//
// GameLevelManager::onGetFriendRequestsCompleted from 0x713290 to 0x713aac (2076 bytes)
//
// 2 xrefs:
// > GameLevelManager::handleIt @ 0x732734
// > ??> @ 0xb4d38
//
// 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::onGetFriendRequestsCompleted(GameLevelManager *a1, const void **a2, char **a3)
{
char *v3; // x19
int SplitIntFromKey; // w28
_DWORD *v7; // x25
unsigned __int64 v8; // x24
unsigned __int64 v9; // x23
size_t v10; // x2
int v11; // w19
__int64 v12; // x23
__int64 *v13; // x0
char *v14; // x19
cocos2d::CCArray *v15; // x19
char *v16; // x0
cocos2d::CCString *v17; // x0
char *CString; // x0
cocos2d::CCString *v19; // x0
char *v20; // x0
cocos2d::CCArray *v21; // x0
FriendRequestDelegate *v22; // x19
void (__fastcall *setupPageInfo)(FriendRequestDelegate *__hidden, std::string, const unsigned __int8 *); // x20
long double v24; // q0
cocos2d::CCArray *v25; // x26
void *v26; // x0
unsigned int v27; // w20
cocos2d::CCString *v28; // x0
char *v29; // x0
char *v30; // x0
GJUserScore *v31; // x19
GJFriendRequest *v32; // x23
bool m_newFriendRequest; // w1
int v34; // w2
int m_accountID; // w0
cocos2d::CCArray *v36; // x0
std::string *p_m_userName; // x1
int m_userID; // w23
int v39; // w19
char *v40; // x0
char *v41; // x0
FriendRequestDelegate *m_friendRequestDelegate; // x0
FriendRequestDelegate *v44; // x0
unsigned int *v45; // x1
int v46; // w2
unsigned int *v47; // x25
int v48; // w1
unsigned int *v49; // x1
int v50; // w2
unsigned int *v51; // x1
int v52; // w2
char *v53; // x0
FriendRequestDelegate *v54; // x0
void *v55; // x0
char *v56; // x0
unsigned int *v57; // x19
int v58; // w1
unsigned int *v59; // x1
int v60; // w2
unsigned int *v61; // x1
int v62; // w2
unsigned int *v63; // x1
int v64; // w2
unsigned int *v65; // x1
int v66; // w2
unsigned int *v67; // x1
int v68; // w2
_QWORD v69[13]; // [xsp+0h] [xbp+0h] BYREF
__int64 *v70; // [xsp+68h] [xbp+68h]
char *v71; // [xsp+70h] [xbp+70h]
cocos2d::CCArray *v72; // [xsp+78h] [xbp+78h]
char *v73; // [xsp+90h] [xbp+90h] BYREF
__int64 v74; // [xsp+98h] [xbp+98h] BYREF
__int64 v75; // [xsp+A0h] [xbp+A0h] BYREF
__int64 v76; // [xsp+A8h] [xbp+A8h] BYREF
char *v77; // [xsp+B0h] [xbp+B0h] BYREF
char *v78; // [xsp+B8h] [xbp+B8h] BYREF
void *v79; // [xsp+C0h] [xbp+C0h] BYREF
v71 = *a3;
v3 = v71;
SplitIntFromKey = GameLevelManager::getSplitIntFromKey(a1, v71, 1);
GameLevelManager::removeDLFromActive(a1, v3);
sub_D153B8((unsigned int)v69 + 192, "-1");
v7 = v79;
v8 = *((_QWORD *)v79 - 3);
v9 = *((_QWORD *)*a2 - 3);
if ( v8 > v9 )
v10 = *((_QWORD *)*a2 - 3);
else
v10 = *((_QWORD *)v79 - 3);
v11 = memcmp(*a2, v79, v10);
if ( v11 || (v11 = 0x7FFFFFFF, v12 = v9 - v8, v12 > 0x7FFFFFFF) )
{
v13 = (__int64 *)(v7 - 6);
if ( v7 - 6 == (_DWORD *)&qword_124B6B0 )
goto LABEL_7;
}
else
{
v13 = (__int64 *)(v7 - 6);
if ( v12 >= (__int64)0xFFFFFFFF80000000LL )
v11 = v12;
else
v11 = 0x80000000;
if ( v13 == &qword_124B6B0 )
goto LABEL_7;
}
if ( &pthread_create )
{
v47 = v7 - 2;
do
v48 = __ldaxr(v47);
while ( __stlxr(v48 - 1, v47) );
}
else
{
v48 = *(v7 - 2);
*(v7 - 2) = v48 - 1;
}
if ( v48 <= 0 )
operator delete(v13);
LABEL_7:
if ( !v11 )
{
LABEL_25:
m_friendRequestDelegate = a1->m_friendRequestDelegate;
if ( m_friendRequestDelegate )
m_friendRequestDelegate->loadFRequestsFailed(
m_friendRequestDelegate,
(const unsigned __int8 *)v71,
(GJErrorCode)0xFFFFFFFFLL);
return _stack_chk_guard;
}
v14 = (char *)*a2;
if ( (atoi((const char *)*a2) & 0x80000000) == 0 )
{
sub_D153B8((unsigned int)v69 + 192, v14);
v15 = sub_6F004C(&v79, "#");
v16 = (char *)v79 - 24;
if ( (char *)v79 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v63 = (unsigned int *)((char *)v79 - 8);
do
v64 = __ldaxr(v63);
while ( __stlxr(v64 - 1, v63) );
}
else
{
v64 = *((_DWORD *)v79 - 2);
*((_DWORD *)v79 - 2) = v64 - 1;
}
if ( v64 <= 0 )
operator delete(v16);
}
if ( (unsigned int)cocos2d::CCArray::count(v15) > 1 )
{
v17 = (cocos2d::CCString *)cocos2d::CCArray::objectAtIndex(v15, 0);
CString = (char *)cocos2d::CCString::getCString(v17);
sub_D153B8((int)&v73, CString);
v19 = (cocos2d::CCString *)cocos2d::CCArray::objectAtIndex(v15, 1u);
v20 = (char *)cocos2d::CCString::getCString(v19);
v70 = &v74;
v21 = (cocos2d::CCArray *)sub_D153B8((int)&v74, v20);
v22 = a1->m_friendRequestDelegate;
if ( v22 )
{
setupPageInfo = v22->setupPageInfo;
*(__n128 *)&v24 = sub_D18D28(&v75, &v74);
((void (__fastcall *)(FriendRequestDelegate *, __int64 *, char *, long double))setupPageInfo)(
v22,
&v75,
v71,
v24);
v21 = (cocos2d::CCArray *)(v75 - 24);
if ( (__int64 *)(v75 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v61 = (unsigned int *)(v75 - 8);
do
v62 = __ldaxr(v61);
while ( __stlxr(v62 - 1, v61) );
}
else
{
v62 = *(_DWORD *)(v75 - 8);
*(_DWORD *)(v75 - 8) = v62 - 1;
}
if ( v62 <= 0 )
operator delete(v21);
}
}
v72 = (cocos2d::CCArray *)cocos2d::CCArray::create(v21);
v69[12] = &v76;
sub_D153B8((int)&v76, v73);
v25 = sub_6F004C(&v76, "|");
v26 = (void *)(v76 - 24);
if ( (__int64 *)(v76 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v59 = (unsigned int *)(v76 - 8);
do
v60 = __ldaxr(v59);
while ( __stlxr(v60 - 1, v59) );
}
else
{
v60 = *(_DWORD *)(v76 - 8);
*(_DWORD *)(v76 - 8) = v60 - 1;
}
if ( v60 <= 0 )
operator delete(v26);
}
v27 = 0;
while ( v27 < (unsigned int)cocos2d::CCArray::count(v25) )
{
v28 = (cocos2d::CCString *)cocos2d::CCArray::objectAtIndex(v25, v27);
v29 = (char *)cocos2d::CCString::getCString(v28);
sub_D153B8((int)&v79, v29);
sub_D18D28(&v77, &v79);
GameLevelManager::responseToDict(&v77, 0);
v30 = v77 - 24;
if ( v77 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v49 = (unsigned int *)(v77 - 8);
do
v50 = __ldaxr(v49);
while ( __stlxr(v50 - 1, v49) );
}
else
{
v50 = *((_DWORD *)v77 - 2);
*((_DWORD *)v77 - 2) = v50 - 1;
}
if ( v50 <= 0 )
operator delete(v30);
}
v31 = GJUserScore::create();
if ( v31 )
{
v32 = GJFriendRequest::create();
if ( v32 )
{
m_newFriendRequest = v31->m_newFriendRequest;
v34 = SplitIntFromKey ? 4 : 3;
m_accountID = v31->m_accountID;
v31->m_friendReqStatus = v34;
v32->m_accountID = m_accountID;
v36 = v72;
v32->m_isRead = !m_newFriendRequest;
cocos2d::CCArray::addObject(v36, v31);
GameLevelManager::storeFriendRequest(a1, v32);
p_m_userName = &v31->m_userName;
m_userID = v31->m_userID;
v39 = v31->m_accountID;
sub_D18D28(&v78, p_m_userName);
GameLevelManager::storeUserName(a1, m_userID, v39, &v78);
v40 = v78 - 24;
if ( v78 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v51 = (unsigned int *)(v78 - 8);
do
v52 = __ldaxr(v51);
while ( __stlxr(v52 - 1, v51) );
}
else
{
v52 = *((_DWORD *)v78 - 2);
*((_DWORD *)v78 - 2) = v52 - 1;
}
if ( v52 <= 0 )
operator delete(v40);
}
}
}
v41 = (char *)v79 - 24;
if ( (char *)v79 - 24 == (char *)&qword_124B6B0 )
goto LABEL_24;
if ( &pthread_create )
{
v45 = (unsigned int *)((char *)v79 - 8);
do
v46 = __ldaxr(v45);
while ( __stlxr(v46 - 1, v45) );
}
else
{
v46 = *((_DWORD *)v79 - 2);
*((_DWORD *)v79 - 2) = v46 - 1;
}
if ( v46 > 0 )
{
LABEL_24:
++v27;
}
else
{
++v27;
operator delete(v41);
}
}
sub_D18D28(&v79, v70);
GameLevelManager::storeCommentsResult(a1, v72, (char **)&v79, v71);
v53 = (char *)v79 - 24;
if ( (char *)v79 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v65 = (unsigned int *)((char *)v79 - 8);
do
v66 = __ldaxr(v65);
while ( __stlxr(v66 - 1, v65) );
}
else
{
v66 = *((_DWORD *)v79 - 2);
*((_DWORD *)v79 - 2) = v66 - 1;
}
if ( v66 <= 0 )
operator delete(v53);
}
v54 = a1->m_friendRequestDelegate;
if ( v54 )
v54->loadFRequestsFinished(v54, v72, (const unsigned __int8 *)v71);
v55 = (void *)(v74 - 24);
if ( (__int64 *)(v74 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v67 = (unsigned int *)(v74 - 8);
do
v68 = __ldaxr(v67);
while ( __stlxr(v68 - 1, v67) );
}
else
{
v68 = *(_DWORD *)(v74 - 8);
*(_DWORD *)(v74 - 8) = v68 - 1;
}
if ( v68 <= 0 )
operator delete(v55);
}
v56 = v73 - 24;
if ( v73 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v57 = (unsigned int *)(v73 - 8);
do
v58 = __ldaxr(v57);
while ( __stlxr(v58 - 1, v57) );
}
else
{
v58 = *((_DWORD *)v73 - 2);
*((_DWORD *)v73 - 2) = v58 - 1;
}
if ( v58 <= 0 )
operator delete(v56);
}
return _stack_chk_guard;
}
goto LABEL_25;
}
v44 = a1->m_friendRequestDelegate;
if ( v44 )
v44->loadFRequestsFailed(v44, (const unsigned __int8 *)v71, NotFound);
return _stack_chk_guard;
}