//
// GameStatsManager::awardCurrencyForLevel from 0x1402e4380 to 0x1402e48ee (1390 bytes)
//
// 5 xrefs:
// > GameLevelManager::updateLevelRewards @ 0x14021e0f1
// > PlayLayer::levelComplete @ 0x140506cb4
// > PlayLayer::destroyPlayer @ 0x140512d21
// > ??> @ 0x14091df48
// > ??> @ 0x14091df54
//
// 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=4
__int64 __fastcall GameStatsManager::awardCurrencyForLevel(_QWORD *a1, __int64 a2)
{
int v4; // r9d
int v5; // r14d
int v6; // r8d
int v7; // edx
int v8; // eax
int v9; // ecx
__int64 v10; // r12
cocos2d::CCString *v11; // rax
const char *CString; // rax
size_t v13; // rbx
size_t v14; // r8
cocos2d::CCString *v15; // rax
__int128 *v16; // rdx
size_t v17; // r8
cocos2d::CCString *v18; // rax
int v19; // esi
float BaseCurrencyForLevel; // xmm7_4
int v21; // r15d
int v22; // esi
signed int v23; // esi
__int128 *v24; // rdx
size_t v25; // r8
struct cocos2d::CCString *v26; // rax
__int64 v27; // rax
__int64 v28; // r14
cocos2d::CCString *v29; // rax
const char *v30; // rax
size_t v31; // r8
cocos2d::CCString *v32; // rax
void **v33; // rdx
size_t v34; // r8
cocos2d::CCString *v35; // rax
int v36; // edi
void *v37; // r8
void **v38; // rdx
struct cocos2d::CCString *v39; // rax
void *v40; // rcx
void *v41; // rcx
int v43; // [rsp+30h] [rbp-69h]
int v44; // [rsp+34h] [rbp-65h]
int v45; // [rsp+38h] [rbp-61h]
void *Block[2]; // [rsp+40h] [rbp-59h] BYREF
__int128 v47; // [rsp+50h] [rbp-49h]
void *v48[2]; // [rsp+60h] [rbp-39h] BYREF
__int128 v49; // [rsp+70h] [rbp-29h]
__int128 v50; // [rsp+80h] [rbp-19h] BYREF
__int128 v51; // [rsp+90h] [rbp-9h]
v4 = *(_DWORD *)(a2 + 1020) - *(_DWORD *)(a2 + 1024);
v43 = v4;
v5 = *(_DWORD *)(a2 + 936) - *(_DWORD *)(a2 + 940);
v6 = *(_DWORD *)(a2 + 1220);
v44 = v6;
v7 = *(_DWORD *)(a2 + 992);
v8 = *(_DWORD *)(a2 + 996);
v9 = v7 - v8;
v45 = v7 - v8;
if ( v7 - v8 <= 0 )
{
if ( v6 == 1 )
{
v10 = a1[94];
}
else if ( *(_BYTE *)(a2 + 721) )
{
v10 = a1[95];
}
else
{
v10 = a1[93];
}
}
else
{
v10 = a1[96];
}
if ( v4 <= 0 || v5 <= 0 )
return 0;
if ( v9 > 0 )
{
if ( !(unsigned __int8)GameStatsManager::isDailyRecall(a1, (unsigned int)v9) )
{
v7 = *(_DWORD *)(a2 + 992);
v8 = *(_DWORD *)(a2 + 996);
goto LABEL_13;
}
return 0;
}
LABEL_13:
if ( v5 > 100 )
v5 = 100;
if ( v7 - v8 <= 0 )
{
v15 = cocos2d::CCString::createWithFormat(
(const char *)&word_1406ED6F8,
(unsigned int)(*(_DWORD *)(a2 + 328) - *(_DWORD *)(a2 + 332)));
CString = cocos2d::CCString::getCString(v15);
v50 = 0;
v51 = 0;
v13 = -1;
v14 = -1;
do
++v14;
while ( CString[v14] );
}
else
{
v11 = cocos2d::CCString::createWithFormat((const char *)&word_1406ED6F8);
CString = cocos2d::CCString::getCString(v11);
v50 = 0;
v51 = 0;
v13 = -1;
v14 = -1;
do
++v14;
while ( CString[v14] );
}
sub_14003D230(&v50, CString, v14);
v16 = &v50;
if ( *((_QWORD *)&v51 + 1) > 0xFu )
v16 = (__int128 *)v50;
*(_OWORD *)Block = 0;
v47 = 0;
v17 = -1;
do
++v17;
while ( *((_BYTE *)v16 + v17) );
sub_14003D230(Block, v16, v17);
v18 = (cocos2d::CCString *)cocos2d::CCDictionary::valueForKey(v10, Block);
v19 = cocos2d::CCString::intValue(v18);
sub_14003D310((__int64)Block);
if ( v19 >= v5 )
goto LABEL_67;
BaseCurrencyForLevel = (float)(int)GameStatsManager::getBaseCurrencyForLevel((__int64)a1, (_DWORD *)a2);
v21 = (int)floorf((float)((float)v19 / 100.0) * BaseCurrencyForLevel);
v22 = (int)floorf((float)((float)v5 / 100.0) * BaseCurrencyForLevel);
if ( v5 == 100 )
v22 = (int)(float)((float)(BaseCurrencyForLevel * 0.25) + (float)v22);
v23 = v22 - v21;
if ( v23 <= 0 )
{
LABEL_67:
v23 = 0;
}
else
{
v24 = &v50;
if ( *((_QWORD *)&v51 + 1) > 0xFu )
v24 = (__int128 *)v50;
*(_OWORD *)Block = 0;
v47 = 0;
v25 = -1;
do
++v25;
while ( *((_BYTE *)v24 + v25) );
sub_14003D230(Block, v24, v25);
v26 = cocos2d::CCString::createWithFormat((const char *)&word_1406ED6F8, (unsigned int)v5);
cocos2d::CCDictionary::setObject(v10, v26, Block);
sub_14003D310((__int64)Block);
if ( v44 != 1 )
{
v27 = 98;
if ( v45 <= 0 )
v27 = 97;
v28 = a1[v27];
if ( *(_DWORD *)(a2 + 992) - *(_DWORD *)(a2 + 996) <= 0 )
{
v32 = cocos2d::CCString::createWithFormat(
(const char *)&word_1406ED6F8,
(unsigned int)(*(_DWORD *)(a2 + 328) - *(_DWORD *)(a2 + 332)));
v30 = cocos2d::CCString::getCString(v32);
*(_OWORD *)v48 = 0;
v49 = 0;
v31 = -1;
do
++v31;
while ( v30[v31] );
}
else
{
v29 = cocos2d::CCString::createWithFormat((const char *)&word_1406ED6F8);
v30 = cocos2d::CCString::getCString(v29);
*(_OWORD *)v48 = 0;
v49 = 0;
v31 = -1;
do
++v31;
while ( v30[v31] );
}
sub_14003D230(v48, v30, v31);
v33 = v48;
if ( *((_QWORD *)&v49 + 1) > 0xFu )
v33 = (void **)v48[0];
*(_OWORD *)Block = 0;
v47 = 0;
v34 = -1;
do
++v34;
while ( *((_BYTE *)v33 + v34) );
sub_14003D230(Block, v33, v34);
v35 = (cocos2d::CCString *)cocos2d::CCDictionary::valueForKey(v28, Block);
v36 = cocos2d::CCString::intValue(v35);
if ( *((_QWORD *)&v47 + 1) > 0xFu )
{
v37 = Block[0];
if ( (unsigned __int64)(*((_QWORD *)&v47 + 1) + 1LL) >= 0x1000 )
{
v37 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v37 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v37);
}
if ( v36 < v43 )
{
v38 = v48;
if ( *((_QWORD *)&v49 + 1) > 0xFu )
v38 = (void **)v48[0];
*(_OWORD *)Block = 0;
v47 = 0;
do
++v13;
while ( *((_BYTE *)v38 + v13) );
sub_14003D230(Block, v38, v13);
v39 = cocos2d::CCString::createWithFormat((const char *)&word_1406ED6F8, (unsigned int)v43);
cocos2d::CCDictionary::setObject(v28, v39, Block);
if ( *((_QWORD *)&v47 + 1) > 0xFu )
{
v40 = Block[0];
if ( (unsigned __int64)(*((_QWORD *)&v47 + 1) + 1LL) >= 0x1000 )
{
v40 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v40 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v40);
}
}
if ( *((_QWORD *)&v49 + 1) > 0xFu )
{
v41 = v48[0];
if ( (unsigned __int64)(*((_QWORD *)&v49 + 1) + 1LL) >= 0x1000 )
{
v41 = *((void **)v48[0] - 1);
if ( (unsigned __int64)((char *)v48[0] - (char *)v41 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v41);
}
}
GameStatsManager::incrementStat((__int64)a1, (const char *)&word_140737D98, v23);
}
sub_14003D310((__int64)&v50);
return (unsigned int)v23;
}