Skip to content

Commit

Permalink
fix: use erase_if for map change timers
Browse files Browse the repository at this point in the history
  • Loading branch information
roflmuffin committed Dec 24, 2024
1 parent ec2e68c commit 2b80520
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions src/core/timer_system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 2b80520

Please sign in to comment.