cWorld:QueueTickBlock takes the delay in ticks.
This commit is contained in:
parent
7ecd728f1e
commit
40d295da26
@ -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;
|
||||
|
@ -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 */
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user