//
// GJLevelList::getListLevelsArray from 0x1000b11cc to 0x1000b1408 (572 bytes)
//
// 2 xrefs:
// > GJLevelList::duplicateListLevels @ 0x1000b117c
// > LevelListLayer::updateResultArray @ 0x10024676c
//
// 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
//
cocos2d::CCArray *__fastcall GJLevelList::getListLevelsArray(GJLevelList *a1, cocos2d::CCArray *a2)
{
GJLevelList *v2; // x19
cocos2d::ccArray *data; // x9
__int64 num; // x8
cocos2d::CCObject **arr; // x21
unsigned __int64 v6; // x22
cocos2d::CCObject *v7; // x24
cocos2d::CCArray *v8; // x20
std::__vector_base::pointer begin; // x21
std::__vector_base::pointer end; // x26
int v11; // w27
GJGameLevel *v12; // x25
cocos2d::CCDictionary *m_levelsDict; // x23
GJGameLevel *ListSnapshot; // x24
GameLevelManager *v15; // x0
GJGameLevel *SavedLevel; // x24
cocos2d::CCDictionary *v17; // x23
GJGameLevel *v18; // x23
int v20; // w24
float v21; // s0
std::string __str; // [xsp+8h] [xbp-B8h] BYREF
void *__p[2]; // [xsp+20h] [xbp-A0h] BYREF
char v25; // [xsp+37h] [xbp-89h]
int v26; // [xsp+3Ch] [xbp-84h] BYREF
_QWORD v27[4]; // [xsp+40h] [xbp-80h] BYREF
int v28; // [xsp+60h] [xbp-60h]
v2 = a1;
memset(v27, 0, sizeof(v27));
v28 = 1065353216;
if ( a2 )
{
data = a2->data;
num = data->num;
if ( (_DWORD)num )
{
arr = data->arr;
v6 = (unsigned __int64)&arr[num - 1];
do
{
v7 = *arr;
if ( !*arr )
break;
v26 = v7[5].m_uOrderOfArrival - v7[5].m_unknown5;
__p[0] = &v26;
a1 = (GJLevelList *)sub_100019F24((unsigned __int64)v27, &v26, (__int64)&unk_1006369C3, (_DWORD **)__p);
*(_QWORD *)&a1->m_uAutoReleaseCount = v7;
++arr;
}
while ( (unsigned __int64)arr <= v6 );
}
}
v8 = (cocos2d::CCArray *)sub_10024A15C(a1);
begin = v2->m_levels.__begin_;
end = v2->m_levels.__end_;
if ( begin != end )
{
v11 = 1;
do
{
if ( sub_100018814(v27, begin) )
{
__p[0] = begin;
v12 = (GJGameLevel *)sub_100019F24((unsigned __int64)v27, begin, (__int64)&unk_1006369C3, (_DWORD **)__p)[3];
m_levelsDict = v2->m_levelsDict;
ListSnapshot = GJGameLevel::getListSnapshot(v12);
GameToolbox::intToString((unsigned int)(v12->m_levelID.random - v12->m_levelID.seed), __p);
cocos2d::CCDictionary::setObject_1(m_levelsDict, ListSnapshot, __p);
if ( v25 < 0 )
operator delete(__p[0]);
}
v15 = GameLevelManager::sharedState();
SavedLevel = GameLevelManager::getSavedLevel(v15, *begin);
v17 = v2->m_levelsDict;
GameToolbox::intToString((unsigned int)*begin, __p);
v18 = (GJGameLevel *)cocos2d::CCDictionary::objectForKey_1(v17, __p);
if ( v25 < 0 )
{
operator delete(__p[0]);
if ( !SavedLevel )
{
LABEL_20:
if ( !v18 )
{
v18 = GJGameLevel::create_1();
v20 = *begin;
v18->m_levelID.value = *begin;
v21 = vcvts_n_f32_s32(rand(), 0x1Fu) * 1000.0;
v18->m_levelID.seed = (int)v21;
v18->m_levelID.random = v20 + (int)v21;
GameToolbox::intToString((unsigned int)*begin, &__str);
std::string::operator=((std::string *)&v18->m_levelName, &__str);
if ( SHIBYTE(__str.__r_.__value_.__r.__words[2]) < 0 )
operator delete(__str.__r_.__value_.__l.__data_);
}
goto LABEL_23;
}
}
else if ( !SavedLevel )
{
goto LABEL_20;
}
if ( !SavedLevel->m_levelNotDownloaded || v18 == nullptr )
v18 = SavedLevel;
LABEL_23:
v18->m_listPosition = v11;
sub_10024A2D0(v8, v18);
++v11;
++begin;
}
while ( begin != end );
}
sub_100017A98((__int64)v27);
return v8;
}