//
// PlayLayer::scanActiveSaveObjects from 0x5cfd88 to 0x5d0018 (656 bytes)
//
// 2 xrefs:
// > PlayLayer::setupHasCompleted @ 0x5dc2f8
// > ??> @ 0x42db0
//
// 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 PlayLayer::scanActiveSaveObjects(PlayLayer *a1)
{
cocos2d::CCArray *m_objects; // x21
cocos2d::ccArray *data; // x1
cocos2d::CCObject **arr; // x20
__int64 v4; // x23
char *v5; // x22
cocos2d::CCObject *v6; // x19
float *v7; // x23
bool *p_m_isPlatformer; // x25
char *v10; // x2
char *v11; // x2
GameObject **v12; // x0
signed __int64 v13; // x21
unsigned __int64 v14; // x1
unsigned __int64 v15; // x2
unsigned __int64 v16; // x27
char *v17; // x28
GameObject **m_start; // x0
signed __int64 v19; // x21
unsigned __int64 v20; // x1
unsigned __int64 v21; // x27
char *v22; // x28
unsigned __int64 v23; // x2
m_objects = a1->m_objects;
if ( m_objects )
{
data = m_objects->data;
if ( data->num )
{
arr = data->arr;
v4 = 8LL * data->num - 8;
v5 = (char *)arr + v4;
if ( arr <= (cocos2d::CCObject **)((char *)arr + v4) )
{
v6 = *arr;
if ( *arr )
{
v7 = &a1->m_varianceValues.__elems_[1975];
p_m_isPlatformer = &a1->m_isPlatformer;
while ( 1 )
{
if ( ((unsigned __int8 (__fastcall *)(cocos2d::CCObject *))v6->__vftable[20].~CCObject_0)(v6) )
{
if ( !((unsigned __int8 (__fastcall *)(cocos2d::CCObject *, bool))v6->__vftable[21].encodeWithCoder)(
v6,
*p_m_isPlatformer) )
{
v10 = *((char **)v7 + 254);
if ( v10 == *((char **)v7 + 255) )
{
m_start = a1->m_activeSaveObjects1.m_start;
v19 = v10 - (char *)m_start;
v20 = (v10 - (char *)m_start) >> 3;
if ( !v20 )
{
v21 = 8;
goto LABEL_34;
}
v23 = 2 * v20;
v21 = -8;
if ( v20 > 2 * v20 || v23 > 0x1FFFFFFFFFFFFFFFLL || (v21 = 16 * v20, v22 = nullptr, v23) )
{
LABEL_34:
v22 = (char *)operator new(v21);
m_start = a1->m_activeSaveObjects1.m_start;
v19 = (char *)a1->m_activeSaveObjects1.m_finish - (char *)m_start;
}
if ( &v22[v19] )
{
*(_QWORD *)&v22[v19] = v6;
m_start = *((GameObject ***)v7 + 253);
v19 = *((_QWORD *)v7 + 254) - (_QWORD)m_start;
}
if ( v19 >> 3 )
{
memmove(v22, m_start, v19);
m_start = *((GameObject ***)v7 + 253);
}
if ( m_start )
operator delete(m_start);
*((_QWORD *)v7 + 253) = v22;
*((_QWORD *)v7 + 254) = &v22[v19 + 8];
*((_QWORD *)v7 + 255) = &v22[v21];
goto LABEL_8;
}
if ( v10 )
{
*(_QWORD *)v10 = v6;
v10 = *((char **)v7 + 254);
}
*((_QWORD *)v7 + 254) = v10 + 8;
}
}
else if ( LODWORD(v6[22].__vftable) == 2 && LOBYTE(v6[26].m_uIndexInArray) )
{
v11 = *((char **)v7 + 257);
if ( v11 == *((char **)v7 + 258) )
{
v12 = a1->m_activeSaveObjects2.m_start;
v13 = v11 - (char *)v12;
v14 = (v11 - (char *)v12) >> 3;
if ( v14 )
{
v15 = 2 * v14;
v16 = -8;
if ( v14 > 2 * v14 || v15 > 0x1FFFFFFFFFFFFFFFLL || (v16 = 16 * v14, v17 = nullptr, v15) )
{
LABEL_23:
v17 = (char *)operator new(v16);
v12 = a1->m_activeSaveObjects2.m_start;
v13 = (char *)a1->m_activeSaveObjects2.m_finish - (char *)v12;
}
if ( &v17[v13] )
{
*(_QWORD *)&v17[v13] = v6;
v12 = *((GameObject ***)v7 + 256);
v13 = *((_QWORD *)v7 + 257) - (_QWORD)v12;
}
if ( v13 >> 3 )
{
memmove(v17, v12, v13);
v12 = *((GameObject ***)v7 + 256);
}
if ( v12 )
operator delete(v12);
*((_QWORD *)v7 + 256) = v17;
*((_QWORD *)v7 + 257) = &v17[v13 + 8];
*((_QWORD *)v7 + 258) = &v17[v16];
goto LABEL_8;
}
v16 = 8;
goto LABEL_23;
}
if ( v11 )
{
*(_QWORD *)v11 = v6;
v11 = *((char **)v7 + 257);
}
*((_QWORD *)v7 + 257) = v11 + 8;
}
LABEL_8:
if ( v5 >= (char *)++arr )
{
v6 = *arr;
if ( *arr )
continue;
}
return;
}
}
}
}
}
}