//
// GameLevelManager::getMainLevel from 0x3bf4dc to 0x3bf632 (342 bytes)
//
// 22 xrefs:
// > GameManager::verifyStarUnlocks @ 0x3214ba
// > GameManager::verifySyncedCoins @ 0x3214ee
// > GameManager::verifySyncedCoins @ 0x321560
// > GameManager::verifyCoinUnlocks @ 0x3266f0
// > GameManager::verifyCoinUnlocks @ 0x326762
// > GameManager::recountUserStats @ 0x328036
// > GameManager::dataLoaded @ 0x328dd0
// > GameManager::dataLoaded @ 0x328f76
// > GameManager::dataLoaded @ 0x328f90
// > GameManager::dataLoaded @ 0x328faa
// > LevelSelectLayer::init @ 0x40a18a
// > GameStatsManager::getTotalCollectedCurrency @ 0x40dac2
// > GameStatsManager::getTotalCollectedCurrency @ 0x40db3e
// > GameStatsManager::getTotalCollectedCurrency @ 0x40dbba
// > GameStatsManager::awardOldSpecialStats @ 0x41c240
// > SecretLayer2::onSecretLevel @ 0x4eab64
// > SecretLayer2::init @ 0x4eef3c
// > GJWorldNode::unlockActiveItem @ 0x4fce14
// > GJWorldNode::init @ 0x4fda90
// > GJWorldNode::onLevel @ 0x4ff442
// > LevelAreaInnerLayer::playStep1 @ 0x56bdd2
// > LevelAreaInnerLayer::init @ 0x56d2ba
//
// 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 *GameLevelManager::getMainLevel(GameLevelManager *a1, int a2, bool a3)
{
cocos2d::CCDictionary *m_mainLevels; // r5
char *LevelKey; // r0
GJGameLevel *v8; // r5
GJGameLevel *Level; // r0
GJGameLevel *v10; // r6
GJGameLevel *v11; // r0
cocos2d::CCDictionary *v12; // r6
char *v13; // r0
int random; // r1
std::string v16; // [sp+8h] [bp-8h] BYREF
v16.m_data.m_data = (stl::StringData::Internal *)a3;
m_mainLevels = a1->m_mainLevels;
LevelKey = (char *)GameLevelManager::getLevelKey(a1, a2);
sub_776584((int)&v16, LevelKey);
v8 = (GJGameLevel *)cocos2d::CCDictionary::objectForKey(m_mainLevels, &v16);
sub_774008(&v16);
Level = LevelTools::getLevel(a2, a3);
v10 = Level;
if ( v8 )
{
sub_775C20(&v16, &Level->m_levelString);
sub_775D40(&v8->m_levelString, &v16);
sub_774008(&v16);
GJGameLevel::setStars(v8, v10->m_stars.random - v10->m_stars.seed);
v8->m_coins = v10->m_coins;
v8->m_requiredCoins = v10->m_requiredCoins;
sub_775C20(&v16, &v10->m_levelName);
sub_775D40(&v8->m_levelName, &v16);
sub_774008(&v16);
v8->m_audioTrack = v10->m_audioTrack;
random = v10->m_demon.random;
v8->m_twoPlayerMode = v10->m_twoPlayerMode;
GJGameLevel::setDemon(v8, random - v10->m_demon.seed);
v8->m_difficulty = v10->m_difficulty;
sub_775C20(&v16, &v10->m_capacityString);
sub_775D40(&v8->m_capacityString, &v16);
sub_774008(&v16);
GJGameLevel::setLevelID(v8, a2);
v8->m_timestamp = v10->m_timestamp;
v8->m_levelLength = v10->m_levelLength;
}
else
{
v11 = LevelTools::getLevel(a2, 0);
v12 = a1->m_mainLevels;
v8 = v11;
v13 = (char *)GameLevelManager::getLevelKey(a1, a2);
sub_776584((int)&v16, v13);
cocos2d::CCDictionary::setObject((int)v12, v8);
sub_774008(&v16);
}
return v8;
}