From 84056c6ea2142e260ee3dfaabddb90cba5e5c658 Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Sun, 24 Dec 2023 11:48:40 -0500 Subject: [PATCH] Improve MxTickleManager::Tickle code gneeration --- LEGO1/mxticklemanager.cpp | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/LEGO1/mxticklemanager.cpp b/LEGO1/mxticklemanager.cpp index 28a6c141..29f8428c 100644 --- a/LEGO1/mxticklemanager.cpp +++ b/LEGO1/mxticklemanager.cpp @@ -29,30 +29,29 @@ MxTickleManager::~MxTickleManager() } } -// TODO: Match. // FUNCTION: LEGO1 0x100bdde0 MxResult MxTickleManager::Tickle() { MxTime time = Timer()->GetTime(); - MxTickleClientPtrList::iterator it = m_clients.begin(); - - while (it != m_clients.end()) { + for (MxTickleClientPtrList::iterator it = m_clients.begin(); it != m_clients.end();) { MxTickleClient* client = *it; - if ((client->GetFlags() & TICKLE_MANAGER_FLAG_DESTROY) == 0) { - if (client->GetLastUpdateTime() >= time) + + // TODO: Match. + if ((MxU8) client->GetFlags() & TICKLE_MANAGER_FLAG_DESTROY) { + m_clients.erase(it++); + delete client; + } + else { + it++; + + if (client->GetLastUpdateTime() > time) client->SetLastUpdateTime(-client->GetTickleInterval()); if ((client->GetTickleInterval() + client->GetLastUpdateTime()) < time) { client->GetClient()->Tickle(); client->SetLastUpdateTime(time); } - - it++; - } - else { - m_clients.erase(it++); - delete client; } }