From 5ba46ebc21714c7398e7c1a14e81cb0f00c3f348 Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Mon, 3 Feb 2014 20:08:38 +0100 Subject: This renames the cBlockWoodHandler to cBlockSidewaysHandler, and implements a new cBlockQuartzHandler to handle the quartz pillars. --- src/Blocks/BlockHandler.cpp | 9 ++++-- src/Blocks/BlockQuartz.h | 66 +++++++++++++++++++++++++++++++++++++++++ src/Blocks/BlockSideways.h | 72 +++++++++++++++++++++++++++++++++++++++++++++ src/Blocks/BlockWood.h | 72 --------------------------------------------- 4 files changed, 144 insertions(+), 75 deletions(-) create mode 100644 src/Blocks/BlockQuartz.h create mode 100644 src/Blocks/BlockSideways.h delete mode 100644 src/Blocks/BlockWood.h (limited to 'src') diff --git a/src/Blocks/BlockHandler.cpp b/src/Blocks/BlockHandler.cpp index c16f255b8..3ecf0d7e2 100644 --- a/src/Blocks/BlockHandler.cpp +++ b/src/Blocks/BlockHandler.cpp @@ -49,6 +49,7 @@ #include "BlockPlanks.h" #include "BlockPortal.h" #include "BlockPumpkin.h" +#include "BlockQuartz.h" #include "BlockRail.h" #include "BlockRedstone.h" #include "BlockRedstoneLamp.h" @@ -56,6 +57,7 @@ #include "BlockRedstoneTorch.h" #include "BlockSand.h" #include "BlockSapling.h" +#include "BlockSideways.h" #include "BlockSign.h" #include "BlockSlab.h" #include "BlockSnow.h" @@ -67,7 +69,6 @@ #include "BlockTorch.h" #include "BlockTrapdoor.h" #include "BlockVine.h" -#include "BlockWood.h" #include "BlockWorkbench.h" @@ -144,6 +145,7 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType) case E_BLOCK_GLASS: return new cBlockGlassHandler (a_BlockType); case E_BLOCK_GRASS: return new cBlockDirtHandler (a_BlockType); case E_BLOCK_GRAVEL: return new cBlockGravelHandler (a_BlockType); + case E_BLOCK_HAY_BALE: return new cBlockSidewaysHandler (a_BlockType); case E_BLOCK_HOPPER: return new cBlockHopperHandler (a_BlockType); case E_BLOCK_ICE: return new cBlockIceHandler (a_BlockType); case E_BLOCK_INACTIVE_COMPARATOR: return new cBlockComparatorHandler (a_BlockType); @@ -158,14 +160,14 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType) case E_BLOCK_LAVA: return new cBlockLavaHandler (a_BlockType); case E_BLOCK_LEAVES: return new cBlockLeavesHandler (a_BlockType); case E_BLOCK_LIT_FURNACE: return new cBlockFurnaceHandler (a_BlockType); - case E_BLOCK_LOG: return new cBlockWoodHandler (a_BlockType); + case E_BLOCK_LOG: return new cBlockSidewaysHandler (a_BlockType); case E_BLOCK_MELON: return new cBlockMelonHandler (a_BlockType); case E_BLOCK_MELON_STEM: return new cBlockStemsHandler (a_BlockType); case E_BLOCK_MYCELIUM: return new cBlockMyceliumHandler (a_BlockType); case E_BLOCK_NETHER_BRICK_STAIRS: return new cBlockStairsHandler (a_BlockType); case E_BLOCK_NETHER_PORTAL: return new cBlockPortalHandler (a_BlockType); case E_BLOCK_NETHER_WART: return new cBlockNetherWartHandler (a_BlockType); - case E_BLOCK_NEW_LOG: return new cBlockWoodHandler (a_BlockType); + case E_BLOCK_NEW_LOG: return new cBlockSidewaysHandler (a_BlockType); case E_BLOCK_NOTE_BLOCK: return new cBlockNoteHandler (a_BlockType); case E_BLOCK_PISTON: return new cBlockPistonHandler (a_BlockType); case E_BLOCK_PISTON_EXTENSION: return new cBlockPistonHeadHandler ( ); @@ -174,6 +176,7 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType) case E_BLOCK_POWERED_RAIL: return new cBlockRailHandler (a_BlockType); case E_BLOCK_PUMPKIN: return new cBlockPumpkinHandler (a_BlockType); case E_BLOCK_PUMPKIN_STEM: return new cBlockStemsHandler (a_BlockType); + case E_BLOCK_QUARTZ_BLOCK: return new cBlockQuartsHandler (a_BlockType); case E_BLOCK_QUARTZ_STAIRS: return new cBlockStairsHandler (a_BlockType); case E_BLOCK_RAIL: return new cBlockRailHandler (a_BlockType); case E_BLOCK_REDSTONE_LAMP_ON: return new cBlockRedstoneLampHandler (a_BlockType); // We need this to change pickups to an off lamp; else 1.7+ clients crash diff --git a/src/Blocks/BlockQuartz.h b/src/Blocks/BlockQuartz.h new file mode 100644 index 000000000..a01abac7b --- /dev/null +++ b/src/Blocks/BlockQuartz.h @@ -0,0 +1,66 @@ + +#pragma once + +#include "BlockHandler.h" + + + + + +class cBlockQuartsHandler : public cBlockHandler +{ +public: + cBlockQuartsHandler(BLOCKTYPE a_BlockType) + : cBlockHandler(a_BlockType) + { + } + + + virtual bool GetPlacementBlockTypeMeta( + cChunkInterface & a_ChunkInterface, cPlayer * a_Player, + int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, + int a_CursorX, int a_CursorY, int a_CursorZ, + BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta + ) override + { + a_BlockType = m_BlockType; + NIBBLETYPE Meta = (NIBBLETYPE)(a_Player->GetEquippedItem().m_ItemDamage); + if (Meta != 0x2) // Check if the block is a pillar block. + { + return false; + } + + a_BlockMeta = BlockFaceToMetaData(a_BlockFace, Meta); + return true; + } + + inline static NIBBLETYPE BlockFaceToMetaData(char a_BlockFace, NIBBLETYPE a_QuartzMeta) + { + switch (a_BlockFace) + { + case BLOCK_FACE_YM: + case BLOCK_FACE_YP: + { + return a_QuartzMeta; // Top or bottom, just return original + } + + case BLOCK_FACE_ZP: + case BLOCK_FACE_ZM: + { + return 0x4; // North or south + } + + case BLOCK_FACE_XP: + case BLOCK_FACE_XM: + { + return 0x3; // East or west + } + + default: + { + ASSERT(!"Unhandled block face!"); + return a_QuartzMeta; // No idea, give a special meta (all sides the sa) + } + } + } +} ; \ No newline at end of file diff --git a/src/Blocks/BlockSideways.h b/src/Blocks/BlockSideways.h new file mode 100644 index 000000000..f11f0bee1 --- /dev/null +++ b/src/Blocks/BlockSideways.h @@ -0,0 +1,72 @@ + +#pragma once + +#include "BlockHandler.h" + + + + + +class cBlockSidewaysHandler : public cBlockHandler +{ +public: + cBlockSidewaysHandler(BLOCKTYPE a_BlockType) + : cBlockHandler(a_BlockType) + { + } + + + virtual bool GetPlacementBlockTypeMeta( + cChunkInterface & a_ChunkInterface, cPlayer * a_Player, + int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, + int a_CursorX, int a_CursorY, int a_CursorZ, + BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta + ) override + { + a_BlockType = m_BlockType; + NIBBLETYPE Meta = (NIBBLETYPE)(a_Player->GetEquippedItem().m_ItemDamage); + a_BlockMeta = BlockFaceToMetaData(a_BlockFace, Meta); + return true; + } + + + inline static NIBBLETYPE BlockFaceToMetaData(char a_BlockFace, NIBBLETYPE a_WoodMeta) + { + switch (a_BlockFace) + { + case BLOCK_FACE_YM: + case BLOCK_FACE_YP: + { + return a_WoodMeta; // Top or bottom, just return original + } + + case BLOCK_FACE_ZP: + case BLOCK_FACE_ZM: + { + return a_WoodMeta | 0x8; // North or south + } + + case BLOCK_FACE_XP: + case BLOCK_FACE_XM: + { + return a_WoodMeta | 0x4; // East or west + } + + default: + { + ASSERT(!"Unhandled block face!"); + return a_WoodMeta | 0xC; // No idea, give a special meta (all sides bark) + } + } + } + + + virtual const char * GetStepSound(void) override + { + return "step.wood"; + } +} ; + + + + diff --git a/src/Blocks/BlockWood.h b/src/Blocks/BlockWood.h deleted file mode 100644 index cf49d0745..000000000 --- a/src/Blocks/BlockWood.h +++ /dev/null @@ -1,72 +0,0 @@ - -#pragma once - -#include "BlockHandler.h" - - - - - -class cBlockWoodHandler : public cBlockHandler -{ -public: - cBlockWoodHandler(BLOCKTYPE a_BlockType) - : cBlockHandler(a_BlockType) - { - } - - - virtual bool GetPlacementBlockTypeMeta( - cChunkInterface & a_ChunkInterface, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, - int a_CursorX, int a_CursorY, int a_CursorZ, - BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta - ) override - { - a_BlockType = m_BlockType; - NIBBLETYPE Meta = (NIBBLETYPE)(a_Player->GetEquippedItem().m_ItemDamage); - a_BlockMeta = BlockFaceToMetaData(a_BlockFace, Meta); - return true; - } - - - inline static NIBBLETYPE BlockFaceToMetaData(char a_BlockFace, NIBBLETYPE a_WoodMeta) - { - switch (a_BlockFace) - { - case BLOCK_FACE_YM: - case BLOCK_FACE_YP: - { - return a_WoodMeta; // Top or bottom, just return original - } - - case BLOCK_FACE_ZP: - case BLOCK_FACE_ZM: - { - return a_WoodMeta | 0x8; // North or south - } - - case BLOCK_FACE_XP: - case BLOCK_FACE_XM: - { - return a_WoodMeta | 0x4; // East or west - } - - default: - { - ASSERT(!"Unhandled block face!"); - return a_WoodMeta | 0xC; // No idea, give a special meta (all sides bark) - } - } - } - - - virtual const char * GetStepSound(void) override - { - return "step.wood"; - } -} ; - - - - -- cgit v1.2.3 From 0c29c52ff3713047fe280bdc07d7a2f09e9a32e8 Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Mon, 3 Feb 2014 20:22:45 +0100 Subject: Renamed cBlockQuartsHandler to cBlockQuartzHandler. Fixed not being able to place normal quartz blocks. --- src/Blocks/BlockHandler.cpp | 2 +- src/Blocks/BlockQuartz.h | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/Blocks/BlockHandler.cpp b/src/Blocks/BlockHandler.cpp index 3ecf0d7e2..657058e3e 100644 --- a/src/Blocks/BlockHandler.cpp +++ b/src/Blocks/BlockHandler.cpp @@ -176,7 +176,7 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType) case E_BLOCK_POWERED_RAIL: return new cBlockRailHandler (a_BlockType); case E_BLOCK_PUMPKIN: return new cBlockPumpkinHandler (a_BlockType); case E_BLOCK_PUMPKIN_STEM: return new cBlockStemsHandler (a_BlockType); - case E_BLOCK_QUARTZ_BLOCK: return new cBlockQuartsHandler (a_BlockType); + case E_BLOCK_QUARTZ_BLOCK: return new cBlockQuartzHandler (a_BlockType); case E_BLOCK_QUARTZ_STAIRS: return new cBlockStairsHandler (a_BlockType); case E_BLOCK_RAIL: return new cBlockRailHandler (a_BlockType); case E_BLOCK_REDSTONE_LAMP_ON: return new cBlockRedstoneLampHandler (a_BlockType); // We need this to change pickups to an off lamp; else 1.7+ clients crash diff --git a/src/Blocks/BlockQuartz.h b/src/Blocks/BlockQuartz.h index a01abac7b..e5306ff6a 100644 --- a/src/Blocks/BlockQuartz.h +++ b/src/Blocks/BlockQuartz.h @@ -7,10 +7,10 @@ -class cBlockQuartsHandler : public cBlockHandler +class cBlockQuartzHandler : public cBlockHandler { public: - cBlockQuartsHandler(BLOCKTYPE a_BlockType) + cBlockQuartzHandler(BLOCKTYPE a_BlockType) : cBlockHandler(a_BlockType) { } @@ -27,7 +27,7 @@ public: NIBBLETYPE Meta = (NIBBLETYPE)(a_Player->GetEquippedItem().m_ItemDamage); if (Meta != 0x2) // Check if the block is a pillar block. { - return false; + return true; } a_BlockMeta = BlockFaceToMetaData(a_BlockFace, Meta); -- cgit v1.2.3 From 347488a9a23e43b59062a8f161bcc7f88628db56 Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Mon, 3 Feb 2014 20:34:05 +0100 Subject: Fixed some issues. Meta wasn't set if the block wasn't a pillar. Fixed typo. --- src/Blocks/BlockQuartz.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/Blocks/BlockQuartz.h b/src/Blocks/BlockQuartz.h index e5306ff6a..41f4e15a7 100644 --- a/src/Blocks/BlockQuartz.h +++ b/src/Blocks/BlockQuartz.h @@ -27,6 +27,7 @@ public: NIBBLETYPE Meta = (NIBBLETYPE)(a_Player->GetEquippedItem().m_ItemDamage); if (Meta != 0x2) // Check if the block is a pillar block. { + a_BlockMeta = Meta; return true; } @@ -59,7 +60,7 @@ public: default: { ASSERT(!"Unhandled block face!"); - return a_QuartzMeta; // No idea, give a special meta (all sides the sa) + return a_QuartzMeta; // No idea, give a special meta (all sides the same) } } } -- cgit v1.2.3 From c2e7dd34d98258bdfa5baa2f27f08999909996c5 Mon Sep 17 00:00:00 2001 From: tonibm19 Date: Mon, 3 Feb 2014 20:52:11 +0100 Subject: Exporded World:FindClosestPlayer, Item:IsEnchantable and Monster:MoveToPosition to Lua API --- src/Entities/Entity.h | 1 + src/Item.h | 2 +- src/Mobs/Monster.cpp | 8 ++++++++ src/Mobs/Monster.h | 1 + src/World.cpp | 2 +- src/World.h | 2 +- 6 files changed, 13 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/Entities/Entity.h b/src/Entities/Entity.h index b2edfc2b4..5287e3a6d 100644 --- a/src/Entities/Entity.h +++ b/src/Entities/Entity.h @@ -158,6 +158,7 @@ public: double GetHeight (void) const { return m_Height; } double GetMass (void) const { return m_Mass; } const Vector3d & GetPosition (void) const { return m_Pos; } + const Vector3d & GetPosition (void) const { return m_Pos; } double GetPosX (void) const { return m_Pos.x; } double GetPosY (void) const { return m_Pos.y; } double GetPosZ (void) const { return m_Pos.z; } diff --git a/src/Item.h b/src/Item.h index 727965112..7781db0cb 100644 --- a/src/Item.h +++ b/src/Item.h @@ -167,7 +167,7 @@ public: void FromJson(const Json::Value & a_Value); /// Returns true if the specified item type is enchantable (as per 1.2.5 protocol requirements) - static bool IsEnchantable(short a_ItemType); + static bool IsEnchantable(short a_ItemType); // tolua_export // tolua_begin diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp index 283ef36e6..35880bcff 100644 --- a/src/Mobs/Monster.cpp +++ b/src/Mobs/Monster.cpp @@ -188,6 +188,14 @@ void cMonster::MoveToPosition(const Vector3f & a_Position) TickPathFinding(); } +void cMonster::MoveToPosition(const Vector3d & a_Position) +{ + FinishPathFinding(); + + m_FinalDestination = a_Position; + m_bMovingToDestination = true; + TickPathFinding(); +} diff --git a/src/Mobs/Monster.h b/src/Mobs/Monster.h index 1dd302cdc..714feddb9 100644 --- a/src/Mobs/Monster.h +++ b/src/Mobs/Monster.h @@ -91,6 +91,7 @@ public: virtual void KilledBy(cEntity * a_Killer) override; virtual void MoveToPosition(const Vector3f & a_Position); + virtual void MoveToPosition(const Vector3d & a_Position); // tolua_export virtual bool ReachedDestination(void); // tolua_begin diff --git a/src/World.cpp b/src/World.cpp index de2002b84..410326b2d 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -2339,7 +2339,7 @@ bool cWorld::FindAndDoWithPlayer(const AString & a_PlayerNameHint, cPlayerListCa // TODO: This interface is dangerous! -cPlayer * cWorld::FindClosestPlayer(const Vector3f & a_Pos, float a_SightLimit, bool a_CheckLineOfSight) +cPlayer * cWorld::FindClosestPlayer(const Vector3d & a_Pos, float a_SightLimit, bool a_CheckLineOfSight) { cTracer LineOfSight(this); diff --git a/src/World.h b/src/World.h index bf6a4ba28..531154181 100644 --- a/src/World.h +++ b/src/World.h @@ -248,7 +248,7 @@ public: bool FindAndDoWithPlayer(const AString & a_PlayerNameHint, cPlayerListCallback & a_Callback); // >> EXPORTED IN MANUALBINDINGS << // TODO: This interface is dangerous - rewrite to DoWithClosestPlayer(pos, sight, action) - cPlayer * FindClosestPlayer(const Vector3f & a_Pos, float a_SightLimit, bool a_CheckLineOfSight = true); + cPlayer * FindClosestPlayer(const Vector3d & a_Pos, float a_SightLimit, bool a_CheckLineOfSight = true); // tolua_export void SendPlayerList(cPlayer * a_DestPlayer); // Sends playerlist to the player -- cgit v1.2.3 From defb001ad7f242e524530770a02c65f1bf455c19 Mon Sep 17 00:00:00 2001 From: tonibm19 Date: Mon, 3 Feb 2014 21:05:10 +0100 Subject: Fixed compilation --- src/Entities/Entity.h | 1 - 1 file changed, 1 deletion(-) (limited to 'src') diff --git a/src/Entities/Entity.h b/src/Entities/Entity.h index 5287e3a6d..b2edfc2b4 100644 --- a/src/Entities/Entity.h +++ b/src/Entities/Entity.h @@ -158,7 +158,6 @@ public: double GetHeight (void) const { return m_Height; } double GetMass (void) const { return m_Mass; } const Vector3d & GetPosition (void) const { return m_Pos; } - const Vector3d & GetPosition (void) const { return m_Pos; } double GetPosX (void) const { return m_Pos.x; } double GetPosY (void) const { return m_Pos.y; } double GetPosZ (void) const { return m_Pos.z; } -- cgit v1.2.3 From df8b589b31af5a94c06ad042a1d2b01f723ab4ee Mon Sep 17 00:00:00 2001 From: tonibm19 Date: Mon, 3 Feb 2014 21:06:43 +0100 Subject: Not exporting FindClosestPlayer --- src/World.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/World.h b/src/World.h index 531154181..33db16614 100644 --- a/src/World.h +++ b/src/World.h @@ -248,7 +248,7 @@ public: bool FindAndDoWithPlayer(const AString & a_PlayerNameHint, cPlayerListCallback & a_Callback); // >> EXPORTED IN MANUALBINDINGS << // TODO: This interface is dangerous - rewrite to DoWithClosestPlayer(pos, sight, action) - cPlayer * FindClosestPlayer(const Vector3d & a_Pos, float a_SightLimit, bool a_CheckLineOfSight = true); // tolua_export + cPlayer * FindClosestPlayer(const Vector3d & a_Pos, float a_SightLimit, bool a_CheckLineOfSight = true); void SendPlayerList(cPlayer * a_DestPlayer); // Sends playerlist to the player -- cgit v1.2.3 From 80807eec2cc1c497c4766a0c7cddb9c3ddc29e45 Mon Sep 17 00:00:00 2001 From: Tycho Date: Mon, 3 Feb 2014 12:26:17 -0800 Subject: Increased Type safety of Biomes Changed a number of funcictions from using integers to store biomes to using EMCSBiome Note that switching from an int to an Enum is a non-breaking chang to the lua bindings --- src/BiomeDef.cpp | 14 +++++++++++--- src/BiomeDef.h | 9 ++++++++- src/Generating/BioGen.cpp | 10 +++++----- src/Generating/ChunkDesc.cpp | 4 ++-- src/Generating/ChunkDesc.h | 2 +- src/Mobs/SnowGolem.cpp | 2 +- src/World.cpp | 4 ++-- src/World.h | 2 +- 8 files changed, 31 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/BiomeDef.cpp b/src/BiomeDef.cpp index 89a1cdefb..5c1156484 100644 --- a/src/BiomeDef.cpp +++ b/src/BiomeDef.cpp @@ -13,8 +13,16 @@ EMCSBiome StringToBiome(const AString & a_BiomeString) int res = atoi(a_BiomeString.c_str()); if ((res != 0) || (a_BiomeString.compare("0") == 0)) { - // It was a valid number - return (EMCSBiome)res; + if(res >= biFirstBiome && res < biNumBiomes) + { + return (EMCSBiome)res; + } + else if(res >= biFirstVarientBiome && res < biNumVarientBiomes) + { + return (EMCSBiome)res; + } + // It was an invalid number + return biInvalidBiome; } // Convert using the built-in map: @@ -100,7 +108,7 @@ EMCSBiome StringToBiome(const AString & a_BiomeString) return BiomeMap[i].m_Biome; } } // for i - BiomeMap[] - return (EMCSBiome)-1; + return biInvalidBiome; } diff --git a/src/BiomeDef.h b/src/BiomeDef.h index df1e387f0..f015dd836 100644 --- a/src/BiomeDef.h +++ b/src/BiomeDef.h @@ -20,6 +20,9 @@ BiomeIDs over 255 are used by MCServer internally and are translated to MC biome */ enum EMCSBiome { + biInvalidBiome = -1, + + biFirstBiome = 0, biOcean = 0, biPlains = 1, biDesert = 2, @@ -74,6 +77,7 @@ enum EMCSBiome biVariant = 128, // Release 1.7 biome variants: + biFirstVarientBiome = 129, biSunflowerPlains = 129, biDesertM = 130, biExtremeHillsM = 131, @@ -95,9 +99,12 @@ enum EMCSBiome biMesaBryce = 165, biMesaPlateauFM = 166, biMesaPlateauM = 167, + // Automatically capture the maximum consecutive biome value into biVarientMaxBiome: + biNumVarientBiomes, // True number of biomes, since they are zero-based + biMaxVarientBiome = biNumVarientBiomes - 1, // The maximum biome value } ; -/// Translates a biome string to biome enum. Takes either a number or a biome alias (built-in). Returns -1 on failure. +/// Translates a biome string to biome enum. Takes either a number or a biome alias (built-in). Returns biInvalidBiome on failure. extern EMCSBiome StringToBiome(const AString & a_BiomeString); /// Returns true if the biome has no downfall - deserts and savannas diff --git a/src/Generating/BioGen.cpp b/src/Generating/BioGen.cpp index f89b1800d..1a18f53f1 100644 --- a/src/Generating/BioGen.cpp +++ b/src/Generating/BioGen.cpp @@ -97,7 +97,7 @@ void cBioGenConstant::InitializeBiomeGen(cIniFile & a_IniFile) { AString Biome = a_IniFile.GetValueSet("Generator", "ConstantBiome", "Plains"); m_Biome = StringToBiome(Biome); - if (m_Biome == -1) + if (m_Biome == EMCSBiome::biInvalidBiome) { LOGWARN("[Generator]::ConstantBiome value \"%s\" not recognized, using \"Plains\".", Biome.c_str()); m_Biome = biPlains; @@ -233,7 +233,7 @@ void cBiomeGenList::InitializeBiomes(const AString & a_Biomes) } } EMCSBiome Biome = StringToBiome(Split2[0]); - if (Biome != -1) + if (Biome != EMCSBiome::biInvalidBiome) { for (int i = 0; i < Count; i++) { @@ -500,7 +500,7 @@ void cBioGenMultiStepMap::DecideOceanLandMushroom(int a_ChunkX, int a_ChunkZ, cC int OffsetZ = (m_Noise4.IntNoise3DInt(RealCellX, 32 * RealCellX - 16 * RealCellZ, RealCellZ) / 8) % m_OceanCellSize; SeedX[xc][zc] = CellBlockX + OffsetX; SeedZ[xc][zc] = CellBlockZ + OffsetZ; - SeedV[xc][zc] = (((m_Noise6.IntNoise3DInt(RealCellX, RealCellX - RealCellZ + 1000, RealCellZ) / 11) % 256) > 90) ? biOcean : ((EMCSBiome)(-1)); + SeedV[xc][zc] = (((m_Noise6.IntNoise3DInt(RealCellX, RealCellX - RealCellZ + 1000, RealCellZ) / 11) % 256) > 90) ? biOcean : (EMCSBiome::biInvalidBiome); } // for z } // for x @@ -573,7 +573,7 @@ void cBioGenMultiStepMap::AddRivers(int a_ChunkX, int a_ChunkZ, cChunkDef::Biome float NoiseCoordZ = (float)(a_ChunkZ * cChunkDef::Width + z) / m_RiverCellSize; for (int x = 0; x < cChunkDef::Width; x++) { - if (cChunkDef::GetBiome(a_BiomeMap, x, z) != -1) + if (cChunkDef::GetBiome(a_BiomeMap, x, z) != EMCSBiome::biInvalidBiome) { // Biome already set, skip this column continue; @@ -693,7 +693,7 @@ void cBioGenMultiStepMap::DecideLandBiomes(cChunkDef::BiomeMap & a_BiomeMap, con int idxZ = 17 * z; for (int x = 0; x < cChunkDef::Width; x++) { - if (cChunkDef::GetBiome(a_BiomeMap, x, z) != -1) + if (cChunkDef::GetBiome(a_BiomeMap, x, z) != EMCSBiome::biInvalidBiome) { // Already set before continue; diff --git a/src/Generating/ChunkDesc.cpp b/src/Generating/ChunkDesc.cpp index 87566aa78..d9529b4b0 100644 --- a/src/Generating/ChunkDesc.cpp +++ b/src/Generating/ChunkDesc.cpp @@ -118,9 +118,9 @@ void cChunkDesc::SetBlockMeta(int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_B -void cChunkDesc::SetBiome(int a_RelX, int a_RelZ, int a_BiomeID) +void cChunkDesc::SetBiome(int a_RelX, int a_RelZ, EMCSBiome a_BiomeID) { - cChunkDef::SetBiome(m_BiomeMap, a_RelX, a_RelZ, (EMCSBiome)a_BiomeID); + cChunkDef::SetBiome(m_BiomeMap, a_RelX, a_RelZ, a_BiomeID); } diff --git a/src/Generating/ChunkDesc.h b/src/Generating/ChunkDesc.h index e258383d5..8edc2800b 100644 --- a/src/Generating/ChunkDesc.h +++ b/src/Generating/ChunkDesc.h @@ -53,7 +53,7 @@ public: void SetBlockMeta(int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_BlockMeta); NIBBLETYPE GetBlockMeta(int a_RelX, int a_RelY, int a_RelZ); - void SetBiome(int a_RelX, int a_RelZ, int a_BiomeID); + void SetBiome(int a_RelX, int a_RelZ, EMCSBiome a_BiomeID); EMCSBiome GetBiome(int a_RelX, int a_RelZ); // These operate on the heightmap, so they could get out of sync with the data diff --git a/src/Mobs/SnowGolem.cpp b/src/Mobs/SnowGolem.cpp index 06021cca5..c60103055 100644 --- a/src/Mobs/SnowGolem.cpp +++ b/src/Mobs/SnowGolem.cpp @@ -29,7 +29,7 @@ void cSnowGolem::GetDrops(cItems & a_Drops, cEntity * a_Killer) void cSnowGolem::Tick(float a_Dt, cChunk & a_Chunk) { super::Tick(a_Dt, a_Chunk); - if (IsBiomeNoDownfall((EMCSBiome) m_World->GetBiomeAt((int) floor(GetPosX()), (int) floor(GetPosZ())) )) + if (IsBiomeNoDownfall(m_World->GetBiomeAt((int) floor(GetPosX()), (int) floor(GetPosZ())) )) { TakeDamage(*this); } diff --git a/src/World.cpp b/src/World.cpp index de2002b84..f9a6e7776 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -1222,7 +1222,7 @@ void cWorld::GrowTreeByBiome(int a_X, int a_Y, int a_Z) { cNoise Noise(m_Generator.GetSeed()); sSetBlockVector Logs, Other; - GetTreeImageByBiome(a_X, a_Y, a_Z, Noise, (int)(m_WorldAge & 0xffffffff), (EMCSBiome)GetBiomeAt(a_X, a_Z), Logs, Other); + GetTreeImageByBiome(a_X, a_Y, a_Z, Noise, (int)(m_WorldAge & 0xffffffff), GetBiomeAt(a_X, a_Z), Logs, Other); Other.insert(Other.begin(), Logs.begin(), Logs.end()); Logs.clear(); GrowTreeImage(Other); @@ -1475,7 +1475,7 @@ void cWorld::GrowSugarcane(int a_BlockX, int a_BlockY, int a_BlockZ, int a_NumBl -int cWorld::GetBiomeAt (int a_BlockX, int a_BlockZ) +EMCSBiome cWorld::GetBiomeAt (int a_BlockX, int a_BlockZ) { return m_ChunkMap->GetBiomeAt(a_BlockX, a_BlockZ); } diff --git a/src/World.h b/src/World.h index bf6a4ba28..afdc09788 100644 --- a/src/World.h +++ b/src/World.h @@ -526,7 +526,7 @@ public: void GrowSugarcane(int a_BlockX, int a_BlockY, int a_BlockZ, int a_NumBlocksToGrow); /** Returns the biome at the specified coords. Reads the biome from the chunk, if loaded, otherwise uses the world generator to provide the biome value */ - int GetBiomeAt(int a_BlockX, int a_BlockZ); + EMCSBiome GetBiomeAt(int a_BlockX, int a_BlockZ); /** Returns the name of the world */ const AString & GetName(void) const { return m_WorldName; } -- cgit v1.2.3 From f8881622a4000d769af700396f772bae21d1d117 Mon Sep 17 00:00:00 2001 From: Tycho Date: Mon, 3 Feb 2014 12:31:18 -0800 Subject: Removed unused lookups --- src/Simulator/FluidSimulator.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'src') diff --git a/src/Simulator/FluidSimulator.cpp b/src/Simulator/FluidSimulator.cpp index 72b2eb628..61c93ed73 100644 --- a/src/Simulator/FluidSimulator.cpp +++ b/src/Simulator/FluidSimulator.cpp @@ -166,14 +166,12 @@ Direction cFluidSimulator::GetFlowingDirection(int a_X, int a_Y, int a_Z, bool a { LowestPoint = Meta; X = Pos->x; - Pos->y; //Remove if no side effects Z = Pos->z; } }else if(BlockID == E_BLOCK_AIR) { LowestPoint = 9; //This always dominates X = Pos->x; - Pos->y; //Remove if no side effects Z = Pos->z; } -- cgit v1.2.3 From d9fb83300cf831ea31a74d509f9be9f2ed4f1189 Mon Sep 17 00:00:00 2001 From: Tycho Date: Mon, 3 Feb 2014 13:01:12 -0800 Subject: Fixed Compile errors c++11 introduces scoped enums, so the code didn't fail in clang --- src/BiomeDef.cpp | 4 ++-- src/BiomeDef.h | 6 +++--- src/Generating/BioGen.cpp | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/BiomeDef.cpp b/src/BiomeDef.cpp index 5c1156484..3fba93e8a 100644 --- a/src/BiomeDef.cpp +++ b/src/BiomeDef.cpp @@ -13,11 +13,11 @@ EMCSBiome StringToBiome(const AString & a_BiomeString) int res = atoi(a_BiomeString.c_str()); if ((res != 0) || (a_BiomeString.compare("0") == 0)) { - if(res >= biFirstBiome && res < biNumBiomes) + if ((res >= biFirstBiome) && (res < biNumBiomes)) { return (EMCSBiome)res; } - else if(res >= biFirstVarientBiome && res < biNumVarientBiomes) + else if ((res >= biFirstVariantBiome) && (res < biNumVariantBiomes)) { return (EMCSBiome)res; } diff --git a/src/BiomeDef.h b/src/BiomeDef.h index f015dd836..474d4df76 100644 --- a/src/BiomeDef.h +++ b/src/BiomeDef.h @@ -77,7 +77,7 @@ enum EMCSBiome biVariant = 128, // Release 1.7 biome variants: - biFirstVarientBiome = 129, + biFirstVariantBiome = 129, biSunflowerPlains = 129, biDesertM = 130, biExtremeHillsM = 131, @@ -100,8 +100,8 @@ enum EMCSBiome biMesaPlateauFM = 166, biMesaPlateauM = 167, // Automatically capture the maximum consecutive biome value into biVarientMaxBiome: - biNumVarientBiomes, // True number of biomes, since they are zero-based - biMaxVarientBiome = biNumVarientBiomes - 1, // The maximum biome value + biNumVariantBiomes, // True number of biomes, since they are zero-based + biMaxVariantBiome = biNumVariantBiomes - 1, // The maximum biome value } ; /// Translates a biome string to biome enum. Takes either a number or a biome alias (built-in). Returns biInvalidBiome on failure. diff --git a/src/Generating/BioGen.cpp b/src/Generating/BioGen.cpp index 1a18f53f1..20f269fc8 100644 --- a/src/Generating/BioGen.cpp +++ b/src/Generating/BioGen.cpp @@ -97,7 +97,7 @@ void cBioGenConstant::InitializeBiomeGen(cIniFile & a_IniFile) { AString Biome = a_IniFile.GetValueSet("Generator", "ConstantBiome", "Plains"); m_Biome = StringToBiome(Biome); - if (m_Biome == EMCSBiome::biInvalidBiome) + if (m_Biome == biInvalidBiome) { LOGWARN("[Generator]::ConstantBiome value \"%s\" not recognized, using \"Plains\".", Biome.c_str()); m_Biome = biPlains; -- cgit v1.2.3 From 4b1924730502c26519202c9fa8ea9e77976475e5 Mon Sep 17 00:00:00 2001 From: Tycho Date: Mon, 3 Feb 2014 13:07:38 -0800 Subject: Fogot to save Biogen --- src/Generating/BioGen.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/Generating/BioGen.cpp b/src/Generating/BioGen.cpp index 20f269fc8..967deba6a 100644 --- a/src/Generating/BioGen.cpp +++ b/src/Generating/BioGen.cpp @@ -233,7 +233,7 @@ void cBiomeGenList::InitializeBiomes(const AString & a_Biomes) } } EMCSBiome Biome = StringToBiome(Split2[0]); - if (Biome != EMCSBiome::biInvalidBiome) + if (Biome != biInvalidBiome) { for (int i = 0; i < Count; i++) { @@ -500,7 +500,7 @@ void cBioGenMultiStepMap::DecideOceanLandMushroom(int a_ChunkX, int a_ChunkZ, cC int OffsetZ = (m_Noise4.IntNoise3DInt(RealCellX, 32 * RealCellX - 16 * RealCellZ, RealCellZ) / 8) % m_OceanCellSize; SeedX[xc][zc] = CellBlockX + OffsetX; SeedZ[xc][zc] = CellBlockZ + OffsetZ; - SeedV[xc][zc] = (((m_Noise6.IntNoise3DInt(RealCellX, RealCellX - RealCellZ + 1000, RealCellZ) / 11) % 256) > 90) ? biOcean : (EMCSBiome::biInvalidBiome); + SeedV[xc][zc] = (((m_Noise6.IntNoise3DInt(RealCellX, RealCellX - RealCellZ + 1000, RealCellZ) / 11) % 256) > 90) ? biOcean : (biInvalidBiome); } // for z } // for x @@ -573,7 +573,7 @@ void cBioGenMultiStepMap::AddRivers(int a_ChunkX, int a_ChunkZ, cChunkDef::Biome float NoiseCoordZ = (float)(a_ChunkZ * cChunkDef::Width + z) / m_RiverCellSize; for (int x = 0; x < cChunkDef::Width; x++) { - if (cChunkDef::GetBiome(a_BiomeMap, x, z) != EMCSBiome::biInvalidBiome) + if (cChunkDef::GetBiome(a_BiomeMap, x, z) != biInvalidBiome) { // Biome already set, skip this column continue; @@ -693,7 +693,7 @@ void cBioGenMultiStepMap::DecideLandBiomes(cChunkDef::BiomeMap & a_BiomeMap, con int idxZ = 17 * z; for (int x = 0; x < cChunkDef::Width; x++) { - if (cChunkDef::GetBiome(a_BiomeMap, x, z) != EMCSBiome::biInvalidBiome) + if (cChunkDef::GetBiome(a_BiomeMap, x, z) != biInvalidBiome) { // Already set before continue; -- cgit v1.2.3 From 70e48960acdbc09bedd4bbeb536e6aa46b50f82e Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Mon, 3 Feb 2014 22:30:32 +0100 Subject: Named the different quartz block. --- src/BlockID.h | 5 +++++ src/Blocks/BlockQuartz.h | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/BlockID.h b/src/BlockID.h index b31c589b9..612eee1fc 100644 --- a/src/BlockID.h +++ b/src/BlockID.h @@ -500,6 +500,11 @@ enum E_META_PLANKS_BIRCH = 2, E_META_PLANKS_JUNGLE = 3, + // E_BLOCK_QUARTZ_BLOCK metas: + E_META_QUARTZ_NORMAL = 0, + E_META_QUARTZ_CHISELLED = 1, + E_META_QUARTZ_PILLAR = 2, + // E_BLOCK_RAIL metas E_META_RAIL_ZM_ZP = 0, E_META_RAIL_XM_XP = 1, diff --git a/src/Blocks/BlockQuartz.h b/src/Blocks/BlockQuartz.h index 41f4e15a7..a9f8f9046 100644 --- a/src/Blocks/BlockQuartz.h +++ b/src/Blocks/BlockQuartz.h @@ -25,7 +25,7 @@ public: { a_BlockType = m_BlockType; NIBBLETYPE Meta = (NIBBLETYPE)(a_Player->GetEquippedItem().m_ItemDamage); - if (Meta != 0x2) // Check if the block is a pillar block. + if (Meta != E_META_QUARTZ_PILLAR) // Check if the block is a pillar block. { a_BlockMeta = Meta; return true; -- cgit v1.2.3 From d1b5f0859a4176a31f764b23cf0fce49743d245e Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Mon, 3 Feb 2014 22:55:15 +0000 Subject: Greatly improved TNT propulsion chances --- src/ChunkMap.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/ChunkMap.cpp b/src/ChunkMap.cpp index 1e2181f32..757396a20 100644 --- a/src/ChunkMap.cpp +++ b/src/ChunkMap.cpp @@ -1808,7 +1808,7 @@ void cChunkMap::DoExplosionAt(double a_ExplosionSize, double a_BlockX, double a_ if (FinalDamage > a_Entity->GetMaxHealth()) FinalDamage = a_Entity->GetMaxHealth(); else if (FinalDamage < 0) - return false; + FinalDamage = 0; if (!a_Entity->IsTNT()) // Don't apply damage to other TNT entities, they should be invincible { -- cgit v1.2.3 From aa19f4fd042c7085d1b7f6d692ffee7bf5a7ff80 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 4 Feb 2014 09:18:32 +0100 Subject: Improved error resistance in cPluginManager:CallPlugin(). Fixed: If the call failed, all the next plugin calls would fail as well. --- src/Bindings/LuaState.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src') diff --git a/src/Bindings/LuaState.cpp b/src/Bindings/LuaState.cpp index d49cd8ef3..6a02197e8 100644 --- a/src/Bindings/LuaState.cpp +++ b/src/Bindings/LuaState.cpp @@ -1066,6 +1066,8 @@ int cLuaState::CallFunctionWithForeignParams( { // Something went wrong, fix the stack and exit lua_pop(m_LuaState, 2); + m_NumCurrentFunctionArgs = -1; + m_CurrentFunctionName.clear(); return -1; } @@ -1081,11 +1083,17 @@ int cLuaState::CallFunctionWithForeignParams( { lua_pop(m_LuaState, CurTop - OldTop); } + + // Reset the internal checking mechanisms: + m_NumCurrentFunctionArgs = -1; + m_CurrentFunctionName.clear(); + return -1; } // Reset the internal checking mechanisms: m_NumCurrentFunctionArgs = -1; + m_CurrentFunctionName.clear(); // Remove the error handler from the stack: lua_remove(m_LuaState, OldTop + 1); -- cgit v1.2.3 From 69c85e5169e5322857d2dfbfccd45281ca1be1c4 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 4 Feb 2014 10:29:10 +0100 Subject: Fixed error handling in cPluginManager:CallPlugin() API. Fixed: When the called function malfunctioned, the entire plugin's call was aborted. --- src/Bindings/LuaState.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/Bindings/LuaState.cpp b/src/Bindings/LuaState.cpp index 6a02197e8..0a3f6f5b7 100644 --- a/src/Bindings/LuaState.cpp +++ b/src/Bindings/LuaState.cpp @@ -1072,7 +1072,8 @@ int cLuaState::CallFunctionWithForeignParams( } // Call the function, with an error handler: - int s = lua_pcall(m_LuaState, a_SrcParamEnd - a_SrcParamStart + 1, LUA_MULTRET, OldTop); + LogStack("Before pcall"); + int s = lua_pcall(m_LuaState, a_SrcParamEnd - a_SrcParamStart + 1, LUA_MULTRET, OldTop + 1); if (ReportErrors(s)) { LOGWARN("Error while calling function '%s' in '%s'", a_FunctionName.c_str(), m_SubsystemName.c_str()); @@ -1088,7 +1089,9 @@ int cLuaState::CallFunctionWithForeignParams( m_NumCurrentFunctionArgs = -1; m_CurrentFunctionName.clear(); - return -1; + // Make Lua think everything is okay and return 0 values, so that plugins continue executing. + // The failure is indicated by the zero return values. + return 0; } // Reset the internal checking mechanisms: -- cgit v1.2.3 From 1dbfd7eb764f1ad32351257de85925a256c2bc45 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 4 Feb 2014 11:37:34 +0100 Subject: Removed a leftover debug message. --- src/Bindings/LuaState.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'src') diff --git a/src/Bindings/LuaState.cpp b/src/Bindings/LuaState.cpp index 0a3f6f5b7..1bec5e525 100644 --- a/src/Bindings/LuaState.cpp +++ b/src/Bindings/LuaState.cpp @@ -1072,7 +1072,6 @@ int cLuaState::CallFunctionWithForeignParams( } // Call the function, with an error handler: - LogStack("Before pcall"); int s = lua_pcall(m_LuaState, a_SrcParamEnd - a_SrcParamStart + 1, LUA_MULTRET, OldTop + 1); if (ReportErrors(s)) { -- cgit v1.2.3 From 3dc1452790c1986daa0375da15b79cc3f8ae61a8 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 4 Feb 2014 14:26:36 +0100 Subject: Fixed calling plugins with userdata params. --- src/Bindings/LuaState.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/Bindings/LuaState.cpp b/src/Bindings/LuaState.cpp index 1bec5e525..8dd17c448 100644 --- a/src/Bindings/LuaState.cpp +++ b/src/Bindings/LuaState.cpp @@ -1162,6 +1162,7 @@ int cLuaState::CopyStackFrom(cLuaState & a_SrcLuaState, int a_SrcStart, int a_Sr // Copy the value: void * ud = tolua_touserdata(a_SrcLuaState, i, NULL); tolua_pushusertype(m_LuaState, ud, type); + break; } default: { -- cgit v1.2.3 From a845b9abbb2531761b1ff25ba0e4d1958a4e9299 Mon Sep 17 00:00:00 2001 From: tonibm19 Date: Tue, 4 Feb 2014 17:29:36 +0100 Subject: Blank lines and indentation. Also removed GetClosestPlayer documentation --- src/Mobs/Monster.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp index 35880bcff..340761a7e 100644 --- a/src/Mobs/Monster.cpp +++ b/src/Mobs/Monster.cpp @@ -188,6 +188,10 @@ void cMonster::MoveToPosition(const Vector3f & a_Position) TickPathFinding(); } + + + + void cMonster::MoveToPosition(const Vector3d & a_Position) { FinishPathFinding(); -- cgit v1.2.3 From 634331fd3b84c4099dfbfbbde3edebf2a1f221eb Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 4 Feb 2014 18:38:10 +0100 Subject: Fixed chest placement. Fixes #624. --- src/Blocks/BlockChest.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/Blocks/BlockChest.h b/src/Blocks/BlockChest.h index 014b98063..280f2f288 100644 --- a/src/Blocks/BlockChest.h +++ b/src/Blocks/BlockChest.h @@ -110,9 +110,11 @@ public: return "step.wood"; } - virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ, const cChunk & a_Chunk) override + virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override { - return CanBeAt(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ); + int BlockX = a_RelX + a_Chunk.GetPosX() * cChunkDef::Width; + int BlockZ = a_RelZ + a_Chunk.GetPosZ() * cChunkDef::Width; + return CanBeAt(a_ChunkInterface, BlockX, a_RelY, BlockZ); } -- cgit v1.2.3 From 8464f689ea214d3c30105ae58539885cf1268317 Mon Sep 17 00:00:00 2001 From: Tycho Date: Tue, 4 Feb 2014 10:59:05 -0800 Subject: Improved Type safety of eBlockFace May Fix #640 --- src/Blocks/BlockBed.cpp | 4 ++-- src/Blocks/BlockBed.h | 4 ++-- src/Blocks/BlockButton.h | 8 ++++---- src/Blocks/BlockCarpet.h | 2 +- src/Blocks/BlockChest.h | 4 ++-- src/Blocks/BlockComparator.h | 4 ++-- src/Blocks/BlockDoor.cpp | 4 ++-- src/Blocks/BlockDoor.h | 6 +++--- src/Blocks/BlockDropSpenser.h | 2 +- src/Blocks/BlockEnderchest.h | 2 +- src/Blocks/BlockEntity.h | 2 +- src/Blocks/BlockFenceGate.h | 4 ++-- src/Blocks/BlockFurnace.h | 2 +- src/Blocks/BlockHandler.cpp | 6 +++--- src/Blocks/BlockHandler.h | 6 +++--- src/Blocks/BlockHopper.h | 2 +- src/Blocks/BlockLadder.h | 33 +++++++++++++++++---------------- src/Blocks/BlockLever.h | 8 ++++---- src/Blocks/BlockPiston.cpp | 2 +- src/Blocks/BlockPiston.h | 2 +- src/Blocks/BlockPlanks.h | 2 +- src/Blocks/BlockPortal.h | 2 +- src/Blocks/BlockPumpkin.h | 4 ++-- src/Blocks/BlockQuartz.h | 6 +++--- src/Blocks/BlockRail.h | 4 ++-- src/Blocks/BlockRedstoneRepeater.h | 4 ++-- src/Blocks/BlockSideways.h | 4 ++-- src/Blocks/BlockSign.h | 4 ++-- src/Blocks/BlockSlab.h | 2 +- src/Blocks/BlockSnow.h | 2 +- src/Blocks/BlockStairs.h | 2 +- src/Blocks/BlockTorch.h | 16 ++++++++-------- src/Blocks/BlockTrapdoor.h | 8 ++++---- src/Blocks/BlockVine.h | 2 +- src/Blocks/BlockWorkbench.h | 2 +- src/BoundingBox.cpp | 6 +++--- src/BoundingBox.h | 5 +++-- src/ClientHandle.cpp | 10 +++++----- src/ClientHandle.h | 10 +++++----- src/Defines.h | 6 ++---- src/Entities/Floater.cpp | 4 ++-- src/Entities/ProjectileEntity.cpp | 22 +++++++++++----------- src/Entities/ProjectileEntity.h | 18 +++++++++--------- src/Items/ItemBed.h | 2 +- src/Items/ItemBoat.h | 4 ++-- src/Items/ItemBow.h | 4 ++-- src/Items/ItemBrewingStand.h | 2 +- src/Items/ItemBucket.h | 4 ++-- src/Items/ItemCauldron.h | 2 +- src/Items/ItemComparator.h | 2 +- src/Items/ItemDoor.h | 2 +- src/Items/ItemDye.h | 2 +- src/Items/ItemFishingRod.h | 4 ++-- src/Items/ItemFlowerPot.h | 2 +- src/Items/ItemHandler.cpp | 6 +++--- src/Items/ItemHandler.h | 8 ++++---- src/Items/ItemHoe.h | 2 +- src/Items/ItemLeaves.h | 2 +- src/Items/ItemLighter.h | 2 +- src/Items/ItemMinecart.h | 2 +- src/Items/ItemNetherWart.h | 4 ++-- src/Items/ItemRedstoneDust.h | 2 +- src/Items/ItemRedstoneRepeater.h | 2 +- src/Items/ItemSapling.h | 2 +- src/Items/ItemSeeds.h | 2 +- src/Items/ItemShears.h | 2 +- src/Items/ItemShovel.h | 2 +- src/Items/ItemSign.h | 2 +- src/Items/ItemSpawnEgg.h | 2 +- src/Items/ItemSugarcane.h | 2 +- src/Items/ItemThrowable.h | 6 +++--- src/Piston.h | 21 ++++++++++++++++++++- src/Protocol/Protocol125.cpp | 4 ++-- src/Protocol/Protocol132.cpp | 2 +- src/Protocol/Protocol17x.cpp | 4 ++-- src/Simulator/RedstoneSimulator.cpp | 5 +++-- 76 files changed, 194 insertions(+), 174 deletions(-) (limited to 'src') diff --git a/src/Blocks/BlockBed.cpp b/src/Blocks/BlockBed.cpp index 65d397b36..2fd993817 100644 --- a/src/Blocks/BlockBed.cpp +++ b/src/Blocks/BlockBed.cpp @@ -7,7 +7,7 @@ void cBlockBedHandler::OnPlacedByPlayer( cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, + int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta ) @@ -51,7 +51,7 @@ void cBlockBedHandler::OnDestroyed(cChunkInterface & a_ChunkInterface, cWorldInt -void cBlockBedHandler::OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) +void cBlockBedHandler::OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) { if (a_WorldInterface.GetDimension() != dimOverworld) { diff --git a/src/Blocks/BlockBed.h b/src/Blocks/BlockBed.h index 0b86fe5e7..caec2b56f 100644 --- a/src/Blocks/BlockBed.h +++ b/src/Blocks/BlockBed.h @@ -20,9 +20,9 @@ public: } - virtual void OnPlacedByPlayer(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) override; + virtual void OnPlacedByPlayer(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) override; virtual void OnDestroyed(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, int a_BlockX, int a_BlockY, int a_BlockZ) override; - virtual void OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override; + virtual void OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override; virtual bool IsUseable(void) override diff --git a/src/Blocks/BlockButton.h b/src/Blocks/BlockButton.h index f592b94a1..ca6850ced 100644 --- a/src/Blocks/BlockButton.h +++ b/src/Blocks/BlockButton.h @@ -16,7 +16,7 @@ public: } - virtual void OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override + virtual void OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override { // Set p the ON bit to on NIBBLETYPE Meta = (a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ) | 0x08); @@ -44,7 +44,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cChunkInterface & a_ChunkInterface, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, + int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta ) override @@ -61,7 +61,7 @@ public: } - inline static NIBBLETYPE BlockFaceToMetaData(char a_BlockFace) + inline static NIBBLETYPE BlockFaceToMetaData(eBlockFace a_BlockFace) { switch (a_BlockFace) { @@ -77,7 +77,7 @@ public: } } - inline static NIBBLETYPE BlockMetaDataToBlockFace(NIBBLETYPE a_Meta) + inline static eBlockFace BlockMetaDataToBlockFace(NIBBLETYPE a_Meta) { switch (a_Meta & 0x7) { diff --git a/src/Blocks/BlockCarpet.h b/src/Blocks/BlockCarpet.h index 757d62c33..33dc1da6c 100644 --- a/src/Blocks/BlockCarpet.h +++ b/src/Blocks/BlockCarpet.h @@ -32,7 +32,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cChunkInterface & a_ChunkInterface, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, + int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta ) override diff --git a/src/Blocks/BlockChest.h b/src/Blocks/BlockChest.h index 014b98063..c2ac8ae27 100644 --- a/src/Blocks/BlockChest.h +++ b/src/Blocks/BlockChest.h @@ -21,7 +21,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cChunkInterface & a_ChunkInterface, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, + int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta ) override @@ -67,7 +67,7 @@ public: virtual void OnPlacedByPlayer( cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, + int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta ) override diff --git a/src/Blocks/BlockComparator.h b/src/Blocks/BlockComparator.h index 3b32efd6b..aba390d9d 100644 --- a/src/Blocks/BlockComparator.h +++ b/src/Blocks/BlockComparator.h @@ -18,7 +18,7 @@ public: } - virtual void OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override + virtual void OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override { NIBBLETYPE Meta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ); Meta ^= 0x04; // Toggle 3rd (addition/subtraction) bit with XOR @@ -47,7 +47,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cChunkInterface & a_ChunkInterface, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, + int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta ) override diff --git a/src/Blocks/BlockDoor.cpp b/src/Blocks/BlockDoor.cpp index 9d891f2b2..2ff5c1c37 100644 --- a/src/Blocks/BlockDoor.cpp +++ b/src/Blocks/BlockDoor.cpp @@ -43,7 +43,7 @@ void cBlockDoorHandler::OnDestroyed(cChunkInterface & a_ChunkInterface, cWorldIn -void cBlockDoorHandler::OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) +void cBlockDoorHandler::OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) { if (a_ChunkInterface.GetBlock(a_BlockX, a_BlockY, a_BlockZ) == E_BLOCK_WOODEN_DOOR) { @@ -57,7 +57,7 @@ void cBlockDoorHandler::OnUse(cChunkInterface & a_ChunkInterface, cWorldInterfac void cBlockDoorHandler::OnPlacedByPlayer( cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, + int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta ) diff --git a/src/Blocks/BlockDoor.h b/src/Blocks/BlockDoor.h index 2da561952..ef0dbb787 100644 --- a/src/Blocks/BlockDoor.h +++ b/src/Blocks/BlockDoor.h @@ -15,13 +15,13 @@ public: cBlockDoorHandler(BLOCKTYPE a_BlockType); virtual void OnDestroyed(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, int a_BlockX, int a_BlockY, int a_BlockZ) override; - virtual void OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override; + virtual void OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override; virtual const char * GetStepSound(void) override; virtual bool GetPlacementBlockTypeMeta( cChunkInterface & a_ChunkInterface, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, + int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta ) override @@ -54,7 +54,7 @@ public: virtual void OnPlacedByPlayer( cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, + int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta ) override; diff --git a/src/Blocks/BlockDropSpenser.h b/src/Blocks/BlockDropSpenser.h index 0c285612e..30d347ec9 100644 --- a/src/Blocks/BlockDropSpenser.h +++ b/src/Blocks/BlockDropSpenser.h @@ -23,7 +23,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cChunkInterface & a_ChunkInterface, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, + int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta ) override diff --git a/src/Blocks/BlockEnderchest.h b/src/Blocks/BlockEnderchest.h index 7ea09cd4c..b4b0b995d 100644 --- a/src/Blocks/BlockEnderchest.h +++ b/src/Blocks/BlockEnderchest.h @@ -24,7 +24,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cChunkInterface & a_ChunkInterface, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, + int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta ) override diff --git a/src/Blocks/BlockEntity.h b/src/Blocks/BlockEntity.h index f05bf16b1..7f86a22b2 100644 --- a/src/Blocks/BlockEntity.h +++ b/src/Blocks/BlockEntity.h @@ -15,7 +15,7 @@ public: { } - virtual void OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer *a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override + virtual void OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer *a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override { a_ChunkInterface.UseBlockEntity(a_Player, a_BlockX, a_BlockY, a_BlockZ); } diff --git a/src/Blocks/BlockFenceGate.h b/src/Blocks/BlockFenceGate.h index 2d0cfb8fd..fb984f345 100644 --- a/src/Blocks/BlockFenceGate.h +++ b/src/Blocks/BlockFenceGate.h @@ -19,7 +19,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cChunkInterface & a_ChunkInterface, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, + int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta ) override @@ -30,7 +30,7 @@ public: } - virtual void OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override + virtual void OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override { NIBBLETYPE OldMetaData = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ); NIBBLETYPE NewMetaData = PlayerYawToMetaData(a_Player->GetYaw()); diff --git a/src/Blocks/BlockFurnace.h b/src/Blocks/BlockFurnace.h index bbc50de9f..27ef2689f 100644 --- a/src/Blocks/BlockFurnace.h +++ b/src/Blocks/BlockFurnace.h @@ -27,7 +27,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cChunkInterface & a_ChunkInterface, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, + int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta ) override diff --git a/src/Blocks/BlockHandler.cpp b/src/Blocks/BlockHandler.cpp index 657058e3e..6c9bbeb02 100644 --- a/src/Blocks/BlockHandler.cpp +++ b/src/Blocks/BlockHandler.cpp @@ -250,7 +250,7 @@ cBlockHandler::cBlockHandler(BLOCKTYPE a_BlockType) bool cBlockHandler::GetPlacementBlockTypeMeta( cChunkInterface & a_ChunkInterface, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, + int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta ) @@ -273,7 +273,7 @@ void cBlockHandler::OnUpdate(cChunkInterface & cChunkInterface, cWorldInterface -void cBlockHandler::OnPlacedByPlayer(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) +void cBlockHandler::OnPlacedByPlayer(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) { } @@ -347,7 +347,7 @@ void cBlockHandler::OnDigging(cChunkInterface & a_ChunkInterface, cWorldInterfac -void cBlockHandler::OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer *a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) +void cBlockHandler::OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer *a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) { } diff --git a/src/Blocks/BlockHandler.h b/src/Blocks/BlockHandler.h index 44b15bce1..a2913d7f8 100644 --- a/src/Blocks/BlockHandler.h +++ b/src/Blocks/BlockHandler.h @@ -35,7 +35,7 @@ public: */ virtual bool GetPlacementBlockTypeMeta( cChunkInterface & a_ChunkInterface, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, + int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta ); @@ -46,7 +46,7 @@ public: /// Called by cClientHandle::HandlePlaceBlock() after the player has placed a new block. Called after OnPlaced(). virtual void OnPlacedByPlayer( cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, + int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta ); @@ -67,7 +67,7 @@ public: virtual void OnDigging(cChunkInterface & cChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ); /// Called if the user right clicks the block and the block is useable - virtual void OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ); + virtual void OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ); /// Called when the item is mined to convert it into pickups. Pickups may specify multiple items. Appends items to a_Pickups, preserves its original contents virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta); diff --git a/src/Blocks/BlockHopper.h b/src/Blocks/BlockHopper.h index aa0317660..59b84aa0e 100644 --- a/src/Blocks/BlockHopper.h +++ b/src/Blocks/BlockHopper.h @@ -19,7 +19,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cChunkInterface & a_ChunkInterface, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, + int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta ) override diff --git a/src/Blocks/BlockLadder.h b/src/Blocks/BlockLadder.h index 5c2b542c0..6a105d5c9 100644 --- a/src/Blocks/BlockLadder.h +++ b/src/Blocks/BlockLadder.h @@ -20,7 +20,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cChunkInterface & a_ChunkInterface, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, + int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta ) override @@ -41,37 +41,38 @@ public: } - static NIBBLETYPE DirectionToMetaData(char a_Direction) // tolua_export + static NIBBLETYPE DirectionToMetaData(eBlockFace a_Direction) // tolua_export { // tolua_export switch (a_Direction) { - case 0x2: return 0x2; - case 0x3: return 0x3; - case 0x4: return 0x4; - case 0x5: return 0x5; + case BLOCK_FACE_ZM: return 0x2; + case BLOCK_FACE_ZP: return 0x3; + case BLOCK_FACE_XM: return 0x4; + case BLOCK_FACE_XP: return 0x5; default: return 0x2; } } // tolua_export - static char MetaDataToDirection(NIBBLETYPE a_MetaData) // tolua_export + static eBlockFace MetaDataToDirection(NIBBLETYPE a_MetaData) // tolua_export { // tolua_export switch (a_MetaData) { - case 0x2: return 0x2; - case 0x3: return 0x3; - case 0x4: return 0x4; - case 0x5: return 0x5; - default: return 0x2; + case 0x2: return BLOCK_FACE_ZM; + case 0x3: return BLOCK_FACE_ZP; + case 0x4: return BLOCK_FACE_XM; + case 0x5: return BLOCK_FACE_XP; + default: return BLOCK_FACE_ZM; } } // tolua_export /// Finds a suitable Direction for the Ladder. Returns BLOCK_FACE_BOTTOM on failure - static char FindSuitableBlockFace(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ) + static eBlockFace FindSuitableBlockFace(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ) { - for (int Face = 2; Face <= 5; Face++) + for (int FaceInt = BLOCK_FACE_ZM; FaceInt <= BLOCK_FACE_XP; FaceInt++) { + eBlockFace Face = static_cast(FaceInt); if (LadderCanBePlacedAt(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, Face)) { return Face; @@ -81,7 +82,7 @@ public: } - static bool LadderCanBePlacedAt(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace) + static bool LadderCanBePlacedAt(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace) { if ((a_BlockFace == BLOCK_FACE_BOTTOM) || (a_BlockFace == BLOCK_FACE_TOP)) { @@ -97,7 +98,7 @@ public: virtual bool CanBeAt(cChunkInterface & a_ChunkInterface,int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override { // TODO: Use AdjustCoordsByMeta(), then cChunk::UnboundedRelGetBlock() and finally some comparison - char BlockFace = MetaDataToDirection(a_Chunk.GetMeta(a_RelX, a_RelY, a_RelZ)); + eBlockFace BlockFace = MetaDataToDirection(a_Chunk.GetMeta(a_RelX, a_RelY, a_RelZ)); int BlockX = a_RelX + a_Chunk.GetPosX() * cChunkDef::Width; int BlockZ = a_RelZ + a_Chunk.GetPosZ() * cChunkDef::Width; return LadderCanBePlacedAt(a_ChunkInterface, BlockX, a_RelY, BlockZ, BlockFace); diff --git a/src/Blocks/BlockLever.h b/src/Blocks/BlockLever.h index 09b600759..48c7e774b 100644 --- a/src/Blocks/BlockLever.h +++ b/src/Blocks/BlockLever.h @@ -15,7 +15,7 @@ public: { } - virtual void OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override + virtual void OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override { // Flip the ON bit on/off using the XOR bitwise operation NIBBLETYPE Meta = (a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ) ^ 0x08); @@ -40,7 +40,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cChunkInterface & a_ChunkInterface, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, + int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta ) override @@ -51,7 +51,7 @@ public: } - inline static NIBBLETYPE LeverDirectionToMetaData(char a_Dir) + inline static NIBBLETYPE LeverDirectionToMetaData(eBlockFace a_Dir) { // Determine lever direction: switch (a_Dir) @@ -73,7 +73,7 @@ public: } - inline static NIBBLETYPE BlockMetaDataToBlockFace(NIBBLETYPE a_Meta) + inline static eBlockFace BlockMetaDataToBlockFace(NIBBLETYPE a_Meta) { switch (a_Meta & 0x7) { diff --git a/src/Blocks/BlockPiston.cpp b/src/Blocks/BlockPiston.cpp index e960d23e4..542eb33b5 100644 --- a/src/Blocks/BlockPiston.cpp +++ b/src/Blocks/BlockPiston.cpp @@ -54,7 +54,7 @@ void cBlockPistonHandler::OnDestroyed(cChunkInterface & a_ChunkInterface, cWorld bool cBlockPistonHandler::GetPlacementBlockTypeMeta( cChunkInterface & a_ChunkInterface, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, + int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta ) diff --git a/src/Blocks/BlockPiston.h b/src/Blocks/BlockPiston.h index de40afdd6..7632b5e5a 100644 --- a/src/Blocks/BlockPiston.h +++ b/src/Blocks/BlockPiston.h @@ -17,7 +17,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cChunkInterface & a_ChunkInterface, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, + int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta ) override; diff --git a/src/Blocks/BlockPlanks.h b/src/Blocks/BlockPlanks.h index 483761b5f..2a99a455e 100644 --- a/src/Blocks/BlockPlanks.h +++ b/src/Blocks/BlockPlanks.h @@ -18,7 +18,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cChunkInterface & a_ChunkInterface, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, + int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta ) override diff --git a/src/Blocks/BlockPortal.h b/src/Blocks/BlockPortal.h index dc916990e..21bcbdeea 100644 --- a/src/Blocks/BlockPortal.h +++ b/src/Blocks/BlockPortal.h @@ -18,7 +18,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cChunkInterface & a_ChunkInterface, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, + int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta ) override diff --git a/src/Blocks/BlockPumpkin.h b/src/Blocks/BlockPumpkin.h index 4a33d1d16..349f52605 100644 --- a/src/Blocks/BlockPumpkin.h +++ b/src/Blocks/BlockPumpkin.h @@ -14,7 +14,7 @@ public: { } - virtual void OnPlacedByPlayer(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) override + virtual void OnPlacedByPlayer(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) override { // Check whether the pumpkin is a part of a golem or a snowman @@ -80,7 +80,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cChunkInterface & a_ChunkInterface, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, + int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta ) override diff --git a/src/Blocks/BlockQuartz.h b/src/Blocks/BlockQuartz.h index a9f8f9046..9cc51490f 100644 --- a/src/Blocks/BlockQuartz.h +++ b/src/Blocks/BlockQuartz.h @@ -18,7 +18,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cChunkInterface & a_ChunkInterface, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, + int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta ) override @@ -35,7 +35,7 @@ public: return true; } - inline static NIBBLETYPE BlockFaceToMetaData(char a_BlockFace, NIBBLETYPE a_QuartzMeta) + inline static NIBBLETYPE BlockFaceToMetaData(eBlockFace a_BlockFace, NIBBLETYPE a_QuartzMeta) { switch (a_BlockFace) { @@ -64,4 +64,4 @@ public: } } } -} ; \ No newline at end of file +} ; diff --git a/src/Blocks/BlockRail.h b/src/Blocks/BlockRail.h index 65c6889de..52d6f60b3 100644 --- a/src/Blocks/BlockRail.h +++ b/src/Blocks/BlockRail.h @@ -31,7 +31,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cChunkInterface & a_ChunkInterface, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, + int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta ) override @@ -344,7 +344,7 @@ public: } - bool IsNotConnected(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, char a_Pure = 0) + bool IsNotConnected(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, char a_Pure = 0) { AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, false); NIBBLETYPE Meta; diff --git a/src/Blocks/BlockRedstoneRepeater.h b/src/Blocks/BlockRedstoneRepeater.h index a48fed8b6..eb0918acf 100644 --- a/src/Blocks/BlockRedstoneRepeater.h +++ b/src/Blocks/BlockRedstoneRepeater.h @@ -20,7 +20,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cChunkInterface & a_ChunkInterface, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, + int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta ) override @@ -31,7 +31,7 @@ public: } - virtual void OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override + virtual void OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override { a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, ((a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ) + 0x04) & 0x0f)); } diff --git a/src/Blocks/BlockSideways.h b/src/Blocks/BlockSideways.h index f11f0bee1..69c0a7230 100644 --- a/src/Blocks/BlockSideways.h +++ b/src/Blocks/BlockSideways.h @@ -18,7 +18,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cChunkInterface & a_ChunkInterface, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, + int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta ) override @@ -30,7 +30,7 @@ public: } - inline static NIBBLETYPE BlockFaceToMetaData(char a_BlockFace, NIBBLETYPE a_WoodMeta) + inline static NIBBLETYPE BlockFaceToMetaData(eBlockFace a_BlockFace, NIBBLETYPE a_WoodMeta) { switch (a_BlockFace) { diff --git a/src/Blocks/BlockSign.h b/src/Blocks/BlockSign.h index dced0008c..cd0c02a40 100644 --- a/src/Blocks/BlockSign.h +++ b/src/Blocks/BlockSign.h @@ -45,7 +45,7 @@ public: } - static char DirectionToMetaData(char a_Direction) + static char DirectionToMetaData(eBlockFace a_Direction) { switch (a_Direction) { @@ -64,7 +64,7 @@ public: virtual void OnPlacedByPlayer( cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, + int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta ) override diff --git a/src/Blocks/BlockSlab.h b/src/Blocks/BlockSlab.h index 51e78393a..3628303ce 100644 --- a/src/Blocks/BlockSlab.h +++ b/src/Blocks/BlockSlab.h @@ -34,7 +34,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cChunkInterface & a_ChunkInterface, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, + int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta ) override diff --git a/src/Blocks/BlockSnow.h b/src/Blocks/BlockSnow.h index b79ef9f64..a3daf0393 100644 --- a/src/Blocks/BlockSnow.h +++ b/src/Blocks/BlockSnow.h @@ -19,7 +19,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cChunkInterface & a_ChunkInterface, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, + int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta ) override diff --git a/src/Blocks/BlockStairs.h b/src/Blocks/BlockStairs.h index d50014dd1..c1887bc46 100644 --- a/src/Blocks/BlockStairs.h +++ b/src/Blocks/BlockStairs.h @@ -20,7 +20,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cChunkInterface & a_ChunkInterface, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, + int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta ) override diff --git a/src/Blocks/BlockTorch.h b/src/Blocks/BlockTorch.h index c3b25c899..13f961d21 100644 --- a/src/Blocks/BlockTorch.h +++ b/src/Blocks/BlockTorch.h @@ -19,7 +19,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cChunkInterface & a_ChunkInterface, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, + int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta ) override @@ -57,7 +57,7 @@ public: } - inline static NIBBLETYPE DirectionToMetaData(char a_Direction) + inline static NIBBLETYPE DirectionToMetaData(eBlockFace a_Direction) { switch (a_Direction) { @@ -77,7 +77,7 @@ public: } - inline static char MetaDataToDirection(NIBBLETYPE a_MetaData) + inline static eBlockFace MetaDataToDirection(NIBBLETYPE a_MetaData) { switch (a_MetaData) { @@ -93,11 +93,11 @@ public: break; } } - return 0; + return BLOCK_FACE_TOP; } - static bool CanBePlacedOn(BLOCKTYPE a_BlockType, char a_BlockFace) + static bool CanBePlacedOn(BLOCKTYPE a_BlockType, eBlockFace a_BlockFace) { if ( !g_BlockFullyOccupiesVoxel[a_BlockType] ) { @@ -111,9 +111,9 @@ public: /// Finds a suitable face to place the torch, returning BLOCK_FACE_NONE on failure - static char FindSuitableFace(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ) + static eBlockFace FindSuitableFace(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ) { - for (int i = BLOCK_FACE_YM; i <= BLOCK_FACE_XP; i++) // Loop through all directions + for (eBlockFace i = BLOCK_FACE_YM; i <= BLOCK_FACE_XP; i++) // Loop through all directions { AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, i, true); BLOCKTYPE BlockInQuestion = a_ChunkInterface.GetBlock(a_BlockX, a_BlockY, a_BlockZ); @@ -145,7 +145,7 @@ public: virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override { - char Face = MetaDataToDirection(a_Chunk.GetMeta(a_RelX, a_RelY, a_RelZ)); + eBlockFace Face = MetaDataToDirection(a_Chunk.GetMeta(a_RelX, a_RelY, a_RelZ)); AddFaceDirection(a_RelX, a_RelY, a_RelZ, Face, true); BLOCKTYPE BlockInQuestion; diff --git a/src/Blocks/BlockTrapdoor.h b/src/Blocks/BlockTrapdoor.h index f549b4183..37e79a1e1 100644 --- a/src/Blocks/BlockTrapdoor.h +++ b/src/Blocks/BlockTrapdoor.h @@ -32,7 +32,7 @@ public: return true; } - virtual void OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override + virtual void OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override { // Flip the ON bit on/off using the XOR bitwise operation NIBBLETYPE Meta = (a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ) ^ 0x04); @@ -42,7 +42,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cChunkInterface & a_ChunkInterface, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, + int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta ) override @@ -57,7 +57,7 @@ public: return true; } - inline static NIBBLETYPE BlockFaceToMetaData(char a_BlockFace) + inline static NIBBLETYPE BlockFaceToMetaData(eBlockFace a_BlockFace) { switch (a_BlockFace) { @@ -73,7 +73,7 @@ public: } } - inline static NIBBLETYPE BlockMetaDataToBlockFace(NIBBLETYPE a_Meta) + inline static eBlockFace BlockMetaDataToBlockFace(NIBBLETYPE a_Meta) { switch (a_Meta & 0x3) { diff --git a/src/Blocks/BlockVine.h b/src/Blocks/BlockVine.h index aa0d582b3..ee7dcee8a 100644 --- a/src/Blocks/BlockVine.h +++ b/src/Blocks/BlockVine.h @@ -19,7 +19,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cChunkInterface & a_ChunkInterface, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, + int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta ) override diff --git a/src/Blocks/BlockWorkbench.h b/src/Blocks/BlockWorkbench.h index 1c08adb43..70468369c 100644 --- a/src/Blocks/BlockWorkbench.h +++ b/src/Blocks/BlockWorkbench.h @@ -19,7 +19,7 @@ public: } - virtual void OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override + virtual void OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override { cWindow * Window = new cCraftingWindow(a_BlockX, a_BlockY, a_BlockZ); a_Player->OpenWindow(Window); diff --git a/src/BoundingBox.cpp b/src/BoundingBox.cpp index d0943d42a..86d4546c7 100644 --- a/src/BoundingBox.cpp +++ b/src/BoundingBox.cpp @@ -228,7 +228,7 @@ bool cBoundingBox::IsInside(const Vector3d & a_Min, const Vector3d & a_Max, doub -bool cBoundingBox::CalcLineIntersection(const Vector3d & a_Line1, const Vector3d & a_Line2, double & a_LineCoeff, char & a_Face) +bool cBoundingBox::CalcLineIntersection(const Vector3d & a_Line1, const Vector3d & a_Line2, double & a_LineCoeff, eBlockFace & a_Face) { return CalcLineIntersection(m_Min, m_Max, a_Line1, a_Line2, a_LineCoeff, a_Face); } @@ -237,7 +237,7 @@ bool cBoundingBox::CalcLineIntersection(const Vector3d & a_Line1, const Vector3d -bool cBoundingBox::CalcLineIntersection(const Vector3d & a_Min, const Vector3d & a_Max, const Vector3d & a_Line1, const Vector3d & a_Line2, double & a_LineCoeff, char & a_Face) +bool cBoundingBox::CalcLineIntersection(const Vector3d & a_Min, const Vector3d & a_Max, const Vector3d & a_Line1, const Vector3d & a_Line2, double & a_LineCoeff, eBlockFace & a_Face) { if (IsInside(a_Min, a_Max, a_Line1)) { @@ -247,7 +247,7 @@ bool cBoundingBox::CalcLineIntersection(const Vector3d & a_Min, const Vector3d & return true; } - char Face = BLOCK_FACE_NONE; + eBlockFace Face = BLOCK_FACE_NONE; double Coeff = Vector3d::NO_INTERSECTION; // Check each individual bbox face for intersection with the line, remember the one with the lowest coeff diff --git a/src/BoundingBox.h b/src/BoundingBox.h index ff9963989..9ac5f11b8 100644 --- a/src/BoundingBox.h +++ b/src/BoundingBox.h @@ -9,6 +9,7 @@ #pragma once #include "Vector3d.h" +#include "Defines.h" @@ -66,13 +67,13 @@ public: Also calculates the distance along the line in which the intersection occurs (0 .. 1) Only forward collisions (a_LineCoeff >= 0) are returned. */ - bool CalcLineIntersection(const Vector3d & a_Line1, const Vector3d & a_Line2, double & a_LineCoeff, char & a_Face); + bool CalcLineIntersection(const Vector3d & a_Line1, const Vector3d & a_Line2, double & a_LineCoeff, eBlockFace & a_Face); /** Returns true if the specified bounding box is intersected by the line specified by its two points Also calculates the distance along the line in which the intersection occurs (0 .. 1) and the face hit (BLOCK_FACE_ constants) Only forward collisions (a_LineCoeff >= 0) are returned. */ - static bool CalcLineIntersection(const Vector3d & a_Min, const Vector3d & a_Max, const Vector3d & a_Line1, const Vector3d & a_Line2, double & a_LineCoeff, char & a_Face); + static bool CalcLineIntersection(const Vector3d & a_Min, const Vector3d & a_Max, const Vector3d & a_Line1, const Vector3d & a_Line2, double & a_LineCoeff, eBlockFace & a_Face); // tolua_end diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index 6b61eaae8..aa43f192c 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -620,7 +620,7 @@ void cClientHandle::HandleCommandBlockMessage(const char* a_Data, unsigned int a -void cClientHandle::HandleLeftClick(int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, char a_Status) +void cClientHandle::HandleLeftClick(int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, char a_Status) { LOGD("HandleLeftClick: {%i, %i, %i}; Face: %i; Stat: %i", a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_Status @@ -721,7 +721,7 @@ void cClientHandle::HandleLeftClick(int a_BlockX, int a_BlockY, int a_BlockZ, ch -void cClientHandle::HandleBlockDigStarted(int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, BLOCKTYPE a_OldBlock, NIBBLETYPE a_OldMeta) +void cClientHandle::HandleBlockDigStarted(int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, BLOCKTYPE a_OldBlock, NIBBLETYPE a_OldMeta) { if ( m_HasStartedDigging && @@ -795,7 +795,7 @@ void cClientHandle::HandleBlockDigStarted(int a_BlockX, int a_BlockY, int a_Bloc -void cClientHandle::HandleBlockDigFinished(int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, BLOCKTYPE a_OldBlock, NIBBLETYPE a_OldMeta) +void cClientHandle::HandleBlockDigFinished(int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, BLOCKTYPE a_OldBlock, NIBBLETYPE a_OldMeta) { if ( !m_HasStartedDigging || // Hasn't received the DIG_STARTED packet @@ -844,7 +844,7 @@ void cClientHandle::HandleBlockDigFinished(int a_BlockX, int a_BlockY, int a_Blo -void cClientHandle::HandleRightClick(int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, const cItem & a_HeldItem) +void cClientHandle::HandleRightClick(int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, const cItem & a_HeldItem) { LOGD("HandleRightClick: {%d, %d, %d}, face %d, HeldItem: %s", a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, ItemToFullString(a_HeldItem).c_str() @@ -946,7 +946,7 @@ void cClientHandle::HandleRightClick(int a_BlockX, int a_BlockY, int a_BlockZ, c -void cClientHandle::HandlePlaceBlock(int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, cItemHandler & a_ItemHandler) +void cClientHandle::HandlePlaceBlock(int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, cItemHandler & a_ItemHandler) { if (a_BlockFace < 0) { diff --git a/src/ClientHandle.h b/src/ClientHandle.h index e1f326543..a4a22e4df 100644 --- a/src/ClientHandle.h +++ b/src/ClientHandle.h @@ -184,7 +184,7 @@ public: bool HandleHandshake (const AString & a_Username); void HandleKeepAlive (int a_KeepAliveID); - void HandleLeftClick (int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, char a_Status); + void HandleLeftClick (int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, char a_Status); void HandlePing (void); void HandlePlayerAbilities (bool a_CanFly, bool a_IsFlying, float FlyingSpeed, float WalkingSpeed); void HandlePlayerLook (float a_Rotation, float a_Pitch, bool a_IsOnGround); @@ -192,7 +192,7 @@ public: void HandlePlayerPos (double a_PosX, double a_PosY, double a_PosZ, double a_Stance, bool a_IsOnGround); void HandlePluginMessage (const AString & a_Channel, const AString & a_Message); void HandleRespawn (void); - void HandleRightClick (int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, const cItem & a_HeldItem); + void HandleRightClick (int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, const cItem & a_HeldItem); void HandleSlotSelected (short a_SlotNum); void HandleSteerVehicle (float Forward, float Sideways); void HandleTabCompletion (const AString & a_Text); @@ -217,7 +217,7 @@ public: void MoveToWorld(cWorld & a_World, bool a_SendRespawnPacket); /// Handles the block placing packet when it is a real block placement (not block-using, item-using or eating) - void HandlePlaceBlock(int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, cItemHandler & a_ItemHandler); + void HandlePlaceBlock(int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, cItemHandler & a_ItemHandler); private: @@ -325,10 +325,10 @@ private: void StreamChunk(int a_ChunkX, int a_ChunkZ); /// Handles the DIG_STARTED dig packet: - void HandleBlockDigStarted (int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, BLOCKTYPE a_OldBlock, NIBBLETYPE a_OldMeta); + void HandleBlockDigStarted (int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, BLOCKTYPE a_OldBlock, NIBBLETYPE a_OldMeta); /// Handles the DIG_FINISHED dig packet: - void HandleBlockDigFinished(int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, BLOCKTYPE a_OldBlock, NIBBLETYPE a_OldMeta); + void HandleBlockDigFinished(int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, BLOCKTYPE a_OldBlock, NIBBLETYPE a_OldMeta); /// Handles the "MC|AdvCdm" plugin message void HandleCommandBlockMessage(const char* a_Data, unsigned int a_Length); diff --git a/src/Defines.h b/src/Defines.h index 5b868b2e5..1a12a8743 100644 --- a/src/Defines.h +++ b/src/Defines.h @@ -325,7 +325,7 @@ inline bool IsBlockTypeOfDirt(BLOCKTYPE a_BlockType) -inline void AddFaceDirection(int & a_BlockX, int & a_BlockY, int & a_BlockZ, char a_BlockFace, bool a_bInverse = false) // tolua_export +inline void AddFaceDirection(int & a_BlockX, int & a_BlockY, int & a_BlockZ, eBlockFace a_BlockFace, bool a_bInverse = false) // tolua_export { // tolua_export if (!a_bInverse) { @@ -369,7 +369,7 @@ inline void AddFaceDirection(int & a_BlockX, int & a_BlockY, int & a_BlockZ, cha -inline void AddFaceDirection(int & a_BlockX, unsigned char & a_BlockY, int & a_BlockZ, char a_BlockFace, bool a_bInverse = false) +inline void AddFaceDirection(int & a_BlockX, unsigned char & a_BlockY, int & a_BlockZ, eBlockFace a_BlockFace, bool a_bInverse = false) { int Y = a_BlockY; AddFaceDirection(a_BlockX, Y, a_BlockZ, a_BlockFace, a_bInverse); @@ -389,8 +389,6 @@ inline void AddFaceDirection(int & a_BlockX, unsigned char & a_BlockY, int & a_B - - #define PI 3.14159265358979323846264338327950288419716939937510582097494459072381640628620899862803482534211706798f inline void EulerToVector(double a_Pan, double a_Pitch, double & a_X, double & a_Y, double & a_Z) diff --git a/src/Entities/Floater.cpp b/src/Entities/Floater.cpp index dfe77f059..38160a30e 100644 --- a/src/Entities/Floater.cpp +++ b/src/Entities/Floater.cpp @@ -35,7 +35,7 @@ public: cBoundingBox EntBox(a_Entity->GetPosition(), a_Entity->GetWidth() / 2, a_Entity->GetHeight()); double LineCoeff; - char Face; + eBlockFace Face; EntBox.Expand(m_Floater->GetWidth() / 2, m_Floater->GetHeight() / 2, m_Floater->GetWidth() / 2); if (!EntBox.CalcLineIntersection(m_Pos, m_NextPos, LineCoeff, Face)) { @@ -215,4 +215,4 @@ void cFloater::Tick(float a_Dt, cChunk & a_Chunk) SetSpeedZ(GetSpeedZ() * 0.95); BroadcastMovementUpdate(); -} \ No newline at end of file +} diff --git a/src/Entities/ProjectileEntity.cpp b/src/Entities/ProjectileEntity.cpp index bffa790a3..a3fa9d557 100644 --- a/src/Entities/ProjectileEntity.cpp +++ b/src/Entities/ProjectileEntity.cpp @@ -63,7 +63,7 @@ protected: Vector3d Line1 = m_Projectile->GetPosition(); Vector3d Line2 = Line1 + m_Projectile->GetSpeed(); double LineCoeff = 0; - char Face; + eBlockFace Face; if (bb.CalcLineIntersection(Line1, Line2, LineCoeff, Face)) { Vector3d Intersection = Line1 + m_Projectile->GetSpeed() * LineCoeff; @@ -138,7 +138,7 @@ public: // Instead of colliding the bounding box with another bounding box in motion, we collide an enlarged bounding box with a hairline. // The results should be good enough for our purposes double LineCoeff; - char Face; + eBlockFace Face; EntBox.Expand(m_Projectile->GetWidth() / 2, m_Projectile->GetHeight() / 2, m_Projectile->GetWidth() / 2); if (!EntBox.CalcLineIntersection(m_Pos, m_NextPos, LineCoeff, Face)) { @@ -243,7 +243,7 @@ cProjectileEntity * cProjectileEntity::Create(eKind a_Kind, cEntity * a_Creator, -void cProjectileEntity::OnHitSolidBlock(const Vector3d & a_HitPos, char a_HitFace) +void cProjectileEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) { // Set the position based on what face was hit: SetPosition(a_HitPos); @@ -446,7 +446,7 @@ bool cArrowEntity::CanPickup(const cPlayer & a_Player) const -void cArrowEntity::OnHitSolidBlock(const Vector3d & a_HitPos, char a_HitFace) +void cArrowEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) { if (a_HitFace == BLOCK_FACE_NONE) { return; } @@ -590,7 +590,7 @@ cThrownEggEntity::cThrownEggEntity(cEntity * a_Creator, double a_X, double a_Y, -void cThrownEggEntity::OnHitSolidBlock(const Vector3d & a_HitPos, char a_HitFace) +void cThrownEggEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) { if (m_World->GetTickRandomNumber(7) == 1) { @@ -623,7 +623,7 @@ cThrownEnderPearlEntity::cThrownEnderPearlEntity(cEntity * a_Creator, double a_X -void cThrownEnderPearlEntity::OnHitSolidBlock(const Vector3d & a_HitPos, char a_HitFace) +void cThrownEnderPearlEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) { // Teleport the creator here, make them take 5 damage: if (m_Creator != NULL) @@ -653,7 +653,7 @@ cThrownSnowballEntity::cThrownSnowballEntity(cEntity * a_Creator, double a_X, do -void cThrownSnowballEntity::OnHitSolidBlock(const Vector3d & a_HitPos, char a_HitFace) +void cThrownSnowballEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) { // TODO: Apply damage to certain mobs (blaze etc.) and anger all mobs @@ -677,7 +677,7 @@ super(pkExpBottle, a_Creator, a_X, a_Y, a_Z, 0.25, 0.25) -void cExpBottleEntity::OnHitSolidBlock(const Vector3d & a_HitPos, char a_HitFace) +void cExpBottleEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) { // Spawn an experience orb with a reward between 3 and 11. m_World->SpawnExperienceOrb(GetPosX(), GetPosY(), GetPosZ(), 3 + m_World->GetTickRandomNumber(8)); @@ -701,7 +701,7 @@ super(pkFirework, a_Creator, a_X, a_Y, a_Z, 0.25, 0.25) -void cFireworkEntity::OnHitSolidBlock(const Vector3d & a_HitPos, char a_HitFace) +void cFireworkEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) { if ((a_HitFace != BLOCK_FACE_BOTTOM) && (a_HitFace != BLOCK_FACE_NONE)) { @@ -784,7 +784,7 @@ void cGhastFireballEntity::Explode(int a_BlockX, int a_BlockY, int a_BlockZ) -void cGhastFireballEntity::OnHitSolidBlock(const Vector3d & a_HitPos, char a_HitFace) +void cGhastFireballEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) { Destroy(); Explode((int)floor(a_HitPos.x), (int)floor(a_HitPos.y), (int)floor(a_HitPos.z)); @@ -830,7 +830,7 @@ void cFireChargeEntity::Explode(int a_BlockX, int a_BlockY, int a_BlockZ) -void cFireChargeEntity::OnHitSolidBlock(const Vector3d & a_HitPos, char a_HitFace) +void cFireChargeEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) { Destroy(); Explode((int)floor(a_HitPos.x), (int)floor(a_HitPos.y), (int)floor(a_HitPos.z)); diff --git a/src/Entities/ProjectileEntity.h b/src/Entities/ProjectileEntity.h index 4721409ee..e80592999 100644 --- a/src/Entities/ProjectileEntity.h +++ b/src/Entities/ProjectileEntity.h @@ -49,7 +49,7 @@ public: static cProjectileEntity * Create(eKind a_Kind, cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d * a_Speed = NULL); /// Called by the physics blocktracer when the entity hits a solid block, the hit position and the face hit (BLOCK_FACE_) is given - virtual void OnHitSolidBlock(const Vector3d & a_HitPos, char a_HitFace); + virtual void OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace); /// Called by the physics blocktracer when the entity hits another entity virtual void OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos) @@ -174,7 +174,7 @@ protected: Vector3i m_HitBlockPos; // cProjectileEntity overrides: - virtual void OnHitSolidBlock(const Vector3d & a_HitPos, char a_HitFace) override; + virtual void OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) override; virtual void OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos) override; virtual void CollectedBy(cPlayer * a_Player) override; virtual void Tick(float a_Dt, cChunk & a_Chunk) override; @@ -204,7 +204,7 @@ protected: // tolua_end // cProjectileEntity overrides: - virtual void OnHitSolidBlock(const Vector3d & a_HitPos, char a_HitFace) override; + virtual void OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) override; // tolua_begin @@ -232,7 +232,7 @@ protected: // tolua_end // cProjectileEntity overrides: - virtual void OnHitSolidBlock(const Vector3d & a_HitPos, char a_HitFace) override; + virtual void OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) override; // tolua_begin @@ -258,7 +258,7 @@ public: protected: // cProjectileEntity overrides: - virtual void OnHitSolidBlock(const Vector3d & a_HitPos, char a_HitFace) override; + virtual void OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) override; // tolua_begin @@ -284,7 +284,7 @@ public: protected: // cProjectileEntity overrides: - virtual void OnHitSolidBlock(const Vector3d & a_HitPos, char a_HitFace) override; + virtual void OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) override; // tolua_begin @@ -310,7 +310,7 @@ public: protected: // cProjectileEntity overrides: - virtual void OnHitSolidBlock(const Vector3d & a_HitPos, char a_HitFace) override; + virtual void OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) override; virtual void HandlePhysics(float a_Dt, cChunk & a_Chunk) override; // tolua_begin @@ -339,7 +339,7 @@ protected: void Explode(int a_BlockX, int a_BlockY, int a_BlockZ); // cProjectileEntity overrides: - virtual void OnHitSolidBlock(const Vector3d & a_HitPos, char a_HitFace) override; + virtual void OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) override; virtual void OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos) override; // TODO: Deflecting the fireballs by arrow- or sword- hits @@ -370,7 +370,7 @@ protected: void Explode(int a_BlockX, int a_BlockY, int a_BlockZ); // cProjectileEntity overrides: - virtual void OnHitSolidBlock(const Vector3d & a_HitPos, char a_HitFace) override; + virtual void OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) override; virtual void OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos) override; // tolua_begin diff --git a/src/Items/ItemBed.h b/src/Items/ItemBed.h index 9b7c8bff8..f23d69731 100644 --- a/src/Items/ItemBed.h +++ b/src/Items/ItemBed.h @@ -26,7 +26,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cWorld * a_World, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, + int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta ) override diff --git a/src/Items/ItemBoat.h b/src/Items/ItemBoat.h index 79c8e9589..31d1ca52e 100644 --- a/src/Items/ItemBoat.h +++ b/src/Items/ItemBoat.h @@ -29,9 +29,9 @@ public: - virtual bool OnItemUse(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Dir) override + virtual bool OnItemUse(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_Dir) override { - if (a_Dir > 0) + if (a_Dir != BLOCK_FACE_YM || a_Dir != BLOCK_FACE_NONE) { return false; } diff --git a/src/Items/ItemBow.h b/src/Items/ItemBow.h index d533c21fd..410c5f512 100644 --- a/src/Items/ItemBow.h +++ b/src/Items/ItemBow.h @@ -27,7 +27,7 @@ public: } - virtual bool OnItemUse(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Dir) override + virtual bool OnItemUse(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_Dir) override { ASSERT(a_Player != NULL); @@ -42,7 +42,7 @@ public: } - virtual void OnItemShoot(cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace) override + virtual void OnItemShoot(cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace) override { // Actual shot - produce the arrow with speed based on the ticks that the bow was charged ASSERT(a_Player != NULL); diff --git a/src/Items/ItemBrewingStand.h b/src/Items/ItemBrewingStand.h index 4ff14d4b4..d5eefb855 100644 --- a/src/Items/ItemBrewingStand.h +++ b/src/Items/ItemBrewingStand.h @@ -25,7 +25,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cWorld * a_World, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, + int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta ) override diff --git a/src/Items/ItemBucket.h b/src/Items/ItemBucket.h index f18a4d959..72cb8fa0a 100644 --- a/src/Items/ItemBucket.h +++ b/src/Items/ItemBucket.h @@ -22,7 +22,7 @@ public: } - virtual bool OnItemUse(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Dir) override + virtual bool OnItemUse(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_Dir) override { switch (m_ItemType) { @@ -93,7 +93,7 @@ public: } - bool PlaceFluid(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, BLOCKTYPE a_FluidBlock) + bool PlaceFluid(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, BLOCKTYPE a_FluidBlock) { if (a_BlockFace < 0) { diff --git a/src/Items/ItemCauldron.h b/src/Items/ItemCauldron.h index 8b2ddc29f..07ae12660 100644 --- a/src/Items/ItemCauldron.h +++ b/src/Items/ItemCauldron.h @@ -25,7 +25,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cWorld * a_World, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, + int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta ) override diff --git a/src/Items/ItemComparator.h b/src/Items/ItemComparator.h index 3a5d1d200..60d9c3648 100644 --- a/src/Items/ItemComparator.h +++ b/src/Items/ItemComparator.h @@ -24,7 +24,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cWorld * a_World, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, + int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta ) override diff --git a/src/Items/ItemDoor.h b/src/Items/ItemDoor.h index 531a0c6e4..f3677c28c 100644 --- a/src/Items/ItemDoor.h +++ b/src/Items/ItemDoor.h @@ -25,7 +25,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cWorld * a_World, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, + int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta ) override diff --git a/src/Items/ItemDye.h b/src/Items/ItemDye.h index 190cdc510..ccf4714f7 100644 --- a/src/Items/ItemDye.h +++ b/src/Items/ItemDye.h @@ -19,7 +19,7 @@ public: } - virtual bool OnItemUse(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Dir) override + virtual bool OnItemUse(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_Dir) override { // Handle growing the plants: if (a_Item.m_ItemDamage == E_META_DYE_WHITE) diff --git a/src/Items/ItemFishingRod.h b/src/Items/ItemFishingRod.h index b2eaee63a..15acbd9fe 100644 --- a/src/Items/ItemFishingRod.h +++ b/src/Items/ItemFishingRod.h @@ -84,7 +84,7 @@ public: { } - virtual bool OnItemUse(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Dir) override + virtual bool OnItemUse(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_Dir) override { if (a_Dir != BLOCK_FACE_NONE) { @@ -230,4 +230,4 @@ public: } return true; } -} ; \ No newline at end of file +} ; diff --git a/src/Items/ItemFlowerPot.h b/src/Items/ItemFlowerPot.h index befa2ff21..60bf87985 100644 --- a/src/Items/ItemFlowerPot.h +++ b/src/Items/ItemFlowerPot.h @@ -25,7 +25,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cWorld * a_World, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, + int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta ) override diff --git a/src/Items/ItemHandler.cpp b/src/Items/ItemHandler.cpp index 302796d1b..f7115c558 100644 --- a/src/Items/ItemHandler.cpp +++ b/src/Items/ItemHandler.cpp @@ -231,7 +231,7 @@ cItemHandler::cItemHandler(int a_ItemType) -bool cItemHandler::OnItemUse(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Dir) +bool cItemHandler::OnItemUse(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_Dir) { return false; } @@ -240,7 +240,7 @@ bool cItemHandler::OnItemUse(cWorld * a_World, cPlayer * a_Player, const cItem & -bool cItemHandler::OnDiggingBlock(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Dir) +bool cItemHandler::OnDiggingBlock(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_Dir) { return false; } @@ -454,7 +454,7 @@ bool cItemHandler::CanHarvestBlock(BLOCKTYPE a_BlockType) bool cItemHandler::GetPlacementBlockTypeMeta( cWorld * a_World, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, + int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta ) diff --git a/src/Items/ItemHandler.h b/src/Items/ItemHandler.h index db0ffc9db..1a6bb044f 100644 --- a/src/Items/ItemHandler.h +++ b/src/Items/ItemHandler.h @@ -22,10 +22,10 @@ public: cItemHandler(int a_ItemType); /// Called when the player tries to use the item (right mouse button). Return false to make the item unusable. DEFAULT: False - virtual bool OnItemUse(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Dir); + virtual bool OnItemUse(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_Dir); /// Called when the client sends the SHOOT status in the lclk packet - virtual void OnItemShoot(cPlayer *, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace) + virtual void OnItemShoot(cPlayer *, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace) { UNUSED(a_BlockX); UNUSED(a_BlockY); @@ -34,7 +34,7 @@ public: } /// Called while the player diggs a block using this item - virtual bool OnDiggingBlock(cWorld * a_World, cPlayer * a_Player, const cItem & a_HeldItem, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace); + virtual bool OnDiggingBlock(cWorld * a_World, cPlayer * a_Player, const cItem & a_HeldItem, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace); /// Called when the player destroys a block using this item. This also calls the drop function for the destroyed block virtual void OnBlockDestroyed(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_X, int a_Y, int a_Z); @@ -80,7 +80,7 @@ public: */ virtual bool GetPlacementBlockTypeMeta( cWorld * a_World, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, + int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta ); diff --git a/src/Items/ItemHoe.h b/src/Items/ItemHoe.h index 7b6b3e6ac..29f7c83d5 100644 --- a/src/Items/ItemHoe.h +++ b/src/Items/ItemHoe.h @@ -19,7 +19,7 @@ public: } - virtual bool OnItemUse(cWorld *a_World, cPlayer *a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Dir) override + virtual bool OnItemUse(cWorld *a_World, cPlayer *a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_Dir) override { BLOCKTYPE Block = a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ); diff --git a/src/Items/ItemLeaves.h b/src/Items/ItemLeaves.h index 60222eaa9..12cb45d1c 100644 --- a/src/Items/ItemLeaves.h +++ b/src/Items/ItemLeaves.h @@ -20,7 +20,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cWorld * a_World, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, + int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta ) override diff --git a/src/Items/ItemLighter.h b/src/Items/ItemLighter.h index 8f3389d95..6681a08d4 100644 --- a/src/Items/ItemLighter.h +++ b/src/Items/ItemLighter.h @@ -19,7 +19,7 @@ public: { } - virtual bool OnItemUse(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace) override + virtual bool OnItemUse(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace) override { if (a_BlockFace < 0) { diff --git a/src/Items/ItemMinecart.h b/src/Items/ItemMinecart.h index 4071f8c60..bcaa5635a 100644 --- a/src/Items/ItemMinecart.h +++ b/src/Items/ItemMinecart.h @@ -28,7 +28,7 @@ public: - virtual bool OnItemUse(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Dir) override + virtual bool OnItemUse(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_Dir) override { if (a_Dir < 0) { diff --git a/src/Items/ItemNetherWart.h b/src/Items/ItemNetherWart.h index aa4a44340..a6a9a286a 100644 --- a/src/Items/ItemNetherWart.h +++ b/src/Items/ItemNetherWart.h @@ -25,7 +25,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cWorld * a_World, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, + int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta ) override @@ -51,4 +51,4 @@ public: return true; } -} ; \ No newline at end of file +} ; diff --git a/src/Items/ItemRedstoneDust.h b/src/Items/ItemRedstoneDust.h index de90c8075..18c6b8615 100644 --- a/src/Items/ItemRedstoneDust.h +++ b/src/Items/ItemRedstoneDust.h @@ -22,7 +22,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cWorld * a_World, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, + int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta ) override diff --git a/src/Items/ItemRedstoneRepeater.h b/src/Items/ItemRedstoneRepeater.h index e71c8e672..c5fb5d566 100644 --- a/src/Items/ItemRedstoneRepeater.h +++ b/src/Items/ItemRedstoneRepeater.h @@ -24,7 +24,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cWorld * a_World, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, + int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta ) override diff --git a/src/Items/ItemSapling.h b/src/Items/ItemSapling.h index dc0810a45..61b1a32be 100644 --- a/src/Items/ItemSapling.h +++ b/src/Items/ItemSapling.h @@ -20,7 +20,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cWorld * a_World, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, + int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta ) override diff --git a/src/Items/ItemSeeds.h b/src/Items/ItemSeeds.h index 67f0d38bd..ba3b2538b 100644 --- a/src/Items/ItemSeeds.h +++ b/src/Items/ItemSeeds.h @@ -25,7 +25,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cWorld * a_World, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, + int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta ) override diff --git a/src/Items/ItemShears.h b/src/Items/ItemShears.h index 6a17607ee..b8f75f5ba 100644 --- a/src/Items/ItemShears.h +++ b/src/Items/ItemShears.h @@ -25,7 +25,7 @@ public: } - virtual bool OnDiggingBlock(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Dir) override + virtual bool OnDiggingBlock(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_Dir) override { BLOCKTYPE Block = a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ); if (Block == E_BLOCK_LEAVES) diff --git a/src/Items/ItemShovel.h b/src/Items/ItemShovel.h index 4921b257a..873d5ae25 100644 --- a/src/Items/ItemShovel.h +++ b/src/Items/ItemShovel.h @@ -21,7 +21,7 @@ public: } - virtual bool OnDiggingBlock(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Dir) override + virtual bool OnDiggingBlock(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_Dir) override { BLOCKTYPE Block = a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ); if (Block == E_BLOCK_SNOW) diff --git a/src/Items/ItemSign.h b/src/Items/ItemSign.h index 8c134ab83..60cf0f5f8 100644 --- a/src/Items/ItemSign.h +++ b/src/Items/ItemSign.h @@ -27,7 +27,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cWorld * a_World, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, + int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta ) override diff --git a/src/Items/ItemSpawnEgg.h b/src/Items/ItemSpawnEgg.h index 407d655de..0d6019398 100644 --- a/src/Items/ItemSpawnEgg.h +++ b/src/Items/ItemSpawnEgg.h @@ -19,7 +19,7 @@ public: } - virtual bool OnItemUse(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace) override + virtual bool OnItemUse(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace) override { if (a_BlockFace < 0) { diff --git a/src/Items/ItemSugarcane.h b/src/Items/ItemSugarcane.h index ce93aa3e5..e891cc367 100644 --- a/src/Items/ItemSugarcane.h +++ b/src/Items/ItemSugarcane.h @@ -23,7 +23,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cWorld * a_World, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, + int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta ) override diff --git a/src/Items/ItemThrowable.h b/src/Items/ItemThrowable.h index fc24e775a..46049f961 100644 --- a/src/Items/ItemThrowable.h +++ b/src/Items/ItemThrowable.h @@ -26,7 +26,7 @@ public: } - virtual bool OnItemUse(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Dir) override + virtual bool OnItemUse(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_Dir) override { if (!a_Player->IsGameModeCreative()) { @@ -120,7 +120,7 @@ public: { } - virtual bool OnItemUse(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Dir) override + virtual bool OnItemUse(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_Dir) override { if (a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ) == E_BLOCK_AIR) { @@ -137,4 +137,4 @@ public: return true; } -}; \ No newline at end of file +}; diff --git a/src/Piston.h b/src/Piston.h index 92ddf6938..9bbc8c6b9 100644 --- a/src/Piston.h +++ b/src/Piston.h @@ -2,7 +2,7 @@ #pragma once - +#include "Defines.h" // fwd: World.h @@ -54,6 +54,25 @@ public: } } } + + static eBlockFace MetaDataToDirection(NIBBLETYPE a_MetaData) + { + switch (a_MetaData) + { + //case -1: return BLOCK_FACE_NONE; //can never happen as metadata is unsigned + case 0x0: return BLOCK_FACE_YM; + case 0x1: return BLOCK_FACE_YP; + case 0x2: return BLOCK_FACE_ZM; + case 0x3: return BLOCK_FACE_ZP; + case 0x4: return BLOCK_FACE_XM; + case 0x5: return BLOCK_FACE_XP; + default: + { + ASSERT(!"Invalid Metadata"); + return BLOCK_FACE_NONE; + } + } + } void ExtendPiston( int, int, int ); void RetractPiston( int, int, int ); diff --git a/src/Protocol/Protocol125.cpp b/src/Protocol/Protocol125.cpp index 323a13992..73d21161c 100644 --- a/src/Protocol/Protocol125.cpp +++ b/src/Protocol/Protocol125.cpp @@ -1211,7 +1211,7 @@ int cProtocol125::ParseBlockDig(void) HANDLE_PACKET_READ(ReadByte, Byte, PosY); HANDLE_PACKET_READ(ReadBEInt, int, PosZ); HANDLE_PACKET_READ(ReadChar, char, BlockFace); - m_Client->HandleLeftClick(PosX, PosY, PosZ, BlockFace, Status); + m_Client->HandleLeftClick(PosX, PosY, PosZ, static_cast(BlockFace), Status); return PARSE_OK; } @@ -1234,7 +1234,7 @@ int cProtocol125::ParseBlockPlace(void) } // 1.2.5 didn't have any cursor position, so use 8, 8, 8, so that halfslabs and stairs work correctly and the special value is recognizable. - m_Client->HandleRightClick(PosX, PosY, PosZ, BlockFace, 8, 8, 8, HeldItem); + m_Client->HandleRightClick(PosX, PosY, PosZ, static_cast(BlockFace), 8, 8, 8, HeldItem); return PARSE_OK; } diff --git a/src/Protocol/Protocol132.cpp b/src/Protocol/Protocol132.cpp index f5fd95c7e..648e70151 100644 --- a/src/Protocol/Protocol132.cpp +++ b/src/Protocol/Protocol132.cpp @@ -476,7 +476,7 @@ int cProtocol132::ParseBlockPlace(void) HANDLE_PACKET_READ(ReadChar, char, CursorY); HANDLE_PACKET_READ(ReadChar, char, CursorZ); - m_Client->HandleRightClick(PosX, PosY, PosZ, BlockFace, CursorX, CursorY, CursorZ, HeldItem); + m_Client->HandleRightClick(PosX, PosY, PosZ, static_cast(BlockFace), CursorX, CursorY, CursorZ, HeldItem); return PARSE_OK; } diff --git a/src/Protocol/Protocol17x.cpp b/src/Protocol/Protocol17x.cpp index 04bade867..434055fe4 100644 --- a/src/Protocol/Protocol17x.cpp +++ b/src/Protocol/Protocol17x.cpp @@ -1480,7 +1480,7 @@ void cProtocol172::HandlePacketBlockDig(cByteBuffer & a_ByteBuffer) HANDLE_READ(a_ByteBuffer, ReadByte, Byte, BlockY); HANDLE_READ(a_ByteBuffer, ReadBEInt, int, BlockZ); HANDLE_READ(a_ByteBuffer, ReadByte, Byte, Face); - m_Client->HandleLeftClick(BlockX, BlockY, BlockZ, Face, Status); + m_Client->HandleLeftClick(BlockX, BlockY, BlockZ, static_cast(Face), Status); } @@ -1499,7 +1499,7 @@ void cProtocol172::HandlePacketBlockPlace(cByteBuffer & a_ByteBuffer) HANDLE_READ(a_ByteBuffer, ReadByte, Byte, CursorX); HANDLE_READ(a_ByteBuffer, ReadByte, Byte, CursorY); HANDLE_READ(a_ByteBuffer, ReadByte, Byte, CursorZ); - m_Client->HandleRightClick(BlockX, BlockY, BlockZ, Face, CursorX, CursorY, CursorZ, m_Client->GetPlayer()->GetEquippedItem()); + m_Client->HandleRightClick(BlockX, BlockY, BlockZ, static_cast(Face), CursorX, CursorY, CursorZ, m_Client->GetPlayer()->GetEquippedItem()); } diff --git a/src/Simulator/RedstoneSimulator.cpp b/src/Simulator/RedstoneSimulator.cpp index 05badf0d4..6b7ae3196 100644 --- a/src/Simulator/RedstoneSimulator.cpp +++ b/src/Simulator/RedstoneSimulator.cpp @@ -1112,12 +1112,13 @@ bool cRedstoneSimulator::IsPistonPowered(int a_BlockX, int a_BlockY, int a_Block // Pistons cannot be powered through their front face; this function verifies that a source meets this requirement int OldX = a_BlockX, OldY = a_BlockY, OldZ = a_BlockZ; + eBlockFace Face = cPiston::MetaDataToDirection(a_Meta); for (PoweredBlocksList::const_iterator itr = m_PoweredBlocks.begin(); itr != m_PoweredBlocks.end(); ++itr) { if (!itr->a_BlockPos.Equals(Vector3i(a_BlockX, a_BlockY, a_BlockZ))) { continue; } - AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_Meta); // Piston meta is based on what direction they face, so we can do this + AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, Face); if (!itr->a_SourcePos.Equals(Vector3i(a_BlockX, a_BlockY, a_BlockZ))) { @@ -1133,7 +1134,7 @@ bool cRedstoneSimulator::IsPistonPowered(int a_BlockX, int a_BlockY, int a_Block { if (!itr->a_BlockPos.Equals(Vector3i(a_BlockX, a_BlockY, a_BlockZ))) { continue; } - AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_Meta); + AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, Face); if (!itr->a_MiddlePos.Equals(Vector3i(a_BlockX, a_BlockY, a_BlockZ))) { -- cgit v1.2.3 From 1f26c9f5ab478b072eac7e850e730d5f0095c7dd Mon Sep 17 00:00:00 2001 From: Tycho Date: Tue, 4 Feb 2014 11:26:39 -0800 Subject: Fix gcc not having operator ++ on enums --- src/Blocks/BlockTorch.h | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/Blocks/BlockTorch.h b/src/Blocks/BlockTorch.h index 13f961d21..f2a4c8665 100644 --- a/src/Blocks/BlockTorch.h +++ b/src/Blocks/BlockTorch.h @@ -113,9 +113,10 @@ public: /// Finds a suitable face to place the torch, returning BLOCK_FACE_NONE on failure static eBlockFace FindSuitableFace(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ) { - for (eBlockFace i = BLOCK_FACE_YM; i <= BLOCK_FACE_XP; i++) // Loop through all directions + for (int i = BLOCK_FACE_YM; i <= BLOCK_FACE_XP; i++) // Loop through all directions { - AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, i, true); + eBlockFace Face = static_cast(i); + AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, Face, true); BLOCKTYPE BlockInQuestion = a_ChunkInterface.GetBlock(a_BlockX, a_BlockY, a_BlockZ); if ( // If on a block that can only hold a torch if torch is standing on it, return that face @@ -123,20 +124,20 @@ public: (BlockInQuestion == E_BLOCK_FENCE) || (BlockInQuestion == E_BLOCK_NETHER_BRICK_FENCE) || (BlockInQuestion == E_BLOCK_COBBLESTONE_WALL)) && - (i == BLOCK_FACE_TOP) + (Face == BLOCK_FACE_TOP) ) { - return i; + return Face; } else if ((g_BlockFullyOccupiesVoxel[BlockInQuestion]) && (i != BLOCK_FACE_BOTTOM)) { // Otherwise, if block in that direction is torch placeable and we haven't gotten to it via the bottom face, return that face - return i; + return Face; } else { // Reset coords in preparation for next iteration - AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, i, false); + AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, Face, false); } } return BLOCK_FACE_NONE; -- cgit v1.2.3 From 835a59b8fc4d005a6101546e2f2db33e205bc0e5 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 4 Feb 2014 22:15:01 +0100 Subject: Protocol 1.7 uses char for blockface. That should fix #644 on RasPi. --- src/Protocol/Protocol17x.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/Protocol/Protocol17x.cpp b/src/Protocol/Protocol17x.cpp index 434055fe4..8168e8314 100644 --- a/src/Protocol/Protocol17x.cpp +++ b/src/Protocol/Protocol17x.cpp @@ -1479,7 +1479,7 @@ void cProtocol172::HandlePacketBlockDig(cByteBuffer & a_ByteBuffer) HANDLE_READ(a_ByteBuffer, ReadBEInt, int, BlockX); HANDLE_READ(a_ByteBuffer, ReadByte, Byte, BlockY); HANDLE_READ(a_ByteBuffer, ReadBEInt, int, BlockZ); - HANDLE_READ(a_ByteBuffer, ReadByte, Byte, Face); + HANDLE_READ(a_ByteBuffer, ReadChar, char, Face); m_Client->HandleLeftClick(BlockX, BlockY, BlockZ, static_cast(Face), Status); } @@ -1492,7 +1492,7 @@ void cProtocol172::HandlePacketBlockPlace(cByteBuffer & a_ByteBuffer) HANDLE_READ(a_ByteBuffer, ReadBEInt, int, BlockX); HANDLE_READ(a_ByteBuffer, ReadByte, Byte, BlockY); HANDLE_READ(a_ByteBuffer, ReadBEInt, int, BlockZ); - HANDLE_READ(a_ByteBuffer, ReadByte, Byte, Face); + HANDLE_READ(a_ByteBuffer, ReadChar, char, Face); cItem Item; ReadItem(a_ByteBuffer, Item); -- cgit v1.2.3 From 5cdbb6683fa57814a3c83464de0178de0ce4ca9b Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 4 Feb 2014 22:18:59 +0100 Subject: Fixed a warning in cItem in gcc. Constructor member order... --- src/Item.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/Item.h b/src/Item.h index 7781db0cb..ca9ec5a2b 100644 --- a/src/Item.h +++ b/src/Item.h @@ -174,9 +174,9 @@ public: short m_ItemType; char m_ItemCount; short m_ItemDamage; + cEnchantments m_Enchantments; AString m_CustomName; AString m_Lore; - cEnchantments m_Enchantments; }; // tolua_end -- cgit v1.2.3 From 010e64be1124caabeb692f2005db364efb6ac9a0 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 4 Feb 2014 22:24:03 +0100 Subject: Removed a useless check in cLuaState. --- src/Bindings/LuaState.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'src') diff --git a/src/Bindings/LuaState.cpp b/src/Bindings/LuaState.cpp index 8dd17c448..ac5ce47e1 100644 --- a/src/Bindings/LuaState.cpp +++ b/src/Bindings/LuaState.cpp @@ -1018,9 +1018,7 @@ void cLuaState::LogStackTrace(lua_State * a_LuaState) int depth = 0; while (lua_getstack(a_LuaState, depth, &entry)) { - int status = lua_getinfo(a_LuaState, "Sln", &entry); - assert(status); - + lua_getinfo(a_LuaState, "Sln", &entry); LOGWARNING(" %s(%d): %s", entry.short_src, entry.currentline, entry.name ? entry.name : "(no name)"); depth++; } -- cgit v1.2.3 From 82173db9bf9c4f076062ca316c57bf6af9ea1a83 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 4 Feb 2014 22:26:35 +0100 Subject: Fixed a gcc warning in ManualBindings. Constructor member order... --- src/Bindings/ManualBindings.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/Bindings/ManualBindings.cpp b/src/Bindings/ManualBindings.cpp index dbaf32756..9ebdc4b22 100644 --- a/src/Bindings/ManualBindings.cpp +++ b/src/Bindings/ManualBindings.cpp @@ -1593,9 +1593,9 @@ static int tolua_cPluginManager_CallPlugin(lua_State * tolua_S) int m_NumReturns; cCallback(const AString & a_FunctionName, cLuaState & a_SrcLuaState) : + m_NumReturns(0), m_FunctionName(a_FunctionName), - m_SrcLuaState(a_SrcLuaState), - m_NumReturns(0) + m_SrcLuaState(a_SrcLuaState) { } protected: -- cgit v1.2.3