//
// GameLevelManager::createAndGetMapPacks from 0x100543950 to 0x100543b85 (565 bytes)
//
// 3 xrefs:
// > GJAccountManager::onSyncAccountCompleted @ 0x10009f68e
// > GameLevelManager::onGetMapPacksCompleted @ 0x100524312
// > GameLevelManager::onGetGauntletsCompleted @ 0x10052e8d0
//
// This function is hookable on this platform (idp: pc, 32 bit: False, 64 bit: True!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 12:31:58 +0000
//
__int64 __fastcall GameLevelManager::createAndGetMapPacks(__int64 a1, __int64 a2)
{
const char *v2; // r14
size_t v3; // rax
size_t v4; // rbx
char *v5; // r15
size_t v6; // r12
__int64 v7; // r14
unsigned int v8; // r15d
__int64 v9; // rax
const char *CString; // rbx
size_t v11; // rax
size_t v12; // r13
char *v13; // r12
char v14; // r14
__int64 v15; // rax
size_t v16; // r14
_QWORD *v17; // rax
__int64 v18; // rbx
__int64 v20; // [rsp+8h] [rbp-68h]
__int128 v21; // [rsp+10h] [rbp-60h] BYREF
void *v22; // [rsp+20h] [rbp-50h]
__int64 v23; // [rsp+28h] [rbp-48h]
__int128 __dst; // [rsp+30h] [rbp-40h] BYREF
void *__p; // [rsp+40h] [rbp-30h]
v23 = sub_1007FE900(a1);
if ( (*(_BYTE *)a2 & 1) != 0 )
v2 = *(const char **)(a2 + 16);
else
v2 = (const char *)(a2 + 1);
v3 = strlen(v2);
if ( v3 >= 0xFFFFFFFFFFFFFFF8LL )
LABEL_32:
sub_100003630();
v4 = v3;
if ( v3 >= 0x17 )
{
v6 = 26;
if ( (v3 | 7) != 0x17 )
v6 = (v3 | 7) + 1;
v5 = (char *)operator new(v6);
__p = v5;
*(_QWORD *)&__dst = v6 + 1;
*((_QWORD *)&__dst + 1) = v4;
goto LABEL_11;
}
LOBYTE(__dst) = 2 * v3;
v5 = (char *)&__dst + 1;
if ( v3 )
LABEL_11:
memmove(v5, v2, v4);
v5[v4] = 0;
v7 = sub_10053FBE0((unsigned __int8 *)&__dst, "|");
if ( (__dst & 1) != 0 )
operator delete(__p);
if ( (unsigned int)sub_1007FEF90(v7) )
{
v8 = 0;
v20 = v7;
do
{
v9 = sub_1007FEFE0(v7, v8);
CString = (const char *)cocos2d::CCString::getCString(v9);
v11 = strlen(CString);
if ( v11 >= 0xFFFFFFFFFFFFFFF8LL )
goto LABEL_32;
v12 = v11;
if ( v11 >= 0x17 )
{
v15 = v11 | 7;
v16 = 26;
if ( (v12 | 7) != 0x17 )
v16 = v15 + 1;
v13 = (char *)operator new(v16);
__p = v13;
*(_QWORD *)&__dst = v16 + 1;
*((_QWORD *)&__dst + 1) = v12;
}
else
{
LOBYTE(__dst) = 2 * v11;
v13 = (char *)&__dst + 1;
if ( !v11 )
{
BYTE1(__dst) = 0;
v14 = __dst;
if ( (__dst & 1) != 0 )
goto LABEL_26;
goto LABEL_21;
}
}
memmove(v13, CString, v12);
v13[v12] = 0;
v14 = __dst;
if ( (__dst & 1) != 0 )
{
LABEL_26:
sub_10001AD30(&v21, __p, *((unsigned __int64 *)&__dst + 1));
goto LABEL_27;
}
LABEL_21:
v22 = __p;
v21 = __dst;
LABEL_27:
v17 = GameLevelManager::responseToDict((__int64)&v21, 0);
v18 = GJMapPack::create(v17);
if ( (v21 & 1) != 0 )
operator delete(v22);
sub_1007FEBF0(v23, v18);
if ( (v14 & 1) != 0 )
operator delete(__p);
++v8;
v7 = v20;
}
while ( v8 < (unsigned int)sub_1007FEF90(v20) );
}
return v23;
}