1
0

cFinishGenPreSimulator: Preserve sand meta (#4025)

Fixes #1516.
This commit is contained in:
peterbell10 2017-09-18 08:45:32 +01:00 committed by Alexander Harkness
parent ad33a2d866
commit b5fa96f4f8
2 changed files with 8 additions and 13 deletions

View File

@ -1062,7 +1062,7 @@ void cFinishGenPreSimulator::GenFinish(cChunkDesc & a_ChunkDesc)
{ {
if (m_PreSimulateFallingBlocks) if (m_PreSimulateFallingBlocks)
{ {
CollapseSandGravel(a_ChunkDesc.GetBlockTypes(), a_ChunkDesc.GetHeightMap()); CollapseSandGravel(a_ChunkDesc);
} }
if (m_PreSimulateWater) if (m_PreSimulateWater)
@ -1081,10 +1081,7 @@ void cFinishGenPreSimulator::GenFinish(cChunkDesc & a_ChunkDesc)
void cFinishGenPreSimulator::CollapseSandGravel( void cFinishGenPreSimulator::CollapseSandGravel(cChunkDesc & a_ChunkDesc)
cChunkDef::BlockTypes & a_BlockTypes, // Block types to read and change
cChunkDef::HeightMap & a_HeightMap // Height map to update by the current data
)
{ {
for (int z = 0; z < cChunkDef::Width; z++) for (int z = 0; z < cChunkDef::Width; z++)
{ {
@ -1094,7 +1091,7 @@ void cFinishGenPreSimulator::CollapseSandGravel(
int HeightY = 0; int HeightY = 0;
for (int y = 0; y < cChunkDef::Height; y++) for (int y = 0; y < cChunkDef::Height; y++)
{ {
BLOCKTYPE Block = cChunkDef::GetBlock(a_BlockTypes, x, y, z); BLOCKTYPE Block = a_ChunkDesc.GetBlockType(x, y, z);
switch (Block) switch (Block)
{ {
default: default:
@ -1124,8 +1121,9 @@ void cFinishGenPreSimulator::CollapseSandGravel(
{ {
if (LastY < y - 1) if (LastY < y - 1)
{ {
cChunkDef::SetBlock(a_BlockTypes, x, LastY + 1, z, Block); auto BlockMeta = a_ChunkDesc.GetBlockMeta(x, y, z);
cChunkDef::SetBlock(a_BlockTypes, x, y, z, E_BLOCK_AIR); a_ChunkDesc.SetBlockTypeMeta(x, LastY + 1, z, Block, BlockMeta);
a_ChunkDesc.SetBlockTypeMeta(x, y, z, E_BLOCK_AIR, 0);
} }
LastY++; LastY++;
if (LastY > HeightY) if (LastY > HeightY)
@ -1136,7 +1134,7 @@ void cFinishGenPreSimulator::CollapseSandGravel(
} }
} // switch (GetBlock) } // switch (GetBlock)
} // for y } // for y
cChunkDef::SetHeight(a_HeightMap, x, z, static_cast<HEIGHTTYPE>(HeightY)); a_ChunkDesc.SetHeight(x, z, static_cast<HEIGHTTYPE>(HeightY));
} // for x } // for x
} // for z } // for z
} }

View File

@ -393,10 +393,7 @@ protected:
bool m_PreSimulateLava; bool m_PreSimulateLava;
/** Drops hanging sand and gravel down to the ground, recalculates heightmap */ /** Drops hanging sand and gravel down to the ground, recalculates heightmap */
void CollapseSandGravel( void CollapseSandGravel(cChunkDesc & a_ChunkDesc);
cChunkDef::BlockTypes & a_BlockTypes, // Block types to read and change
cChunkDef::HeightMap & a_HeightMap // Height map to update by the current data
);
/** For each fluid block: /** For each fluid block:
- if all surroundings are of the same fluid, makes it stationary; otherwise makes it flowing (excl. top) - if all surroundings are of the same fluid, makes it stationary; otherwise makes it flowing (excl. top)