//
// SetGroupIDLayer::determineStartValues from 0x1003154a0 to 0x100315840 (928 bytes)
//
// 2 xrefs:
// > SetGroupIDLayer::init @ 0x100313524
// > SetGroupIDLayer::onPaste @ 0x10031674a
//
// 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)
{
__int64 v1; // rsi
SetGroupIDLayer *v2; // r12
__int64 m_targetObjects; // r14
int v4; // eax
ZLayer v5; // ebx
bool v6; // r14
bool v7; // bl
unsigned int v8; // r15d
int m_pobTexture_high; // r13d
__int64 v10; // r12
int v11; // ecx
GameObject *v12; // rax
GameObject *v13; // r12
int v14; // edx
bool v15; // zf
ZLayer ObjectZLayer; // eax
int v17; // ecx
GameObject *m_targetObject; // rax
int m_editorLayer; // ebx
GameObject *v20; // rax
int m_editorLayer2; // ebx
GameObject *v22; // rdi
int ObjectZOrder; // r15d
unsigned int i; // r14d
int v25; // eax
unsigned int j; // r14d
int v27; // eax
int v28; // ebx
unsigned int v29; // r14d
GameObject *v30; // rax
__int64 v31; // [rsp+8h] [rbp-38h]
int x_low; // [rsp+10h] [rbp-30h]
int v33; // [rsp+14h] [rbp-2Ch]
v2 = a1;
a1->m_orderValue = 0;
a1->m_channelValue = 0;
*(_WORD *)&a1->m_hasTargetObjects = 0;
if ( a1->m_targetObject )
{
m_targetObjects = sub_10071F9E0(a1, v1);
sub_10071FCD0(m_targetObjects, a1->m_targetObject);
v4 = -100;
v5 = 0;
if ( m_targetObjects )
goto LABEL_3;
LABEL_28:
v6 = 0;
goto LABEL_37;
}
m_targetObjects = (__int64)a1->m_targetObjects;
v4 = -100;
v5 = 0;
if ( !m_targetObjects )
goto LABEL_28;
LABEL_3:
if ( !(unsigned int)sub_100720070(m_targetObjects) )
{
v6 = 0;
LABEL_36:
v4 = -100;
goto LABEL_37;
}
a1->m_hasTargetObjects = 1;
v31 = m_targetObjects;
if ( !(unsigned int)sub_100720070(m_targetObjects) )
{
v6 = 1;
goto LABEL_36;
}
v6 = 1;
v33 = -100;
v7 = 0;
v8 = 0;
x_low = -100;
m_pobTexture_high = -100;
v10 = v31;
do
{
v12 = (GameObject *)sub_1007200C0(v10, v8);
v13 = v12;
if ( v7 )
{
v7 = 1;
if ( !v6 )
goto LABEL_13;
LABEL_12:
v6 = GameObject::getCustomZLayer(v13) == 0;
goto LABEL_13;
}
ObjectZLayer = GameObject::getObjectZLayer(v12);
v17 = v33;
if ( v33 == -100 )
{
v7 = 0;
v33 = ObjectZLayer;
if ( v6 )
goto LABEL_12;
}
else
{
v7 = v33 != ObjectZLayer;
if ( v33 != ObjectZLayer )
v17 = -100;
v33 = v17;
if ( v6 )
goto LABEL_12;
}
LABEL_13:
if ( v13->m_classType == Effect )
{
a1->m_showChannelOrder = 1;
v14 = 0;
if ( m_pobTexture_high == HIDWORD(v13[1].m_pobTexture) )
v14 = m_pobTexture_high;
v15 = m_pobTexture_high == -100;
m_pobTexture_high = v14;
if ( v15 )
m_pobTexture_high = HIDWORD(v13[1].m_pobTexture);
v11 = x_low;
if ( x_low == -100 )
{
x_low = LODWORD(v13[1].m_obRect.origin.x);
}
else
{
if ( x_low != LODWORD(v13[1].m_obRect.origin.x) )
v11 = 0;
x_low = v11;
}
}
v10 = v31;
++v8;
}
while ( v8 < (unsigned int)sub_100720070(v31) );
v2 = a1;
if ( m_pobTexture_high != -100 )
a1->m_orderValue = m_pobTexture_high;
v5 = 0;
if ( x_low != -100 )
a1->m_channelValue = x_low;
v4 = v33;
LABEL_37:
if ( v4 != -100 )
v5 = v4;
if ( !v6 )
v5 = v4;
v2->m_zLayerValue = v5;
m_targetObject = v2->m_targetObject;
if ( m_targetObject )
{
m_editorLayer = m_targetObject->m_editorLayer;
goto LABEL_43;
}
m_editorLayer = -1;
if ( (unsigned int)sub_100720070(v2->m_targetObjects) )
{
for ( i = 0; i < (unsigned int)sub_100720070(v2->m_targetObjects); ++i )
{
v25 = *(__int16 *)(sub_1007200C0(v2->m_targetObjects, i) + 1202);
if ( m_editorLayer == -1 )
{
m_editorLayer = v25;
}
else if ( m_editorLayer != v25 )
{
m_editorLayer = -1;
break;
}
}
}
LABEL_43:
v2->m_editorLayerValue = m_editorLayer;
v20 = v2->m_targetObject;
if ( v20 )
{
m_editorLayer2 = v20->m_editorLayer2;
goto LABEL_45;
}
m_editorLayer2 = -1;
if ( (unsigned int)sub_100720070(v2->m_targetObjects) )
{
for ( j = 0; j < (unsigned int)sub_100720070(v2->m_targetObjects); ++j )
{
v27 = *(__int16 *)(sub_1007200C0(v2->m_targetObjects, j) + 1204);
if ( m_editorLayer2 == -1 )
{
m_editorLayer2 = v27;
}
else if ( m_editorLayer2 != v27 )
{
m_editorLayer2 = -1;
break;
}
}
}
LABEL_45:
v2->m_editorLayer2Value = m_editorLayer2;
v22 = v2->m_targetObject;
if ( v22 )
{
ObjectZOrder = GameObject::getObjectZOrder(v22);
}
else
{
if ( (unsigned int)sub_100720070(v2->m_targetObjects) )
{
v28 = -1000;
v29 = 0;
while ( 1 )
{
v30 = (GameObject *)sub_1007200C0(v2->m_targetObjects, v29);
ObjectZOrder = GameObject::getObjectZOrder(v30);
if ( v28 != -1000 )
{
v15 = v28 == ObjectZOrder;
ObjectZOrder = v28;
if ( !v15 )
break;
}
++v29;
v28 = ObjectZOrder;
if ( v29 >= (unsigned int)sub_100720070(v2->m_targetObjects) )
goto LABEL_67;
}
}
ObjectZOrder = -1000;
}
LABEL_67:
v2->m_zOrderValue = ObjectZOrder;
}