From 85164fab8e5298ce1c0582b2aebb7e6a283d4a0c Mon Sep 17 00:00:00 2001 From: "madmaxoft@gmail.com" Date: Mon, 1 Oct 2012 21:08:15 +0000 Subject: Slight refactoring of BlockHandlers - dropping unneeded virtual functions ( http://forum.mc-server.org/showthread.php?tid=434&pid=4734#pid4734 ) git-svn-id: http://mc-server.googlecode.com/svn/trunk@917 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/Blocks/BlockOre.h | 96 +++++++++++++++++++++++++++++------------------- 1 file changed, 59 insertions(+), 37 deletions(-) (limited to 'source/Blocks/BlockOre.h') diff --git a/source/Blocks/BlockOre.h b/source/Blocks/BlockOre.h index 556a215ce..86688b761 100644 --- a/source/Blocks/BlockOre.h +++ b/source/Blocks/BlockOre.h @@ -1,9 +1,16 @@ + #pragma once + #include "BlockHandler.h" #include "../MersenneTwister.h" #include "../World.h" -class cBlockOreHandler : public cBlockHandler + + + + +class cBlockOreHandler : + public cBlockHandler { public: cBlockOreHandler(BLOCKTYPE a_BlockID) @@ -11,48 +18,63 @@ public: { } - virtual char GetDropCount() override + virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override { + short ItemType = E_ITEM_EMPTY; + char Count = 1; + short Meta = 0; + MTRand r1; - switch(m_BlockID) + switch (m_BlockID) { - case E_BLOCK_LAPIS_ORE: - return 4 + (char)r1.randInt(4); - case E_BLOCK_REDSTONE_ORE: - case E_BLOCK_REDSTONE_ORE_GLOWING: - return 4 + (char)r1.randInt(1); - default: - return 1; + case E_BLOCK_LAPIS_ORE: + { + ItemType = E_ITEM_DYE; + Count = 4 + (char)r1.randInt(4); + Meta = 4; + break; + } + case E_BLOCK_REDSTONE_ORE: + case E_BLOCK_REDSTONE_ORE_GLOWING: + { + Count = 4 + (char)r1.randInt(1); + break; + } + default: + { + Count = 1; + break; + } } - } - virtual NIBBLETYPE GetDropMeta(NIBBLETYPE a_Meta) override - { - switch(m_BlockID) + switch (m_BlockID) { - case E_BLOCK_LAPIS_ORE: - return 4; - default: - return 0; + case E_BLOCK_DIAMOND_ORE: + { + ItemType = E_ITEM_DIAMOND; + break; + } + case E_BLOCK_REDSTONE_ORE: + case E_BLOCK_REDSTONE_ORE_GLOWING: + { + ItemType = E_ITEM_REDSTONE_DUST; + break; + } + case E_BLOCK_EMERALD_ORE: + { + ItemType = E_ITEM_EMERALD; + break; + } + case E_BLOCK_COAL_ORE: + { + ItemType = E_ITEM_COAL; + break; + } } + a_Pickups.push_back(cItem(ItemType, Count, Meta)); } +} ; + + + - virtual int GetDropID() override - { - switch(m_BlockID) - { - case E_BLOCK_DIAMOND_ORE: - return E_ITEM_DIAMOND; - case E_BLOCK_REDSTONE_ORE: - case E_BLOCK_REDSTONE_ORE_GLOWING: - return E_ITEM_REDSTONE_DUST; - case E_BLOCK_EMERALD_ORE: - return E_ITEM_EMERALD; - case E_BLOCK_LAPIS_ORE: - return E_ITEM_DYE; - case E_BLOCK_COAL_ORE: - return E_ITEM_COAL; - } - return m_BlockID; - } -}; \ No newline at end of file -- cgit v1.2.3