Match Act3List::FUN_100720d0 (#1622)

This commit is contained in:
jonschz
2025-07-13 16:50:20 +02:00
committed by GitHub
parent 00a4861914
commit 657720c825
2 changed files with 45 additions and 32 deletions

View File

@@ -47,7 +47,7 @@ public:
void Insert(MxS32 p_objectId, InsertMode p_option); void Insert(MxS32 p_objectId, InsertMode p_option);
void DeleteActionWrapper(); void DeleteActionWrapper();
void Clear(); void Clear();
void FUN_100720d0(MxU32 p_objectId); void RemoveByObjectIdOrFirst(MxU32 p_objectId);
private: private:
undefined4 m_unk0x0c; // 0x0c undefined4 m_unk0x0c; // 0x0c

View File

@@ -172,18 +172,33 @@ void Act3List::Clear()
} }
} }
// Removes the element with the given objectId from the list, or the first if `p_objectId` is zero.
// FUNCTION: LEGO1 0x100720d0 // FUNCTION: LEGO1 0x100720d0
void Act3List::FUN_100720d0(MxU32 p_objectId) void Act3List::RemoveByObjectIdOrFirst(MxU32 p_objectId)
{ {
if (m_unk0x0c) { if (m_unk0x0c) {
return; return;
} }
MxU32 removed = FALSE; MxU32 removed = FALSE;
Act3List::iterator it;
// This iterator appears to be unnecessary - maybe left in by accident, or it was used for assertions.
// Removing it decreases the match percentage.
Act3List::iterator unusedIterator;
if (empty()) {
return;
}
if (!p_objectId) {
pop_front();
removed = TRUE;
}
else {
for (it = begin(); it != end(); it++) {
// Removing this variable decreases the match, but replacing `*it` by `unused` below also does.
Act3ListElement& unused = *it;
if (!empty()) {
if (p_objectId != 0) {
for (Act3List::iterator it = begin(); it != end(); it++) {
if ((*it).m_hasStarted && (*it).m_objectId == p_objectId) { if ((*it).m_hasStarted && (*it).m_objectId == p_objectId) {
erase(it); erase(it);
removed = TRUE; removed = TRUE;
@@ -191,26 +206,25 @@ void Act3List::FUN_100720d0(MxU32 p_objectId)
} }
} }
} }
else {
pop_front();
removed = TRUE;
}
if (removed && size() > 0) { if (removed && size() > 0) {
Act3List::iterator it = begin(); it = begin();
Act3ListElement& firstItem = *(it++); unusedIterator = it;
Act3ListElement& firstItem = front();
it++;
for (; it != end(); it++) { while (it != end()) {
if ((*it).m_unk0x04 == 1) { if ((*it).m_unk0x04 == 1) {
for (Act3List::iterator it2 = begin(); it2 != it;) { for (Act3List::iterator it2 = begin(); it2 != it; erase(it2++)) {
if ((*it2).m_hasStarted) { if ((*it2).m_hasStarted) {
DeleteActionWrapper(); DeleteActionWrapper();
return; return;
} }
}
}
it2 = erase(it2); it++;
} unusedIterator++;
}
} }
if (!firstItem.m_hasStarted) { if (!firstItem.m_hasStarted) {
@@ -218,7 +232,6 @@ void Act3List::FUN_100720d0(MxU32 p_objectId)
InvokeAction(Extra::e_start, *g_act3Script, firstItem.m_objectId, NULL); InvokeAction(Extra::e_start, *g_act3Script, firstItem.m_objectId, NULL);
} }
} }
}
} }
// FUNCTION: LEGO1 0x10072270 // FUNCTION: LEGO1 0x10072270
@@ -613,7 +626,7 @@ MxLong Act3::Notify(MxParam& p_param)
} while (length < (MxS32) sizeOfArray(m_helicopterDots)); } while (length < (MxS32) sizeOfArray(m_helicopterDots));
} }
else { else {
m_unk0x4220.FUN_100720d0(param.GetAction()->GetObjectId()); m_unk0x4220.RemoveByObjectIdOrFirst(param.GetAction()->GetObjectId());
} }
} }
break; break;
@@ -633,7 +646,7 @@ MxLong Act3::Notify(MxParam& p_param)
case c_notificationEndAnim: case c_notificationEndAnim:
if (m_state->m_unk0x08 == 1) { if (m_state->m_unk0x08 == 1) {
assert(m_copter && m_brickster && m_cop1 && m_cop2); assert(m_copter && m_brickster && m_cop1 && m_cop2);
m_unk0x4220.FUN_100720d0(0); m_unk0x4220.RemoveByObjectIdOrFirst(0);
m_state->m_unk0x08 = 0; m_state->m_unk0x08 = 0;
Disable(TRUE, LegoOmni::c_disableInput | LegoOmni::c_disable3d | LegoOmni::c_clearScreen); Disable(TRUE, LegoOmni::c_disableInput | LegoOmni::c_disable3d | LegoOmni::c_clearScreen);
m_copter->HandleClick(); m_copter->HandleClick();