From 897733a58e595ec94d93c81e0f7f07e577d89a04 Mon Sep 17 00:00:00 2001 From: "madmaxoft@gmail.com" Date: Fri, 10 Aug 2012 20:42:59 +0000 Subject: Use named constants instead of magic values - block digging direction and torch placement git-svn-id: http://mc-server.googlecode.com/svn/trunk@724 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/Defines.h | 80 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 40 insertions(+), 40 deletions(-) (limited to 'source/Defines.h') diff --git a/source/Defines.h b/source/Defines.h index 08ee877b7..fb856b835 100644 --- a/source/Defines.h +++ b/source/Defines.h @@ -19,6 +19,20 @@ extern bool g_BlockOneHitDig[]; +enum +{ + BLOCK_FACE_BOTTOM = 0, // Interacting with the bottom face of the block + BLOCK_FACE_TOP = 1, // Interacting with the top face of the block + BLOCK_FACE_EAST = 2, // Interacting with the eastern face of the block + BLOCK_FACE_WEST = 3, // Interacting with the western face of the block + BLOCK_FACE_NORTH = 4, // Interacting with the northern face of the block + BLOCK_FACE_SOUTH = 5, // Interacting with the southern face of the block +} ; + + + + + inline bool IsValidBlock( int a_BlockID ) //tolua_export { //tolua_export if( a_BlockID > -1 && @@ -94,53 +108,39 @@ inline bool IsBlockTypeOfDirt(char a_BlockID) inline void AddDirection( int & a_X, int & a_Y, int & a_Z, char a_Direction, bool a_bInverse = false ) { - if( !a_bInverse ) + if (!a_bInverse) { - switch( a_Direction ) + switch (a_Direction) { - case 0: - a_Y--; - break; - case 1: - a_Y++; - break; - case 2: - a_Z--; - break; - case 3: - a_Z++; - break; - case 4: - a_X--; - break; - case 5: - a_X++; - break; - }; + case BLOCK_FACE_BOTTOM: a_Y--; break; + case BLOCK_FACE_TOP: a_Y++; break; + case BLOCK_FACE_EAST: a_Z--; break; + case BLOCK_FACE_WEST: a_Z++; break; + case BLOCK_FACE_NORTH: a_X--; break; + case BLOCK_FACE_SOUTH: a_X++; break; + default: + { + ASSERT(!"Unknown direction"); + break; + } + } } else { switch( a_Direction ) // other way around { - case 0: - a_Y++; - break; - case 1: - a_Y--; - break; - case 2: - a_Z++; - break; - case 3: - a_Z--; - break; - case 4: - a_X++; - break; - case 5: - a_X--; - break; - }; + case BLOCK_FACE_BOTTOM: a_Y++; break; + case BLOCK_FACE_TOP: a_Y--; break; + case BLOCK_FACE_EAST: a_Z++; break; + case BLOCK_FACE_WEST: a_Z--; break; + case BLOCK_FACE_NORTH: a_X++; break; + case BLOCK_FACE_SOUTH: a_X--; break; + default: + { + ASSERT(!"Unknown direction"); + break; + } + } } } -- cgit v1.2.3