//
// GameLevelManager::onGetUserMessagesCompleted from 0x714814 to 0x714fe0 (1996 bytes)
//
// 2 xrefs:
// > GameLevelManager::handleIt @ 0x733064
// > ??> @ 0x6f360
//
// 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::onGetUserMessagesCompleted(GameLevelManager *a1, const void **a2, const char **a3)
{
_DWORD *v5; // x24
unsigned __int64 v6; // x25
unsigned __int64 v7; // x23
size_t v8; // x2
int v9; // w19
__int64 v10; // x23
__int64 *v11; // x0
char *v12; // x19
cocos2d::CCArray *v13; // x19
char *v14; // x0
cocos2d::CCString *v15; // x0
char *CString; // x0
cocos2d::CCString *v17; // x0
char *v18; // x0
cocos2d::CCArray *v19; // x0
MessageListDelegate *v20; // x19
void (__fastcall *setupPageInfo)(MessageListDelegate *__hidden, std::string, const unsigned __int8 *); // x24
long double v22; // q0
cocos2d::CCArray *v23; // x28
cocos2d::CCArray *v24; // x25
void *v25; // x0
unsigned int v26; // w20
cocos2d::CCString *v27; // x0
char *v28; // x0
char *v29; // x0
GJUserMessage *v30; // x19
std::string *p_m_username; // x1
int m_userID; // w27
int m_accountID; // w19
char *v34; // x0
char *v35; // x0
MessageListDelegate *m_messageListDelegate; // x0
MessageListDelegate *v38; // x0
unsigned int *v39; // x1
int v40; // w2
unsigned int *v41; // x24
int v42; // w1
unsigned int *v43; // x1
int v44; // w2
unsigned int *v45; // x1
int v46; // w2
char *v47; // x0
MessageListDelegate *v48; // x0
void *v49; // x0
char *v50; // x0
unsigned int *v51; // x19
int v52; // w1
unsigned int *v53; // x1
int v54; // w2
unsigned int *v55; // x1
int v56; // w2
unsigned int *v57; // x1
int v58; // w2
unsigned int *v59; // x1
int v60; // w2
unsigned int *v61; // x1
int v62; // w2
char *v63; // [xsp+78h] [xbp+78h]
char *v64; // [xsp+90h] [xbp+90h] BYREF
__int64 v65; // [xsp+98h] [xbp+98h] BYREF
__int64 v66; // [xsp+A0h] [xbp+A0h] BYREF
__int64 v67; // [xsp+A8h] [xbp+A8h] BYREF
char *v68; // [xsp+B0h] [xbp+B0h] BYREF
char *v69; // [xsp+B8h] [xbp+B8h] BYREF
void *v70; // [xsp+C0h] [xbp+C0h] BYREF
v63 = (char *)*a3;
GameLevelManager::removeDLFromActive(a1, *a3);
sub_D153B8((int)&v70, "-1");
v5 = v70;
v6 = *((_QWORD *)v70 - 3);
v7 = *((_QWORD *)*a2 - 3);
if ( v6 > v7 )
v8 = *((_QWORD *)*a2 - 3);
else
v8 = *((_QWORD *)v70 - 3);
v9 = memcmp(*a2, v70, 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 )
{
v41 = v5 - 2;
do
v42 = __ldaxr(v41);
while ( __stlxr(v42 - 1, v41) );
}
else
{
v42 = *(v5 - 2);
*(v5 - 2) = v42 - 1;
}
if ( v42 <= 0 )
operator delete(v11);
LABEL_7:
if ( !v9 )
{
LABEL_21:
m_messageListDelegate = a1->m_messageListDelegate;
if ( m_messageListDelegate )
m_messageListDelegate->loadMessagesFailed(
m_messageListDelegate,
(const unsigned __int8 *)v63,
(GJErrorCode)0xFFFFFFFFLL);
return _stack_chk_guard;
}
v12 = (char *)*a2;
if ( (atoi((const char *)*a2) & 0x80000000) == 0 )
{
sub_D153B8((int)&v70, v12);
v13 = sub_6F004C(&v70, "#");
v14 = (char *)v70 - 24;
if ( (char *)v70 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v57 = (unsigned int *)((char *)v70 - 8);
do
v58 = __ldaxr(v57);
while ( __stlxr(v58 - 1, v57) );
}
else
{
v58 = *((_DWORD *)v70 - 2);
*((_DWORD *)v70 - 2) = v58 - 1;
}
if ( v58 <= 0 )
operator delete(v14);
}
if ( (unsigned int)cocos2d::CCArray::count(v13) > 1 )
{
v15 = (cocos2d::CCString *)cocos2d::CCArray::objectAtIndex(v13, 0);
CString = (char *)cocos2d::CCString::getCString(v15);
sub_D153B8((int)&v64, CString);
v17 = (cocos2d::CCString *)cocos2d::CCArray::objectAtIndex(v13, 1u);
v18 = (char *)cocos2d::CCString::getCString(v17);
v19 = (cocos2d::CCArray *)sub_D153B8((int)&v65, v18);
v20 = a1->m_messageListDelegate;
if ( v20 )
{
setupPageInfo = v20->setupPageInfo;
*(__n128 *)&v22 = sub_D18D28(&v66, &v65);
((void (__fastcall *)(MessageListDelegate *, __int64 *, char *, long double))setupPageInfo)(v20, &v66, v63, v22);
v19 = (cocos2d::CCArray *)(v66 - 24);
if ( (__int64 *)(v66 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v55 = (unsigned int *)(v66 - 8);
do
v56 = __ldaxr(v55);
while ( __stlxr(v56 - 1, v55) );
}
else
{
v56 = *(_DWORD *)(v66 - 8);
*(_DWORD *)(v66 - 8) = v56 - 1;
}
if ( v56 <= 0 )
operator delete(v19);
}
}
v23 = (cocos2d::CCArray *)cocos2d::CCArray::create(v19);
sub_D153B8((int)&v67, v64);
v24 = sub_6F004C(&v67, "|");
v25 = (void *)(v67 - 24);
if ( (__int64 *)(v67 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v53 = (unsigned int *)(v67 - 8);
do
v54 = __ldaxr(v53);
while ( __stlxr(v54 - 1, v53) );
}
else
{
v54 = *(_DWORD *)(v67 - 8);
*(_DWORD *)(v67 - 8) = v54 - 1;
}
if ( v54 <= 0 )
operator delete(v25);
}
v26 = 0;
while ( v26 < (unsigned int)cocos2d::CCArray::count(v24) )
{
v27 = (cocos2d::CCString *)cocos2d::CCArray::objectAtIndex(v24, v26);
v28 = (char *)cocos2d::CCString::getCString(v27);
sub_D153B8((int)&v70, v28);
sub_D18D28(&v68, &v70);
GameLevelManager::responseToDict(&v68, 0);
v29 = v68 - 24;
if ( v68 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v43 = (unsigned int *)(v68 - 8);
do
v44 = __ldaxr(v43);
while ( __stlxr(v44 - 1, v43) );
}
else
{
v44 = *((_DWORD *)v68 - 2);
*((_DWORD *)v68 - 2) = v44 - 1;
}
if ( v44 <= 0 )
operator delete(v29);
}
v30 = GJUserMessage::create();
if ( v30 )
{
cocos2d::CCArray::addObject(v23, v30);
GameLevelManager::storeUserMessage(a1, v30);
p_m_username = &v30->m_username;
m_userID = v30->m_userID;
m_accountID = v30->m_accountID;
sub_D18D28(&v69, p_m_username);
GameLevelManager::storeUserName(a1, m_userID, m_accountID, &v69);
v34 = v69 - 24;
if ( v69 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v45 = (unsigned int *)(v69 - 8);
do
v46 = __ldaxr(v45);
while ( __stlxr(v46 - 1, v45) );
}
else
{
v46 = *((_DWORD *)v69 - 2);
*((_DWORD *)v69 - 2) = v46 - 1;
}
if ( v46 <= 0 )
operator delete(v34);
}
}
v35 = (char *)v70 - 24;
if ( (char *)v70 - 24 == (char *)&qword_124B6B0 )
goto LABEL_20;
if ( &pthread_create )
{
v39 = (unsigned int *)((char *)v70 - 8);
do
v40 = __ldaxr(v39);
while ( __stlxr(v40 - 1, v39) );
}
else
{
v40 = *((_DWORD *)v70 - 2);
*((_DWORD *)v70 - 2) = v40 - 1;
}
if ( v40 > 0 )
{
LABEL_20:
++v26;
}
else
{
++v26;
operator delete(v35);
}
}
sub_D18D28(&v70, &v65);
GameLevelManager::storeCommentsResult(a1, v23, (char **)&v70, v63);
v47 = (char *)v70 - 24;
if ( (char *)v70 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v59 = (unsigned int *)((char *)v70 - 8);
do
v60 = __ldaxr(v59);
while ( __stlxr(v60 - 1, v59) );
}
else
{
v60 = *((_DWORD *)v70 - 2);
*((_DWORD *)v70 - 2) = v60 - 1;
}
if ( v60 <= 0 )
operator delete(v47);
}
v48 = a1->m_messageListDelegate;
if ( v48 )
v48->loadMessagesFinished(v48, v23, (const unsigned __int8 *)v63);
v49 = (void *)(v65 - 24);
if ( (__int64 *)(v65 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v61 = (unsigned int *)(v65 - 8);
do
v62 = __ldaxr(v61);
while ( __stlxr(v62 - 1, v61) );
}
else
{
v62 = *(_DWORD *)(v65 - 8);
*(_DWORD *)(v65 - 8) = v62 - 1;
}
if ( v62 <= 0 )
operator delete(v49);
}
v50 = v64 - 24;
if ( v64 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v51 = (unsigned int *)(v64 - 8);
do
v52 = __ldaxr(v51);
while ( __stlxr(v52 - 1, v51) );
}
else
{
v52 = *((_DWORD *)v64 - 2);
*((_DWORD *)v64 - 2) = v52 - 1;
}
if ( v52 <= 0 )
operator delete(v50);
}
return _stack_chk_guard;
}
goto LABEL_21;
}
v38 = a1->m_messageListDelegate;
if ( v38 )
((void (__fastcall *)(MessageListDelegate *, char *))v38->loadMessagesFailed)(v38, v63);
return _stack_chk_guard;
}