From 2b80520150457ccbbf5aaba264a49c7a679a82ad Mon Sep 17 00:00:00 2001 From: Michael Wilson Date: Tue, 24 Dec 2024 15:35:52 +1000 Subject: [PATCH] fix: use erase_if for map change timers --- src/core/timer_system.cpp | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/src/core/timer_system.cpp b/src/core/timer_system.cpp index a945da96..9c7dba01 100644 --- a/src/core/timer_system.cpp +++ b/src/core/timer_system.cpp @@ -188,21 +188,17 @@ void TimerSystem::RunFrame() void TimerSystem::RemoveMapChangeTimers() { - for (auto timer : m_once_off_timers) - { - if (timer->m_flags & TIMER_FLAG_NO_MAPCHANGE) + auto isMapChangeTimer = [](timers::Timer* timer) { + bool shouldRemove = timer->m_flags & TIMER_FLAG_NO_MAPCHANGE; + if (shouldRemove) { - KillTimer(timer); + delete timer; } - } + return shouldRemove; + }; - for (auto timer : m_repeat_timers) - { - if (timer->m_flags & TIMER_FLAG_NO_MAPCHANGE) - { - KillTimer(timer); - } - } + std::erase_if(m_once_off_timers, isMapChangeTimer); + std::erase_if(m_repeat_timers, isMapChangeTimer); } timers::Timer* TimerSystem::CreateTimer(float interval, CallbackT callback, int flags)