//
// GameLevelManager::onAcceptFriendRequestCompleted from 0x6fae3c to 0x6fb0d0 (660 bytes)
//
// 2 xrefs:
// > GameLevelManager::handleIt @ 0x732b24
// > ??> @ 0xb6b20
//
// 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::onAcceptFriendRequestCompleted(GameLevelManager *a1, const void **a2, char **a3)
{
const char *v3; // x21
cocos2d::CCDictionary *m_friendReqAndUserBlocks; // x23
char *v7; // x0
int SplitIntFromKey; // w25
unsigned int v9; // w24
_DWORD *v10; // x26
_QWORD *v11; // x1
unsigned __int64 v12; // x27
unsigned __int64 v13; // x21
size_t v14; // x2
int v15; // w19
__int64 v16; // x21
__int64 *v17; // x0
UploadActionDelegate *v18; // x0
GJUserScore *v20; // x1
UserInfoDelegate *m_userInfoDelegate; // x0
UploadActionDelegate *m_uploadActionDelegate; // x0
unsigned int *v23; // x26
int v24; // w1
unsigned int *v25; // x1
int v26; // w2
void *v27; // [xsp+70h] [xbp+70h] BYREF
v3 = *a3;
m_friendReqAndUserBlocks = a1->m_friendReqAndUserBlocks;
sub_D153B8((int)&v27, *a3);
cocos2d::CCDictionary::removeObjectForKey(m_friendReqAndUserBlocks, (const std::string *)&v27);
v7 = (char *)v27 - 24;
if ( (char *)v27 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v25 = (unsigned int *)((char *)v27 - 8);
do
v26 = __ldaxr(v25);
while ( __stlxr(v26 - 1, v25) );
}
else
{
v26 = *((_DWORD *)v27 - 2);
*((_DWORD *)v27 - 2) = v26 - 1;
}
if ( v26 <= 0 )
operator delete(v7);
}
SplitIntFromKey = GameLevelManager::getSplitIntFromKey(a1, v3, 1);
v9 = GameLevelManager::getSplitIntFromKey(a1, v3, 2);
sub_D153B8((int)&v27, "-1");
v10 = v27;
v11 = *a2;
v12 = *((_QWORD *)v27 - 3);
v13 = *(v11 - 3);
if ( v12 > v13 )
v14 = *(v11 - 3);
else
v14 = *((_QWORD *)v27 - 3);
v15 = memcmp(v11, v27, v14);
if ( v15 || (v15 = 0x7FFFFFFF, v16 = v13 - v12, v16 > 0x7FFFFFFF) )
{
v17 = (__int64 *)(v10 - 6);
if ( v10 - 6 == (_DWORD *)&qword_124B6B0 )
goto LABEL_8;
}
else
{
v17 = (__int64 *)(v10 - 6);
if ( v16 >= (__int64)0xFFFFFFFF80000000LL )
v15 = v16;
else
v15 = 0x80000000;
if ( v17 == &qword_124B6B0 )
goto LABEL_8;
}
if ( &pthread_create )
{
v23 = v10 - 2;
do
v24 = __ldaxr(v23);
while ( __stlxr(v24 - 1, v23) );
}
else
{
v24 = *(v10 - 2);
*(v10 - 2) = v24 - 1;
}
if ( v24 <= 0 )
operator delete(v17);
LABEL_8:
if ( v15 )
{
v20 = GameLevelManager::userInfoForAccountID(a1, SplitIntFromKey);
if ( v20 )
{
m_userInfoDelegate = a1->m_userInfoDelegate;
v20->m_friendReqStatus = 1;
if ( m_userInfoDelegate )
((void (__fastcall *)(UserInfoDelegate *))m_userInfoDelegate->userInfoChanged)(m_userInfoDelegate);
}
m_uploadActionDelegate = a1->m_uploadActionDelegate;
if ( m_uploadActionDelegate )
m_uploadActionDelegate->uploadActionFinished(m_uploadActionDelegate, v9, 31);
GameLevelManager::friendRequestWasRemoved(a1, SplitIntFromKey, 0);
GameLevelManager::resetStoredUserList(a1, (UserListType)0);
}
else
{
v18 = a1->m_uploadActionDelegate;
if ( v18 )
v18->uploadActionFailed(v18, v9, 31);
}
return _stack_chk_guard;
}