summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--source/Bindings.cpp6
-rw-r--r--source/Bindings.h2
-rw-r--r--source/World.cpp17
-rw-r--r--source/World.h10
4 files changed, 19 insertions, 16 deletions
diff --git a/source/Bindings.cpp b/source/Bindings.cpp
index 7768b1279..82b4a1d92 100644
--- a/source/Bindings.cpp
+++ b/source/Bindings.cpp
@@ -1,6 +1,6 @@
/*
** Lua binding: AllToLua
-** Generated automatically by tolua++-1.0.92 on 09/15/13 22:09:07.
+** Generated automatically by tolua++-1.0.92 on 09/16/13 09:19:33.
*/
#ifndef __cplusplus
@@ -13163,12 +13163,12 @@ static int tolua_AllToLua_cWorld_QueueBlockForTick00(lua_State* tolua_S)
int a_BlockX = ((int) tolua_tonumber(tolua_S,2,0));
int a_BlockY = ((int) tolua_tonumber(tolua_S,3,0));
int a_BlockZ = ((int) tolua_tonumber(tolua_S,4,0));
- float a_TimeToWait = ((float) tolua_tonumber(tolua_S,5,0));
+ int a_TicksToWait = ((int) tolua_tonumber(tolua_S,5,0));
#ifndef TOLUA_RELEASE
if (!self) tolua_error(tolua_S,"invalid 'self' in function 'QueueBlockForTick'", NULL);
#endif
{
- self->QueueBlockForTick(a_BlockX,a_BlockY,a_BlockZ,a_TimeToWait);
+ self->QueueBlockForTick(a_BlockX,a_BlockY,a_BlockZ,a_TicksToWait);
}
}
return 0;
diff --git a/source/Bindings.h b/source/Bindings.h
index d2a89fb47..8182de938 100644
--- a/source/Bindings.h
+++ b/source/Bindings.h
@@ -1,6 +1,6 @@
/*
** Lua binding: AllToLua
-** Generated automatically by tolua++-1.0.92 on 09/15/13 22:09:07.
+** Generated automatically by tolua++-1.0.92 on 09/16/13 09:19:34.
*/
/* Exported function */
diff --git a/source/World.cpp b/source/World.cpp
index c36c614b1..7be83168c 100644
--- a/source/World.cpp
+++ b/source/World.cpp
@@ -612,7 +612,7 @@ void cWorld::Tick(float a_Dt)
m_ChunkMap->Tick(a_Dt);
TickClients(a_Dt);
- TickQueuedBlocks(a_Dt);
+ TickQueuedBlocks();
TickQueuedTasks();
GetSimulatorManager()->Simulate(a_Dt);
@@ -2514,7 +2514,7 @@ void cWorld::GetChunkStats(int & a_NumValid, int & a_NumDirty, int & a_NumInLigh
-void cWorld::TickQueuedBlocks(float a_Dt)
+void cWorld::TickQueuedBlocks(void)
{
if (m_BlockTickQueue.empty())
{
@@ -2526,15 +2526,16 @@ void cWorld::TickQueuedBlocks(float a_Dt)
for (std::vector<BlockTickQueueItem *>::iterator itr = m_BlockTickQueueCopy.begin(); itr != m_BlockTickQueueCopy.end(); itr++)
{
BlockTickQueueItem *Block = (*itr);
- Block->ToWait -= a_Dt;
- if (Block->ToWait <= 0)
+ Block->TicksToWait -= 1;
+ if (Block->TicksToWait <= 0)
{
+ // TODO: Handle the case when the chunk is already unloaded
BlockHandler(GetBlock(Block->X, Block->Y, Block->Z))->OnUpdate(this, Block->X, Block->Y, Block->Z);
- delete Block; //We don't have to remove it from the vector, this will happen automatically on the next tick
+ delete Block; // We don't have to remove it from the vector, this will happen automatically on the next tick
}
else
{
- m_BlockTickQueue.push_back(Block); //Keep the block in the queue
+ m_BlockTickQueue.push_back(Block); // Keep the block in the queue
}
} // for itr - m_BlockTickQueueCopy[]
}
@@ -2543,13 +2544,13 @@ void cWorld::TickQueuedBlocks(float a_Dt)
-void cWorld::QueueBlockForTick(int a_BlockX, int a_BlockY, int a_BlockZ, float a_TimeToWait)
+void cWorld::QueueBlockForTick(int a_BlockX, int a_BlockY, int a_BlockZ, int a_TicksToWait)
{
BlockTickQueueItem * Block = new BlockTickQueueItem;
Block->X = a_BlockX;
Block->Y = a_BlockY;
Block->Z = a_BlockZ;
- Block->ToWait = a_TimeToWait;
+ Block->TicksToWait = a_TicksToWait;
m_BlockTickQueue.push_back(Block);
}
diff --git a/source/World.h b/source/World.h
index dac30e6aa..5381dc614 100644
--- a/source/World.h
+++ b/source/World.h
@@ -530,17 +530,19 @@ public:
/// Stops threads that belong to this world (part of deinit)
void Stop(void);
- void TickQueuedBlocks(float a_Dt);
+ /// Processes the blocks queued for ticking with a delay (m_BlockTickQueue[])
+ void TickQueuedBlocks(void);
struct BlockTickQueueItem
{
int X;
int Y;
int Z;
- float ToWait;
+ int TicksToWait;
};
- void QueueBlockForTick(int a_BlockX, int a_BlockY, int a_BlockZ, float a_TimeToWait); // tolua_export
+ /// Queues the block to be ticked after the specified number of game ticks
+ void QueueBlockForTick(int a_BlockX, int a_BlockY, int a_BlockZ, int a_TicksToWait); // tolua_export
// tolua_begin
/// Casts a thunderbolt at the specified coords
@@ -633,7 +635,7 @@ private:
std::vector<int> m_RSList;
std::vector<BlockTickQueueItem *> m_BlockTickQueue;
- std::vector<BlockTickQueueItem *> m_BlockTickQueueCopy; //Second is for safely removing the objects from the queue
+ std::vector<BlockTickQueueItem *> m_BlockTickQueueCopy; // Second is for safely removing the objects from the queue
cSimulatorManager * m_SimulatorManager;
cSandSimulator * m_SandSimulator;