summaryrefslogtreecommitdiffstats
path: root/src/World.cpp
diff options
context:
space:
mode:
authorTycho <work.tycho+git@gmail.com>2014-01-20 18:21:47 +0100
committerTycho <work.tycho+git@gmail.com>2014-01-20 18:21:47 +0100
commit16375f6aad355333d1d3aff6140cdb4439a9b62f (patch)
treeeb4192092b928e90aebaf914288d12c9cafaf5a5 /src/World.cpp
parentAdded Inifile and OSSupport Linking (diff)
parentAPIDump: Added notes about objects across cWorld's task execution. (diff)
downloadcuberite-16375f6aad355333d1d3aff6140cdb4439a9b62f.tar
cuberite-16375f6aad355333d1d3aff6140cdb4439a9b62f.tar.gz
cuberite-16375f6aad355333d1d3aff6140cdb4439a9b62f.tar.bz2
cuberite-16375f6aad355333d1d3aff6140cdb4439a9b62f.tar.lz
cuberite-16375f6aad355333d1d3aff6140cdb4439a9b62f.tar.xz
cuberite-16375f6aad355333d1d3aff6140cdb4439a9b62f.tar.zst
cuberite-16375f6aad355333d1d3aff6140cdb4439a9b62f.zip
Diffstat (limited to 'src/World.cpp')
-rw-r--r--src/World.cpp48
1 files changed, 30 insertions, 18 deletions
diff --git a/src/World.cpp b/src/World.cpp
index 3e7c0ef74..5e9f4a38a 100644
--- a/src/World.cpp
+++ b/src/World.cpp
@@ -865,28 +865,27 @@ void cWorld::TickQueuedTasks(void)
} // for itr - m_Tasks[]
}
-void cWorld::TickScheduledTasks()
+
+
+
+
+void cWorld::TickScheduledTasks(void)
{
- ScheduledTaskList Tasks;
// Make a copy of the tasks to avoid deadlocks on accessing m_Tasks
+ cScheduledTasks Tasks;
{
cCSLock Lock(m_CSScheduledTasks);
- ScheduledTaskList::iterator itr = m_ScheduledTasks.begin();
- while (itr != m_ScheduledTasks.end() && (*itr)->Ticks > 0)
+ while (!m_ScheduledTasks.empty() && (m_ScheduledTasks.front()->m_TargetTick < m_WorldAge))
{
Tasks.push_back(m_ScheduledTasks.front());
m_ScheduledTasks.pop_front();
}
- for(;itr != m_ScheduledTasks.end(); itr++)
- {
- (*itr)->Ticks--;
- }
}
// Execute and delete each task:
- for (ScheduledTaskList::iterator itr = Tasks.begin(), end = Tasks.end(); itr != end; ++itr)
+ for (cScheduledTasks::iterator itr = Tasks.begin(), end = Tasks.end(); itr != end; ++itr)
{
- (*itr)->Run(*this);
+ (*itr)->m_Task->Run(*this);
delete *itr;
} // for itr - m_Tasks[]
}
@@ -1149,6 +1148,15 @@ bool cWorld::DoWithNoteBlockAt(int a_BlockX, int a_BlockY, int a_BlockZ, cNoteBl
+bool cWorld::DoWithCommandBlockAt(int a_BlockX, int a_BlockY, int a_BlockZ, cCommandBlockCallback & a_Callback)
+{
+ return m_ChunkMap->DoWithCommandBlockAt(a_BlockX, a_BlockY, a_BlockZ, a_Callback);
+}
+
+
+
+
+
bool cWorld::GetSignLines(int a_BlockX, int a_BlockY, int a_BlockZ, AString & a_Line1, AString & a_Line2, AString & a_Line3, AString & a_Line4)
{
return m_ChunkMap->GetSignLines(a_BlockX, a_BlockY, a_BlockZ, a_Line1, a_Line2, a_Line3, a_Line4);
@@ -2623,18 +2631,25 @@ void cWorld::QueueTask(cTask * a_Task)
m_Tasks.push_back(a_Task);
}
-void cWorld::ScheduleTask(cScheduledTask * a_Task)
+
+
+
+
+void cWorld::ScheduleTask(int a_DelayTicks, cTask * a_Task)
{
+ Int64 TargetTick = a_DelayTicks + m_WorldAge;
+
+ // Insert the task into the list of scheduled tasks, ordered by its target tick
cCSLock Lock(m_CSScheduledTasks);
- for(ScheduledTaskList::iterator itr = m_ScheduledTasks.begin(); itr != m_ScheduledTasks.end(); itr++)
+ for (cScheduledTasks::iterator itr = m_ScheduledTasks.begin(), end = m_ScheduledTasks.end(); itr != end; ++itr)
{
- if((*itr)->Ticks >= a_Task->Ticks)
+ if ((*itr)->m_TargetTick >= TargetTick)
{
- m_ScheduledTasks.insert(itr, a_Task);
+ m_ScheduledTasks.insert(itr, new cScheduledTask(TargetTick, a_Task));
return;
}
}
- m_ScheduledTasks.push_back(a_Task);
+ m_ScheduledTasks.push_back(new cScheduledTask(TargetTick, a_Task));
}
@@ -2766,9 +2781,6 @@ int cWorld::SpawnMob(double a_PosX, double a_PosY, double a_PosZ, cMonster::eTyp
{
Monster->SetPosition(a_PosX, a_PosY, a_PosZ);
}
-
- // Because it's logical that ALL mob spawns need spawn effects, not just spawners
- BroadcastSoundParticleEffect(2004, (int)a_PosX, (int)a_PosY, (int)a_PosZ, 0);
return SpawnMobFinalize(Monster);
}