//
// LevelListLayer::loadLevelsFinished from 0x10035f3a0 to 0x10035f5b0 (528 bytes)
//
// 2 xrefs:
// > sub_10035F5B0 @ 0x10035f5bc
// > ??> @ 0x100918660
//
// 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
//
void __fastcall LevelListLayer::loadLevelsFinished(LevelListLayer *a1, cocos2d::CCArray *a2, const char *a3, int a4)
{
__int128 v4; // xmm0
GJSearchObject *m_searchObject; // rax
int v8; // r13d
std::string *p_m_searchQuery; // rax
char *v10; // r12
int v11; // r15d
GameLevelManager *v12; // rax
GJLevelList *m_levelList; // rax
size_t v14; // rax
size_t v15; // r15
char *v16; // r12
size_t v17; // r13
char v18; // r15
char *v19; // r14
unsigned int sizex2; // eax
std::size_t size; // rax
std::array *p_shortStorage; // rdi
size_t v23; // rdx
char *v24; // rsi
bool v25; // zf
char v26; // r12
GameLevelManager *v27; // r14
const char *Key; // rax
char __dst[16]; // [rsp+10h] [rbp-40h] BYREF
char *longStorage; // [rsp+20h] [rbp-30h]
m_searchObject = a1->m_searchObject;
if ( !m_searchObject || m_searchObject->m_searchType != LevelListsOnClick )
goto LABEL_10;
v8 = a4;
if ( (m_searchObject->m_searchQuery.m_data.m_short.sizex2 & 1) != 0 )
{
sub_100006B70(
__dst,
m_searchObject->m_searchQuery.m_data.m_long.longStorage,
m_searchObject->m_searchQuery.m_data.m_long.size,
*(double *)&v4);
if ( (__dst[0] & 1) != 0 )
goto LABEL_5;
}
else
{
p_m_searchQuery = &m_searchObject->m_searchQuery;
longStorage = p_m_searchQuery->m_data.m_long.longStorage;
v4 = *(_OWORD *)&p_m_searchQuery->m_data.m_short.sizex2;
*(_OWORD *)__dst = *(_OWORD *)&p_m_searchQuery->m_data.m_short.sizex2;
if ( (__dst[0] & 1) != 0 )
{
LABEL_5:
v10 = longStorage;
v11 = atoi(longStorage);
operator delete(v10);
goto LABEL_8;
}
}
v11 = atoi(&__dst[1]);
LABEL_8:
v12 = GameLevelManager::sharedState();
GameLevelManager::markListAsDownloaded(v12, v11);
m_levelList = a1->m_levelList;
a4 = v8;
if ( v11 == m_levelList->m_listID )
m_levelList->m_onlineLevelsLoaded = 1;
LABEL_10:
if ( a4 != 1 )
{
LevelBrowserLayer::loadLevelsFinished(a1, a2, a3, a4);
return;
}
v14 = strlen(a3);
if ( v14 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100006BF0(*(double *)&v4);
v15 = v14;
if ( v14 >= 0x17 )
{
v17 = 26;
if ( (v14 | 7) != 0x17 )
v17 = (v14 | 7) + 1;
v16 = (char *)operator new(v17);
longStorage = v16;
*(_QWORD *)__dst = v17 + 1;
*(_QWORD *)&__dst[8] = v15;
}
else
{
__dst[0] = 2 * v14;
v16 = &__dst[1];
if ( !v14 )
goto LABEL_20;
}
memcpy(v16, a3, v15);
LABEL_20:
v16[v15] = 0;
v18 = __dst[0];
v19 = longStorage;
sizex2 = a1->m_searchKey2.m_data.m_short.sizex2;
if ( (sizex2 & 1) != 0 )
{
size = a1->m_searchKey2.m_data.m_long.size;
p_shortStorage = (std::array *)a1->m_searchKey2.m_data.m_long.longStorage;
}
else
{
size = sizex2 >> 1;
p_shortStorage = &a1->m_searchKey2.m_data.m_short.shortStorage;
}
v23 = (unsigned __int8)__dst[0] >> 1;
if ( (__dst[0] & 1) != 0 )
v23 = *(_QWORD *)&__dst[8];
v24 = &__dst[1];
if ( (__dst[0] & 1) != 0 )
v24 = longStorage;
v25 = v23 == size;
if ( v23 >= size )
v23 = size;
v26 = v25 & (memcmp(p_shortStorage, v24, v23) == 0);
if ( (v18 & 1) != 0 )
operator delete(v19);
if ( v26 )
{
LevelListLayer::updateStatsArt(a1);
v27 = GameLevelManager::sharedState();
Key = GJSearchObject::getKey(a1->m_searchObject);
GameLevelManager::resetTimerForKey(v27, Key);
LevelBrowserLayer::loadPage(a1, a1->m_searchObject);
}
}