//
// GameLevelManager::onGetFriendRequestsCompleted from 0x100524450 to 0x100524b9c (1868 bytes)
//
// 1 xrefs:
// > GameLevelManager::handleIt @ 0x10051bc4e
//
// 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 __fastcall GameLevelManager::onGetFriendRequestsCompleted(
GameLevelManager *a1,
unsigned __int8 *a2,
__int64 a3,
__m128 a4)
{
const char *v4; // rbx
GameLevelManager *v5; // r13
char v6; // r15
unsigned __int64 v7; // rax
const char *v8; // r12
const char *v9; // rdi
size_t v10; // rdx
FriendRequestDelegate *m_friendRequestDelegate; // rdi
size_t v12; // rax
size_t v13; // rbx
char *v14; // r14
FriendRequestDelegate *v15; // rdi
size_t v16; // r15
__int64 v17; // r12
GameLevelManager *v18; // rbx
FriendRequestDelegate *v19; // rdi
cocos2d::CCString *v20; // rax
const char *CString; // r14
size_t v22; // rax
size_t v23; // rbx
char *v24; // r15
size_t v25; // r13
__int64 v26; // rsi
cocos2d::CCString *v27; // rax
const char *v28; // rbx
void *v29; // rdi
size_t v30; // rax
size_t v31; // r14
char *v32; // r12
size_t v33; // r15
FriendRequestDelegate *v34; // rbx
const char *v35; // r12
size_t v36; // rax
size_t v37; // rbx
char *v38; // r14
size_t v39; // r15
unsigned int i; // r15d
cocos2d::CCString *v41; // rax
const char *v42; // r14
size_t v43; // rax
size_t v44; // rbx
char *v45; // r12
char v46; // r13
__int64 v47; // rax
size_t v48; // r13
cocos2d::CCDictionary *v49; // rbx
GJUserScore *v50; // r14
GJFriendRequest *v51; // rax
cocos2d::CCObject *v52; // rbx
intptr_t m_unknown2; // rdx
unsigned int m_userID; // ebx
unsigned int m_accountID; // r12d
std::string *p_m_userName; // r14
char v57; // bl
FriendRequestDelegate *v58; // rdi
__int128 v59; // [rsp+0h] [rbp-110h] BYREF
void *v60; // [rsp+10h] [rbp-100h]
__int128 v61; // [rsp+20h] [rbp-F0h] BYREF
void *v62; // [rsp+30h] [rbp-E0h]
__m128 v63; // [rsp+40h] [rbp-D0h] BYREF
void *longStorage; // [rsp+50h] [rbp-C0h]
__int128 v65; // [rsp+60h] [rbp-B0h] BYREF
void *v66; // [rsp+70h] [rbp-A0h]
__int64 v67; // [rsp+78h] [rbp-98h]
__int64 v68; // [rsp+80h] [rbp-90h]
__int128 __dst; // [rsp+88h] [rbp-88h] BYREF
void *v70; // [rsp+98h] [rbp-78h]
const char *v71; // [rsp+A0h] [rbp-70h]
__int128 v72; // [rsp+A8h] [rbp-68h] BYREF
void *v73; // [rsp+B8h] [rbp-58h]
unsigned int SplitIntFromKey; // [rsp+C4h] [rbp-4Ch]
size_t __s2; // [rsp+C8h] [rbp-48h] BYREF
size_t v76; // [rsp+D0h] [rbp-40h]
void *__p; // [rsp+D8h] [rbp-38h]
GameLevelManager *v78; // [rsp+E0h] [rbp-30h]
v78 = a1;
if ( (*(_BYTE *)a3 & 1) != 0 )
v4 = *(const char **)(a3 + 16);
else
v4 = (const char *)(a3 + 1);
SplitIntFromKey = GameLevelManager::getSplitIntFromKey(a1, v4, 1);
v5 = v78;
v71 = v4;
GameLevelManager::removeDLFromActive(v78, v4);
LOBYTE(__s2) = 4;
*(_WORD *)((char *)&__s2 + 1) = 12589;
BYTE3(__s2) = 0;
v6 = *a2;
v7 = *a2 >> 1;
v8 = *((const char **)a2 + 2);
v9 = v8;
if ( (*a2 & 1) == 0 )
v9 = (const char *)(a2 + 1);
if ( (v6 & 1) != 0 )
v7 = *((_QWORD *)a2 + 1);
v10 = 2;
if ( v7 < 2 )
v10 = v7;
if ( !((v7 != 2) | (memcmp(v9, (char *)&__s2 + 1, v10) != 0)) )
{
m_friendRequestDelegate = v5->m_friendRequestDelegate;
if ( m_friendRequestDelegate )
((void (__fastcall *)(FriendRequestDelegate *, const char *, __int64))m_friendRequestDelegate->loadFRequestsFailed)(
m_friendRequestDelegate,
v71,
0xFFFFFFFFLL);
return;
}
if ( (v6 & 1) != 0 )
{
if ( atoi(v8) >= 0 )
{
LABEL_17:
v12 = strlen(v8);
if ( v12 >= 0xFFFFFFFFFFFFFFF8LL )
goto LABEL_105;
v13 = v12;
if ( v12 >= 0x17 )
{
v16 = 26;
if ( (v12 | 7) != 0x17 )
v16 = (v12 | 7) + 1;
v14 = (char *)operator new(v16);
__p = v14;
__s2 = v16 + 1;
v76 = v13;
}
else
{
LOBYTE(__s2) = 2 * v12;
v14 = (char *)&__s2 + 1;
if ( !v12 )
{
LABEL_27:
v14[v13] = 0;
v17 = sub_10052DD30(&__s2, "#");
v18 = v78;
if ( (__s2 & 1) != 0 )
operator delete(__p);
if ( (unsigned int)sub_100720070(v17) <= 1 )
{
v19 = v18->m_friendRequestDelegate;
if ( v19 )
((void (__fastcall *)(FriendRequestDelegate *, const char *, __int64))v19->loadFRequestsFailed)(
v19,
v71,
0xFFFFFFFFLL);
return;
}
v20 = (cocos2d::CCString *)sub_1007200C0(v17, 0);
CString = cocos2d::CCString::getCString(v20);
v22 = strlen(CString);
if ( v22 < 0xFFFFFFFFFFFFFFF8LL )
{
v23 = v22;
if ( v22 >= 0x17 )
{
v25 = 26;
if ( (v22 | 7) != 0x17 )
v25 = (v22 | 7) + 1;
v24 = (char *)operator new(v25);
__p = v24;
__s2 = v25 + 1;
v76 = v23;
}
else
{
LOBYTE(__s2) = 2 * v22;
v24 = (char *)&__s2 + 1;
if ( !v22 )
{
LABEL_40:
v24[v23] = 0;
v26 = 1;
v27 = (cocos2d::CCString *)sub_1007200C0(v17, 1);
v28 = cocos2d::CCString::getCString(v27);
v29 = (void *)v28;
v30 = strlen(v28);
if ( v30 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100006BF0(*(double *)a4.i64);
v31 = v30;
if ( v30 >= 0x17 )
{
v33 = 26;
if ( (v30 | 7) != 0x17 )
v33 = (v30 | 7) + 1;
v32 = (char *)operator new(v33);
v70 = v32;
*(_QWORD *)&__dst = v33 | 1;
*((_QWORD *)&__dst + 1) = v31;
}
else
{
LOBYTE(__dst) = 2 * v30;
v32 = (char *)&__dst + 1;
if ( !v30 )
goto LABEL_48;
}
v29 = v32;
v26 = (__int64)v28;
memmove(v32, v28, v31);
LABEL_48:
v32[v31] = 0;
v34 = v78->m_friendRequestDelegate;
v35 = (char *)&__s2 + 1;
if ( v34 )
{
if ( (__dst & 1) != 0 )
{
sub_100006B70(&v59, v70, *((unsigned __int64 *)&__dst + 1), *(double *)a4.i64);
}
else
{
v60 = v70;
a4.i64[0] = __dst;
v59 = __dst;
}
v26 = (__int64)&v59;
v29 = v34;
((void (__fastcall *)(FriendRequestDelegate *, __int128 *, const char *))v34->setupPageInfo)(
v34,
&v59,
v71);
if ( (v59 & 1) != 0 )
{
v29 = v60;
operator delete(v60);
}
}
v68 = sub_10071F9E0(v29, v26);
if ( (__s2 & 1) != 0 )
v35 = (const char *)__p;
v36 = strlen(v35);
if ( v36 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100006BF0(*(double *)a4.i64);
v37 = v36;
if ( v36 >= 0x17 )
{
v39 = 26;
if ( (v36 | 7) != 0x17 )
v39 = (v36 | 7) + 1;
v38 = (char *)operator new(v39);
v73 = v38;
*(_QWORD *)&v72 = v39 | 1;
*((_QWORD *)&v72 + 1) = v37;
}
else
{
LOBYTE(v72) = 2 * v36;
v38 = (char *)&v72 + 1;
if ( !v36 )
goto LABEL_64;
}
memmove(v38, v35, v37);
LABEL_64:
v38[v37] = 0;
v67 = sub_10052DD30(&v72, "|");
if ( (v72 & 1) != 0 )
operator delete(v73);
SplitIntFromKey = ((SplitIntFromKey | 0x400000000uLL) - 1) >> 32;
for ( i = 0; ; ++i )
{
if ( i >= (unsigned int)sub_100720070(v67) )
{
v57 = __dst;
if ( (__dst & 1) != 0 )
{
sub_100006B70(&v65, v70, *((unsigned __int64 *)&__dst + 1), *(double *)a4.i64);
}
else
{
v66 = v70;
v65 = __dst;
}
GameLevelManager::storeCommentsResult(v78, v68, &v65, v71);
if ( (v65 & 1) != 0 )
operator delete(v66);
v58 = v78->m_friendRequestDelegate;
if ( v58 )
((void (__fastcall *)(FriendRequestDelegate *, __int64, const char *))v58->loadFRequestsFinished)(
v58,
v68,
v71);
if ( (v57 & 1) != 0 )
operator delete(v70);
if ( (__s2 & 1) != 0 )
operator delete(__p);
return;
}
v41 = (cocos2d::CCString *)sub_1007200C0(v67, i);
v42 = cocos2d::CCString::getCString(v41);
v43 = strlen(v42);
if ( v43 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100006BF0(*(double *)a4.i64);
v44 = v43;
if ( v43 >= 0x17 )
{
v47 = v43 | 7;
v48 = 26;
if ( (v44 | 7) != 0x17 )
v48 = v47 + 1;
v45 = (char *)operator new(v48);
v73 = v45;
*(_QWORD *)&v72 = v48 | 1;
*((_QWORD *)&v72 + 1) = v44;
}
else
{
LOBYTE(v72) = 2 * v43;
v45 = (char *)&v72 + 1;
if ( !v43 )
{
BYTE1(v72) = 0;
v46 = v72;
if ( (v72 & 1) == 0 )
goto LABEL_73;
goto LABEL_78;
}
}
memmove(v45, v42, v44);
v45[v44] = 0;
v46 = v72;
if ( (v72 & 1) == 0 )
{
LABEL_73:
v62 = v73;
a4.i64[0] = v72;
v61 = v72;
goto LABEL_79;
}
LABEL_78:
sub_100006B70(&v61, v73, *((unsigned __int64 *)&v72 + 1), *(double *)a4.i64);
LABEL_79:
v49 = (cocos2d::CCDictionary *)GameLevelManager::responseToDict(&v61, 0);
if ( (v61 & 1) != 0 )
operator delete(v62);
v50 = GJUserScore::create(v49);
if ( v50 )
{
v51 = GJFriendRequest::create(v49);
v52 = v51;
if ( v51 )
{
v50->m_friendReqStatus = SplitIntFromKey;
v51->m_isRead = !v50->m_newFriendRequest;
v51->m_accountID = v50->m_accountID;
sub_10071FCD0(v68, v50);
m_unknown2 = v52[5].m_unknown2;
if ( m_unknown2 > 0 )
cocos2d::CCDictionary::setObject(v78->m_friendRequests, v52, m_unknown2);
m_userID = v50->m_userID;
m_accountID = v50->m_accountID;
if ( (v50->m_userName.m_data.m_short.sizex2 & 1) != 0 )
{
sub_100006B70(
&v63,
v50->m_userName.m_data.m_long.longStorage,
v50->m_userName.m_data.m_long.size,
*(double *)a4.i64);
}
else
{
p_m_userName = &v50->m_userName;
longStorage = p_m_userName->m_data.m_long.longStorage;
a4 = *(__m128 *)&p_m_userName->m_data.m_short.sizex2;
v63 = *(__m128 *)&p_m_userName->m_data.m_short.sizex2;
}
GameLevelManager::storeUserName(v78, m_userID, m_accountID, &v63);
if ( (v63.i8[0] & 1) != 0 )
operator delete(longStorage);
}
}
if ( (v46 & 1) != 0 )
operator delete(v73);
}
}
}
memmove(v24, CString, v23);
goto LABEL_40;
}
LABEL_105:
sub_100006BF0(*(double *)a4.i64);
}
}
memmove(v14, v8, v13);
goto LABEL_27;
}
}
else if ( atoi((const char *)a2 + 1) >= 0 )
{
v8 = (const char *)(a2 + 1);
goto LABEL_17;
}
v15 = v78->m_friendRequestDelegate;
if ( v15 )
((void (__fastcall *)(FriendRequestDelegate *, const char *, __int64))v15->loadFRequestsFailed)(
v15,
v71,
4294967294LL);
}