//
// SetGroupIDLayer::determineStartValues from 0x10003d608 to 0x10003d8e4 (732 bytes)
//
// 2 xrefs:
// > SetGroupIDLayer::init @ 0x10003bd6c
// > SetGroupIDLayer::onPaste @ 0x10003e3b4
//
// 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 SetGroupIDLayer::determineStartValues(SetGroupIDLayer *a1)
{
cocos2d::CCArray *m_targetObjects; // x20
bool v3; // w26
__int64 v4; // x21
bool v5; // w24
int v6; // w23
int x_low; // w27
int m_pobTexture_high; // w28
GameObject *v9; // x0
GameObject *v10; // x22
ZLayer ObjectZLayer; // w0
int v12; // w9
int v13; // w9
int v14; // w9
ZLayer v15; // w8
GameObject *m_targetObject; // x8
int m_editorLayer; // w21
__int64 v18; // x20
__int64 v19; // x0
GameObject *v20; // x8
int m_editorLayer2; // w21
__int64 v22; // x20
__int64 v23; // x0
GameObject *v24; // x0
__int64 v25; // x21
__int64 v26; // x20
__int64 v27; // x22
GameObject *v28; // x0
__int64 ObjectZOrder; // x0
a1->m_orderValue = 0;
a1->m_channelValue = 0;
*(_WORD *)&a1->m_hasTargetObjects = 0;
if ( a1->m_targetObject )
{
m_targetObjects = (cocos2d::CCArray *)sub_10024A15C(a1);
sub_10024A2D0(m_targetObjects, a1->m_targetObject);
if ( !m_targetObjects )
goto LABEL_40;
}
else
{
m_targetObjects = a1->m_targetObjects;
if ( !m_targetObjects )
{
LABEL_40:
v5 = 0;
LABEL_41:
v6 = -100;
goto LABEL_42;
}
}
if ( !(unsigned int)sub_10024A36C(m_targetObjects) )
goto LABEL_40;
a1->m_hasTargetObjects = 1;
if ( !(unsigned int)sub_10024A36C(m_targetObjects) )
{
v5 = 1;
goto LABEL_41;
}
v3 = 0;
v4 = 0;
v5 = 1;
v6 = -100;
x_low = -100;
m_pobTexture_high = -100;
do
{
v9 = (GameObject *)sub_10024A388(m_targetObjects, v4);
v10 = v9;
if ( v3 )
{
v3 = 1;
if ( !v5 )
goto LABEL_10;
}
else
{
ObjectZLayer = GameObject::getObjectZLayer(v9);
if ( v6 == ObjectZLayer )
v12 = v6;
else
v12 = -100;
v3 = v6 != -100 && v6 != ObjectZLayer;
if ( v6 == -100 )
v6 = ObjectZLayer;
else
v6 = v12;
if ( !v5 )
{
LABEL_10:
v5 = 0;
goto LABEL_22;
}
}
v5 = GameObject::getCustomZLayer(v10) == 0;
LABEL_22:
if ( v10->m_classType == Effect )
{
a1->m_showChannelOrder = 1;
if ( m_pobTexture_high == HIDWORD(v10[1].m_pobTexture) )
v13 = m_pobTexture_high;
else
v13 = 0;
if ( m_pobTexture_high == -100 )
m_pobTexture_high = HIDWORD(v10[1].m_pobTexture);
else
m_pobTexture_high = v13;
if ( x_low == LODWORD(v10[1].m_obRect.origin.x) )
v14 = x_low;
else
v14 = 0;
if ( x_low == -100 )
x_low = LODWORD(v10[1].m_obRect.origin.x);
else
x_low = v14;
}
v4 = (unsigned int)(v4 + 1);
}
while ( (unsigned int)v4 < (unsigned int)sub_10024A36C(m_targetObjects) );
if ( m_pobTexture_high != -100 )
a1->m_orderValue = m_pobTexture_high;
if ( x_low != -100 )
a1->m_channelValue = x_low;
LABEL_42:
if ( v5 && v6 == -100 )
v15 = 0;
else
v15 = v6;
a1->m_zLayerValue = v15;
m_targetObject = a1->m_targetObject;
if ( m_targetObject )
{
m_editorLayer = m_targetObject->m_editorLayer;
}
else if ( (unsigned int)sub_10024A36C(a1->m_targetObjects) )
{
v18 = 0;
m_editorLayer = -1;
do
{
v19 = sub_10024A388(a1->m_targetObjects, v18);
if ( m_editorLayer == -1 )
{
m_editorLayer = *(__int16 *)(v19 + 1202);
}
else if ( m_editorLayer != *(__int16 *)(v19 + 1202) )
{
goto LABEL_55;
}
v18 = (unsigned int)(v18 + 1);
}
while ( (unsigned int)v18 < (unsigned int)sub_10024A36C(a1->m_targetObjects) );
}
else
{
LABEL_55:
m_editorLayer = -1;
}
a1->m_editorLayerValue = m_editorLayer;
v20 = a1->m_targetObject;
if ( v20 )
{
m_editorLayer2 = v20->m_editorLayer2;
}
else if ( (unsigned int)sub_10024A36C(a1->m_targetObjects) )
{
v22 = 0;
m_editorLayer2 = -1;
do
{
v23 = sub_10024A388(a1->m_targetObjects, v22);
if ( m_editorLayer2 == -1 )
{
m_editorLayer2 = *(__int16 *)(v23 + 1204);
}
else if ( m_editorLayer2 != *(__int16 *)(v23 + 1204) )
{
goto LABEL_66;
}
v22 = (unsigned int)(v22 + 1);
}
while ( (unsigned int)v22 < (unsigned int)sub_10024A36C(a1->m_targetObjects) );
}
else
{
LABEL_66:
m_editorLayer2 = -1;
}
a1->m_editorLayer2Value = m_editorLayer2;
v24 = a1->m_targetObject;
if ( v24 )
{
LODWORD(v25) = GameObject::getObjectZOrder(v24);
}
else
{
if ( (unsigned int)sub_10024A36C(a1->m_targetObjects) )
{
v26 = 0;
v27 = 4294966296LL;
while ( 1 )
{
v28 = (GameObject *)sub_10024A388(a1->m_targetObjects, v26);
ObjectZOrder = GameObject::getObjectZOrder(v28);
v25 = ObjectZOrder;
if ( (_DWORD)v27 != -1000 )
{
v25 = v27;
if ( (_DWORD)v27 != (_DWORD)ObjectZOrder )
break;
}
v26 = (unsigned int)(v26 + 1);
v27 = v25;
if ( (unsigned int)v26 >= (unsigned int)sub_10024A36C(a1->m_targetObjects) )
goto LABEL_76;
}
}
LODWORD(v25) = -1000;
}
LABEL_76:
a1->m_zOrderValue = v25;
}