//
// ProfilePage::onFriend from 0xa569d4 to 0xa56d58 (900 bytes)
//
// 3 xrefs:
// > ??> @ 0x7fc90
// > ProfilePage::setupAccountButtons @ 0xa54070
// > ??> @ 0x15434f0
//
// This function is hookable on this platform (idp: arm, 32 bit: False, 64 bit: True!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 13:00:08 +0000
//
__int64 __fastcall ProfilePage::onFriend(ProfilePage *this, cocos2d::CCObject *a2)
{
__int64 v3; // x0
GJAccountManager *v4; // x0
__int64 v5; // x1
GameLevelManager *v6; // x0
int v8; // w23
__int64 v9; // x22
cocos2d::CCDictionary **v10; // x0
FriendRequestPopup *v11; // x0
__int64 v12; // x0
GJAccountManager *v13; // x0
char *v14; // x20
__int64 v15; // x2
__int64 v16; // x1
__int64 UnfriendAlert; // x20
cocos2d::CCDictionary **v18; // x0
FriendRequestPopup *v19; // x0
__int64 v20; // x0
ButtonSprite **v21; // x20
__int64 v22[2]; // [xsp+48h] [xbp+48h] BYREF
void *v23; // [xsp+58h] [xbp+58h]
__int64 v24; // [xsp+60h] [xbp+60h] BYREF
__int64 v25; // [xsp+68h] [xbp+68h]
void *v26; // [xsp+70h] [xbp+70h]
v3 = GJAccountManager::sharedState(_stack_chk_guard);
v4 = (GJAccountManager *)(unsigned int)(*(_DWORD *)(v3 + 352) - *(_DWORD *)(v3 + 356));
if ( (int)v4 <= 0 )
{
v13 = (GJAccountManager *)GJAccountManager::sharedState(v4);
GJAccountManager::showAccountNeededAlert(v13, "add friends");
}
else
{
*(_QWORD *)(GameLevelManager::sharedState(v4) + 1352) = (char *)this + 688;
v5 = *((_QWORD *)this + 91);
v6 = (GameLevelManager *)*(unsigned int *)(v5 + 688);
if ( (_DWORD)v6 )
{
switch ( (_DWORD)v6 )
{
case 4:
v10 = (cocos2d::CCDictionary **)GameLevelManager::sharedState(v6);
v11 = (FriendRequestPopup *)GameLevelManager::friendRequestFromAccountID(
v10,
*(_DWORD *)(*((_QWORD *)this + 91) + 376LL));
if ( v11 )
{
v12 = FriendRequestPopup::create(v11, (GJFriendRequest *)((char *)&dword_0 + 1));
(*(void (__fastcall **)(__int64))(*(_QWORD *)v12 + 1312LL))(v12);
}
else
{
v24 = 0;
v25 = 0;
v26 = nullptr;
std::string::__init(&v24, "Are you sure you want to remove this friend request?", 0x34u);
v21 = (ButtonSprite **)FLAlertLayer::create(
(__int64)this + 664,
(cocos2d::CCLabelBMFont *)"Cancel friend request",
(char *)&v24,
(ButtonSprite *)"Back",
(ButtonSprite *)"Remove",
0,
380.0,
0.0,
1.0);
if ( (v24 & 1) != 0 )
operator delete(v26);
(*((void (__fastcall **)(ButtonSprite **, __int64))*v21 + 9))(v21, 1);
ButtonSprite::updateBGImage(v21[77], "GJ_button_06.png");
(*((void (__fastcall **)(ButtonSprite **))*v21 + 164))(v21);
}
break;
case 3:
v18 = (cocos2d::CCDictionary **)GameLevelManager::sharedState(v6);
v19 = (FriendRequestPopup *)GameLevelManager::friendRequestFromAccountID(
v18,
*(_DWORD *)(*((_QWORD *)this + 91) + 376LL));
*(_BYTE *)(*((_QWORD *)this + 91) + 724LL) = 0;
v20 = FriendRequestPopup::create(v19, nullptr);
(*(void (__fastcall **)(__int64))(*(_QWORD *)v20 + 1312LL))(v20);
break;
case 1:
v24 = 0;
v14 = (char *)this + 664;
v25 = 0;
v26 = nullptr;
v15 = v5 + 320;
if ( (*(_BYTE *)(v5 + 320) & 1) != 0 )
{
std::string::__init(&v24, *(void **)(v5 + 336), *(_QWORD *)(v5 + 328));
}
else
{
v16 = *(_QWORD *)(v5 + 328);
v24 = *(_QWORD *)v15;
v25 = v16;
v26 = *(void **)(v15 + 16);
}
UnfriendAlert = ProfilePage::createUnfriendAlert((__int64)v14, (char *)&v24);
if ( (v24 & 1) != 0 )
operator delete(v26);
(*(void (__fastcall **)(__int64, __int64))(*(_QWORD *)UnfriendAlert + 72LL))(UnfriendAlert, 2);
(*(void (__fastcall **)(__int64))(*(_QWORD *)UnfriendAlert + 1312LL))(UnfriendAlert);
break;
}
}
else
{
v22[0] = 0;
v22[1] = 0;
v23 = nullptr;
std::string::__init(v22, "Friend Request", 0xEu);
v8 = *((_DWORD *)this + 184);
v24 = 0;
v25 = 0;
v26 = nullptr;
std::string::__init(&v24, &byte_11B8890, 0);
v9 = ShareCommentLayer::create((char *)v22, 140, 2u, v8, (char *)&v24);
if ( (v24 & 1) != 0 )
operator delete(v26);
if ( (v22[0] & 1) != 0 )
operator delete(v23);
if ( *(_DWORD *)(*((_QWORD *)this + 91) + 440LL) != 2 )
{
v24 = 0;
v25 = 0;
v26 = nullptr;
std::string::__init(&v24, "This user does not accept messages in friend requests.", 0x3Eu);
ShareCommentLayer::lockInput(v9, (__int64)&v24);
if ( (v24 & 1) != 0 )
operator delete(v26);
}
(*(void (__fastcall **)(__int64))(*(_QWORD *)v9 + 1312LL))(v9);
}
}
return _stack_chk_guard;
}