//
// GameStatsManager::incrementChallenge from 0x100030d00 to 0x100030f0b (523 bytes)
//
// 5 xrefs:
// > GameStatsManager::incrementStat @ 0x10002c6f0
// > GameStatsManager::incrementStat @ 0x10002c78c
// > GameStatsManager::incrementStat @ 0x10002c7f1
// > GameStatsManager::incrementStat @ 0x10002c83b
// > GameStatsManager::incrementStat @ 0x10002c84a
//
// 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 12:19:30 +0000
//
void __fastcall GameStatsManager::incrementChallenge(__int64 a1, int a2, int a3)
{
unsigned int i; // r12d
__int64 Challenge; // rax
__int64 v7; // r13
char v8; // al
int v9; // ebx
int v10; // eax
float v11; // xmm0_4
int v12; // eax
std::string *v13; // rdi
const std::string::value_type *v14; // rsi
const std::string::value_type *v15; // rsi
__int64 v16; // rbx
__int64 v17; // rax
__int64 CString; // rax
std::string::pointer data; // rcx
char v20; // [rsp+0h] [rbp-60h]
int v21; // [rsp+4h] [rbp-5Ch]
std::string v22; // [rsp+8h] [rbp-58h] BYREF
std::string v23; // [rsp+20h] [rbp-40h] BYREF
v21 = a3;
for ( i = 1; i != 4; ++i )
{
Challenge = GameStatsManager::getChallenge(a1, i);
if ( Challenge )
{
v7 = Challenge;
v8 = *(_BYTE *)(Challenge + 100);
if ( !v8 )
{
if ( *(_DWORD *)(v7 + 56) == a2 )
{
v9 = v21 + *(_DWORD *)(v7 + 60) - *(_DWORD *)(v7 + 64);
v10 = *(_DWORD *)(v7 + 84) - *(_DWORD *)(v7 + 88);
if ( v9 >= v10 )
{
*(_BYTE *)(v7 + 100) = 1;
v9 = v10;
}
*(_DWORD *)(v7 + 68) = v9;
v11 = (float)((float)rand() * 4.6566129e-10) * 1000.0;
*(_DWORD *)(v7 + 64) = (int)v11;
*(_DWORD *)(v7 + 60) = (int)v11 + v9;
v8 = *(_BYTE *)(v7 + 100);
}
if ( (v8 & 1) != 0 )
{
*(_WORD *)&v22.__r_.__value_.__l.0 = 0;
v23.__r_.__value_.__r.__words[2] = (std::string::size_type)operator new(0x1Au);
v23.__r_.__value_.__r.__words[0] = 27;
v23.__r_.__value_.__l.__size_ = 23;
strcpy(v23.__r_.__value_.__l.__data_, "currencyOrbIcon_001.png");
v12 = *(_DWORD *)(v7 + 56);
if ( v12 == 3 )
{
std::string::assign(&v22, "Stars/Moons");
v13 = &v23;
v14 = "GJ_starsIcon_001.png";
}
else if ( v12 == 2 )
{
v15 = "Silver Coins";
if ( *(_DWORD *)(v7 + 84) - *(_DWORD *)(v7 + 88) == 1 )
v15 = "Silver Coin";
std::string::assign(&v22, v15);
v13 = &v23;
v14 = "GJ_coinsIcon2_001.png";
}
else
{
v13 = &v22;
v14 = "?";
if ( v12 == 1 )
{
std::string::assign(&v22, "Mana Orbs");
v13 = &v23;
v14 = "currencyOrbIcon_001.png";
}
}
std::string::assign(v13, v14);
v16 = AchievementManager::sharedState();
v17 = sub_10088E820("Collect %i %s.", v20);
CString = cocos2d::CCString::getCString(v17);
data = v23.__r_.__value_.__s.__data_;
if ( (*(_BYTE *)&v23.__r_.__value_.__s.0 & 1) != 0 )
data = v23.__r_.__value_.__l.__data_;
AchievementManager::notifyAchievement(v16, "Quest Complete!", CString, data);
if ( (*(_BYTE *)&v23.__r_.__value_.__s.0 & 1) != 0 )
operator delete(v23.__r_.__value_.__l.__data_);
if ( (*(_BYTE *)&v22.__r_.__value_.__s.0 & 1) != 0 )
operator delete(v22.__r_.__value_.__l.__data_);
}
}
}
}
}