//
// GJMultiplayerManager::onJoinLobbyCompleted from 0x100659730 to 0x100659f2e (2046 bytes)
//
// 1 xrefs:
// > GJMultiplayerManager::handleIt @ 0x1006593c7
//
// 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 GJMultiplayerManager::onJoinLobbyCompleted(
GJMultiplayerManager *a1,
unsigned __int8 *a2,
__int64 a3,
double a4)
{
const char *v5; // rbx
unsigned int v6; // r15d
const void *v7; // rdi
unsigned __int64 v8; // rcx
char *v9; // rbx
size_t v10; // rdx
cocos2d::CCArray *v11; // r13
cocos2d::CCString *v12; // rax
const char *CString; // r15
size_t v14; // rax
size_t v15; // r14
GJMPDelegate *m_mpDelegate; // rdi
size_t v17; // r12
cocos2d::CCString *v18; // rdi
cocos2d::CCString *v19; // rax
const char *v20; // rbx
size_t v21; // rax
size_t v22; // r14
char *v23; // r15
size_t v24; // r12
unsigned int v25; // r15d
cocos2d::CCString *v26; // rax
const char *v27; // rbx
size_t v28; // rax
size_t v29; // r14
char *v30; // r12
size_t v31; // r15
cocos2d::CCArray *v32; // r14
unsigned int v33; // eax
int v34; // r15d
cocos2d::CCString *v35; // rax
cocos2d::CCString *v36; // rax
const char *v37; // r12
size_t v38; // rax
size_t v39; // r13
char *v40; // r15
size_t v41; // rbx
cocos2d::CCString *v42; // rax
int v43; // r12d
GJUserScore *v44; // rax
GJUserScore *v45; // r14
char v46; // bl
cocos2d::CCString *v47; // rax
const char *v48; // rbx
size_t v49; // rax
size_t v50; // r14
char *v51; // r15
size_t v52; // r12
char v53; // al
unsigned int v54; // r14d
__int128 *v55; // rbx
unsigned int v56; // esi
__int128 *v57; // r14
cocos2d::CCString *v58; // rax
const char *v59; // r12
size_t v60; // rax
size_t v61; // r13
char *v62; // r15
__int64 v63; // rax
size_t v64; // rbx
char v65; // r12
int v66; // r14d
GJMPDelegate *v67; // rdi
timeb v68; // [rsp+8h] [rbp-108h] BYREF
cocos2d::CCArray *v69; // [rsp+18h] [rbp-F8h]
__int128 v70; // [rsp+20h] [rbp-F0h] BYREF
void *v71; // [rsp+30h] [rbp-E0h]
std::string __str; // [rsp+40h] [rbp-D0h] BYREF
cocos2d::CCObject *v73; // [rsp+58h] [rbp-B8h]
_QWORD __dst[2]; // [rsp+60h] [rbp-B0h] BYREF
void *v75; // [rsp+70h] [rbp-A0h]
_QWORD __s2[2]; // [rsp+78h] [rbp-98h] BYREF
void *v77; // [rsp+88h] [rbp-88h]
cocos2d::CCArray *v78; // [rsp+90h] [rbp-80h]
int v79; // [rsp+9Ch] [rbp-74h]
cocos2d::CCArray *v80; // [rsp+A0h] [rbp-70h]
__int64 v81; // [rsp+A8h] [rbp-68h] BYREF
size_t v82; // [rsp+B0h] [rbp-60h]
void *v83; // [rsp+B8h] [rbp-58h]
unsigned int v84; // [rsp+C4h] [rbp-4Ch]
GJMultiplayerManager *v85; // [rsp+C8h] [rbp-48h]
__int128 v86; // [rsp+D0h] [rbp-40h] BYREF
void *__p; // [rsp+E0h] [rbp-30h]
v85 = a1;
if ( (*(_BYTE *)a3 & 1) != 0 )
{
GJMultiplayerManager::removeDLFromActive(v85, *(const char **)(a3 + 16));
if ( (*(_BYTE *)a3 & 1) != 0 )
goto LABEL_3;
}
else
{
GJMultiplayerManager::removeDLFromActive(v85, (const char *)(a3 + 1));
if ( (*(_BYTE *)a3 & 1) != 0 )
{
LABEL_3:
v5 = *(const char **)(a3 + 16);
goto LABEL_6;
}
}
v5 = (const char *)(a3 + 1);
LABEL_6:
v6 = atoi(v5);
LOBYTE(__s2[0]) = 4;
*(_WORD *)((char *)__s2 + 1) = 12589;
BYTE3(__s2[0]) = 0;
v7 = a2 + 1;
v8 = *a2 >> 1;
if ( (*a2 & 1) != 0 )
v7 = *((const void **)a2 + 2);
v9 = (char *)__s2 + 1;
if ( (*a2 & 1) != 0 )
v8 = *((_QWORD *)a2 + 1);
v10 = 2;
if ( v8 < 2 )
v10 = v8;
if ( !((v8 != 2) | (memcmp(v7, (char *)__s2 + 1, v10) != 0))
|| (v11 = (cocos2d::CCArray *)sub_10065AB20(a2, "#"), (unsigned int)sub_100720070(v11) < 3) )
{
m_mpDelegate = v85->m_mpDelegate;
if ( m_mpDelegate )
((void (__fastcall *)(GJMPDelegate *, _QWORD, _QWORD))m_mpDelegate->joinLobbyFailed)(m_mpDelegate, v6, 0);
return;
}
v12 = cocos2d::CCArray::stringAtIndex(v11, 0);
CString = cocos2d::CCString::getCString(v12);
v14 = strlen(CString);
if ( v14 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100006BF0(a4);
v15 = v14;
if ( v14 >= 0x17 )
{
v17 = 26;
if ( (v14 | 7) != 0x17 )
v17 = (v14 | 7) + 1;
v9 = (char *)operator new(v17);
v77 = v9;
__s2[0] = v17 + 1;
__s2[1] = v15;
goto LABEL_23;
}
LOBYTE(__s2[0]) = 2 * v14;
if ( v14 )
LABEL_23:
memmove(v9, CString, v15);
v9[v15] = 0;
v18 = cocos2d::CCArray::stringAtIndex(v11, 1u);
v84 = cocos2d::CCString::intValue(v18);
v73 = (cocos2d::CCObject *)sub_10071F9E0(v18, 1);
v19 = cocos2d::CCArray::stringAtIndex(v11, 2u);
v20 = cocos2d::CCString::getCString(v19);
v21 = strlen(v20);
if ( v21 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100006BF0(a4);
v22 = v21;
if ( v21 >= 0x17 )
{
v24 = 26;
if ( (v21 | 7) != 0x17 )
v24 = (v21 | 7) + 1;
v23 = (char *)operator new(v24);
v75 = v23;
__dst[0] = v24 | 1;
__dst[1] = v22;
}
else
{
LOBYTE(__dst[0]) = 2 * v21;
v23 = (char *)__dst + 1;
if ( !v21 )
goto LABEL_32;
}
memmove(v23, v20, v22);
LABEL_32:
v23[v22] = 0;
v78 = (cocos2d::CCArray *)sub_10065AB20(__dst, ";");
v25 = 0;
v69 = v11;
while ( v25 < (unsigned int)sub_100720070(v78) )
{
LODWORD(v80) = v25;
v26 = cocos2d::CCArray::stringAtIndex(v78, v25);
v27 = cocos2d::CCString::getCString(v26);
v28 = strlen(v27);
if ( v28 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100006BF0(a4);
v29 = v28;
if ( v28 >= 0x17 )
{
v31 = (v28 | 7) + 1;
if ( (v28 | 7) == 0x17 )
v31 = 26;
v30 = (char *)operator new(v31);
v83 = v30;
v81 = v31 | 1;
v82 = v29;
LABEL_42:
memmove(v30, v27, v29);
goto LABEL_43;
}
LOBYTE(v81) = 2 * v28;
v30 = (char *)&v81 + 1;
if ( v28 )
goto LABEL_42;
LABEL_43:
v30[v29] = 0;
v32 = (cocos2d::CCArray *)sub_10065AB20(&v81, ",");
v33 = sub_100720070(v32);
v34 = (int)v80;
if ( v33 < 3 )
goto LABEL_59;
v35 = cocos2d::CCArray::stringAtIndex(v32, 0);
v79 = cocos2d::CCString::intValue(v35);
v36 = cocos2d::CCArray::stringAtIndex(v32, 1u);
v37 = cocos2d::CCString::getCString(v36);
v38 = strlen(v37);
if ( v38 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100006BF0(a4);
v39 = v38;
if ( v38 >= 0x17 )
{
v41 = (v38 | 7) + 1;
if ( (v38 | 7) == 0x17 )
v41 = 26;
v40 = (char *)operator new(v41);
__p = v40;
*(_QWORD *)&v86 = v41 | 1;
*((_QWORD *)&v86 + 1) = v39;
}
else
{
LOBYTE(v86) = 2 * v38;
v40 = (char *)&v86 + 1;
if ( !v38 )
goto LABEL_52;
}
memmove(v40, v37, v39);
LABEL_52:
v40[v39] = 0;
v42 = cocos2d::CCArray::stringAtIndex(v32, 2u);
v43 = cocos2d::CCString::intValue(v42);
v44 = GJUserScore::create_1();
v11 = v69;
v34 = (int)v80;
v45 = v44;
v44->m_accountID = v79;
v46 = v86;
if ( (v86 & 1) != 0 )
{
sub_100006B70(&__str, __p, *((unsigned __int64 *)&v86 + 1), a4);
}
else
{
__str.__r_.__value_.__r.__words[2] = (std::string::size_type)__p;
*(_OWORD *)&__str.__r_.__value_.__l.0 = v86;
}
std::string::operator=((std::string *)&v45->m_userName, &__str);
if ( (*(_BYTE *)&__str.__r_.__value_.__s.0 & 1) != 0 )
operator delete(__str.__r_.__value_.__l.__data_);
ftime(&v68);
a4 = (double)(v68.millitm + 1000 * (v68.time & 0xFFFFF)) / 1000.0;
v45->m_lobbyJoinTime = (float)((float)v43 * -1000.0) + a4;
cocos2d::CCDictionary::setObject(v85->m_lobbyScores, v45, v79);
sub_10071FCD0(v73, v45);
if ( (v46 & 1) != 0 )
operator delete(__p);
LABEL_59:
if ( (v81 & 1) != 0 )
operator delete(v83);
v25 = v34 + 1;
}
cocos2d::CCDictionary::setObject(v85->m_scoreArrays, v73, (int)v84);
if ( (unsigned int)sub_100720070(v11) < 4 )
goto LABEL_95;
v47 = cocos2d::CCArray::stringAtIndex(v11, 3u);
v48 = cocos2d::CCString::getCString(v47);
v49 = strlen(v48);
if ( v49 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100006BF0(a4);
v50 = v49;
if ( v49 >= 0x17 )
{
v52 = 26;
if ( (v49 | 7) != 0x17 )
v52 = (v49 | 7) + 1;
v51 = (char *)operator new(v52);
v83 = v51;
v81 = v52 | 1;
v82 = v50;
goto LABEL_69;
}
LOBYTE(v81) = 2 * v49;
v51 = (char *)&v81 + 1;
if ( v49 )
LABEL_69:
memmove(v51, v48, v50);
v51[v50] = 0;
v53 = v81 & 1;
if ( (v81 & 1) != 0 )
{
if ( !v82 )
goto LABEL_93;
LABEL_74:
v80 = (cocos2d::CCArray *)sub_10065AB20(&v81, "|");
v54 = 0;
v55 = &v70;
while ( 2 )
{
if ( v54 >= (unsigned int)sub_100720070(v80) )
{
v53 = v81 & 1;
goto LABEL_93;
}
v56 = v54;
v57 = v55;
LODWORD(v78) = v56;
v58 = cocos2d::CCArray::stringAtIndex(v80, v56);
v59 = cocos2d::CCString::getCString(v58);
v60 = strlen(v59);
if ( v60 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100006BF0(a4);
v61 = v60;
if ( v60 >= 0x17 )
{
v63 = v60 | 7;
v64 = 26;
if ( (v61 | 7) != 0x17 )
v64 = v63 + 1;
v62 = (char *)operator new(v64);
__p = v62;
*(_QWORD *)&v86 = v64 | 1;
*((_QWORD *)&v86 + 1) = v61;
v55 = v57;
}
else
{
LOBYTE(v86) = 2 * v60;
v62 = (char *)&v86 + 1;
if ( !v60 )
goto LABEL_85;
}
memmove(v62, v59, v61);
LABEL_85:
v62[v61] = 0;
v65 = v86;
v66 = (int)v78;
if ( (v86 & 1) != 0 )
{
sub_100006B70(v55, __p, *((unsigned __int64 *)&v86 + 1), a4);
}
else
{
v71 = __p;
a4 = *(double *)&v86;
v70 = v86;
}
GJMultiplayerManager::addComment(v85, v55, v84);
if ( (v70 & 1) != 0 )
operator delete(v71);
if ( (v65 & 1) != 0 )
operator delete(__p);
v54 = v66 + 1;
continue;
}
}
if ( (unsigned __int8)v81 >> 1 )
goto LABEL_74;
LABEL_93:
if ( v53 )
operator delete(v83);
LABEL_95:
v67 = v85->m_mpDelegate;
if ( v67 )
((void (__fastcall *)(GJMPDelegate *, _QWORD))v67->joinLobbyFinished)(v67, v84);
if ( (__dst[0] & 1) != 0 )
operator delete(v75);
if ( (__s2[0] & 1) != 0 )
operator delete(v77);
}