//
// GameLevelManager::applyThreadAddReply from 0x80f6a4 to 0x80fa50 (940 bytes)
//
// 2 xrefs:
// > GameLevelManager::onUpdateThreadCompleted @ 0x8399d4
// > ??> @ 0x5d220
//
// This function is hookable on this platform (idp: arm, 32 bit: False, 64 bit: True!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 12:54:49 +0000
//
__int64 __fastcall GameLevelManager::applyThreadAddReply(cocos2d::CCArray **a1, unsigned int a2, char *a3)
{
cocos2d::CCObject *v6; // x0
cocos2d::CCObject *v7; // x0
cocos2d::CCObject *v8; // x0
cocos2d::CCObject *v9; // x0
cocos2d::CCArray *v10; // x0
cocos2d::CCObject *v11; // x0
cocos2d::CCArray *v12; // x0
cocos2d::CCObject *v13; // x0
cocos2d::CCArray *v14; // x2
cocos2d::CCArray *v15; // x1
char *v16; // x20
char v17; // t1
size_t v18; // x0
cocos2d::CCArray *v19; // x25
__int64 i; // x23
cocos2d::CCObject *v21; // x0
signed int v22; // w23
cocos2d::CCArray *ThreadMembers; // x21
signed int v24; // w23
cocos2d::CCArray *ThreadPendingInvites; // x21
cocos2d::CCString *v27; // x0
const char *CString; // x0
size_t v29; // x0
cocos2d::CCArray *v30; // x22
signed int v31; // w21
signed int v32; // w28
cocos2d::CCString *v33; // x0
int v34; // w20
cocos2d::CCObject *v35; // x0
cocos2d::CCArray *v36; // x0
signed int v37; // w20
cocos2d::CCObject *v38; // x24
int v39; // w22
GJAccountManager *v40; // x0
__int64 v41; // x0
signed int v42; // w20
cocos2d::CCObject *v43; // x24
int v44; // w22
char *v45; // [xsp+68h] [xbp+68h]
_QWORD v46[3]; // [xsp+78h] [xbp+78h]
__int64 v47; // [xsp+90h] [xbp+90h] BYREF
__int64 v48; // [xsp+98h] [xbp+98h]
void *v49; // [xsp+A0h] [xbp+A0h]
v6 = a1[86];
if ( v6 )
{
cocos2d::CCObject::release(v6);
a1[86] = nullptr;
}
v7 = a1[87];
if ( v7 )
{
cocos2d::CCObject::release(v7);
a1[87] = nullptr;
}
v8 = a1[88];
if ( v8 )
{
v8 = (cocos2d::CCObject *)cocos2d::CCObject::release(v8);
a1[88] = nullptr;
}
v9 = (cocos2d::CCObject *)cocos2d::CCArray::create(v8);
a1[86] = v9;
v10 = (cocos2d::CCArray *)cocos2d::CCObject::retain(v9);
v11 = (cocos2d::CCObject *)cocos2d::CCArray::create(v10);
a1[87] = v11;
v12 = (cocos2d::CCArray *)cocos2d::CCObject::retain(v11);
v13 = (cocos2d::CCObject *)cocos2d::CCArray::create(v12);
a1[88] = v13;
cocos2d::CCObject::retain(v13);
v14 = a1[87];
v15 = a1[88];
v17 = *a3;
v16 = a3 + 1;
v46[0] = a1[86];
v46[1] = v14;
v46[2] = v15;
if ( (v17 & 1) != 0 )
v16 = *((char **)a3 + 2);
v47 = 0;
v48 = 0;
v49 = nullptr;
v18 = strlen(v16);
std::string::__init(&v47, v16, v18);
v19 = sub_80CFCC((unsigned __int8 *)&v47, ":");
if ( (v47 & 1) != 0 )
operator delete(v49);
for ( i = 0; i != 3; ++i )
{
if ( (int)cocos2d::CCArray::count(v19) <= (int)i )
break;
v27 = (cocos2d::CCString *)cocos2d::CCArray::stringAtIndex(v19, i);
CString = (const char *)cocos2d::CCString::getCString(v27);
v47 = 0;
v48 = 0;
v49 = nullptr;
v45 = (char *)CString;
v29 = strlen(CString);
std::string::__init(&v47, v45, v29);
v30 = sub_80CFCC((unsigned __int8 *)&v47, &byte_1169BE0);
if ( (v47 & 1) != 0 )
operator delete(v49);
v31 = 0;
while ( v31 < (int)cocos2d::CCArray::count(v30) )
{
v32 = 0;
v33 = (cocos2d::CCString *)cocos2d::CCArray::stringAtIndex(v30, v31);
v34 = cocos2d::CCString::intValue(v33);
if ( v34 > 0 )
{
while ( 1 )
{
v36 = a1[85];
if ( v36 )
{
if ( v32 >= (int)cocos2d::CCArray::count(v36) )
goto LABEL_30;
}
else if ( v32 >= 0 )
{
goto LABEL_30;
}
v35 = (cocos2d::CCObject *)cocos2d::CCArray::objectAtIndex(a1[85], v32);
if ( v34 == *((_DWORD *)v35 + 94) )
break;
++v32;
}
++v31;
cocos2d::CCArray::addObject((cocos2d::CCArray *)v46[i], v35);
}
else
{
LABEL_30:
++v31;
}
}
}
v21 = a1[85];
if ( v21 )
{
cocos2d::CCObject::release(v21);
a1[85] = nullptr;
}
v22 = 0;
ThreadMembers = (cocos2d::CCArray *)GameLevelManager::getThreadMembers((GameLevelManager *)a1, (const char *)a2);
if ( ThreadMembers )
{
while ( (int)cocos2d::CCArray::count(a1[86]) > v22 )
{
v42 = 0;
v43 = (cocos2d::CCObject *)cocos2d::CCArray::objectAtIndex(a1[86], v22);
v44 = *((_DWORD *)v43 + 94);
while ( v42 < (int)cocos2d::CCArray::count(ThreadMembers) )
{
if ( v44 == *(_DWORD *)(cocos2d::CCArray::objectAtIndex(ThreadMembers, v42) + 376) )
goto LABEL_46;
++v42;
}
cocos2d::CCArray::addObject(ThreadMembers, v43);
LABEL_46:
++v22;
}
}
v24 = 0;
ThreadPendingInvites = (cocos2d::CCArray *)GameLevelManager::getThreadPendingInvites(
(GameLevelManager *)a1,
(const char *)a2);
if ( ThreadPendingInvites )
{
while ( (int)cocos2d::CCArray::count(a1[87]) > v24 )
{
v37 = 0;
v38 = (cocos2d::CCObject *)cocos2d::CCArray::objectAtIndex(a1[87], v24);
v39 = *((_DWORD *)v38 + 94);
while ( 1 )
{
v40 = (GJAccountManager *)cocos2d::CCArray::count(ThreadPendingInvites);
if ( v37 >= (int)v40 )
break;
if ( v39 == *(_DWORD *)(cocos2d::CCArray::objectAtIndex(ThreadPendingInvites, v37) + 376) )
goto LABEL_40;
++v37;
}
v41 = GJAccountManager::sharedState(v40);
*((_DWORD *)v38 + 99) = *(_DWORD *)(v41 + 352) - *(_DWORD *)(v41 + 356);
cocos2d::CCArray::addObject(ThreadPendingInvites, v38);
LABEL_40:
++v24;
}
}
return _stack_chk_guard;
}