//
// GameLevelManager::onRemoveFriendCompleted from 0x6fa540 to 0x6fa828 (744 bytes)
//
// 2 xrefs:
// > GameLevelManager::handleIt @ 0x733224
// > ??> @ 0xbe488
//
// 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
//
__int64 __fastcall GameLevelManager::onRemoveFriendCompleted(GameLevelManager *a1, const void **a2, char **a3)
{
const char *v3; // x21
cocos2d::CCDictionary *m_friendReqAndUserBlocks; // x24
char *v7; // x0
unsigned int SplitIntFromKey; // w21
_QWORD *v9; // x1
_DWORD *v10; // x25
unsigned __int64 v11; // x20
unsigned __int64 v12; // x26
size_t v13; // x2
int v14; // w19
__int64 v15; // x20
__int64 *v16; // x0
UploadActionDelegate *m_uploadActionDelegate; // x0
GJUserScore *v19; // x1
UserInfoDelegate *m_userInfoDelegate; // x0
unsigned int v21; // w19
cocos2d::CCArray *StoredUserList; // x0
cocos2d::CCArray *v23; // x20
UserListDelegate *m_userListDelegate; // x0
unsigned int *v25; // x25
int v26; // w1
unsigned int *v27; // x1
int v28; // w2
void *v29; // [xsp+60h] [xbp+60h] BYREF
v3 = *a3;
m_friendReqAndUserBlocks = a1->m_friendReqAndUserBlocks;
sub_D153B8((int)&v29, *a3);
cocos2d::CCDictionary::removeObjectForKey(m_friendReqAndUserBlocks, (const std::string *)&v29);
v7 = (char *)v29 - 24;
if ( (char *)v29 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v27 = (unsigned int *)((char *)v29 - 8);
do
v28 = __ldaxr(v27);
while ( __stlxr(v28 - 1, v27) );
}
else
{
v28 = *((_DWORD *)v29 - 2);
*((_DWORD *)v29 - 2) = v28 - 1;
}
if ( v28 <= 0 )
operator delete(v7);
}
SplitIntFromKey = GameLevelManager::getSplitIntFromKey(a1, v3, 1);
sub_D153B8((int)&v29, "-1");
v9 = *a2;
v10 = v29;
v11 = *(v9 - 3);
v12 = *((_QWORD *)v29 - 3);
if ( v12 > v11 )
v13 = *(v9 - 3);
else
v13 = *((_QWORD *)v29 - 3);
v14 = memcmp(v9, v29, v13);
if ( v14 || (v14 = 0x7FFFFFFF, v15 = v11 - v12, v15 > 0x7FFFFFFF) )
{
v16 = (__int64 *)(v10 - 6);
if ( v10 - 6 == (_DWORD *)&qword_124B6B0 )
goto LABEL_8;
}
else
{
v16 = (__int64 *)(v10 - 6);
if ( v15 >= (__int64)0xFFFFFFFF80000000LL )
v14 = v15;
else
v14 = 0x80000000;
if ( v16 == &qword_124B6B0 )
goto LABEL_8;
}
if ( &pthread_create )
{
v25 = v10 - 2;
do
v26 = __ldaxr(v25);
while ( __stlxr(v26 - 1, v25) );
}
else
{
v26 = *(v10 - 2);
*(v10 - 2) = v26 - 1;
}
if ( v26 <= 0 )
operator delete(v16);
LABEL_8:
m_uploadActionDelegate = a1->m_uploadActionDelegate;
if ( v14 )
{
if ( m_uploadActionDelegate )
m_uploadActionDelegate->uploadActionFinished(m_uploadActionDelegate, SplitIntFromKey, 33);
v19 = GameLevelManager::userInfoForAccountID(a1, SplitIntFromKey);
if ( v19 )
{
m_userInfoDelegate = a1->m_userInfoDelegate;
v19->m_friendReqStatus = 0;
if ( m_userInfoDelegate )
((void (__fastcall *)(UserInfoDelegate *))m_userInfoDelegate->userInfoChanged)(m_userInfoDelegate);
}
v21 = 0;
StoredUserList = GameLevelManager::getStoredUserList(a1, (UserListType)0);
v23 = StoredUserList;
if ( StoredUserList && (unsigned int)cocos2d::CCArray::count(StoredUserList) )
{
if ( SplitIntFromKey == *(_DWORD *)(cocos2d::CCArray::objectAtIndex(v23, 0) + 344) )
{
LABEL_22:
cocos2d::CCArray::removeObjectAtIndex(v23, v21, 1);
m_userListDelegate = a1->m_userListDelegate;
if ( m_userListDelegate )
m_userListDelegate->userListChanged(m_userListDelegate, v23, (UserListType)0LL);
}
else
{
while ( ++v21 < (unsigned int)cocos2d::CCArray::count(v23) )
{
if ( SplitIntFromKey == *(_DWORD *)(cocos2d::CCArray::objectAtIndex(v23, v21) + 344) )
goto LABEL_22;
}
}
}
}
else if ( m_uploadActionDelegate )
{
m_uploadActionDelegate->uploadActionFailed(m_uploadActionDelegate, SplitIntFromKey, 33);
}
return _stack_chk_guard;
}