//
// GameLevelManager::onGetFriendRequestsCompleted from 0x3cbc7c to 0x3cbeee (626 bytes)
//
// 1 xrefs:
// > GameLevelManager::handleIt @ 0x3d73cc
//
// 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
//
int __fastcall GameLevelManager::onGetFriendRequestsCompleted(GameLevelManager *a1, char **a2, const char **a3)
{
char *v4; // r6
_BOOL4 v6; // r10
char *v7; // r7
int result; // r0
int (*v9)(void); // r3
cocos2d::CCArray *v10; // r7
cocos2d::CCString *v11; // r0
char *CString; // r0
cocos2d::CCString *v13; // r0
char *v14; // r0
cocos2d::CCArray *v15; // r0
FriendRequestDelegate *m_friendRequestDelegate; // r9
void (__fastcall *setupPageInfo)(FriendRequestDelegate *__hidden, std::string, const unsigned __int8 *); // r11
unsigned int i; // r10
cocos2d::CCString *v19; // r0
char *v20; // r0
GJUserScore *v21; // r7
GJFriendRequest *v22; // r0
GJFriendRequest *v23; // r11
int v24; // r3
const char *m_userID; // r11
FriendRequestDelegate *v26; // r0
cocos2d::CCArray *v27; // [sp+4h] [bp-38h]
cocos2d::CCArray *v28; // [sp+8h] [bp-34h]
int SplitIntFromKey; // [sp+Ch] [bp-30h]
const char *m_accountID; // [sp+10h] [bp-2Ch]
char *v31; // [sp+18h] [bp-24h] BYREF
char v32[4]; // [sp+1Ch] [bp-20h] BYREF
char v33[4]; // [sp+20h] [bp-1Ch] BYREF
char v34; // [sp+24h] [bp-18h] BYREF
char *v35; // [sp+28h] [bp-14h] BYREF
char *v36; // [sp+2Ch] [bp-10h] BYREF
char *v37; // [sp+30h] [bp-Ch] BYREF
v4 = (char *)*a3;
SplitIntFromKey = GameLevelManager::getSplitIntFromKey(a1, *a3, 1);
GameLevelManager::removeDLFromActive(a1, v4);
sub_776584((int)&v37, "-1");
v6 = sub_3BE0D8((int)a2, (int)&v37);
sub_774008(&v37);
if ( v6 )
goto LABEL_6;
v7 = *a2;
if ( atoi(v7) < 0 )
{
result = (int)a1->m_friendRequestDelegate;
if ( !result )
return result;
v9 = *(int (**)(void))(*(_DWORD *)result + 4);
return v9();
}
sub_776584((int)&v37, v7);
v10 = sub_3BE530((cocos2d::CCArray *)&v37, "#");
sub_774008(&v37);
if ( cocos2d::CCArray::count(v10) <= 1u )
{
LABEL_6:
result = (int)a1->m_friendRequestDelegate;
if ( !result )
return result;
v9 = *(int (**)(void))(*(_DWORD *)result + 4);
return v9();
}
v11 = (cocos2d::CCString *)cocos2d::CCArray::objectAtIndex(v10, 0);
CString = (char *)cocos2d::CCString::getCString(v11);
sub_776584((int)&v31, CString);
v13 = (cocos2d::CCString *)cocos2d::CCArray::objectAtIndex(v10, 1u);
v14 = (char *)cocos2d::CCString::getCString(v13);
v15 = (cocos2d::CCArray *)sub_776584((int)v32, v14);
m_friendRequestDelegate = a1->m_friendRequestDelegate;
if ( m_friendRequestDelegate )
{
setupPageInfo = m_friendRequestDelegate->setupPageInfo;
sub_775C20(v33, v32);
((void (__fastcall *)(FriendRequestDelegate *, char *, char *))setupPageInfo)(m_friendRequestDelegate, v33, v4);
v15 = (cocos2d::CCArray *)sub_774008(v33);
}
v27 = (cocos2d::CCArray *)cocos2d::CCArray::create(v15);
sub_776584((int)&v34, v31);
v28 = sub_3BE530((cocos2d::CCArray *)&v34, "|");
sub_774008(&v34);
for ( i = 0; i < cocos2d::CCArray::count(v28); ++i )
{
v19 = (cocos2d::CCString *)cocos2d::CCArray::objectAtIndex(v28, i);
v20 = (char *)cocos2d::CCString::getCString(v19);
sub_776584((int)&v37, v20);
sub_775C20(&v35, &v37);
GameLevelManager::responseToDict(&v35, 0);
sub_774008(&v35);
v21 = GJUserScore::create();
if ( v21 )
{
v22 = GJFriendRequest::create();
v23 = v22;
if ( v22 )
{
if ( SplitIntFromKey )
v24 = 4;
else
v24 = 3;
v21->m_friendReqStatus = v24;
v22->m_isRead = !v21->m_newFriendRequest;
v22->m_accountID = v21->m_accountID;
cocos2d::CCArray::addObject(v27, v21);
GameLevelManager::storeFriendRequest(a1, v23);
m_userID = (const char *)v21->m_userID;
m_accountID = (const char *)v21->m_accountID;
sub_775C20(&v36, &v21->m_userName);
GameLevelManager::storeUserName(a1, m_userID, m_accountID, &v36);
sub_774008(&v36);
}
}
sub_774008(&v37);
}
sub_775C20(&v37, v32);
GameLevelManager::storeCommentsResult(a1, v27, &v37, v4);
sub_774008(&v37);
v26 = a1->m_friendRequestDelegate;
if ( v26 )
v26->loadFRequestsFinished(v26, v27, (const unsigned __int8 *)v4);
sub_774008(v32);
return sub_774008(&v31);
}