//
// PlayLayer::processCreateObjectsFromSetup from 0x1001163a0 to 0x10011684c (1196 bytes)
//
// 2 xrefs:
// > LevelInfoLayer::loadLevelStep @ 0x10002a774
// > PlayLayer::init @ 0x100115f74
//
// 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::processCreateObjectsFromSetup(PlayLayer *a1)
{
unsigned __int64 v2; // x28
float v3; // s1
float v4; // s0
int m_objectsCreated; // w8
int v6; // w21
GJGameLevel *m_level; // x9
unsigned __int64 v8; // x20
__int64 v9; // x9
std::__vector_base::pointer begin; // x8
std::string *v11; // x22
std::string::size_type v12; // x0
std::string::size_type v13; // x23
std::size_t size; // x8
bool v15; // w27
std::string::size_type v16; // x24
std::string::size_type v17; // x25
char v18; // w26
std::string *v19; // x24
__int128 v20; // q0
void *v21; // x24
std::string::size_type v22; // x0
ParticleGameObject *v23; // x0
GameObject *v24; // x23
int m_objectID; // w8
__int128 v26; // q0
int m_mainColorKeyIndex; // w8
int v29; // w9
int m_detailColorKeyIndex; // w8
bool hasSecondaryColor; // w24
char v32; // w27
unsigned int m_nextColorKey; // w25
cocos2d::CCDictionary *m_colorKeyDict; // x26
__int64 v35; // x0
char v36; // w8
int v37; // w8
float v38; // s0
GJLevelType m_levelType; // [xsp+4h] [xbp-CCh]
bool m_lowDetailModeToggled; // [xsp+8h] [xbp-C8h]
unsigned int v41; // [xsp+Ch] [xbp-C4h]
void *__p[2]; // [xsp+10h] [xbp-C0h] BYREF
char *longStorage; // [xsp+20h] [xbp-B0h]
std::string v44; // [xsp+30h] [xbp-A0h] BYREF
std::vector v45; // [xsp+48h] [xbp-88h] BYREF
std::vector v46; // [xsp+60h] [xbp-70h] BYREF
std::allocator __a; // [xsp+7Fh] [xbp-51h] BYREF
memset(&v46, 0, sizeof(v46));
sub_10011BFA4(&v46, 601);
memset(&v45, 0, sizeof(v45));
sub_10000EC70(&v45, 0x259u);
v2 = 0xAAAAAAAAAAAAAAABLL * (((char *)a1->m_objectStrings.__end_ - (char *)a1->m_objectStrings.__begin_) >> 3);
v3 = (float)(v2 / 0x3E8) + 10.0;
v4 = (float)v2;
if ( v3 > 100.0 )
v3 = 100.0;
v41 = vcvtps_s32_f32(v4 / v3);
m_objectsCreated = a1->m_objectsCreated;
if ( v2 <= m_objectsCreated )
goto LABEL_64;
v6 = 0;
m_level = a1->m_level;
m_levelType = m_level->m_levelType;
m_lowDetailModeToggled = m_level->m_lowDetailModeToggled;
v8 = m_objectsCreated;
do
{
m_objectsCreated = a1->m_objectsCreated;
if ( (__int64)v8 >= (int)(m_objectsCreated + v41) )
goto LABEL_63;
v9 = 0;
begin = a1->m_objectStrings.__begin_;
do
v45.__begin_[v9++] = nullptr;
while ( v9 != 601 );
v11 = &begin[v8];
v12 = std::string::find((const std::string *)v11, 44, 0);
v13 = v12;
size = v11->m_data.m_short.shortStorage.__elems_[22];
if ( (size & 0x8000000000000000LL) != 0 )
size = v11->m_data.m_long.size;
if ( v12 != -1 )
{
v15 = 0;
v16 = 0;
v17 = (int)size;
v18 = 1;
while ( 1 )
{
if ( v16 != v17 )
{
if ( (v18 & 1) != 0 )
{
std::string::basic_string(&v44, (const std::string *)v11, v16, v13 - v16, &__a);
if ( SHIBYTE(v44.__r_.__value_.__r.__words[2]) < 0 )
{
v21 = (void *)v44.__r_.__value_.__r.__words[0];
v6 = atoi(v44.__r_.__value_.__l.__data_);
operator delete(v21);
}
else
{
v6 = atoi((const char *)&v44);
}
}
else if ( (unsigned int)(v6 - 1) <= 0x257 )
{
std::string::basic_string(&v44, (const std::string *)v11, v16, v13 - v16, &__a);
v19 = &v46.__begin_[v6];
if ( v19->m_data.m_short.shortStorage.__elems_[22] < 0 )
operator delete((void *)v19->m_data.m_long.capacitym1);
v20 = *(_OWORD *)&v44.__r_.__value_.__l.__data_;
v19->m_data.m_long.longStorage = (char *)v44.__r_.__value_.__r.__words[2];
*(_OWORD *)&v19->m_data.m_short.sizex2 = v20;
v45.__begin_[v6] = a1;
}
v18 ^= 1u;
}
if ( v15 )
break;
v16 = v13 + 1;
v22 = std::string::find((const std::string *)v11, 44, v13 + 1);
v15 = v22 == -1;
if ( v22 == -1 )
v13 = v17;
else
v13 = v22;
}
}
v23 = (ParticleGameObject *)GameObject::objectFromVector(&v46, &v45, a1, m_lowDetailModeToggled);
v24 = v23;
if ( !v23 )
goto LABEL_58;
m_objectID = v23->m_objectID;
if ( m_objectID == 2065 )
{
ParticleGameObject::updateParticleStruct(v23);
}
else if ( m_objectID == 31 )
{
if ( v11->m_data.m_short.shortStorage.__elems_[22] < 0 )
{
sub_1000097D0(__p, (void *)v11->m_data.m_long.capacitym1, v11->m_data.m_long.size);
}
else
{
v26 = *(_OWORD *)&v11->m_data.m_short.sizex2;
longStorage = v11->m_data.m_long.longStorage;
*(_OWORD *)__p = v26;
}
StartPosObject::loadSettingsFromString(v24, __p);
if ( SHIBYTE(longStorage) < 0 )
operator delete(__p[0]);
}
if ( ((unsigned int (__fastcall *)(GameObject *))v24->getType)(v24) == 22 && m_levelType != Main )
goto LABEL_58;
m_mainColorKeyIndex = v24->m_mainColorKeyIndex;
if ( m_mainColorKeyIndex <= 0 )
{
hasSecondaryColor = GameObject::hasSecondaryColor(v24);
v32 = 1;
while ( 1 )
{
GameObject::getColorKey(&v44, v24, v32 & 1, 0);
if ( cocos2d::CCDictionary::objectForKey_1(a1->m_colorKeyDict, &v44) )
{
m_nextColorKey = *(_DWORD *)(cocos2d::CCDictionary::objectForKey_1(a1->m_colorKeyDict, &v44) + 56);
if ( (v32 & 1) == 0 )
goto LABEL_50;
}
else
{
m_nextColorKey = a1->m_nextColorKey;
m_colorKeyDict = a1->m_colorKeyDict;
v35 = sub_10011C030(m_nextColorKey);
cocos2d::CCDictionary::setObject_1(m_colorKeyDict, v35, &v44);
++a1->m_nextColorKey;
if ( (v32 & 1) == 0 )
{
LABEL_50:
v24->m_detailColorKeyIndex = m_nextColorKey;
goto LABEL_51;
}
}
v24->m_mainColorKeyIndex = m_nextColorKey;
LABEL_51:
if ( SHIBYTE(v44.__r_.__value_.__r.__words[2]) < 0 )
operator delete(v44.__r_.__value_.__l.__data_);
v36 = hasSecondaryColor & v32;
v32 = 0;
if ( (v36 & 1) == 0 )
goto LABEL_54;
}
}
v29 = a1->m_nextColorKey;
if ( m_mainColorKeyIndex > v29 )
{
a1->m_nextColorKey = m_mainColorKeyIndex;
v29 = m_mainColorKeyIndex;
}
m_detailColorKeyIndex = v24->m_detailColorKeyIndex;
if ( m_detailColorKeyIndex > v29 )
a1->m_nextColorKey = m_detailColorKeyIndex;
LABEL_54:
if ( ((unsigned int (__fastcall *)(GameObject *))v24->getType)(v24) == 31 )
{
if ( (unsigned int)sub_10024A36C(a1->m_coinArray) > 2 )
goto LABEL_58;
sub_10024A2D0(a1->m_coinArray, v24);
}
PlayLayer::addObject(a1, v24);
LABEL_58:
if ( v11->m_data.m_short.shortStorage.__elems_[22] < 0 )
{
*(_BYTE *)v11->m_data.m_long.capacitym1 = 0;
v11->m_data.m_long.size = 0;
}
else
{
v11->m_data.m_short.sizex2 = 0;
v11->m_data.m_short.shortStorage.__elems_[22] = 0;
}
++v8;
}
while ( v2 > v8 );
m_objectsCreated = a1->m_objectsCreated;
LABEL_63:
v2 = 0xAAAAAAAAAAAAAAABLL * (((char *)a1->m_objectStrings.__end_ - (char *)a1->m_objectStrings.__begin_) >> 3);
v4 = (float)v2;
LABEL_64:
v37 = m_objectsCreated + v41;
a1->m_objectsCreated = v37;
v38 = (float)(v37 - 1) / v4;
if ( v38 > 1.0 )
v38 = 1.0;
a1->m_loadingProgress = v38;
if ( v2 <= v37 )
{
PlayLayer::createObjectsFromSetupFinished(a1);
a1->m_loadingProgress = 1.0;
PlayLayer::setupHasCompleted(a1);
}
if ( v45.__begin_ )
{
v45.__end_ = v45.__begin_;
operator delete(v45.__begin_);
}
v45.__begin_ = (std::__vector_base::pointer)&v46;
sub_1000177FC(&v45.__begin_);
}