summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2014-10-13 14:49:18 +0200
committerMattes D <github@xoft.cz>2014-10-13 14:49:18 +0200
commit7f8118e0cbcea2b54b7c14119626772c88e42d94 (patch)
tree36f6861fb0390f3a543dde56a9825d795f150778 /src
parentFixed style. (diff)
downloadcuberite-7f8118e0cbcea2b54b7c14119626772c88e42d94.tar
cuberite-7f8118e0cbcea2b54b7c14119626772c88e42d94.tar.gz
cuberite-7f8118e0cbcea2b54b7c14119626772c88e42d94.tar.bz2
cuberite-7f8118e0cbcea2b54b7c14119626772c88e42d94.tar.lz
cuberite-7f8118e0cbcea2b54b7c14119626772c88e42d94.tar.xz
cuberite-7f8118e0cbcea2b54b7c14119626772c88e42d94.tar.zst
cuberite-7f8118e0cbcea2b54b7c14119626772c88e42d94.zip
Diffstat (limited to '')
-rw-r--r--src/World.cpp27
1 files changed, 18 insertions, 9 deletions
diff --git a/src/World.cpp b/src/World.cpp
index d147b1c84..96afb8cc8 100644
--- a/src/World.cpp
+++ b/src/World.cpp
@@ -1068,15 +1068,24 @@ void cWorld::TickScheduledTasks(void)
{
cCSLock Lock(m_CSScheduledTasks);
auto WorldAge = m_WorldAge;
- std::move(
- m_ScheduledTasks.begin(),
- std::find_if(
- m_ScheduledTasks.begin(),
- m_ScheduledTasks.end(),
- [WorldAge] (cScheduledTaskPtr & Task) { return (Task->m_TargetTick < WorldAge);}
- ),
- std::back_inserter(Tasks)
- );
+
+ // Move all the due tasks from m_ScheduledTasks into Tasks:
+ for (auto itr = m_ScheduledTasks.begin(); itr != m_ScheduledTasks.end();) // Cannot use range-basd for, we're modifying the container
+ {
+ if ((*itr)->m_TargetTick < WorldAge)
+ {
+ auto next = itr;
+ ++next;
+ Tasks.push_back(std::move(*itr));
+ m_ScheduledTasks.erase(itr);
+ itr = next;
+ }
+ else
+ {
+ // All the eligible tasks have been moved, bail out now
+ break;
+ }
+ }
}
// Execute and delete each task: