1
0
Fork 0

Remove unused block tick related cChunk functions

This commit is contained in:
Tiger Wang 2020-07-29 18:51:07 +01:00
parent 225c2fa9f6
commit 71ffa76847
4 changed files with 17 additions and 81 deletions

View File

@ -1159,23 +1159,6 @@ bool cChunk::UnboundedRelFastSetBlock(Vector3i a_RelPos, BLOCKTYPE a_BlockType,
void cChunk::UnboundedQueueTickBlock(Vector3i a_RelPos)
{
if (!cChunkDef::IsValidHeight(a_RelPos.y))
{
return;
}
auto chunk = GetRelNeighborChunkAdjustCoords(a_RelPos);
if ((chunk != nullptr) && chunk->IsValid())
{
chunk->QueueTickBlock(a_RelPos);
}
}
int cChunk::GetHeight(int a_X, int a_Z)
{
ASSERT((a_X >= 0) && (a_X < Width) && (a_Z >= 0) && (a_Z < Width));
@ -1283,10 +1266,8 @@ void cChunk::SetBlock(Vector3i a_RelPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_Blo
FastSetBlock(a_RelPos, a_BlockType, a_BlockMeta);
// Tick this block and its neighbors:
m_ToTickBlocks.push_back(a_RelPos);
QueueTickBlockNeighbors(a_RelPos);
// TODO: use relative coordinates, cChunk reference
// Wake up the simulators for this block:
GetWorld()->GetSimulatorManager()->WakeUp(*this, a_RelPos);
@ -1332,38 +1313,26 @@ void cChunk::SetBlock(Vector3i a_RelPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_Blo
void cChunk::QueueTickBlock(Vector3i a_RelPos)
void cChunk::QueueTickBlockNeighbors(Vector3i a_Position)
{
ASSERT(IsValidRelPos(a_RelPos));
m_ToTickBlocks.push(a_Position);
if (!IsValid())
for (const auto & Offset : cSimulator::AdjacentOffsets)
{
return;
}
auto Relative = a_Position + Offset;
m_ToTickBlocks.push_back(a_RelPos);
}
if (!cChunkDef::IsValidHeight(Relative.y))
{
continue;
}
auto Chunk = GetRelNeighborChunkAdjustCoords(Relative);
if ((Chunk == nullptr) || !Chunk->IsValid())
{
continue;
}
void cChunk::QueueTickBlockNeighbors(Vector3i a_RelPos)
{
// Contains our direct adjacents
static const Vector3i Offsets[] =
{
{ 1, 0, 0 },
{ -1, 0, 0 },
{ 0, 1, 0 },
{ 0, -1, 0 },
{ 0, 0, 1 },
{ 0, 0, -1 },
};
for (const auto & Offset : Offsets)
{
UnboundedQueueTickBlock(a_RelPos + Offset);
Chunk->m_ToTickBlocks.push(Relative);
}
}

View File

@ -158,18 +158,9 @@ public:
void SetBlock(Vector3i a_RelBlockPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta);
// SetBlock() does a lot of work (heightmap, tickblocks, blockentities) so a BlockIdx version doesn't make sense
/** Queues block for ticking (m_ToTickQueue) */
void QueueTickBlock(Vector3i a_RelPos);
/** OBSOLETE, use the Vector3i-based overload instead.
Queues block for ticking (m_ToTickQueue) */
void QueueTickBlock(int a_RelX, int a_RelY, int a_RelZ)
{
return QueueTickBlock({a_RelX, a_RelY, a_RelZ});
}
/** Queues all 6 neighbors of the specified block for ticking (m_ToTickQueue). If any are outside the chunk, relays the checking to the proper neighboring chunk */
void QueueTickBlockNeighbors(Vector3i a_RelPos);
/** Queues the position itself, and all 6 neighbors of the specified position for ticking (m_ToTickQueue).
If any are outside the chunk, relays the checking to the proper neighboring chunk. */
void QueueTickBlockNeighbors(Vector3i a_Position);
void FastSetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType, BLOCKTYPE a_BlockMeta, bool a_SendToClients = true); // Doesn't force block updates on neighbors, use for simple changes such as grass growing etc.
void FastSetBlock(Vector3i a_RelPos, BLOCKTYPE a_BlockType, BLOCKTYPE a_BlockMeta, bool a_SendToClients = true)
@ -525,10 +516,6 @@ public:
return UnboundedRelFastSetBlock({a_RelX, a_RelY, a_RelZ}, a_BlockType, a_BlockMeta);
}
/** Same as QueueTickBlock(), but relative coords needn't be in this chunk (uses m_Neighbor-s in such a case)
Ignores unsuccessful attempts */
void UnboundedQueueTickBlock(Vector3i a_RelPos);
// Per-chunk simulator data:

View File

@ -2191,23 +2191,6 @@ void cChunkMap::ChunkValidated(void)
void cChunkMap::QueueTickBlock(Vector3i a_AbsPos)
{
auto chunkCoords = cChunkDef::BlockToChunk(a_AbsPos);
auto relPos = cChunkDef::AbsoluteToRelative(a_AbsPos, chunkCoords);
cCSLock Lock(m_CSChunks);
cChunkPtr Chunk = GetChunkNoLoad(chunkCoords);
if (Chunk != nullptr)
{
Chunk->QueueTickBlock(relPos);
}
}
void cChunkMap::SetChunkAlwaysTicked(int a_ChunkX, int a_ChunkZ, bool a_AlwaysTicked)
{
cCSLock Lock(m_CSChunks);

View File

@ -401,9 +401,6 @@ public:
void ChunkValidated(void); // Called by chunks that have become valid
/** Queues the specified block for ticking (block update) */
void QueueTickBlock(Vector3i a_AbsPos);
/** Returns the CS for locking the chunkmap; only cWorld::cLock may use this function! */
cCriticalSection & GetCS(void) { return m_CSChunks; }