//
// GameLevelManager::getMainLevel from 0x1000921f8 to 0x100092488 (656 bytes)
//
// 16 xrefs:
// > SecretLayer2::init @ 0x10030a3c4
// > SecretLayer2::onSecretLevel @ 0x10030bb24
// > GameManager::verifyStarUnlocks @ 0x100313ec0
// > GameManager::verifyCoinUnlocks @ 0x100313f4c
// > GameManager::verifyCoinUnlocks @ 0x100313ff4
// > GameManager::recountUserStats @ 0x100319e2c
// > GameManager::dataLoaded @ 0x10031c0d8
// > GameManager::dataLoaded @ 0x10031c33c
// > GameManager::dataLoaded @ 0x10031c360
// > GameManager::dataLoaded @ 0x10031c384
// > GameStatsManager::getTotalCollectedCurrency @ 0x100334a08
// > GameStatsManager::getTotalCollectedCurrency @ 0x100334acc
// > GameStatsManager::getTotalCollectedCurrency @ 0x100334b8c
// > LevelAreaInnerLayer::init @ 0x1003459f8
// > LevelAreaInnerLayer::playStep1 @ 0x100346d08
// > LevelSelectLayer::init @ 0x100401cf4
//
// 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
//
GJGameLevel *__fastcall GameLevelManager::getMainLevel(GameLevelManager *a1, int a2, bool a3)
{
cocos2d::CCDictionary *m_mainLevels; // x19
cocos2d::CCString *v7; // x0
char *CString; // x0
GJGameLevel *v9; // x19
GJGameLevel *Level; // x0
GJGameLevel *v11; // x21
cocos2d::CCDictionary *v12; // x21
cocos2d::CCString *v13; // x0
char *v14; // x0
int v15; // w22
float v16; // s0
int v17; // w22
float v18; // s0
float v19; // s0
std::string m_capacityString; // [xsp+10h] [xbp-90h] BYREF
std::string __dst; // [xsp+30h] [xbp-70h] BYREF
std::string __str; // [xsp+50h] [xbp-50h] BYREF
void *v24[2]; // [xsp+68h] [xbp-38h] BYREF
char v25; // [xsp+7Fh] [xbp-21h]
m_mainLevels = a1->m_mainLevels;
v7 = (cocos2d::CCString *)sub_100268F4C("%i", a2);
CString = (char *)cocos2d::CCString::getCString(v7);
sub_100009900(v24, CString);
v9 = (GJGameLevel *)cocos2d::CCDictionary::objectForKey_1(m_mainLevels, v24);
if ( v25 < 0 )
operator delete(v24[0]);
Level = LevelTools::getLevel(a2, a3);
if ( v9 )
{
v11 = Level;
if ( Level->m_levelString.m_data.m_short.shortStorage.__elems_[22] < 0 )
sub_1000097D0(
&__str,
(void *)Level->m_levelString.m_data.m_long.capacitym1,
Level->m_levelString.m_data.m_long.size);
else
__str = (std::string)Level->m_levelString;
std::string::operator=((std::string *)&v9->m_levelString, &__str);
if ( SHIBYTE(__str.__r_.__value_.__r.__words[2]) < 0 )
operator delete(__str.__r_.__value_.__l.__data_);
v15 = v11->m_stars.random - v11->m_stars.seed;
v9->m_stars.value = v15;
v16 = vcvts_n_f32_s32(rand(), 0x1Fu) * 1000.0;
v9->m_stars.seed = (int)v16;
v9->m_stars.random = v15 + (int)v16;
v9->m_coins = v11->m_coins;
v9->m_requiredCoins = v11->m_requiredCoins;
if ( v11->m_levelName.m_data.m_short.shortStorage.__elems_[22] < 0 )
sub_1000097D0(&__dst, (void *)v11->m_levelName.m_data.m_long.capacitym1, v11->m_levelName.m_data.m_long.size);
else
__dst = (std::string)v11->m_levelName;
std::string::operator=((std::string *)&v9->m_levelName, &__dst);
if ( SHIBYTE(__dst.__r_.__value_.__r.__words[2]) < 0 )
operator delete(__dst.__r_.__value_.__l.__data_);
v9->m_audioTrack = v11->m_audioTrack;
v9->m_twoPlayerMode = v11->m_twoPlayerMode;
v17 = v11->m_demon.random - v11->m_demon.seed;
v9->m_demon.value = v17;
v18 = vcvts_n_f32_s32(rand(), 0x1Fu) * 1000.0;
v9->m_demon.seed = (int)v18;
v9->m_demon.random = v17 + (int)v18;
v9->m_difficulty = v11->m_difficulty;
if ( v11->m_capacityString.m_data.m_short.shortStorage.__elems_[22] < 0 )
sub_1000097D0(
&m_capacityString,
(void *)v11->m_capacityString.m_data.m_long.capacitym1,
v11->m_capacityString.m_data.m_long.size);
else
m_capacityString = (std::string)v11->m_capacityString;
std::string::operator=((std::string *)&v9->m_capacityString, &m_capacityString);
if ( SHIBYTE(m_capacityString.__r_.__value_.__r.__words[2]) < 0 )
operator delete(m_capacityString.__r_.__value_.__l.__data_);
v9->m_levelID.value = a2;
v19 = vcvts_n_f32_s32(rand(), 0x1Fu) * 1000.0;
v9->m_levelID.seed = (int)v19;
v9->m_levelID.random = (int)v19 + a2;
v9->m_timestamp = v11->m_timestamp;
v9->m_levelLength = v11->m_levelLength;
}
else
{
v9 = LevelTools::getLevel(a2, 0);
v12 = a1->m_mainLevels;
v13 = (cocos2d::CCString *)sub_100268F4C("%i", a2);
v14 = (char *)cocos2d::CCString::getCString(v13);
sub_100009900(v24, v14);
cocos2d::CCDictionary::setObject_1(v12, v9, v24);
if ( v25 < 0 )
operator delete(v24[0]);
}
return v9;
}