//
// ProfilePage::onFriend from 0x140556e40 to 0x1405573dd (1437 bytes)
//
// 2 xrefs:
// > ProfilePage::setupAccountButtons @ 0x1405526ed
// > ??> @ 0x14092bebc
//
// This function is hookable on this platform (idp: pc, 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 11:34:11 +0000
//
// Hidden C++ exception states: #wind=8
__int64 __fastcall ProfilePage::onFriend(__int64 a1)
{
__int64 v2; // rax
__int64 v3; // rcx
__int64 result; // rax
__int64 v5; // rdi
__int64 v6; // rcx
__int64 v7; // rdx
__int64 v8; // rsi
_QWORD *v9; // rbx
__int64 v10; // rcx
__int64 v11; // rcx
size_t v12; // r8
const struct cocos2d::CCPoint *v13; // rax
const struct cocos2d::CCPoint *v14; // rbx
float *v15; // rax
char *v16; // rdi
__int64 v17; // rbx
__int64 v18; // rax
void *v19; // rcx
struct cocos2d::CCObject *v20; // rax
unsigned __int8 v21; // dl
_QWORD *v22; // rax
__int64 v23; // rdi
__int64 *v24; // rbx
__int64 v25; // rax
__int64 UnfriendAlert; // rbx
void *v27; // [rsp+50h] [rbp-59h]
void *v28; // [rsp+50h] [rbp-59h]
__int128 v29; // [rsp+58h] [rbp-51h] BYREF
__int64 v30; // [rsp+68h] [rbp-41h]
__int64 v31; // [rsp+70h] [rbp-39h]
__int128 *v32; // [rsp+78h] [rbp-31h] BYREF
__int128 v33; // [rsp+80h] [rbp-29h] BYREF
__int64 v34; // [rsp+90h] [rbp-19h]
__int64 v35; // [rsp+98h] [rbp-11h]
__int128 v36; // [rsp+A0h] [rbp-9h] BYREF
__int64 v37; // [rsp+B0h] [rbp+7h]
__int64 v38; // [rsp+B8h] [rbp+Fh]
void *Block[2]; // [rsp+C0h] [rbp+17h] BYREF
__int64 v40; // [rsp+D0h] [rbp+27h]
unsigned __int64 v41; // [rsp+D8h] [rbp+2Fh]
v2 = GJAccountManager::sharedState();
if ( *(_DWORD *)(v2 + 360) - *(_DWORD *)(v2 + 364) <= 0 )
{
GJAccountManager::sharedState();
return GJAccountManager::showAccountNeededAlert(v3, "add friends");
}
v5 = a1 + 688;
if ( !a1 )
v5 = 0;
v6 = *(_QWORD *)&qword_14090BFB0;
if ( !*(_QWORD *)&qword_14090BFB0 )
{
v27 = operator new(0x690u);
*(_QWORD *)&qword_14090BFB0 = GameLevelManager::GameLevelManager((__int64)v27);
(*(void (__fastcall **)(_QWORD))(**(_QWORD **)&qword_14090BFB0 + 72LL))(*(_QWORD *)&qword_14090BFB0);
v6 = *(_QWORD *)&qword_14090BFB0;
}
*(_QWORD *)(v6 + 1480) = v5;
v7 = *(_QWORD *)(a1 + 728);
result = *(unsigned int *)(v7 + 760);
switch ( (_DWORD)result )
{
case 0:
v33 = 0;
v34 = 0;
v35 = 15;
LOBYTE(v33) = 0;
v30 = 14;
v31 = 15;
qmemcpy(&v29, "Friend Reque", 12);
HIDWORD(v29) = *(unsigned __int16 *)"st";
v8 = ShareCommentLayer::create((unsigned int)&v29, 140, 2, *(_DWORD *)(a1 + 736), (__int64)&v33);
if ( *(_DWORD *)(*(_QWORD *)(a1 + 728) + 456LL) != 2 )
{
*(_OWORD *)Block = 0;
v9 = sub_14003D460(0x40u);
Block[0] = v9;
v40 = 62;
v41 = 63;
strcpy((char *)v9, "This user does not accept messages in friend requests.");
(*(void (__fastcall **)(_QWORD, _QWORD))(**(_QWORD **)(v8 + 704) + 336LL))(*(_QWORD *)(v8 + 704), 0);
(*(void (__fastcall **)(_QWORD, _QWORD))(**(_QWORD **)(v8 + 704) + 920LL))(*(_QWORD *)(v8 + 704), 0);
v10 = *(_QWORD *)(v8 + 712);
if ( v10 )
(*(void (__fastcall **)(__int64, _QWORD))(*(_QWORD *)v10 + 336LL))(v10, 0);
v11 = *(_QWORD *)(v8 + 792);
if ( v11 )
(*(void (__fastcall **)(__int64, _QWORD))(*(_QWORD *)v11 + 336LL))(v11, 0);
v36 = 0;
v37 = 0;
v38 = 0;
v12 = -1;
do
++v12;
while ( *((_BYTE *)v9 + v12) );
sub_14003D230(&v36, v9, v12);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v32, 0.5, 0.5);
v14 = v13;
v15 = (float *)(*(__int64 (__fastcall **)(_QWORD))(**(_QWORD **)(v8 + 704) + 320LL))(*(_QWORD *)(v8 + 704));
v16 = TextArea::create(
(__int64)&v36,
"chatFont.fnt",
1.0,
(float)((float)(*v15 - 40.0) * 1.1) / 0.80000001,
v14,
1101004800,
0,
0);
(*(void (__fastcall **)(char *))(*(_QWORD *)v16 + 160LL))(v16);
v17 = *(_QWORD *)v16;
v18 = (*(__int64 (__fastcall **)(_QWORD))(**(_QWORD **)(v8 + 704) + 200LL))(*(_QWORD *)(v8 + 704));
(*(void (__fastcall **)(char *, __int64))(v17 + 184))(v16, v18);
(*(void (__fastcall **)(_QWORD, char *, __int64))(**(_QWORD **)(v8 + 584) + 456LL))(
*(_QWORD *)(v8 + 584),
v16,
2);
if ( v41 > 0xF )
{
v19 = Block[0];
if ( v41 + 1 >= 0x1000 )
{
v19 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v19 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v19);
}
}
return (*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v8 + 1064LL))(v8);
case 4:
v20 = cocos2d::CCDictionary::objectForKey(*(cocos2d::CCDictionary **)(v6 + 1240), *(int *)(v7 + 392));
if ( v20 )
{
v21 = 1;
LABEL_24:
v22 = FriendRequestPopup::create((__int64)v20, v21);
return (*(__int64 (__fastcall **)(_QWORD *))(*v22 + 1064LL))(v22);
}
v23 = a1 + 664;
v29 = 0;
*(_QWORD *)&v29 = sub_14003D460(0x40u);
v30 = 52;
v31 = 63;
strcpy((char *)v29, "Are you sure you want to remove this friend request?");
v32 = &v29;
v28 = operator new(0x298u);
v24 = (__int64 *)FLAlertLayer::FLAlertLayer((__int64)v28);
if ( v24 )
{
v25 = sub_14003F4F0((__int64)Block, (__int64)&v29);
if ( FLAlertLayer::init(
(cocos2d::CCLayerColor *)v24,
v23,
"Cancel friend request",
v25,
(__int64)"Back",
(__int64)"Remove",
380.0,
0,
0,
1.0) )
{
cocos2d::CCObject::autorelease((cocos2d::CCObject *)v24);
}
else
{
(*(void (__fastcall **)(__int64 *, __int64))(*v24 + 8))(v24, 1);
v24 = nullptr;
}
}
sub_14003D310((__int64)&v29);
(*(void (__fastcall **)(__int64 *, __int64))(*v24 + 64))(v24, 1);
ButtonSprite::updateBGImage(v24[77], "GJ_button_06.png");
return (*(__int64 (__fastcall **)(__int64 *))(*v24 + 1064))(v24);
case 3:
v20 = cocos2d::CCDictionary::objectForKey(*(cocos2d::CCDictionary **)(v6 + 1240), *(int *)(v7 + 392));
*(_BYTE *)(*(_QWORD *)(a1 + 728) + 796LL) = 0;
v21 = 0;
goto LABEL_24;
case 1:
sub_14003F4F0((__int64)Block, v7 + 320);
UnfriendAlert = ProfilePage::createUnfriendAlert(a1 + 664, Block);
(*(void (__fastcall **)(__int64, __int64))(*(_QWORD *)UnfriendAlert + 64LL))(UnfriendAlert, 2);
return (*(__int64 (__fastcall **)(__int64))(*(_QWORD *)UnfriendAlert + 1064LL))(UnfriendAlert);
}
return result;
}