diff options
Diffstat (limited to '')
-rw-r--r-- | src/World.cpp | 10 |
1 files changed, 5 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; |