1
0

Prefabs can specify that they don't want flooring.

Previously the flag was ignored.
This commit is contained in:
madmaxoft 2014-05-05 22:28:54 +02:00
parent b69a0c914e
commit e4af9a21af

View File

@ -174,44 +174,47 @@ void cPrefab::Draw(cChunkDesc & a_Dest, const cPlacedPiece * a_Placement) const
a_Dest.WriteBlockArea(Image, Placement.x, Placement.y, Placement.z, m_MergeStrategy); a_Dest.WriteBlockArea(Image, Placement.x, Placement.y, Placement.z, m_MergeStrategy);
// If requested, draw the floor (from the bottom of the prefab down to the nearest non-air) // If requested, draw the floor (from the bottom of the prefab down to the nearest non-air)
int MaxX = Image.GetSizeX(); if (m_ShouldExtendFloor)
int MaxZ = Image.GetSizeZ();
for (int z = 0; z < MaxZ; z++)
{ {
int RelZ = Placement.z + z; int MaxX = Image.GetSizeX();
if ((RelZ < 0) || (RelZ >= cChunkDef::Width)) int MaxZ = Image.GetSizeZ();
for (int z = 0; z < MaxZ; z++)
{ {
// Z coord outside the chunk int RelZ = Placement.z + z;
continue; if ((RelZ < 0) || (RelZ >= cChunkDef::Width))
}
for (int x = 0; x < MaxX; x++)
{
int RelX = Placement.x + x;
if ((RelX < 0) || (RelX >= cChunkDef::Width))
{ {
// X coord outside the chunk // Z coord outside the chunk
continue; continue;
} }
BLOCKTYPE BlockType; for (int x = 0; x < MaxX; x++)
NIBBLETYPE BlockMeta;
Image.GetRelBlockTypeMeta(x, 0, z, BlockType, BlockMeta);
if ((BlockType == E_BLOCK_AIR) || (BlockType == E_BLOCK_SPONGE))
{ {
// Do not expand air nor sponge blocks int RelX = Placement.x + x;
continue; if ((RelX < 0) || (RelX >= cChunkDef::Width))
}
for (int y = Placement.y - 1; y >= 0; y--)
{
BLOCKTYPE ExistingBlock = a_Dest.GetBlockType(RelX, y, RelZ);
if (ExistingBlock != E_BLOCK_AIR)
{ {
// End the expansion for this column, reached the end // X coord outside the chunk
break; continue;
} }
a_Dest.SetBlockTypeMeta(RelX, y, RelZ, BlockType, BlockMeta); BLOCKTYPE BlockType;
} // for y NIBBLETYPE BlockMeta;
} // for x Image.GetRelBlockTypeMeta(x, 0, z, BlockType, BlockMeta);
} // for z if ((BlockType == E_BLOCK_AIR) || (BlockType == E_BLOCK_SPONGE))
{
// Do not expand air nor sponge blocks
continue;
}
for (int y = Placement.y - 1; y >= 0; y--)
{
BLOCKTYPE ExistingBlock = a_Dest.GetBlockType(RelX, y, RelZ);
if (ExistingBlock != E_BLOCK_AIR)
{
// End the expansion for this column, reached the end
break;
}
a_Dest.SetBlockTypeMeta(RelX, y, RelZ, BlockType, BlockMeta);
} // for y
} // for x
} // for z
}
} }