diff options
author | Tycho <work.tycho+git@gmail.com> | 2014-01-17 19:07:33 +0100 |
---|---|---|
committer | Tycho <work.tycho+git@gmail.com> | 2014-01-17 19:07:33 +0100 |
commit | ce030bc7c9838a2c0c60b18a0e53bb40ff0fda26 (patch) | |
tree | 8da7f97bc253394e6aeec25e62973bbe494626d2 | |
parent | APIDump: Updated cPluginManager:GetAllPlugins(). (diff) | |
download | cuberite-ce030bc7c9838a2c0c60b18a0e53bb40ff0fda26.tar cuberite-ce030bc7c9838a2c0c60b18a0e53bb40ff0fda26.tar.gz cuberite-ce030bc7c9838a2c0c60b18a0e53bb40ff0fda26.tar.bz2 cuberite-ce030bc7c9838a2c0c60b18a0e53bb40ff0fda26.tar.lz cuberite-ce030bc7c9838a2c0c60b18a0e53bb40ff0fda26.tar.xz cuberite-ce030bc7c9838a2c0c60b18a0e53bb40ff0fda26.tar.zst cuberite-ce030bc7c9838a2c0c60b18a0e53bb40ff0fda26.zip |
Diffstat (limited to '')
-rw-r--r-- | src/World.cpp | 10 | ||||
-rw-r--r-- | src/World.h | 3 |
2 files changed, 8 insertions, 5 deletions
diff --git a/src/World.cpp b/src/World.cpp index edf27050d..e4c03699f 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -875,10 +875,6 @@ void cWorld::TickScheduledTasks() Tasks.push_back(m_ScheduledTasks.front()); m_ScheduledTasks.pop_front(); } - for(;itr != m_ScheduledTasks.end(); itr++) - { - (*itr)->Ticks--; - } } // Execute and delete each task: @@ -887,6 +883,9 @@ void cWorld::TickScheduledTasks() (*itr)->Run(*this); delete *itr; } // for itr - m_Tasks[] + + // Increment TickID + m_TickID = (m_TickID+1) &0xFFFF; } @@ -2623,10 +2622,11 @@ void cWorld::QueueTask(cTask * a_Task) void cWorld::ScheduleTask(cScheduledTask * a_Task) { + a_Task->Ticks = (a_Task->Ticks + m_TickID) & 0xFFFF; cCSLock Lock(m_CSScheduledTasks); for(ScheduledTaskList::iterator itr = m_ScheduledTasks.begin(); itr != m_ScheduledTasks.end(); itr++) { - if((*itr)->Ticks >= a_Task->Ticks) + if((*itr)->Ticks >= a_Task->Ticks && (a_Task->Ticks > m_TickID || (*itr)->Ticks < m_TickID)) { m_ScheduledTasks.insert(itr, a_Task); return; diff --git a/src/World.h b/src/World.h index 1ecf41507..2fd7319cf 100644 --- a/src/World.h +++ b/src/World.h @@ -772,6 +772,9 @@ private: /// the future; guarded by m_CSScheduledTasks ScheduledTaskList m_ScheduledTasks; + /// Current Tick number for sceduled tasks + int m_TickID; + /// Guards m_Clients cCriticalSection m_CSClients; |