//
// GameLevelManager::writeSpecialFilters from 0x6f5058 to 0x6f548c (1076 bytes)
//
// 3 xrefs:
// > GameLevelManager::getLevelLists @ 0x72b9c4
// > GameLevelManager::getOnlineLevels @ 0x72c144
// > ??> @ 0x2acd8
//
// 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
//
__int64 __usercall GameLevelManager::writeSpecialFilters@(
GameLevelManager *this@,
GJSearchObject *a2@,
__int64 a3@)
{
void *v5; // x0
GJDifficulty m_demonFilter; // w0
unsigned int v7; // w0
unsigned int v8; // w22
char *v9; // x0
GameLevelManager *v11; // x0
cocos2d::CCArray *v12; // x21
unsigned int v13; // w19
cocos2d::CCString *v14; // x0
unsigned int v15; // w22
void *v16; // x0
unsigned int *v17; // x1
int v18; // w2
size_t v19; // x0
char *v20; // x0
unsigned int *v21; // x19
int v22; // w1
unsigned int *v23; // x1
int v24; // w2
unsigned int *v25; // x1
int v26; // w2
char *v27; // [xsp+68h] [xbp+68h]
__int64 v28; // [xsp+80h] [xbp+80h] BYREF
char *v29; // [xsp+88h] [xbp+88h] BYREF
__int64 v30; // [xsp+90h] [xbp+90h] BYREF
sub_D153B8(a3, &byte_F288A0);
sub_D15FD4(a3, "&diff=", 6);
sub_D18D28(&v28, &a2->m_difficulty);
sub_D15E14(a3, &v28);
v5 = (void *)(v28 - 24);
if ( (__int64 *)(v28 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v23 = (unsigned int *)(v28 - 8);
do
v24 = __ldaxr(v23);
while ( __stlxr(v24 - 1, v23) );
}
else
{
v24 = *(_DWORD *)(v28 - 8);
*(_DWORD *)(v28 - 8) = v24 - 1;
}
if ( v24 <= 0 )
operator delete(v5);
}
if ( a2->m_starFilter )
{
sub_D15FD4(a3, "&star=1", 7);
}
else if ( a2->m_noStarFilter )
{
sub_D15FD4(a3, "&noStar=1", 9);
}
m_demonFilter = a2->m_demonFilter;
if ( m_demonFilter > Auto )
{
v7 = m_demonFilter - 6;
v8 = 0;
if ( v7 <= 4 )
v8 = dword_ECAEB0[v7];
sub_D15FD4(a3, "&demonFilter=", 13);
GameToolbox::intToString((__int64 *)&v29, (GameToolbox *)v8);
sub_D15E14(a3, &v29);
v9 = v29 - 24;
if ( v29 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v25 = (unsigned int *)(v29 - 8);
do
v26 = __ldaxr(v25);
while ( __stlxr(v26 - 1, v25) );
}
else
{
v26 = *((_DWORD *)v29 - 2);
*((_DWORD *)v29 - 2) = v26 - 1;
}
if ( v26 <= 0 )
operator delete(v9);
}
}
if ( a2->m_searchType == Followed )
{
sub_D153B8((int)&v29, &byte_F288A0);
v11 = GameLevelManager::sharedState();
v12 = cocos2d::CCDictionary::allKeys(v11->m_followedCreators);
v13 = 0;
while ( v13 < (unsigned int)cocos2d::CCArray::count(v12) )
{
v14 = cocos2d::CCArray::stringAtIndex(v12, v13);
v15 = cocos2d::CCString::intValue(v14);
if ( v13 )
sub_D15FD4(&v29, &byte_F804F8, 1);
GameToolbox::intToString(&v30, (GameToolbox *)v15);
sub_D15E14(&v29, &v30);
v16 = (void *)(v30 - 24);
if ( (__int64 *)(v30 - 24) == &qword_124B6B0 )
goto LABEL_17;
if ( &pthread_create )
{
v17 = (unsigned int *)(v30 - 8);
do
v18 = __ldaxr(v17);
while ( __stlxr(v18 - 1, v17) );
}
else
{
v18 = *(_DWORD *)(v30 - 8);
*(_DWORD *)(v30 - 8) = v18 - 1;
}
if ( v18 > 0 )
{
LABEL_17:
++v13;
}
else
{
++v13;
operator delete(v16);
}
}
sub_D15FD4(a3, "&followed=", 10);
v27 = v29;
v19 = strlen(v29);
sub_D15FD4(a3, v27, v19);
v20 = v29 - 24;
if ( v29 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v21 = (unsigned int *)(v29 - 8);
do
v22 = __ldaxr(v21);
while ( __stlxr(v22 - 1, v21) );
}
else
{
v22 = *((_DWORD *)v29 - 2);
*((_DWORD *)v29 - 2) = v22 - 1;
}
if ( v22 <= 0 )
operator delete(v20);
}
}
return a3;
}