//
// GJGameLevel::savePercentage from 0x4d6e00 to 0x4d6f9e (414 bytes)
//
// 2 xrefs:
// > PlayLayer::destroyPlayer @ 0x405c5e
// > PlayLayer::levelComplete @ 0x407ef2
//
// 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:53 +0000
//
GJGameLevel *__fastcall GJGameLevel::savePercentage(GJGameLevel *this, int a2, int a3, int a4, int a5, bool a6)
{
GJGameLevel *v7; // r4
int v8; // r5
int v10; // r3
int v11; // r9
int v12; // r3
int v13; // r9
int v14; // r3
char *v15; // r0
int v16[3]; // [sp+Ch] [bp-21Ch] BYREF
int v17[3]; // [sp+18h] [bp-210h] BYREF
unsigned int v18[3]; // [sp+24h] [bp-204h] BYREF
char v19; // [sp+30h] [bp-1F8h] BYREF
if ( a2 >= 100 )
a2 = 100;
v7 = this;
v8 = a2 & ~(a2 >> 31);
if ( a3 )
{
v10 = *((_DWORD *)this + 178);
if ( v10 < v8 )
{
LABEL_12:
*((_DWORD *)v7 + 178) = v8;
return this;
}
if ( v10 != v8 )
return this;
LABEL_9:
if ( a4 <= 0 || *((_DWORD *)v7 + 161) - *((_DWORD *)v7 + 162) > 0 )
{
if ( a3 )
return this;
goto LABEL_15;
}
if ( a3 )
goto LABEL_12;
goto LABEL_13;
}
this = (GJGameLevel *)GJGameLevel::getNormalPercent(this);
if ( (int)this >= v8 )
{
if ( this != (GJGameLevel *)v8 )
goto LABEL_15;
goto LABEL_9;
}
LABEL_13:
this = (GJGameLevel *)GJGameLevel::setNormalPercent(v7, v8);
LABEL_15:
v11 = *((_DWORD *)v7 + 175) - *((_DWORD *)v7 + 176);
if ( v11 < v8 )
{
GJGameLevel::setNewNormalPercent2(v7, v8);
GJGameLevel::setClicks(v7, a4);
GJGameLevel::setAttemptTime(v7, a5);
*((_BYTE *)v7 + 672) = a6;
v12 = 1482;
if ( !a6 )
v12 = 0;
v13 = v8 - v11;
*((_DWORD *)v7 + 167) = (a5 + 4085) * (a5 + 4085) + (a4 + 3991) * (v8 + 8354) + v12 - 50028039;
std::string::basic_string(v16, (int)v7 + 988);
v18[0] = 0;
v18[1] = 500;
v18[2] = (unsigned int)&v19;
if ( (v16[0] & 1) != 0 )
v14 = v16[1];
else
v14 = (int)LOBYTE(v16[0]) >> 1;
if ( v14 )
fmt::BasicWriter::operator<<(v18, ",", 0);
fmt::BasicWriter::operator<<(v18, v13);
v15 = (char *)fmt::BasicWriter::c_str((int *)v18);
std::string::append(v16, v15);
std::string::basic_string(v17, (int)v16);
std::string::operator=((unsigned __int8 *)v7 + 988, (unsigned __int8 *)v17);
std::string::~string((int)v17);
fmt::internal::Array::free((int)v18);
this = (GJGameLevel *)std::string::~string((int)v16);
}
if ( *((_DWORD *)v7 + 172) - *((_DWORD *)v7 + 173) < v8 )
return (GJGameLevel *)GJGameLevel::setNewNormalPercent(v7, v8);
return this;
}