From 62abd8f29bbaec6da00b277d0bf4ced54ccab921 Mon Sep 17 00:00:00 2001 From: "lapayo94@gmail.com" Date: Sun, 25 Dec 2011 17:47:01 +0000 Subject: =?UTF-8?q?-=20Implemented=20function=20to=20check=20item=20catego?= =?UTF-8?q?ry=20-=20(Cobble-)stone=20don=C2=B4t=20drop=20item=20anymore=20?= =?UTF-8?q?if=20mined=20without=20pickaxe=20-=20FluidSimulator=20no=20long?= =?UTF-8?q?er=20causes=20compiler=20warning=20-=20Glowstone=20drops=20fixe?= =?UTF-8?q?d?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: http://mc-server.googlecode.com/svn/trunk@109 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/Defines.h | 32 ++++++++++++++++++++++++++++++++ source/cBlockToPickup.cpp | 10 +++++++++- source/cFluidSimulator.cpp | 3 ++- 3 files changed, 43 insertions(+), 2 deletions(-) (limited to 'source') diff --git a/source/Defines.h b/source/Defines.h index 838eb1340..fb76c5bc7 100644 --- a/source/Defines.h +++ b/source/Defines.h @@ -140,3 +140,35 @@ inline float GetSpecialSignf( float a_Val ) { return (a_Val <= 0.f)?-1.f:1.f; } + + + +namespace ItemCategory +{ + inline bool IsPickaxe(ENUM_ITEM_ID a_ItemID) + { + return a_ItemID == E_ITEM_WOODEN_PICKAXE + || a_ItemID == E_ITEM_STONE_PICKAXE + || a_ItemID == E_ITEM_IRON_PICKAXE + || a_ItemID == E_ITEM_GOLD_PICKAXE + || a_ItemID == E_ITEM_DIAMOND_PICKAXE; + } + + inline bool IsAxe(ENUM_ITEM_ID a_ItemID) + { + return a_ItemID == E_ITEM_WOODEN_AXE + || a_ItemID == E_ITEM_STONE_AXE + || a_ItemID == E_ITEM_IRON_AXE + || a_ItemID == E_ITEM_GOLD_AXE + || a_ItemID == E_ITEM_DIAMOND_AXE; + } + + inline bool IsSword(ENUM_ITEM_ID a_ItemID) + { + return a_ItemID == E_ITEM_WOODEN_SWORD + || a_ItemID == E_ITEM_STONE_SWORD + || a_ItemID == E_ITEM_IRON_SWORD + || a_ItemID == E_ITEM_GOLD_SWORD + || a_ItemID == E_ITEM_DIAMOND_SWORD; + } +} \ No newline at end of file diff --git a/source/cBlockToPickup.cpp b/source/cBlockToPickup.cpp index c0597d005..fb7a898ae 100644 --- a/source/cBlockToPickup.cpp +++ b/source/cBlockToPickup.cpp @@ -1,4 +1,5 @@ #include "cBlockToPickup.h" +#include "Defines.h" #include "BlockID.h" #include "stdlib.h" @@ -10,8 +11,11 @@ ENUM_ITEM_ID cBlockToPickup::ToPickup( unsigned char a_BlockID, ENUM_ITEM_ID a_U { case E_BLOCK_AIR: return E_ITEM_EMPTY; + case E_BLOCK_COBBLESTONE: case E_BLOCK_STONE: - return E_ITEM_COBBLESTONE; + if(ItemCategory::IsPickaxe(a_UsedItemID)) + return E_ITEM_COBBLESTONE; + return E_ITEM_EMPTY; case E_BLOCK_GRASS: return E_ITEM_DIRT; case E_BLOCK_GLASS: @@ -54,6 +58,8 @@ ENUM_ITEM_ID cBlockToPickup::ToPickup( unsigned char a_BlockID, ENUM_ITEM_ID a_U return E_ITEM_WOODEN_DOOR; case E_BLOCK_IRON_DOOR: return E_ITEM_IRON_DOOR; + case E_BLOCK_GLOWSTONE: + return E_ITEM_GLOWSTONE_DUST; default: return (ENUM_ITEM_ID)a_BlockID; } @@ -66,6 +72,8 @@ char cBlockToPickup::PickupCount(unsigned char a_BlockID) case E_BLOCK_REDSTONE_ORE_GLOWING: case E_BLOCK_REDSTONE_ORE: return rand() % 2 + 4; + case E_BLOCK_GLOWSTONE: + return rand() % 3 + 2; case E_BLOCK_MELON: return rand() % 8 + 3; case E_BLOCK_LAPIS_ORE: diff --git a/source/cFluidSimulator.cpp b/source/cFluidSimulator.cpp index acbb19f56..6eb5dbb0a 100644 --- a/source/cFluidSimulator.cpp +++ b/source/cFluidSimulator.cpp @@ -73,8 +73,9 @@ public: cFluidSimulator::cFluidSimulator( cWorld* a_World ) : m_World(a_World) - , m_Data(new FluidData(a_World, this)) + , m_Data(0) { + m_Data = new FluidData(a_World, this); } cFluidSimulator::~cFluidSimulator() -- cgit v1.2.3