//
// GJMultiplayerManager::onJoinLobbyCompleted from 0x981f48 to 0x98276c (2084 bytes)
//
// 2 xrefs:
// > GJMultiplayerManager::handleIt @ 0x9828d4
// > ??> @ 0x5d660
//
// 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 GJMultiplayerManager::onJoinLobbyCompleted(
GJMultiplayerManager *a1,
const void **a2,
const char **a3)
{
unsigned int v4; // w20
_DWORD *v5; // x24
unsigned __int64 v6; // x25
unsigned __int64 v7; // x22
size_t v8; // x2
int v9; // w19
__int64 v10; // x22
__int64 *v11; // x0
GJMPDelegate *v12; // x0
cocos2d::CCString *v14; // x0
char *CString; // x0
cocos2d::CCString *v16; // x0
cocos2d::CCArray *v17; // x0
cocos2d::CCString *v18; // x0
char *v19; // x0
cocos2d::CCArray *v20; // x24
unsigned int v21; // w19
cocos2d::CCString *v22; // x0
char *v23; // x0
cocos2d::CCArray *v24; // x23
void *v25; // x0
unsigned int *v26; // x24
int v27; // w1
unsigned int *v28; // x1
int v29; // w2
cocos2d::CCString *v30; // x0
cocos2d::CCString *v31; // x0
char *v32; // x0
cocos2d::CCString *v33; // x0
GJUserScore *v34; // x0
int v35; // w23
__int64 v36; // x25
void *v37; // x0
cocos2d::CCDictionary *m_lobbyScores; // x0
void *v39; // x0
unsigned int *v40; // x1
int v41; // w2
unsigned int *v42; // x1
int v43; // w2
GJMPDelegate *m_mpDelegate; // x0
void *v45; // x0
void *v46; // x0
unsigned int *v47; // x19
int v48; // w1
cocos2d::CCString *v49; // x0
char *v50; // x0
__int64 v51; // x1
void *v52; // x0
unsigned int *v53; // x1
int v54; // w2
unsigned int *v55; // x1
int v56; // w2
cocos2d::CCArray *v57; // x23
unsigned int v58; // w19
cocos2d::CCString *v59; // x0
char *v60; // x0
void *v61; // x0
char *v62; // x0
unsigned int *v63; // x1
int v64; // w2
unsigned int *v65; // x1
int v66; // w2
cocos2d::CCArray *v67; // [xsp+78h] [xbp+78h]
int v68; // [xsp+84h] [xbp+84h]
cocos2d::CCArray *v69; // [xsp+88h] [xbp+88h]
int v71; // [xsp+90h] [xbp+90h]
__int64 v73; // [xsp+B0h] [xbp+B0h] BYREF
__int64 v74; // [xsp+B8h] [xbp+B8h] BYREF
__int64 v75; // [xsp+C0h] [xbp+C0h] BYREF
__int64 v76; // [xsp+C8h] [xbp+C8h] BYREF
__int64 v77; // [xsp+D0h] [xbp+D0h] BYREF
void *v78[2]; // [xsp+D8h] [xbp+D8h] BYREF
GJMultiplayerManager::removeDLFromActive(a1, *a3);
v4 = atoi(*a3);
sub_D153B8((int)v78, "-1");
v5 = v78[0];
v6 = *((_QWORD *)v78[0] - 3);
v7 = *((_QWORD *)*a2 - 3);
if ( v6 > v7 )
v8 = *((_QWORD *)*a2 - 3);
else
v8 = *((_QWORD *)v78[0] - 3);
v9 = memcmp(*a2, v78[0], v8);
if ( v9 || (v9 = 0x7FFFFFFF, v10 = v7 - v6, v10 > 0x7FFFFFFF) )
{
v11 = (__int64 *)(v5 - 6);
if ( v5 - 6 == (_DWORD *)&qword_124B6B0 )
goto LABEL_7;
}
else
{
v11 = (__int64 *)(v5 - 6);
if ( v10 >= (__int64)0xFFFFFFFF80000000LL )
v9 = v10;
else
v9 = 0x80000000;
if ( v11 == &qword_124B6B0 )
goto LABEL_7;
}
if ( &pthread_create )
{
v26 = v5 - 2;
do
v27 = __ldaxr(v26);
while ( __stlxr(v27 - 1, v26) );
}
else
{
v27 = *(v5 - 2);
*(v5 - 2) = v27 - 1;
}
if ( v27 <= 0 )
operator delete(v11);
LABEL_7:
if ( v9 && (v67 = sub_980C40(a2, "#"), (unsigned int)cocos2d::CCArray::count(v67) > 2) )
{
v14 = cocos2d::CCArray::stringAtIndex(v67, 0);
CString = (char *)cocos2d::CCString::getCString(v14);
sub_D153B8((int)&v73, CString);
v16 = cocos2d::CCArray::stringAtIndex(v67, 1u);
v17 = (cocos2d::CCArray *)cocos2d::CCString::intValue(v16);
v68 = (int)v17;
v69 = (cocos2d::CCArray *)cocos2d::CCArray::create(v17);
v18 = cocos2d::CCArray::stringAtIndex(v67, 2u);
v19 = (char *)cocos2d::CCString::getCString(v18);
sub_D153B8((int)&v74, v19);
v20 = sub_980C40(&v74, ";");
v21 = 0;
while ( v21 < (unsigned int)cocos2d::CCArray::count(v20) )
{
v22 = cocos2d::CCArray::stringAtIndex(v20, v21);
v23 = (char *)cocos2d::CCString::getCString(v22);
sub_D153B8((int)&v75, v23);
v24 = sub_980C40(&v75, &byte_F804F8);
if ( (unsigned int)cocos2d::CCArray::count(v24) > 2 )
{
v30 = cocos2d::CCArray::stringAtIndex(v24, 0);
v71 = cocos2d::CCString::intValue(v30);
v31 = cocos2d::CCArray::stringAtIndex(v24, 1u);
v32 = (char *)cocos2d::CCString::getCString(v31);
sub_D153B8((int)&v77, v32);
v33 = cocos2d::CCArray::stringAtIndex(v24, 2u);
v34 = (GJUserScore *)cocos2d::CCString::intValue(v33);
v35 = (int)v34;
v36 = GJUserScore::create(v34);
*(_DWORD *)(v36 + 344) = v71;
sub_D18D28(&v76);
sub_D18EA8(v36 + 320, &v76);
v37 = (void *)(v76 - 24);
if ( (__int64 *)(v76 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v42 = (unsigned int *)(v76 - 8);
do
v43 = __ldaxr(v42);
while ( __stlxr(v43 - 1, v42) );
}
else
{
v43 = *(_DWORD *)(v76 - 8);
*(_DWORD *)(v76 - 8) = v43 - 1;
}
if ( v43 <= 0 )
operator delete(v37);
}
clock_gettime(0, (struct timespec *)v78);
m_lobbyScores = a1->m_lobbyScores;
*(double *)(v36 + 560) = (double)(__int64)v78[0]
+ (double)(__int64)v78[1] / 1000000000.0
- (float)((float)v35 * 1000.0);
cocos2d::CCDictionary::setObject(m_lobbyScores, (cocos2d::CCObject *)v36, v71);
cocos2d::CCArray::addObject(v69, (cocos2d::CCObject *)v36);
v39 = (void *)(v77 - 24);
if ( (__int64 *)(v77 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v40 = (unsigned int *)(v77 - 8);
do
v41 = __ldaxr(v40);
while ( __stlxr(v41 - 1, v40) );
}
else
{
v41 = *(_DWORD *)(v77 - 8);
*(_DWORD *)(v77 - 8) = v41 - 1;
}
if ( v41 <= 0 )
operator delete(v39);
}
}
v25 = (void *)(v75 - 24);
if ( (__int64 *)(v75 - 24) == &qword_124B6B0 )
goto LABEL_21;
if ( &pthread_create )
{
v28 = (unsigned int *)(v75 - 8);
do
v29 = __ldaxr(v28);
while ( __stlxr(v29 - 1, v28) );
}
else
{
v29 = *(_DWORD *)(v75 - 8);
*(_DWORD *)(v75 - 8) = v29 - 1;
}
if ( v29 > 0 )
{
LABEL_21:
++v21;
}
else
{
++v21;
operator delete(v25);
}
}
cocos2d::CCDictionary::setObject(a1->m_scoreArrays, v69, v68);
if ( (unsigned int)cocos2d::CCArray::count(v67) > 3 )
{
v49 = cocos2d::CCArray::stringAtIndex(v67, 3u);
v50 = (char *)cocos2d::CCString::getCString(v49);
sub_D153B8((int)&v76, v50);
v51 = v76;
if ( *(_QWORD *)(v76 - 24) )
{
v57 = sub_980C40(&v76, "|");
v58 = 0;
while ( v58 < (unsigned int)cocos2d::CCArray::count(v57) )
{
v59 = cocos2d::CCArray::stringAtIndex(v57, v58);
v60 = (char *)cocos2d::CCString::getCString(v59);
sub_D153B8((int)v78, v60);
sub_D18D28(&v77);
GJMultiplayerManager::addComment((__int64)a1, (__int64)&v77, v68);
v61 = (void *)(v77 - 24);
if ( (__int64 *)(v77 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v65 = (unsigned int *)(v77 - 8);
do
v66 = __ldaxr(v65);
while ( __stlxr(v66 - 1, v65) );
}
else
{
v66 = *(_DWORD *)(v77 - 8);
*(_DWORD *)(v77 - 8) = v66 - 1;
}
if ( v66 <= 0 )
operator delete(v61);
}
v62 = (char *)v78[0] - 24;
if ( (char *)v78[0] - 24 == (char *)&qword_124B6B0 )
goto LABEL_74;
if ( &pthread_create )
{
v63 = (unsigned int *)((char *)v78[0] - 8);
do
v64 = __ldaxr(v63);
while ( __stlxr(v64 - 1, v63) );
}
else
{
v64 = *((_DWORD *)v78[0] - 2);
*((_DWORD *)v78[0] - 2) = v64 - 1;
}
if ( v64 > 0 )
{
LABEL_74:
++v58;
}
else
{
++v58;
operator delete(v62);
}
}
v51 = v76;
}
v52 = (void *)(v51 - 24);
if ( (__int64 *)(v51 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v53 = (unsigned int *)(v51 - 8);
do
v54 = __ldaxr(v53);
while ( __stlxr(v54 - 1, v53) );
}
else
{
v54 = *(_DWORD *)(v51 - 8);
*(_DWORD *)(v51 - 8) = v54 - 1;
}
if ( v54 <= 0 )
operator delete(v52);
}
}
m_mpDelegate = a1->m_mpDelegate;
if ( m_mpDelegate )
m_mpDelegate->joinLobbyFinished(m_mpDelegate, v68);
v45 = (void *)(v74 - 24);
if ( (__int64 *)(v74 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v55 = (unsigned int *)(v74 - 8);
do
v56 = __ldaxr(v55);
while ( __stlxr(v56 - 1, v55) );
}
else
{
v56 = *(_DWORD *)(v74 - 8);
*(_DWORD *)(v74 - 8) = v56 - 1;
}
if ( v56 <= 0 )
operator delete(v45);
}
v46 = (void *)(v73 - 24);
if ( (__int64 *)(v73 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v47 = (unsigned int *)(v73 - 8);
do
v48 = __ldaxr(v47);
while ( __stlxr(v48 - 1, v47) );
}
else
{
v48 = *(_DWORD *)(v73 - 8);
*(_DWORD *)(v73 - 8) = v48 - 1;
}
if ( v48 <= 0 )
operator delete(v46);
}
}
else
{
v12 = a1->m_mpDelegate;
if ( v12 )
v12->joinLobbyFailed(v12, v4, Failed);
}
return _stack_chk_guard;
}