//
// GameLevelManager::saveLevel from 0x4b5380 to 0x4b5808 (1160 bytes)
//
// 7 xrefs:
// > LevelInfoLayer::downloadLevel @ 0x49a004
// > GameLevelManager::gotoLevelPage @ 0x4b58fc
// > GameLevelManager::processOnDownloadLevelCompleted @ 0x4da09c
// > GameLevelManager::processOnDownloadLevelCompleted @ 0x4da0e4
// > GameLevelManager::processOnDownloadLevelCompleted @ 0x4da108
// > GameLevelManager::processOnDownloadLevelCompleted @ 0x4da12c
// > GameLevelManager::processOnDownloadLevelCompleted @ 0x4da162
//
// This function is hookable on this platform (idp: arm, 32 bit: True, 64 bit: False!
//
// 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 11:50:08 +0000
//
int __fastcall GameLevelManager::saveLevel(GameLevelManager *this, GJGameLevel *a2)
{
int v4; // r8
_BOOL4 v5; // r7
_DWORD *SavedLevel; // r0
_DWORD *v7; // r5
int NormalPercent; // r0
int v9; // r3
int v10; // r3
int v11; // r3
int v12; // r3
int v13; // r3
int v14; // r3
int v15; // r5
cocos2d::CCString *v16; // r0
const char *v17; // r0
const char *v18; // r7
size_t v19; // r0
int v20; // r5
cocos2d::CCString *v21; // r0
const char *CString; // r0
const char *v23; // r8
size_t v24; // r0
int v25; // r5
const char *LevelKey; // r0
const char *v27; // r7
size_t v28; // r0
_BOOL4 v30; // [sp+4h] [bp-28h]
int v31[3]; // [sp+Ch] [bp-20h] BYREF
int v32; // [sp+18h] [bp-14h] BYREF
int v33; // [sp+1Ch] [bp-10h]
int v34; // [sp+20h] [bp-Ch]
v4 = *((unsigned __int8 *)a2 + 477);
v5 = *((_DWORD *)a2 + 186) - *((_DWORD *)a2 + 187) > 0;
SavedLevel = (_DWORD *)GameLevelManager::getSavedLevel(this, a2);
v7 = SavedLevel;
if ( v5 || v4 )
{
if ( !SavedLevel || SavedLevel[67] - SavedLevel[68] != *((_DWORD *)a2 + 67) - *((_DWORD *)a2 + 68) )
goto LABEL_33;
}
else if ( !SavedLevel )
{
goto LABEL_37;
}
GJGameLevel::setAttempts(a2, SavedLevel[155] - SavedLevel[156]);
*((_DWORD *)a2 + 296) = v7[296];
GJGameLevel::setJumps(a2, v7[158] - v7[159]);
GJGameLevel::setClicks(a2, v7[161] - v7[162]);
GJGameLevel::setAttemptTime(a2, v7[164] - v7[165]);
*((_BYTE *)a2 + 672) = *((_BYTE *)v7 + 672);
*((_DWORD *)a2 + 167) = v7[167];
std::string::basic_string(&v32, (int)(v7 + 247));
std::string::operator=((unsigned __int8 *)a2 + 988, (unsigned __int8 *)&v32);
std::string::~string((int)&v32);
NormalPercent = GJGameLevel::getNormalPercent((GJGameLevel *)v7);
GJGameLevel::setNormalPercent(a2, NormalPercent);
*((_DWORD *)a2 + 178) = v7[178];
GJGameLevel::setNewNormalPercent(a2, v7[172] - v7[173]);
GJGameLevel::setNewNormalPercent2(a2, v7[175] - v7[176]);
*((_DWORD *)a2 + 260) = v7[260];
*((_DWORD *)a2 + 261) = v7[261];
*((_DWORD *)a2 + 262) = v7[262];
*((_DWORD *)a2 + 263) = v7[263];
std::string::operator=((unsigned __int8 *)a2 + 1056, (unsigned __int8 *)v7 + 1056);
*((_DWORD *)a2 + 267) = v7[267];
*((_DWORD *)a2 + 268) = v7[268];
*((_DWORD *)a2 + 269) = v7[269];
*((_DWORD *)a2 + 270) = v7[270];
std::string::operator=((unsigned __int8 *)a2 + 1084, (unsigned __int8 *)v7 + 1084);
*((_DWORD *)a2 + 274) = v7[274];
*((_BYTE *)a2 + 1124) = *((_BYTE *)v7 + 1124);
*((_BYTE *)a2 + 1125) = *((_BYTE *)v7 + 1125);
*((_DWORD *)a2 + 282) = v7[282];
*((_BYTE *)a2 + 1180) = *((_BYTE *)v7 + 1180);
*((_DWORD *)a2 + 297) = v7[297];
std::string::operator=((unsigned __int8 *)a2 + 1192, (unsigned __int8 *)v7 + 1192);
std::string::operator=((unsigned __int8 *)a2 + 1204, (unsigned __int8 *)v7 + 1204);
std::string::operator=((unsigned __int8 *)a2 + 1216, (unsigned __int8 *)v7 + 1216);
std::string::operator=((unsigned __int8 *)a2 + 1228, (unsigned __int8 *)v7 + 1228);
*((_DWORD *)a2 + 310) = v7[310];
*((_DWORD *)a2 + 311) = v7[311];
*((_DWORD *)a2 + 312) = v7[312];
*((_DWORD *)a2 + 313) = v7[313];
*((_DWORD *)a2 + 314) = v7[314];
std::string::operator=((unsigned __int8 *)a2 + 1260, (unsigned __int8 *)v7 + 1260);
std::string::operator=((unsigned __int8 *)a2 + 1272, (unsigned __int8 *)v7 + 1272);
*((_BYTE *)a2 + 1284) = *((_BYTE *)v7 + 1284);
*((_DWORD *)a2 + 326) = v7[326];
std::string::operator=((unsigned __int8 *)a2 + 1328, (unsigned __int8 *)v7 + 1328);
*((_DWORD *)a2 + 335) = v7[335];
std::string::operator=((unsigned __int8 *)a2 + 1344, (unsigned __int8 *)v7 + 1344);
*((_DWORD *)a2 + 339) = v7[339];
*((_BYTE *)a2 + 1360) = *((_BYTE *)v7 + 1360);
*((_DWORD *)a2 + 341) = v7[341];
if ( v7[153] == *((_DWORD *)a2 + 153) )
{
std::string::operator=((unsigned __int8 *)a2 + 1288, (unsigned __int8 *)v7 + 1288);
*((_BYTE *)a2 + 1300) = *((_BYTE *)v7 + 1300);
}
if ( *((_BYTE *)v7 + 593)
|| GJGameLevel::getNormalPercent((GJGameLevel *)v7) > 0
|| ((v9 = *((unsigned __int8 *)v7 + 1148), (v9 & 1) != 0) ? (v10 = v7[288]) : (v10 = v9 >> 1), v10) )
{
*((_BYTE *)a2 + 593) = *((_BYTE *)v7 + 593);
}
v11 = v7[115];
if ( v11 > *((_DWORD *)a2 + 115) )
*((_DWORD *)a2 + 115) = v11;
if ( *((_BYTE *)v7 + 736) )
*((_BYTE *)a2 + 736) = 1;
v12 = v7[185];
if ( v12 > 0 )
*((_DWORD *)a2 + 185) = v12;
if ( *((_BYTE *)v7 + 478) )
*((_BYTE *)a2 + 478) = 1;
std::string::basic_string(v31, (int)a2 + 316);
v32 = 0;
v33 = 0;
v34 = 0;
std::string::__init(&v32, "-", 1u);
v30 = sub_4A9CC4((unsigned __int8 *)v31, (unsigned __int8 *)&v32);
std::string::~string((int)&v32);
std::string::~string((int)v31);
if ( v30 )
{
std::string::basic_string(&v32, (int)(v7 + 79));
std::string::operator=((unsigned __int8 *)a2 + 316, (unsigned __int8 *)&v32);
std::string::~string((int)&v32);
}
if ( *((_DWORD *)a2 + 104) == *((_DWORD *)a2 + 105) )
GJGameLevel::setAccountID(a2, v7[104] - v7[105]);
if ( v7[153] == *((_DWORD *)a2 + 153) )
{
v13 = *((unsigned __int8 *)a2 + 1148);
if ( (v13 & 1) != 0 )
v14 = *((_DWORD *)a2 + 288);
else
v14 = v13 >> 1;
if ( !v14 || v7[294] > *((_DWORD *)a2 + 294) )
{
std::string::operator=((unsigned __int8 *)a2 + 1148, (unsigned __int8 *)v7 + 1148);
std::string::operator=((unsigned __int8 *)a2 + 1160, (unsigned __int8 *)v7 + 1160);
*((_DWORD *)a2 + 293) = v7[293];
*((_DWORD *)a2 + 294) = v7[294];
}
}
LABEL_33:
if ( !v5 )
{
if ( v4 )
{
v20 = *((_DWORD *)this + 168);
v21 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"%i",
(const char *)(*((_DWORD *)a2 + 67) - *((_DWORD *)a2 + 68)));
CString = (const char *)cocos2d::CCString::getCString(v21);
v32 = 0;
v33 = 0;
v34 = 0;
v23 = CString;
v24 = strlen(CString);
std::string::__init(&v32, v23, v24);
cocos2d::CCDictionary::setObject(v20, a2);
return std::string::~string((int)&v32);
}
LABEL_37:
v25 = *((_DWORD *)this + 136);
LevelKey = (const char *)GameLevelManager::getLevelKey(
this,
(const char *)(*((_DWORD *)a2 + 67) - *((_DWORD *)a2 + 68)));
v32 = v4;
v33 = v4;
v34 = v4;
v27 = LevelKey;
v28 = strlen(LevelKey);
std::string::__init(&v32, v27, v28);
cocos2d::CCDictionary::setObject(v25, a2);
return std::string::~string((int)&v32);
}
v15 = *((_DWORD *)this + 147);
v16 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"%i",
(const char *)(*((_DWORD *)a2 + 186) - *((_DWORD *)a2 + 187)));
v17 = (const char *)cocos2d::CCString::getCString(v16);
v32 = 0;
v33 = 0;
v34 = 0;
v18 = v17;
v19 = strlen(v17);
std::string::__init(&v32, v18, v19);
cocos2d::CCDictionary::setObject(v15, a2);
return std::string::~string((int)&v32);
}