diff options
Diffstat (limited to 'src/Defines.h')
-rw-r--r-- | src/Defines.h | 93 |
1 files changed, 73 insertions, 20 deletions
diff --git a/src/Defines.h b/src/Defines.h index 787eacab8..f3b742e09 100644 --- a/src/Defines.h +++ b/src/Defines.h @@ -29,16 +29,16 @@ enum -/// Block face constants, used in PlayerDigging and PlayerBlockPlacement packets and bbox collision calc +/** Block face constants, used in PlayerDigging and PlayerBlockPlacement packets and bbox collision calc */ enum eBlockFace { BLOCK_FACE_NONE = -1, // Interacting with no block face - swinging the item in the air - BLOCK_FACE_XM = 4, // Interacting with the X- face of the block - BLOCK_FACE_XP = 5, // Interacting with the X+ face of the block - BLOCK_FACE_YM = 0, // Interacting with the Y- face of the block - BLOCK_FACE_YP = 1, // Interacting with the Y+ face of the block - BLOCK_FACE_ZM = 2, // Interacting with the Z- face of the block - BLOCK_FACE_ZP = 3, // Interacting with the Z+ face of the block + BLOCK_FACE_XM = 4, // Interacting with the X- face of the block + BLOCK_FACE_XP = 5, // Interacting with the X+ face of the block + BLOCK_FACE_YM = 0, // Interacting with the Y- face of the block + BLOCK_FACE_YP = 1, // Interacting with the Y+ face of the block + BLOCK_FACE_ZM = 2, // Interacting with the Z- face of the block + BLOCK_FACE_ZP = 3, // Interacting with the Z+ face of the block // Synonyms using the (deprecated) world directions: BLOCK_FACE_BOTTOM = BLOCK_FACE_YM, // Interacting with the bottom face of the block @@ -47,6 +47,10 @@ enum eBlockFace BLOCK_FACE_SOUTH = BLOCK_FACE_ZP, // Interacting with the southern face of the block BLOCK_FACE_WEST = BLOCK_FACE_XM, // Interacting with the western face of the block BLOCK_FACE_EAST = BLOCK_FACE_XP, // Interacting with the eastern face of the block + + // Bounds, used for range-checking: + BLOCK_FACE_MIN = -1, + BLOCK_FACE_MAX = 5, } ; @@ -133,6 +137,17 @@ enum eGameMode +enum eChatType +{ + ctChatBox = 0, + ctSystem = 1, + ctAboveActionBar = 2, +} ; + + + + + enum eWeather { eWeather_Sunny = 0, @@ -238,8 +253,17 @@ 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; + case BLOCK_FACE_NONE: + case BLOCK_FACE_YM: + case BLOCK_FACE_YP: + { + return a_BlockFace; + }; } + #if !defined(__clang__) + ASSERT(!"Unknown BLOCK_FACE"); + return a_BlockFace; + #endif } @@ -255,8 +279,17 @@ 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; + case BLOCK_FACE_NONE: + case BLOCK_FACE_YM: + case BLOCK_FACE_YP: + { + return a_BlockFace; + } } + #if !defined(__clang__) + ASSERT(!"Unknown BLOCK_FACE"); + return a_BlockFace; + #endif } @@ -271,25 +304,45 @@ 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; + case BLOCK_FACE_NONE: + case BLOCK_FACE_YM: + case BLOCK_FACE_YP: + { + return a_BlockFace; + }; } + #if !defined(__clang__) + ASSERT(!"Unknown BLOCK_FACE"); + return a_BlockFace; + #endif } + + + + 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; + 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; + case BLOCK_FACE_NONE: return a_BlockFace; } + #if !defined(__clang__) + ASSERT(!"Unknown BLOCK_FACE"); + return a_BlockFace; + #endif } + + + /** Returns the textual representation of the BlockFace constant. */ inline AString BlockFaceToString(eBlockFace a_BlockFace) { @@ -305,7 +358,7 @@ inline AString BlockFaceToString(eBlockFace a_BlockFace) } // clang optimisises this line away then warns that it has done so. #if !defined(__clang__) - return Printf("Unknown BLOCK_FACE: %d", a_BlockFace); + return Printf("Unknown BLOCK_FACE: %d", a_BlockFace); #endif } @@ -436,7 +489,7 @@ inline void AddFaceDirection(int & a_BlockX, int & a_BlockY, int & a_BlockZ, eBl case BLOCK_FACE_ZP: a_BlockZ++; break; case BLOCK_FACE_XP: a_BlockX++; break; case BLOCK_FACE_XM: a_BlockX--; break; - default: + case BLOCK_FACE_NONE: { LOGWARNING("%s: Unknown face: %d", __FUNCTION__, a_BlockFace); ASSERT(!"AddFaceDirection(): Unknown face"); @@ -454,7 +507,7 @@ inline void AddFaceDirection(int & a_BlockX, int & a_BlockY, int & a_BlockZ, eBl case BLOCK_FACE_ZP: a_BlockZ--; break; case BLOCK_FACE_XP: a_BlockX--; break; case BLOCK_FACE_XM: a_BlockX++; break; - default: + case BLOCK_FACE_NONE: { LOGWARNING("%s: Unknown inv face: %d", __FUNCTION__, a_BlockFace); ASSERT(!"AddFaceDirection(): Unknown face"); |