summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
Diffstat (limited to 'source')
-rw-r--r--source/BlockID.h7
-rw-r--r--source/Defines.h80
-rw-r--r--source/cTorch.h120
3 files changed, 98 insertions, 109 deletions
diff --git a/source/BlockID.h b/source/BlockID.h
index e085e2624..139e08eb7 100644
--- a/source/BlockID.h
+++ b/source/BlockID.h
@@ -500,6 +500,13 @@ enum
E_META_WOOL_RED = 14,
E_META_WOOL_BLACK = 15,
+ // E_BLOCK_TORCH, E_BLOCK_REDSTONE_TORCH_OFF, E_BLOCK_REDSTONE_TORCH_ON metas:
+ E_META_TORCH_EAST = 1, // east face of the block, pointing east
+ E_META_TORCH_WEST = 2,
+ E_META_TORCH_SOUTH = 3,
+ E_META_TORCH_NORTH = 4,
+ E_META_TORCH_FLOOR = 5,
+
// E_BLOCK_DOUBLE_STEP metas:
E_META_DOUBLE_STEP_STONE = 0,
E_META_DOUBLE_STEP_SANDSTONE = 1,
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;
+ }
+ }
}
}
diff --git a/source/cTorch.h b/source/cTorch.h
index c45916dbf..5d0b9ad0c 100644
--- a/source/cTorch.h
+++ b/source/cTorch.h
@@ -1,6 +1,11 @@
-#pragma once
+#pragma once
#include "Vector3i.h"
+#include "Defines.h"
+
+
+
+
class cTorch //tolua_export
{ //tolua_export
@@ -8,87 +13,64 @@ public:
static char DirectionToMetaData( char a_Direction ) //tolua_export
{ //tolua_export
- switch( a_Direction )
+ switch (a_Direction)
{
- case 0x0:
- return 0x0;
- case 0x1:
- return 0x5; //standing on floor
- case 0x2:
- return 0x4; // south
- case 0x3:
- return 0x3; // north
- case 0x4:
- return 0x2; // west
- case 0x5:
- return 0x1; // east
- default:
- break;
+ case BLOCK_FACE_BOTTOM: ASSERT(!"Shouldn't be getting this direction"); 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
+ static char MetaDataToDirection(char a_MetaData) //tolua_export
{ //tolua_export
- switch( a_MetaData )
+ switch (a_MetaData)
{
- case 0x0:
- return 0x0;
- case 0x1:
- return 0x5;
- case 0x2:
- return 0x4;
- case 0x3:
- return 0x3;
- case 0x4:
- return 0x2;
- case 0x5:
- return 0x1;
- default:
- break;
- };
- return 0x0;
+ 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 )
+
+ static bool IsAttachedTo(const Vector3i & a_TorchPos, char a_TorchMeta, const Vector3i & a_BlockPos)
{
- switch( a_TorchMeta )
+ switch (a_TorchMeta)
{
- case 0x0:
- case 0x5: // On floor
- if( (a_TorchPos - a_BlockPos).Equals( Vector3i(0, 1, 0 ) ) )
+ 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:
{
- return true;
+ ASSERT(!"Unhandled torch meta!");
+ break;
}
- break;
- case 0x4: // South -Z
- if( (a_TorchPos - a_BlockPos).Equals( Vector3i(0, 0, -1 ) ) )
- {
- return true;
- }
- break;
- case 0x3: // North +Z
- if( (a_TorchPos - a_BlockPos).Equals( Vector3i(0, 0, 1 ) ) )
- {
- return true;
- }
- break;
- case 0x2: // West -X
- if( (a_TorchPos - a_BlockPos).Equals( Vector3i(-1, 0, 0 ) ) )
- {
- return true;
- }
- break;
- case 0x1: // East +X
- if( (a_TorchPos - a_BlockPos).Equals( Vector3i( 1, 0, 0 ) ) )
- {
- return true;
- }
- break;
- default:
- break;
- };
+ }
return false;
}
-}; //tolua_export \ No newline at end of file
+} ; //tolua_export
+
+
+
+