Simulators are woken up upon chunk load
git-svn-id: http://mc-server.googlecode.com/svn/trunk@1248 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
parent
4e8fd2c084
commit
55326ee2a7
@ -308,6 +308,9 @@ void cChunk::SetAllData(
|
|||||||
|
|
||||||
// Create block entities that the loader didn't load; fill them with defaults
|
// Create block entities that the loader didn't load; fill them with defaults
|
||||||
CreateBlockEntities();
|
CreateBlockEntities();
|
||||||
|
|
||||||
|
// Wake up all simulators for their respective blocks:
|
||||||
|
WakeUpSimulators();
|
||||||
|
|
||||||
m_HasLoadFailed = false;
|
m_HasLoadFailed = false;
|
||||||
}
|
}
|
||||||
@ -1052,6 +1055,42 @@ void cChunk::CreateBlockEntities(void)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void cChunk::WakeUpSimulators(void)
|
||||||
|
{
|
||||||
|
cSimulator * WaterSimulator = m_World->GetWaterSimulator();
|
||||||
|
cSimulator * LavaSimulator = m_World->GetLavaSimulator();
|
||||||
|
int BaseX = m_PosX * cChunkDef::Width;
|
||||||
|
int BaseZ = m_PosZ * cChunkDef::Width;
|
||||||
|
for (int x = 0; x < Width; x++)
|
||||||
|
{
|
||||||
|
int BlockX = x + BaseX;
|
||||||
|
for (int z = 0; z < Width; z++)
|
||||||
|
{
|
||||||
|
int BlockZ = z + BaseZ;
|
||||||
|
for (int y = GetHeight(x, z); y >= 0; y--)
|
||||||
|
{
|
||||||
|
switch (cChunkDef::GetBlock(m_BlockTypes, x, y, z))
|
||||||
|
{
|
||||||
|
case E_BLOCK_WATER:
|
||||||
|
{
|
||||||
|
WaterSimulator->AddBlock(BlockX, y, BlockZ, this);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case E_BLOCK_LAVA:
|
||||||
|
{
|
||||||
|
LavaSimulator->AddBlock(BlockX, y, BlockZ, this);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} // switch (BlockType)
|
||||||
|
} // for y
|
||||||
|
} // for z
|
||||||
|
} // for x
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cChunk::CalculateHeightmap()
|
void cChunk::CalculateHeightmap()
|
||||||
{
|
{
|
||||||
for (int x = 0; x < Width; x++)
|
for (int x = 0; x < Width; x++)
|
||||||
|
@ -331,8 +331,12 @@ private:
|
|||||||
|
|
||||||
void SpreadLightOfBlock(NIBBLETYPE * a_LightBuffer, int a_X, int a_Y, int a_Z, char a_Falloff);
|
void SpreadLightOfBlock(NIBBLETYPE * a_LightBuffer, int a_X, int a_Y, int a_Z, char a_Falloff);
|
||||||
|
|
||||||
|
/// Creates a block entity for each block that needs a block entity and doesn't have one in the list
|
||||||
void CreateBlockEntities(void);
|
void CreateBlockEntities(void);
|
||||||
|
|
||||||
|
/// Wakes up each simulator for its specific blocks; through all the blocks in the chunk
|
||||||
|
void WakeUpSimulators(void);
|
||||||
|
|
||||||
// Makes a copy of the list
|
// Makes a copy of the list
|
||||||
cClientHandleList GetAllClients(void) const {return m_LoadedByClient; }
|
cClientHandleList GetAllClients(void) const {return m_LoadedByClient; }
|
||||||
|
|
||||||
|
@ -33,6 +33,8 @@ public:
|
|||||||
virtual bool IsAllowedBlock(BLOCKTYPE a_BlockType) = 0;
|
virtual bool IsAllowedBlock(BLOCKTYPE a_BlockType) = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
friend class cChunk; // Calls AddBlock() in its WakeUpSimulators() function, to speed things up
|
||||||
|
|
||||||
/// Called to simulate a new block
|
/// Called to simulate a new block
|
||||||
virtual void AddBlock(int a_BlockX, int a_BlockY, int a_BlockZ, cChunk * a_Chunk) = 0;
|
virtual void AddBlock(int a_BlockX, int a_BlockY, int a_BlockZ, cChunk * a_Chunk) = 0;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user