//
// GameStatsManager::recountSpecialStats from 0x10033516c to 0x100335bbc (2640 bytes)
//
// 1 xrefs:
// > GameManager::dataLoaded @ 0x10031bb00
//
// 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 __fastcall GameStatsManager::recountSpecialStats(GameStatsManager *a1)
{
__int64 TotalCollectedCurrency; // x20
GameStatsManager *v3; // x0
GameStatsManager *v4; // x0
int TotalCollectedDiamonds; // w26
__int64 v6; // x25
int v7; // w21
float v8; // s0
int v9; // w11
int v10; // w14
__int64 v11; // x24
int v12; // w13
int v13; // w9
cocos2d::CCDictionary **v14; // x8
cocos2d::CCDictionary *v15; // x8
cocos2d::CCDictElement *m_pElements; // x8
__int64 v17; // x27
int v18; // w26
int v19; // w28
unsigned int v20; // w19
unsigned int v21; // w20
unsigned int v22; // w21
unsigned int v23; // w22
unsigned int v24; // w23
GJRewardItem *m_pObject; // x24
cocos2d::CCDictionary *m_worldAdvertChests; // x8
cocos2d::CCDictElement *v27; // x8
__int64 v28; // x22
cocos2d::CCDictElement *v29; // x25
int v30; // w0
int v31; // w8
cocos2d::CCArray *v32; // x0
cocos2d::ccArray *data; // x9
__int64 num; // x8
__int64 v35; // x19
__int64 v36; // x28
__int64 v37; // x20
__int64 v38; // x21
__int64 v39; // x27
int v40; // w23
cocos2d::CCString **arr; // x9
cocos2d::CCString **v42; // x8
char *CString; // x0
const char *v44; // x0
int v45; // w0
__int64 v46; // x26
__int64 v47; // x23
__int64 v48; // x22
__int64 v49; // x21
__int64 v50; // x20
__int64 v51; // x19
int v52; // w28
int v53; // w27
int v54; // w25
int v55; // w24
int v56; // w9
int v57; // w8
__int64 v58; // x0
__int64 v59; // x24
unsigned int v60; // w25
__int64 v61; // x0
int v62; // w8
cocos2d::CCArray *v63; // x0
cocos2d::ccArray *v64; // x9
__int64 v65; // x8
cocos2d::CCString **v66; // x27
int v67; // w25
char *v68; // x0
char *v69; // x0
intptr_t v70; // x28
cocos2d::CCObject *v71; // x19
cocos2d::CCString *v72; // x0
int v73; // w24
cocos2d::CCObject *v74; // x0
int v75; // w8
bool v76; // cc
int v77; // w8
bool m_skipIncrementChallenge; // w24
AchievementManager *v79; // x0
int i; // w19
GameStatsManager *v81; // x0
cocos2d::CCString *v82; // x0
char *v83; // x0
GameManager *v84; // x0
char *v85; // x1
int v86; // w19
int j; // w20
GameStatsManager *v88; // x0
GameStatsManager *v89; // x0
unsigned int v90; // w19
GameStatsManager *v91; // x0
GameManager *v92; // x0
int v93; // [xsp+Ch] [xbp-E4h]
GameStatsManager *v94; // [xsp+10h] [xbp-E0h]
cocos2d::CCDictionary **p_m_dailyChests; // [xsp+18h] [xbp-D8h]
cocos2d::CCDictionary **p_m_miscChests; // [xsp+20h] [xbp-D0h]
cocos2d::CCDictionary **p_m_weeklyChest; // [xsp+28h] [xbp-C8h]
int v98; // [xsp+30h] [xbp-C0h]
unsigned __int64 v99; // [xsp+30h] [xbp-C0h]
unsigned __int64 v100; // [xsp+38h] [xbp-B8h]
unsigned __int64 v101; // [xsp+40h] [xbp-B0h]
int v102; // [xsp+40h] [xbp-B0h]
int v103; // [xsp+44h] [xbp-ACh]
unsigned int v104; // [xsp+48h] [xbp-A8h]
cocos2d::CCString **v105; // [xsp+48h] [xbp-A8h]
int v106; // [xsp+48h] [xbp-A8h]
int v107; // [xsp+54h] [xbp-9Ch]
int v108; // [xsp+54h] [xbp-9Ch]
int v109; // [xsp+58h] [xbp-98h]
cocos2d::CCDictElement *next; // [xsp+58h] [xbp-98h]
int v111; // [xsp+64h] [xbp-8Ch]
int v112; // [xsp+68h] [xbp-88h]
int v113; // [xsp+6Ch] [xbp-84h]
int v114; // [xsp+70h] [xbp-80h]
int v115; // [xsp+70h] [xbp-80h]
unsigned __int64 v116; // [xsp+70h] [xbp-80h]
bool m_dontNotify; // [xsp+70h] [xbp-80h]
int v118; // [xsp+7Ch] [xbp-74h]
int v119; // [xsp+7Ch] [xbp-74h]
char __s[8]; // [xsp+80h] [xbp-70h] BYREF
char v121; // [xsp+97h] [xbp-59h]
TotalCollectedCurrency = GameStatsManager::getTotalCollectedCurrency(a1);
v3 = GameStatsManager::sharedState();
if ( GameStatsManager::getStat(v3, "22") != (_DWORD)TotalCollectedCurrency )
{
v4 = GameStatsManager::sharedState();
GameStatsManager::setStat(v4, "22", TotalCollectedCurrency);
}
TotalCollectedDiamonds = GameStatsManager::getTotalCollectedDiamonds(a1);
v6 = TotalCollectedCurrency;
v7 = vcvtms_s32_f32((float)(int)TotalCollectedCurrency / 500.0);
a1->m_bonusKey.value = v7;
v8 = vcvts_n_f32_s32(rand(), 0x1Fu) * 1000.0;
a1->m_bonusKey.seed = (int)v8;
a1->m_bonusKey.random = (int)v8 + v7;
GameStatsManager::removeErrorFromSpecialChests(a1);
v9 = 0;
v10 = 0;
v107 = 0;
v109 = 0;
v100 = 0;
v101 = 0;
v104 = 0;
v11 = 0;
v12 = 0;
v13 = 0;
p_m_miscChests = &a1->m_miscChests;
p_m_weeklyChest = &a1->m_weeklyChest;
v94 = a1;
p_m_dailyChests = &a1->m_dailyChests;
do
{
v14 = p_m_weeklyChest;
if ( v13 != 2 )
v14 = p_m_miscChests;
v98 = v13;
if ( !v13 )
v14 = p_m_dailyChests;
v15 = *v14;
v112 = v10;
v113 = v7;
v111 = v9;
v114 = TotalCollectedDiamonds;
if ( v15 && (m_pElements = v15->m_pElements) != nullptr )
{
LODWORD(v17) = v11;
v18 = v107;
v19 = v109;
v21 = HIDWORD(v101);
v20 = v104;
v23 = v100;
v22 = HIDWORD(v100);
v24 = v101;
do
{
v118 = v12;
next = (cocos2d::CCDictElement *)m_pElements->hh.next;
m_pObject = (GJRewardItem *)m_pElements->m_pObject;
v6 = (unsigned int)(GJRewardItem::getRewardCount(m_pObject, BonusKey|FireShard) + v6);
v114 += GJRewardItem::getRewardCount(m_pObject, Diamonds);
v111 += GJRewardItem::getRewardCount(m_pObject, FireShard);
v112 += GJRewardItem::getRewardCount(m_pObject, IceShard);
v18 += GJRewardItem::getRewardCount(m_pObject, PoisonShard);
v24 += GJRewardItem::getRewardCount(m_pObject, ShadowShard);
v23 += GJRewardItem::getRewardCount(m_pObject, LavaShard);
v22 += GJRewardItem::getRewardCount(m_pObject, EarthShard);
v21 += GJRewardItem::getRewardCount(m_pObject, BloodShard);
v20 += GJRewardItem::getRewardCount(m_pObject, MetalShard);
v19 += GJRewardItem::getRewardCount(m_pObject, LightShard);
v17 = (unsigned int)(GJRewardItem::getRewardCount(m_pObject, SoulShard) + v17);
v113 += GJRewardItem::getRewardCount(m_pObject, BonusKey);
v12 = GJRewardItem::getRewardCount(m_pObject, GoldKey) + v118;
m_pElements = next;
}
while ( next );
}
else
{
v17 = v11;
v18 = v107;
v19 = v109;
v21 = HIDWORD(v101);
v20 = v104;
v23 = v100;
v22 = HIDWORD(v100);
v24 = v101;
}
v107 = v18;
v109 = v19;
v101 = __PAIR64__(v21, v24);
v100 = __PAIR64__(v22, v23);
v104 = v20;
v11 = v17;
v13 = v98 + 1;
v10 = v112;
v7 = v113;
v9 = v111;
TotalCollectedDiamonds = v114;
}
while ( v98 != 2 );
m_worldAdvertChests = v94->m_worldAdvertChests;
if ( !m_worldAdvertChests )
{
v119 = v12;
goto LABEL_24;
}
v119 = v12;
v27 = m_worldAdvertChests->m_pElements;
if ( !v27 )
{
LABEL_24:
v28 = v6;
goto LABEL_25;
}
LODWORD(v28) = v6;
do
{
v29 = (cocos2d::CCDictElement *)v27->hh.next;
v30 = cocos2d::CCString::intValue((cocos2d::CCString *)v27->m_pObject);
if ( v30 >= 200 )
v31 = 200;
else
v31 = v30;
v28 = (unsigned int)(v31 + v28);
v27 = v29;
}
while ( v29 );
LABEL_25:
v32 = cocos2d::CCDictionary::allKeys(v94->m_treasureRoomChests);
v93 = v17;
if ( v32 )
{
data = v32->data;
num = data->num;
v35 = v21;
v36 = v104;
v38 = (unsigned int)v100;
v37 = HIDWORD(v100);
v39 = v24;
v40 = v107;
if ( (_DWORD)num )
{
arr = (cocos2d::CCString **)data->arr;
v99 = (unsigned __int64)&arr[num - 1];
v42 = arr;
do
{
if ( !*v42 )
break;
v105 = v42;
CString = (char *)cocos2d::CCString::getCString(*v42);
sub_100009900(__s, CString);
v44 = v121 >= 0 ? __s : *(const char **)__s;
v45 = atoi(v44);
v108 = v40;
v115 = TotalCollectedDiamonds;
if ( v45 > 6000 )
{
v46 = v28;
v47 = v39;
v48 = v38;
v49 = v37;
v50 = v35;
v51 = v36;
v52 = v109;
v53 = v93;
v55 = 0;
v57 = 1;
v54 = -1;
v56 = v119;
}
else
{
v46 = v28;
v47 = v39;
v48 = v38;
v49 = v37;
v50 = v35;
v51 = v36;
if ( v45 <= 5000 )
{
if ( v45 <= 4000 )
{
if ( v45 <= 3000 )
{
v52 = v109;
v53 = v93;
if ( v45 <= 2000 )
{
v54 = 0;
v55 = v45 <= 1000 ? 1 : 5;
v56 = v113;
v57 = v55;
}
else
{
v54 = 0;
v55 = 10;
v56 = v113;
v57 = 10;
}
}
else
{
v52 = v109;
v53 = v93;
v54 = 0;
v55 = 25;
v56 = v113;
v57 = 25;
}
}
else
{
v52 = v109;
v53 = v93;
v54 = 0;
v55 = 50;
v56 = v113;
v57 = 50;
}
}
else
{
v52 = v109;
v53 = v93;
v54 = 0;
v55 = 100;
v56 = v113;
v57 = 100;
}
}
v93 = v53;
v109 = v52;
if ( v57 <= v56 )
{
v58 = cocos2d::CCDictionary::objectForKey_1(v94->m_treasureRoomChests, __s);
v119 += v54;
v113 -= v55;
if ( *(_QWORD *)(v58 + 72) )
{
v59 = *(_QWORD *)(v58 + 72);
v60 = 0;
v36 = v51;
v35 = v50;
v37 = v49;
v38 = v48;
v39 = v47;
v40 = v108;
v28 = v46;
TotalCollectedDiamonds = v115;
while ( v60 < (unsigned int)sub_10024A36C(v59) )
{
v61 = sub_10024A388(v59, v60);
v62 = *(_DWORD *)(v61 + 56);
if ( v62 > 7 )
{
if ( v62 > 11 )
{
switch ( v62 )
{
case 12:
v36 = (unsigned int)(*(_DWORD *)(v61 + 68) + v36);
break;
case 13:
v109 += *(_DWORD *)(v61 + 68);
break;
case 14:
v93 += *(_DWORD *)(v61 + 68);
break;
}
}
else
{
switch ( v62 )
{
case 8:
TotalCollectedDiamonds += *(_DWORD *)(v61 + 68);
break;
case 10:
v37 = (unsigned int)(*(_DWORD *)(v61 + 68) + v37);
break;
case 11:
v35 = (unsigned int)(*(_DWORD *)(v61 + 68) + v35);
break;
}
}
}
else if ( v62 > 3 )
{
switch ( v62 )
{
case 4:
v39 = (unsigned int)(*(_DWORD *)(v61 + 68) + v39);
break;
case 5:
v38 = (unsigned int)(*(_DWORD *)(v61 + 68) + v38);
break;
case 7:
v28 = (unsigned int)(*(_DWORD *)(v61 + 68) + v28);
break;
}
}
else
{
switch ( v62 )
{
case 1:
v111 += *(_DWORD *)(v61 + 68);
break;
case 2:
v112 += *(_DWORD *)(v61 + 68);
break;
case 3:
v40 += *(_DWORD *)(v61 + 68);
break;
}
}
++v60;
}
}
else
{
v36 = v51;
v35 = v50;
v37 = v49;
v38 = v48;
v39 = v47;
v40 = v108;
v28 = v46;
TotalCollectedDiamonds = v115;
}
}
else
{
cocos2d::CCDictionary::removeObjectForKey_1((int)v94->m_treasureRoomChests, __s);
v36 = v51;
v35 = v50;
v37 = v49;
v38 = v48;
v39 = v47;
v40 = v108;
v28 = v46;
TotalCollectedDiamonds = v115;
}
if ( v121 < 0 )
operator delete(*(void **)__s);
v42 = v105 + 1;
}
while ( (unsigned __int64)(v105 + 1) <= v99 );
}
}
else
{
LODWORD(v35) = v21;
LODWORD(v36) = v104;
LODWORD(v38) = v100;
LODWORD(v37) = HIDWORD(v100);
LODWORD(v39) = v24;
v40 = v107;
}
v63 = cocos2d::CCDictionary::allKeys(v94->m_purchasedItems);
v102 = v39;
v103 = v35;
v106 = v36;
if ( v63 )
{
v64 = v63->data;
v65 = v64->num;
if ( (_DWORD)v65 )
{
v66 = (cocos2d::CCString **)v64->arr;
v116 = (unsigned __int64)&v66[v65 - 1];
v67 = TotalCollectedDiamonds;
while ( 1 )
{
if ( !*v66 )
goto LABEL_113;
v68 = (char *)cocos2d::CCString::getCString(*v66);
sub_100009900(__s, v68);
if ( v121 >= 0 )
v69 = __s;
else
v69 = *(char **)__s;
v70 = atoi(v69);
v71 = cocos2d::CCDictionary::objectForKey(v94->m_storeItems, v70);
v72 = (cocos2d::CCString *)cocos2d::CCDictionary::valueForKey_1(v94->m_purchasedItems, __s);
v73 = cocos2d::CCString::intValue(v72);
if ( v73 >= 1 )
{
if ( v71 )
v73 = v71[6].m_nTag - v71[6].m_uReference;
v74 = cocos2d::CCDictionary::objectForKey(v94->m_storeItems, v70);
if ( v74 && v74[6].m_eObjType == 4 )
{
if ( v67 >= v73 )
v75 = v73;
else
v75 = 0;
v76 = v67 < v73;
v67 -= v75;
if ( !v76 )
goto LABEL_108;
}
else
{
if ( (int)v28 >= v73 )
v77 = v73;
else
v77 = 0;
v76 = (int)v28 < v73;
LODWORD(v28) = v28 - v77;
if ( !v76 )
goto LABEL_108;
}
}
cocos2d::CCDictionary::removeObjectForKey_1((int)v94->m_purchasedItems, __s);
LABEL_108:
if ( v121 < 0 )
operator delete(*(void **)__s);
if ( (unsigned __int64)++v66 > v116 )
goto LABEL_113;
}
}
}
v67 = TotalCollectedDiamonds;
LABEL_113:
m_dontNotify = AchievementManager::sharedState()->m_dontNotify;
m_skipIncrementChallenge = v94->m_skipIncrementChallenge;
v79 = AchievementManager::sharedState();
v79->m_dontNotify = 1;
v94->m_skipIncrementChallenge = 1;
GameStatsManager::resetSpecialStatAchievements((GameStatsManager *)v79);
GameStatsManager::setStat(v94, "14", v28);
GameStatsManager::setStat(v94, "13", TotalCollectedDiamonds);
GameStatsManager::setStat(v94, "29", v67);
GameStatsManager::setStat(v94, "21", v113);
GameStatsManager::setStat(v94, "43", v119);
GameStatsManager::setStat(v94, "18", v111);
GameStatsManager::setStat(v94, "19", v112);
GameStatsManager::setStat(v94, "17", v40);
GameStatsManager::setStat(v94, "16", v102);
GameStatsManager::setStat(v94, "20", v38);
GameStatsManager::setStat(v94, "23", v37);
GameStatsManager::setStat(v94, "24", v103);
GameStatsManager::setStat(v94, "25", v106);
GameStatsManager::setStat(v94, "26", v109);
GameStatsManager::setStat(v94, "27", v93);
for ( i = 6; i != 16; ++i )
{
v81 = GameStatsManager::sharedState();
if ( GameStatsManager::isItemUnlocked(v81, GJItem, i) )
{
v82 = (cocos2d::CCString *)sub_100268F4C("geometry.ach.path%02d.00", i - 5);
v83 = (char *)cocos2d::CCString::getCString(v82);
sub_100009900(__s, v83);
v84 = GameManager::sharedState();
if ( v121 >= 0 )
v85 = __s;
else
v85 = *(char **)__s;
GameManager::reportAchievementWithID(v84, v85, 100, 0);
if ( v121 < 0 )
operator delete(*(void **)__s);
}
}
v86 = 0;
for ( j = 1; j != 61; ++j )
{
v88 = GameStatsManager::sharedState();
v86 += GameStatsManager::isGauntletChestUnlocked(v88, j);
}
v89 = GameStatsManager::sharedState();
GameStatsManager::setStat(v89, "40", v86);
v90 = cocos2d::CCDictionary::count(v94->m_completedLists);
v91 = GameStatsManager::sharedState();
GameStatsManager::setStat(v91, "41", v90);
v92 = GameManager::sharedState();
GameManager::checkUsedIcons(v92);
AchievementManager::sharedState()->m_dontNotify = m_dontNotify;
v94->m_skipIncrementChallenge = m_skipIncrementChallenge;
}