//
// GameLevelManager::onGetLevelSaveDataCompleted from 0x1005265a0 to 0x100526839 (665 bytes)
//
// 1 xrefs:
// > GameLevelManager::handleIt @ 0x10051caaa
//
// 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::onGetLevelSaveDataCompleted(
GameLevelManager *a1,
unsigned __int8 *a2,
__int64 a3,
double a4)
{
const char *v4; // rdx
unsigned __int8 v5; // r14
unsigned __int64 v6; // r15
char *v7; // r13
char *v8; // rdi
unsigned __int64 v9; // rbx
unsigned __int64 v10; // rax
size_t v11; // rdx
size_t v12; // rax
size_t v13; // r15
char *v14; // r14
size_t v15; // rbx
cocos2d::CCArray *v16; // r14
unsigned int i; // r15d
cocos2d::CCString *v18; // rax
int v19; // r12d
cocos2d::CCString *v20; // rax
int v21; // r13d
GameLevelManager *v22; // rdi
GJGameLevel *SavedLevel; // rax
GJGameLevel *v24; // r12
float v25; // xmm0_4
_BOOL4 v26; // ebx
float v27; // xmm0_4
std::string v28; // [rsp+8h] [rbp-68h] BYREF
GameLevelManager *v29; // [rsp+20h] [rbp-50h]
char *__s; // [rsp+28h] [rbp-48h]
_QWORD __s2[2]; // [rsp+30h] [rbp-40h] BYREF
void *v32; // [rsp+40h] [rbp-30h]
v29 = a1;
if ( (*(_BYTE *)a3 & 1) != 0 )
v4 = *(const char **)(a3 + 16);
else
v4 = (const char *)(a3 + 1);
GameLevelManager::removeDLFromActive(v29, v4);
*(_WORD *)((char *)__s2 + 1) = 12589;
BYTE3(__s2[0]) = 0;
v5 = *a2;
v6 = *a2 >> 1;
v7 = *((char **)a2 + 2);
v8 = v7;
__s = (char *)(a2 + 1);
if ( (v5 & 1) == 0 )
v8 = (char *)(a2 + 1);
v9 = *((_QWORD *)a2 + 1);
v10 = v9;
if ( (v5 & 1) == 0 )
v10 = v6;
v11 = 2;
if ( v10 < 2 )
v11 = v10;
if ( ((v10 == 2) & (memcmp(v8, (char *)__s2 + 1, v11) == 0)) == 0 )
{
if ( (v5 & 1) != 0 )
{
if ( strlen(v7) < 0x29 )
return;
v6 = v9;
__s = v7;
if ( v9 > 0x13 )
{
LABEL_15:
v12 = v6 - 40;
v13 = v6 - 20;
if ( v13 >= v12 )
v13 = v12;
v14 = (char *)__s2 + 1;
if ( v13 >= 0x17 )
{
v15 = 26;
if ( (v13 | 7) != 0x17 )
v15 = (v13 | 7) + 1;
v14 = (char *)operator new(v15);
v32 = v14;
__s2[0] = v15 + 1;
__s2[1] = v13;
}
else
{
LOBYTE(__s2[0]) = 2 * v13;
if ( !v13 )
{
LABEL_27:
v14[v13] = 0;
cocos2d::ZipUtils::decompressString(&v28, (char *)__s2, 0, 11, a4);
v16 = (cocos2d::CCArray *)sub_10052DD30(&v28, ",");
for ( i = 1; i < (unsigned int)sub_100720070(v16); i += 2 )
{
v18 = cocos2d::CCArray::stringAtIndex(v16, i - 1);
v19 = cocos2d::CCString::intValue(v18);
v20 = cocos2d::CCArray::stringAtIndex(v16, i);
v21 = cocos2d::CCString::intValue(v20);
if ( (unsigned int)(v21 - 1) <= 9 )
{
v22 = v29;
SavedLevel = GameLevelManager::getSavedLevel(v29, v19);
v24 = SavedLevel;
if ( SavedLevel )
{
SavedLevel->m_stars.value = v21;
v25 = (float)((float)rand() * 4.6566129e-10) * 1000.0;
v24->m_stars.seed = (int)v25;
v24->m_stars.random = v21 + (int)v25;
v26 = v21 == 10;
v24->m_demon.value = v26;
v27 = (float)((float)rand() * 4.6566129e-10) * 1000.0;
v24->m_demon.seed = (int)v27;
v24->m_demon.random = (int)v27 + v26;
GameLevelManager::verifyLevelState(v22, v24);
GameLevelManager::updateLevelRewards(v22, v24);
}
}
}
if ( (*(_BYTE *)&v28.__r_.__value_.__s.0 & 1) != 0 )
operator delete(v28.__r_.__value_.__l.__data_);
if ( (__s2[0] & 1) != 0 )
operator delete(v32);
return;
}
}
memmove(v14, __s + 20, v13);
goto LABEL_27;
}
}
else
{
if ( strlen(__s) < 0x29 )
return;
if ( v5 >= 0x28u )
goto LABEL_15;
}
sub_1000547C0();
}
}