//
// GameStatsManager::preSaveGameStats from 0x522d2c to 0x522e22 (246 bytes)
//
// 2 xrefs:
// > GameStatsManager::encodeDataTo @ 0x522e36
// > GJAccountManager::onSyncAccountCompleted @ 0x58280c
//
// 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:51:52 +0000
//
int __fastcall GameStatsManager::preSaveGameStats(GameStatsManager *this)
{
const char *v2; // r4
AchievementManager *v3; // r0
cocos2d::CCString *v4; // r0
const char *CString; // r0
const char *v6; // r6
size_t v7; // r0
char *v8; // r1
const char *Stat; // r0
char *v10; // r1
cocos2d::CCObject *v11; // r10
size_t v12; // r0
AchievementManager *v13; // r0
int result; // r0
char v15; // [sp+0h] [bp-34h]
int v16; // [sp+4h] [bp-30h]
char *v17; // [sp+Ch] [bp-28h]
int v18[2]; // [sp+14h] [bp-20h] BYREF
char *v19; // [sp+1Ch] [bp-18h]
int v20[3]; // [sp+20h] [bp-14h] BYREF
v2 = (_BYTE *)(&dword_0 + 1);
v3 = (AchievementManager *)AchievementManager::sharedState(this);
v15 = *((_BYTE *)v3 + 284);
*(_BYTE *)(AchievementManager::sharedState(v3) + 284) = 1;
do
{
v4 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat((cocos2d::CCString *)"%i", v2);
CString = (const char *)cocos2d::CCString::getCString(v4);
v18[0] = 0;
v18[1] = 0;
v19 = nullptr;
v6 = CString;
v7 = strlen(CString);
std::string::__init(v18, v6, v7);
v16 = *((_DWORD *)this + 92);
if ( (v18[0] & 1) != 0 )
v8 = v19;
else
v8 = (char *)v18 + 1;
Stat = (const char *)GameStatsManager::getStat(this, v8);
v11 = (cocos2d::CCObject *)cocos2d::CCString::createWithFormat((cocos2d::CCString *)"%i", Stat);
v20[0] = 0;
v20[1] = 0;
if ( (v18[0] & 1) == 0 )
v10 = (char *)v18 + 1;
v20[2] = 0;
if ( (v18[0] & 1) != 0 )
v10 = v19;
v17 = v10;
v12 = strlen(v10);
std::string::__init(v20, v17, v12);
cocos2d::CCDictionary::setObject(v16, v11);
++v2;
std::string::~string((int)v20);
v13 = (AchievementManager *)std::string::~string((int)v18);
}
while ( v2 != (_BYTE *)&word_2C + 1 );
result = AchievementManager::sharedState(v13);
*(_BYTE *)(result + 284) = v15;
return result;
}