1
0
Fork 0

Added cBlockInfo::CanBeTerraformed and made finishers use it

I might have forgotten some of them though
This commit is contained in:
STRWarrior 2014-07-29 22:31:31 +02:00
parent 30e64ed4d8
commit adae2b70b1
4 changed files with 31 additions and 44 deletions

View File

@ -17,6 +17,7 @@ cBlockInfo::cBlockInfo()
, m_IsSnowable(false)
, m_IsSolid(true)
, m_FullyOccupiesVoxel(false)
, m_CanBeTerraformed(false)
, m_Handler(NULL)
{}
@ -548,6 +549,26 @@ void cBlockInfo::Initialize(cBlockInfoArray & a_Info)
a_Info[E_BLOCK_STONE ].m_FullyOccupiesVoxel = true;
a_Info[E_BLOCK_STONE_BRICKS ].m_FullyOccupiesVoxel = true;
a_Info[E_BLOCK_WOOL ].m_FullyOccupiesVoxel = true;
// Blocks that can be terraformed
a_Info[E_BLOCK_COAL_ORE ].m_CanBeTerraformed = true;
a_Info[E_BLOCK_COBBLESTONE ].m_CanBeTerraformed = true;
a_Info[E_BLOCK_DIAMOND_ORE ].m_CanBeTerraformed = true;
a_Info[E_BLOCK_DIRT ].m_CanBeTerraformed = true;
a_Info[E_BLOCK_GOLD_ORE ].m_CanBeTerraformed = true;
a_Info[E_BLOCK_GRASS ].m_CanBeTerraformed = true;
a_Info[E_BLOCK_GRAVEL ].m_CanBeTerraformed = true;
a_Info[E_BLOCK_HARDENED_CLAY ].m_CanBeTerraformed = true;
a_Info[E_BLOCK_IRON_ORE ].m_CanBeTerraformed = true;
a_Info[E_BLOCK_MYCELIUM ].m_CanBeTerraformed = true;
a_Info[E_BLOCK_NETHERRACK ].m_CanBeTerraformed = true;
a_Info[E_BLOCK_REDSTONE_ORE ].m_CanBeTerraformed = true;
a_Info[E_BLOCK_REDSTONE_ORE_GLOWING].m_CanBeTerraformed = true;
a_Info[E_BLOCK_SAND ].m_CanBeTerraformed = true;
a_Info[E_BLOCK_SANDSTONE ].m_CanBeTerraformed = true;
a_Info[E_BLOCK_STAINED_CLAY ].m_CanBeTerraformed = true;
a_Info[E_BLOCK_STONE ].m_CanBeTerraformed = true;
}

View File

@ -45,6 +45,9 @@ public:
/** Does this block fully occupy its voxel - is it a 'full' block? */
bool m_FullyOccupiesVoxel;
/** Can a finisher change it? */
bool m_CanBeTerraformed;
// tolua_end
/** Associated block handler. */
@ -60,6 +63,7 @@ public:
inline static bool IsSnowable (BLOCKTYPE a_Type) { return Get(a_Type).m_IsSnowable; }
inline static bool IsSolid (BLOCKTYPE a_Type) { return Get(a_Type).m_IsSolid; }
inline static bool FullyOccupiesVoxel (BLOCKTYPE a_Type) { return Get(a_Type).m_FullyOccupiesVoxel; }
inline static bool CanBeTerraformed (BLOCKTYPE a_Type) { return Get(a_Type).m_CanBeTerraformed; }
// tolua_end

View File

@ -497,29 +497,9 @@ void cCaveTunnel::ProcessChunk(
int SqDist = (DifX - x) * (DifX - x) + (DifY - y) * (DifY - y) + (DifZ - z) * (DifZ - z);
if (4 * SqDist <= SqRad)
{
switch (cChunkDef::GetBlock(a_BlockTypes, x, y, z))
if (cBlockInfo::CanBeTerraformed(cChunkDef::GetBlock(a_BlockTypes, x, y, z)))
{
// Only carve out these specific block types
case E_BLOCK_DIRT:
case E_BLOCK_GRASS:
case E_BLOCK_STONE:
case E_BLOCK_COBBLESTONE:
case E_BLOCK_GRAVEL:
case E_BLOCK_SAND:
case E_BLOCK_SANDSTONE:
case E_BLOCK_SOULSAND:
case E_BLOCK_NETHERRACK:
case E_BLOCK_COAL_ORE:
case E_BLOCK_IRON_ORE:
case E_BLOCK_GOLD_ORE:
case E_BLOCK_DIAMOND_ORE:
case E_BLOCK_REDSTONE_ORE:
case E_BLOCK_REDSTONE_ORE_GLOWING:
{
cChunkDef::SetBlock(a_BlockTypes, x, y, z, E_BLOCK_AIR);
break;
}
default: break;
cChunkDef::SetBlock(a_BlockTypes, x, y, z, E_BLOCK_AIR);
}
}
} // for y

View File

@ -201,29 +201,11 @@ protected:
{
continue;
}
switch (a_ChunkDesc.GetBlockType(x, y, z))
if (cBlockInfo::CanBeTerraformed(a_ChunkDesc.GetBlockType(x, y, z)))
{
// Only carve out these specific block types
case E_BLOCK_DIRT:
case E_BLOCK_GRASS:
case E_BLOCK_STONE:
case E_BLOCK_COBBLESTONE:
case E_BLOCK_GRAVEL:
case E_BLOCK_SAND:
case E_BLOCK_SANDSTONE:
case E_BLOCK_NETHERRACK:
case E_BLOCK_COAL_ORE:
case E_BLOCK_IRON_ORE:
case E_BLOCK_GOLD_ORE:
case E_BLOCK_DIAMOND_ORE:
case E_BLOCK_REDSTONE_ORE:
case E_BLOCK_REDSTONE_ORE_GLOWING:
{
a_ChunkDesc.SetBlockType(x, y, z, E_BLOCK_AIR);
break;
}
default: break;
} // switch (BlockType)
a_ChunkDesc.SetBlockType(x, y, z, E_BLOCK_AIR);
}
} // for y
} // for x, z - a_BlockTypes
} // for itr - m_Points[]