diff options
author | Howaner <franzi.moos@googlemail.com> | 2014-02-28 15:26:32 +0100 |
---|---|---|
committer | Howaner <franzi.moos@googlemail.com> | 2014-02-28 15:26:32 +0100 |
commit | 66c84250410bf24bc689436c570c284bc47e3638 (patch) | |
tree | b0d9de1efb603c55c041505f6c12b7d5b092a846 /src/Blocks/BlockSlab.h | |
parent | Fixed crash and some warnings in map handling. (diff) | |
download | cuberite-66c84250410bf24bc689436c570c284bc47e3638.tar cuberite-66c84250410bf24bc689436c570c284bc47e3638.tar.gz cuberite-66c84250410bf24bc689436c570c284bc47e3638.tar.bz2 cuberite-66c84250410bf24bc689436c570c284bc47e3638.tar.lz cuberite-66c84250410bf24bc689436c570c284bc47e3638.tar.xz cuberite-66c84250410bf24bc689436c570c284bc47e3638.tar.zst cuberite-66c84250410bf24bc689436c570c284bc47e3638.zip |
Diffstat (limited to '')
-rw-r--r-- | src/Blocks/BlockSlab.h | 35 |
1 files changed, 23 insertions, 12 deletions
diff --git a/src/Blocks/BlockSlab.h b/src/Blocks/BlockSlab.h index 3628303ce..8a3c998ec 100644 --- a/src/Blocks/BlockSlab.h +++ b/src/Blocks/BlockSlab.h @@ -28,7 +28,7 @@ public: virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override { - a_Pickups.push_back(cItem(m_BlockType, 1, a_BlockMeta)); + a_Pickups.push_back(cItem(m_BlockType, 1, a_BlockMeta & 0x7)); } @@ -41,7 +41,7 @@ public: { a_BlockType = m_BlockType; BLOCKTYPE Type = (BLOCKTYPE) (a_Player->GetEquippedItem().m_ItemType); - NIBBLETYPE Meta = (NIBBLETYPE)(a_Player->GetEquippedItem().m_ItemDamage & 0x07); + NIBBLETYPE Meta = (NIBBLETYPE) a_Player->GetEquippedItem().m_ItemDamage; // HandlePlaceBlock wants a cItemHandler pointer thing, so let's give it one cItemHandler * ItemHandler = cItemHandler::GetItemHandler(GetDoubleSlabType(Type)); @@ -159,21 +159,32 @@ public: virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override { - if (m_BlockType == E_BLOCK_DOUBLE_STONE_SLAB) - { - m_BlockType = E_BLOCK_STONE_SLAB; - } - else + BLOCKTYPE Block = GetSingleSlabType(m_BlockType); + a_Pickups.push_back(cItem(Block, 2, a_BlockMeta & 0x7)); + } + + inline static BLOCKTYPE GetSingleSlabType(BLOCKTYPE a_BlockType) + { + switch (a_BlockType) { - m_BlockType = E_BLOCK_WOODEN_SLAB; + case E_BLOCK_DOUBLE_STONE_SLAB: return E_BLOCK_STONE_SLAB; + case E_BLOCK_DOUBLE_WOODEN_SLAB: return E_BLOCK_WOODEN_SLAB; } - a_Pickups.push_back(cItem(m_BlockType, 2, a_BlockMeta)); + ASSERT(!"Unhandled double slab type!"); + return a_BlockType; } - virtual const char * GetStepSound(void) override - { - return ((m_BlockType == E_BLOCK_DOUBLE_WOODEN_SLAB) || (m_BlockType == E_BLOCK_DOUBLE_WOODEN_SLAB)) ? "step.wood" : "step.stone"; + { + BLOCKTYPE Block = GetSingleSlabType(m_BlockType); + if (Block != m_BlockType) + { + return cBlockHandler::GetBlockHandler(Block)->GetStepSound(); + } + else + { + return "step.stone"; + } } } ; |