//
// SpawnTriggerGameObject::changeRemap from 0x771544 to 0x771864 (800 bytes)
//
// 3 xrefs:
// > EditorUI::replaceGroupID @ 0x68a744
// > EditorUI::replaceGroupID @ 0x68a768
// > ??> @ 0xa70b8
//
// 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 SpawnTriggerGameObject::changeRemap(SpawnTriggerGameObject *a1, int a2, int a3, bool a4)
{
ChanceObject *m_finish; // x19
ChanceObject *m_start; // x21
ChanceObject *v7; // x0
ChanceObject *v8; // x2
int *v9; // x28
int m_groupID; // w20
int m_chance; // w26
int *v12; // x0
int *v13; // x3
int v14; // w1
int v15; // w0
int *v16; // x19
int v17; // w1
bool v18; // cc
int *v19; // x0
int v20; // w2
__int64 v21; // x0
int v22; // w0
_BOOL4 v23; // w27
__int64 v24; // x0
int *v25; // x19
ChanceObject *v26; // x0
__int64 v27; // x1
ChanceObject *v28; // x1
__int64 v29; // x26
__int64 v30; // x27
int *v31; // x0
char v32[8]; // [xsp+68h] [xbp+68h] BYREF
int v33; // [xsp+70h] [xbp+70h] BYREF
int *v34; // [xsp+78h] [xbp+78h]
int *v35; // [xsp+80h] [xbp+80h]
int *v36; // [xsp+88h] [xbp+88h]
__int64 v37; // [xsp+90h] [xbp+90h]
m_finish = a1->m_remapObjects.m_finish;
m_start = a1->m_remapObjects.m_start;
if ( m_start == m_finish )
return;
v7 = a1->m_remapObjects.m_start;
do
{
if ( a4 )
{
if ( v7->m_groupID == a2 && v7->m_chance != a3 )
v7->m_groupID = a3;
}
else if ( v7->m_chance == a2 && v7->m_groupID != a3 )
{
v7->m_chance = a3;
}
++v7;
}
while ( m_finish != v7 );
v33 = 0;
v34 = nullptr;
v37 = 0;
v8 = m_finish;
v35 = &v33;
v9 = nullptr;
v36 = &v33;
do
{
m_groupID = m_start->m_groupID;
m_chance = m_start->m_chance;
if ( !v9 )
{
v16 = &v33;
if ( v35 == &v33 )
goto LABEL_53;
goto LABEL_46;
}
v12 = v9;
v13 = &v33;
do
{
while ( 1 )
{
v14 = v12[8];
if ( m_groupID > v14 || m_groupID >= v14 && m_chance > v12[9] )
break;
v13 = v12;
v12 = *((int **)v12 + 2);
if ( !v12 )
goto LABEL_13;
}
v12 = *((int **)v12 + 3);
}
while ( v12 );
LABEL_13:
if ( v13 == &v33 || (v15 = v13[8], m_groupID < v15) || m_groupID <= v15 && m_chance < v13[9] )
{
v16 = v9;
v17 = *(_DWORD *)((char *)&qword_20 + (_QWORD)v9);
v18 = m_groupID <= v17;
if ( m_groupID >= v17 )
goto LABEL_18;
LABEL_23:
while ( 1 )
{
v19 = *((int **)v16 + 2);
v20 = 1;
if ( !v19 )
break;
while ( 1 )
{
v16 = v19;
v17 = v19[8];
v18 = m_groupID <= v17;
if ( m_groupID < v17 )
break;
LABEL_18:
if ( v18 && m_chance < v16[9] )
goto LABEL_23;
v19 = *((int **)v16 + 3);
v20 = 0;
if ( !v19 )
goto LABEL_24;
}
}
LABEL_24:
v21 = (__int64)v16;
if ( !v20 )
{
LABEL_25:
if ( m_groupID <= v17 && (m_groupID < v17 || m_chance <= *(_DWORD *)(v21 + 36)) || !v16 )
{
v25 = v9;
goto LABEL_44;
}
LABEL_27:
if ( v16 != &v33 )
{
v22 = v16[8];
v23 = 1;
if ( m_groupID >= v22 )
{
v23 = 0;
if ( m_groupID <= v22 )
v23 = m_chance < v16[9];
}
goto LABEL_29;
}
LABEL_53:
v23 = 1;
LABEL_29:
v24 = operator new(0x28u);
*(_DWORD *)(v24 + 32) = m_groupID;
*(_DWORD *)(v24 + 36) = m_chance;
sub_CFAD74(v23, v24, v16, &v33);
v25 = v34;
++v37;
LABEL_44:
++m_start;
v8 = a1->m_remapObjects.m_finish;
goto LABEL_35;
}
if ( v35 == v16 )
goto LABEL_27;
LABEL_46:
v21 = sub_CFABD4(v16);
v17 = *(_DWORD *)(v21 + 32);
goto LABEL_25;
}
v26 = m_start + 1;
if ( v8 != &m_start[1] )
{
v27 = v8 - v26;
if ( v27 > 0 )
{
v28 = &m_start[v27 + 1];
do
{
v29 = *(_QWORD *)&v26->m_groupID;
v30 = *(_QWORD *)&v26->m_chance;
++v26;
*(_QWORD *)&v26[-2].m_groupID = v29;
*(_QWORD *)&v26[-2].m_chance = v30;
}
while ( v26 != v28 );
}
}
--v8;
v25 = v9;
a1->m_remapObjects.m_finish = v8;
LABEL_35:
v9 = v25;
}
while ( m_start != v8 );
while ( v25 )
{
std::_Rb_tree,std::pair,std::_Identity>,std::less>,std::allocator>>::_M_erase(
(__int64)&v32,
*((_QWORD **)v25 + 3));
v31 = v25;
v25 = *((int **)v25 + 2);
operator delete(v31);
}
}