From d73cdba1f66a92f011ac881b581595c0959139ef Mon Sep 17 00:00:00 2001 From: andrew Date: Sat, 1 Mar 2014 21:34:19 +0200 Subject: g_BlockXXX => cBlockInfo::XXX --- src/Defines.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Defines.h') diff --git a/src/Defines.h b/src/Defines.h index ba2866f83..31d48860f 100644 --- a/src/Defines.h +++ b/src/Defines.h @@ -654,7 +654,7 @@ namespace ItemCategory inline bool BlockRequiresSpecialTool(BLOCKTYPE a_BlockType) { if(!IsValidBlock(a_BlockType)) return false; - return g_BlockRequiresSpecialTool[a_BlockType]; + return cBlockInfo::RequiresSpecialTool(a_BlockType); } -- cgit v1.2.3 From cff4ee11f125efb0b10ffe19d84869b858416584 Mon Sep 17 00:00:00 2001 From: andrew Date: Sun, 2 Mar 2014 11:30:20 +0200 Subject: Removed g_BlockXXX arrays --- src/Defines.h | 27 --------------------------- 1 file changed, 27 deletions(-) (limited to 'src/Defines.h') diff --git a/src/Defines.h b/src/Defines.h index 31d48860f..6d3d28c80 100644 --- a/src/Defines.h +++ b/src/Defines.h @@ -17,33 +17,6 @@ typedef std::vector cSlotNums; // tolua_begin -/// How much light do the blocks emit on their own? -extern unsigned char g_BlockLightValue[]; - -/// How much light do the block consume? -extern unsigned char g_BlockSpreadLightFalloff[]; - -/// Is a block completely transparent? (light doesn't get decreased(?)) -extern bool g_BlockTransparent[]; - -/// Is a block destroyed after a single hit? -extern bool g_BlockOneHitDig[]; - -/// Can a piston break this block? -extern bool g_BlockPistonBreakable[256]; - -/// Can this block hold snow atop? -extern bool g_BlockIsSnowable[256]; - -/// Does this block require a tool to drop? -extern bool g_BlockRequiresSpecialTool[256]; - -/// Is this block solid (player cannot walk through)? -extern bool g_BlockIsSolid[256]; - -/// Does this block fully occupy it's voxel - is it a 'full' block? -extern bool g_BlockFullyOccupiesVoxel[256]; - /// Experience Orb setup enum { -- cgit v1.2.3 From 274d2bcb17791c292a2095af649b1a4c51246d23 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sun, 2 Mar 2014 16:05:39 +0100 Subject: Added blockface mirroring and rotating. --- src/Defines.h | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) (limited to 'src/Defines.h') diff --git a/src/Defines.h b/src/Defines.h index 6d3d28c80..018ecb1d3 100644 --- a/src/Defines.h +++ b/src/Defines.h @@ -226,6 +226,56 @@ inline const char * ClickActionToString(eClickAction a_ClickAction) +/** Returns a blockface mirrored around the Y axis (doesn't change up/down). */ +inline eBlockFace MirrorBlockFaceY(eBlockFace a_BlockFace) +{ + switch (a_BlockFace) + { + case BLOCK_FACE_XM: return BLOCK_FACE_XP; + case BLOCK_FACE_XP: return BLOCK_FACE_XM; + case BLOCK_FACE_ZM: return BLOCK_FACE_ZP; + case BLOCK_FACE_ZP: return BLOCK_FACE_ZM; + } + return a_BlockFace; +} + + + + + +/** Returns a blockface rotated around the Y axis counter-clockwise. */ +inline eBlockFace RotateBlockFaceCCW(eBlockFace a_BlockFace) +{ + switch (a_BlockFace) + { + case BLOCK_FACE_XM: return BLOCK_FACE_ZP; + case BLOCK_FACE_XP: return BLOCK_FACE_ZM; + case BLOCK_FACE_ZM: return BLOCK_FACE_XM; + case BLOCK_FACE_ZP: return BLOCK_FACE_XP; + } + return a_BlockFace; +} + + + + + +inline eBlockFace RotateBlockFaceCW(eBlockFace a_BlockFace) +{ + switch (a_BlockFace) + { + case BLOCK_FACE_XM: return BLOCK_FACE_ZM; + case BLOCK_FACE_XP: return BLOCK_FACE_ZP; + case BLOCK_FACE_ZM: return BLOCK_FACE_XP; + case BLOCK_FACE_ZP: return BLOCK_FACE_XM; + } + return a_BlockFace; +} + + + + + inline bool IsValidBlock(int a_BlockType) { if ( -- cgit v1.2.3 From a845c051b8df10c6eaf1f68d3c37abe71425e9d6 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 4 Mar 2014 22:25:31 +0100 Subject: Fixed some gcc warnings in Defines.h. --- src/Defines.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/Defines.h') diff --git a/src/Defines.h b/src/Defines.h index 018ecb1d3..6ab2274a4 100644 --- a/src/Defines.h +++ b/src/Defines.h @@ -235,8 +235,8 @@ inline eBlockFace MirrorBlockFaceY(eBlockFace a_BlockFace) case BLOCK_FACE_XP: return BLOCK_FACE_XM; case BLOCK_FACE_ZM: return BLOCK_FACE_ZP; case BLOCK_FACE_ZP: return BLOCK_FACE_ZM; + default: return a_BlockFace; } - return a_BlockFace; } @@ -252,8 +252,8 @@ inline eBlockFace RotateBlockFaceCCW(eBlockFace a_BlockFace) case BLOCK_FACE_XP: return BLOCK_FACE_ZM; case BLOCK_FACE_ZM: return BLOCK_FACE_XM; case BLOCK_FACE_ZP: return BLOCK_FACE_XP; + default: return a_BlockFace; } - return a_BlockFace; } @@ -268,8 +268,8 @@ inline eBlockFace RotateBlockFaceCW(eBlockFace a_BlockFace) case BLOCK_FACE_XP: return BLOCK_FACE_ZP; case BLOCK_FACE_ZM: return BLOCK_FACE_XP; case BLOCK_FACE_ZP: return BLOCK_FACE_XM; + default: return a_BlockFace; } - return a_BlockFace; } -- cgit v1.2.3 From 5be983e7752091adbf7262f3074b3062ea44ae73 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sun, 9 Mar 2014 10:05:30 +0100 Subject: Added BlockFaceToString() translation function. --- src/Defines.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src/Defines.h') diff --git a/src/Defines.h b/src/Defines.h index 6ab2274a4..d2fcce576 100644 --- a/src/Defines.h +++ b/src/Defines.h @@ -276,6 +276,26 @@ inline eBlockFace RotateBlockFaceCW(eBlockFace a_BlockFace) +/** Returns the textual representation of the BlockFace constant. */ +inline AString BlockFaceToString(eBlockFace a_BlockFace) +{ + switch (a_BlockFace) + { + case BLOCK_FACE_XM: return "BLOCK_FACE_XM"; + case BLOCK_FACE_XP: return "BLOCK_FACE_XP"; + case BLOCK_FACE_YM: return "BLOCK_FACE_YM"; + case BLOCK_FACE_YP: return "BLOCK_FACE_YP"; + case BLOCK_FACE_ZM: return "BLOCK_FACE_ZM"; + case BLOCK_FACE_ZP: return "BLOCK_FACE_ZP"; + case BLOCK_FACE_NONE: return "BLOCK_FACE_NONE"; + } + return Printf("Unknown BLOCK_FACE: %d", a_BlockFace); +} + + + + + inline bool IsValidBlock(int a_BlockType) { if ( -- cgit v1.2.3 From 9825dbfd34c65580d795065d1a82e7697b9c5cbd Mon Sep 17 00:00:00 2001 From: Tycho Date: Sun, 9 Mar 2014 11:21:42 -0700 Subject: Fixed Mesannine twister to use UInt32 --- src/Defines.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Defines.h') diff --git a/src/Defines.h b/src/Defines.h index 6ab2274a4..fd240c91a 100644 --- a/src/Defines.h +++ b/src/Defines.h @@ -469,7 +469,7 @@ inline void EulerToVector(double a_Pan, double a_Pitch, double & a_X, double & a inline void VectorToEuler(double a_X, double a_Y, double a_Z, double & a_Pan, double & a_Pitch) { - if (a_X != 0) + if (fabs(a_X) < std::numeric_limits::epsilon() ) { a_Pan = atan2(a_Z, a_X) * 180 / PI - 90; } -- cgit v1.2.3 From 1bf99b5fd26d142106d7a097900ebfe8a6279ad4 Mon Sep 17 00:00:00 2001 From: Tycho Date: Sun, 9 Mar 2014 11:47:22 -0700 Subject: Be more parinoid about int sizes --- src/Defines.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/Defines.h') diff --git a/src/Defines.h b/src/Defines.h index fd240c91a..592b9434a 100644 --- a/src/Defines.h +++ b/src/Defines.h @@ -2,6 +2,7 @@ #pragma once #include "ChatColor.h" +#include @@ -469,7 +470,7 @@ inline void EulerToVector(double a_Pan, double a_Pitch, double & a_X, double & a inline void VectorToEuler(double a_X, double a_Y, double a_Z, double & a_Pan, double & a_Pitch) { - if (fabs(a_X) < std::numeric_limits::epsilon() ) + if (fabs(a_X) < std::numeric_limits::epsilon()) { a_Pan = atan2(a_Z, a_X) * 180 / PI - 90; } -- cgit v1.2.3 From e61810e1bf67dc43861d4741b16e65b30fe8d23c Mon Sep 17 00:00:00 2001 From: Tycho Date: Fri, 14 Mar 2014 06:52:49 -0700 Subject: Removed invalid block face handling code The code for handling invalid block faces is removed by gcc and clang as it is undefined behavior for a enum to contain a value that is not part of the enum. Since the only way that the line can be executed is through undefined behavior clang and gcc remove it so the function fits in the caches better. --- src/Defines.h | 1 - 1 file changed, 1 deletion(-) (limited to 'src/Defines.h') diff --git a/src/Defines.h b/src/Defines.h index 3b7654265..2e412209d 100644 --- a/src/Defines.h +++ b/src/Defines.h @@ -290,7 +290,6 @@ inline AString BlockFaceToString(eBlockFace a_BlockFace) case BLOCK_FACE_ZP: return "BLOCK_FACE_ZP"; case BLOCK_FACE_NONE: return "BLOCK_FACE_NONE"; } - return Printf("Unknown BLOCK_FACE: %d", a_BlockFace); } -- cgit v1.2.3 From ef50e73a9c3053b8787ded3d26b3a5d3b6c92edc Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sun, 16 Mar 2014 18:44:23 +0100 Subject: Added common eMessageType aliases. --- src/Defines.h | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) (limited to 'src/Defines.h') diff --git a/src/Defines.h b/src/Defines.h index 3b7654265..38411c69d 100644 --- a/src/Defines.h +++ b/src/Defines.h @@ -530,16 +530,22 @@ enum eMessageType // http://forum.mc-server.org/showthread.php?tid=1212 // MessageType... - mtCustom, // Send raw data without any processing - mtFailure, // Something could not be done (i.e. command not executed due to insufficient privilege) - mtInformation, // Informational message (i.e. command usage) - mtSuccess, // Something executed successfully - mtWarning, // Something concerning (i.e. reload) is about to happen - mtFatal, // Something catastrophic occured (i.e. plugin crash) - mtDeath, // Denotes death of player - mtPrivateMessage, // Player to player messaging identifier - mtJoin, // A player has joined the server - mtLeave, // A player has left the server + mtCustom, // Send raw data without any processing + mtFailure, // Something could not be done (i.e. command not executed due to insufficient privilege) + mtInformation, // Informational message (i.e. command usage) + mtSuccess, // Something executed successfully + mtWarning, // Something concerning (i.e. reload) is about to happen + mtFatal, // Something catastrophic occured (i.e. plugin crash) + mtDeath, // Denotes death of player + mtPrivateMessage, // Player to player messaging identifier + mtJoin, // A player has joined the server + mtLeave, // A player has left the server + + // Common aliases: + mtFail = mtFailure, + mtError = mtFailure, + mtInfo = mtInformation, + mtPM = mtPrivateMessage, }; -- cgit v1.2.3 From 363c92ed534d5cffe164079359b62a0768bc0f80 Mon Sep 17 00:00:00 2001 From: Tycho Date: Wed, 19 Mar 2014 12:06:12 -0700 Subject: Added unreachable lines backit prtected by preprocessor guards --- src/Defines.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/Defines.h') diff --git a/src/Defines.h b/src/Defines.h index 7f7a2eeb1..1a8b3fa4a 100644 --- a/src/Defines.h +++ b/src/Defines.h @@ -290,6 +290,10 @@ inline AString BlockFaceToString(eBlockFace a_BlockFace) case BLOCK_FACE_ZP: return "BLOCK_FACE_ZP"; case BLOCK_FACE_NONE: return "BLOCK_FACE_NONE"; } + // clang optimisises this line away then warns that it has done so. + #if !defined(__clang__) + return Printf("Unknown BLOCK_FACE: %d", a_BlockFace); + #endif } -- cgit v1.2.3