//
// GameLevelManager::onGetAccountCommentsCompleted from 0x71878c to 0x718cf0 (1380 bytes)
//
// 2 xrefs:
// > GameLevelManager::handleIt @ 0x732dc4
// > ??> @ 0x3cf00
//
// 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 GameLevelManager::onGetAccountCommentsCompleted(
GameLevelManager *a1,
const void **a2,
const char **a3)
{
char *v3; // x20
_DWORD *v6; // x28
unsigned __int64 v7; // x25
unsigned __int64 v8; // x22
size_t v9; // x2
int v10; // w26
__int64 v11; // x22
__int64 *v12; // x0
LevelCommentDelegate *v13; // x0
cocos2d::CCArray *v15; // x26
char *v16; // x0
cocos2d::CCString *v17; // x0
char *CString; // x0
cocos2d::CCString *v19; // x0
char *v20; // x0
LevelCommentDelegate *m_levelCommentDelegate; // x27
void (__fastcall *setupPageInfo)(LevelCommentDelegate *__hidden, std::string, const unsigned __int8 *); // x25
long double v23; // q0
void *v24; // x0
cocos2d::CCArray *AccountComments; // x25
void *v26; // x0
char *v27; // x0
LevelCommentDelegate *v28; // x0
void *v29; // x0
void *v30; // x21
unsigned int *v31; // x20
int v32; // w0
unsigned int *v33; // x28
int v34; // w1
unsigned int *v35; // x1
int v36; // w2
unsigned int *v37; // x1
int v38; // w2
unsigned int *v39; // x1
int v40; // w2
unsigned int *v41; // x1
int v42; // w2
unsigned int *v43; // x1
int v44; // w2
__int64 v45; // [xsp+0h] [xbp+0h] BYREF
int v46; // [xsp+6Ch] [xbp+6Ch]
__int64 v47; // [xsp+80h] [xbp+80h]
__int64 v48; // [xsp+88h] [xbp+88h] BYREF
__int64 v49; // [xsp+90h] [xbp+90h] BYREF
__int64 v50; // [xsp+98h] [xbp+98h] BYREF
void *v51; // [xsp+A0h] [xbp+A0h] BYREF
v3 = (char *)*a3;
v46 = GameLevelManager::levelIDFromCommentKey(a1, *a3);
GameLevelManager::removeDLFromActive(a1, v3);
sub_D153B8((int)&v51, "-1");
v6 = v51;
v7 = *((_QWORD *)v51 - 3);
v8 = *((_QWORD *)*a2 - 3);
if ( v7 > v8 )
v9 = *((_QWORD *)*a2 - 3);
else
v9 = *((_QWORD *)v51 - 3);
v10 = memcmp(*a2, v51, v9);
if ( v10 || (v10 = 0x7FFFFFFF, v11 = v8 - v7, v11 > 0x7FFFFFFF) )
{
v12 = (__int64 *)(v6 - 6);
if ( v6 - 6 == (_DWORD *)&qword_124B6B0 )
goto LABEL_7;
}
else
{
v12 = (__int64 *)(v6 - 6);
if ( v11 >= (__int64)0xFFFFFFFF80000000LL )
v10 = v11;
else
v10 = 0x80000000;
if ( v12 == &qword_124B6B0 )
goto LABEL_7;
}
if ( &pthread_create )
{
v33 = v6 - 2;
do
v34 = __ldaxr(v33);
while ( __stlxr(v34 - 1, v33) );
}
else
{
v34 = *(v6 - 2);
*(v6 - 2) = v34 - 1;
}
if ( v34 <= 0 )
operator delete(v12);
LABEL_7:
if ( !v10 )
goto LABEL_8;
sub_D153B8((int)&v51, (char *)*a2);
v15 = sub_6F004C(&v51, "#");
v16 = (char *)v51 - 24;
if ( (char *)v51 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v35 = (unsigned int *)((char *)v51 - 8);
do
v36 = __ldaxr(v35);
while ( __stlxr(v36 - 1, v35) );
}
else
{
v36 = *((_DWORD *)v51 - 2);
*((_DWORD *)v51 - 2) = v36 - 1;
}
if ( v36 <= 0 )
operator delete(v16);
}
if ( (unsigned int)cocos2d::CCArray::count(v15) > 1 )
{
v17 = (cocos2d::CCString *)cocos2d::CCArray::objectAtIndex(v15, 0);
CString = (char *)cocos2d::CCString::getCString(v17);
sub_D153B8((unsigned int)&v45 + 128, CString);
v19 = (cocos2d::CCString *)cocos2d::CCArray::objectAtIndex(v15, 1u);
v20 = (char *)cocos2d::CCString::getCString(v19);
sub_D153B8((int)&v48, v20);
m_levelCommentDelegate = a1->m_levelCommentDelegate;
if ( m_levelCommentDelegate )
{
setupPageInfo = m_levelCommentDelegate->setupPageInfo;
*(__n128 *)&v23 = sub_D18D28(&v49);
((void (__fastcall *)(LevelCommentDelegate *, __int64 *, char *, long double))setupPageInfo)(
m_levelCommentDelegate,
&v49,
v3,
v23);
v24 = (void *)(v49 - 24);
if ( (__int64 *)(v49 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v43 = (unsigned int *)(v49 - 8);
do
v44 = __ldaxr(v43);
while ( __stlxr(v44 - 1, v43) );
}
else
{
v44 = *(_DWORD *)(v49 - 8);
*(_DWORD *)(v49 - 8) = v44 - 1;
}
if ( v44 <= 0 )
operator delete(v24);
}
}
sub_D18D28(&v50);
AccountComments = GameLevelManager::createAndGetAccountComments(a1, (__int64)&v50, v46);
v26 = (void *)(v50 - 24);
if ( (__int64 *)(v50 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v39 = (unsigned int *)(v50 - 8);
do
v40 = __ldaxr(v39);
while ( __stlxr(v40 - 1, v39) );
}
else
{
v40 = *(_DWORD *)(v50 - 8);
*(_DWORD *)(v50 - 8) = v40 - 1;
}
if ( v40 <= 0 )
operator delete(v26);
}
sub_D18D28(&v51);
GameLevelManager::storeCommentsResult(a1, AccountComments, (char **)&v51, v3);
v27 = (char *)v51 - 24;
if ( (char *)v51 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v41 = (unsigned int *)((char *)v51 - 8);
do
v42 = __ldaxr(v41);
while ( __stlxr(v42 - 1, v41) );
}
else
{
v42 = *((_DWORD *)v51 - 2);
*((_DWORD *)v51 - 2) = v42 - 1;
}
if ( v42 <= 0 )
operator delete(v27);
}
v28 = a1->m_levelCommentDelegate;
if ( v28 )
v28->loadCommentsFinished(v28, AccountComments, (const unsigned __int8 *)v3);
v29 = (void *)(v48 - 24);
if ( (__int64 *)(v48 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v37 = (unsigned int *)(v48 - 8);
do
v38 = __ldaxr(v37);
while ( __stlxr(v38 - 1, v37) );
}
else
{
v38 = *(_DWORD *)(v48 - 8);
*(_DWORD *)(v48 - 8) = v38 - 1;
}
if ( v38 <= 0 )
operator delete(v29);
}
v30 = (void *)(v47 - 24);
if ( (__int64 *)(v47 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v31 = (unsigned int *)(v47 - 8);
do
v32 = __ldaxr(v31);
while ( __stlxr(v32 - 1, v31) );
}
else
{
v32 = *(_DWORD *)(v47 - 8);
*(_DWORD *)(v47 - 8) = v32 - 1;
}
if ( v32 <= 0 )
operator delete(v30);
}
}
else
{
LABEL_8:
v13 = a1->m_levelCommentDelegate;
if ( v13 )
v13->loadCommentsFailed(v13, (const unsigned __int8 *)v3);
}
return _stack_chk_guard;
}