// // GameManager::recountUserStats from 0x5f9b54 to 0x5fa874 (3360 bytes) // // 3 xrefs: // > GameManager::dataLoaded @ 0x5fb588 // > GJAccountManager::onSyncAccountCompleted @ 0x848d1c // > @ 0xa0758 // // 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 // __int64 __fastcall GameManager::recountUserStats(GameManager *a1, _QWORD *a2) { unsigned __int64 v3; // x0 __int64 *v4; // x20 cocos2d::CCFileUtils *v5; // x0 cocos2d::CCString *v6; // x0 char *CString; // x0 char *v8; // x21 std::__detail::_Hash_node_base *M_nxt; // x20 int v10; // w26 int v11; // w25 int v12; // w28 int v13; // w24 int v14; // w19 GameLevelManager *v15; // x0 GJGameLevel *MainLevel; // x19 int random; // w21 int seed; // w22 GameStatsManager *v19; // x0 bool isPlatformer; // w0 int v21; // w21 int v22; // w0 cocos2d::CCDictionary *m_onlineLevels; // x0 cocos2d::CCDictElement *m_pElements; // x0 cocos2d::CCDictElement *i; // x20 GJGameLevel *m_pObject; // x19 GameStatsManager *v27; // x0 _BOOL4 hasCompletedLevel; // w21 GameStatsManager *v29; // x0 int v30; // w21 int v31; // w22 unsigned __int64 v32; // x23 __int64 **v33; // x0 __int64 *v34; // x1 int v35; // w0 __int64 v36; // x5 _QWORD *v37; // x0 __int64 v38; // x1 int *v39; // x0 int v40; // w22 int v41; // w0 int v42; // w0 __int64 v43; // x4 cocos2d::CCArray *v44; // x22 unsigned int j; // w20 int v46; // w21 cocos2d::CCString *v47; // x0 int v48; // w0 int v49; // w19 GameStatsManager *v50; // x0 GameStatsManager *v51; // x0 cocos2d::CCArray *CompletedMapPacks; // x20 unsigned int k; // w19 cocos2d::CCString *v54; // x0 int v55; // w21 GameStatsManager *v56; // x0 GameStatsManager *v57; // x0 char *v58; // x19 cocos2d::CCString *m; // x0 char *v60; // x22 GameManager *v61; // x21 char *v62; // x0 unsigned int *v63; // x1 int v64; // w2 GameStatsManager *v65; // x0 char *v66; // x19 cocos2d::CCString *n; // x0 char *v68; // x22 GameManager *v69; // x21 char *v70; // x0 unsigned int *v71; // x1 int v72; // w2 GameStatsManager *v73; // x0 char *v74; // x19 cocos2d::CCString *ii; // x0 char *v76; // x22 GameManager *v77; // x21 char *v78; // x0 unsigned int *v79; // x1 int v80; // w2 GameStatsManager *v81; // x0 char *v82; // x19 cocos2d::CCString *v83; // x0 char *v84; // x22 GameManager *v85; // x21 char *v86; // x0 GameStatsManager *v87; // x0 GameStatsManager *v88; // x0 GameStatsManager *v89; // x0 GameStatsManager *v90; // x0 GameStatsManager *v91; // x0 char *v92; // x0 int *p_m_unknown2; // x0 unsigned int *v95; // x1 int v96; // w2 unsigned int v97; // w0 unsigned __int8 *v98; // x3 char *v99; // x2 _DWORD *v100; // x22 _DWORD *v101; // x23 unsigned __int64 v102; // x27 unsigned __int64 v103; // x24 size_t v104; // x2 int v105; // w21 __int64 v106; // x27 unsigned int *v107; // x3 int v108; // w2 unsigned int *p_m_sString; // x2 int m_data; // w1 unsigned int *v111; // x2 int v112; // w1 unsigned int *v113; // x2 int v114; // w1 int v115; // w0 bool m_skipIncrementChallenge; // [xsp+78h] [xbp+78h] bool m_dontNotify; // [xsp+7Ch] [xbp+7Ch] int v119; // [xsp+88h] [xbp+88h] int v120; // [xsp+8Ch] [xbp+8Ch] __int64 v121; // [xsp+A8h] [xbp+A8h] int v122; // [xsp+A8h] [xbp+A8h] cocos2d::CCDictionary *StarPackDict; // [xsp+A8h] [xbp+A8h] cocos2d::CCString *v124; // [xsp+C0h] [xbp+C0h] BYREF char *v125; // [xsp+C8h] [xbp+C8h] BYREF void *v126; // [xsp+D0h] [xbp+D0h] BYREF void *v127; // [xsp+D8h] [xbp+D8h] BYREF const char *v128; // [xsp+E0h] [xbp+E0h] BYREF const char *v129; // [xsp+E8h] [xbp+E8h] BYREF const char *v130; // [xsp+F0h] [xbp+F0h] BYREF const char *v131; // [xsp+F8h] [xbp+F8h] BYREF __int64 *v132; // [xsp+100h] [xbp+100h] BYREF unsigned __int64 v133; // [xsp+108h] [xbp+108h] __int64 v134; // [xsp+110h] [xbp+110h] __int64 v135; // [xsp+118h] [xbp+118h] float v136; // [xsp+120h] [xbp+120h] BYREF __int64 v137; // [xsp+128h] [xbp+128h] __int64 v138; // [xsp+130h] [xbp+130h] BYREF std::unordered_set v139; // [xsp+138h] [xbp+138h] BYREF unsigned __int8 v140[24]; // [xsp+170h] [xbp+170h] BYREF unsigned __int8 v141[48]; // [xsp+188h] [xbp+188h] BYREF m_dontNotify = AchievementManager::sharedState()->m_dontNotify; AchievementManager::sharedState()->m_dontNotify = 1; m_skipIncrementChallenge = GameStatsManager::sharedState()->m_skipIncrementChallenge; GameStatsManager::sharedState()->m_skipIncrementChallenge = 1; v134 = 0; v135 = 0; v136 = 1.0; v137 = 0; v3 = sub_D146DC(&v136, 10); v133 = v3; if ( v3 == 1 ) { v138 = 0; v4 = &v138; } else { if ( v3 > 0x1FFFFFFFFFFFFFFFLL ) sub_D1383C(); v121 = 8 * v3; v4 = (__int64 *)operator new(8 * v3); memset(v4, 0, v121); } v132 = v4; v5 = cocos2d::CCFileUtils::sharedFileUtils(); ((void (__fastcall *)(cocos2d::CCString **__return_ptr, cocos2d::CCFileUtils *, const char *, _QWORD))v5->createCCArrayWithContentsOfFile)( &v124, v5, "LevelStats.dat", 0); v6 = cocos2d::CCString::createWithContentsOfFile((const char *)v124); CString = (char *)cocos2d::CCString::getCString(v6); sub_D153B8((int)&v125, CString); v8 = v125; if ( *((_QWORD *)v125 - 3) ) { v97 = strlen(v125); rtsha1::calc((rtsha1 *)v8, (const void *)v97, (__int64)v140, v98); rtsha1::toHexString((rtsha1 *)v140, v141, v99); sub_D153B8((int)&v126, (char *)v141); sub_D153B8((int)&v127, "2dc0e75c5070651ccb072bd2fe938607ea7e4ab9"); v100 = v126; v101 = v127; v102 = *((_QWORD *)v126 - 3); v103 = *((_QWORD *)v127 - 3); if ( v103 > v102 ) v104 = *((_QWORD *)v126 - 3); else v104 = *((_QWORD *)v127 - 3); v105 = memcmp(v126, v127, v104); if ( !v105 ) { v105 = 0x7FFFFFFF; v106 = v102 - v103; if ( v106 <= 0x7FFFFFFF ) { if ( v106 >= (__int64)0xFFFFFFFF80000000LL ) v105 = v106; else v105 = 0x80000000; } } if ( v101 - 6 != (_DWORD *)&qword_124B6B0 ) { v113 = v101 - 2; if ( &pthread_create ) { do v114 = __ldaxr(v113); while ( __stlxr(v114 - 1, v113) ); } else { v114 = *(v101 - 2); *(v101 - 2) = v114 - 1; } if ( v114 <= 0 ) operator delete(v101 - 6); v100 = v126; } if ( v100 - 6 == (_DWORD *)&qword_124B6B0 ) goto LABEL_133; v111 = v100 - 2; if ( &pthread_create ) { do v112 = __ldaxr(v111); while ( __stlxr(v112 - 1, v111) ); } else { v112 = *(v100 - 2); *(v100 - 2) = v112 - 1; } if ( v112 > 0 ) { LABEL_133: if ( v105 ) goto LABEL_5; } else { operator delete(v100 - 6); if ( v105 ) goto LABEL_5; } addStarsToMap(&v132, &v125); } LABEL_5: if ( *(_QWORD *)(*a2 - 24LL) ) addStarsToMap(&v132, a2); LevelTools::getLevelList(&v139); M_nxt = v139._M_h._M_before_begin._M_nxt; v10 = 0; v11 = 0; v12 = 0; v13 = 0; while ( M_nxt ) { while ( 1 ) { v14 = (int)M_nxt[1]._M_nxt; v15 = GameLevelManager::sharedState(); MainLevel = GameLevelManager::getMainLevel(v15, v14, 1); random = MainLevel->m_stars.random; seed = MainLevel->m_stars.seed; v19 = GameStatsManager::sharedState(); if ( GameStatsManager::hasCompletedLevel(v19, MainLevel) ) break; M_nxt = M_nxt->_M_nxt; if ( !M_nxt ) goto LABEL_22; } isPlatformer = GJGameLevel::isPlatformer(MainLevel); v21 = random - seed; if ( v21 < 0 ) v21 = 0; if ( v21 > 20 ) v21 = 20; if ( isPlatformer ) v12 += v21; else v13 += v21; M_nxt = M_nxt->_M_nxt; if ( MainLevel->m_demon.random - MainLevel->m_demon.seed == 1 ) ++v11; if ( MainLevel->m_difficulty == Insane ) ++v10; } LABEL_22: v122 = 0; v120 = 1; v22 = 0; v119 = 0; while ( v22 != 2 ) { m_onlineLevels = GameLevelManager::sharedState()->m_onlineLevels; if ( m_onlineLevels ) goto LABEL_25; LABEL_59: if ( v120 == 3 ) goto LABEL_66; while ( 1 ) { ++v122; ++v120; v22 = v122; if ( v122 != 1 ) break; m_onlineLevels = GameLevelManager::sharedState()->m_dailyLevels; if ( m_onlineLevels ) goto LABEL_25; } } m_onlineLevels = GameLevelManager::sharedState()->m_gauntletLevels; if ( m_onlineLevels ) { LABEL_25: m_pElements = m_onlineLevels->m_pElements; if ( !m_pElements ) goto LABEL_59; for ( i = (cocos2d::CCDictElement *)m_pElements->hh.next; ; i = (cocos2d::CCDictElement *)i->hh.next ) { m_pObject = (GJGameLevel *)m_pElements->m_pObject; v27 = GameStatsManager::sharedState(); hasCompletedLevel = GameStatsManager::hasCompletedLevel(v27, m_pObject); if ( m_pObject->m_stars.random - m_pObject->m_stars.seed > 0 ) { if ( hasCompletedLevel ) { LABEL_29: v29 = GameStatsManager::sharedState(); GameStatsManager::markLevelAsCompletedAndClaimed(v29, m_pObject); v30 = m_pObject->m_stars.random - m_pObject->m_stars.seed; if ( v30 < 0 ) v30 = 0; if ( v30 > 10 ) v30 = 10; if ( GJGameLevel::isPlatformer(m_pObject) ) v12 += v30; else v13 += v30; if ( m_pObject->m_demon.random - m_pObject->m_demon.seed == 1 ) ++v11; if ( (unsigned int)(m_pObject->m_stars.random - m_pObject->m_stars.seed - 8) <= 1 ) ++v10; if ( v122 == 1 ) { v115 = v119; if ( (unsigned int)(m_pObject->m_dailyID.random - m_pObject->m_dailyID.seed - 1) <= 0x1869F ) v115 = v119 + 1; v119 = v115; } } LABEL_40: if ( !i ) goto LABEL_59; goto LABEL_41; } v31 = m_pObject->m_levelID.random - m_pObject->m_levelID.seed; v32 = v31 % v133; v33 = (__int64 **)v132[v32]; if ( !v33 ) goto LABEL_56; v34 = *v33; if ( !*v33 ) goto LABEL_56; v35 = *((_DWORD *)v34 + 2); v36 = 0; while ( v31 == v35 ) { v34 = (__int64 *)*v34; ++v36; if ( !v34 ) goto LABEL_52; LABEL_49: v35 = *((_DWORD *)v34 + 2); if ( v32 != v35 % v133 ) goto LABEL_52; } if ( v36 ) goto LABEL_53; v34 = (__int64 *)*v34; if ( v34 ) goto LABEL_49; LABEL_52: if ( !v36 ) goto LABEL_40; LABEL_53: LODWORD(v131) = m_pObject->m_levelID.random - m_pObject->m_levelID.seed; v37 = sub_5E8138(&v132, v31 % v133, (int *)&v131); if ( !v37 || (v38 = *v37, v39 = (int *)(*v37 + 12LL), !v38) ) { v43 = operator new(0x10u); *(_QWORD *)v43 = 0; *(_DWORD *)(v43 + 8) = v31; *(_DWORD *)(v43 + 12) = 0; v39 = (int *)std::_Hashtable,std::allocator>,std::__detail::_Select1st,std::equal_to,std::hash,std::__detail::_Mod_range_hashing,std::__detail::_Default_ranged_hash,std::__detail::_Prime_rehash_policy,std::__detail::_Hashtable_traits>::_M_insert_unique_node( (__int64)&v132, v32, v31, (_QWORD *)v43) + 3; } v40 = *v39; if ( (unsigned int)(*v39 - 1) <= 9 ) { m_pObject->m_stars.value = v40; v41 = (int)(float)((float)((float)rand() * 4.6566e-10) * 1000.0); m_pObject->m_stars.seed = v41; m_pObject->m_stars.random = v40 + v41; if ( v40 == 10 ) { m_pObject->m_demon.value = 1; v42 = (int)(float)((float)((float)rand() * 4.6566e-10) * 1000.0); m_pObject->m_demon.seed = v42; m_pObject->m_demon.random = v42 + 1; } } LABEL_56: if ( !hasCompletedLevel ) goto LABEL_40; if ( m_pObject->m_stars.random - m_pObject->m_stars.seed > 0 ) goto LABEL_29; if ( !i ) goto LABEL_59; LABEL_41: m_pElements = i; } } LABEL_66: StarPackDict = LevelTools::createStarPackDict(); v44 = cocos2d::CCDictionary::allKeys(StarPackDict); for ( j = 0; j < (unsigned int)cocos2d::CCArray::count(v44); ++j ) { v46 = *(_DWORD *)(cocos2d::CCArray::objectAtIndex(v44, j) + 56); v47 = (cocos2d::CCString *)cocos2d::CCDictionary::valueForKey(StarPackDict, v46); v48 = cocos2d::CCString::intValue(v47); if ( v48 > 10 ) v49 = 10; else v49 = v48; if ( v49 < 0 ) v49 = 0; v50 = GameStatsManager::sharedState(); GameStatsManager::setStarsForMapPack(v50, v46, v49); } v51 = GameStatsManager::sharedState(); CompletedMapPacks = GameStatsManager::getCompletedMapPacks(v51); for ( k = 0; k < (unsigned int)cocos2d::CCArray::count(CompletedMapPacks); ++k ) { v54 = cocos2d::CCArray::stringAtIndex(CompletedMapPacks, k); v55 = cocos2d::CCString::intValue(v54); v56 = GameStatsManager::sharedState(); v13 += GameStatsManager::starsForMapPack(v56, v55); } v57 = GameStatsManager::sharedState(); if ( GameStatsManager::getStat(v57, "6") > v13 ) { v58 = (char *)&dword_0 + 1; for ( m = (cocos2d::CCString *)cocos2d::CCString::createWithFormat( (cocos2d::CCString *)"geometry.ach.stars%02d", (const char *)&dword_0 + 1); ; m = (cocos2d::CCString *)cocos2d::CCString::createWithFormat( (cocos2d::CCString *)"geometry.ach.stars%02d", (const char *)(unsigned int)v58) ) { v60 = (char *)cocos2d::CCString::getCString(m); v61 = GameManager::sharedState(); sub_D153B8((int)&v128, v60); GameManager::resetAchievement(v61, &v128); v62 = (char *)(v128 - 24); if ( v128 - 24 == (const char *)&qword_124B6B0 ) goto LABEL_79; if ( &pthread_create ) { v63 = (unsigned int *)(v128 - 8); do v64 = __ldaxr(v63); while ( __stlxr(v64 - 1, v63) ); } else { v64 = *((_DWORD *)v128 - 2); *((_DWORD *)v128 - 2) = v64 - 1; } if ( v64 > 0 ) { LABEL_79: LODWORD(v58) = (_DWORD)v58 + 1; if ( (_DWORD)v58 == 34 ) break; } else { LODWORD(v58) = (_DWORD)v58 + 1; operator delete(v62); if ( (_DWORD)v58 == 34 ) break; } } } v65 = GameStatsManager::sharedState(); if ( GameStatsManager::getStat(v65, "5") > v11 ) { v66 = (char *)&dword_0 + 1; for ( n = (cocos2d::CCString *)cocos2d::CCString::createWithFormat( (cocos2d::CCString *)"geometry.ach.demon%02d", (const char *)&dword_0 + 1); ; n = (cocos2d::CCString *)cocos2d::CCString::createWithFormat( (cocos2d::CCString *)"geometry.ach.demon%02d", (const char *)(unsigned int)v66) ) { v68 = (char *)cocos2d::CCString::getCString(n); v69 = GameManager::sharedState(); sub_D153B8((int)&v129, v68); GameManager::resetAchievement(v69, &v129); v70 = (char *)(v129 - 24); if ( v129 - 24 == (const char *)&qword_124B6B0 ) goto LABEL_89; if ( &pthread_create ) { v71 = (unsigned int *)(v129 - 8); do v72 = __ldaxr(v71); while ( __stlxr(v72 - 1, v71) ); } else { v72 = *((_DWORD *)v129 - 2); *((_DWORD *)v129 - 2) = v72 - 1; } if ( v72 > 0 ) { LABEL_89: LODWORD(v66) = (_DWORD)v66 + 1; if ( (_DWORD)v66 == 28 ) break; } else { LODWORD(v66) = (_DWORD)v66 + 1; operator delete(v70); if ( (_DWORD)v66 == 28 ) break; } } } v73 = GameStatsManager::sharedState(); if ( GameStatsManager::getStat(v73, "42") > v10 ) { v74 = (char *)&dword_0 + 1; for ( ii = (cocos2d::CCString *)cocos2d::CCString::createWithFormat( (cocos2d::CCString *)"geometry.ach.insane%02d", (const char *)&dword_0 + 1); ; ii = (cocos2d::CCString *)cocos2d::CCString::createWithFormat( (cocos2d::CCString *)"geometry.ach.insane%02d", (const char *)(unsigned int)v74) ) { v76 = (char *)cocos2d::CCString::getCString(ii); v77 = GameManager::sharedState(); sub_D153B8((int)&v130, v76); GameManager::resetAchievement(v77, &v130); v78 = (char *)(v130 - 24); if ( v130 - 24 == (const char *)&qword_124B6B0 ) goto LABEL_99; if ( &pthread_create ) { v79 = (unsigned int *)(v130 - 8); do v80 = __ldaxr(v79); while ( __stlxr(v80 - 1, v79) ); } else { v80 = *((_DWORD *)v130 - 2); *((_DWORD *)v130 - 2) = v80 - 1; } if ( v80 > 0 ) { LABEL_99: LODWORD(v74) = (_DWORD)v74 + 1; if ( (_DWORD)v74 == 11 ) break; } else { LODWORD(v74) = (_DWORD)v74 + 1; operator delete(v78); if ( (_DWORD)v74 == 11 ) break; } } } v81 = GameStatsManager::sharedState(); if ( GameStatsManager::getStat(v81, "15") > v119 ) { v82 = (char *)&dword_0 + 1; do { v83 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat( (cocos2d::CCString *)"geometry.ach.daily%02d", (const char *)(unsigned int)v82); v84 = (char *)cocos2d::CCString::getCString(v83); v85 = GameManager::sharedState(); sub_D153B8((int)&v131, v84); GameManager::resetAchievement(v85, &v131); v86 = (char *)(v131 - 24); if ( v131 - 24 != (const char *)&qword_124B6B0 ) { if ( &pthread_create ) { v95 = (unsigned int *)(v131 - 8); do v96 = __ldaxr(v95); while ( __stlxr(v96 - 1, v95) ); } else { v96 = *((_DWORD *)v131 - 2); *((_DWORD *)v131 - 2) = v96 - 1; } if ( v96 <= 0 ) operator delete(v86); } LODWORD(v82) = (_DWORD)v82 + 1; } while ( (_DWORD)v82 != 8 ); } v87 = GameStatsManager::sharedState(); GameStatsManager::setStat(v87, "6", v13); v88 = GameStatsManager::sharedState(); GameStatsManager::setStat(v88, "28", v12); v89 = GameStatsManager::sharedState(); GameStatsManager::setStat(v89, "5", v11); v90 = GameStatsManager::sharedState(); GameStatsManager::setStat(v90, "42", v10); v91 = GameStatsManager::sharedState(); GameStatsManager::setStat(v91, "15", v119); GameManager::checkUsedIcons(a1); GameStatsManager::sharedState()->m_skipIncrementChallenge = m_skipIncrementChallenge; AchievementManager::sharedState()->m_dontNotify = m_dontNotify; std::_Hashtable,std::__detail::_Identity,std::equal_to,std::hash,std::__detail::_Mod_range_hashing,std::__detail::_Default_ranged_hash,std::__detail::_Prime_rehash_policy,std::__detail::_Hashtable_traits>::~_Hashtable((__int64)&v139); v92 = v125 - 24; if ( v125 - 24 != (char *)&qword_124B6B0 ) { v107 = (unsigned int *)(v125 - 8); if ( &pthread_create ) { do v108 = __ldaxr(v107); while ( __stlxr(v108 - 1, v107) ); } else { v108 = *((_DWORD *)v125 - 2); *((_DWORD *)v125 - 2) = v108 - 1; } if ( v108 <= 0 ) operator delete(v92); } p_m_unknown2 = &v124[-1].m_unknown2; if ( &v124[-1].m_unknown2 != (int *)&qword_124B6B0 ) { p_m_sString = (unsigned int *)&v124[-1].m_sString; if ( &pthread_create ) { do m_data = __ldaxr(p_m_sString); while ( __stlxr(m_data - 1, p_m_sString) ); } else { m_data = (int)v124[-1].m_sString.m_data.m_data; LODWORD(v124[-1].m_sString.m_data.m_data) = m_data - 1; } if ( m_data <= 0 ) operator delete(p_m_unknown2); } std::_Hashtable,std::allocator>,std::__detail::_Select1st,std::equal_to,std::hash,std::__detail::_Mod_range_hashing,std::__detail::_Default_ranged_hash,std::__detail::_Prime_rehash_policy,std::__detail::_Hashtable_traits>::~_Hashtable((__int64)&v132); return _stack_chk_guard; }
GD Web Decomp Icon

GD Web Decomp

Raw Source