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/BlockHandler.cpp | 59 ++++++++++++------------------------------ 1 file changed, 16 insertions(+), 43 deletions(-) (limited to 'source/Blocks/BlockHandler.cpp') diff --git a/source/Blocks/BlockHandler.cpp b/source/Blocks/BlockHandler.cpp index 419b20de0..ae138db92 100644 --- a/source/Blocks/BlockHandler.cpp +++ b/source/Blocks/BlockHandler.cpp @@ -317,43 +317,24 @@ void cBlockHandler::PlaceBlock(cWorld *a_World, cPlayer *a_Player, NIBBLETYPE a_ -char cBlockHandler::GetDropCount() +void cBlockHandler::ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) { - return 1; + // Setting the meta to a_BlockMeta keeps most textures. The few other blocks have to override this. + a_Pickups.push_back(cItem(m_BlockID, 1, a_BlockMeta)); } -int cBlockHandler::GetDropID() +void cBlockHandler::DropBlock(cWorld * a_World, int a_X, int a_Y, int a_Z) { - return m_BlockID; -} - - - - - -NIBBLETYPE cBlockHandler::GetDropMeta(NIBBLETYPE a_BlockMeta) -{ - return a_BlockMeta; //This keeps most textures. The few other blocks have to override this -} - - - - - -void cBlockHandler::DropBlock(cWorld *a_World, int a_X, int a_Y, int a_Z) -{ - cItems Drops; + cItems Pickups; NIBBLETYPE Meta = a_World->GetBlockMeta(a_X, a_Y, a_Z); - char DropCount = GetDropCount(); - short DropItem = (short)GetDropID(); - if (DropCount > 0 && (DropItem != E_ITEM_EMPTY)) + ConvertToPickups(Pickups, Meta); + if (!Pickups.empty()) { - Drops.push_back(cItem(DropItem, DropCount, GetDropMeta(Meta))); - a_World->SpawnItemPickups(Drops, a_X, a_Y, a_Z); + a_World->SpawnItemPickups(Pickups, a_X, a_Y, a_Z); } } @@ -361,7 +342,8 @@ void cBlockHandler::DropBlock(cWorld *a_World, int a_X, int a_Y, int a_Z) -AString cBlockHandler::GetStepSound() { +const char * cBlockHandler::GetStepSound() +{ return "step.stone"; } @@ -396,7 +378,7 @@ bool cBlockHandler::IsUseable() -bool cBlockHandler::IsClickedThrough() +bool cBlockHandler::IsClickedThrough(void) { return false; } @@ -405,25 +387,16 @@ bool cBlockHandler::IsClickedThrough() -bool cBlockHandler::IgnoreBuildCollision() +bool cBlockHandler::DoesIgnoreBuildCollision(void) { - return m_BlockID == E_BLOCK_AIR; -} - - - - - -bool cBlockHandler::NeedsRandomTicks() -{ - return false; + return (m_BlockID == E_BLOCK_AIR); } -bool cBlockHandler::AllowBlockOnTop() +bool cBlockHandler::DoesAllowBlockOnTop(void) { return true; } @@ -432,7 +405,7 @@ bool cBlockHandler::AllowBlockOnTop() -bool cBlockHandler::CanBePlacedOnSide() +bool cBlockHandler::CanBePlacedOnSide(void) { return true; } @@ -441,7 +414,7 @@ bool cBlockHandler::CanBePlacedOnSide() -bool cBlockHandler::DropOnUnsuitable() +bool cBlockHandler::DoesDropOnUnsuitable(void) { return true; } -- cgit v1.2.3