//
// GameLevelManager::onGetLevelCommentsCompleted from 0x100520a90 to 0x100520f20 (1168 bytes)
//
// 1 xrefs:
// > GameLevelManager::handleIt @ 0x10051bef9
//
// 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 GameLevelManager::onGetLevelCommentsCompleted(
GameLevelManager *a1,
unsigned __int8 *a2,
__int64 a3,
double a4)
{
const char *v4; // rbx
const void *v5; // r12
unsigned __int64 v6; // rcx
char *v7; // r13
size_t v8; // rdx
LevelCommentDelegate *m_levelCommentDelegate; // rdi
size_t v10; // rax
size_t v11; // r15
size_t v12; // r14
__int64 v13; // r12
LevelCommentDelegate *v14; // rdi
cocos2d::CCString *v15; // rax
const char *CString; // r15
size_t v17; // rax
size_t v18; // r13
const char *v19; // rbx
char *v20; // r14
const char *v21; // rbx
size_t v22; // r15
cocos2d::CCString *v23; // rax
const char *v24; // r12
size_t v25; // rax
size_t v26; // r13
char *v27; // r15
size_t v28; // r14
GameLevelManager *v29; // r13
LevelCommentDelegate *v30; // r15
char v31; // r14
__int64 CommentsFull; // r15
char v33; // r12
LevelCommentDelegate *v34; // rdi
__int128 v35; // [rsp+0h] [rbp-E0h] BYREF
void *v36; // [rsp+10h] [rbp-D0h]
__int128 v37; // [rsp+20h] [rbp-C0h] BYREF
void *v38; // [rsp+30h] [rbp-B0h]
GameLevelManager *v39; // [rsp+40h] [rbp-A0h]
unsigned int v40; // [rsp+4Ch] [rbp-94h]
__int128 v41; // [rsp+50h] [rbp-90h] BYREF
void *v42; // [rsp+60h] [rbp-80h]
__int128 __dst; // [rsp+68h] [rbp-78h] BYREF
void *v44; // [rsp+78h] [rbp-68h]
const char *v45; // [rsp+80h] [rbp-60h]
__int128 v46; // [rsp+88h] [rbp-58h] BYREF
void *v47; // [rsp+98h] [rbp-48h]
__int128 __s2; // [rsp+A0h] [rbp-40h] BYREF
void *__p; // [rsp+B0h] [rbp-30h]
if ( (*(_BYTE *)a3 & 1) != 0 )
v4 = *(const char **)(a3 + 16);
else
v4 = (const char *)(a3 + 1);
v40 = GameLevelManager::levelIDFromCommentKey(a1, v4);
v45 = v4;
GameLevelManager::removeDLFromActive(a1, v4);
LOBYTE(__s2) = 4;
*(_WORD *)((char *)&__s2 + 1) = 12589;
BYTE3(__s2) = 0;
v5 = a2 + 1;
v6 = *a2 >> 1;
if ( (*a2 & 1) != 0 )
v5 = *((const void **)a2 + 2);
v7 = (char *)&__s2 + 1;
if ( (*a2 & 1) != 0 )
v6 = *((_QWORD *)a2 + 1);
v8 = 2;
if ( v6 < 2 )
v8 = v6;
if ( !((v6 != 2) | (memcmp(v5, (char *)&__s2 + 1, v8) != 0)) )
{
m_levelCommentDelegate = a1->m_levelCommentDelegate;
if ( m_levelCommentDelegate )
((void (__fastcall *)(LevelCommentDelegate *, const char *))m_levelCommentDelegate->loadCommentsFailed)(
m_levelCommentDelegate,
v45);
return;
}
v39 = a1;
v10 = strlen((const char *)v5);
if ( v10 >= 0xFFFFFFFFFFFFFFF8LL )
goto LABEL_70;
v11 = v10;
if ( v10 >= 0x17 )
{
v12 = 26;
if ( (v10 | 7) != 0x17 )
v12 = (v10 | 7) + 1;
v7 = (char *)operator new(v12);
__p = v7;
*(_QWORD *)&__s2 = v12 + 1;
*((_QWORD *)&__s2 + 1) = v11;
goto LABEL_20;
}
LOBYTE(__s2) = 2 * v10;
if ( v10 )
LABEL_20:
memmove(v7, v5, v11);
v7[v11] = 0;
v13 = sub_10052DD30(&__s2, "#");
if ( (__s2 & 1) != 0 )
operator delete(__p);
if ( (unsigned int)sub_100720070(v13) <= 1 )
{
v14 = v39->m_levelCommentDelegate;
if ( v14 )
((void (__fastcall *)(LevelCommentDelegate *, const char *))v14->loadCommentsFailed)(v14, v45);
return;
}
v15 = (cocos2d::CCString *)sub_1007200C0(v13, 0);
CString = cocos2d::CCString::getCString(v15);
v17 = strlen(CString);
if ( v17 >= 0xFFFFFFFFFFFFFFF8LL )
LABEL_70:
sub_100006BF0(a4);
v18 = v17;
v19 = v45;
if ( v17 >= 0x17 )
{
v21 = CString;
v22 = 26;
if ( (v17 | 7) != 0x17 )
v22 = (v17 | 7) + 1;
v20 = (char *)operator new(v22);
v44 = v20;
*(_QWORD *)&__dst = v22 + 1;
CString = v21;
v19 = v45;
*((_QWORD *)&__dst + 1) = v18;
goto LABEL_33;
}
LOBYTE(__dst) = 2 * v17;
v20 = (char *)&__dst + 1;
if ( v17 )
LABEL_33:
memmove(v20, CString, v18);
v20[v18] = 0;
v23 = (cocos2d::CCString *)sub_1007200C0(v13, 1);
v24 = cocos2d::CCString::getCString(v23);
v25 = strlen(v24);
if ( v25 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100006BF0(a4);
v26 = v25;
if ( v25 >= 0x17 )
{
v28 = 26;
if ( (v25 | 7) != 0x17 )
v28 = (v25 | 7) + 1;
v27 = (char *)operator new(v28);
v47 = v27;
*(_QWORD *)&v46 = v28 | 1;
*((_QWORD *)&v46 + 1) = v26;
}
else
{
LOBYTE(v46) = 2 * v25;
v27 = (char *)&v46 + 1;
if ( !v25 )
goto LABEL_42;
}
memmove(v27, v24, v26);
LABEL_42:
v27[v26] = 0;
v29 = v39;
v30 = v39->m_levelCommentDelegate;
if ( v30 )
{
if ( (v46 & 1) != 0 )
{
sub_100006B70(&v35, v47, *((unsigned __int64 *)&v46 + 1), a4);
}
else
{
v36 = v47;
a4 = *(double *)&v46;
v35 = v46;
}
((void (__fastcall *)(LevelCommentDelegate *, __int128 *, const char *))v30->setupPageInfo)(v30, &v35, v19);
if ( (v35 & 1) != 0 )
operator delete(v36);
}
v31 = __dst;
if ( (__dst & 1) != 0 )
{
sub_100006B70(&v41, v44, *((unsigned __int64 *)&__dst + 1), a4);
}
else
{
v42 = v44;
a4 = *(double *)&__dst;
v41 = __dst;
}
if ( (v41 & 1) != 0 )
{
sub_100006B70(&__s2, v42, *((unsigned __int64 *)&v41 + 1), a4);
}
else
{
__p = v42;
a4 = *(double *)&v41;
__s2 = v41;
}
CommentsFull = GameLevelManager::createAndGetCommentsFull(v29, &__s2, v40, 0);
if ( (__s2 & 1) == 0 )
{
if ( (v41 & 1) == 0 )
goto LABEL_56;
LABEL_59:
operator delete(v42);
v33 = v46;
if ( (v46 & 1) == 0 )
goto LABEL_57;
LABEL_60:
sub_100006B70(&v37, v47, *((unsigned __int64 *)&v46 + 1), a4);
goto LABEL_61;
}
operator delete(__p);
if ( (v41 & 1) != 0 )
goto LABEL_59;
LABEL_56:
v33 = v46;
if ( (v46 & 1) != 0 )
goto LABEL_60;
LABEL_57:
v38 = v47;
v37 = v46;
LABEL_61:
GameLevelManager::storeCommentsResult(v29, CommentsFull, &v37, v19);
if ( (v37 & 1) != 0 )
operator delete(v38);
v34 = v29->m_levelCommentDelegate;
if ( v34 )
((void (__fastcall *)(LevelCommentDelegate *, __int64, const char *))v34->loadCommentsFinished)(
v34,
CommentsFull,
v19);
if ( (v33 & 1) != 0 )
operator delete(v47);
if ( (v31 & 1) != 0 )
operator delete(v44);
}