From 3ee523628465a59070354781cda6585f6778192c Mon Sep 17 00:00:00 2001 From: "madmaxoft@gmail.com" Date: Tue, 4 Jun 2013 19:22:14 +0000 Subject: Removed cLadder, cSign, cStairs, cTorch and cVine classes, moved their functionality into the appropriate BlockHandlers / ItemHandlers git-svn-id: http://mc-server.googlecode.com/svn/trunk@1555 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/AllToLua.pkg | 5 - source/Bindings.cpp | 285 +++------------------------------ source/Bindings.h | 2 +- source/Blocks/BlockBed.h | 21 +-- source/Blocks/BlockLadder.h | 33 +++- source/Blocks/BlockRedstone.cpp | 1 - source/Blocks/BlockRedstoneTorch.h | 1 - source/Blocks/BlockSign.h | 32 +++- source/Blocks/BlockStairs.h | 30 +++- source/Blocks/BlockTorch.h | 67 +++++++- source/Blocks/BlockVine.h | 31 +++- source/Chunk.cpp | 2 - source/ClientHandle.cpp | 4 - source/Enchantments.h | 4 +- source/Items/ItemSign.h | 6 +- source/Ladder.h | 43 ----- source/Sign.h | 44 ----- source/Simulator/RedstoneSimulator.cpp | 4 +- source/Stairs.h | 44 ----- source/Torch.h | 77 --------- source/Vine.h | 42 ----- 21 files changed, 218 insertions(+), 560 deletions(-) delete mode 100644 source/Ladder.h delete mode 100644 source/Sign.h delete mode 100644 source/Stairs.h delete mode 100644 source/Torch.h delete mode 100644 source/Vine.h (limited to 'source') diff --git a/source/AllToLua.pkg b/source/AllToLua.pkg index ee098e63e..f36443329 100644 --- a/source/AllToLua.pkg +++ b/source/AllToLua.pkg @@ -15,11 +15,6 @@ typedef unsigned short UInt16; $cfile "ChunkDef.h" -$cfile "Torch.h" -$cfile "Stairs.h" -$cfile "Ladder.h" -$cfile "Vine.h" - $cfile "../iniFile/iniFile.h" $cfile "BlockID.h" diff --git a/source/Bindings.cpp b/source/Bindings.cpp index 5f0ae7159..bd4abb140 100644 --- a/source/Bindings.cpp +++ b/source/Bindings.cpp @@ -1,6 +1,6 @@ /* ** Lua binding: AllToLua -** Generated automatically by tolua++-1.0.92 on 06/04/13 13:50:42. +** Generated automatically by tolua++-1.0.92 on 06/04/13 21:16:57. */ #ifndef __cplusplus @@ -16,10 +16,6 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S); #include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules #include "tolua_base.h" #include "ChunkDef.h" -#include "Torch.h" -#include "Stairs.h" -#include "Ladder.h" -#include "Vine.h" #include "../iniFile/iniFile.h" #include "BlockID.h" #include "Defines.h" @@ -190,10 +186,8 @@ static int tolua_collect_Vector3d (lua_State* tolua_S) static void tolua_reg_types (lua_State* tolua_S) { tolua_usertype(tolua_S,"TakeDamageInfo"); - tolua_usertype(tolua_S,"cCraftingGrid"); tolua_usertype(tolua_S,"cCraftingRecipe"); - tolua_usertype(tolua_S,"cPlugin"); - tolua_usertype(tolua_S,"cWindow"); + tolua_usertype(tolua_S,"cEntity"); tolua_usertype(tolua_S,"cStringMap"); tolua_usertype(tolua_S,"cItemGrid"); tolua_usertype(tolua_S,"cBlockArea"); @@ -201,265 +195,53 @@ static void tolua_reg_types (lua_State* tolua_S) tolua_usertype(tolua_S,"cLuaWindow"); tolua_usertype(tolua_S,"cInventory"); tolua_usertype(tolua_S,"cRoot"); - tolua_usertype(tolua_S,"cStairs"); - tolua_usertype(tolua_S,"cGroup"); - tolua_usertype(tolua_S,"cTracer"); - tolua_usertype(tolua_S,"cCuboid"); + tolua_usertype(tolua_S,"cWindow"); + tolua_usertype(tolua_S,"cCraftingGrid"); tolua_usertype(tolua_S,"cPickup"); tolua_usertype(tolua_S,"cItems"); - tolua_usertype(tolua_S,"Vector3i"); + tolua_usertype(tolua_S,"cGroup"); tolua_usertype(tolua_S,"cClientHandle"); tolua_usertype(tolua_S,"cChunkDesc"); tolua_usertype(tolua_S,"cFurnaceRecipe"); - tolua_usertype(tolua_S,"Lua__cPickup"); + tolua_usertype(tolua_S,"cTracer"); tolua_usertype(tolua_S,"cChatColor"); - tolua_usertype(tolua_S,"cWebAdmin"); - tolua_usertype(tolua_S,"cCraftingRecipes"); + tolua_usertype(tolua_S,"cCuboid"); + tolua_usertype(tolua_S,"Vector3i"); tolua_usertype(tolua_S,"Lua__cWebPlugin"); tolua_usertype(tolua_S,"Lua__cPawn"); - tolua_usertype(tolua_S,"cGroupManager"); + tolua_usertype(tolua_S,"cPlugin_NewLua"); tolua_usertype(tolua_S,"cItem"); tolua_usertype(tolua_S,"Vector3f"); - tolua_usertype(tolua_S,"cWebPlugin"); + tolua_usertype(tolua_S,"cWebAdmin"); tolua_usertype(tolua_S,"cDropSpenserEntity"); tolua_usertype(tolua_S,"Lua__cPlayer"); - tolua_usertype(tolua_S,"HTTPRequest"); + tolua_usertype(tolua_S,"cCraftingRecipes"); tolua_usertype(tolua_S,"cChestEntity"); tolua_usertype(tolua_S,"cDispenserEntity"); - tolua_usertype(tolua_S,"HTTPFormData"); - tolua_usertype(tolua_S,"cBlockEntity"); tolua_usertype(tolua_S,"cItemGrid::cListener"); + tolua_usertype(tolua_S,"cBlockEntity"); + tolua_usertype(tolua_S,"cCriticalSection"); + tolua_usertype(tolua_S,"Lua__cPickup"); + tolua_usertype(tolua_S,"cWebPlugin"); + tolua_usertype(tolua_S,"HTTPRequest"); + tolua_usertype(tolua_S,"HTTPFormData"); tolua_usertype(tolua_S,"cDropperEntity"); - tolua_usertype(tolua_S,"cServer"); tolua_usertype(tolua_S,"cPluginManager"); - tolua_usertype(tolua_S,"cBlockEntityWithItems"); - tolua_usertype(tolua_S,"cLadder"); - tolua_usertype(tolua_S,"cCriticalSection"); - tolua_usertype(tolua_S,"cEntity"); + tolua_usertype(tolua_S,"cWorld"); tolua_usertype(tolua_S,"cIniFile"); - tolua_usertype(tolua_S,"cListeners"); + tolua_usertype(tolua_S,"cPlugin"); tolua_usertype(tolua_S,"AStringVector"); - tolua_usertype(tolua_S,"cVine"); + tolua_usertype(tolua_S,"cPawn"); tolua_usertype(tolua_S,"cPlayer"); - tolua_usertype(tolua_S,"cTorch"); + tolua_usertype(tolua_S,"cGroupManager"); tolua_usertype(tolua_S,"cBlockEntityWindowOwner"); - tolua_usertype(tolua_S,"cWorld"); - tolua_usertype(tolua_S,"cPlugin_NewLua"); - tolua_usertype(tolua_S,"cPawn"); + tolua_usertype(tolua_S,"cBlockEntityWithItems"); + tolua_usertype(tolua_S,"cServer"); + tolua_usertype(tolua_S,"cListeners"); tolua_usertype(tolua_S,"Lua__cEntity"); tolua_usertype(tolua_S,"Vector3d"); } -/* method: DirectionToMetaData of class cTorch */ -#ifndef TOLUA_DISABLE_tolua_AllToLua_cTorch_DirectionToMetaData00 -static int tolua_AllToLua_cTorch_DirectionToMetaData00(lua_State* tolua_S) -{ -#ifndef TOLUA_RELEASE - tolua_Error tolua_err; - if ( - !tolua_isusertable(tolua_S,1,"cTorch",0,&tolua_err) || - !tolua_isnumber(tolua_S,2,0,&tolua_err) || - !tolua_isnoobj(tolua_S,3,&tolua_err) - ) - goto tolua_lerror; - else -#endif - { - char a_Direction = ((char) tolua_tonumber(tolua_S,2,0)); - { - char tolua_ret = (char) cTorch::DirectionToMetaData(a_Direction); - tolua_pushnumber(tolua_S,(lua_Number)tolua_ret); - } - } - return 1; -#ifndef TOLUA_RELEASE - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'DirectionToMetaData'.",&tolua_err); - return 0; -#endif -} -#endif //#ifndef TOLUA_DISABLE - -/* method: MetaDataToDirection of class cTorch */ -#ifndef TOLUA_DISABLE_tolua_AllToLua_cTorch_MetaDataToDirection00 -static int tolua_AllToLua_cTorch_MetaDataToDirection00(lua_State* tolua_S) -{ -#ifndef TOLUA_RELEASE - tolua_Error tolua_err; - if ( - !tolua_isusertable(tolua_S,1,"cTorch",0,&tolua_err) || - !tolua_isnumber(tolua_S,2,0,&tolua_err) || - !tolua_isnoobj(tolua_S,3,&tolua_err) - ) - goto tolua_lerror; - else -#endif - { - char a_MetaData = ((char) tolua_tonumber(tolua_S,2,0)); - { - char tolua_ret = (char) cTorch::MetaDataToDirection(a_MetaData); - tolua_pushnumber(tolua_S,(lua_Number)tolua_ret); - } - } - return 1; -#ifndef TOLUA_RELEASE - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'MetaDataToDirection'.",&tolua_err); - return 0; -#endif -} -#endif //#ifndef TOLUA_DISABLE - -/* method: RotationToMetaData of class cStairs */ -#ifndef TOLUA_DISABLE_tolua_AllToLua_cStairs_RotationToMetaData00 -static int tolua_AllToLua_cStairs_RotationToMetaData00(lua_State* tolua_S) -{ -#ifndef TOLUA_RELEASE - tolua_Error tolua_err; - if ( - !tolua_isusertable(tolua_S,1,"cStairs",0,&tolua_err) || - !tolua_isnumber(tolua_S,2,0,&tolua_err) || - !tolua_isnoobj(tolua_S,3,&tolua_err) - ) - goto tolua_lerror; - else -#endif - { - double a_Rotation = ((double) tolua_tonumber(tolua_S,2,0)); - { - unsigned char tolua_ret = (unsigned char) cStairs::RotationToMetaData(a_Rotation); - tolua_pushnumber(tolua_S,(lua_Number)tolua_ret); - } - } - return 1; -#ifndef TOLUA_RELEASE - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'RotationToMetaData'.",&tolua_err); - return 0; -#endif -} -#endif //#ifndef TOLUA_DISABLE - -/* method: DirectionToMetaData of class cLadder */ -#ifndef TOLUA_DISABLE_tolua_AllToLua_cLadder_DirectionToMetaData00 -static int tolua_AllToLua_cLadder_DirectionToMetaData00(lua_State* tolua_S) -{ -#ifndef TOLUA_RELEASE - tolua_Error tolua_err; - if ( - !tolua_isusertable(tolua_S,1,"cLadder",0,&tolua_err) || - !tolua_isnumber(tolua_S,2,0,&tolua_err) || - !tolua_isnoobj(tolua_S,3,&tolua_err) - ) - goto tolua_lerror; - else -#endif - { - char a_Direction = ((char) tolua_tonumber(tolua_S,2,0)); - { - char tolua_ret = (char) cLadder::DirectionToMetaData(a_Direction); - tolua_pushnumber(tolua_S,(lua_Number)tolua_ret); - } - } - return 1; -#ifndef TOLUA_RELEASE - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'DirectionToMetaData'.",&tolua_err); - return 0; -#endif -} -#endif //#ifndef TOLUA_DISABLE - -/* method: MetaDataToDirection of class cLadder */ -#ifndef TOLUA_DISABLE_tolua_AllToLua_cLadder_MetaDataToDirection00 -static int tolua_AllToLua_cLadder_MetaDataToDirection00(lua_State* tolua_S) -{ -#ifndef TOLUA_RELEASE - tolua_Error tolua_err; - if ( - !tolua_isusertable(tolua_S,1,"cLadder",0,&tolua_err) || - !tolua_isnumber(tolua_S,2,0,&tolua_err) || - !tolua_isnoobj(tolua_S,3,&tolua_err) - ) - goto tolua_lerror; - else -#endif - { - char a_MetaData = ((char) tolua_tonumber(tolua_S,2,0)); - { - char tolua_ret = (char) cLadder::MetaDataToDirection(a_MetaData); - tolua_pushnumber(tolua_S,(lua_Number)tolua_ret); - } - } - return 1; -#ifndef TOLUA_RELEASE - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'MetaDataToDirection'.",&tolua_err); - return 0; -#endif -} -#endif //#ifndef TOLUA_DISABLE - -/* method: DirectionToMetaData of class cVine */ -#ifndef TOLUA_DISABLE_tolua_AllToLua_cVine_DirectionToMetaData00 -static int tolua_AllToLua_cVine_DirectionToMetaData00(lua_State* tolua_S) -{ -#ifndef TOLUA_RELEASE - tolua_Error tolua_err; - if ( - !tolua_isusertable(tolua_S,1,"cVine",0,&tolua_err) || - !tolua_isnumber(tolua_S,2,0,&tolua_err) || - !tolua_isnoobj(tolua_S,3,&tolua_err) - ) - goto tolua_lerror; - else -#endif - { - char a_BlockFace = ((char) tolua_tonumber(tolua_S,2,0)); - { - unsigned char tolua_ret = (unsigned char) cVine::DirectionToMetaData(a_BlockFace); - tolua_pushnumber(tolua_S,(lua_Number)tolua_ret); - } - } - return 1; -#ifndef TOLUA_RELEASE - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'DirectionToMetaData'.",&tolua_err); - return 0; -#endif -} -#endif //#ifndef TOLUA_DISABLE - -/* method: MetaDataToDirection of class cVine */ -#ifndef TOLUA_DISABLE_tolua_AllToLua_cVine_MetaDataToDirection00 -static int tolua_AllToLua_cVine_MetaDataToDirection00(lua_State* tolua_S) -{ -#ifndef TOLUA_RELEASE - tolua_Error tolua_err; - if ( - !tolua_isusertable(tolua_S,1,"cVine",0,&tolua_err) || - !tolua_isnumber(tolua_S,2,0,&tolua_err) || - !tolua_isnoobj(tolua_S,3,&tolua_err) - ) - goto tolua_lerror; - else -#endif - { - unsigned char a_MetaData = (( unsigned char) tolua_tonumber(tolua_S,2,0)); - { - char tolua_ret = (char) cVine::MetaDataToDirection(a_MetaData); - tolua_pushnumber(tolua_S,(lua_Number)tolua_ret); - } - } - return 1; -#ifndef TOLUA_RELEASE - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'MetaDataToDirection'.",&tolua_err); - return 0; -#endif -} -#endif //#ifndef TOLUA_DISABLE - /* method: new of class cIniFile */ #ifndef TOLUA_DISABLE_tolua_AllToLua_cIniFile_new00 static int tolua_AllToLua_cIniFile_new00(lua_State* tolua_S) @@ -26656,25 +26438,6 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S) tolua_constant(tolua_S,"biJungleHills",biJungleHills); tolua_constant(tolua_S,"biNumBiomes",biNumBiomes); tolua_constant(tolua_S,"biMaxBiome",biMaxBiome); - tolua_cclass(tolua_S,"cTorch","cTorch","",NULL); - tolua_beginmodule(tolua_S,"cTorch"); - tolua_function(tolua_S,"DirectionToMetaData",tolua_AllToLua_cTorch_DirectionToMetaData00); - tolua_function(tolua_S,"MetaDataToDirection",tolua_AllToLua_cTorch_MetaDataToDirection00); - tolua_endmodule(tolua_S); - tolua_cclass(tolua_S,"cStairs","cStairs","",NULL); - tolua_beginmodule(tolua_S,"cStairs"); - tolua_function(tolua_S,"RotationToMetaData",tolua_AllToLua_cStairs_RotationToMetaData00); - tolua_endmodule(tolua_S); - tolua_cclass(tolua_S,"cLadder","cLadder","",NULL); - tolua_beginmodule(tolua_S,"cLadder"); - tolua_function(tolua_S,"DirectionToMetaData",tolua_AllToLua_cLadder_DirectionToMetaData00); - tolua_function(tolua_S,"MetaDataToDirection",tolua_AllToLua_cLadder_MetaDataToDirection00); - tolua_endmodule(tolua_S); - tolua_cclass(tolua_S,"cVine","cVine","",NULL); - tolua_beginmodule(tolua_S,"cVine"); - tolua_function(tolua_S,"DirectionToMetaData",tolua_AllToLua_cVine_DirectionToMetaData00); - tolua_function(tolua_S,"MetaDataToDirection",tolua_AllToLua_cVine_MetaDataToDirection00); - tolua_endmodule(tolua_S); #ifdef __cplusplus tolua_cclass(tolua_S,"cIniFile","cIniFile","",tolua_collect_cIniFile); #else diff --git a/source/Bindings.h b/source/Bindings.h index f5b824121..9ef96eb40 100644 --- a/source/Bindings.h +++ b/source/Bindings.h @@ -1,6 +1,6 @@ /* ** Lua binding: AllToLua -** Generated automatically by tolua++-1.0.92 on 06/04/13 13:50:43. +** Generated automatically by tolua++-1.0.92 on 06/04/13 21:16:57. */ /* Exported function */ diff --git a/source/Blocks/BlockBed.h b/source/Blocks/BlockBed.h index ab55ffc92..bf8906750 100644 --- a/source/Blocks/BlockBed.h +++ b/source/Blocks/BlockBed.h @@ -3,7 +3,6 @@ #include "BlockHandler.h" #include "../World.h" -#include "../Sign.h" #include "../Player.h" @@ -44,13 +43,11 @@ public: } - - // Bed specific helper functions static NIBBLETYPE RotationToMetaData(double a_Rotation) { - a_Rotation += 180 + (180/4); // So its not aligned with axis - if( a_Rotation > 360 ) a_Rotation -= 360; + a_Rotation += 180 + (180 / 4); // So its not aligned with axis + if (a_Rotation > 360) a_Rotation -= 360; a_Rotation = (a_Rotation / 360) * 4; @@ -62,15 +59,11 @@ public: { switch (a_MetaData) { - case 0: // south +z - return Vector3i(0, 0, 1); - case 1: // west -x - return Vector3i(-1, 0, 0); - case 2: // north -z - return Vector3i(0, 0, -1); - case 3: // east +x - return Vector3i(1, 0, 0); - }; + case 0: return Vector3i(0, 0, 1); + case 1: return Vector3i(-1, 0, 0); + case 2: return Vector3i(0, 0, -1); + case 3: return Vector3i(1, 0, 0); + } return Vector3i(); } } ; diff --git a/source/Blocks/BlockLadder.h b/source/Blocks/BlockLadder.h index 280f0deb1..93473f757 100644 --- a/source/Blocks/BlockLadder.h +++ b/source/Blocks/BlockLadder.h @@ -3,7 +3,6 @@ #include "BlockHandler.h" #include "../World.h" -#include "../Ladder.h" @@ -37,11 +36,37 @@ public: } a_BlockType = m_BlockType; - a_BlockMeta = cLadder::DirectionToMetaData(a_BlockFace); + a_BlockMeta = DirectionToMetaData(a_BlockFace); return true; } + static NIBBLETYPE DirectionToMetaData(char a_Direction) // tolua_export + { // tolua_export + switch (a_Direction) + { + case 0x2: return 0x2; + case 0x3: return 0x3; + case 0x4: return 0x4; + case 0x5: return 0x5; + default: return 0x2; + } + } // tolua_export + + + static char MetaDataToDirection(NIBBLETYPE a_MetaData) // tolua_export + { // tolua_export + switch (a_MetaData) + { + case 0x2: return 0x2; + case 0x3: return 0x3; + case 0x4: return 0x4; + case 0x5: return 0x5; + default: return 0x2; + } + } // tolua_export + + /// Finds a suitable Direction for the Ladder. Returns BLOCK_FACE_BOTTOM on failure static char FindSuitableBlockFace(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ) { @@ -71,8 +96,8 @@ public: virtual bool CanBeAt(int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override { - // TODO: Use cTorch::AdjustCoordsByMeta(), then cChunk::UnboundedRelGetBlock() and finally some comparison - char BlockFace = cLadder::MetaDataToDirection(a_Chunk.GetMeta(a_RelX, a_RelY, a_RelZ)); + // TODO: Use AdjustCoordsByMeta(), then cChunk::UnboundedRelGetBlock() and finally some comparison + char BlockFace = MetaDataToDirection(a_Chunk.GetMeta(a_RelX, a_RelY, a_RelZ)); int BlockX = a_RelX + a_Chunk.GetPosX() * cChunkDef::Width; int BlockZ = a_RelZ + a_Chunk.GetPosZ() * cChunkDef::Width; return LadderCanBePlacedAt(a_Chunk.GetWorld(), BlockX, a_RelY, BlockZ, BlockFace); diff --git a/source/Blocks/BlockRedstone.cpp b/source/Blocks/BlockRedstone.cpp index ec54169c0..f433be4ef 100644 --- a/source/Blocks/BlockRedstone.cpp +++ b/source/Blocks/BlockRedstone.cpp @@ -3,7 +3,6 @@ #include "BlockRedstone.h" #include "../Item.h" #include "../World.h" -#include "../Torch.h" diff --git a/source/Blocks/BlockRedstoneTorch.h b/source/Blocks/BlockRedstoneTorch.h index 0127dc082..c8256ce64 100644 --- a/source/Blocks/BlockRedstoneTorch.h +++ b/source/Blocks/BlockRedstoneTorch.h @@ -3,7 +3,6 @@ #include "BlockRedstone.h" #include "BlockTorch.h" -#include "../Torch.h" diff --git a/source/Blocks/BlockSign.h b/source/Blocks/BlockSign.h index 23645d0d2..4bdccb47e 100644 --- a/source/Blocks/BlockSign.h +++ b/source/Blocks/BlockSign.h @@ -3,7 +3,6 @@ #include "BlockHandler.h" #include "../World.h" -#include "../Sign.h" #include "../Player.h" @@ -36,6 +35,37 @@ public: { return "step.wood"; } + + + static char RotationToMetaData(double a_Rotation) + { + a_Rotation += 180 + (180 / 16); // So it's not aligned with axis + if (a_Rotation > 360) + { + a_Rotation -= 360; + } + + a_Rotation = (a_Rotation / 360) * 16; + + return ((char)a_Rotation) % 16; + } + + + static char DirectionToMetaData(char a_Direction) + { + switch (a_Direction) + { + case 0x2: return 0x2; + case 0x3: return 0x3; + case 0x4: return 0x4; + case 0x5: return 0x5; + default: + { + break; + } + } + return 0x2; + } } ; diff --git a/source/Blocks/BlockStairs.h b/source/Blocks/BlockStairs.h index c85d07c00..6fc316e45 100644 --- a/source/Blocks/BlockStairs.h +++ b/source/Blocks/BlockStairs.h @@ -2,7 +2,6 @@ #pragma once #include "BlockHandler.h" -#include "../Stairs.h" @@ -27,7 +26,7 @@ public: ) override { a_BlockType = m_BlockType; - a_BlockMeta = cStairs::RotationToMetaData(a_Player->GetRotation()); + a_BlockMeta = RotationToMetaData(a_Player->GetRotation()); switch (a_BlockFace) { case BLOCK_FACE_TOP: break; @@ -51,6 +50,33 @@ public: // TODO: step sound + static NIBBLETYPE RotationToMetaData(double a_Rotation) + { + a_Rotation += 90 + 45; // So its not aligned with axis + NIBBLETYPE result = 0x0; + if (a_Rotation > 360) + { + a_Rotation -= 360; + } + if ((a_Rotation >= 0) && (a_Rotation < 90)) + { + return 0x0; + } + else if ((a_Rotation >= 180) && (a_Rotation < 270)) + { + return 0x1; + } + else if ((a_Rotation >= 90) && (a_Rotation < 180)) + { + return 0x2; + } + else + { + return 0x3; + } + } + + virtual NIBBLETYPE MetaRotateCCW(NIBBLETYPE a_Meta) override { // Bits 3 and 4 stay, the rest is swapped around according to a table: diff --git a/source/Blocks/BlockTorch.h b/source/Blocks/BlockTorch.h index 97e31533b..9951b8ea4 100644 --- a/source/Blocks/BlockTorch.h +++ b/source/Blocks/BlockTorch.h @@ -2,7 +2,6 @@ #pragma once #include "BlockHandler.h" -#include "../Torch.h" #include "../World.h" @@ -37,11 +36,71 @@ public: } } a_BlockType = m_BlockType; - a_BlockMeta = cTorch::DirectionToMetaData(a_BlockFace); + a_BlockMeta = DirectionToMetaData(a_BlockFace); return true; } + static NIBBLETYPE DirectionToMetaData(char a_Direction) // tolua_export + { // tolua_export + switch (a_Direction) + { + case BLOCK_FACE_BOTTOM: ASSERT(!"Shouldn't be getting this face"); return 0; + case BLOCK_FACE_TOP: return E_META_TORCH_FLOOR; + case BLOCK_FACE_EAST: return E_META_TORCH_EAST; + case BLOCK_FACE_WEST: return E_META_TORCH_WEST; + case BLOCK_FACE_NORTH: return E_META_TORCH_NORTH; + case BLOCK_FACE_SOUTH: return E_META_TORCH_SOUTH; + default: + { + ASSERT(!"Unhandled torch direction!"); + break; + } + }; + return 0x0; + } // tolua_export + + + static char MetaDataToDirection(NIBBLETYPE a_MetaData) // tolua_export + { // tolua_export + switch (a_MetaData) + { + case 0: return BLOCK_FACE_TOP; // by default, the torches stand on the ground + case E_META_TORCH_FLOOR: return BLOCK_FACE_TOP; + case E_META_TORCH_EAST: return BLOCK_FACE_EAST; + case E_META_TORCH_WEST: return BLOCK_FACE_WEST; + case E_META_TORCH_NORTH: return BLOCK_FACE_NORTH; + case E_META_TORCH_SOUTH: return BLOCK_FACE_SOUTH; + default: + { + ASSERT(!"Unhandled torch metadata"); + break; + } + } + return 0; + } // tolua_export + + + static bool IsAttachedTo(const Vector3i & a_TorchPos, char a_TorchMeta, const Vector3i & a_BlockPos) + { + switch (a_TorchMeta) + { + case 0x0: + case E_META_TORCH_FLOOR: return ((a_TorchPos - a_BlockPos).Equals(Vector3i(0, 1, 0))); + case E_META_TORCH_EAST: return ((a_TorchPos - a_BlockPos).Equals(Vector3i(0, 0, -1))); + case E_META_TORCH_WEST: return ((a_TorchPos - a_BlockPos).Equals(Vector3i(0, 0, 1))); + case E_META_TORCH_NORTH: return ((a_TorchPos - a_BlockPos).Equals(Vector3i(-1, 0, 0))); + case E_META_TORCH_SOUTH: return ((a_TorchPos - a_BlockPos).Equals(Vector3i(1, 0, 0))); + default: + { + ASSERT(!"Unhandled torch meta!"); + break; + } + } + return false; + } + + virtual bool DoesAllowBlockOnTop(void) override { return false; @@ -113,8 +172,8 @@ public: virtual bool CanBeAt(int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override { - // TODO: Use cTorch::AdjustCoordsByMeta(), then cChunk::UnboundedRelGetBlock() and finally some comparison - char Face = cTorch::MetaDataToDirection(a_Chunk.GetMeta(a_RelX, a_RelY, a_RelZ)); + // TODO: Use AdjustCoordsByMeta(), then cChunk::UnboundedRelGetBlock() and finally some comparison + char Face = MetaDataToDirection(a_Chunk.GetMeta(a_RelX, a_RelY, a_RelZ)); int BlockX = a_RelX + a_Chunk.GetPosX() * cChunkDef::Width; int BlockZ = a_RelZ + a_Chunk.GetPosZ() * cChunkDef::Width; return TorchCanBePlacedAt(a_Chunk.GetWorld(), BlockX, a_RelY, BlockZ, Face); diff --git a/source/Blocks/BlockVine.h b/source/Blocks/BlockVine.h index 67376a4d8..2a88c9b68 100644 --- a/source/Blocks/BlockVine.h +++ b/source/Blocks/BlockVine.h @@ -2,7 +2,6 @@ #pragma once #include "BlockHandler.h" -#include "../Vine.h" @@ -31,17 +30,43 @@ public: a_World->GetBlockTypeMeta(a_BlockX, a_BlockY, a_BlockZ, BlockType, BlockMeta); if (BlockType == m_BlockType) { - a_BlockMeta = BlockMeta | cVine::DirectionToMetaData(a_BlockFace); + a_BlockMeta = BlockMeta | DirectionToMetaData(a_BlockFace); } else { - a_BlockMeta = cVine::DirectionToMetaData(a_BlockFace); + a_BlockMeta = DirectionToMetaData(a_BlockFace); } a_BlockType = m_BlockType; return true; } + static NIBBLETYPE DirectionToMetaData(char a_BlockFace) + { + switch (a_BlockFace) + { + case BLOCK_FACE_NORTH: return 0x1; + case BLOCK_FACE_SOUTH: return 0x4; + case BLOCK_FACE_WEST: return 0x8; + case BLOCK_FACE_EAST: return 0x2; + default: return 0x0; + } + } + + + static char MetaDataToDirection(NIBBLETYPE a_MetaData) + { + switch(a_MetaData) + { + case 0x1: return BLOCK_FACE_NORTH; + case 0x4: return BLOCK_FACE_SOUTH; + case 0x8: return BLOCK_FACE_WEST; + case 0x2: return BLOCK_FACE_EAST; + default: return BLOCK_FACE_TOP; + } + } + + /// Returns true if the specified block type is good for vines to attach to static bool IsBlockAttachable(BLOCKTYPE a_BlockType) { diff --git a/source/Chunk.cpp b/source/Chunk.cpp index 60ec273be..3cebe7d5c 100644 --- a/source/Chunk.cpp +++ b/source/Chunk.cpp @@ -19,8 +19,6 @@ #include "BlockEntities/JukeboxEntity.h" #include "BlockEntities/NoteEntity.h" #include "BlockEntities/SignEntity.h" -#include "Torch.h" -#include "Ladder.h" #include "Pickup.h" #include "Item.h" #include "Noise.h" diff --git a/source/ClientHandle.cpp b/source/ClientHandle.cpp index 0eb24e9e9..d0904bfb0 100644 --- a/source/ClientHandle.cpp +++ b/source/ClientHandle.cpp @@ -12,11 +12,7 @@ #include "BlockEntities/SignEntity.h" #include "UI/Window.h" #include "Item.h" -#include "Torch.h" #include "Doors.h" -#include "Ladder.h" -#include "Vine.h" -#include "Sign.h" #include "Piston.h" #include "Mobs/Monster.h" #include "ChatColor.h" diff --git a/source/Enchantments.h b/source/Enchantments.h index 30c2fe7b7..c20da654b 100644 --- a/source/Enchantments.h +++ b/source/Enchantments.h @@ -90,11 +90,11 @@ public: /// Returns true if a_Other contains exactly the same enchantments and levels bool operator ==(const cEnchantments & a_Other) const; + // tolua_end + /// Returns true if a_Other doesn't contain exactly the same enchantments and levels bool operator !=(const cEnchantments & a_Other) const; - // tolua_end - /// Writes the enchantments into the specified NBT writer; begins with the LIST tag of the specified name ("ench" or "StoredEnchantments") void WriteToNBTCompound(cFastNBTWriter & a_Writer, const AString & a_ListTagName) const; diff --git a/source/Items/ItemSign.h b/source/Items/ItemSign.h index 758e08c4d..7a0924147 100644 --- a/source/Items/ItemSign.h +++ b/source/Items/ItemSign.h @@ -3,7 +3,7 @@ #include "ItemHandler.h" #include "../World.h" -#include "../Sign.h" +#include "../Blocks/BlockSign.h" @@ -34,12 +34,12 @@ public: { if (a_BlockFace == BLOCK_FACE_TOP) { - a_BlockMeta = cSign::RotationToMetaData(a_Player->GetRotation()); + a_BlockMeta = cBlockSignHandler::RotationToMetaData(a_Player->GetRotation()); a_BlockType = E_BLOCK_SIGN_POST; } else { - a_BlockMeta = cSign::DirectionToMetaData(a_BlockFace); + a_BlockMeta = cBlockSignHandler::DirectionToMetaData(a_BlockFace); a_BlockType = E_BLOCK_WALLSIGN; } return true; diff --git a/source/Ladder.h b/source/Ladder.h deleted file mode 100644 index 50a697437..000000000 --- a/source/Ladder.h +++ /dev/null @@ -1,43 +0,0 @@ -#pragma once - -class cLadder // tolua_export -{ // tolua_export -public: - - static char DirectionToMetaData( char a_Direction ) // tolua_export - { // tolua_export - switch( a_Direction ) - { - case 0x2: - return 0x2; - case 0x3: - return 0x3; - case 0x4: - return 0x4; - case 0x5: - return 0x5; - default: - break; - }; - return 0x2; - } // tolua_export - - static char MetaDataToDirection( char a_MetaData ) // tolua_export - { // tolua_export - switch( a_MetaData ) - { - case 0x2: - return 0x2; - case 0x3: - return 0x3; - case 0x4: - return 0x4; - case 0x5: - return 0x5; - default: - break; - }; - return 0x2; - } // tolua_export - -}; // tolua_export diff --git a/source/Sign.h b/source/Sign.h deleted file mode 100644 index cc71666b5..000000000 --- a/source/Sign.h +++ /dev/null @@ -1,44 +0,0 @@ - -#pragma once - - - - - -// tolua_begin -class cSign -{ -public: - static char RotationToMetaData(double a_Rotation) - { - a_Rotation += 180 + (180 / 16); // So it's not aligned with axis - if (a_Rotation > 360) - { - a_Rotation -= 360; - } - - a_Rotation = (a_Rotation / 360) * 16; - - return ((char)a_Rotation) % 16; - } - - - static char DirectionToMetaData(char a_Direction) - { - switch (a_Direction) - { - case 0x2: return 0x2; - case 0x3: return 0x3; - case 0x4: return 0x4; - case 0x5: return 0x5; - default: - break; - }; - return 0x2; - } -} ; -// tolua_end - - - - diff --git a/source/Simulator/RedstoneSimulator.cpp b/source/Simulator/RedstoneSimulator.cpp index 989443e41..97412cca1 100644 --- a/source/Simulator/RedstoneSimulator.cpp +++ b/source/Simulator/RedstoneSimulator.cpp @@ -3,10 +3,10 @@ #include "RedstoneSimulator.h" #include "../BlockEntities/DropSpenserEntity.h" +#include "../Blocks/BlockTorch.h" #include "../Piston.h" #include "../World.h" #include "../BlockID.h" -#include "../Torch.h" #include "../Chunk.h" @@ -179,7 +179,7 @@ void cRedstoneSimulator::RefreshTorchesAround(const Vector3i & a_BlockPos) { if (BlockType != TargetBlockType) { - if (cTorch::IsAttachedTo(TorchPos, BlockMeta, a_BlockPos)) + if (cBlockTorchHandler::IsAttachedTo(TorchPos, BlockMeta, a_BlockPos)) { m_World.FastSetBlock(TorchPos.x, TorchPos.y, TorchPos.z, TargetBlockType, BlockMeta); m_Blocks.push_back(TorchPos); diff --git a/source/Stairs.h b/source/Stairs.h deleted file mode 100644 index 6d3a5a45c..000000000 --- a/source/Stairs.h +++ /dev/null @@ -1,44 +0,0 @@ - -#pragma once - - - - - -// tolua_begin - -class cStairs -{ -public: - /// Converts player rotation to stair rotation metadata. To get upside-down stairs, OR with 0x4 - static NIBBLETYPE RotationToMetaData(double a_Rotation) - { - a_Rotation += 90 + 45; // So its not aligned with axis - NIBBLETYPE result = 0x0; - if (a_Rotation > 360) - { - a_Rotation -= 360; - } - if ((a_Rotation >= 0) && (a_Rotation < 90)) - { - return 0x0; - } - else if ((a_Rotation >= 180) && (a_Rotation < 270)) - { - return 0x1; - } - else if ((a_Rotation >= 90) && (a_Rotation < 180)) - { - return 0x2; - } - else - { - return 0x3; - } - } -} ; - -// tolua_end - - - diff --git a/source/Torch.h b/source/Torch.h deleted file mode 100644 index 2a84db072..000000000 --- a/source/Torch.h +++ /dev/null @@ -1,77 +0,0 @@ - -#pragma once -#include "Vector3i.h" -#include "Defines.h" - - - - - -class cTorch // tolua_export -{ // tolua_export -public: - - static char DirectionToMetaData( char a_Direction ) // tolua_export - { // tolua_export - switch (a_Direction) - { - case BLOCK_FACE_BOTTOM: ASSERT(!"Shouldn't be getting this face"); return 0; - case BLOCK_FACE_TOP: return E_META_TORCH_FLOOR; - case BLOCK_FACE_EAST: return E_META_TORCH_EAST; - case BLOCK_FACE_WEST: return E_META_TORCH_WEST; - case BLOCK_FACE_NORTH: return E_META_TORCH_NORTH; - case BLOCK_FACE_SOUTH: return E_META_TORCH_SOUTH; - default: - { - ASSERT(!"Unhandled torch direction!"); - break; - } - }; - return 0x0; - } // tolua_export - - - static char MetaDataToDirection(char a_MetaData) // tolua_export - { // tolua_export - switch (a_MetaData) - { - case 0: return BLOCK_FACE_TOP; // by default, the torches stand on the ground - case E_META_TORCH_FLOOR: return BLOCK_FACE_TOP; - case E_META_TORCH_EAST: return BLOCK_FACE_EAST; - case E_META_TORCH_WEST: return BLOCK_FACE_WEST; - case E_META_TORCH_NORTH: return BLOCK_FACE_NORTH; - case E_META_TORCH_SOUTH: return BLOCK_FACE_SOUTH; - default: - { - ASSERT(!"Unhandled torch metadata"); - break; - } - } - return 0; - } // tolua_export - - - static bool IsAttachedTo(const Vector3i & a_TorchPos, char a_TorchMeta, const Vector3i & a_BlockPos) - { - switch (a_TorchMeta) - { - case 0x0: - case E_META_TORCH_FLOOR: return ((a_TorchPos - a_BlockPos).Equals(Vector3i(0, 1, 0))); - case E_META_TORCH_EAST: return ((a_TorchPos - a_BlockPos).Equals(Vector3i(0, 0, -1))); - case E_META_TORCH_WEST: return ((a_TorchPos - a_BlockPos).Equals(Vector3i(0, 0, 1))); - case E_META_TORCH_NORTH: return ((a_TorchPos - a_BlockPos).Equals(Vector3i(-1, 0, 0))); - case E_META_TORCH_SOUTH: return ((a_TorchPos - a_BlockPos).Equals(Vector3i(1, 0, 0))); - default: - { - ASSERT(!"Unhandled torch meta!"); - break; - } - } - return false; - } - -} ; // tolua_export - - - - diff --git a/source/Vine.h b/source/Vine.h deleted file mode 100644 index 7abf3992b..000000000 --- a/source/Vine.h +++ /dev/null @@ -1,42 +0,0 @@ - -#pragma once - - - - - -// tolua_begin -class cVine -{ -public: - - static NIBBLETYPE DirectionToMetaData(char a_BlockFace) - { - switch (a_BlockFace) - { - case BLOCK_FACE_NORTH: return 0x1; - case BLOCK_FACE_SOUTH: return 0x4; - case BLOCK_FACE_WEST: return 0x8; - case BLOCK_FACE_EAST: return 0x2; - default: return 0x0; - } - } - - - static char MetaDataToDirection(NIBBLETYPE a_MetaData) - { - switch(a_MetaData) - { - case 0x1: return BLOCK_FACE_NORTH; - case 0x4: return BLOCK_FACE_SOUTH; - case 0x8: return BLOCK_FACE_WEST; - case 0x2: return BLOCK_FACE_EAST; - default: return BLOCK_FACE_TOP; - } - } -} ; -// tolua_end - - - - -- cgit v1.2.3