//
// ProfilePage::onFriend from 0x8fd168 to 0x8fd55c (1012 bytes)
//
// 3 xrefs:
// > ??> @ 0x5d5d0
// > ProfilePage::loadPageFromUserInfo @ 0x8fa6c4
// > ??> @ 0x122b048
//
// This function is hookable on this platform!
//
// Using BromaIDA 8.0.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit ba9f177b at Thu Jul 16 22:52:06 2026 from https://github.com/geode-sdk/bindings
//
void ProfilePage::onFriend(ProfilePage *a1, cocos2d::CCObject *a2)
{
GJAccountManager *v3; // x0
int m_friendReqStatus; // w0
int m_accountID; // w20
__int64 v6; // x22
void *v7; // x0
void *v8; // x0
FLAlertLayer *v9; // x20
void *v10; // x0
FLAlertLayer_vtbl *v11; // x2
FLAlertLayer *v12; // x0
__int64 v13; // x1
void *v14; // x0
GameLevelManager *v15; // x0
GJFriendRequest *v16; // x0
FriendRequestPopup *v17; // x0
unsigned int *v18; // x1
int v19; // w2
unsigned int *v20; // x1
int v21; // w2
unsigned int *v22; // x2
int v23; // w1
unsigned int *v24; // x2
int v25; // w1
__int64 v26; // [xsp+48h] [xbp+48h] BYREF
__int64 v27; // [xsp+50h] [xbp+50h] BYREF
v3 = GJAccountManager::sharedState();
if ( v3->m_accountID - v3->m_unkInt1 <= 0 )
{
ProfilePage::showNoAccountError(a1);
return;
}
m_friendReqStatus = a1->m_score->m_friendReqStatus;
switch ( m_friendReqStatus )
{
case 0:
sub_D153B8((int)&v26, "Friend request");
m_accountID = a1->m_accountID;
sub_D153B8((int)&v27, &byte_F288A0);
v6 = ShareCommentLayer::create((__int64)&v26, 140, 2, m_accountID);
v7 = (void *)(v27 - 24);
if ( (__int64 *)(v27 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v20 = (unsigned int *)(v27 - 8);
do
v21 = __ldaxr(v20);
while ( __stlxr(v21 - 1, v20) );
}
else
{
v21 = *(_DWORD *)(v27 - 8);
*(_DWORD *)(v27 - 8) = v21 - 1;
}
if ( v21 <= 0 )
operator delete(v7);
}
v8 = (void *)(v26 - 24);
if ( (__int64 *)(v26 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v18 = (unsigned int *)(v26 - 8);
do
v19 = __ldaxr(v18);
while ( __stlxr(v19 - 1, v18) );
}
else
{
v19 = *(_DWORD *)(v26 - 8);
*(_DWORD *)(v26 - 8) = v19 - 1;
}
if ( v19 <= 0 )
operator delete(v8);
}
(*(void (__fastcall **)(__int64))(*(_QWORD *)v6 + 1288LL))(v6);
return;
case 4:
sub_D153B8((int)&v27, "Are you sure you want to remove this friend request?");
v9 = FLAlertLayer::create((int)a1 + 632, (__int64)"Cancel friend request", (__int64)&v27);
v14 = (void *)(v27 - 24);
if ( (__int64 *)(v27 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v24 = (unsigned int *)(v27 - 8);
do
v25 = __ldaxr(v24);
while ( __stlxr(v25 - 1, v24) );
}
else
{
v25 = *(_DWORD *)(v27 - 8);
*(_DWORD *)(v27 - 8) = v25 - 1;
}
if ( v25 <= 0 )
operator delete(v14);
}
v11 = v9->cocos2d::CCLayerColor::cocos2d::CCLayerRGBA::cocos2d::CCLayer::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
v12 = v9;
v13 = 1;
goto LABEL_12;
case 3:
v15 = GameLevelManager::sharedState();
v16 = GameLevelManager::friendRequestFromAccountID(v15, a1->m_score->m_accountID);
a1->m_score->m_newFriendRequest = 0;
v17 = FriendRequestPopup::create(v16);
v17->show(v17);
return;
case 1:
sub_D153B8((int)&v27, "Are you sure you want to remove this friend?");
v9 = FLAlertLayer::create((int)a1 + 632, (__int64)"Unfriend", (__int64)&v27);
v10 = (void *)(v27 - 24);
if ( (__int64 *)(v27 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v22 = (unsigned int *)(v27 - 8);
do
v23 = __ldaxr(v22);
while ( __stlxr(v23 - 1, v22) );
}
else
{
v23 = *(_DWORD *)(v27 - 8);
*(_DWORD *)(v27 - 8) = v23 - 1;
}
if ( v23 <= 0 )
operator delete(v10);
}
v11 = v9->cocos2d::CCLayerColor::cocos2d::CCLayerRGBA::cocos2d::CCLayer::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
v12 = v9;
v13 = 2;
LABEL_12:
v11->setTag(v12, v13);
ButtonSprite::updateBGImage(v9->m_button2, "GJ_button_06.png");
v9->show(v9);
break;
}
}