From eb0f713b6a5a7107a97284d1728858b4b2882c3d Mon Sep 17 00:00:00 2001 From: Howaner Date: Fri, 9 May 2014 23:43:00 +0200 Subject: Add block place/break distance check. --- src/Defines.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/Defines.h') diff --git a/src/Defines.h b/src/Defines.h index 9fa3b3a8e..b0b209934 100644 --- a/src/Defines.h +++ b/src/Defines.h @@ -3,6 +3,7 @@ #include "ChatColor.h" #include +#include @@ -528,6 +529,15 @@ inline float GetSpecialSignf( float a_Val ) +template inline int Diff(T a_Val1, T a_Val2) +{ + return std::abs(a_Val1 - a_Val2); +} + + + + + // tolua_begin enum eMessageType -- cgit v1.2.3 From e09a04a23aaa14598bff6692393f4187f59d3824 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sun, 18 May 2014 22:36:17 +0200 Subject: Fixed datatype truncation in Diff() template. --- 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 b0b209934..563fc308c 100644 --- a/src/Defines.h +++ b/src/Defines.h @@ -529,7 +529,7 @@ inline float GetSpecialSignf( float a_Val ) -template inline int Diff(T a_Val1, T a_Val2) +template inline T Diff(T a_Val1, T a_Val2) { return std::abs(a_Val1 - a_Val2); } -- cgit v1.2.3 From 6fa99a211ec792ea4dbb4a303a26608de2cd5990 Mon Sep 17 00:00:00 2001 From: Tycho Date: Mon, 16 Jun 2014 17:55:58 +0100 Subject: Refactored reversing logic into seperate function --- src/Defines.h | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'src/Defines.h') diff --git a/src/Defines.h b/src/Defines.h index 563fc308c..ee91ee596 100644 --- a/src/Defines.h +++ b/src/Defines.h @@ -274,8 +274,19 @@ inline eBlockFace RotateBlockFaceCW(eBlockFace a_BlockFace) } } - - +inline eBlockFace ReverseBlockFace(eBlockFace a_BlockFace) +{ + switch (a_BlockFace) + { + case BLOCK_FACE_YP: return BLOCK_FACE_YM; + case BLOCK_FACE_XP: return BLOCK_FACE_XM; + case BLOCK_FACE_ZP: return BLOCK_FACE_ZM; + case BLOCK_FACE_YM: return BLOCK_FACE_YP; + case BLOCK_FACE_XM: return BLOCK_FACE_XP; + case BLOCK_FACE_ZM: return BLOCK_FACE_ZP; + default: return a_BlockFace; + } +} /** Returns the textual representation of the BlockFace constant. */ -- cgit v1.2.3 From 993fd14ddfc881cf5be951df77da0338124d68cc Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 17 Jul 2014 16:33:09 +0200 Subject: Fixed basic whitespace problems. Indenting by spaces and alignment by spaces, as well as trailing whitespace on non-empty lines. --- 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 ee91ee596..ba2e8f504 100644 --- a/src/Defines.h +++ b/src/Defines.h @@ -512,7 +512,7 @@ inline void VectorToEuler(double a_X, double a_Y, double a_Z, double & a_Pan, do } else { - a_Pan = atan2(a_Z, a_X) * 180 / PI - 90; + a_Pan = atan2(a_Z, a_X) * 180 / PI - 90; } a_Pitch = atan2(a_Y, r) * 180 / PI; -- cgit v1.2.3 From 7fff12bfacbb4bef1c02cea0ec10fdc9a6fb64e4 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 17 Jul 2014 19:13:23 +0200 Subject: Fixed spaces around single-line comments. There should be at least two spaces in front and one space after //-style comments. --- 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 ba2e8f504..877970ab8 100644 --- a/src/Defines.h +++ b/src/Defines.h @@ -22,7 +22,7 @@ typedef std::vector cSlotNums; /// Experience Orb setup enum { - //open to suggestion on naming convention here :) + // Open to suggestion on naming convention here :) MAX_EXPERIENCE_ORB_SIZE = 2000 } ; -- cgit v1.2.3 From 0f8c24e04d60aa1642a5fe7346941ccd7697977e Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Thu, 17 Jul 2014 22:26:53 +0100 Subject: Fixed issues relating to saplings and leaves - Removed cBlockInfo::RequiresSpecialTool * Fixes #1195 * Fixes #1201 --- src/Defines.h | 9 --------- 1 file changed, 9 deletions(-) (limited to 'src/Defines.h') diff --git a/src/Defines.h b/src/Defines.h index ee91ee596..4fde6800a 100644 --- a/src/Defines.h +++ b/src/Defines.h @@ -727,14 +727,5 @@ namespace ItemCategory // tolua_end -inline bool BlockRequiresSpecialTool(BLOCKTYPE a_BlockType) -{ - if(!IsValidBlock(a_BlockType)) return false; - return cBlockInfo::RequiresSpecialTool(a_BlockType); -} - - - - -- cgit v1.2.3 From ffe44c13d0ce037efb01544b96fe0756d64b8517 Mon Sep 17 00:00:00 2001 From: archshift Date: Thu, 17 Jul 2014 23:25:14 -0700 Subject: Moved ChatColor.h out of defines where it was not needed --- 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 877970ab8..f57e63c7f 100644 --- a/src/Defines.h +++ b/src/Defines.h @@ -1,7 +1,6 @@ #pragma once -#include "ChatColor.h" #include #include -- cgit v1.2.3 From 041bfd5860cd8ef51db42eb6fb4b50b45549feba Mon Sep 17 00:00:00 2001 From: archshift Date: Sat, 19 Jul 2014 01:40:29 -0700 Subject: Fixed clamping issues --- src/Defines.h | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) (limited to 'src/Defines.h') diff --git a/src/Defines.h b/src/Defines.h index f57e63c7f..f7c8d0fc5 100644 --- a/src/Defines.h +++ b/src/Defines.h @@ -470,18 +470,7 @@ inline void AddFaceDirection(int & a_BlockX, unsigned char & a_BlockY, int & a_B { int Y = a_BlockY; AddFaceDirection(a_BlockX, Y, a_BlockZ, a_BlockFace, a_bInverse); - if (Y < 0) - { - a_BlockY = 0; - } - else if (Y > 255) - { - a_BlockY = 255; - } - else - { - a_BlockY = (unsigned char)Y; - } + a_BlockY = Clamp(Y, 0, 255); } -- cgit v1.2.3 From 6be79575fd50e37ac275bd0cb9d16f9e51e8a225 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sun, 20 Jul 2014 23:10:31 +0200 Subject: Style: Normalized spaces after if, for and while. --- 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 f7c8d0fc5..f4ebbd9ff 100644 --- a/src/Defines.h +++ b/src/Defines.h @@ -717,7 +717,7 @@ namespace ItemCategory inline bool BlockRequiresSpecialTool(BLOCKTYPE a_BlockType) { - if(!IsValidBlock(a_BlockType)) return false; + if (!IsValidBlock(a_BlockType)) return false; return cBlockInfo::RequiresSpecialTool(a_BlockType); } -- cgit v1.2.3 From 93d29555e58df172bafba530afbc593c16ec66a3 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 21 Jul 2014 15:19:48 +0200 Subject: Style: Normalized to no spaces before closing parenthesis. --- src/Defines.h | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src/Defines.h') diff --git a/src/Defines.h b/src/Defines.h index f4ebbd9ff..f095069d9 100644 --- a/src/Defines.h +++ b/src/Defines.h @@ -479,9 +479,9 @@ inline void AddFaceDirection(int & a_BlockX, unsigned char & a_BlockY, int & a_B inline void EulerToVector(double a_Pan, double a_Pitch, double & a_X, double & a_Y, double & a_Z) { - // a_X = sinf ( a_Pan / 180 * PI ) * cosf ( a_Pitch / 180 * PI ); - // a_Y = -sinf ( a_Pitch / 180 * PI ); - // a_Z = -cosf ( a_Pan / 180 * PI ) * cosf ( a_Pitch / 180 * PI ); + // a_X = sinf ( a_Pan / 180 * PI) * cosf ( a_Pitch / 180 * PI); + // a_Y = -sinf ( a_Pitch / 180 * PI); + // a_Z = -cosf ( a_Pan / 180 * PI) * cosf ( a_Pitch / 180 * PI); a_X = cos(a_Pan / 180 * PI) * cos(a_Pitch / 180 * PI); a_Y = sin(a_Pan / 180 * PI) * cos(a_Pitch / 180 * PI); a_Z = sin(a_Pitch / 180 * PI); @@ -519,7 +519,7 @@ inline float GetSignf(float a_Val) -inline float GetSpecialSignf( float a_Val ) +inline float GetSpecialSignf( float a_Val) { return (a_Val <= 0.f) ? -1.f : 1.f; } @@ -640,11 +640,11 @@ namespace ItemCategory inline bool IsTool(short a_ItemID) { - return IsPickaxe( a_ItemID ) - || IsAxe ( a_ItemID ) - || IsSword ( a_ItemID ) - || IsHoe ( a_ItemID ) - || IsShovel ( a_ItemID ); + return IsPickaxe( a_ItemID) + || IsAxe ( a_ItemID) + || IsSword ( a_ItemID) + || IsHoe ( a_ItemID) + || IsShovel ( a_ItemID); } -- cgit v1.2.3 From dd0ab044810d87dc4233a652087808638c696d94 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 21 Jul 2014 18:07:51 +0200 Subject: Defines.h: Fixed a warning. --- 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 f095069d9..9f66cbf9b 100644 --- a/src/Defines.h +++ b/src/Defines.h @@ -470,7 +470,7 @@ inline void AddFaceDirection(int & a_BlockX, unsigned char & a_BlockY, int & a_B { int Y = a_BlockY; AddFaceDirection(a_BlockX, Y, a_BlockZ, a_BlockFace, a_bInverse); - a_BlockY = Clamp(Y, 0, 255); + a_BlockY = Clamp((unsigned char)Y, 0, 255); } -- cgit v1.2.3