From 7a1b8f1484d6b604a6e0b334eb0cbd52460e6bfa Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Tue, 27 Feb 2024 14:25:40 -0500 Subject: [PATCH] Match LegoGameState::DeleteState() --- .../legoomni/src/common/legogamestate.cpp | 24 +++++++------------ 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/LEGO1/lego/legoomni/src/common/legogamestate.cpp b/LEGO1/lego/legoomni/src/common/legogamestate.cpp index 80437bd4..28cb8683 100644 --- a/LEGO1/lego/legoomni/src/common/legogamestate.cpp +++ b/LEGO1/lego/legoomni/src/common/legogamestate.cpp @@ -254,25 +254,17 @@ MxResult LegoGameState::DeleteState() m_stateCount = 0; m_stateArray = NULL; - if (stateCount > 0) { - MxS32 count = stateCount; - LegoState** it = stateArray; - - do { - if (!(*it)->SetFlag() && (*it)->VTable0x14()) { - delete *it; - } - else { - RegisterState(*it); - *it = NULL; - } - - it++; - } while (--count); + for (MxS32 count = 0; count < stateCount; count++) { + if (!stateArray[count]->SetFlag() && stateArray[count]->VTable0x14()) { + delete stateArray[count]; + } + else { + RegisterState(stateArray[count]); + stateArray[count] = NULL; + } } delete[] stateArray; - return SUCCESS; }