//
// GameStatsManager::markLevelAsCompletedAndClaimed from 0x1402e21a0 to 0x1402e244b (683 bytes)
//
// 2 xrefs:
// > GameManager::recountUserStats @ 0x140280bb7
// > ??> @ 0x14091de94
//
// This function is hookable on this platform (idp: pc, 32 bit: False, 64 bit: True!
//
// 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:29:49 +0000
//
// Hidden C++ exception states: #wind=2
void __fastcall GameStatsManager::markLevelAsCompletedAndClaimed(__int64 a1, __int64 a2)
{
__int64 v3; // rsi
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
v3 = a1;
v4 = *(_DWORD *)(a2 + 992) - *(_DWORD *)(a2 + 996);
v5 = *(_DWORD *)(a2 + 1220) != 1 && v4 <= 0;
LOBYTE(a1) = *(_DWORD *)(a2 + 992) - *(_DWORD *)(a2 + 996) > 0;
GameStatsManager::getLevelKey(
a1,
v18,
*(_DWORD *)(a2 + 328) - *(_DWORD *)(a2 + 332),
v5,
a1,
*(_BYTE *)(a2 + 721),
v4 > 200000);
cocos2d::CCDictionary::setObject(*(_QWORD *)(v3 + 712), *(_QWORD *)(v3 + 328), v18);
if ( *(_DWORD *)(a2 + 992) - *(_DWORD *)(a2 + 996) <= 0 )
{
v7 = "gstar_%i";
if ( !*(_BYTE *)(a2 + 721) )
v7 = "star_%i";
v6 = cocos2d::CCString::createWithFormat(v7, (unsigned int)(*(_DWORD *)(a2 + 328) - *(_DWORD *)(a2 + 332)));
}
else
{
v6 = cocos2d::CCString::createWithFormat("%s%i", "dstar_", *(_DWORD *)(a2 + 992) - *(_DWORD *)(a2 + 996));
}
CString = cocos2d::CCString::getCString(v6);
*(_OWORD *)Block = 0;
v17 = 0;
v9 = -1;
v10 = -1;
do
++v10;
while ( CString[v10] );
sub_14003D230(Block, CString, v10);
cocos2d::CCDictionary::setObject(*(_QWORD *)(v3 + 712), *(_QWORD *)(v3 + 328), 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 )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v11);
}
if ( *(_DWORD *)(a2 + 992) - *(_DWORD *)(a2 + 996) <= 0 )
{
v13 = "gdemon_%i";
if ( !*(_BYTE *)(a2 + 721) )
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_14003D230(Block, v14, v9);
cocos2d::CCDictionary::setObject(*(_QWORD *)(v3 + 712), *(_QWORD *)(v3 + 328), 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 )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v15);
}
sub_14003D310((__int64)v18);
}