//
// GameStatsManager::completedDemonLevel from 0x1402e1d50 to 0x1402e1fd3 (643 bytes)
//
// 5 xrefs:
// > GameLevelManager::updateLevelRewards @ 0x14021dede
// > GameManager::dataLoaded @ 0x14028411a
// > GameStatsManager::completedLevel @ 0x1402e1cfb
// > LevelInfoLayer::init @ 0x14041dc7c
// > ??> @ 0x14091de7c
//
// 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=1
void __fastcall GameStatsManager::completedDemonLevel(__int64 a1, __int64 a2)
{
cocos2d::CCString *v4; // rax
const char *v5; // rcx
const char *CString; // rax
size_t v7; // rbx
size_t v8; // r8
__int64 v9; // rbp
void *v10; // r8
cocos2d::CCString *v11; // rax
const char *v12; // rcx
const char *v13; // rax
void *v14; // rcx
void *Block[2]; // [rsp+30h] [rbp-58h] BYREF
__int128 v16; // [rsp+40h] [rbp-48h]
if ( *(_DWORD *)(a2 + 992) - *(_DWORD *)(a2 + 996) <= 0 )
{
v5 = "gdemon_%i";
if ( !*(_BYTE *)(a2 + 721) )
v5 = "demon_%i";
v4 = cocos2d::CCString::createWithFormat(v5);
}
else
{
v4 = cocos2d::CCString::createWithFormat("ddemon_%i");
}
CString = cocos2d::CCString::getCString(v4);
*(_OWORD *)Block = 0;
v16 = 0;
v7 = -1;
v8 = -1;
do
++v8;
while ( CString[v8] );
sub_14003D230(Block, CString, v8);
v9 = cocos2d::CCDictionary::objectForKey(*(_QWORD *)(a1 + 712), Block);
if ( *((_QWORD *)&v16 + 1) > 0xFu )
{
v10 = Block[0];
if ( (unsigned __int64)(*((_QWORD *)&v16 + 1) + 1LL) >= 0x1000 )
{
v10 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v10 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v10);
}
if ( !v9 && *(_DWORD *)(a2 + 1004) - *(_DWORD *)(a2 + 1008) == 1 )
{
if ( *(_DWORD *)(a2 + 992) - *(_DWORD *)(a2 + 996) <= 0 )
{
v12 = "gdemon_%i";
if ( !*(_BYTE *)(a2 + 721) )
v12 = "demon_%i";
v11 = cocos2d::CCString::createWithFormat(v12);
}
else
{
v11 = cocos2d::CCString::createWithFormat("ddemon_%i");
}
v13 = cocos2d::CCString::getCString(v11);
*(_OWORD *)Block = 0;
v16 = 0;
do
++v7;
while ( v13[v7] );
sub_14003D230(Block, v13, v7);
cocos2d::CCDictionary::setObject(*(_QWORD *)(a1 + 712), *(_QWORD *)(a1 + 328), Block);
if ( *((_QWORD *)&v16 + 1) > 0xFu )
{
v14 = Block[0];
if ( (unsigned __int64)(*((_QWORD *)&v16 + 1) + 1LL) >= 0x1000 )
{
v14 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v14 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v14);
}
if ( *(_DWORD *)(a2 + 1020) - *(_DWORD *)(a2 + 1024) >= 10 )
GameStatsManager::incrementStat(a1, (const char *)&word_14070D048, 1u);
}
}