//
// GameStatsManager::incrementChallenge from 0x7add7c to 0x7ae08c (784 bytes)
//
// 2 xrefs:
// > GameStatsManager::incrementStat @ 0x7ba068
// > ??> @ 0x67c80
//
// 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
//
void GameStatsManager::incrementChallenge(GameStatsManager *a1, GJChallengeType a2, int a3)
{
int i; // w19
GJChallengeItem *Challenge; // x0
GJChallengeItem *v8; // x20
GJChallengeType m_challengeType; // w0
cocos2d::CCString *v10; // x0
const char *CString; // x0
char *v12; // x0
void *v13; // x0
unsigned int *v14; // x1
int v15; // w2
unsigned int *v16; // x1
int v17; // w2
AchievementManager *v18; // [xsp+60h] [xbp+60h]
__int64 v19; // [xsp+78h] [xbp+78h] BYREF
const char *v20; // [xsp+80h] [xbp+80h] BYREF
for ( i = 1; i != 4; ++i )
{
Challenge = GameStatsManager::getChallenge(a1, i);
v8 = Challenge;
if ( Challenge )
{
if ( !Challenge->m_canClaim && Challenge->m_challengeType == a2 )
{
GJChallengeItem::incrementCount(Challenge, a3);
if ( v8->m_canClaim )
{
sub_D153B8((int)&v19, &byte_F288A0);
sub_D153B8((int)&v20, "currencyOrbIcon_001.png");
m_challengeType = v8->m_challengeType;
switch ( m_challengeType )
{
case 1:
sub_D1798C(&v19, "Mana Orbs", 9);
sub_D1798C(&v20, "currencyOrbIcon_001.png", 23);
break;
case 3:
sub_D1798C(&v19, "Stars/Moons", 11);
sub_D1798C(&v20, "GJ_starsIcon_001.png", 20);
break;
case 2:
if ( v8->m_goal.random - v8->m_goal.seed == 1 )
sub_D1798C(&v19, "Silver Coin", 11);
else
sub_D1798C(&v19, "Silver Coins", 12);
sub_D1798C(&v20, "GJ_coinsIcon2_001.png", 21);
break;
default:
sub_D1798C(&v19, "?", 1);
break;
}
v18 = AchievementManager::sharedState();
v10 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"Collect %i %s.",
(const char *)(unsigned int)(v8->m_goal.random - v8->m_goal.seed),
v19);
CString = cocos2d::CCString::getCString(v10);
AchievementManager::notifyAchievement(v18, "Quest Complete!", CString, v20);
v12 = (char *)(v20 - 24);
if ( v20 - 24 != (const char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v16 = (unsigned int *)(v20 - 8);
do
v17 = __ldaxr(v16);
while ( __stlxr(v17 - 1, v16) );
}
else
{
v17 = *((_DWORD *)v20 - 2);
*((_DWORD *)v20 - 2) = v17 - 1;
}
if ( v17 <= 0 )
operator delete(v12);
}
v13 = (void *)(v19 - 24);
if ( (__int64 *)(v19 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v14 = (unsigned int *)(v19 - 8);
do
v15 = __ldaxr(v14);
while ( __stlxr(v15 - 1, v14) );
}
else
{
v15 = *(_DWORD *)(v19 - 8);
*(_DWORD *)(v19 - 8) = v15 - 1;
}
if ( v15 <= 0 )
operator delete(v13);
}
}
}
}
}
}