//
// PlayLayer::scanDynamicSaveObjects from 0x1001176ec to 0x100117a2c (832 bytes)
//
// 1 xrefs:
// > PlayLayer::setupHasCompleted @ 0x100116918
//
// 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 PlayLayer::scanDynamicSaveObjects(PlayLayer *a1)
{
cocos2d::CCArray *m_objects; // x8
cocos2d::ccArray *data; // x9
__int64 num; // x8
cocos2d::CCObject **arr; // x21
unsigned __int64 v6; // x22
cocos2d::CCObject *v7; // x25
int m_uReference; // w8
bool v9; // zf
std::__tree::__iter_pointer begin_node; // x23
cocos2d::CCArray *Group; // x0
cocos2d::ccArray *v12; // x9
__int64 v13; // x8
cocos2d::CCObject **v14; // x24
unsigned __int64 v15; // x25
cocos2d::CCObject *v16; // x8
std::set *left; // x9
std::set *v18; // x8
int v19; // w0
__int64 v20; // x20
int v21; // w24
__int64 v22; // x23
__int64 v23; // x22
__int64 v24; // x21
unsigned int *v25; // x9
__int64 v26; // x8
cocos2d::CCObject **v27; // x23
unsigned __int64 v28; // x27
cocos2d::CCObject *v29; // x8
unsigned int *v30; // x9
__int64 v31; // x8
cocos2d::CCObject **v32; // x22
unsigned __int64 v33; // x23
cocos2d::CCObject *v34; // x8
__int64 v35; // x21
__int64 v36; // x8
unsigned int *v37; // x9
__int64 v38; // x8
cocos2d::CCObject **v39; // x22
unsigned __int64 v40; // x23
cocos2d::CCObject *v41; // x8
cocos2d::CCObject *v42; // [xsp+0h] [xbp-70h] BYREF
std::set v43; // [xsp+8h] [xbp-68h] BYREF
v43.__tree_.__pair1_.__value_.__left_ = nullptr;
v43.__tree_.__pair3_.__value_ = 0;
v43.__tree_.__begin_node_ = &v43.__tree_.__pair1_.__value_;
m_objects = a1->m_objects;
if ( m_objects )
{
data = m_objects->data;
num = data->num;
if ( (_DWORD)num )
{
arr = data->arr;
v6 = (unsigned __int64)&arr[num - 1];
while ( 1 )
{
v7 = *arr;
if ( !*arr )
goto LABEL_20;
m_uReference = v7[18].m_uReference;
if ( m_uReference > 2066 )
break;
switch ( m_uReference )
{
case 1346:
goto LABEL_16;
case 1347:
LODWORD(v42) = v7[26].m_nLuaID;
sub_1000B4D20((__int64)&v43, (int *)&v42, &v42);
break;
case 1814:
goto LABEL_16;
}
LABEL_17:
if ( (unsigned __int64)++arr > v6 )
goto LABEL_20;
}
v9 = (unsigned int)(m_uReference - 3016) > 0x11 || ((1 << (m_uReference + 56)) & 0x30001) == 0;
if ( v9 && m_uReference != 2067 )
goto LABEL_17;
LABEL_16:
LODWORD(v42) = v7[26].m_uID;
sub_1000B4D20((__int64)&v43, (int *)&v42, &v42);
LODWORD(v42) = v7[26].m_nLuaID;
sub_1000B4D20((__int64)&v43, (int *)&v42, &v42);
goto LABEL_17;
}
}
LABEL_20:
GJBaseGameLayer::addRemapTargets(a1, &v43);
begin_node = v43.__tree_.__begin_node_;
if ( (std::__compressed_pair *>> *)v43.__tree_.__begin_node_ != &v43.__tree_.__pair1_ )
{
do
{
Group = GJBaseGameLayer::getGroup(a1, HIDWORD(begin_node[3].__left_));
if ( Group )
{
v12 = Group->data;
v13 = v12->num;
if ( (_DWORD)v13 )
{
v14 = v12->arr;
v15 = (unsigned __int64)&v14[v13 - 1];
do
{
v16 = *v14;
if ( !*v14 )
break;
v42 = *v14;
if ( ((__int64)v16[24].__vftable & 1) == 0 )
{
LOBYTE(v16[24].__vftable) = 1;
sub_1000115B8((__int64)&a1->m_dynamicSaveObjects, &v42);
}
++v14;
}
while ( (unsigned __int64)v14 <= v15 );
}
}
left = (std::set *)begin_node[1].__left_;
if ( left )
{
do
{
v18 = left;
left = (std::set *)left->__tree_.__begin_node_;
}
while ( left );
}
else
{
do
{
v18 = (std::set *)begin_node[2].__left_;
v9 = v18->__tree_.__begin_node_ == begin_node;
begin_node = (std::__tree::__iter_pointer)v18;
}
while ( !v9 );
}
begin_node = (std::__tree::__iter_pointer)v18;
}
while ( v18 != (std::set *)&v43.__tree_.__pair1_ );
}
v19 = sub_10024A36C(a1->m_targetGroupsArray);
if ( v19 >= 3 )
{
v20 = 0;
v21 = v19 - 2;
do
{
v22 = sub_10024A388(a1->m_targetGroupsArray, v20);
v23 = sub_10024A388(a1->m_targetGroupsArray, (unsigned int)v20 | 1);
v24 = sub_10024A388(a1->m_targetGroupsArray, (unsigned int)v20 | 2);
if ( v22 )
{
v25 = *(unsigned int **)(v22 + 56);
v26 = *v25;
if ( (_DWORD)v26 )
{
v27 = *((cocos2d::CCObject ***)v25 + 2);
v28 = (unsigned __int64)&v27[v26 - 1];
do
{
v29 = *v27;
if ( !*v27 )
break;
v42 = *v27;
if ( ((__int64)v29[24].__vftable & 1) == 0 )
{
LOBYTE(v29[24].__vftable) = 1;
sub_1000115B8((__int64)&a1->m_dynamicSaveObjects, &v42);
}
++v27;
}
while ( (unsigned __int64)v27 <= v28 );
}
}
if ( v23 )
{
v30 = *(unsigned int **)(v23 + 56);
v31 = *v30;
if ( (_DWORD)v31 )
{
v32 = *((cocos2d::CCObject ***)v30 + 2);
v33 = (unsigned __int64)&v32[v31 - 1];
do
{
v34 = *v32;
if ( !*v32 )
break;
v42 = *v32;
if ( ((__int64)v34[24].__vftable & 1) == 0 )
{
LOBYTE(v34[24].__vftable) = 1;
sub_1000115B8((__int64)&a1->m_dynamicSaveObjects, &v42);
}
++v32;
}
while ( (unsigned __int64)v32 <= v33 );
}
}
if ( v24 )
{
v35 = *(_QWORD *)(v24 + 56);
while ( v35 )
{
v36 = *(_QWORD *)(v35 + 264);
v35 = *(_QWORD *)(v35 + 288);
if ( v36 )
{
v37 = *(unsigned int **)(v36 + 56);
v38 = *v37;
if ( (_DWORD)v38 )
{
v39 = *((cocos2d::CCObject ***)v37 + 2);
v40 = (unsigned __int64)&v39[v38 - 1];
do
{
v41 = *v39;
if ( !*v39 )
break;
v42 = *v39;
if ( ((__int64)v41[24].__vftable & 1) == 0 )
{
LOBYTE(v41[24].__vftable) = 1;
sub_1000115B8((__int64)&a1->m_dynamicSaveObjects, &v42);
}
++v39;
}
while ( (unsigned __int64)v39 <= v40 );
}
}
}
}
v20 = (unsigned int)(v20 + 4);
}
while ( (int)v20 < v21 );
}
sub_100017D70((__int64)&v43, (_QWORD *)v43.__tree_.__pair1_.__value_.__left_);
}