//
// GameLevelManager::onUploadFriendRequestCompleted from 0x6fa060 to 0x6fa2d0 (624 bytes)
//
// 2 xrefs:
// > GameLevelManager::handleIt @ 0x733144
// > ??> @ 0x36de0
//
// 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::onUploadFriendRequestCompleted(GameLevelManager *a1, const void **a2, char **a3)
{
const char *v4; // x24
cocos2d::CCDictionary *m_friendReqAndUserBlocks; // x23
char *v7; // x0
unsigned int SplitIntFromKey; // w25
_QWORD *v9; // x1
_DWORD *v10; // x26
unsigned __int64 v11; // x20
unsigned __int64 v12; // x27
size_t v13; // x2
int v14; // w19
__int64 v15; // x20
__int64 *v16; // x0
UploadActionDelegate *v17; // x0
GJUserScore *v19; // x1
UserInfoDelegate *m_userInfoDelegate; // x0
UploadActionDelegate *m_uploadActionDelegate; // x0
unsigned int *v22; // x26
int v23; // w1
unsigned int *v24; // x1
int v25; // w2
void *v26; // [xsp+70h] [xbp+70h] BYREF
v4 = *a3;
m_friendReqAndUserBlocks = a1->m_friendReqAndUserBlocks;
sub_D153B8((int)&v26, *a3);
cocos2d::CCDictionary::removeObjectForKey(m_friendReqAndUserBlocks, (const std::string *)&v26);
v7 = (char *)v26 - 24;
if ( (char *)v26 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v24 = (unsigned int *)((char *)v26 - 8);
do
v25 = __ldaxr(v24);
while ( __stlxr(v25 - 1, v24) );
}
else
{
v25 = *((_DWORD *)v26 - 2);
*((_DWORD *)v26 - 2) = v25 - 1;
}
if ( v25 <= 0 )
operator delete(v7);
}
SplitIntFromKey = GameLevelManager::getSplitIntFromKey(a1, v4, 1);
sub_D153B8((int)&v26, "-1");
v9 = *a2;
v10 = v26;
v11 = *(v9 - 3);
v12 = *((_QWORD *)v26 - 3);
if ( v12 > v11 )
v13 = *(v9 - 3);
else
v13 = *((_QWORD *)v26 - 3);
v14 = memcmp(v9, v26, 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 )
{
v22 = v10 - 2;
do
v23 = __ldaxr(v22);
while ( __stlxr(v23 - 1, v22) );
}
else
{
v23 = *(v10 - 2);
*(v10 - 2) = v23 - 1;
}
if ( v23 <= 0 )
operator delete(v16);
LABEL_8:
if ( v14 )
{
v19 = GameLevelManager::userInfoForAccountID(a1, SplitIntFromKey);
if ( v19 )
{
m_userInfoDelegate = a1->m_userInfoDelegate;
v19->m_friendReqStatus = 4;
if ( m_userInfoDelegate )
((void (__fastcall *)(UserInfoDelegate *))m_userInfoDelegate->userInfoChanged)(m_userInfoDelegate);
}
m_uploadActionDelegate = a1->m_uploadActionDelegate;
if ( m_uploadActionDelegate )
m_uploadActionDelegate->uploadActionFinished(m_uploadActionDelegate, SplitIntFromKey, 29);
}
else
{
v17 = a1->m_uploadActionDelegate;
if ( v17 )
v17->uploadActionFailed(v17, SplitIntFromKey, 29);
GameLevelManager::resetTimerForKey(a1, v4);
}
return _stack_chk_guard;
}