//
// MPLobbyLayer::joinLobbyFinished from 0x9c9fa8 to 0x9ca2d0 (808 bytes)
//
// 3 xrefs:
// > `non-virtual thunk to'MPLobbyLayer::joinLobbyFinished @ 0x9ca2e4
// > ??> @ 0x63a38
// > ??> @ 0x11c9920
//
// 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 MPLobbyLayer::joinLobbyFinished(MPLobbyLayer *a1, int a2)
{
__int64 v4; // x0
GJMultiplayerManager *v5; // x0
cocos2d::CCArray *v6; // x23
cocos2d::CCString *v7; // x0
unsigned int v8; // w19
char *CString; // x0
__int64 v10; // x20
unsigned int v11; // w25
__int64 v12; // x24
cocos2d::CCString *v13; // x0
size_t v14; // x0
void *v15; // x0
unsigned int *v16; // x1
int v17; // w2
unsigned __int8 *v18; // x0
MPLobbyLayer_vtbl *v19; // x1
float v20; // s0
const char *v21; // x1
cocos2d::CCLabelBMFont *m_lobbyLabel; // x20
void (__fastcall *setString)(cocos2d::CCLabelBMFont *__hidden, const unsigned __int8 *); // x19
cocos2d::CCString *v24; // x0
const char *v25; // x0
unsigned int *v26; // x19
int v27; // w1
const char *v29; // [xsp+78h] [xbp+78h]
const unsigned __int8 *v30; // [xsp+88h] [xbp+88h] BYREF
__int64 v31; // [xsp+90h] [xbp+90h] BYREF
__int64 v32; // [xsp+98h] [xbp+98h] BYREF
__int64 v33; // [xsp+A0h] [xbp+A0h]
__int64 v34; // [xsp+A8h] [xbp+A8h]
v4 = _stack_chk_guard;
a1->m_lobbyID = a2;
v34 = v4;
v5 = GJMultiplayerManager::sharedState();
v6 = (cocos2d::CCArray *)cocos2d::CCDictionary::objectForKey(v5->m_scoreArrays, a1->m_lobbyID);
if ( v6 )
{
v7 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"Game: %i",
(const char *)(unsigned int)a1->m_lobbyID);
v8 = 0;
CString = (char *)cocos2d::CCString::getCString(v7);
sub_D153B8((int)&v30, CString);
while ( v8 < (unsigned int)cocos2d::CCArray::count(v6) )
{
v10 = cocos2d::CCArray::objectAtIndex(v6, v8);
v11 = *(_DWORD *)(v10 + 344);
sub_D18D28(&v31);
v12 = v31;
clock_gettime(0, (struct timespec *)&v32);
v13 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"\n%i: %s - Last Action: %f",
(const char *)v11,
v12,
((double)v32 + (double)v33 / 1000000000.0 - *(double *)(v10 + 560)) / 1000.0);
v29 = cocos2d::CCString::getCString(v13);
v14 = strlen(v29);
sub_D15FD4(&v30, v29, v14);
v15 = (void *)(v31 - 24);
if ( (__int64 *)(v31 - 24) == &qword_124B6B0 )
goto LABEL_5;
if ( &pthread_create )
{
v16 = (unsigned int *)(v31 - 8);
do
v17 = __ldaxr(v16);
while ( __stlxr(v17 - 1, v16) );
}
else
{
v17 = *(_DWORD *)(v31 - 8);
*(_DWORD *)(v31 - 8) = v17 - 1;
}
if ( v17 > 0 )
{
LABEL_5:
++v8;
}
else
{
++v8;
operator delete(v15);
}
}
a1->m_lobbyLabel->setString(a1->m_lobbyLabel, v30);
v18 = (unsigned __int8 *)(v30 - 24);
if ( v30 - 24 != (const unsigned __int8 *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v26 = (unsigned int *)(v30 - 8);
do
v27 = __ldaxr(v26);
while ( __stlxr(v27 - 1, v26) );
}
else
{
v27 = *((_DWORD *)v30 - 2);
*((_DWORD *)v30 - 2) = v27 - 1;
}
if ( v27 <= 0 )
operator delete(v18);
}
}
else
{
v21 = (const char *)(unsigned int)a2;
m_lobbyLabel = a1->m_lobbyLabel;
setString = m_lobbyLabel->setString;
v24 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"MPLobbyLayer::joinLobbyFinished: %i",
v21);
v25 = cocos2d::CCString::getCString(v24);
setString(m_lobbyLabel, (const unsigned __int8 *)v25);
}
v19 = a1->cocos2d::CCLayer::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
a1->m_awaitingLobby = 0;
v19->updateComments(a1);
if ( a1->m_awaitingLobby )
{
v20 = 2.0;
a1->m_lobbyDelay = 2.0;
}
else
{
v20 = a1->m_lobbyDelay + 0.5;
if ( v20 > 10.0 )
v20 = 10.0;
a1->m_lobbyDelay = v20;
}
MPLobbyLayer::updateLobby(a1, v20);
}