cChunk: don't inherit from cChunkDef (#5106)
This commit is contained in:
parent
bdb45998c9
commit
813176fbd1
@ -313,7 +313,7 @@ bool cHopperEntity::MoveItemsOut(cChunk & a_Chunk, Int64 a_CurrentTick)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Convert coords to relative:
|
// Convert coords to relative:
|
||||||
auto relCoord = a_Chunk.AbsoluteToRelative(out.second);
|
auto relCoord = cChunkDef::AbsoluteToRelative(out.second);
|
||||||
auto destChunk = a_Chunk.GetRelNeighborChunkAdjustCoords(relCoord);
|
auto destChunk = a_Chunk.GetRelNeighborChunkAdjustCoords(relCoord);
|
||||||
if (destChunk == nullptr)
|
if (destChunk == nullptr)
|
||||||
{
|
{
|
||||||
@ -554,7 +554,7 @@ bool cHopperEntity::MoveItemsToChest(cChunk & a_Chunk, Vector3i a_Coords)
|
|||||||
{ 0, 0, 1},
|
{ 0, 0, 1},
|
||||||
{ 0, 0, -1},
|
{ 0, 0, -1},
|
||||||
} ;
|
} ;
|
||||||
auto relCoord = a_Chunk.AbsoluteToRelative(a_Coords);
|
auto relCoord = cChunkDef::AbsoluteToRelative(a_Coords);
|
||||||
for (const auto & ofs: neighborOfs)
|
for (const auto & ofs: neighborOfs)
|
||||||
{
|
{
|
||||||
auto otherHalfRelCoord = relCoord + ofs;
|
auto otherHalfRelCoord = relCoord + ofs;
|
||||||
|
@ -29,7 +29,7 @@ private:
|
|||||||
|
|
||||||
virtual void OnNeighborChanged(cChunkInterface & a_ChunkInterface, Vector3i a_BlockPos, eBlockFace a_WhichNeighbor) const override
|
virtual void OnNeighborChanged(cChunkInterface & a_ChunkInterface, Vector3i a_BlockPos, eBlockFace a_WhichNeighbor) const override
|
||||||
{
|
{
|
||||||
a_ChunkInterface.DoWithChunkAt(a_BlockPos, [&](cChunk & a_Chunk) { CheckSoaked(a_Chunk.AbsoluteToRelative(a_BlockPos), a_Chunk); return true; });
|
a_ChunkInterface.DoWithChunkAt(a_BlockPos, [&](cChunk & a_Chunk) { CheckSoaked(cChunkDef::AbsoluteToRelative(a_BlockPos), a_Chunk); return true; });
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Check blocks above and around to see if they are water. If one is, converts this into concrete block. */
|
/** Check blocks above and around to see if they are water. If one is, converts this into concrete block. */
|
||||||
|
@ -488,7 +488,7 @@ void cBlockHandler::OnUpdate(
|
|||||||
|
|
||||||
void cBlockHandler::OnNeighborChanged(cChunkInterface & a_ChunkInterface, Vector3i a_BlockPos, eBlockFace a_WhichNeighbor) const
|
void cBlockHandler::OnNeighborChanged(cChunkInterface & a_ChunkInterface, Vector3i a_BlockPos, eBlockFace a_WhichNeighbor) const
|
||||||
{
|
{
|
||||||
if (a_ChunkInterface.DoWithChunkAt(a_BlockPos, [&](cChunk & a_Chunk) { return CanBeAt(a_ChunkInterface, a_Chunk.AbsoluteToRelative(a_BlockPos), a_Chunk); }))
|
if (a_ChunkInterface.DoWithChunkAt(a_BlockPos, [&](cChunk & a_Chunk) { return CanBeAt(a_ChunkInterface, cChunkDef::AbsoluteToRelative(a_BlockPos), a_Chunk); }))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ private:
|
|||||||
|
|
||||||
virtual void OnNeighborChanged(cChunkInterface & a_ChunkInterface, Vector3i a_BlockPos, eBlockFace a_WhichNeighbor) const override
|
virtual void OnNeighborChanged(cChunkInterface & a_ChunkInterface, Vector3i a_BlockPos, eBlockFace a_WhichNeighbor) const override
|
||||||
{
|
{
|
||||||
a_ChunkInterface.DoWithChunkAt(a_BlockPos, [&](cChunk & a_Chunk) { CheckSoaked(a_Chunk.AbsoluteToRelative(a_BlockPos), a_Chunk); return true; });
|
a_ChunkInterface.DoWithChunkAt(a_BlockPos, [&](cChunk & a_Chunk) { CheckSoaked(cChunkDef::AbsoluteToRelative(a_BlockPos), a_Chunk); return true; });
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Check blocks around the sponge to see if they are water.
|
/** Check blocks around the sponge to see if they are water.
|
||||||
|
@ -162,7 +162,7 @@ private:
|
|||||||
a_ChunkInterface.DoWithChunkAt(a_BlockPos, [&](cChunk & a_Chunk)
|
a_ChunkInterface.DoWithChunkAt(a_BlockPos, [&](cChunk & a_Chunk)
|
||||||
{
|
{
|
||||||
|
|
||||||
const auto a_RelPos = a_Chunk.AbsoluteToRelative(a_BlockPos);
|
const auto a_RelPos = cChunkDef::AbsoluteToRelative(a_BlockPos);
|
||||||
NIBBLETYPE CurMeta = a_Chunk.GetMeta(a_RelPos);
|
NIBBLETYPE CurMeta = a_Chunk.GetMeta(a_RelPos);
|
||||||
NIBBLETYPE MaxMeta = GetMaxMeta(a_Chunk, a_RelPos);
|
NIBBLETYPE MaxMeta = GetMaxMeta(a_Chunk, a_RelPos);
|
||||||
|
|
||||||
|
@ -483,7 +483,7 @@ void cChunk::WriteBlockArea(cBlockArea & a_Area, int a_MinBlockX, int a_MinBlock
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// This block entity is inside the chunk, clone it (and remove any that is there currently):
|
// This block entity is inside the chunk, clone it (and remove any that is there currently):
|
||||||
auto idx = static_cast<size_t>(MakeIndex(posX - m_PosX * cChunkDef::Width, posY, posZ - m_PosZ * cChunkDef::Width));
|
auto idx = static_cast<size_t>(cChunkDef::MakeIndex(posX - m_PosX * cChunkDef::Width, posY, posZ - m_PosZ * cChunkDef::Width));
|
||||||
auto itr = m_BlockEntities.find(idx);
|
auto itr = m_BlockEntities.find(idx);
|
||||||
if (itr != m_BlockEntities.end())
|
if (itr != m_BlockEntities.end())
|
||||||
{
|
{
|
||||||
@ -584,7 +584,7 @@ void cChunk::GetRandomBlockCoords(int & a_X, int & a_Y, int & a_Z)
|
|||||||
// MG TODO : check if this kind of optimization (only one random call) is still needed
|
// MG TODO : check if this kind of optimization (only one random call) is still needed
|
||||||
// MG TODO : if so propagate it
|
// MG TODO : if so propagate it
|
||||||
|
|
||||||
GetThreeRandomNumbers(a_X, a_Y, a_Z, Width, Height - 2, Width);
|
GetThreeRandomNumbers(a_X, a_Y, a_Z, cChunkDef::Width, cChunkDef::Height - 2, cChunkDef::Width);
|
||||||
a_Y++;
|
a_Y++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1201,8 +1201,8 @@ bool cChunk::UnboundedRelFastSetBlock(Vector3i a_RelPos, BLOCKTYPE a_BlockType,
|
|||||||
|
|
||||||
int cChunk::GetHeight(int a_X, int a_Z) const
|
int cChunk::GetHeight(int a_X, int a_Z) const
|
||||||
{
|
{
|
||||||
ASSERT((a_X >= 0) && (a_X < Width) && (a_Z >= 0) && (a_Z < Width));
|
ASSERT((a_X >= 0) && (a_X < cChunkDef::Width) && (a_Z >= 0) && (a_Z < cChunkDef::Width));
|
||||||
return m_HeightMap[a_X + a_Z * Width];
|
return m_HeightMap[a_X + a_Z * cChunkDef::Width];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1272,7 +1272,7 @@ void cChunk::WakeUpSimulators(void)
|
|||||||
for (size_t BlockIdx = 0; BlockIdx != cChunkData::SectionBlockCount; ++BlockIdx)
|
for (size_t BlockIdx = 0; BlockIdx != cChunkData::SectionBlockCount; ++BlockIdx)
|
||||||
{
|
{
|
||||||
const auto BlockType = Section->m_BlockTypes[BlockIdx];
|
const auto BlockType = Section->m_BlockTypes[BlockIdx];
|
||||||
auto Position = IndexToCoordinate(BlockIdx);
|
auto Position = cChunkDef::IndexToCoordinate(BlockIdx);
|
||||||
Position.y += static_cast<int>(SectionIdx * cChunkData::SectionHeight);
|
Position.y += static_cast<int>(SectionIdx * cChunkData::SectionHeight);
|
||||||
|
|
||||||
RedstoneSimulator->AddBlock(*this, Position, BlockType);
|
RedstoneSimulator->AddBlock(*this, Position, BlockType);
|
||||||
@ -1286,29 +1286,6 @@ void cChunk::WakeUpSimulators(void)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cChunk::CalculateHeightmap(const BLOCKTYPE * a_BlockTypes)
|
|
||||||
{
|
|
||||||
for (int x = 0; x < Width; x++)
|
|
||||||
{
|
|
||||||
for (int z = 0; z < Width; z++)
|
|
||||||
{
|
|
||||||
for (int y = Height - 1; y > -1; y--)
|
|
||||||
{
|
|
||||||
int index = MakeIndex( x, y, z);
|
|
||||||
if (a_BlockTypes[index] != E_BLOCK_AIR)
|
|
||||||
{
|
|
||||||
m_HeightMap[x + z * Width] = static_cast<HEIGHTTYPE>(y);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} // for y
|
|
||||||
} // for z
|
|
||||||
} // for x
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cChunk::SetBlock(Vector3i a_RelPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
|
void cChunk::SetBlock(Vector3i a_RelPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
|
||||||
{
|
{
|
||||||
FastSetBlock(a_RelPos, a_BlockType, a_BlockMeta);
|
FastSetBlock(a_RelPos, a_BlockType, a_BlockMeta);
|
||||||
@ -1341,7 +1318,7 @@ void cChunk::SetBlock(Vector3i a_RelPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_Blo
|
|||||||
|
|
||||||
void cChunk::FastSetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType, BLOCKTYPE a_BlockMeta)
|
void cChunk::FastSetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType, BLOCKTYPE a_BlockMeta)
|
||||||
{
|
{
|
||||||
ASSERT(!((a_RelX < 0) || (a_RelX >= Width) || (a_RelY < 0) || (a_RelY >= Height) || (a_RelZ < 0) || (a_RelZ >= Width)));
|
ASSERT(!((a_RelX < 0) || (a_RelX >= cChunkDef::Width) || (a_RelY < 0) || (a_RelY >= cChunkDef::Height) || (a_RelZ < 0) || (a_RelZ >= cChunkDef::Width)));
|
||||||
|
|
||||||
ASSERT(IsValid());
|
ASSERT(IsValid());
|
||||||
|
|
||||||
@ -1393,11 +1370,11 @@ void cChunk::FastSetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockT
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Update heightmap, if needed:
|
// Update heightmap, if needed:
|
||||||
if (a_RelY >= m_HeightMap[a_RelX + a_RelZ * Width])
|
if (a_RelY >= m_HeightMap[a_RelX + a_RelZ * cChunkDef::Width])
|
||||||
{
|
{
|
||||||
if (a_BlockType != E_BLOCK_AIR)
|
if (a_BlockType != E_BLOCK_AIR)
|
||||||
{
|
{
|
||||||
m_HeightMap[a_RelX + a_RelZ * Width] = static_cast<HEIGHTTYPE>(a_RelY);
|
m_HeightMap[a_RelX + a_RelZ * cChunkDef::Width] = static_cast<HEIGHTTYPE>(a_RelY);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1405,7 +1382,7 @@ void cChunk::FastSetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockT
|
|||||||
{
|
{
|
||||||
if (GetBlock(a_RelX, y, a_RelZ) != E_BLOCK_AIR)
|
if (GetBlock(a_RelX, y, a_RelZ) != E_BLOCK_AIR)
|
||||||
{
|
{
|
||||||
m_HeightMap[a_RelX + a_RelZ * Width] = static_cast<HEIGHTTYPE>(y);
|
m_HeightMap[a_RelX + a_RelZ * cChunkDef::Width] = static_cast<HEIGHTTYPE>(y);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} // for y - column in m_BlockData
|
} // for y - column in m_BlockData
|
||||||
@ -1445,7 +1422,7 @@ void cChunk::SendBlockTo(int a_RelX, int a_RelY, int a_RelZ, cClientHandle * a_C
|
|||||||
void cChunk::AddBlockEntity(OwnedBlockEntity a_BlockEntity)
|
void cChunk::AddBlockEntity(OwnedBlockEntity a_BlockEntity)
|
||||||
{
|
{
|
||||||
[[maybe_unused]] const auto Result = m_BlockEntities.emplace(
|
[[maybe_unused]] const auto Result = m_BlockEntities.emplace(
|
||||||
MakeIndex(a_BlockEntity->GetRelX(), a_BlockEntity->GetPosY(), a_BlockEntity->GetRelZ()),
|
cChunkDef::MakeIndex(a_BlockEntity->GetRelX(), a_BlockEntity->GetPosY(), a_BlockEntity->GetRelZ()),
|
||||||
std::move(a_BlockEntity)
|
std::move(a_BlockEntity)
|
||||||
);
|
);
|
||||||
ASSERT(Result.second); // No block entity already at this position
|
ASSERT(Result.second); // No block entity already at this position
|
||||||
@ -1457,15 +1434,15 @@ void cChunk::AddBlockEntity(OwnedBlockEntity a_BlockEntity)
|
|||||||
|
|
||||||
cBlockEntity * cChunk::GetBlockEntity(Vector3i a_AbsPos)
|
cBlockEntity * cChunk::GetBlockEntity(Vector3i a_AbsPos)
|
||||||
{
|
{
|
||||||
auto relPos = AbsoluteToRelative(a_AbsPos);
|
const auto relPos = cChunkDef::AbsoluteToRelative(a_AbsPos);
|
||||||
|
|
||||||
if (!IsValidRelPos(relPos))
|
if (!cChunkDef::IsValidRelPos(relPos))
|
||||||
{
|
{
|
||||||
// Coordinates are outside outside this chunk, no block entities here
|
// Coordinates are outside outside this chunk, no block entities here
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto itr = m_BlockEntities.find(static_cast<size_t>(MakeIndexNoCheck(relPos)));
|
auto itr = m_BlockEntities.find(static_cast<size_t>(cChunkDef::MakeIndexNoCheck(relPos)));
|
||||||
return (itr == m_BlockEntities.end()) ? nullptr : itr->second.get();
|
return (itr == m_BlockEntities.end()) ? nullptr : itr->second.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1475,8 +1452,8 @@ cBlockEntity * cChunk::GetBlockEntity(Vector3i a_AbsPos)
|
|||||||
|
|
||||||
cBlockEntity * cChunk::GetBlockEntityRel(Vector3i a_RelPos)
|
cBlockEntity * cChunk::GetBlockEntityRel(Vector3i a_RelPos)
|
||||||
{
|
{
|
||||||
ASSERT(IsValidRelPos(a_RelPos));
|
ASSERT(cChunkDef::IsValidRelPos(a_RelPos));
|
||||||
auto itr = m_BlockEntities.find(static_cast<size_t>(MakeIndexNoCheck(a_RelPos)));
|
auto itr = m_BlockEntities.find(static_cast<size_t>(cChunkDef::MakeIndexNoCheck(a_RelPos)));
|
||||||
return (itr == m_BlockEntities.end()) ? nullptr : itr->second.get();
|
return (itr == m_BlockEntities.end()) ? nullptr : itr->second.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1588,7 +1565,7 @@ void cChunk::RemoveBlockEntity(cBlockEntity * a_BlockEntity)
|
|||||||
{
|
{
|
||||||
MarkDirty();
|
MarkDirty();
|
||||||
ASSERT(a_BlockEntity != nullptr);
|
ASSERT(a_BlockEntity != nullptr);
|
||||||
auto idx = static_cast<size_t>(MakeIndex(a_BlockEntity->GetRelX(), a_BlockEntity->GetPosY(), a_BlockEntity->GetRelZ()));
|
auto idx = static_cast<size_t>(cChunkDef::MakeIndex(a_BlockEntity->GetRelX(), a_BlockEntity->GetPosY(), a_BlockEntity->GetRelZ()));
|
||||||
m_BlockEntities.erase(idx);
|
m_BlockEntities.erase(idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2171,7 +2148,7 @@ cChunk * cChunk::GetRelNeighborChunk(int a_RelX, int a_RelZ)
|
|||||||
int BlockX = m_PosX * cChunkDef::Width + a_RelX;
|
int BlockX = m_PosX * cChunkDef::Width + a_RelX;
|
||||||
int BlockZ = m_PosZ * cChunkDef::Width + a_RelZ;
|
int BlockZ = m_PosZ * cChunkDef::Width + a_RelZ;
|
||||||
int ChunkX, ChunkZ;
|
int ChunkX, ChunkZ;
|
||||||
BlockToChunk(BlockX, BlockZ, ChunkX, ChunkZ);
|
cChunkDef::BlockToChunk(BlockX, BlockZ, ChunkX, ChunkZ);
|
||||||
return m_ChunkMap->FindChunk(ChunkX, ChunkZ);
|
return m_ChunkMap->FindChunk(ChunkX, ChunkZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2236,8 +2213,8 @@ cChunk * cChunk::GetRelNeighborChunkAdjustCoords(Vector3i & a_RelPos) const
|
|||||||
|
|
||||||
// The most common case: inside this chunk:
|
// The most common case: inside this chunk:
|
||||||
if (
|
if (
|
||||||
(a_RelPos.x >= 0) && (a_RelPos.x < Width) &&
|
(a_RelPos.x >= 0) && (a_RelPos.x < cChunkDef::Width) &&
|
||||||
(a_RelPos.z >= 0) && (a_RelPos.z < Width)
|
(a_RelPos.z >= 0) && (a_RelPos.z < cChunkDef::Width)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return ToReturn;
|
return ToReturn;
|
||||||
@ -2246,24 +2223,24 @@ cChunk * cChunk::GetRelNeighborChunkAdjustCoords(Vector3i & a_RelPos) const
|
|||||||
// Request for a different chunk, calculate chunk offset:
|
// Request for a different chunk, calculate chunk offset:
|
||||||
int RelX = a_RelPos.x; // Make a local copy of the coords (faster access)
|
int RelX = a_RelPos.x; // Make a local copy of the coords (faster access)
|
||||||
int RelZ = a_RelPos.z;
|
int RelZ = a_RelPos.z;
|
||||||
while ((RelX >= Width) && (ToReturn != nullptr))
|
while ((RelX >= cChunkDef::Width) && (ToReturn != nullptr))
|
||||||
{
|
{
|
||||||
RelX -= Width;
|
RelX -= cChunkDef::Width;
|
||||||
ToReturn = ToReturn->m_NeighborXP;
|
ToReturn = ToReturn->m_NeighborXP;
|
||||||
}
|
}
|
||||||
while ((RelX < 0) && (ToReturn != nullptr))
|
while ((RelX < 0) && (ToReturn != nullptr))
|
||||||
{
|
{
|
||||||
RelX += Width;
|
RelX += cChunkDef::Width;
|
||||||
ToReturn = ToReturn->m_NeighborXM;
|
ToReturn = ToReturn->m_NeighborXM;
|
||||||
}
|
}
|
||||||
while ((RelZ >= Width) && (ToReturn != nullptr))
|
while ((RelZ >= cChunkDef::Width) && (ToReturn != nullptr))
|
||||||
{
|
{
|
||||||
RelZ -= Width;
|
RelZ -= cChunkDef::Width;
|
||||||
ToReturn = ToReturn->m_NeighborZP;
|
ToReturn = ToReturn->m_NeighborZP;
|
||||||
}
|
}
|
||||||
while ((RelZ < 0) && (ToReturn != nullptr))
|
while ((RelZ < 0) && (ToReturn != nullptr))
|
||||||
{
|
{
|
||||||
RelZ += Width;
|
RelZ += cChunkDef::Width;
|
||||||
ToReturn = ToReturn->m_NeighborZM;
|
ToReturn = ToReturn->m_NeighborZM;
|
||||||
}
|
}
|
||||||
if (ToReturn != nullptr)
|
if (ToReturn != nullptr)
|
||||||
@ -2274,13 +2251,13 @@ cChunk * cChunk::GetRelNeighborChunkAdjustCoords(Vector3i & a_RelPos) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
// The chunk cannot be walked through neighbors, find it through the chunkmap:
|
// The chunk cannot be walked through neighbors, find it through the chunkmap:
|
||||||
int AbsX = a_RelPos.x + m_PosX * Width;
|
int AbsX = a_RelPos.x + m_PosX * cChunkDef::Width;
|
||||||
int AbsZ = a_RelPos.z + m_PosZ * Width;
|
int AbsZ = a_RelPos.z + m_PosZ * cChunkDef::Width;
|
||||||
int DstChunkX, DstChunkZ;
|
int DstChunkX, DstChunkZ;
|
||||||
BlockToChunk(AbsX, AbsZ, DstChunkX, DstChunkZ);
|
cChunkDef::BlockToChunk(AbsX, AbsZ, DstChunkX, DstChunkZ);
|
||||||
ToReturn = m_ChunkMap->FindChunk(DstChunkX, DstChunkZ);
|
ToReturn = m_ChunkMap->FindChunk(DstChunkX, DstChunkZ);
|
||||||
a_RelPos.x = AbsX - DstChunkX * Width;
|
a_RelPos.x = AbsX - DstChunkX * cChunkDef::Width;
|
||||||
a_RelPos.z = AbsZ - DstChunkZ * Width;
|
a_RelPos.z = AbsZ - DstChunkZ * cChunkDef::Width;
|
||||||
return ToReturn;
|
return ToReturn;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2305,8 +2282,8 @@ void cChunk::SendBlockEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cClientHa
|
|||||||
void cChunk::PositionToWorldPosition(int a_RelX, int a_RelY, int a_RelZ, int & a_BlockX, int & a_BlockY, int & a_BlockZ)
|
void cChunk::PositionToWorldPosition(int a_RelX, int a_RelY, int a_RelZ, int & a_BlockX, int & a_BlockY, int & a_BlockZ)
|
||||||
{
|
{
|
||||||
a_BlockY = a_RelY;
|
a_BlockY = a_RelY;
|
||||||
a_BlockX = m_PosX * Width + a_RelX;
|
a_BlockX = m_PosX * cChunkDef::Width + a_RelX;
|
||||||
a_BlockZ = m_PosZ * Width + a_RelZ;
|
a_BlockZ = m_PosZ * cChunkDef::Width + a_RelZ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -2315,7 +2292,7 @@ void cChunk::PositionToWorldPosition(int a_RelX, int a_RelY, int a_RelZ, int & a
|
|||||||
|
|
||||||
Vector3i cChunk::PositionToWorldPosition(int a_RelX, int a_RelY, int a_RelZ)
|
Vector3i cChunk::PositionToWorldPosition(int a_RelX, int a_RelY, int a_RelZ)
|
||||||
{
|
{
|
||||||
return Vector3i(m_PosX * Width + a_RelX, a_RelY, m_PosZ * Width + a_RelZ);
|
return Vector3i(m_PosX * cChunkDef::Width + a_RelX, a_RelY, m_PosZ * cChunkDef::Width + a_RelZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -45,10 +45,7 @@ typedef std::list<cClientHandle *> cClientHandleList;
|
|||||||
#define PREPARE_REL_AND_CHUNK(Position, OriginalChunk) cChunk * Chunk; Vector3i Rel; bool RelSuccess = (OriginalChunk).GetChunkAndRelByAbsolute(Position, &Chunk, Rel)
|
#define PREPARE_REL_AND_CHUNK(Position, OriginalChunk) cChunk * Chunk; Vector3i Rel; bool RelSuccess = (OriginalChunk).GetChunkAndRelByAbsolute(Position, &Chunk, Rel)
|
||||||
|
|
||||||
|
|
||||||
// This class is not to be used directly
|
class cChunk
|
||||||
// Instead, call actions on cChunkMap (such as cChunkMap::SetBlock() etc.)
|
|
||||||
class cChunk :
|
|
||||||
public cChunkDef // The inheritance is "misused" here only to inherit the functions and constants defined in cChunkDef
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -347,8 +344,6 @@ public:
|
|||||||
returns true if the use was successful, return false to use the block as a "normal" block */
|
returns true if the use was successful, return false to use the block as a "normal" block */
|
||||||
bool UseBlockEntity(cPlayer * a_Player, int a_X, int a_Y, int a_Z); // [x, y, z] in world block coords
|
bool UseBlockEntity(cPlayer * a_Player, int a_X, int a_Y, int a_Z); // [x, y, z] in world block coords
|
||||||
|
|
||||||
void CalculateHeightmap(const BLOCKTYPE * a_BlockTypes);
|
|
||||||
|
|
||||||
void SendBlockEntity (int a_BlockX, int a_BlockY, int a_BlockZ, cClientHandle & a_Client);
|
void SendBlockEntity (int a_BlockX, int a_BlockY, int a_BlockZ, cClientHandle & a_Client);
|
||||||
|
|
||||||
Vector3i PositionToWorldPosition(Vector3i a_RelPos)
|
Vector3i PositionToWorldPosition(Vector3i a_RelPos)
|
||||||
|
@ -137,7 +137,7 @@ void cMinecart::HandlePhysics(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto relPos = a_Chunk.AbsoluteToRelative(GetPosition());
|
auto relPos = cChunkDef::AbsoluteToRelative(GetPosition());
|
||||||
auto chunk = a_Chunk.GetRelNeighborChunkAdjustCoords(relPos);
|
auto chunk = a_Chunk.GetRelNeighborChunkAdjustCoords(relPos);
|
||||||
if (chunk == nullptr)
|
if (chunk == nullptr)
|
||||||
{
|
{
|
||||||
|
@ -25,7 +25,7 @@ ForEachSourceCallback::ForEachSourceCallback(const cChunk & Chunk, const Vector3
|
|||||||
|
|
||||||
void ForEachSourceCallback::operator()(Vector3i Location)
|
void ForEachSourceCallback::operator()(Vector3i Location)
|
||||||
{
|
{
|
||||||
if (!cChunk::IsValidHeight(Location.y))
|
if (!cChunkDef::IsValidHeight(Location.y))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -121,7 +121,7 @@ PowerLevel ForEachSourceCallback::QueryLinkedPower(const cChunk & Chunk, const V
|
|||||||
for (const auto & Offset : cSimulator::GetLinkedOffsets(SolidBlockPosition - QueryPosition))
|
for (const auto & Offset : cSimulator::GetLinkedOffsets(SolidBlockPosition - QueryPosition))
|
||||||
{
|
{
|
||||||
auto SourcePosition = QueryPosition + Offset;
|
auto SourcePosition = QueryPosition + Offset;
|
||||||
if (!cChunk::IsValidHeight(SourcePosition.y))
|
if (!cChunkDef::IsValidHeight(SourcePosition.y))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user