//
// LevelBrowserLayer::getSearchTitle from 0x1402cbbc0 to 0x1402cc411 (2129 bytes)
//
// 2 xrefs:
// > LevelBrowserLayer::setupLevelBrowser @ 0x1402cba4a
// > ??> @ 0x1406d2c9c
//
// 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=13
__int64 __fastcall LevelBrowserLayer::getSearchTitle(__int64 a1, __int64 a2)
{
__int64 v4; // rcx
size_t v5; // rdi
int v6; // eax
size_t v7; // r8
char *v8; // rdx
__int64 v9; // rcx
int v10; // edx
cocos2d::CCString *v11; // rax
char *CString; // rax
size_t v13; // r8
void **v14; // r8
cocos2d::CCString *v15; // rax
__int64 v16; // rdx
char v17; // si
const char *v18; // rcx
__int64 v19; // r12
__int64 v20; // rdx
__int64 v21; // r14
cocos2d::CCString *v22; // rax
const char *v23; // rax
size_t v24; // r8
__int64 v25; // r14
void *v26; // rcx
char **v27; // rdx
size_t v28; // r8
void *v29; // rcx
GJAccountManager *v30; // rax
__int64 v31; // rcx
__int64 v32; // rcx
unsigned __int64 v33; // r15
bool v34; // cc
__int64 v35; // rcx
__int64 v36; // r14
cocos2d::CCString *v37; // rax
int v38; // eax
__int64 Username; // r14
void *v40; // rcx
unsigned __int64 v41; // xmm1_8
__int64 v42; // rcx
const char *v43; // rax
cocos2d::CCString *v44; // rax
char *v45; // rax
size_t v46; // r8
char v47; // si
int v48; // eax
unsigned int v49; // eax
int v50; // ecx
bool v51; // r14
const char *v52; // r8
const char *v53; // rdx
cocos2d::CCString *v54; // rax
char *v55; // rax
void *v57; // [rsp+28h] [rbp-51h]
void *v58; // [rsp+28h] [rbp-51h]
void *v59; // [rsp+28h] [rbp-51h]
void *v60; // [rsp+28h] [rbp-51h]
void *v61; // [rsp+28h] [rbp-51h]
void *v62; // [rsp+28h] [rbp-51h]
void *v63; // [rsp+28h] [rbp-51h]
char *String[3]; // [rsp+38h] [rbp-41h] BYREF
unsigned __int64 v65; // [rsp+50h] [rbp-29h]
void *Block[2]; // [rsp+58h] [rbp-21h] BYREF
__int64 v67; // [rsp+68h] [rbp-11h]
unsigned __int64 v68; // [rsp+70h] [rbp-9h]
void *v69[2]; // [rsp+78h] [rbp-1h] BYREF
__int128 v70; // [rsp+88h] [rbp+Fh]
*(_OWORD *)a2 = 0;
*(_QWORD *)(a2 + 16) = 13;
*(_QWORD *)(a2 + 24) = 15;
strcpy((char *)a2, "Online Levels");
v4 = *(_QWORD *)(a1 + 664);
v5 = -1;
if ( !v4 )
goto LABEL_26;
v6 = *(_DWORD *)(v4 + 320);
switch ( v6 )
{
case 'c':
v7 = 12;
v8 = "Saved Levels";
break;
case 'd':
v7 = 15;
v8 = "Favorite Levels";
break;
case 'b':
v7 = 9;
v8 = "My Levels";
break;
case 'f':
v7 = 8;
v8 = "My Lists";
break;
case 'g':
v7 = 14;
v8 = "Favorite Lists";
break;
default:
if ( *(_DWORD *)(v4 + 464) == 1 )
sub_14003CCE0((void **)a2, "Online Lists", 0xCu);
goto LABEL_26;
}
sub_14003CCE0((void **)a2, v8, v7);
if ( *(int *)(*(_QWORD *)(a1 + 664) + 452LL) > 0 )
{
v9 = qword_1406C2EC0;
if ( !qword_1406C2EC0 )
{
v57 = operator new(0x3D0u);
qword_1406C2EC0 = sub_140141280((__int64)v57);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2EC0 + 72LL))(qword_1406C2EC0);
v9 = qword_1406C2EC0;
}
GameLevelManager::getFolderName(
v9,
Block,
*(_DWORD *)(*(_QWORD *)(a1 + 664) + 452LL),
*(_DWORD *)(*(_QWORD *)(a1 + 664) + 320LL) == 98);
v10 = *(_DWORD *)(*(_QWORD *)(a1 + 664) + 452LL);
if ( v67 )
{
v14 = Block;
if ( v68 > 0xF )
v14 = (void **)Block[0];
v15 = cocos2d::CCString::createWithFormat(" (%i: %s)", v10, (const char *)v14);
CString = (char *)cocos2d::CCString::getCString(v15);
v13 = -1;
do
++v13;
while ( CString[v13] );
}
else
{
v11 = cocos2d::CCString::createWithFormat(" (%i)", v10);
CString = (char *)cocos2d::CCString::getCString(v11);
v13 = -1;
do
++v13;
while ( CString[v13] );
}
sub_140041270((_QWORD *)a2, CString, v13);
sub_14003A830((__int64)Block);
}
LABEL_26:
v16 = *(_QWORD *)(a1 + 664);
if ( v16 )
{
sub_14003BDB0((__int64)String, v16 + 328);
v17 = 5;
v18 = (const char *)String;
if ( v65 > 0xF )
v18 = String[0];
v19 = atoi(v18);
sub_14003A830((__int64)String);
v20 = *(_QWORD *)(a1 + 664);
switch ( *(_DWORD *)(v20 + 320) )
{
case 5:
if ( *(_DWORD *)(v20 + 464) == 1
&& (v30 = GJAccountManager::sharedState(), (_DWORD)v19 == v30->m_accountID - v30->m_unkInt1) )
{
sub_14003CCE0((void **)a2, "My Online Lists", 0xFu);
}
else
{
v31 = qword_1406C2ED8;
if ( !qword_1406C2ED8 )
{
v59 = operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00((__int64)v59);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v31 = qword_1406C2ED8;
}
if ( (_DWORD)v19 != *(_DWORD *)(v31 + 652) - *(_DWORD *)(v31 + 656) )
{
v32 = qword_1406C2EC0;
if ( !qword_1406C2EC0 )
{
v60 = operator new(0x3D0u);
qword_1406C2EC0 = sub_140141280((__int64)v60);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2EC0 + 72LL))(qword_1406C2EC0);
v32 = qword_1406C2EC0;
}
GameLevelManager::userNameForUserID(v32, v69, v19);
v33 = v70;
v34 = (unsigned __int64)v70 <= 2;
if ( (unsigned __int64)v70 < 2 )
{
v35 = qword_1406C2EC0;
if ( !qword_1406C2EC0 )
{
v61 = operator new(0x3D0u);
qword_1406C2EC0 = sub_140141280((__int64)v61);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2EC0 + 72LL))(qword_1406C2EC0);
v35 = qword_1406C2EC0;
}
v36 = v35;
if ( !v35 )
{
v62 = operator new(0x3D0u);
qword_1406C2EC0 = sub_140141280((__int64)v62);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2EC0 + 72LL))(qword_1406C2EC0);
v35 = qword_1406C2EC0;
}
v37 = (cocos2d::CCString *)cocos2d::CCDictionary::valueForKey(*(cocos2d::CCDictionary **)(v35 + 536), v19);
v38 = cocos2d::CCString::intValue(v37);
Username = GameLevelManager::tryGetUsername(v36, (__int64)String, v38);
if ( v69 != (void **)Username )
{
if ( *((_QWORD *)&v70 + 1) > 0xFu )
{
v40 = v69[0];
if ( (unsigned __int64)(*((_QWORD *)&v70 + 1) + 1LL) >= 0x1000 )
{
v40 = *((void **)v69[0] - 1);
if ( (unsigned __int64)((char *)v69[0] - (char *)v40 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v40);
}
*(_OWORD *)v69 = *(_OWORD *)Username;
v70 = *(_OWORD *)(Username + 16);
v41 = v70;
*(_QWORD *)(Username + 16) = 0;
*(_QWORD *)(Username + 24) = 15;
*(_BYTE *)Username = 0;
v33 = v41;
}
sub_14003A830((__int64)String);
v34 = v33 <= 2;
}
if ( !v34 )
{
v42 = qword_1406C2EC0;
if ( !qword_1406C2EC0 )
{
v63 = operator new(0x3D0u);
qword_1406C2EC0 = sub_140141280((__int64)v63);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2EC0 + 72LL))(qword_1406C2EC0);
v42 = qword_1406C2EC0;
}
v43 = (const char *)GameLevelManager::userNameForUserID(v42, Block, v19);
if ( *((_QWORD *)v43 + 3) > 0xFu )
v43 = *(const char **)v43;
v44 = cocos2d::CCString::createWithFormat("%ss Levels", v43);
v45 = (char *)cocos2d::CCString::getCString(v44);
v46 = -1;
do
++v46;
while ( v45[v46] );
sub_14003CCE0((void **)a2, v45, v46);
sub_14003A830((__int64)Block);
}
v29 = v69;
goto LABEL_80;
}
sub_14003CCE0((void **)a2, "My Online Levels", 0x10u);
}
break;
case 6:
case 0x10:
case 0x11:
case 0x15:
case 0x16:
case 0x17:
case 0x19:
case 0x1A:
case 0x1C:
case 0x1D:
sub_14003CCE0((void **)a2, " ", 1u);
break;
case 9:
sub_14003CCE0((void **)a2, "Map Packs", 9u);
break;
case 0xA:
v21 = qword_1406C2EC0;
if ( !qword_1406C2EC0 )
{
v58 = operator new(0x3D0u);
qword_1406C2EC0 = sub_140141280((__int64)v58);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2EC0 + 72LL))(qword_1406C2EC0);
v21 = qword_1406C2EC0;
}
v22 = cocos2d::CCString::createWithFormat("pack_%i", *(_DWORD *)(v21 + 908));
v23 = cocos2d::CCString::getCString(v22);
*(_OWORD *)Block = 0;
v67 = 0;
v68 = 0;
v24 = -1;
do
++v24;
while ( v23[v24] );
sub_14003A930(Block, v23, v24);
v25 = cocos2d::CCDictionary::objectForKey(*(_QWORD *)(v21 + 568), Block);
if ( v68 > 0xF )
{
v26 = Block[0];
if ( v68 + 1 >= 0x1000 )
{
v26 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v26 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v26);
}
v67 = 0;
v68 = 15;
LOBYTE(Block[0]) = 0;
if ( v25 )
{
sub_14003BDB0((__int64)String, v25 + 344);
v17 = 37;
v27 = String;
if ( v65 > 0xF )
v27 = (char **)String[0];
v28 = -1;
do
++v28;
while ( *((_BYTE *)v27 + v28) );
sub_14003CCE0((void **)a2, v27, v28);
v29 = String;
LABEL_80:
sub_14003A830((__int64)v29);
}
break;
case 0xE:
sub_14003CCE0((void **)a2, "Find Users", 0xAu);
break;
case 0x65:
sub_14003CCE0((void **)a2, "Smart Templates", 0xFu);
break;
default:
break;
}
sub_14003BDB0((__int64)String, *(_QWORD *)(a1 + 664) + 328LL);
v47 = v17 | 0xA;
v51 = false;
if ( String[2] )
{
v48 = *(_DWORD *)(*(_QWORD *)(a1 + 664) + 320LL);
if ( v48 == 99 || (v49 = v48 - 98, v49 <= 5) && (v50 = 53, _bittest(&v50, v49)) )
v51 = true;
}
if ( (v47 & 2) != 0 )
sub_14003A830((__int64)String);
if ( v51 )
{
sub_14003BDB0((__int64)String, *(_QWORD *)(a1 + 664) + 328LL);
v52 = (const char *)String;
if ( v65 > 0xF )
v52 = String[0];
v53 = (const char *)a2;
if ( *(_QWORD *)(a2 + 24) > 0xFu )
v53 = *(const char **)a2;
v54 = cocos2d::CCString::createWithFormat("%s (%s)", v53, v52);
v55 = (char *)cocos2d::CCString::getCString(v54);
do
++v5;
while ( v55[v5] );
sub_14003CCE0((void **)a2, v55, v5);
sub_14003A830((__int64)String);
}
}
return a2;
}