//
// GameStatsManager::markLevelAsCompletedAndClaimed from 0x1401de910 to 0x1401deb89 (633 bytes)
//
// 2 xrefs:
// > GameManager::recountUserStats @ 0x140185262
// > ??> @ 0x1406cc42c
//
// 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
//
// Hidden C++ exception states: #wind=2
void GameStatsManager::markLevelAsCompletedAndClaimed(GameStatsManager *a1, GJGameLevel *a2)
{
int v4; // eax
char v5; // r9
cocos2d::CCString *v6; // rax
const char *v7; // rcx
const char *CString; // rax
size_t v9; // rbx
size_t v10; // r8
void *v11; // rcx
cocos2d::CCString *v12; // rax
const char *v13; // rcx
const char *v14; // rax
void *v15; // rcx
void *Block[2]; // [rsp+48h] [rbp-50h] BYREF
__int128 v17; // [rsp+58h] [rbp-40h]
_QWORD v18[4]; // [rsp+68h] [rbp-30h] BYREF
v4 = a2->m_dailyID.random - a2->m_dailyID.seed;
v5 = a2->m_levelType != Main && v4 <= 0;
GameStatsManager::getLevelKey(
a2->m_gauntletLevel,
v18,
a2->m_levelID.random - a2->m_levelID.seed,
v5,
v4 > 0,
a2->m_gauntletLevel,
v4 > 200000);
cocos2d::CCDictionary::setObject(a1->m_completedLevels, a1->m_trueString, v18);
if ( a2->m_dailyID.random - a2->m_dailyID.seed <= 0 )
{
v7 = "gstar_%i";
if ( !a2->m_gauntletLevel )
v7 = "star_%i";
v6 = cocos2d::CCString::createWithFormat(v7);
}
else
{
v6 = cocos2d::CCString::createWithFormat("dstar_%i");
}
CString = cocos2d::CCString::getCString(v6);
*(_OWORD *)Block = 0;
v17 = 0;
v9 = -1;
v10 = -1;
do
++v10;
while ( CString[v10] );
sub_14003A930(Block, CString, v10);
cocos2d::CCDictionary::setObject(a1->m_completedLevels, a1->m_trueString, Block);
if ( *((_QWORD *)&v17 + 1) > 0xFu )
{
v11 = Block[0];
if ( (unsigned __int64)(*((_QWORD *)&v17 + 1) + 1LL) >= 0x1000 )
{
v11 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v11 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v11);
}
if ( a2->m_dailyID.random - a2->m_dailyID.seed <= 0 )
{
v13 = "gdemon_%i";
if ( !a2->m_gauntletLevel )
v13 = "demon_%i";
v12 = cocos2d::CCString::createWithFormat(v13);
}
else
{
v12 = cocos2d::CCString::createWithFormat("ddemon_%i");
}
v14 = cocos2d::CCString::getCString(v12);
*(_OWORD *)Block = 0;
v17 = 0;
do
++v9;
while ( v14[v9] );
sub_14003A930(Block, v14, v9);
cocos2d::CCDictionary::setObject(a1->m_completedLevels, a1->m_trueString, Block);
if ( *((_QWORD *)&v17 + 1) > 0xFu )
{
v15 = Block[0];
if ( (unsigned __int64)(*((_QWORD *)&v17 + 1) + 1LL) >= 0x1000 )
{
v15 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v15 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v15);
}
sub_14003A830((__int64)v18);
}