//
// GameLevelManager::getNextLevelName from 0x3bf000 to 0x3bf1de (478 bytes)
//
// 1 xrefs:
// > GJGameLevel::copyLevelInfo @ 0x3c974a
//
// 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
//
_DWORD *__fastcall GameLevelManager::getNextLevelName(_DWORD *a1, int a2, const char **a3)
{
unsigned int i; // r5
unsigned int v6; // r1
LocalLevelManager *v7; // r0
int v8; // r0
int v9; // r10
cocos2d::CCString *v10; // r0
char *CString; // r0
unsigned int j; // r8
cocos2d::CCString *v13; // r0
char *v14; // r0
cocos2d::CCDictionary *AllLevelsInDict; // [sp+4h] [bp-38h]
int v17; // [sp+8h] [bp-34h]
int v18; // [sp+1Ch] [bp-20h]
char *v19; // [sp+24h] [bp-18h] BYREF
int v20; // [sp+28h] [bp-14h] BYREF
char *v21; // [sp+2Ch] [bp-10h] BYREF
std::string v22; // [sp+30h] [bp-Ch] BYREF
for ( i = 0; ; ++i )
{
v6 = *((_DWORD *)*a3 - 3);
if ( i >= v6 || (unsigned int)*(unsigned __int8 *)sub_7757BC(a3, v6 - 1 - i) - 48 > 9 )
break;
}
if ( i )
{
v7 = LocalLevelManager::sharedState();
AllLevelsInDict = LocalLevelManager::getAllLevelsInDict(v7);
sub_776158(&v19, a3, *((_DWORD *)*a3 - 3) - i, *((_DWORD *)*a3 - 3));
v8 = atoi(v19);
v17 = v8 + 1000;
v9 = v8;
while ( 1 )
{
v10 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat((cocos2d::CCString *)"%i", (const char *)++v9);
CString = (char *)cocos2d::CCString::getCString(v10);
sub_776584((int)&v20, CString);
if ( *(_DWORD *)(v20 - 12) < i )
{
sub_776584((int)&v22, (char *)&unk_939830);
for ( j = 0; j < i - *(_DWORD *)(v20 - 12); ++j )
sub_774544((int)&v22, "0");
sub_77441C(&v22, &v20);
sub_775D40(&v20, &v22);
sub_774008(&v22);
}
sub_776158(&v21, a3, 0, *((_DWORD *)*a3 - 3) - i);
sub_77441C(&v21, &v20);
sub_776584((int)&v22, v21);
v18 = cocos2d::CCDictionary::objectForKey(AllLevelsInDict, &v22);
sub_774008(&v22);
if ( !v18 )
{
*a1 = v21;
v21 = (char *)&unk_ACDDA8;
goto LABEL_17;
}
if ( v9 == v17 )
break;
sub_774008(&v21);
sub_774008(&v20);
}
*a1 = *a3;
*a3 = (const char *)&unk_ACDDA8;
LABEL_17:
sub_774008(&v21);
sub_774008(&v20);
sub_774008(&v19);
}
else
{
if ( strlen(*a3) <= 0x12 )
{
v13 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat((cocos2d::CCString *)"%s 2", *a3);
v14 = (char *)cocos2d::CCString::getCString(v13);
sub_7753D4((int)a3, v14);
}
*a1 = *a3;
*a3 = (const char *)&unk_ACDDA8;
}
return a1;
}