//
// LevelBrowserLayer::getSearchTitle from 0x6e8058 to 0x6e8874 (2076 bytes)
//
// 2 xrefs:
// > LevelBrowserLayer::setupLevelBrowser @ 0x6e8984
// > ??> @ 0x48b28
//
// 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
//
const char **__usercall LevelBrowserLayer::getSearchTitle@(LevelBrowserLayer *this@, const char **a2@)
{
GJSearchObject *m_searchObject; // x1
SearchType m_searchType; // w0
char *v6; // x24
int v7; // w25
char *v8; // x0
GJSearchObject *v9; // x1
__int64 *v10; // x0
GJSearchObject *v11; // x1
_BOOL4 v12; // w24
GameLevelManager *v14; // x0
GJSearchObject *v15; // x1
cocos2d::CCString *v16; // x0
size_t v17; // x0
void *v18; // x0
const char *v19; // x20
double v20; // d0
cocos2d::CCString *v21; // x0
size_t v22; // x0
void *v23; // x0
unsigned int *v24; // x1
int v25; // w2
GameLevelManager *v26; // x24
GameLevelManager *v27; // x0
GJMapPack *SavedMapPack; // x1
size_t v29; // x0
char *v30; // x0
unsigned int *v31; // x1
int v32; // w2
GameManager *v33; // x0
GameLevelManager *v34; // x0
__int64 v35; // x1
unsigned __int64 v36; // x0
unsigned int *v37; // x2
int v38; // w1
unsigned int *v39; // x24
int v40; // w1
GJAccountManager *v41; // x0
GameLevelManager *v42; // x24
GameLevelManager *v43; // x0
int v44; // w0
unsigned int *v45; // x1
int v46; // w2
unsigned int *v47; // x1
int v48; // w2
GameLevelManager *v49; // x0
cocos2d::CCString *v50; // x0
size_t v51; // x0
const char *CString; // [xsp+58h] [xbp+58h]
const char *v53; // [xsp+58h] [xbp+58h]
char *v54; // [xsp+58h] [xbp+58h]
const char *v55; // [xsp+58h] [xbp+58h]
char *v56; // [xsp+68h] [xbp+68h] BYREF
char *v57; // [xsp+70h] [xbp+70h] BYREF
__int64 v58; // [xsp+78h] [xbp+78h] BYREF
char *v59; // [xsp+80h] [xbp+80h] BYREF
__int64 v60; // [xsp+88h] [xbp+88h] BYREF
__int64 v61; // [xsp+90h] [xbp+90h] BYREF
sub_D153B8((int)a2, "Online Levels");
m_searchObject = this->m_searchObject;
if ( !m_searchObject )
return a2;
m_searchType = m_searchObject->m_searchType;
if ( (unsigned int)(m_searchType - 102) <= 1 || (unsigned int)(m_searchType - 98) <= 2 )
{
switch ( m_searchType )
{
case SavedLevels:
sub_D1798C(a2, "Saved Levels", 12);
break;
case FavouriteLevels:
sub_D1798C(a2, "Favorite Levels", 15);
break;
case MyLists:
sub_D1798C(a2, "My Lists", 8);
break;
case FavouriteLists:
sub_D1798C(a2, "Favorite Lists", 14);
break;
default:
sub_D1798C(a2, "My Levels", 9);
break;
}
m_searchObject = this->m_searchObject;
if ( m_searchObject->m_folder <= 0 )
goto LABEL_5;
v14 = GameLevelManager::sharedState();
GameLevelManager::getFolderName(v14, this->m_searchObject->m_folder, this->m_searchObject->m_searchType == MyLevels);
v15 = this->m_searchObject;
if ( *(_QWORD *)(v61 - 24) )
v16 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)" (%i: %s)",
(const char *)(unsigned int)v15->m_folder);
else
v16 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)" (%i)",
(const char *)(unsigned int)v15->m_folder);
CString = cocos2d::CCString::getCString(v16);
v17 = strlen(CString);
sub_D15FD4(a2, CString, v17);
v18 = (void *)(v61 - 24);
if ( (__int64 *)(v61 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v47 = (unsigned int *)(v61 - 8);
do
v48 = __ldaxr(v47);
while ( __stlxr(v48 - 1, v47) );
}
else
{
v48 = *(_DWORD *)(v61 - 8);
*(_DWORD *)(v61 - 8) = v48 - 1;
}
if ( v48 <= 0 )
operator delete(v18);
}
}
else
{
if ( m_searchObject->m_searchMode != 1 )
goto LABEL_5;
sub_D1798C(a2, "Online Lists", 12);
}
m_searchObject = this->m_searchObject;
if ( !m_searchObject )
return a2;
LABEL_5:
sub_D18D28(&v56, &m_searchObject->m_searchQuery);
v6 = v56;
v7 = atoi(v56);
v8 = v6 - 24;
if ( v6 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v39 = (unsigned int *)(v6 - 8);
do
v40 = __ldaxr(v39);
while ( __stlxr(v40 - 1, v39) );
}
else
{
v40 = *((_DWORD *)v6 - 2);
*((_DWORD *)v6 - 2) = v40 - 1;
}
if ( v40 <= 0 )
operator delete(v8);
}
v9 = this->m_searchObject;
switch ( v9->m_searchType )
{
case UsersLevels:
if ( v9->m_searchMode == 1 && (v41 = GJAccountManager::sharedState(), v7 == v41->m_accountID - v41->m_unkInt1) )
{
sub_D1798C(a2, "My Online Lists", 15);
v9 = this->m_searchObject;
}
else
{
v33 = GameManager::sharedState();
if ( v7 == v33->m_playerUserID.random - v33->m_playerUserID.seed )
{
sub_D1798C(a2, "My Online Levels", 16);
v9 = this->m_searchObject;
}
else
{
v34 = GameLevelManager::sharedState();
GameLevelManager::userNameForUserID(&v61, v34, v7);
v35 = v61;
v36 = *(_QWORD *)(v61 - 24);
if ( v36 <= 1 )
{
v42 = GameLevelManager::sharedState();
v43 = GameLevelManager::sharedState();
v44 = GameLevelManager::accountIDForUserID(v43, v7);
GameLevelManager::tryGetUsername(&v58, v42, v44);
sub_D163D4(&v61, &v58);
if ( (__int64 *)(v58 - 24) != &qword_124B6B0 )
sub_6E6A5C((void *)(v58 - 24));
v35 = v61;
v36 = *(_QWORD *)(v61 - 24);
}
if ( v36 > 2 )
{
v49 = GameLevelManager::sharedState();
GameLevelManager::userNameForUserID((__int64 *)&v59, v49, v7);
v50 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat((cocos2d::CCString *)"%ss Levels", v59);
v55 = cocos2d::CCString::getCString(v50);
v51 = strlen(v55);
sub_D1798C(a2, v55, v51);
if ( v59 - 24 != (char *)&qword_124B6B0 )
sub_6E6A5C(v59 - 24);
v35 = v61;
}
v30 = (char *)(v35 - 24);
if ( (__int64 *)(v35 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v45 = (unsigned int *)(v35 - 8);
do
v46 = __ldaxr(v45);
while ( __stlxr(v46 - 1, v45) );
}
else
{
v46 = *(_DWORD *)(v35 - 8);
*(_DWORD *)(v35 - 8) = v46 - 1;
}
if ( v46 <= 0 )
goto LABEL_75;
}
v9 = this->m_searchObject;
}
}
break;
case Recent|MostLiked:
case HallOfFame:
case FeaturedGDW:
case DailySafe:
case WeeklySafe:
case EventSafe:
case LevelListsOnClick:
case Type26:
case FeaturedLite:
case FeaturedLite|Downloaded:
sub_D1798C(a2, " ", 1);
v9 = this->m_searchObject;
break;
case Sends|Downloaded:
sub_D1798C(a2, "Map Packs", 9);
v9 = this->m_searchObject;
break;
case MapPackOnClick:
v26 = GameLevelManager::sharedState();
v27 = GameLevelManager::sharedState();
SavedMapPack = GameLevelManager::getSavedMapPack(v26, v27->m_mapPack);
if ( !SavedMapPack )
goto LABEL_32;
sub_D18D28(&v57, &SavedMapPack->m_packName);
v54 = v57;
v29 = strlen(v57);
sub_D1798C(a2, v54, v29);
v30 = v57 - 24;
if ( v57 - 24 == (char *)&qword_124B6B0 )
goto LABEL_32;
if ( &pthread_create )
{
v31 = (unsigned int *)(v57 - 8);
do
v32 = __ldaxr(v31);
while ( __stlxr(v32 - 1, v31) );
}
else
{
v32 = *((_DWORD *)v57 - 2);
*((_DWORD *)v57 - 2) = v32 - 1;
}
if ( v32 > 0 )
goto LABEL_32;
LABEL_75:
operator delete(v30);
v9 = this->m_searchObject;
break;
case Users:
sub_D1798C(a2, "Find Users", 10);
v9 = this->m_searchObject;
break;
case SmartTemplates:
sub_D1798C(a2, "Smart Templates", 15);
LABEL_32:
v9 = this->m_searchObject;
break;
default:
break;
}
sub_D18D28(&v60, &v9->m_searchQuery);
v10 = (__int64 *)(v60 - 24);
if ( *(_QWORD *)(v60 - 24)
&& (v11 = this->m_searchObject,
v12 = (unsigned int)(v11->m_searchType - 102) <= 1 || (unsigned int)(v11->m_searchType - 98) <= 2) )
{
if ( v10 == &qword_124B6B0 )
goto LABEL_24;
}
else
{
if ( v10 == &qword_124B6B0 )
return a2;
v12 = 0;
}
if ( &pthread_create )
{
v37 = (unsigned int *)(v60 - 8);
do
v38 = __ldaxr(v37);
while ( __stlxr(v38 - 1, v37) );
}
else
{
v38 = *(_DWORD *)(v60 - 8);
*(_DWORD *)(v60 - 8) = v38 - 1;
}
if ( v38 <= 0 )
operator delete(v10);
if ( v12 )
{
v11 = this->m_searchObject;
LABEL_24:
v19 = *a2;
*(_QWORD *)&v20 = sub_D18D28(&v61, &v11->m_searchQuery).n128_u64[0];
v21 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat((cocos2d::CCString *)"%s (%s)", v19, v61, v20);
v53 = cocos2d::CCString::getCString(v21);
v22 = strlen(v53);
sub_D1798C(a2, v53, v22);
v23 = (void *)(v61 - 24);
if ( (__int64 *)(v61 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v24 = (unsigned int *)(v61 - 8);
do
v25 = __ldaxr(v24);
while ( __stlxr(v25 - 1, v24) );
}
else
{
v25 = *(_DWORD *)(v61 - 8);
*(_DWORD *)(v61 - 8) = v25 - 1;
}
if ( v25 <= 0 )
operator delete(v23);
}
}
return a2;
}