//
// LocalLevelManager::tryLoadMainLevelString from 0x9145ac to 0x9147a8 (508 bytes)
//
// 2 xrefs:
// > LocalLevelManager::getMainLevelString @ 0x9147c8
// > ??> @ 0xe8090
//
// This function is hookable on this platform (idp: arm, 32 bit: False, 64 bit: True!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 12:57:18 +0000
//
__int64 __fastcall LocalLevelManager::tryLoadMainLevelString(LocalLevelManager *this, unsigned int a2)
{
char *v2; // x21
__int64 v4; // x23
cocos2d::CCString *v5; // x0
const char *CString; // x0
size_t v7; // x0
char *v8; // x1
cocos2d::CCString *v9; // x0
cocos2d::CCString *v10; // x0
size_t v11; // x0
__int64 *v12; // x0
char *v13; // x1
size_t v14; // x2
char *v15; // [xsp+40h] [xbp+40h]
char *v16; // [xsp+40h] [xbp+40h]
unsigned int v17; // [xsp+4Ch] [xbp+4Ch] BYREF
__int64 v18[2]; // [xsp+50h] [xbp+50h] BYREF
void *v19; // [xsp+60h] [xbp+60h]
void *v20[2]; // [xsp+68h] [xbp+68h] BYREF
void *v21; // [xsp+78h] [xbp+78h]
__int64 v22; // [xsp+80h] [xbp+80h] BYREF
size_t v23; // [xsp+88h] [xbp+88h]
void *v24; // [xsp+90h] [xbp+90h]
v2 = (char *)this + 376;
v17 = a2;
if ( std::__hash_table,std::__unordered_map_hasher,std::hash,true>,std::__unordered_map_equal,std::equal_to,true>,std::allocator>>::find(
(_QWORD *)this + 47,
(int *)&v17) )
{
return _stack_chk_guard;
}
v4 = cocos2d::CCFileUtils::sharedFileUtils(nullptr);
v5 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat((cocos2d::CCString *)"levels/%i.txt", (const char *)v17);
CString = (const char *)cocos2d::CCString::getCString(v5);
v18[0] = 0;
v15 = (char *)CString;
v18[1] = 0;
v19 = nullptr;
v7 = strlen(CString);
std::string::__init(v18, v15, v7);
v8 = (char *)v18 + 1;
if ( (v18[0] & 1) != 0 )
v8 = (char *)v19;
(*(void (__fastcall **)(void **__return_ptr, __int64, char *, _QWORD))(*(_QWORD *)v4 + 48LL))(v20, v4, v8, 0);
v9 = (cocos2d::CCString *)((char *)v20 + 1);
if ( ((__int64)v20[0] & 1) != 0 )
v9 = (cocos2d::CCString *)v21;
v10 = (cocos2d::CCString *)cocos2d::CCString::createWithContentsOfFile(v9, (const char *)LOBYTE(v20[0]));
if ( v10 )
{
v16 = (char *)cocos2d::CCString::getCString(v10);
v22 = 0;
v23 = 0;
v24 = nullptr;
v11 = strlen(v16);
std::string::__init(&v22, v16, v11);
if ( (v22 & 1) != 0 )
{
if ( !v23 )
{
LABEL_10:
operator delete(v24);
goto LABEL_11;
}
}
else if ( !((int)(unsigned __int8)v22 >> 1) )
{
goto LABEL_11;
}
v12 = (__int64 *)std::unordered_map::operator[]((__int64)v2, (int *)&v17);
if ( v12 != &v22 )
{
if ( (v22 & 1) != 0 )
{
v13 = (char *)v24;
v14 = v23;
}
else
{
v14 = (unsigned __int8)v22 >> 1;
v13 = (char *)&v22 + 1;
}
std::string::assign(v12, v13, v14);
}
if ( (v22 & 1) == 0 )
goto LABEL_11;
goto LABEL_10;
}
LABEL_11:
if ( ((__int64)v20[0] & 1) != 0 )
operator delete(v21);
if ( (v18[0] & 1) != 0 )
operator delete(v19);
return _stack_chk_guard;
}