//
// GameManager::firstLoad from 0x1401886b0 to 0x140188fa1 (2289 bytes)
//
// 2 xrefs:
// > ??> @ 0x14055ce08
// > ??> @ 0x1406cb67c
//
// 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
//
// Hidden C++ exception states: #wind=8
void GameManager::firstLoad(GameManager *a1)
{
__int64 v2; // rcx
cocos2d::CCDictionary *v3; // r12
int i; // esi
cocos2d::CCString *v5; // rax
const char *CString; // rbx
GameManager *v7; // rcx
int IntGameVariable; // r14d
size_t v9; // r8
cocos2d::CCString *v10; // rax
const char *v11; // rax
size_t v12; // r8
__int64 v13; // rax
void *v14; // rcx
bool UGV; // r13
cocos2d::CCDictionary *v16; // rax
cocos2d::CCDictionary *m_valueKeeper; // rcx
cocos2d::CCDictionary *v18; // rbx
cocos2d::CCDictionary *v19; // rax
cocos2d::CCDictionary *m_unlockValueKeeper; // rcx
cocos2d::CCDictionary *v21; // rbx
cocos2d::CCDictionary *v22; // rax
cocos2d::CCDictionary *v23; // rbx
cocos2d::CCDictionary *m_customObjectDict; // rcx
__int64 UniqueUserID; // rax
int v26; // eax
int v27; // eax
__int64 v28; // rax
FMOD::ChannelControl *v29; // rcx
FMOD::ChannelControl *v30; // rcx
AchievementManager *v31; // rsi
__int64 v32; // rcx
cocos2d::CCObject *v33; // rax
cocos2d::CCDictionary *v34; // rbx
cocos2d::CCObject *m_reportedAchievements; // rcx
GameLevelManager *v36; // rcx
GameStatsManager *v37; // rcx
__int64 v38; // rcx
MusicDownloadManager *v39; // rbx
cocos2d::CCObject *v40; // rax
cocos2d::CCDictionary *v41; // rsi
cocos2d::CCObject *m_songObjects; // rcx
KeybindingsManager *v43; // rbx
__int64 v44; // rcx
cocos2d::CCObject *v45; // rax
cocos2d::CCObject *m_keyToCommandDict; // rcx
cocos2d::CCDictionary *v47; // rsi
cocos2d::CCObject *v48; // rax
cocos2d::CCDictionary *v49; // rsi
cocos2d::CCObject *m_commandToKeyDict; // rcx
cocos2d::CCArray *v51; // r15
unsigned int j; // r14d
cocos2d::CCString *v53; // rax
const char *v54; // rax
const char *v55; // rsi
size_t v56; // r8
cocos2d::CCString *v57; // rax
int v58; // ebx
void *v59; // [rsp+20h] [rbp-50h]
FMODAudioEngine *v60; // [rsp+20h] [rbp-50h]
FMODAudioEngine *v61; // [rsp+20h] [rbp-50h]
void *v62; // [rsp+20h] [rbp-50h]
void *v63; // [rsp+20h] [rbp-50h]
__int128 v64; // [rsp+28h] [rbp-48h] BYREF
__int64 v65; // [rsp+38h] [rbp-38h]
__int64 v66; // [rsp+40h] [rbp-30h]
__int128 v67; // [rsp+48h] [rbp-28h] BYREF
__int64 v68; // [rsp+58h] [rbp-18h]
unsigned __int64 v69; // [rsp+60h] [rbp-10h]
a1->m_socialsDuration = 0.0;
*(_DWORD *)&a1->m_clickedTwitter = 0;
a1->m_clickedFacebook = 0;
a1->m_clickedReddit = 0;
UIButtonConfig::reset(&a1->m_dpad1);
UIButtonConfig::reset(&a1->m_dpad2);
UIButtonConfig::reset(&a1->m_dpad3);
UIButtonConfig::resetOneBtn(&a1->m_dpad4);
UIButtonConfig::resetOneBtn(&a1->m_dpad5);
v3 = nullptr;
if ( a1->m_shouldLoadUnlockValueKeeper && a1->m_valueKeeper )
{
v3 = (cocos2d::CCDictionary *)cocos2d::CCDictionary::create(v2);
for ( i = 1; i <= 181; ++i )
{
v5 = cocos2d::CCString::createWithFormat("%04i", i);
CString = cocos2d::CCString::getCString(v5);
v7 = (GameManager *)qword_1406C2ED8;
if ( !qword_1406C2ED8 )
{
v59 = operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00((__int64)v59);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v7 = (GameManager *)qword_1406C2ED8;
}
IntGameVariable = GameManager::getIntGameVariable(v7, CString);
if ( IntGameVariable > 0 )
{
v67 = 0;
v68 = 0;
v69 = 0;
v9 = -1;
do
++v9;
while ( CString[v9] );
sub_14003A930(&v67, CString, v9);
v10 = cocos2d::CCString::createWithFormat("%i", IntGameVariable);
v11 = cocos2d::CCString::getCString(v10);
v64 = 0;
v65 = 0;
v66 = 0;
v12 = -1;
do
++v12;
while ( v11[v12] );
sub_14003A930(&v64, v11, v12);
v13 = cocos2d::CCString::create(&v64);
cocos2d::CCDictionary::setObject(v3, v13, &v67);
sub_14003A830((__int64)&v64);
if ( v69 > 0xF )
{
v14 = (void *)v67;
if ( v69 + 1 >= 0x1000 )
{
v14 = *(void **)(v67 - 8);
if ( (unsigned __int64)(v67 - (_QWORD)v14 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v14);
}
}
}
}
UGV = 0;
if ( a1->m_shouldLoadUnlockValueKeeper && a1->m_unlockValueKeeper )
UGV = GameManager::getUGV(a1, "30");
v16 = (cocos2d::CCDictionary *)cocos2d::CCDictionary::create(v2);
v18 = v16;
if ( a1->m_valueKeeper != v16 )
{
if ( v16 )
cocos2d::CCObject::retain(v16);
m_valueKeeper = a1->m_valueKeeper;
if ( m_valueKeeper )
cocos2d::CCObject::release(m_valueKeeper);
a1->m_valueKeeper = v18;
}
v19 = (cocos2d::CCDictionary *)cocos2d::CCDictionary::create(m_valueKeeper);
v21 = v19;
if ( a1->m_unlockValueKeeper != v19 )
{
if ( v19 )
cocos2d::CCObject::retain(v19);
m_unlockValueKeeper = a1->m_unlockValueKeeper;
if ( m_unlockValueKeeper )
cocos2d::CCObject::release(m_unlockValueKeeper);
a1->m_unlockValueKeeper = v21;
}
if ( !a1->m_customObjectDict )
{
v22 = (cocos2d::CCDictionary *)cocos2d::CCDictionary::create(m_unlockValueKeeper);
v23 = v22;
if ( a1->m_customObjectDict != v22 )
{
if ( v22 )
cocos2d::CCObject::retain(v22);
m_customObjectDict = a1->m_customObjectDict;
if ( m_customObjectDict )
cocos2d::CCObject::release(m_customObjectDict);
a1->m_customObjectDict = v23;
}
}
if ( !a1->m_shouldLoadUnlockValueKeeper )
{
UniqueUserID = PlatformToolbox::getUniqueUserID((__int64)&v64);
sub_140051590((__int64)&a1->m_playerUDID, UniqueUserID);
sub_14003A830((__int64)&v64);
}
sub_14003CCE0((void **)&a1->m_playerName, "Player", 6u);
a1->m_playerUserID.value = 0;
v26 = (int)(float)((float)((float)rand() / 32767.0) * 1000.0);
a1->m_playerUserID.seed = v26;
a1->m_playerUserID.random = v26;
a1->m_hasRP.value = 0;
v27 = (int)(float)((float)((float)rand() / 32767.0) * 1000.0);
a1->m_hasRP.seed = v27;
a1->m_hasRP.random = v27;
a1->m_hasDRP = 0;
if ( !a1->m_shouldLoadUnlockValueKeeper )
{
*(_WORD *)&a1->m_firstSetup = 257;
a1->m_unknownBool4 = 1;
}
GameManager::resetAllIcons(a1);
if ( !a1->m_shouldLoadUnlockValueKeeper )
{
v28 = qword_1406C2E88;
if ( !qword_1406C2E88 )
{
v60 = (FMODAudioEngine *)operator new(0x888u);
qword_1406C2E88 = (__int64)FMODAudioEngine::FMODAudioEngine(v60);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2E88 + 72LL))(qword_1406C2E88);
v28 = qword_1406C2E88;
}
*(_DWORD *)(v28 + 524) = 0;
*(_DWORD *)(v28 + 512) = 1065353216;
v29 = *(FMOD::ChannelControl **)(v28 + 552);
if ( v29 )
{
FMOD::ChannelControl::setVolume(v29, 1.0);
v28 = qword_1406C2E88;
}
if ( !v28 )
{
v61 = (FMODAudioEngine *)operator new(0x888u);
qword_1406C2E88 = (__int64)FMODAudioEngine::FMODAudioEngine(v61);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2E88 + 72LL))(qword_1406C2E88);
v28 = qword_1406C2E88;
}
*(_DWORD *)(v28 + 516) = 1065353216;
v30 = *(FMOD::ChannelControl **)(v28 + 584);
if ( v30 )
FMOD::ChannelControl::setVolume(v30, 1.0);
}
v31 = AchievementManager::sharedState();
v33 = (cocos2d::CCObject *)cocos2d::CCDictionary::create(v32);
v34 = (cocos2d::CCDictionary *)v33;
if ( v31->m_reportedAchievements != v33 )
{
if ( v33 )
cocos2d::CCObject::retain(v33);
m_reportedAchievements = v31->m_reportedAchievements;
if ( m_reportedAchievements )
cocos2d::CCObject::release(m_reportedAchievements);
v31->m_reportedAchievements = v34;
}
v36 = (GameLevelManager *)qword_1406C2EC0;
if ( !qword_1406C2EC0 )
{
v62 = operator new(0x3D0u);
qword_1406C2EC0 = sub_140141280((__int64)v62);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2EC0 + 72LL))(qword_1406C2EC0);
v36 = (GameLevelManager *)qword_1406C2EC0;
}
GameLevelManager::firstSetup(v36);
v37 = (GameStatsManager *)qword_1406C2EE8;
if ( !qword_1406C2EE8 )
{
v63 = operator new(0x3E0u);
qword_1406C2EE8 = sub_1401D0AE0(v63);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2EE8 + 72LL))(qword_1406C2EE8);
v37 = (GameStatsManager *)qword_1406C2EE8;
}
GameStatsManager::firstSetup(v37);
v39 = MusicDownloadManager::sharedState();
if ( !v39->m_songObjects )
{
v40 = (cocos2d::CCObject *)cocos2d::CCDictionary::create(v38);
v41 = (cocos2d::CCDictionary *)v40;
if ( v39->m_songObjects != v40 )
{
if ( v40 )
cocos2d::CCObject::retain(v40);
m_songObjects = v39->m_songObjects;
if ( m_songObjects )
cocos2d::CCObject::release(m_songObjects);
v39->m_songObjects = v41;
}
}
v39->m_songPriority = 0;
GJAccountManager::sharedState();
GJMultiplayerManager::sharedState();
v43 = KeybindingsManager::sharedState();
v45 = (cocos2d::CCObject *)cocos2d::CCDictionary::create(v44);
v47 = (cocos2d::CCDictionary *)v45;
if ( v43->m_keyToCommandDict != v45 )
{
if ( v45 )
cocos2d::CCObject::retain(v45);
m_keyToCommandDict = v43->m_keyToCommandDict;
if ( m_keyToCommandDict )
cocos2d::CCObject::release(m_keyToCommandDict);
v43->m_keyToCommandDict = v47;
}
v48 = (cocos2d::CCObject *)cocos2d::CCDictionary::create(m_keyToCommandDict);
v49 = (cocos2d::CCDictionary *)v48;
if ( v43->m_commandToKeyDict != v48 )
{
if ( v48 )
cocos2d::CCObject::retain(v48);
m_commandToKeyDict = v43->m_commandToKeyDict;
if ( m_commandToKeyDict )
cocos2d::CCObject::release(m_commandToKeyDict);
v43->m_commandToKeyDict = v49;
}
if ( a1->m_shouldLoadUnlockValueKeeper )
{
if ( v3 )
{
v51 = cocos2d::CCDictionary::allKeys(v3);
for ( j = 0; j < cocos2d::CCArray::count(v51); ++j )
{
v53 = cocos2d::CCArray::stringAtIndex(v51, j);
v54 = cocos2d::CCString::getCString(v53);
v55 = v54;
v64 = 0;
v65 = 0;
v66 = 0;
v56 = -1;
do
++v56;
while ( v54[v56] );
sub_14003A930(&v64, v54, v56);
v57 = (cocos2d::CCString *)cocos2d::CCDictionary::valueForKey(v3, &v64);
v58 = cocos2d::CCString::intValue(v57);
sub_14003A830((__int64)&v64);
GameManager::setIntGameVariable(a1, v55, v58);
}
}
}
else
{
a1->m_resolution = -1;
*(_WORD *)&a1->m_showSongMarkers = 1;
*(_WORD *)&a1->m_showProgressBar = 0;
a1->m_vsyncEnabled = 1;
*(_WORD *)&a1->m_showedRateDiffDialog = 0;
a1->m_showedLowDetailDialog = 0;
a1->m_recordGameplay = 0;
GameManager::setGameVariable(a1, "0002", 1);
GameManager::setGameVariable(a1, "0001", 1);
GameManager::setGameVariable(a1, "0026", 1);
GameManager::setGameVariable(a1, "0027", 1);
GameManager::setGameVariable(a1, "0038", 1);
GameManager::setGameVariable(a1, "0043", 1);
GameManager::setGameVariable(a1, "0044", 1);
GameManager::setIntGameVariable(a1, "0050", 2);
GameManager::setIntGameVariable(a1, "0049", 6);
GameManager::setGameVariable(a1, "0046", 1);
GameManager::setGameVariable(a1, "0044", 1);
GameManager::setGameVariable(a1, "0036", 1);
GameManager::setGameVariable(a1, "0118", 1);
GameManager::setGameVariable(a1, "0117", 1);
GameManager::setGameVariable(a1, "0158", 1);
GameManager::setGameVariable(a1, "0121", 1);
GameManager::setGameVariable(a1, "0037", 1);
GameManager::setGameVariable(a1, "0030", 1);
GameManager::setGameVariable(a1, "0013", 1);
GameManager::setGameVariable(a1, "0018", 1);
}
if ( a1->m_shouldLoadUnlockValueKeeper && UGV )
GameManager::setUGV(a1, "30", 1);
a1->m_loaded = 1;
}