From 52d4c49d5cd2c15078c84a18821761b723833584 Mon Sep 17 00:00:00 2001 From: Howaner Date: Thu, 17 Jul 2014 22:32:23 +0200 Subject: Fixed many slime bugs. - Fixed slime hurt/death sound - Added slime spawning on death. - Fixed the max health. - Fixed the attack damage. - Little slimes should not attack players. --- src/Entities/Entity.cpp | 5 +--- src/Mobs/Slime.cpp | 68 ++++++++++++++++++++++++++++++++++++++++++++++++- src/Mobs/Slime.h | 8 ++++-- 3 files changed, 74 insertions(+), 7 deletions(-) diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index 4a6de25b7..3433258fd 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -1146,10 +1146,7 @@ void cEntity::SetMaxHealth(int a_MaxHealth) m_MaxHealth = a_MaxHealth; // Reset health, if too high: - if (m_Health > a_MaxHealth) - { - m_Health = a_MaxHealth; - } + m_Health = std::min(m_Health, a_MaxHealth); } diff --git a/src/Mobs/Slime.cpp b/src/Mobs/Slime.cpp index 52a52bb39..d74b66e5b 100644 --- a/src/Mobs/Slime.cpp +++ b/src/Mobs/Slime.cpp @@ -2,6 +2,8 @@ #include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules #include "Slime.h" +#include "FastRandom.h" +#include "World.h" @@ -9,9 +11,11 @@ /// Creates a slime of the specified size; size is 1 .. 3, with 1 being the smallest cSlime::cSlime(int a_Size) : - super("Slime", mtSlime, "mob.slime.attack", "mob.slime.attack", 0.6 * a_Size, 0.6 * a_Size), + super("Slime", mtSlime, Printf("mob.slime.%s", GetSizeName(a_Size).c_str()), Printf("mob.slime.%s", GetSizeName(a_Size).c_str()), 0.6 * a_Size, 0.6 * a_Size), m_Size(a_Size) { + SetMaxHealth(a_Size * a_Size); + SetAttackDamage(a_Size); } @@ -25,6 +29,7 @@ void cSlime::GetDrops(cItems & a_Drops, cEntity * a_Killer) { LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchLooting); } + if (GetSize() == 1) { AddRandomDropItem(a_Drops, 0, 2 + LootingLevel, E_ITEM_SLIMEBALL); @@ -34,3 +39,64 @@ void cSlime::GetDrops(cItems & a_Drops, cEntity * a_Killer) + +void cSlime::Attack(float a_Dt) +{ + if (m_Size != 1) + { + // Only slimes with the size 2 and 3 attacks a player. + super::Attack(a_Dt); + } +} + + + + + +void cSlime::KilledBy(TakeDamageInfo & a_TDI) +{ + if (GetHealth() > 0) + { + return; + } + + if (m_Size != 1) + { + cFastRandom Random; + int SpawnAmount = 2 + Random.NextInt(3); + + for (int i = 0; i < SpawnAmount; ++i) + { + double AddX = (i % 2 - 0.5) * m_Size / 4.0; + double AddZ = (i / 2 - 0.5) * m_Size / 4.0; + + cSlime * NewSlime = new cSlime(m_Size / 2); + NewSlime->SetPosition(GetPosX() + AddX, GetPosY() + 0.5, GetPosZ() + AddZ); + NewSlime->SetYaw(Random.NextFloat(2.0f) * 360.0f); + NewSlime->SetPitch(0.0f); + + m_World->SpawnMobFinalize(NewSlime); + } + } + super::KilledBy(a_TDI); +} + + + + + +const AString & cSlime::GetSizeName(int a_Size) +{ + if (a_Size > 1) + { + return "big"; + } + else + { + return "small"; + } +} + + + + diff --git a/src/Mobs/Slime.h b/src/Mobs/Slime.h index 782c3113f..1f66d9afb 100644 --- a/src/Mobs/Slime.h +++ b/src/Mobs/Slime.h @@ -13,17 +13,21 @@ class cSlime : typedef cAggressiveMonster super; public: - /// Creates a slime of the specified size; size is 1 .. 3, with 1 being the smallest + /** Creates a slime of the specified size; size is 1 .. 3, with 1 being the smallest */ cSlime(int a_Size); CLASS_PROTODEF(cSlime); virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; + virtual void Attack(float a_Dt) override; + virtual void KilledBy(TakeDamageInfo & a_TDI) override; + int GetSize(void) const { return m_Size; } + const AString & GetSizeName(int a_Size); protected: - /// Size of the slime, 1 .. 3, with 1 being the smallest + /** Size of the slime, 1 .. 3, with 1 being the smallest */ int m_Size; } ; -- cgit v1.2.3 From 0f8c24e04d60aa1642a5fe7346941ccd7697977e Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Thu, 17 Jul 2014 22:26:53 +0100 Subject: Fixed issues relating to saplings and leaves - Removed cBlockInfo::RequiresSpecialTool * Fixes #1195 * Fixes #1201 --- src/Bindings/DeprecatedBindings.cpp | 27 ---------------------- src/BlockInfo.cpp | 46 ------------------------------------- src/BlockInfo.h | 4 ---- src/Blocks/BlockBigFlower.h | 6 ++--- src/Blocks/BlockHandler.cpp | 46 +++++++++---------------------------- src/Blocks/BlockHandler.h | 10 ++++---- src/Blocks/BlockLeaves.h | 10 ++++++-- src/Blocks/BlockSapling.h | 4 ++-- src/Defines.h | 9 -------- src/Items/ItemHandler.cpp | 9 +++----- 10 files changed, 32 insertions(+), 139 deletions(-) diff --git a/src/Bindings/DeprecatedBindings.cpp b/src/Bindings/DeprecatedBindings.cpp index d51ba2da3..5bba1ea7a 100644 --- a/src/Bindings/DeprecatedBindings.cpp +++ b/src/Bindings/DeprecatedBindings.cpp @@ -175,32 +175,6 @@ static int tolua_get_AllToLua_g_BlockIsSnowable(lua_State* tolua_S) -/* get function: g_BlockRequiresSpecialTool */ -#ifndef TOLUA_DISABLE_tolua_get_AllToLua_g_BlockRequiresSpecialTool -static int tolua_get_AllToLua_g_BlockRequiresSpecialTool(lua_State* tolua_S) -{ - int BlockType; - #ifndef TOLUA_RELEASE - { - tolua_Error tolua_err; - if (!tolua_isnumber(tolua_S,2,0,&tolua_err)) - tolua_error(tolua_S,"#vinvalid type in array indexing.",&tolua_err); - } - #endif - BlockType = (int)tolua_tonumber(tolua_S, 2, 0); - if ((BlockType < 0) || (BlockType > E_BLOCK_MAX_TYPE_ID)) - { - tolua_error(tolua_S, "array indexing out of range.", NULL); - } - tolua_pushboolean(tolua_S, cBlockInfo::RequiresSpecialTool((BLOCKTYPE)BlockType)); - return 1; -} -#endif //#ifndef TOLUA_DISABLE - - - - - /* get function: g_BlockIsSolid */ #ifndef TOLUA_DISABLE_tolua_get_AllToLua_g_BlockIsSolid static int tolua_get_AllToLua_g_BlockIsSolid(lua_State* tolua_S) @@ -263,7 +237,6 @@ void DeprecatedBindings::Bind(lua_State * tolua_S) tolua_array(tolua_S, "g_BlockOneHitDig", tolua_get_AllToLua_g_BlockOneHitDig, NULL); tolua_array(tolua_S, "g_BlockPistonBreakable", tolua_get_AllToLua_g_BlockPistonBreakable, NULL); tolua_array(tolua_S, "g_BlockIsSnowable", tolua_get_AllToLua_g_BlockIsSnowable, NULL); - tolua_array(tolua_S, "g_BlockRequiresSpecialTool", tolua_get_AllToLua_g_BlockRequiresSpecialTool, NULL); tolua_array(tolua_S, "g_BlockIsSolid", tolua_get_AllToLua_g_BlockIsSolid, NULL); tolua_array(tolua_S, "g_BlockFullyOccupiesVoxel", tolua_get_AllToLua_g_BlockFullyOccupiesVoxel, NULL); diff --git a/src/BlockInfo.cpp b/src/BlockInfo.cpp index b4b98a2f0..524d39b67 100644 --- a/src/BlockInfo.cpp +++ b/src/BlockInfo.cpp @@ -15,7 +15,6 @@ cBlockInfo::cBlockInfo() , m_OneHitDig(false) , m_PistonBreakable(false) , m_IsSnowable(false) - , m_RequiresSpecialTool(false) , m_IsSolid(true) , m_FullyOccupiesVoxel(false) , m_Handler(NULL) @@ -440,51 +439,6 @@ void cBlockInfo::Initialize(cBlockInfoArray & a_Info) a_Info[E_BLOCK_TNT ].m_IsSnowable = true; a_Info[E_BLOCK_WOOL ].m_IsSnowable = true; - - // Blocks that don't drop without a special tool: - a_Info[E_BLOCK_BRICK ].m_RequiresSpecialTool = true; - a_Info[E_BLOCK_CAULDRON ].m_RequiresSpecialTool = true; - a_Info[E_BLOCK_COAL_ORE ].m_RequiresSpecialTool = true; - a_Info[E_BLOCK_COBBLESTONE ].m_RequiresSpecialTool = true; - a_Info[E_BLOCK_COBBLESTONE_WALL ].m_RequiresSpecialTool = true; - a_Info[E_BLOCK_COBBLESTONE_STAIRS ].m_RequiresSpecialTool = true; - a_Info[E_BLOCK_COBWEB ].m_RequiresSpecialTool = true; - a_Info[E_BLOCK_DIAMOND_BLOCK ].m_RequiresSpecialTool = true; - a_Info[E_BLOCK_DIAMOND_ORE ].m_RequiresSpecialTool = true; - a_Info[E_BLOCK_DOUBLE_STONE_SLAB ].m_RequiresSpecialTool = true; - a_Info[E_BLOCK_EMERALD_ORE ].m_RequiresSpecialTool = true; - a_Info[E_BLOCK_END_STONE ].m_RequiresSpecialTool = true; - a_Info[E_BLOCK_GOLD_BLOCK ].m_RequiresSpecialTool = true; - a_Info[E_BLOCK_GOLD_ORE ].m_RequiresSpecialTool = true; - a_Info[E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE].m_RequiresSpecialTool = true; - a_Info[E_BLOCK_IRON_BLOCK ].m_RequiresSpecialTool = true; - a_Info[E_BLOCK_IRON_ORE ].m_RequiresSpecialTool = true; - a_Info[E_BLOCK_LAPIS_BLOCK ].m_RequiresSpecialTool = true; - a_Info[E_BLOCK_LAPIS_ORE ].m_RequiresSpecialTool = true; - a_Info[E_BLOCK_LEAVES ].m_RequiresSpecialTool = true; - a_Info[E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE].m_RequiresSpecialTool = true; - a_Info[E_BLOCK_MOSSY_COBBLESTONE ].m_RequiresSpecialTool = true; - a_Info[E_BLOCK_NETHERRACK ].m_RequiresSpecialTool = true; - a_Info[E_BLOCK_NETHER_BRICK ].m_RequiresSpecialTool = true; - a_Info[E_BLOCK_NETHER_BRICK_STAIRS ].m_RequiresSpecialTool = true; - a_Info[E_BLOCK_OBSIDIAN ].m_RequiresSpecialTool = true; - a_Info[E_BLOCK_REDSTONE_ORE ].m_RequiresSpecialTool = true; - a_Info[E_BLOCK_REDSTONE_ORE_GLOWING].m_RequiresSpecialTool = true; - a_Info[E_BLOCK_SANDSTONE ].m_RequiresSpecialTool = true; - a_Info[E_BLOCK_SANDSTONE_STAIRS ].m_RequiresSpecialTool = true; - a_Info[E_BLOCK_SNOW ].m_RequiresSpecialTool = true; - a_Info[E_BLOCK_STONE ].m_RequiresSpecialTool = true; - a_Info[E_BLOCK_STONE_BRICKS ].m_RequiresSpecialTool = true; - a_Info[E_BLOCK_STONE_BRICK_STAIRS ].m_RequiresSpecialTool = true; - a_Info[E_BLOCK_STONE_PRESSURE_PLATE].m_RequiresSpecialTool = true; - a_Info[E_BLOCK_STONE_SLAB ].m_RequiresSpecialTool = true; - a_Info[E_BLOCK_VINES ].m_RequiresSpecialTool = true; - a_Info[E_BLOCK_FURNACE ].m_RequiresSpecialTool = true; - a_Info[E_BLOCK_LIT_FURNACE ].m_RequiresSpecialTool = true; - a_Info[E_BLOCK_ANVIL ].m_RequiresSpecialTool = true; - a_Info[E_BLOCK_ENCHANTMENT_TABLE ].m_RequiresSpecialTool = true; - - // Nonsolid blocks: a_Info[E_BLOCK_ACTIVATOR_RAIL ].m_IsSolid = false; a_Info[E_BLOCK_AIR ].m_IsSolid = false; diff --git a/src/BlockInfo.h b/src/BlockInfo.h index d6d4e7430..e10ca9e68 100644 --- a/src/BlockInfo.h +++ b/src/BlockInfo.h @@ -39,9 +39,6 @@ public: /** Can this block hold snow atop? */ bool m_IsSnowable; - /** Does this block require a tool to drop? */ - bool m_RequiresSpecialTool; - /** Is this block solid (player cannot walk through)? */ bool m_IsSolid; @@ -61,7 +58,6 @@ public: inline static bool IsOneHitDig (BLOCKTYPE a_Type) { return Get(a_Type).m_OneHitDig; } inline static bool IsPistonBreakable (BLOCKTYPE a_Type) { return Get(a_Type).m_PistonBreakable; } inline static bool IsSnowable (BLOCKTYPE a_Type) { return Get(a_Type).m_IsSnowable; } - inline static bool RequiresSpecialTool (BLOCKTYPE a_Type) { return Get(a_Type).m_RequiresSpecialTool; } inline static bool IsSolid (BLOCKTYPE a_Type) { return Get(a_Type).m_IsSolid; } inline static bool FullyOccupiesVoxel (BLOCKTYPE a_Type) { return Get(a_Type).m_FullyOccupiesVoxel; } diff --git a/src/Blocks/BlockBigFlower.h b/src/Blocks/BlockBigFlower.h index 39fd3cac8..0ba997a68 100644 --- a/src/Blocks/BlockBigFlower.h +++ b/src/Blocks/BlockBigFlower.h @@ -19,16 +19,16 @@ public: } - virtual void DropBlock(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_BlockPluginInterface, cEntity * a_Digger, int a_BlockX, int a_BlockY, int a_BlockZ) override + virtual void DropBlock(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_BlockPluginInterface, cEntity * a_Digger, int a_BlockX, int a_BlockY, int a_BlockZ, bool a_DropVerbatim) override { NIBBLETYPE Meta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ); if (Meta & 0x8) { - super::DropBlock(a_ChunkInterface, a_WorldInterface, a_BlockPluginInterface, a_Digger, a_BlockX, a_BlockY - 1, a_BlockZ); + super::DropBlock(a_ChunkInterface, a_WorldInterface, a_BlockPluginInterface, a_Digger, a_BlockX, a_BlockY - 1, a_BlockZ, a_DropVerbatim); } else { - super::DropBlock(a_ChunkInterface, a_WorldInterface, a_BlockPluginInterface, a_Digger, a_BlockX, a_BlockY, a_BlockZ); + super::DropBlock(a_ChunkInterface, a_WorldInterface, a_BlockPluginInterface, a_Digger, a_BlockX, a_BlockY, a_BlockZ, a_DropVerbatim); } } diff --git a/src/Blocks/BlockHandler.cpp b/src/Blocks/BlockHandler.cpp index cef1f5f09..233070b14 100644 --- a/src/Blocks/BlockHandler.cpp +++ b/src/Blocks/BlockHandler.cpp @@ -407,39 +407,6 @@ void cBlockHandler::NeighborChanged(cChunkInterface & a_ChunkInterface, int a_Bl - -void cBlockHandler::OnNeighborChanged(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ) -{ -} - - - - - -void cBlockHandler::OnDigging(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer *a_Player, int a_BlockX, int a_BlockY, int a_BlockZ) -{ -} - - - - - -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) -{ -} - - - - - -void cBlockHandler::OnCancelRightClick(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer *a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace) -{ -} - - - - - void cBlockHandler::ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) { // Setting the meta to a_BlockMeta keeps most textures. The few other blocks have to override this. @@ -450,11 +417,20 @@ void cBlockHandler::ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) -void cBlockHandler::DropBlock(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_BlockPluginInterface, cEntity * a_Digger, int a_BlockX, int a_BlockY, int a_BlockZ) +void cBlockHandler::DropBlock(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_BlockPluginInterface, cEntity * a_Digger, int a_BlockX, int a_BlockY, int a_BlockZ, bool a_DropVerbatim) { cItems Pickups; NIBBLETYPE Meta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ); - ConvertToPickups(Pickups, Meta); + + if (!a_DropVerbatim) + { + ConvertToPickups(Pickups, Meta); + } + else + { + // TODO: Add a proper overridable function for this + Pickups.Add(m_BlockType, 1, Meta); + } // Allow plugins to modify the pickups: a_BlockPluginInterface.CallHookBlockToPickups(a_Digger, a_BlockX, a_BlockY, a_BlockZ, m_BlockType, Meta, Pickups); diff --git a/src/Blocks/BlockHandler.h b/src/Blocks/BlockHandler.h index fb6cae729..ee4d4a6fe 100644 --- a/src/Blocks/BlockHandler.h +++ b/src/Blocks/BlockHandler.h @@ -60,25 +60,25 @@ public: virtual void OnDestroyed(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, int a_BlockX, int a_BlockY, int a_BlockZ); /// Called when a direct neighbor of this block has been changed (The position is the own position, not the neighbor position) - virtual void OnNeighborChanged(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ); + virtual void OnNeighborChanged(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ) {}; /// Notifies all neighbors of the given block about a change static void NeighborChanged(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ); /// Called while the player diggs the block. - virtual void OnDigging(cChunkInterface & cChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ); + 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, eBlockFace 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 a Right Click to this Block is cancelled */ - virtual void OnCancelRightClick(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace); + virtual void OnCancelRightClick(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace) {}; /// 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); /// Handles the dropping of a block based on what ConvertToDrops() returns. This will not destroy the block. a_Digger is the entity causing the drop; it may be NULL - virtual void DropBlock(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_BlockPluginInterface, cEntity * a_Digger, int a_BlockX, int a_BlockY, int a_BlockZ); + virtual void DropBlock(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_BlockPluginInterface, cEntity * a_Digger, int a_BlockX, int a_BlockY, int a_BlockZ, bool a_DropVerbatim = false); /// Returns step sound name of block virtual const char * GetStepSound(void); diff --git a/src/Blocks/BlockLeaves.h b/src/Blocks/BlockLeaves.h index 495e849fa..67c4535b8 100644 --- a/src/Blocks/BlockLeaves.h +++ b/src/Blocks/BlockLeaves.h @@ -43,11 +43,17 @@ public: // Only the first 2 bits contain the display information, the others are for growing if (rand.NextInt(6) == 0) { - a_Pickups.push_back(cItem(E_BLOCK_SAPLING, 1, a_BlockMeta & 3)); + a_Pickups.push_back( + cItem( + E_BLOCK_SAPLING, + 1, + (m_BlockType == E_BLOCK_LEAVES) ? (a_BlockMeta & 0x03) : (2 << (a_BlockMeta & 0x01)) // Old leaves - 3 bits contain display; new leaves - 1st bit, shifted left two for saplings to understand + ) + ); } // 1 % chance of dropping an apple, if the leaves' type is Apple Leaves - if ((a_BlockMeta & 3) == E_META_LEAVES_APPLE) + if ((m_BlockType == E_BLOCK_LEAVES) && ((a_BlockMeta & 0x03) == E_META_LEAVES_APPLE)) { if (rand.NextInt(101) == 0) { diff --git a/src/Blocks/BlockSapling.h b/src/Blocks/BlockSapling.h index 3d925029a..e965809a3 100644 --- a/src/Blocks/BlockSapling.h +++ b/src/Blocks/BlockSapling.h @@ -20,8 +20,8 @@ public: virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override { - // Only the first 2 bits contain the display information, the others are for growing - a_Pickups.push_back(cItem(E_BLOCK_SAPLING, 1, a_BlockMeta & 3)); + // Only the first 5 bits contain the display information, 8th bit for growth indicator (but we use 0x07 for forward compatibility) + a_Pickups.push_back(cItem(E_BLOCK_SAPLING, 1, a_BlockMeta & 0x07)); } diff --git a/src/Defines.h b/src/Defines.h index ee91ee596..4fde6800a 100644 --- a/src/Defines.h +++ b/src/Defines.h @@ -727,14 +727,5 @@ namespace ItemCategory // tolua_end -inline bool BlockRequiresSpecialTool(BLOCKTYPE a_BlockType) -{ - if(!IsValidBlock(a_BlockType)) return false; - return cBlockInfo::RequiresSpecialTool(a_BlockType); -} - - - - diff --git a/src/Items/ItemHandler.cpp b/src/Items/ItemHandler.cpp index 85406c826..604cce729 100644 --- a/src/Items/ItemHandler.cpp +++ b/src/Items/ItemHandler.cpp @@ -328,12 +328,9 @@ void cItemHandler::OnBlockDestroyed(cWorld * a_World, cPlayer * a_Player, const if (a_Player->IsGameModeSurvival()) { - if (!BlockRequiresSpecialTool(Block) || CanHarvestBlock(Block)) - { - cChunkInterface ChunkInterface(a_World->GetChunkMap()); - cBlockInServerPluginInterface PluginInterface(*a_World); - Handler->DropBlock(ChunkInterface, *a_World, PluginInterface, a_Player, a_BlockX, a_BlockY, a_BlockZ); - } + cChunkInterface ChunkInterface(a_World->GetChunkMap()); + cBlockInServerPluginInterface PluginInterface(*a_World); + Handler->DropBlock(ChunkInterface, *a_World, PluginInterface, a_Player, a_BlockX, a_BlockY, a_BlockZ, CanHarvestBlock(Block)); } a_Player->UseEquippedItem(); -- cgit v1.2.3 From fba93aac2aa90fa654fef9fe4252042aae53893f Mon Sep 17 00:00:00 2001 From: Howaner Date: Thu, 17 Jul 2014 23:32:01 +0200 Subject: Split into more lines. --- src/Mobs/Slime.cpp | 14 +++++++++----- src/Mobs/Slime.h | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/Mobs/Slime.cpp b/src/Mobs/Slime.cpp index d74b66e5b..4e12fca51 100644 --- a/src/Mobs/Slime.cpp +++ b/src/Mobs/Slime.cpp @@ -11,7 +11,13 @@ /// Creates a slime of the specified size; size is 1 .. 3, with 1 being the smallest cSlime::cSlime(int a_Size) : - super("Slime", mtSlime, Printf("mob.slime.%s", GetSizeName(a_Size).c_str()), Printf("mob.slime.%s", GetSizeName(a_Size).c_str()), 0.6 * a_Size, 0.6 * a_Size), + super("Slime", + mtSlime, + Printf("mob.slime.%s", GetSizeName(a_Size).c_str()), + Printf("mob.slime.%s", GetSizeName(a_Size).c_str()), + 0.6 * a_Size, + 0.6 * a_Size + ), m_Size(a_Size) { SetMaxHealth(a_Size * a_Size); @@ -72,9 +78,7 @@ void cSlime::KilledBy(TakeDamageInfo & a_TDI) cSlime * NewSlime = new cSlime(m_Size / 2); NewSlime->SetPosition(GetPosX() + AddX, GetPosY() + 0.5, GetPosZ() + AddZ); - NewSlime->SetYaw(Random.NextFloat(2.0f) * 360.0f); - NewSlime->SetPitch(0.0f); - + NewSlime->SetYaw(Random.NextFloat(1.0f) * 360.0f); m_World->SpawnMobFinalize(NewSlime); } } @@ -85,7 +89,7 @@ void cSlime::KilledBy(TakeDamageInfo & a_TDI) -const AString & cSlime::GetSizeName(int a_Size) +const AString cSlime::GetSizeName(int a_Size) const { if (a_Size > 1) { diff --git a/src/Mobs/Slime.h b/src/Mobs/Slime.h index 1f66d9afb..87c5a8e5e 100644 --- a/src/Mobs/Slime.h +++ b/src/Mobs/Slime.h @@ -23,7 +23,7 @@ public: virtual void KilledBy(TakeDamageInfo & a_TDI) override; int GetSize(void) const { return m_Size; } - const AString & GetSizeName(int a_Size); + const AString GetSizeName(int a_Size) const; protected: -- cgit v1.2.3 From 33bd78dcdd1f080ef5d3b47b0e24099227a8a5d5 Mon Sep 17 00:00:00 2001 From: Howaner Date: Fri, 18 Jul 2014 01:26:27 +0200 Subject: Skeletons should spawn with a bow in the hand. Fixes #1184 --- src/Mobs/Skeleton.cpp | 15 +++++++++++++++ src/Mobs/Skeleton.h | 2 ++ 2 files changed, 17 insertions(+) diff --git a/src/Mobs/Skeleton.cpp b/src/Mobs/Skeleton.cpp index 0641a3d57..2f57bedeb 100644 --- a/src/Mobs/Skeleton.cpp +++ b/src/Mobs/Skeleton.cpp @@ -4,6 +4,7 @@ #include "Skeleton.h" #include "../World.h" #include "../Entities/ArrowEntity.h" +#include "ClientHandle.h" @@ -90,3 +91,17 @@ void cSkeleton::Attack(float a_Dt) m_AttackInterval = 0.0; } } + + + + + +void cSkeleton::SpawnOn(cClientHandle & a_ClientHandle) +{ + super::SpawnOn(a_ClientHandle); + a_ClientHandle.SendEntityEquipment(*this, 0, cItem(E_ITEM_BOW)); +} + + + + diff --git a/src/Mobs/Skeleton.h b/src/Mobs/Skeleton.h index 8f31b42e1..229462d63 100644 --- a/src/Mobs/Skeleton.h +++ b/src/Mobs/Skeleton.h @@ -20,6 +20,8 @@ public: virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; virtual void MoveToPosition(const Vector3f & a_Position) override; virtual void Attack(float a_Dt) override; + virtual void SpawnOn(cClientHandle & a_ClientHandle) override; + bool IsWither(void) const { return m_bIsWither; }; private: -- cgit v1.2.3 From 57d415e38be306eb933bf71d262f4ea4f4a1036c Mon Sep 17 00:00:00 2001 From: Howaner Date: Fri, 18 Jul 2014 01:28:56 +0200 Subject: Added me to the CONTRIBUTORS list. I hope it is ok. --- CONTRIBUTORS | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 09515aa6b..925e8f35b 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -28,5 +28,6 @@ UltraCoderRU worktycho xoft Yeeeeezus (Donated AlchemistVillage prefabs) +Howaner Please add yourself to this list if you contribute to MCServer. -- cgit v1.2.3 From fc6a5878df2615262eb53cb1ca4ccfcf1e299dc6 Mon Sep 17 00:00:00 2001 From: Howaner Date: Fri, 18 Jul 2014 01:45:45 +0200 Subject: Removed special character in APIDump --- MCServer/Plugins/APIDump/Hooks/OnPlayerUsedBlock.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MCServer/Plugins/APIDump/Hooks/OnPlayerUsedBlock.lua b/MCServer/Plugins/APIDump/Hooks/OnPlayerUsedBlock.lua index 4c91ea89e..9a0e036b9 100644 --- a/MCServer/Plugins/APIDump/Hooks/OnPlayerUsedBlock.lua +++ b/MCServer/Plugins/APIDump/Hooks/OnPlayerUsedBlock.lua @@ -2,7 +2,7 @@ return { HOOK_PLAYER_USED_BLOCK = { - CalledWhen = "A player has just used a block (chest, furnace…). Notification only.", + CalledWhen = "A player has just used a block (chest, furnace...). Notification only.", DefaultFnName = "OnPlayerUsedBlock", -- also used as pagename Desc = [[ This hook is called after a {{cPlayer|player}} has right-clicked a block that can be used, such as a -- cgit v1.2.3 From eeacb6f2223f88a64ce877458c58fa60194e45a6 Mon Sep 17 00:00:00 2001 From: Howaner Date: Fri, 18 Jul 2014 02:19:30 +0200 Subject: Added a extra wall sign handler. Fixes #1119 --- src/Blocks/BlockHandler.cpp | 7 +-- src/Blocks/BlockSign.h | 109 -------------------------------------------- src/Blocks/BlockSignPost.h | 103 +++++++++++++++++++++++++++++++++++++++++ src/Blocks/BlockWallSign.h | 62 +++++++++++++++++++++++++ src/Items/ItemSign.h | 7 +-- 5 files changed, 173 insertions(+), 115 deletions(-) delete mode 100644 src/Blocks/BlockSign.h create mode 100644 src/Blocks/BlockSignPost.h create mode 100644 src/Blocks/BlockWallSign.h diff --git a/src/Blocks/BlockHandler.cpp b/src/Blocks/BlockHandler.cpp index 97762f9bd..8ab4116f4 100644 --- a/src/Blocks/BlockHandler.cpp +++ b/src/Blocks/BlockHandler.cpp @@ -70,7 +70,7 @@ #include "BlockSand.h" #include "BlockSapling.h" #include "BlockSideways.h" -#include "BlockSign.h" +#include "BlockSignPost.h" #include "BlockSlab.h" #include "BlockSnow.h" #include "BlockStairs.h" @@ -81,6 +81,7 @@ #include "BlockTorch.h" #include "BlockTrapdoor.h" #include "BlockVine.h" +#include "BlockWallSign.h" #include "BlockWorkbench.h" @@ -275,7 +276,7 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType) case E_BLOCK_SAND: return new cBlockSandHandler (a_BlockType); case E_BLOCK_SANDSTONE_STAIRS: return new cBlockStairsHandler (a_BlockType); case E_BLOCK_SAPLING: return new cBlockSaplingHandler (a_BlockType); - case E_BLOCK_SIGN_POST: return new cBlockSignHandler (a_BlockType); + case E_BLOCK_SIGN_POST: return new cBlockSignPostHandler (a_BlockType); case E_BLOCK_SNOW: return new cBlockSnowHandler (a_BlockType); case E_BLOCK_SPRUCE_WOOD_STAIRS: return new cBlockStairsHandler (a_BlockType); case E_BLOCK_STAINED_GLASS: return new cBlockGlassHandler (a_BlockType); @@ -297,7 +298,7 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType) case E_BLOCK_TRIPWIRE: return new cBlockTripwireHandler (a_BlockType); case E_BLOCK_TRIPWIRE_HOOK: return new cBlockTripwireHookHandler (a_BlockType); case E_BLOCK_VINES: return new cBlockVineHandler (a_BlockType); - case E_BLOCK_WALLSIGN: return new cBlockSignHandler (a_BlockType); // TODO: This needs a special handler + case E_BLOCK_WALLSIGN: return new cBlockWallSignHandler (a_BlockType); case E_BLOCK_WATER: return new cBlockFluidHandler (a_BlockType); case E_BLOCK_WOODEN_BUTTON: return new cBlockButtonHandler (a_BlockType); case E_BLOCK_WOODEN_DOOR: return new cBlockDoorHandler (a_BlockType); diff --git a/src/Blocks/BlockSign.h b/src/Blocks/BlockSign.h deleted file mode 100644 index 5aa8ade3d..000000000 --- a/src/Blocks/BlockSign.h +++ /dev/null @@ -1,109 +0,0 @@ - -#pragma once - -#include "BlockHandler.h" -#include "../Entities/Player.h" -#include "Chunk.h" - - - - - -class cBlockSignHandler : - public cBlockHandler -{ -public: - cBlockSignHandler(BLOCKTYPE a_BlockType) - : cBlockHandler(a_BlockType) - { - } - - - virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override - { - a_Pickups.push_back(cItem(E_ITEM_SIGN, 1, 0)); - } - - - virtual const char * GetStepSound(void) override - { - return "step.wood"; - } - - - static NIBBLETYPE RotationToMetaData(double a_Rotation) - { - a_Rotation += 180 + (180 / 16); // So it's not aligned with axis - if (a_Rotation > 360) - { - a_Rotation -= 360; - } - - a_Rotation = (a_Rotation / 360) * 16; - - return ((char)a_Rotation) % 16; - } - - - static NIBBLETYPE DirectionToMetaData(eBlockFace a_Direction) - { - switch (a_Direction) - { - case 0x2: return 0x2; - case 0x3: return 0x3; - case 0x4: return 0x4; - case 0x5: return 0x5; - default: - { - break; - } - } - return 0x2; - } - - - 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 - { - a_Player->GetClientHandle()->SendEditSign(a_BlockX, a_BlockY, a_BlockZ); - } - - - virtual NIBBLETYPE MetaRotateCW(NIBBLETYPE a_Meta) override - { - return (a_Meta + 4) & 0x0f; - } - - - virtual NIBBLETYPE MetaRotateCCW(NIBBLETYPE a_Meta) override - { - return (a_Meta + 12) & 0x0f; - } - - virtual NIBBLETYPE MetaMirrorXY(NIBBLETYPE a_Meta) override - { - // Mirrors signs over the XY plane (North-South Mirroring) - - // There are 16 meta values which correspond to different directions. - // These values are equated to angles on a circle; 0x08 = 180 degrees. - return (a_Meta < 0x08) ? (0x08 + a_Meta) : (0x08 - a_Meta); - } - - - virtual NIBBLETYPE MetaMirrorYZ(NIBBLETYPE a_Meta) override - { - // Mirrors signs over the YZ plane (East-West Mirroring) - - // There are 16 meta values which correspond to different directions. - // These values are equated to angles on a circle; 0x10 = 360 degrees. - return 0x10 - a_Meta; - } -} ; - - - - diff --git a/src/Blocks/BlockSignPost.h b/src/Blocks/BlockSignPost.h new file mode 100644 index 000000000..d5b0c0b5f --- /dev/null +++ b/src/Blocks/BlockSignPost.h @@ -0,0 +1,103 @@ + +#pragma once + +#include "BlockHandler.h" +#include "../Entities/Player.h" +#include "Chunk.h" + + + + + +class cBlockSignPostHandler : + public cBlockHandler +{ +public: + cBlockSignPostHandler(BLOCKTYPE a_BlockType) + : cBlockHandler(a_BlockType) + { + } + + + virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override + { + a_Pickups.push_back(cItem(E_ITEM_SIGN, 1, 0)); + } + + + virtual const char * GetStepSound(void) override + { + return "step.wood"; + } + + + virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override + { + if (a_RelY <= 0) + { + return false; + } + + return (cBlockInfo::IsSolid(a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ))); + } + + + static NIBBLETYPE RotationToMetaData(double a_Rotation) + { + a_Rotation += 180 + (180 / 16); // So it's not aligned with axis + if (a_Rotation > 360) + { + a_Rotation -= 360; + } + + a_Rotation = (a_Rotation / 360) * 16; + + return ((char)a_Rotation) % 16; + } + + + 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 + { + a_Player->GetClientHandle()->SendEditSign(a_BlockX, a_BlockY, a_BlockZ); + } + + + virtual NIBBLETYPE MetaRotateCW(NIBBLETYPE a_Meta) override + { + return (a_Meta + 4) & 0x0f; + } + + + virtual NIBBLETYPE MetaRotateCCW(NIBBLETYPE a_Meta) override + { + return (a_Meta + 12) & 0x0f; + } + + virtual NIBBLETYPE MetaMirrorXY(NIBBLETYPE a_Meta) override + { + // Mirrors signs over the XY plane (North-South Mirroring) + + // There are 16 meta values which correspond to different directions. + // These values are equated to angles on a circle; 0x08 = 180 degrees. + return (a_Meta < 0x08) ? (0x08 + a_Meta) : (0x08 - a_Meta); + } + + + virtual NIBBLETYPE MetaMirrorYZ(NIBBLETYPE a_Meta) override + { + // Mirrors signs over the YZ plane (East-West Mirroring) + + // There are 16 meta values which correspond to different directions. + // These values are equated to angles on a circle; 0x10 = 360 degrees. + return 0x10 - a_Meta; + } +} ; + + + + diff --git a/src/Blocks/BlockWallSign.h b/src/Blocks/BlockWallSign.h new file mode 100644 index 000000000..037a7bd19 --- /dev/null +++ b/src/Blocks/BlockWallSign.h @@ -0,0 +1,62 @@ + +#pragma once + +#include "Chunk.h" + + + + + +class cBlockWallSignHandler : + public cBlockSignPostHandler +{ +public: + cBlockWallSignHandler(BLOCKTYPE a_BlockType) + : cBlockSignPostHandler(a_BlockType) + { + } + + + virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override + { + int BlockX = (a_Chunk.GetPosX() * cChunkDef::Width) + a_RelX; + int BlockZ = (a_Chunk.GetPosZ() * cChunkDef::Width) + a_RelZ; + GetBlockCoordsBehindTheSign(a_Chunk.GetMeta(a_RelX, a_RelY, a_RelZ), BlockX, BlockZ); + + return (cBlockInfo::IsSolid(a_ChunkInterface.GetBlock(BlockX, a_RelY, BlockZ))); + } + + + virtual void GetBlockCoordsBehindTheSign(NIBBLETYPE a_BlockMeta, int & a_BlockX, int & a_BlockZ) + { + switch (a_BlockMeta) + { + case 2: a_BlockZ++; break; + case 3: a_BlockZ--; break; + case 4: a_BlockX++; break; + case 5: a_BlockX--; break; + default: break; + } + } + + + static NIBBLETYPE DirectionToMetaData(eBlockFace a_Direction) + { + switch (a_Direction) + { + case 0x2: return 0x2; + case 0x3: return 0x3; + case 0x4: return 0x4; + case 0x5: return 0x5; + default: + { + break; + } + } + return 0x2; + } +} ; + + + + diff --git a/src/Items/ItemSign.h b/src/Items/ItemSign.h index 235a4fa93..0fa0fa0be 100644 --- a/src/Items/ItemSign.h +++ b/src/Items/ItemSign.h @@ -3,7 +3,8 @@ #include "ItemHandler.h" #include "../World.h" -#include "../Blocks/BlockSign.h" +#include "../Blocks/BlockSignPost.h" +#include "../Blocks/BlockWallSign.h" @@ -34,12 +35,12 @@ public: { if (a_BlockFace == BLOCK_FACE_TOP) { - a_BlockMeta = cBlockSignHandler::RotationToMetaData(a_Player->GetYaw()); + a_BlockMeta = cBlockSignPostHandler::RotationToMetaData(a_Player->GetYaw()); a_BlockType = E_BLOCK_SIGN_POST; } else { - a_BlockMeta = cBlockSignHandler::DirectionToMetaData(a_BlockFace); + a_BlockMeta = cBlockWallSignHandler::DirectionToMetaData(a_BlockFace); a_BlockType = E_BLOCK_WALLSIGN; } return true; -- cgit v1.2.3 From 32b25ec7f799ca15fdcdc3e9e9535c798d0cc523 Mon Sep 17 00:00:00 2001 From: archshift Date: Thu, 17 Jul 2014 18:34:47 -0700 Subject: Generator: removed rnd definitions that are never read --- src/Generating/MineShafts.cpp | 1 - src/Generating/StructGen.cpp | 1 - 2 files changed, 2 deletions(-) diff --git a/src/Generating/MineShafts.cpp b/src/Generating/MineShafts.cpp index e951b90fa..0532aff39 100644 --- a/src/Generating/MineShafts.cpp +++ b/src/Generating/MineShafts.cpp @@ -997,7 +997,6 @@ cMineShaft * cMineShaftCrossing::CreateAndFit( BoundingBox.p2.y -= 4; } } - rnd >>= 2; switch (a_Direction) { case dirXP: BoundingBox.p2.x += 4; BoundingBox.p1.z -= 2; BoundingBox.p2.z += 2; break; diff --git a/src/Generating/StructGen.cpp b/src/Generating/StructGen.cpp index 5deded17d..054eec345 100644 --- a/src/Generating/StructGen.cpp +++ b/src/Generating/StructGen.cpp @@ -484,7 +484,6 @@ void cStructGenLakes::CreateLakeImage(int a_ChunkX, int a_ChunkZ, cBlockArea & a const int BubbleY = 4 + (Rnd & 0x01); // 4 .. 5 Rnd >>= 1; const int BubbleZ = BubbleR + (Rnd % Range); - Rnd >>= 4; const int HalfR = BubbleR / 2; // 1 .. 2 const int RSquared = BubbleR * BubbleR; for (int y = -HalfR; y <= HalfR; y++) -- cgit v1.2.3 From 33b0a719da8ed8f76397f6003a5a9afa7079c090 Mon Sep 17 00:00:00 2001 From: archshift Date: Thu, 17 Jul 2014 18:39:44 -0700 Subject: ProtocolRecognizer.cpp: removed unused NumBytesRead --- src/Protocol/ProtocolRecognizer.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Protocol/ProtocolRecognizer.cpp b/src/Protocol/ProtocolRecognizer.cpp index d3aae65fe..3991b84de 100644 --- a/src/Protocol/ProtocolRecognizer.cpp +++ b/src/Protocol/ProtocolRecognizer.cpp @@ -953,7 +953,6 @@ bool cProtocolRecognizer::TryRecognizeLengthlessProtocol(void) bool cProtocolRecognizer::TryRecognizeLengthedProtocol(UInt32 a_PacketLengthRemaining) { UInt32 PacketType; - UInt32 NumBytesRead = (UInt32)m_Buffer.GetReadableSpace(); if (!m_Buffer.ReadVarInt(PacketType)) { return false; @@ -972,7 +971,6 @@ bool cProtocolRecognizer::TryRecognizeLengthedProtocol(UInt32 a_PacketLengthRema { return false; } - NumBytesRead -= (UInt32)m_Buffer.GetReadableSpace(); switch (ProtocolVersion) { case PROTO_VERSION_1_7_2: -- cgit v1.2.3 From ffe44c13d0ce037efb01544b96fe0756d64b8517 Mon Sep 17 00:00:00 2001 From: archshift Date: Thu, 17 Jul 2014 23:25:14 -0700 Subject: Moved ChatColor.h out of defines where it was not needed --- src/Defines.h | 1 - src/Entities/Player.cpp | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Defines.h b/src/Defines.h index 877970ab8..f57e63c7f 100644 --- a/src/Defines.h +++ b/src/Defines.h @@ -1,7 +1,6 @@ #pragma once -#include "ChatColor.h" #include #include diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index 5c3303cb2..ea11926b8 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -2,6 +2,7 @@ #include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules #include "Player.h" +#include "../ChatColor.h" #include "../Server.h" #include "../UI/Window.h" #include "../UI/WindowOwner.h" -- cgit v1.2.3 From d52a51f7b6530d2a63682798472840d7261ebad4 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 18 Jul 2014 09:18:00 +0200 Subject: Removed duplicate IPvX labels. --- src/HTTPServer/HTTPServer.cpp | 4 ++-- src/RCONServer.cpp | 4 ++-- src/Server.cpp | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/HTTPServer/HTTPServer.cpp b/src/HTTPServer/HTTPServer.cpp index b7edf7829..8eabe5cb2 100644 --- a/src/HTTPServer/HTTPServer.cpp +++ b/src/HTTPServer/HTTPServer.cpp @@ -122,8 +122,8 @@ class cDebugCallbacks : // cHTTPServer: cHTTPServer::cHTTPServer(void) : - m_ListenThreadIPv4(*this, cSocket::IPv4, "WebServer IPv4"), - m_ListenThreadIPv6(*this, cSocket::IPv6, "WebServer IPv6"), + m_ListenThreadIPv4(*this, cSocket::IPv4, "WebServer"), + m_ListenThreadIPv6(*this, cSocket::IPv6, "WebServer"), m_Callbacks(NULL) { } diff --git a/src/RCONServer.cpp b/src/RCONServer.cpp index 28cb1e03b..141c67d1b 100644 --- a/src/RCONServer.cpp +++ b/src/RCONServer.cpp @@ -78,8 +78,8 @@ protected: cRCONServer::cRCONServer(cServer & a_Server) : m_Server(a_Server), - m_ListenThread4(*this, cSocket::IPv4, "RCON IPv4"), - m_ListenThread6(*this, cSocket::IPv6, "RCON IPv6") + m_ListenThread4(*this, cSocket::IPv4, "RCON"), + m_ListenThread6(*this, cSocket::IPv6, "RCON") { } diff --git a/src/Server.cpp b/src/Server.cpp index bc9644804..10a354a36 100644 --- a/src/Server.cpp +++ b/src/Server.cpp @@ -105,8 +105,8 @@ void cServer::cTickThread::Execute(void) // cServer: cServer::cServer(void) : - m_ListenThreadIPv4(*this, cSocket::IPv4, "Client IPv4"), - m_ListenThreadIPv6(*this, cSocket::IPv6, "Client IPv6"), + m_ListenThreadIPv4(*this, cSocket::IPv4, "Client"), + m_ListenThreadIPv6(*this, cSocket::IPv6, "Client"), m_PlayerCount(0), m_PlayerCountDiff(0), m_ClientViewDistance(0), -- cgit v1.2.3 From 2df5e26d3b7f08ef7d120511705fa0b75a44783e Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 18 Jul 2014 09:57:34 +0200 Subject: Fixed spaces before commas. --- src/BiomeDef.cpp | 2 +- src/BlockEntities/ChestEntity.cpp | 4 ++-- src/ChunkMap.cpp | 4 ++-- src/Generating/FinishGen.cpp | 4 ++-- src/Generating/HeiGen.cpp | 4 ++-- src/Mobs/Monster.h | 6 +++--- src/Simulator/IncrementalRedstoneSimulator.cpp | 4 ++-- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/BiomeDef.cpp b/src/BiomeDef.cpp index 9852b3dd9..d680377e2 100644 --- a/src/BiomeDef.cpp +++ b/src/BiomeDef.cpp @@ -15,7 +15,7 @@ static struct { const char * m_String; } g_BiomeMap[] = { - {biOcean, "Ocean"} , + {biOcean, "Ocean"}, {biPlains, "Plains"}, {biDesert, "Desert"}, {biExtremeHills, "ExtremeHills"}, diff --git a/src/BlockEntities/ChestEntity.cpp b/src/BlockEntities/ChestEntity.cpp index 9f50365e9..21e1f6ba2 100644 --- a/src/BlockEntities/ChestEntity.cpp +++ b/src/BlockEntities/ChestEntity.cpp @@ -169,8 +169,8 @@ void cChestEntity::OpenNewWindow(void) if ( m_World->DoWithChestAt(m_PosX - 1, m_PosY, m_PosZ, OpenDbl) || m_World->DoWithChestAt(m_PosX + 1, m_PosY, m_PosZ, OpenDbl) || - m_World->DoWithChestAt(m_PosX , m_PosY, m_PosZ - 1, OpenDbl) || - m_World->DoWithChestAt(m_PosX , m_PosY, m_PosZ + 1, OpenDbl) + m_World->DoWithChestAt(m_PosX, m_PosY, m_PosZ - 1, OpenDbl) || + m_World->DoWithChestAt(m_PosX, m_PosY, m_PosZ + 1, OpenDbl) ) { // The double-chest window has been opened in the callback diff --git a/src/ChunkMap.cpp b/src/ChunkMap.cpp index 9f280f1c5..e91f77d27 100644 --- a/src/ChunkMap.cpp +++ b/src/ChunkMap.cpp @@ -2762,8 +2762,8 @@ cChunkPtr cChunkMap::cChunkLayer::GetChunk( int a_ChunkX, int a_ChunkY, int a_Ch { cChunk * neixm = (LocalX > 0) ? m_Chunks[Index - 1] : m_Parent->FindChunk(a_ChunkX - 1, a_ChunkZ); cChunk * neixp = (LocalX < LAYER_SIZE - 1) ? m_Chunks[Index + 1] : m_Parent->FindChunk(a_ChunkX + 1, a_ChunkZ); - cChunk * neizm = (LocalZ > 0) ? m_Chunks[Index - LAYER_SIZE] : m_Parent->FindChunk(a_ChunkX , a_ChunkZ - 1); - cChunk * neizp = (LocalZ < LAYER_SIZE - 1) ? m_Chunks[Index + LAYER_SIZE] : m_Parent->FindChunk(a_ChunkX , a_ChunkZ + 1); + cChunk * neizm = (LocalZ > 0) ? m_Chunks[Index - LAYER_SIZE] : m_Parent->FindChunk(a_ChunkX, a_ChunkZ - 1); + cChunk * neizp = (LocalZ < LAYER_SIZE - 1) ? m_Chunks[Index + LAYER_SIZE] : m_Parent->FindChunk(a_ChunkX, a_ChunkZ + 1); m_Chunks[Index] = new cChunk(a_ChunkX, 0, a_ChunkZ, m_Parent, m_Parent->GetWorld(), neixm, neixp, neizm, neizp, m_Pool); } return m_Chunks[Index]; diff --git a/src/Generating/FinishGen.cpp b/src/Generating/FinishGen.cpp index 13871bbd8..00a93023d 100644 --- a/src/Generating/FinishGen.cpp +++ b/src/Generating/FinishGen.cpp @@ -193,8 +193,8 @@ bool cFinishGenSprinkleFoliage::TryAddSugarcane(cChunkDesc & a_ChunkDesc, int a_ if ( !IsWater(a_ChunkDesc.GetBlockType(a_RelX - 1, a_RelY, a_RelZ)) && !IsWater(a_ChunkDesc.GetBlockType(a_RelX + 1, a_RelY, a_RelZ)) && - !IsWater(a_ChunkDesc.GetBlockType(a_RelX , a_RelY, a_RelZ - 1)) && - !IsWater(a_ChunkDesc.GetBlockType(a_RelX , a_RelY, a_RelZ + 1)) + !IsWater(a_ChunkDesc.GetBlockType(a_RelX, a_RelY, a_RelZ - 1)) && + !IsWater(a_ChunkDesc.GetBlockType(a_RelX, a_RelY, a_RelZ + 1)) ) { return false; diff --git a/src/Generating/HeiGen.cpp b/src/Generating/HeiGen.cpp index b02e06951..3df1a90ff 100644 --- a/src/Generating/HeiGen.cpp +++ b/src/Generating/HeiGen.cpp @@ -283,7 +283,7 @@ void cHeiGenClassic::GenHeightMap(int a_ChunkX, int a_ChunkZ, cChunkDef::HeightM { hei = 250; } - cChunkDef::SetHeight(a_HeightMap, x , z, hei); + cChunkDef::SetHeight(a_HeightMap, x, z, hei); } // for x } // for z } @@ -345,7 +345,7 @@ void cHeiGenMountains::GenHeightMap(int a_ChunkX, int a_ChunkZ, cChunkDef::Heigh { hei = 250; } - cChunkDef::SetHeight(a_HeightMap, x , z, hei); + cChunkDef::SetHeight(a_HeightMap, x, z, hei); } // for x } // for z } diff --git a/src/Mobs/Monster.h b/src/Mobs/Monster.h index 750040468..6e14e3b18 100644 --- a/src/Mobs/Monster.h +++ b/src/Mobs/Monster.h @@ -76,9 +76,9 @@ public: enum MPersonality{PASSIVE,AGGRESSIVE,COWARDLY} m_EMPersonality; /** Creates the mob object. - * If a_ConfigName is not empty, the configuration is loaded using GetMonsterConfig() - * a_MobType is the type of the mob (also used in the protocol ( http://wiki.vg/Entities#Mobs , 2012_12_22)) - * a_SoundHurt and a_SoundDeath are assigned into m_SoundHurt and m_SoundDeath, respectively + If a_ConfigName is not empty, the configuration is loaded using GetMonsterConfig() + a_MobType is the type of the mob (also used in the protocol ( http://wiki.vg/Entities#Mobs 2012_12_22)) + a_SoundHurt and a_SoundDeath are assigned into m_SoundHurt and m_SoundDeath, respectively */ cMonster(const AString & a_ConfigName, eType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height); diff --git a/src/Simulator/IncrementalRedstoneSimulator.cpp b/src/Simulator/IncrementalRedstoneSimulator.cpp index 8e5e40fb5..3dd6417dc 100644 --- a/src/Simulator/IncrementalRedstoneSimulator.cpp +++ b/src/Simulator/IncrementalRedstoneSimulator.cpp @@ -724,7 +724,7 @@ void cIncrementalRedstoneSimulator::HandleRedstoneRepeater(int a_RelBlockX, int X Axis ----> - Repeater directions, values from a cWorld::GetBlockMeta(a_RelBlockX , a_RelBlockY, a_RelBlockZ) lookup: + Repeater directions, values from a cWorld::GetBlockMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ) lookup: East (Right) (X+): 0x1 West (Left) (X-): 0x3 @@ -1723,7 +1723,7 @@ bool cIncrementalRedstoneSimulator::IsWirePowered(int a_RelBlockX, int a_RelBloc { continue; } - a_PowerLevel = std::max(itr->a_PowerLevel , a_PowerLevel); // Get the highest power level (a_PowerLevel is initialised already and there CAN be multiple levels for one block) + a_PowerLevel = std::max(itr->a_PowerLevel, a_PowerLevel); // Get the highest power level (a_PowerLevel is initialised already and there CAN be multiple levels for one block) } for (LinkedBlocksList::const_iterator itr = m_LinkedPoweredBlocks->begin(); itr != m_LinkedPoweredBlocks->end(); ++itr) // Check linked powered list -- cgit v1.2.3 From 204b59117225268a569fb68614bb59add4d53a03 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 18 Jul 2014 09:58:29 +0200 Subject: CheckBasicStyle: Proper spaces with commas. --- src/CheckBasicStyle.lua | 69 ++++++++++++++++++++++++++++++++++--------------- 1 file changed, 48 insertions(+), 21 deletions(-) diff --git a/src/CheckBasicStyle.lua b/src/CheckBasicStyle.lua index f9bb41975..6aad4125d 100644 --- a/src/CheckBasicStyle.lua +++ b/src/CheckBasicStyle.lua @@ -6,13 +6,16 @@ Checks that all source files (*.cpp, *.h) use the basic style requirements of th - Tabs for indentation, spaces for alignment - Trailing whitespace on non-empty lines - Two spaces between code and line-end comment ("//") - - (TODO) Spaces around +, -, (cannot check /, * or & due to their other usage - comment, ptr deref, address-of) + - Spaces after comma, not before (except in #define argument list) - (TODO) Spaces before *, /, & - - (TODO) Spaces after , - (TODO) Hex numbers with even digit length - (TODO) Hex numbers in lowercase - (TODO) Braces not on the end of line - (TODO) Line dividers (////...) exactly 80 slashes + - (TODO) Not using "* "-style doxy comments continuation lines + +Violations that cannot be checked easily: + - Spaces around "+" (there are things like "a++", "++a", "a += 1", "X+", "stack +1" and ascii-drawn tables) Reports all violations on stdout in a form that is readable by Visual Studio's parser, so that dblclicking the line brings the editor directly to the violation. @@ -85,6 +88,45 @@ end +--- Searches for the specified pattern, if found, reports it as a violation with the given message +local function ReportViolationIfFound(a_Line, a_FileName, a_LineNum, a_Pattern, a_Message) + local patStart, patEnd = a_Line:find(a_Pattern) + if not(patStart) then + return + end + ReportViolation(a_FileName, a_LineNum, a_Message .. "(" .. patStart .. " .. " .. patEnd .. ")") +end + + + + + +local g_ViolationPatterns = +{ + -- Check against indenting using spaces: + {"^\t* +", "Indenting with a space"}, + + -- Check against alignment using tabs: + {"[^%s]\t+[^%s]", "Aligning with a tab"}, + + -- Check against trailing whitespace: + {"[^%s]%s+\n", "Trailing whitespace"}, + + -- Check that all "//"-style comments have at least two spaces in front (unless alone on line): + {"[^%s] //", "Needs at least two spaces in front of a \"//\"-style comment"}, + + -- Check that all "//"-style comments have at least one spaces after: + {"%s//[^%s/*<]", "Needs a space after a \"//\"-style comment"}, + + -- Check that all commas have spaces after them and not in front of them: + {" ,", "Extra space before a \",\""}, + {"^\t*[^#].*,[^%s]", "Needs a space after a \",\""}, -- Anywhere except lines starting with "#" - avoid #define params +} + + + + + --- Processes one file local function ProcessFile(a_FileName) assert(type(a_FileName) == "string") @@ -113,26 +155,11 @@ local function ProcessFile(a_FileName) all:gsub("\r\n", "\n") -- normalize CRLF into LF-only string.gsub(all .. "\n", "[^\n]*\n", -- Iterate over each line, while preserving empty lines function(a_Line) - -- Check against indenting using spaces: - if (a_Line:find("^\t* +")) then -- Find any number of tabs at the start of line (incl 0), followed by a space - ReportViolation(a_FileName, lineCounter, "Indenting with a space") - end - -- Check against alignment using tabs: - if (a_Line:find("[^%s]\t+[^%s]")) then -- Find any number of tabs after non-whitespace followed by non-whitespace - ReportViolation(a_FileName, lineCounter, "Aligning with a tab") - end - -- Check against trailing whitespace: - if (a_Line:find("[^%s]%s+\n")) then -- Find any whitespace after non-whitespace at the end of line - ReportViolation(a_FileName, lineCounter, "Trailing whitespace") - end - -- Check that all "//"-style comments have at least two spaces in front (unless alone on line): - if (a_Line:find("[^%s] //")) then - ReportViolation(a_FileName, lineCounter, "Needs at least two spaces in front of a \"//\"-style comment") - end - -- Check that all "//"-style comments have at least one spaces after: - if (a_Line:find("%s//[^%s/*<]")) then - ReportViolation(a_FileName, lineCounter, "Needs a space after a \"//\"-style comment") + -- Check against each violation pattern: + for _, pat in ipairs(g_ViolationPatterns) do + ReportViolationIfFound(a_Line, a_FileName, lineCounter, pat[1], pat[2]) end + lineCounter = lineCounter + 1 end ) -- cgit v1.2.3 From 9529a4255999efc0970d82385ef1ff07c62a7a02 Mon Sep 17 00:00:00 2001 From: archshift Date: Fri, 18 Jul 2014 01:56:26 -0700 Subject: Fixed creative players not being able to drink Fixes #1215 --- src/ClientHandle.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index 97466c331..58247a836 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -1209,11 +1209,12 @@ void cClientHandle::HandleRightClick(int a_BlockX, int a_BlockY, int a_BlockZ, e { HandlePlaceBlock(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, *ItemHandler); } - else if ((ItemHandler->IsFood() || ItemHandler->IsDrinkable(EquippedDamage)) && !m_Player->IsGameModeCreative()) + else if ((ItemHandler->IsFood() || ItemHandler->IsDrinkable(EquippedDamage))) { - if (m_Player->IsSatiated() && !ItemHandler->IsDrinkable(EquippedDamage)) + if ((m_Player->IsSatiated() || m_Player->IsGameModeCreative()) && + ItemHandler->IsFood()) { - // The player is satiated, they cannot eat + // The player is satiated or in creative, and trying to eat return; } m_Player->StartEating(); -- cgit v1.2.3 From 38aeaa64eda9afc645f3d864316cd02d3990e73a Mon Sep 17 00:00:00 2001 From: archshift Date: Fri, 18 Jul 2014 02:02:28 -0700 Subject: MCServer supports Minecraft v1.7.10 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b0f1cde35..85ae459a0 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ MCServer is a Minecraft server that is written in C++ and designed to be efficie MCServer can run on PCs, Macs, and *nix. This includes android phones and tablets as well as Raspberry Pis. -We currently support the protocol from Minecraft 1.2 all the way up to Minecraft 1.7.9. +We currently support the protocol from Minecraft 1.2 all the way up to Minecraft 1.7.10. Installation ------------ -- cgit v1.2.3 From f1be1eb6743700515de3a522898ba99680cf24c0 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Fri, 18 Jul 2014 10:47:00 +0100 Subject: Monster fixes * Fixes #1203 * Fixes #627 --- lib/polarssl | 2 +- src/BlockInfo.cpp | 4 ---- src/Mobs/Monster.cpp | 27 +-------------------------- src/Mobs/Monster.h | 1 - src/Mobs/Skeleton.cpp | 2 +- src/Mobs/Skeleton.h | 2 +- src/Mobs/Zombie.cpp | 2 +- src/Mobs/Zombie.h | 2 +- 8 files changed, 6 insertions(+), 36 deletions(-) diff --git a/lib/polarssl b/lib/polarssl index 784b04ff9..1ed82759c 160000 --- a/lib/polarssl +++ b/lib/polarssl @@ -1 +1 @@ -Subproject commit 784b04ff9afd5faeaeb15c3fa159ff98adf55182 +Subproject commit 1ed82759c68f92c4acc7e3f33b850cf9f01c8aba diff --git a/src/BlockInfo.cpp b/src/BlockInfo.cpp index b4b98a2f0..97e89359f 100644 --- a/src/BlockInfo.cpp +++ b/src/BlockInfo.cpp @@ -496,9 +496,6 @@ void cBlockInfo::Initialize(cBlockInfoArray & a_Info) a_Info[E_BLOCK_CROPS ].m_IsSolid = false; a_Info[E_BLOCK_DANDELION ].m_IsSolid = false; a_Info[E_BLOCK_DETECTOR_RAIL ].m_IsSolid = false; - a_Info[E_BLOCK_END_PORTAL ].m_IsSolid = false; - a_Info[E_BLOCK_FENCE ].m_IsSolid = false; - a_Info[E_BLOCK_FENCE_GATE ].m_IsSolid = false; a_Info[E_BLOCK_FIRE ].m_IsSolid = false; a_Info[E_BLOCK_FLOWER ].m_IsSolid = false; a_Info[E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE].m_IsSolid = false; @@ -530,7 +527,6 @@ void cBlockInfo::Initialize(cBlockInfoArray & a_Info) a_Info[E_BLOCK_WATER ].m_IsSolid = false; a_Info[E_BLOCK_WOODEN_BUTTON ].m_IsSolid = false; a_Info[E_BLOCK_WOODEN_PRESSURE_PLATE].m_IsSolid = false; - a_Info[E_BLOCK_WOODEN_SLAB ].m_IsSolid = false; // Blocks that fully occupy their voxel - used as a guide for torch placeable blocks, amongst other things: diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp index ba901df4e..1369746df 100644 --- a/src/Mobs/Monster.cpp +++ b/src/Mobs/Monster.cpp @@ -115,8 +115,6 @@ void cMonster::TickPathFinding() const int PosY = POSY_TOINT; const int PosZ = POSZ_TOINT; - m_FinalDestination.y = (double)FindFirstNonAirBlockPosition(m_FinalDestination.x, m_FinalDestination.z); - std::vector m_PotentialCoordinates; m_TraversedCoordinates.push_back(Vector3i(PosX, PosY, PosZ)); @@ -201,19 +199,6 @@ void cMonster::TickPathFinding() -void cMonster::MoveToPosition(const Vector3f & a_Position) -{ - FinishPathFinding(); - - m_FinalDestination = a_Position; - m_bMovingToDestination = true; - TickPathFinding(); -} - - - - - void cMonster::MoveToPosition(const Vector3d & a_Position) { FinishPathFinding(); @@ -227,15 +212,7 @@ void cMonster::MoveToPosition(const Vector3d & a_Position) bool cMonster::IsCoordinateInTraversedList(Vector3i a_Coords) { - for (std::vector::const_iterator itr = m_TraversedCoordinates.begin(); itr != m_TraversedCoordinates.end(); ++itr) - { - if (itr->Equals(a_Coords)) - { - return true; - } - } - - return false; + return (std::find(m_TraversedCoordinates.begin(), m_TraversedCoordinates.end(), a_Coords) != m_TraversedCoordinates.end()); } @@ -296,8 +273,6 @@ void cMonster::Tick(float a_Dt, cChunk & a_Chunk) { if (m_bOnGround) { - m_Destination.y = FindFirstNonAirBlockPosition(m_Destination.x, m_Destination.z); - if (DoesPosYRequireJump((int)floor(m_Destination.y))) { m_bOnGround = false; diff --git a/src/Mobs/Monster.h b/src/Mobs/Monster.h index 6e14e3b18..4af7cf4f1 100644 --- a/src/Mobs/Monster.h +++ b/src/Mobs/Monster.h @@ -92,7 +92,6 @@ public: virtual void KilledBy(TakeDamageInfo & a_TDI) override; - virtual void MoveToPosition(const Vector3f & a_Position); virtual void MoveToPosition(const Vector3d & a_Position); // tolua_export virtual bool ReachedDestination(void); diff --git a/src/Mobs/Skeleton.cpp b/src/Mobs/Skeleton.cpp index 2f57bedeb..cd707f4bb 100644 --- a/src/Mobs/Skeleton.cpp +++ b/src/Mobs/Skeleton.cpp @@ -48,7 +48,7 @@ void cSkeleton::GetDrops(cItems & a_Drops, cEntity * a_Killer) -void cSkeleton::MoveToPosition(const Vector3f & a_Position) +void cSkeleton::MoveToPosition(const Vector3d & a_Position) { // If the destination is sufficiently skylight challenged AND the skeleton isn't on fire then block the movement if ( diff --git a/src/Mobs/Skeleton.h b/src/Mobs/Skeleton.h index 229462d63..efb670c83 100644 --- a/src/Mobs/Skeleton.h +++ b/src/Mobs/Skeleton.h @@ -18,7 +18,7 @@ public: CLASS_PROTODEF(cSkeleton); virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; - virtual void MoveToPosition(const Vector3f & a_Position) override; + virtual void MoveToPosition(const Vector3d & a_Position) override; virtual void Attack(float a_Dt) override; virtual void SpawnOn(cClientHandle & a_ClientHandle) override; diff --git a/src/Mobs/Zombie.cpp b/src/Mobs/Zombie.cpp index 725790ed9..30225c32d 100644 --- a/src/Mobs/Zombie.cpp +++ b/src/Mobs/Zombie.cpp @@ -42,7 +42,7 @@ void cZombie::GetDrops(cItems & a_Drops, cEntity * a_Killer) -void cZombie::MoveToPosition(const Vector3f & a_Position) +void cZombie::MoveToPosition(const Vector3d & a_Position) { // If the destination is sufficiently skylight challenged AND the skeleton isn't on fire then block the movement if ( diff --git a/src/Mobs/Zombie.h b/src/Mobs/Zombie.h index 1ba368f9c..c56409570 100644 --- a/src/Mobs/Zombie.h +++ b/src/Mobs/Zombie.h @@ -17,7 +17,7 @@ public: CLASS_PROTODEF(cZombie); virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; - virtual void MoveToPosition(const Vector3f & a_Position) override; + virtual void MoveToPosition(const Vector3d & a_Position) override; bool IsVillagerZombie(void) const {return m_IsVillagerZombie; } bool IsConverting (void) const {return m_IsConverting; } -- cgit v1.2.3 From 509d3d3b62c2dc5b328cf122c0fc5f0595b73721 Mon Sep 17 00:00:00 2001 From: Howaner Date: Fri, 18 Jul 2014 16:55:28 +0200 Subject: Slime sizes are 1, 2 or 4 and not 1, 2 or 3. --- src/Mobs/Monster.cpp | 2 +- src/Mobs/Slime.cpp | 4 ++-- src/Mobs/Slime.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp index e36634c73..2a796e8eb 100644 --- a/src/Mobs/Monster.cpp +++ b/src/Mobs/Monster.cpp @@ -867,7 +867,7 @@ cMonster * cMonster::NewMonsterFromType(cMonster::eType a_MobType) } case mtSlime: { - toReturn = new cSlime(Random.NextInt(2) + 1); + toReturn = new cSlime(1 << Random.NextInt(3)); break; } case mtSkeleton: diff --git a/src/Mobs/Slime.cpp b/src/Mobs/Slime.cpp index 4e12fca51..4b123df12 100644 --- a/src/Mobs/Slime.cpp +++ b/src/Mobs/Slime.cpp @@ -9,7 +9,6 @@ -/// Creates a slime of the specified size; size is 1 .. 3, with 1 being the smallest cSlime::cSlime(int a_Size) : super("Slime", mtSlime, @@ -36,7 +35,8 @@ void cSlime::GetDrops(cItems & a_Drops, cEntity * a_Killer) LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchLooting); } - if (GetSize() == 1) + // Only slimes with the size 1 can drop slimeballs. + if (m_Size == 1) { AddRandomDropItem(a_Drops, 0, 2 + LootingLevel, E_ITEM_SLIMEBALL); } diff --git a/src/Mobs/Slime.h b/src/Mobs/Slime.h index 87c5a8e5e..b0e2f627c 100644 --- a/src/Mobs/Slime.h +++ b/src/Mobs/Slime.h @@ -13,7 +13,7 @@ class cSlime : typedef cAggressiveMonster super; public: - /** Creates a slime of the specified size; size is 1 .. 3, with 1 being the smallest */ + /** Creates a slime of the specified size; size can be 1, 2 or 4, with 1 is the smallest and 4 is the tallest. */ cSlime(int a_Size); CLASS_PROTODEF(cSlime); -- cgit v1.2.3 From 44c944716b4fd933547d76d09bccce72e8959abb Mon Sep 17 00:00:00 2001 From: Howaner Date: Fri, 18 Jul 2014 17:04:01 +0200 Subject: Removed cBlockSignPostHandler descend. --- src/Blocks/BlockWallSign.h | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/src/Blocks/BlockWallSign.h b/src/Blocks/BlockWallSign.h index 037a7bd19..b0f4015b6 100644 --- a/src/Blocks/BlockWallSign.h +++ b/src/Blocks/BlockWallSign.h @@ -1,6 +1,8 @@ #pragma once +#include "BlockHandler.h" +#include "../Entities/Player.h" #include "Chunk.h" @@ -8,15 +10,39 @@ class cBlockWallSignHandler : - public cBlockSignPostHandler + public cBlockHandler { + typedef cBlockHandler super; public: cBlockWallSignHandler(BLOCKTYPE a_BlockType) - : cBlockSignPostHandler(a_BlockType) + : cBlockHandler(a_BlockType) { } + virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override + { + a_Pickups.push_back(cItem(E_ITEM_SIGN, 1, 0)); + } + + + virtual const char * GetStepSound(void) override + { + return "step.wood"; + } + + + 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 + { + a_Player->GetClientHandle()->SendEditSign(a_BlockX, a_BlockY, a_BlockZ); + } + + virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override { int BlockX = (a_Chunk.GetPosX() * cChunkDef::Width) + a_RelX; -- cgit v1.2.3 From 23037ce7ec1f7ff290bd18f30d5fb25b91b5e61c Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 18 Jul 2014 22:41:48 +0200 Subject: Normalized code style for both sign handlers. --- src/Blocks/BlockSignPost.h | 19 +++++++++++-------- src/Blocks/BlockWallSign.h | 17 +++++++++-------- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/src/Blocks/BlockSignPost.h b/src/Blocks/BlockSignPost.h index d5b0c0b5f..ee65d099a 100644 --- a/src/Blocks/BlockSignPost.h +++ b/src/Blocks/BlockSignPost.h @@ -12,9 +12,11 @@ class cBlockSignPostHandler : public cBlockHandler { + typedef cBlockHandler super; + public: - cBlockSignPostHandler(BLOCKTYPE a_BlockType) - : cBlockHandler(a_BlockType) + cBlockSignPostHandler(BLOCKTYPE a_BlockType) : + super(a_BlockType) { } @@ -78,22 +80,23 @@ public: return (a_Meta + 12) & 0x0f; } + virtual NIBBLETYPE MetaMirrorXY(NIBBLETYPE a_Meta) override { - // Mirrors signs over the XY plane (North-South Mirroring) + // Mirrors signs over the XY plane (North-South Mirroring) - // There are 16 meta values which correspond to different directions. - // These values are equated to angles on a circle; 0x08 = 180 degrees. + // There are 16 meta values which correspond to different directions. + // These values are equated to angles on a circle; 0x08 = 180 degrees. return (a_Meta < 0x08) ? (0x08 + a_Meta) : (0x08 - a_Meta); } virtual NIBBLETYPE MetaMirrorYZ(NIBBLETYPE a_Meta) override { - // Mirrors signs over the YZ plane (East-West Mirroring) + // Mirrors signs over the YZ plane (East-West Mirroring) - // There are 16 meta values which correspond to different directions. - // These values are equated to angles on a circle; 0x10 = 360 degrees. + // There are 16 meta values which correspond to different directions. + // These values are equated to angles on a circle; 0x10 = 360 degrees. return 0x10 - a_Meta; } } ; diff --git a/src/Blocks/BlockWallSign.h b/src/Blocks/BlockWallSign.h index b0f4015b6..e837b315e 100644 --- a/src/Blocks/BlockWallSign.h +++ b/src/Blocks/BlockWallSign.h @@ -13,9 +13,10 @@ class cBlockWallSignHandler : public cBlockHandler { typedef cBlockHandler super; + public: - cBlockWallSignHandler(BLOCKTYPE a_BlockType) - : cBlockHandler(a_BlockType) + cBlockWallSignHandler(BLOCKTYPE a_BlockType) : + super(a_BlockType) { } @@ -53,15 +54,15 @@ public: } - virtual void GetBlockCoordsBehindTheSign(NIBBLETYPE a_BlockMeta, int & a_BlockX, int & a_BlockZ) + static void GetBlockCoordsBehindTheSign(NIBBLETYPE a_BlockMeta, int & a_BlockX, int & a_BlockZ) { switch (a_BlockMeta) { - case 2: a_BlockZ++; break; - case 3: a_BlockZ--; break; - case 4: a_BlockX++; break; - case 5: a_BlockX--; break; - default: break; + case 2: a_BlockZ++; break; + case 3: a_BlockZ--; break; + case 4: a_BlockX++; break; + case 5: a_BlockX--; break; + default: break; } } -- cgit v1.2.3 From 51b91befbd26b630cd2cecaec081edd03edfb5f3 Mon Sep 17 00:00:00 2001 From: Howaner Date: Fri, 18 Jul 2014 23:11:59 +0200 Subject: Added RemoveItem() function to the player inventory. --- MCServer/Plugins/Debuggers/Debuggers.lua | 40 ++++++++++++++++++++++++++++---- src/Inventory.cpp | 18 ++++++++++++++ src/Inventory.h | 3 +++ src/ItemGrid.cpp | 33 ++++++++++++++++++++++++++ src/ItemGrid.h | 3 +++ 5 files changed, 93 insertions(+), 4 deletions(-) diff --git a/MCServer/Plugins/Debuggers/Debuggers.lua b/MCServer/Plugins/Debuggers/Debuggers.lua index 918204deb..95b36e854 100644 --- a/MCServer/Plugins/Debuggers/Debuggers.lua +++ b/MCServer/Plugins/Debuggers/Debuggers.lua @@ -60,9 +60,10 @@ function Initialize(Plugin) PM:BindCommand("/ff", "debuggers", HandleFurnaceFuel, "- Shows how long the currently held item would burn in a furnace"); PM:BindCommand("/sched", "debuggers", HandleSched, "- Schedules a simple countdown using cWorld:ScheduleTask()"); PM:BindCommand("/cs", "debuggers", HandleChunkStay, "- Tests the ChunkStay Lua integration for the specified chunk coords"); - PM:BindCommand("/compo", "debuggers", HandleCompo, "- Tests the cCompositeChat bindings") - PM:BindCommand("/sb", "debuggers", HandleSetBiome, "- Sets the biome around you to the specified one") - PM:BindCommand("/wesel", "debuggers", HandleWESel, "- Expands the current WE selection by 1 block in X/Z") + PM:BindCommand("/compo", "debuggers", HandleCompo, "- Tests the cCompositeChat bindings"); + PM:BindCommand("/sb", "debuggers", HandleSetBiome, "- Sets the biome around you to the specified one"); + PM:BindCommand("/wesel", "debuggers", HandleWESel, "- Expands the current WE selection by 1 block in X/Z"); + PM:BindCommand("/rmitem", "debuggers", HandleRMItem, "- Remove the specified item from the inventory."); Plugin:AddWebTab("Debuggers", HandleRequest_Debuggers) Plugin:AddWebTab("StressTest", HandleRequest_StressTest) @@ -533,7 +534,7 @@ function OnTakeDamage(Receiver, TDI) -- Receiver is cPawn -- TDI is TakeDamageInfo - LOG(Receiver:GetClass() .. " was dealt " .. DamageTypeToString(TDI.DamageType) .. " damage: Raw " .. TDI.RawDamage .. ", Final " .. TDI.FinalDamage .. " (" .. (TDI.RawDamage - TDI.FinalDamage) .. " covered by armor)"); + -- LOG(Receiver:GetClass() .. " was dealt " .. DamageTypeToString(TDI.DamageType) .. " damage: Raw " .. TDI.RawDamage .. ", Final " .. TDI.FinalDamage .. " (" .. (TDI.RawDamage - TDI.FinalDamage) .. " covered by armor)"); return false; end @@ -1105,6 +1106,37 @@ end +function HandleRMItem(a_Split, a_Player) + if ((#a_Split ~= 2) and (#a_Split ~= 3)) then + a_Player:SendMessage("Usage: /rmitem [Count]") + return true + end + + local Item = cItem() + if (not StringToItem(a_Split[2], Item)) then + a_Player:SendMessageFailure(a_Split[2] .. " isn't a valid item") + return true + end + + if (#a_Split == 3) then + local Count = tonumber(a_Split[3]) + if (Count == nil) then + a_Player:SendMessageFailure(a_Split[3] .. " isn't a valid number") + return true + end + + Item.m_ItemCount = Count + end + + local RemovedItems = a_Player:GetInventory():RemoveItem(Item) + a_Player:SendMessageSuccess("Removed " .. RemovedItems .. " Items!") + return true +end + + + + + function HandleRequest_Debuggers(a_Request) local FolderContents = cFile:GetFolderContents("./"); return "

The following objects have been returned by cFile:GetFolderContents():

  • " .. table.concat(FolderContents, "
  • ") .. "

"; diff --git a/src/Inventory.cpp b/src/Inventory.cpp index 38d3c886d..5f7c24b60 100644 --- a/src/Inventory.cpp +++ b/src/Inventory.cpp @@ -151,6 +151,24 @@ int cInventory::AddItems(cItems & a_ItemStackList, bool a_AllowNewStacks, bool a +int cInventory::RemoveItem(const cItem & a_ItemStack) +{ + int RemovedItems = m_HotbarSlots.RemoveItem(a_ItemStack); + + if (RemovedItems < a_ItemStack.m_ItemCount) + { + cItem Temp(a_ItemStack); + Temp.m_ItemCount -= RemovedItems; + RemovedItems += m_InventorySlots.RemoveItem(Temp); + } + + return RemovedItems; +} + + + + + bool cInventory::RemoveOneEquippedItem(void) { if (m_HotbarSlots.GetSlot(m_EquippedSlotNum).IsEmpty()) diff --git a/src/Inventory.h b/src/Inventory.h index e25fc4a8a..6e32536b3 100644 --- a/src/Inventory.h +++ b/src/Inventory.h @@ -86,6 +86,9 @@ public: */ int AddItems(cItems & a_ItemStackList, bool a_AllowNewStacks, bool a_tryToFillEquippedFirst); + /** Remove the specified item with the specified amount from the inventory. Returns the amount from the items were was removed. */ + int RemoveItem(const cItem & a_ItemStack); + /** Removes one item out of the currently equipped item stack, returns true if successful, false if empty-handed */ bool RemoveOneEquippedItem(void); diff --git a/src/ItemGrid.cpp b/src/ItemGrid.cpp index cd36b1f2a..38829cbf8 100644 --- a/src/ItemGrid.cpp +++ b/src/ItemGrid.cpp @@ -345,6 +345,39 @@ int cItemGrid::AddItems(cItems & a_ItemStackList, bool a_AllowNewStacks, int a_P +int cItemGrid::RemoveItem(const cItem & a_ItemStack) +{ + int NumLeft = a_ItemStack.m_ItemCount; + + for (int i = 0; i < m_NumSlots; i++) + { + if (NumLeft <= 0) + { + break; + } + + if (m_Slots[i].IsEqual(a_ItemStack)) + { + int NumToRemove = std::min(NumLeft, (int)m_Slots[i].m_ItemCount); + NumLeft -= NumToRemove; + m_Slots[i].m_ItemCount -= NumToRemove; + + if (m_Slots[i].m_ItemCount <= 0) + { + m_Slots[i].Empty(); + } + + TriggerListeners(i); + } + } + + return (a_ItemStack.m_ItemCount - NumLeft); +} + + + + + int cItemGrid::ChangeSlotCount(int a_SlotNum, int a_AddToCount) { if ((a_SlotNum < 0) || (a_SlotNum >= m_NumSlots)) diff --git a/src/ItemGrid.h b/src/ItemGrid.h index c34d5e9e2..6731b0065 100644 --- a/src/ItemGrid.h +++ b/src/ItemGrid.h @@ -96,6 +96,9 @@ public: Returns the total number of items that fit. */ int AddItems(cItems & a_ItemStackList, bool a_AllowNewStacks = true, int a_PrioritarySlot = -1); + + /** Remove the specified item with the specified amount from the inventory. Returns the amount from the items were was removed. */ + int RemoveItem(const cItem & a_ItemStack); /** Adds (or subtracts, if a_AddToCount is negative) to the count of items in the specified slot. If the slot is empty, ignores the call. -- cgit v1.2.3 From 19d012c96ec13498d97d8e43136cc09eca3dca2e Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 18 Jul 2014 23:20:42 +0200 Subject: Fixed slime-related comments. --- src/Mobs/Monster.cpp | 4 ++-- src/Mobs/Slime.cpp | 4 ++-- src/Mobs/Slime.h | 7 ++++++- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp index 2a796e8eb..19851e064 100644 --- a/src/Mobs/Monster.cpp +++ b/src/Mobs/Monster.cpp @@ -867,13 +867,13 @@ cMonster * cMonster::NewMonsterFromType(cMonster::eType a_MobType) } case mtSlime: { - toReturn = new cSlime(1 << Random.NextInt(3)); + toReturn = new cSlime(1 << Random.NextInt(3)); // Size 1, 2 or 4 break; } case mtSkeleton: { // TODO: Actual detection of spawning in Nether - toReturn = new cSkeleton(Random.NextInt(1) == 0 ? false : true); + toReturn = new cSkeleton((Random.NextInt(1) == 0) ? false : true); break; } case mtVillager: diff --git a/src/Mobs/Slime.cpp b/src/Mobs/Slime.cpp index 4b123df12..b709ec664 100644 --- a/src/Mobs/Slime.cpp +++ b/src/Mobs/Slime.cpp @@ -48,9 +48,9 @@ void cSlime::GetDrops(cItems & a_Drops, cEntity * a_Killer) void cSlime::Attack(float a_Dt) { - if (m_Size != 1) + if (m_Size > 1) { - // Only slimes with the size 2 and 3 attacks a player. + // Only slimes larger than size 1 attack a player. super::Attack(a_Dt); } } diff --git a/src/Mobs/Slime.h b/src/Mobs/Slime.h index b0e2f627c..15ae113dc 100644 --- a/src/Mobs/Slime.h +++ b/src/Mobs/Slime.h @@ -18,16 +18,21 @@ public: CLASS_PROTODEF(cSlime); + // cAggressiveMonster overrides: virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; virtual void Attack(float a_Dt) override; virtual void KilledBy(TakeDamageInfo & a_TDI) override; int GetSize(void) const { return m_Size; } + + /** Returns the text describing the slime's size, as used by the client's resource subsystem for sounds. + Returns either "big" or "small". */ const AString GetSizeName(int a_Size) const; protected: - /** Size of the slime, 1 .. 3, with 1 being the smallest */ + /** Size of the slime, with 1 being the smallest. + Vanilla uses sizes 1, 2 and 4 only. */ int m_Size; } ; -- cgit v1.2.3 From 13311c700ffbd94f28fe38654bda4bf026d2a8ce Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 18 Jul 2014 23:47:46 +0200 Subject: Clarified RemoveItem()'s comments. --- src/Inventory.h | 3 ++- src/ItemGrid.h | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Inventory.h b/src/Inventory.h index 6e32536b3..5175afd14 100644 --- a/src/Inventory.h +++ b/src/Inventory.h @@ -86,7 +86,8 @@ public: */ int AddItems(cItems & a_ItemStackList, bool a_AllowNewStacks, bool a_tryToFillEquippedFirst); - /** Remove the specified item with the specified amount from the inventory. Returns the amount from the items were was removed. */ + /** Removes the specified item from the inventory, as many as possible, up to a_ItemStack.m_ItemCount. + Returns the number of items that were removed. */ int RemoveItem(const cItem & a_ItemStack); /** Removes one item out of the currently equipped item stack, returns true if successful, false if empty-handed */ diff --git a/src/ItemGrid.h b/src/ItemGrid.h index 6731b0065..8d6544792 100644 --- a/src/ItemGrid.h +++ b/src/ItemGrid.h @@ -97,7 +97,8 @@ public: */ int AddItems(cItems & a_ItemStackList, bool a_AllowNewStacks = true, int a_PrioritarySlot = -1); - /** Remove the specified item with the specified amount from the inventory. Returns the amount from the items were was removed. */ + /** Removes the specified item from the grid, as many as possible, up to a_ItemStack.m_ItemCount. + Returns the number of items that were removed. */ int RemoveItem(const cItem & a_ItemStack); /** Adds (or subtracts, if a_AddToCount is negative) to the count of items in the specified slot. -- cgit v1.2.3 From abe8a6bd4588892f27f779fd92beb941853c5583 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 18 Jul 2014 23:48:06 +0200 Subject: APIDump: Documented RemoveItem(). --- MCServer/Plugins/APIDump/APIDesc.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 0e626c580..e65da1d16 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -1155,6 +1155,7 @@ These ItemGrids are available in the API and can be manipulated by the plugins, HasItems = { Params = "{{cItem|cItem}}", Return = "bool", Notes = "Returns true if there are at least as many items of the specified type as in the parameter" }, HowManyCanFit = { Params = "{{cItem|cItem}}", Return = "number", Notes = "Returns the number of the specified items that can fit in the storage, including empty slots" }, HowManyItems = { Params = "{{cItem|cItem}}", Return = "number", Notes = "Returns the number of the specified items that are currently stored" }, + RemoveItem = { Params = "{{cItem}}", Return = "number", Notes = "Removes the specified item from the inventory, as many as possible, up to the item's m_ItemCount. Returns the number of items that were removed." }, RemoveOneEquippedItem = { Params = "", Return = "", Notes = "Removes one item from the hotbar's currently selected slot" }, SetArmorSlot = { Params = "ArmorSlotNum, {{cItem|cItem}}", Return = "", Notes = "Sets the specified armor slot contents" }, SetEquippedSlotNum = { Params = "EquippedSlotNum", Return = "", Notes = "Sets the currently selected hotbar slot number" }, @@ -1384,6 +1385,7 @@ local Item5 = cItem(E_ITEM_DIAMOND_CHESTPLATE, 1, 0, "thorns=1;unbreaking=3"); { Params = "SlotNum", Return = "bool", Notes = "Returns true if the specified slot is empty, or an invalid slot is specified" }, { Params = "X, Y", Return = "bool", Notes = "Returns true if the specified slot is empty, or an invalid slot is specified" }, }, + RemoveItem = { Params = "{{cItem}}", Return = "number", Notes = "Removes the specified item from the grid, as many as possible, up to the item's m_ItemCount. Returns the number of items that were removed." }, RemoveOneItem = { { Params = "SlotNum", Return = "{{cItem|cItem}}", Notes = "Removes one item from the stack in the specified slot and returns it as a single cItem. Empty slots are skipped and an empty item is returned" }, -- cgit v1.2.3 From 0346ab15adaf73e4d7c4ee4cfb175d40e721adfe Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 18 Jul 2014 23:51:15 +0200 Subject: Debuggers: Optimized and commented the /rmitem handler. --- MCServer/Plugins/Debuggers/Debuggers.lua | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/MCServer/Plugins/Debuggers/Debuggers.lua b/MCServer/Plugins/Debuggers/Debuggers.lua index 95b36e854..b402c1867 100644 --- a/MCServer/Plugins/Debuggers/Debuggers.lua +++ b/MCServer/Plugins/Debuggers/Debuggers.lua @@ -1107,18 +1107,21 @@ end function HandleRMItem(a_Split, a_Player) - if ((#a_Split ~= 2) and (#a_Split ~= 3)) then + -- Check params: + if (a_Split[2] == nil) then a_Player:SendMessage("Usage: /rmitem [Count]") return true end + -- Parse the item type: local Item = cItem() if (not StringToItem(a_Split[2], Item)) then a_Player:SendMessageFailure(a_Split[2] .. " isn't a valid item") return true end - if (#a_Split == 3) then + -- Parse the optional item count + if (a_Split[3] ~= nil) then local Count = tonumber(a_Split[3]) if (Count == nil) then a_Player:SendMessageFailure(a_Split[3] .. " isn't a valid number") @@ -1128,8 +1131,9 @@ function HandleRMItem(a_Split, a_Player) Item.m_ItemCount = Count end - local RemovedItems = a_Player:GetInventory():RemoveItem(Item) - a_Player:SendMessageSuccess("Removed " .. RemovedItems .. " Items!") + -- Remove the item: + local NumRemovedItems = a_Player:GetInventory():RemoveItem(Item) + a_Player:SendMessageSuccess("Removed " .. NumRemovedItems .. " Items!") return true end -- cgit v1.2.3 From 2f811fc6a2cf2ddacdcb443049a44ad6481f135a Mon Sep 17 00:00:00 2001 From: archshift Date: Thu, 17 Jul 2014 23:55:34 -0700 Subject: Mobs/CMakeLists.txt: Replaced glob with list of files --- src/Mobs/CMakeLists.txt | 74 +++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 69 insertions(+), 5 deletions(-) diff --git a/src/Mobs/CMakeLists.txt b/src/Mobs/CMakeLists.txt index 53c265803..d73a7aafd 100644 --- a/src/Mobs/CMakeLists.txt +++ b/src/Mobs/CMakeLists.txt @@ -4,9 +4,73 @@ project (MCServer) include_directories ("${PROJECT_SOURCE_DIR}/../") -file(GLOB SOURCE - "*.cpp" - "*.h" -) +SET (SRCS + AggressiveMonster.cpp + Bat.cpp + Blaze.cpp + CaveSpider.cpp + Chicken.cpp + Cow.cpp + Creeper.cpp + EnderDragon.cpp + Enderman.cpp + Ghast.cpp + Giant.cpp + Horse.cpp + IronGolem.cpp + MagmaCube.cpp + Monster.cpp + Mooshroom.cpp + PassiveAggressiveMonster.cpp + PassiveMonster.cpp + Pig.cpp + Sheep.cpp + Skeleton.cpp + Slime.cpp + SnowGolem.cpp + Spider.cpp + Squid.cpp + Villager.cpp + Witch.cpp + Wither.cpp + Wolf.cpp + Zombie.cpp + ZombiePigman.cpp) + +SET (HDRS + AggressiveMonster.h + Bat.h + Blaze.h + CaveSpider.h + Chicken.h + Cow.h + Creeper.h + EnderDragon.h + Enderman.h + Ghast.h + Giant.h + Horse.h + IncludeAllMonsters.h + IronGolem.h + MagmaCube.h + Monster.h + Mooshroom.h + Ocelot.h + PassiveAggressiveMonster.h + PassiveMonster.h + Pig.h + Sheep.h + Silverfish.h + Skeleton.h + Slime.h + SnowGolem.h + Spider.h + Squid.h + Villager.h + Witch.h + Wither.h + Wolf.h + Zombie.h + ZombiePigman.h) -add_library(Mobs ${SOURCE}) +add_library(Mobs ${SRCS} ${HDRS}) -- cgit v1.2.3 From 1d8e3e2bb8ca66e83b395e0131d4e5ededb385d0 Mon Sep 17 00:00:00 2001 From: archshift Date: Thu, 17 Jul 2014 23:57:35 -0700 Subject: Entities/CMakeLists.txt: Replaced glob with list of files --- src/Entities/CMakeLists.txt | 61 +++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 56 insertions(+), 5 deletions(-) diff --git a/src/Entities/CMakeLists.txt b/src/Entities/CMakeLists.txt index 205cb2cca..64752d13c 100644 --- a/src/Entities/CMakeLists.txt +++ b/src/Entities/CMakeLists.txt @@ -4,11 +4,62 @@ project (MCServer) include_directories ("${PROJECT_SOURCE_DIR}/../") -file(GLOB SOURCE - "*.cpp" - "*.h" -) +SET (SRCS + ArrowEntity.cpp + Boat.cpp + EnderCrystal.cpp + Entity.cpp + EntityEffect.cpp + ExpBottleEntity.cpp + ExpOrb.cpp + FallingBlock.cpp + FireChargeEntity.cpp + FireworkEntity.cpp + Floater.cpp + GhastFireballEntity.cpp + HangingEntity.cpp + ItemFrame.cpp + Minecart.cpp + Painting.cpp + Pawn.cpp + Pickup.cpp + Player.cpp + ProjectileEntity.cpp + SplashPotionEntity.cpp + TNTEntity.cpp + ThrownEggEntity.cpp + ThrownEnderPearlEntity.cpp + ThrownSnowballEntity.cpp + WitherSkullEntity.cpp) -add_library(Entities ${SOURCE}) +SET (HDRS + ArrowEntity.h + Boat.h + EnderCrystal.h + Entity.h + EntityEffect.h + ExpBottleEntity.h + ExpOrb.h + FallingBlock.h + FireChargeEntity.h + FireworkEntity.h + Floater.h + GhastFireballEntity.h + HangingEntity.h + ItemFrame.h + Minecart.h + Painting.h + Pawn.h + Pickup.h + Player.h + ProjectileEntity.h + SplashPotionEntity.h + TNTEntity.h + ThrownEggEntity.h + ThrownEnderPearlEntity.h + ThrownSnowballEntity.h + WitherSkullEntity.h) + +add_library(Entities ${SRCS} ${HDRS}) target_link_libraries(Entities WorldStorage) -- cgit v1.2.3 From 465743757a4847b860d932a20c3a7570aec6bec5 Mon Sep 17 00:00:00 2001 From: archshift Date: Thu, 17 Jul 2014 23:59:33 -0700 Subject: Items/CMakeLists.txt: Replaced glob with list of files --- src/Items/CMakeLists.txt | 52 +++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 47 insertions(+), 5 deletions(-) diff --git a/src/Items/CMakeLists.txt b/src/Items/CMakeLists.txt index a6fe6ea70..0c15a6944 100644 --- a/src/Items/CMakeLists.txt +++ b/src/Items/CMakeLists.txt @@ -4,9 +4,51 @@ project (MCServer) include_directories ("${PROJECT_SOURCE_DIR}/../") -file(GLOB SOURCE - "*.cpp" - "*.h" -) +SET (SRCS + ItemHandler.cpp) -add_library(Items ${SOURCE}) +SET (HDRS + ItemArmor.h + ItemBed.h + ItemBoat.h + ItemBow.h + ItemBrewingStand.h + ItemBucket.h + ItemCake.h + ItemCauldron.h + ItemCloth.h + ItemComparator.h + ItemDoor.h + ItemDye.h + ItemEmptyMap.h + ItemFishingRod.h + ItemFlowerPot.h + ItemFood.h + ItemHandler.h + ItemHoe.h + ItemItemFrame.h + ItemLeaves.h + ItemLighter.h + ItemLilypad.h + ItemMap.h + ItemMilk.h + ItemMinecart.h + ItemMobHead.h + ItemNetherWart.h + ItemPainting.h + ItemPickaxe.h + ItemPotion.h + ItemRedstoneDust.h + ItemRedstoneRepeater.h + ItemSapling.h + ItemSeeds.h + ItemShears.h + ItemShovel.h + ItemSign.h + ItemSpawnEgg.h + ItemString.h + ItemSugarcane.h + ItemSword.h + ItemThrowable.h) + +add_library(Items ${SRCS} ${HDRS}) -- cgit v1.2.3 From 61c4e2e5cbe93592a5dc1d704ca29a405ac61428 Mon Sep 17 00:00:00 2001 From: archshift Date: Fri, 18 Jul 2014 00:01:26 -0700 Subject: Blocks/CMakeLists.txt: Replaced glob with list of files --- src/Blocks/CMakeLists.txt | 97 ++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 92 insertions(+), 5 deletions(-) diff --git a/src/Blocks/CMakeLists.txt b/src/Blocks/CMakeLists.txt index 4b8c745ad..d356d151b 100644 --- a/src/Blocks/CMakeLists.txt +++ b/src/Blocks/CMakeLists.txt @@ -4,9 +4,96 @@ project (MCServer) include_directories ("${PROJECT_SOURCE_DIR}/../") -file(GLOB SOURCE - "*.cpp" - "*.h" -) +SET (SRCS + BlockBed.cpp + BlockDoor.cpp + BlockHandler.cpp + BlockPiston.cpp + ChunkInterface.cpp) -add_library(Blocks ${SOURCE}) +SET (HDRS + BlockAnvil.h + BlockBed.h + BlockBigFlower.h + BlockBrewingStand.h + BlockButton.h + BlockCactus.h + BlockCake.h + BlockCarpet.h + BlockCauldron.h + BlockChest.h + BlockCloth.h + BlockCobWeb.h + BlockCommandBlock.h + BlockComparator.h + BlockCrops.h + BlockDeadBush.h + BlockDirt.h + BlockDoor.h + BlockDropSpenser.h + BlockEnchantmentTable.h + BlockEnderchest.h + BlockEntity.h + BlockFarmland.h + BlockFenceGate.h + BlockFire.h + BlockFlower.h + BlockFlowerPot.h + BlockFluid.h + BlockFurnace.h + BlockGlass.h + BlockGlowstone.h + BlockGravel.h + BlockHandler.h + BlockHayBale.h + BlockHopper.h + BlockIce.h + BlockLadder.h + BlockLeaves.h + BlockLever.h + BlockLilypad.h + BlockMelon.h + BlockMobHead.h + BlockMushroom.h + BlockMycelium.h + BlockNetherWart.h + BlockNewLeaves.h + BlockNote.h + BlockOre.h + BlockPiston.h + BlockPlanks.h + BlockPluginInterface.h + BlockPortal.h + BlockPressurePlate.h + BlockPumpkin.h + BlockQuartz.h + BlockRail.h + BlockRedstone.h + BlockRedstoneLamp.h + BlockRedstoneRepeater.h + BlockRedstoneTorch.h + BlockSand.h + BlockSapling.h + BlockSideways.h + BlockSign.h + BlockSlab.h + BlockSnow.h + BlockStairs.h + BlockStems.h + BlockStone.h + BlockSugarcane.h + BlockTNT.h + BlockTallGrass.h + BlockTorch.h + BlockTrapdoor.h + BlockTripwire.h + BlockTripwireHook.h + BlockVine.h + BlockWorkbench.h + BroadcastInterface.h + ChunkInterface.h + ClearMetaOnDrop.h + MetaRotator.h + WorldInterface.h) + +add_library(Blocks ${SRCS} ${HDRS}) -- cgit v1.2.3 From 15aacc24a5e4adfb00cc0bf10703c83a60a0735b Mon Sep 17 00:00:00 2001 From: archshift Date: Fri, 18 Jul 2014 00:03:19 -0700 Subject: Protocol/CMakeLists.txt: Replaced glob with list of files --- src/Protocol/CMakeLists.txt | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/src/Protocol/CMakeLists.txt b/src/Protocol/CMakeLists.txt index 849ec27ca..21d49c516 100644 --- a/src/Protocol/CMakeLists.txt +++ b/src/Protocol/CMakeLists.txt @@ -4,9 +4,27 @@ project (MCServer) include_directories ("${PROJECT_SOURCE_DIR}/../") -file(GLOB SOURCE - "*.cpp" - "*.h" -) +SET (SRCS + Authenticator.cpp + ChunkDataSerializer.cpp + Protocol125.cpp + Protocol132.cpp + Protocol14x.cpp + Protocol15x.cpp + Protocol16x.cpp + Protocol17x.cpp + ProtocolRecognizer.cpp) -add_library(Protocol ${SOURCE}) +SET (HDRS + Authenticator.h + ChunkDataSerializer.h + Protocol.h + Protocol125.h + Protocol132.h + Protocol14x.h + Protocol15x.h + Protocol16x.h + Protocol17x.h + ProtocolRecognizer.h) + +add_library(Protocol ${SRCS} ${HDRS}) -- cgit v1.2.3 From 5890d04f212e83bdc2e2305e006e6091471802fc Mon Sep 17 00:00:00 2001 From: archshift Date: Fri, 18 Jul 2014 00:05:50 -0700 Subject: UI/CMakeLists.txt: Replaced glob with list of files --- src/UI/CMakeLists.txt | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/UI/CMakeLists.txt b/src/UI/CMakeLists.txt index 5b5b8cc18..c41123318 100644 --- a/src/UI/CMakeLists.txt +++ b/src/UI/CMakeLists.txt @@ -4,9 +4,13 @@ project (MCServer) include_directories ("${PROJECT_SOURCE_DIR}/../") -file(GLOB SOURCE - "*.cpp" - "*.h" -) +SET (SRCS + SlotArea.cpp + Window.cpp) -add_library(UI ${SOURCE}) +SET (HDRS + SlotArea.h + Window.h + WindowOwner.h) + +add_library(UI ${SRCS} ${HDRS}) -- cgit v1.2.3 From 1a05b7c5d70f1a57dd09d6ae9d35d4c1fb10128e Mon Sep 17 00:00:00 2001 From: archshift Date: Fri, 18 Jul 2014 00:14:15 -0700 Subject: BlockEntities/CMakeLists.txt: Replaced glob with list of files --- src/BlockEntities/CMakeLists.txt | 40 +++++++++++++++++++++++++++++++++++----- 1 file changed, 35 insertions(+), 5 deletions(-) diff --git a/src/BlockEntities/CMakeLists.txt b/src/BlockEntities/CMakeLists.txt index 3e3d17f86..4cd49c52d 100644 --- a/src/BlockEntities/CMakeLists.txt +++ b/src/BlockEntities/CMakeLists.txt @@ -4,9 +4,39 @@ project (MCServer) include_directories ("${PROJECT_SOURCE_DIR}/../") -file(GLOB SOURCE - "*.cpp" - "*.h" -) +SET (SRCS + BeaconEntity.cpp + BlockEntity.cpp + ChestEntity.cpp + CommandBlockEntity.cpp + DispenserEntity.cpp + DropSpenserEntity.cpp + DropperEntity.cpp + EnderChestEntity.cpp + FlowerPotEntity.cpp + FurnaceEntity.cpp + HopperEntity.cpp + JukeboxEntity.cpp + MobHeadEntity.cpp + NoteEntity.cpp + SignEntity.cpp) -add_library(BlockEntities ${SOURCE}) +SET (HDRS + BeaconEntity.h + BlockEntity.h + BlockEntityWithItems.h + ChestEntity.h + CommandBlockEntity.h + DispenserEntity.h + DropSpenserEntity.h + DropperEntity.h + EnderChestEntity.h + FlowerPotEntity.h + FurnaceEntity.h + HopperEntity.h + JukeboxEntity.h + MobHeadEntity.h + NoteEntity.h + SignEntity.h) + +add_library(BlockEntities ${SRCS} ${HDRS}) -- cgit v1.2.3 From 06bef093bf3a035e03bf22808e82f8d82638dbfc Mon Sep 17 00:00:00 2001 From: archshift Date: Fri, 18 Jul 2014 00:20:38 -0700 Subject: Generating/CMakeLists.txt: Replaced glob with list of files --- src/Generating/CMakeLists.txt | 59 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 54 insertions(+), 5 deletions(-) diff --git a/src/Generating/CMakeLists.txt b/src/Generating/CMakeLists.txt index 3dacb5066..b3960914c 100644 --- a/src/Generating/CMakeLists.txt +++ b/src/Generating/CMakeLists.txt @@ -4,11 +4,60 @@ project (MCServer) include_directories ("${PROJECT_SOURCE_DIR}/../") -file(GLOB SOURCE - "*.cpp" - "*.h" -) +SET (SRCS + BioGen.cpp + Caves.cpp + ChunkDesc.cpp + ChunkGenerator.cpp + CompoGen.cpp + ComposableGenerator.cpp + DistortedHeightmap.cpp + EndGen.cpp + FinishGen.cpp + GridStructGen.cpp + HeiGen.cpp + MineShafts.cpp + NetherFortGen.cpp + Noise3DGenerator.cpp + POCPieceGenerator.cpp + PieceGenerator.cpp + Prefab.cpp + PrefabPiecePool.cpp + RainbowRoadsGen.cpp + Ravines.cpp + StructGen.cpp + TestRailsGen.cpp + Trees.cpp + UnderwaterBaseGen.cpp + VillageGen.cpp) -add_library(Generating ${SOURCE}) +SET (HDRS + BioGen.h + Caves.h + ChunkDesc.h + ChunkGenerator.h + CompoGen.h + ComposableGenerator.h + DistortedHeightmap.h + EndGen.h + FinishGen.h + GridStructGen.h + HeiGen.h + MineShafts.h + NetherFortGen.h + Noise3DGenerator.h + POCPieceGenerator.h + PieceGenerator.h + Prefab.h + PrefabPiecePool.h + RainbowRoadsGen.h + Ravines.h + StructGen.h + TestRailsGen.h + Trees.h + UnderwaterBaseGen.h + VillageGen.h) + +add_library(Generating ${SRCS} ${HDRS}) target_link_libraries(Generating OSSupport iniFile Blocks) -- cgit v1.2.3 From 9fe4b61df35ebad8df7b928af73bc798ebaf731f Mon Sep 17 00:00:00 2001 From: archshift Date: Fri, 18 Jul 2014 00:26:55 -0700 Subject: WorldStorage/CMakeLists.txt: Replaced glob with list of files --- src/WorldStorage/CMakeLists.txt | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/src/WorldStorage/CMakeLists.txt b/src/WorldStorage/CMakeLists.txt index 2844f7fe5..212581400 100644 --- a/src/WorldStorage/CMakeLists.txt +++ b/src/WorldStorage/CMakeLists.txt @@ -4,11 +4,32 @@ project (MCServer) include_directories ("${PROJECT_SOURCE_DIR}/../") -file(GLOB SOURCE - "*.cpp" - "*.h" -) +SET (SRCS + EnchantmentSerializer.cpp + FastNBT.cpp + FireworksSerializer.cpp + MapSerializer.cpp + NBTChunkSerializer.cpp + SchematicFileSerializer.cpp + ScoreboardSerializer.cpp + StatSerializer.cpp + WSSAnvil.cpp + WSSCompact.cpp + WorldStorage.cpp) -add_library(WorldStorage ${SOURCE}) +SET (HDRS + EnchantmentSerializer.h + FastNBT.h + FireworksSerializer.h + MapSerializer.h + NBTChunkSerializer.h + SchematicFileSerializer.h + ScoreboardSerializer.h + StatSerializer.h + WSSAnvil.h + WSSCompact.h + WorldStorage.h) + +add_library(WorldStorage ${SRCS} ${HDRS}) target_link_libraries(WorldStorage OSSupport) -- cgit v1.2.3 From 0859ee3995d0cc80d80b328af920911d1cfb25d3 Mon Sep 17 00:00:00 2001 From: archshift Date: Fri, 18 Jul 2014 00:28:40 -0700 Subject: Simulator/CMakeLists.txt: Replaced glob with list of files --- src/Simulator/CMakeLists.txt | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/src/Simulator/CMakeLists.txt b/src/Simulator/CMakeLists.txt index b2a29d45c..f56fb0079 100644 --- a/src/Simulator/CMakeLists.txt +++ b/src/Simulator/CMakeLists.txt @@ -4,9 +4,32 @@ project (MCServer) include_directories ("${PROJECT_SOURCE_DIR}/../") -file(GLOB SOURCE - "*.cpp" - "*.h" -) +SET (SRCS + DelayedFluidSimulator.cpp + FireSimulator.cpp + FloodyFluidSimulator.cpp + FluidSimulator.cpp + IncrementalRedstoneSimulator.cpp + RedstoneSimulator.cpp + SandSimulator.cpp + Simulator.cpp + SimulatorManager.cpp + VanillaFluidSimulator.cpp + VaporizeFluidSimulator.cpp) -add_library(Simulator ${SOURCE}) +SET (HDRS + DelayedFluidSimulator.h + FireSimulator.h + FloodyFluidSimulator.h + FluidSimulator.h + IncrementalRedstoneSimulator.h + NoopFluidSimulator.h + NoopRedstoneSimulator.h + RedstoneSimulator.h + SandSimulator.h + Simulator.h + SimulatorManager.h + VanillaFluidSimulator.h + VaporizeFluidSimulator.h) + +add_library(Simulator ${SRCS} ${HDRS}) -- cgit v1.2.3 From de48688fdbca822a09a9b8abad2010768ab36a20 Mon Sep 17 00:00:00 2001 From: archshift Date: Fri, 18 Jul 2014 00:34:21 -0700 Subject: Generating/Prefabs/CMakeLists.txt: Replaced glob with list of files --- src/Generating/Prefabs/CMakeLists.txt | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/src/Generating/Prefabs/CMakeLists.txt b/src/Generating/Prefabs/CMakeLists.txt index a1f09112d..d53098b4e 100644 --- a/src/Generating/Prefabs/CMakeLists.txt +++ b/src/Generating/Prefabs/CMakeLists.txt @@ -4,11 +4,28 @@ project (MCServer) include_directories ("${PROJECT_SOURCE_DIR}/../../") -file(GLOB SOURCE - "*.cpp" - "*.h" -) +SET (SRCS + AlchemistVillagePrefabs.cpp + JapaneseVillagePrefabs.cpp + NetherFortPrefabs.cpp + PlainsVillagePrefabs.cpp + RainbowRoadPrefabs.cpp + SandFlatRoofVillagePrefabs.cpp + SandVillagePrefabs.cpp + TestRailsPrefabs.cpp + UnderwaterBasePrefabs.cpp) -add_library(Generating_Prefabs ${SOURCE}) +SET (HDRS + AlchemistVillagePrefabs.h + JapaneseVillagePrefabs.h + NetherFortPrefabs.h + PlainsVillagePrefabs.h + RainbowRoadPrefabs.h + SandFlatRoofVillagePrefabs.h + SandVillagePrefabs.h + TestRailsPrefabs.h + UnderwaterBasePrefabs.h) + +add_library(Generating_Prefabs ${SRCS} ${HDRS}) target_link_libraries(Generating_Prefabs OSSupport iniFile Blocks) -- cgit v1.2.3 From 5d966be741eef68749412d706de05d963628abc9 Mon Sep 17 00:00:00 2001 From: archshift Date: Fri, 18 Jul 2014 00:46:39 -0700 Subject: HTTPServer/CMakeLists.txt: Replaced glob with list of files --- src/HTTPServer/CMakeLists.txt | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/src/HTTPServer/CMakeLists.txt b/src/HTTPServer/CMakeLists.txt index dc894368d..a15b2494f 100644 --- a/src/HTTPServer/CMakeLists.txt +++ b/src/HTTPServer/CMakeLists.txt @@ -4,9 +4,24 @@ project (MCServer) include_directories ("${PROJECT_SOURCE_DIR}/../") -file(GLOB SOURCE - "*.cpp" - "*.h" -) +SET (SRCS + EnvelopeParser.cpp + HTTPConnection.cpp + HTTPFormParser.cpp + HTTPMessage.cpp + HTTPServer.cpp + MultipartParser.cpp + NameValueParser.cpp + SslHTTPConnection.cpp) -add_library(HTTPServer ${SOURCE}) +SET (HDRS + EnvelopeParser.h + HTTPConnection.h + HTTPFormParser.h + HTTPMessage.h + HTTPServer.h + MultipartParser.h + NameValueParser.h + SslHTTPConnection.h) + +add_library(HTTPServer ${SRCS} ${HDRS}) -- cgit v1.2.3 From dcaa3262a2b085fa3ea9769c7eee21d3cd48c834 Mon Sep 17 00:00:00 2001 From: archshift Date: Fri, 18 Jul 2014 00:48:22 -0700 Subject: OSSupport/CMakeLists.txt: Replaced glob with list of files --- src/OSSupport/CMakeLists.txt | 37 ++++++++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/src/OSSupport/CMakeLists.txt b/src/OSSupport/CMakeLists.txt index dee60b450..8004d4094 100644 --- a/src/OSSupport/CMakeLists.txt +++ b/src/OSSupport/CMakeLists.txt @@ -3,12 +3,39 @@ cmake_minimum_required (VERSION 2.6) project (MCServer) include_directories ("${PROJECT_SOURCE_DIR}/../") -file(GLOB SOURCE - "*.cpp" - "*.h" -) -add_library(OSSupport ${SOURCE}) +SET (SRCS + CriticalSection.cpp + Errors.cpp + Event.cpp + File.cpp + GZipFile.cpp + IsThread.cpp + ListenThread.cpp + Semaphore.cpp + Sleep.cpp + Socket.cpp + SocketThreads.cpp + Thread.cpp + Timer.cpp) + +SET (HDRS + CriticalSection.h + Errors.h + Event.h + File.h + GZipFile.h + IsThread.h + ListenThread.h + Queue.h + Semaphore.h + Sleep.h + Socket.h + SocketThreads.h + Thread.h + Timer.h) + +add_library(OSSupport ${SRCS} ${HDRS}) if(UNIX) target_link_libraries(OSSupport pthread) -- cgit v1.2.3 From 34c8ff7b24171f9712ce3156013187257bb45327 Mon Sep 17 00:00:00 2001 From: archshift Date: Fri, 18 Jul 2014 01:40:01 -0700 Subject: src/CMakeLists: Small changes for increased readability --- src/CMakeLists.txt | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index fdc33cd82..c33b0983a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -5,8 +5,10 @@ include_directories (SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/../lib/") include_directories (SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/../lib/jsoncpp/include") include_directories (SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/../lib/polarssl/include") -set(FOLDERS OSSupport HTTPServer Items Blocks Protocol Generating PolarSSL++) -set(FOLDERS ${FOLDERS} WorldStorage Mobs Entities Simulator UI BlockEntities Generating/Prefabs) +set(FOLDERS + OSSupport HTTPServer Items Blocks Protocol Generating PolarSSL++ + WorldStorage Mobs Entities Simulator UI BlockEntities Generating/Prefabs +) set(BINDING_DEPENDECIES tolua @@ -261,9 +263,11 @@ endif () if (NOT MSVC) - target_link_libraries(${EXECUTABLE} OSSupport HTTPServer Bindings Items Blocks) - target_link_libraries(${EXECUTABLE} Protocol Generating Generating_Prefabs WorldStorage) - target_link_libraries(${EXECUTABLE} Mobs Entities Simulator UI BlockEntities PolarSSL++) + target_link_libraries(${EXECUTABLE} + OSSupport HTTPServer Bindings Items Blocks + Protocol Generating Generating_Prefabs WorldStorage + Mobs Entities Simulator UI BlockEntities PolarSSL++ + ) endif () if (WIN32) target_link_libraries(${EXECUTABLE} expat tolualib ws2_32.lib Psapi.lib) -- cgit v1.2.3 From 725d1fd1e2995b1720673c280fea1125ac338b3c Mon Sep 17 00:00:00 2001 From: archshift Date: Fri, 18 Jul 2014 13:26:43 -0700 Subject: Subdirs: Only add_library if not using MSVC --- src/BlockEntities/CMakeLists.txt | 4 +++- src/Blocks/CMakeLists.txt | 4 +++- src/Entities/CMakeLists.txt | 6 ++++-- src/Generating/CMakeLists.txt | 6 ++++-- src/Generating/Prefabs/CMakeLists.txt | 6 ++++-- src/HTTPServer/CMakeLists.txt | 4 +++- src/Items/CMakeLists.txt | 4 +++- src/Mobs/CMakeLists.txt | 4 +++- src/OSSupport/CMakeLists.txt | 8 +++++--- src/Protocol/CMakeLists.txt | 4 +++- src/Simulator/CMakeLists.txt | 4 +++- src/UI/CMakeLists.txt | 4 +++- src/WorldStorage/CMakeLists.txt | 6 ++++-- 13 files changed, 45 insertions(+), 19 deletions(-) diff --git a/src/BlockEntities/CMakeLists.txt b/src/BlockEntities/CMakeLists.txt index 4cd49c52d..d87594b0d 100644 --- a/src/BlockEntities/CMakeLists.txt +++ b/src/BlockEntities/CMakeLists.txt @@ -39,4 +39,6 @@ SET (HDRS NoteEntity.h SignEntity.h) -add_library(BlockEntities ${SRCS} ${HDRS}) +if(NOT MSVC) + add_library(BlockEntities ${SRCS} ${HDRS}) +endif() diff --git a/src/Blocks/CMakeLists.txt b/src/Blocks/CMakeLists.txt index d356d151b..d7edf7f29 100644 --- a/src/Blocks/CMakeLists.txt +++ b/src/Blocks/CMakeLists.txt @@ -96,4 +96,6 @@ SET (HDRS MetaRotator.h WorldInterface.h) -add_library(Blocks ${SRCS} ${HDRS}) +if(NOT MSVC) + add_library(Blocks ${SRCS} ${HDRS}) +endif() diff --git a/src/Entities/CMakeLists.txt b/src/Entities/CMakeLists.txt index 64752d13c..5d10e1680 100644 --- a/src/Entities/CMakeLists.txt +++ b/src/Entities/CMakeLists.txt @@ -60,6 +60,8 @@ SET (HDRS ThrownSnowballEntity.h WitherSkullEntity.h) -add_library(Entities ${SRCS} ${HDRS}) +if(NOT MSVC) + add_library(Entities ${SRCS} ${HDRS}) -target_link_libraries(Entities WorldStorage) + target_link_libraries(Entities WorldStorage) +endif() diff --git a/src/Generating/CMakeLists.txt b/src/Generating/CMakeLists.txt index b3960914c..9063abd97 100644 --- a/src/Generating/CMakeLists.txt +++ b/src/Generating/CMakeLists.txt @@ -58,6 +58,8 @@ SET (HDRS UnderwaterBaseGen.h VillageGen.h) -add_library(Generating ${SRCS} ${HDRS}) +if(NOT MSVC) + add_library(Generating ${SRCS} ${HDRS}) -target_link_libraries(Generating OSSupport iniFile Blocks) + target_link_libraries(Generating OSSupport iniFile Blocks) +endif() diff --git a/src/Generating/Prefabs/CMakeLists.txt b/src/Generating/Prefabs/CMakeLists.txt index d53098b4e..2c62aa73d 100644 --- a/src/Generating/Prefabs/CMakeLists.txt +++ b/src/Generating/Prefabs/CMakeLists.txt @@ -26,6 +26,8 @@ SET (HDRS TestRailsPrefabs.h UnderwaterBasePrefabs.h) -add_library(Generating_Prefabs ${SRCS} ${HDRS}) +if(NOT MSVC) + add_library(Generating_Prefabs ${SRCS} ${HDRS}) -target_link_libraries(Generating_Prefabs OSSupport iniFile Blocks) + target_link_libraries(Generating_Prefabs OSSupport iniFile Blocks) +endif() diff --git a/src/HTTPServer/CMakeLists.txt b/src/HTTPServer/CMakeLists.txt index a15b2494f..b0efc810d 100644 --- a/src/HTTPServer/CMakeLists.txt +++ b/src/HTTPServer/CMakeLists.txt @@ -24,4 +24,6 @@ SET (HDRS NameValueParser.h SslHTTPConnection.h) -add_library(HTTPServer ${SRCS} ${HDRS}) +if(NOT MSVC) + add_library(HTTPServer ${SRCS} ${HDRS}) +endif() diff --git a/src/Items/CMakeLists.txt b/src/Items/CMakeLists.txt index 0c15a6944..12a467672 100644 --- a/src/Items/CMakeLists.txt +++ b/src/Items/CMakeLists.txt @@ -51,4 +51,6 @@ SET (HDRS ItemSword.h ItemThrowable.h) -add_library(Items ${SRCS} ${HDRS}) +if(NOT MSVC) + add_library(Items ${SRCS} ${HDRS}) +endif() diff --git a/src/Mobs/CMakeLists.txt b/src/Mobs/CMakeLists.txt index d73a7aafd..2c092c15f 100644 --- a/src/Mobs/CMakeLists.txt +++ b/src/Mobs/CMakeLists.txt @@ -73,4 +73,6 @@ SET (HDRS Zombie.h ZombiePigman.h) -add_library(Mobs ${SRCS} ${HDRS}) +if(NOT MSVC) + add_library(Mobs ${SRCS} ${HDRS}) +endif() diff --git a/src/OSSupport/CMakeLists.txt b/src/OSSupport/CMakeLists.txt index 8004d4094..a42fcbed4 100644 --- a/src/OSSupport/CMakeLists.txt +++ b/src/OSSupport/CMakeLists.txt @@ -35,8 +35,10 @@ SET (HDRS Thread.h Timer.h) -add_library(OSSupport ${SRCS} ${HDRS}) +if(NOT MSVC) + add_library(OSSupport ${SRCS} ${HDRS}) -if(UNIX) - target_link_libraries(OSSupport pthread) + if(UNIX) + target_link_libraries(OSSupport pthread) + endif() endif() diff --git a/src/Protocol/CMakeLists.txt b/src/Protocol/CMakeLists.txt index 21d49c516..ae447ce54 100644 --- a/src/Protocol/CMakeLists.txt +++ b/src/Protocol/CMakeLists.txt @@ -27,4 +27,6 @@ SET (HDRS Protocol17x.h ProtocolRecognizer.h) -add_library(Protocol ${SRCS} ${HDRS}) +if(NOT MSVC) + add_library(Protocol ${SRCS} ${HDRS}) +endif() diff --git a/src/Simulator/CMakeLists.txt b/src/Simulator/CMakeLists.txt index f56fb0079..521b145b6 100644 --- a/src/Simulator/CMakeLists.txt +++ b/src/Simulator/CMakeLists.txt @@ -32,4 +32,6 @@ SET (HDRS VanillaFluidSimulator.h VaporizeFluidSimulator.h) -add_library(Simulator ${SRCS} ${HDRS}) +if(NOT MSVC) + add_library(Simulator ${SRCS} ${HDRS}) +endif() diff --git a/src/UI/CMakeLists.txt b/src/UI/CMakeLists.txt index c41123318..2b094ef1d 100644 --- a/src/UI/CMakeLists.txt +++ b/src/UI/CMakeLists.txt @@ -13,4 +13,6 @@ SET (HDRS Window.h WindowOwner.h) -add_library(UI ${SRCS} ${HDRS}) +if(NOT MSVC) + add_library(UI ${SRCS} ${HDRS}) +endif() diff --git a/src/WorldStorage/CMakeLists.txt b/src/WorldStorage/CMakeLists.txt index 212581400..a00ff3b2f 100644 --- a/src/WorldStorage/CMakeLists.txt +++ b/src/WorldStorage/CMakeLists.txt @@ -30,6 +30,8 @@ SET (HDRS WSSCompact.h WorldStorage.h) -add_library(WorldStorage ${SRCS} ${HDRS}) +if(NOT MSVC) + add_library(WorldStorage ${SRCS} ${HDRS}) -target_link_libraries(WorldStorage OSSupport) + target_link_libraries(WorldStorage OSSupport) +endif() -- cgit v1.2.3 From 84fef3c1569b941e747c471b06b290876baa131e Mon Sep 17 00:00:00 2001 From: archshift Date: Fri, 18 Jul 2014 14:08:49 -0700 Subject: src/CMakeLists.txt: Replaced glob with list of files On MSVC, CMake will traverse all the CMakeLists and add their source and header files to one conglomerate SOURCE list. --- src/Bindings/CMakeLists.txt | 32 +++++++++ src/CMakeLists.txt | 168 ++++++++++++++++++++++++++++++++++++++------ 2 files changed, 180 insertions(+), 20 deletions(-) create mode 100644 src/Bindings/CMakeLists.txt diff --git a/src/Bindings/CMakeLists.txt b/src/Bindings/CMakeLists.txt new file mode 100644 index 000000000..fd6223469 --- /dev/null +++ b/src/Bindings/CMakeLists.txt @@ -0,0 +1,32 @@ +cmake_minimum_required (VERSION 2.6) +project (MCServer) + +include_directories ("${PROJECT_SOURCE_DIR}/../") + +SET (SRCS + Bindings.cpp + DeprecatedBindings.cpp + LuaChunkStay.cpp + LuaState.cpp + LuaWindow.cpp + ManualBindings.cpp + Plugin.cpp + PluginLua.cpp + PluginManager.cpp + WebPlugin.cpp +) + +SET (HDRS + Bindings.h + DeprecatedBindings.h + LuaChunkStay.h + LuaFunctions.h + LuaState.h + LuaWindow.h + ManualBindings.h + Plugin.h + PluginLua.h + PluginManager.h + WebPlugin.h + tolua++.h +) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c33b0983a..dc6fec02f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -82,6 +82,131 @@ set(BINDING_DEPENDECIES World.h ) +SET (SRCS + BiomeDef.cpp + BlockArea.cpp + BlockID.cpp + BlockInfo.cpp + BoundingBox.cpp + ByteBuffer.cpp + ChatColor.cpp + Chunk.cpp + ChunkData.cpp + ChunkMap.cpp + ChunkSender.cpp + ChunkStay.cpp + ClientHandle.cpp + CommandOutput.cpp + CompositeChat.cpp + CraftingRecipes.cpp + Cuboid.cpp + DeadlockDetect.cpp + Enchantments.cpp + FastRandom.cpp + FurnaceRecipe.cpp + Globals.cpp + Group.cpp + GroupManager.cpp + Inventory.cpp + Item.cpp + ItemGrid.cpp + LightingThread.cpp + LineBlockTracer.cpp + LinearInterpolation.cpp + Log.cpp + MCLogger.cpp + Map.cpp + MapManager.cpp + MobCensus.cpp + MobFamilyCollecter.cpp + MobProximityCounter.cpp + MobSpawner.cpp + MonsterConfig.cpp + Noise.cpp + ProbabDistrib.cpp + RCONServer.cpp + Root.cpp + Scoreboard.cpp + Server.cpp + Statistics.cpp + StringCompression.cpp + StringUtils.cpp + Tracer.cpp + VoronoiMap.cpp + WebAdmin.cpp + World.cpp + main.cpp) + +SET (HDRS + AllocationPool.h + BiomeDef.h + BlockArea.h + BlockID.h + BlockInServerPluginInterface.h + BlockInfo.h + BlockTracer.h + BoundingBox.h + ByteBuffer.h + ChatColor.h + Chunk.h + ChunkData.h + ChunkDataCallback.h + ChunkDef.h + ChunkMap.h + ChunkSender.h + ChunkStay.h + ClientHandle.h + CommandOutput.h + CompositeChat.h + CraftingRecipes.h + Cuboid.h + DeadlockDetect.h + Defines.h + Enchantments.h + Endianness.h + FastRandom.h + ForEachChunkProvider.h + FurnaceRecipe.h + Globals.h + Group.h + GroupManager.h + Inventory.h + Item.h + ItemGrid.h + LeakFinder.h + LightingThread.h + LineBlockTracer.h + LinearInterpolation.h + LinearUpscale.h + Log.h + MCLogger.h + Map.h + MapManager.h + Matrix4.h + MemoryLeak.h + MersenneTwister.h + MobCensus.h + MobFamilyCollecter.h + MobProximityCounter.h + MobSpawner.h + MonsterConfig.h + Noise.h + ProbabDistrib.h + RCONServer.h + Root.h + Scoreboard.h + Server.h + StackWalker.h + Statistics.h + StringCompression.h + StringUtils.h + Tracer.h + Vector3.h + VoronoiMap.h + WebAdmin.h + World.h + XMLParser.h) + # List all the files that are generated as part of the Bindings build process set (BINDING_OUTPUTS ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/Bindings.cpp @@ -159,38 +284,21 @@ if (NOT MSVC) add_subdirectory(${folder}) endforeach(folder) - file(GLOB SOURCE - "*.cpp" - "*.h" - ) - - list(REMOVE_ITEM SOURCE "${PROJECT_SOURCE_DIR}/StackWalker.cpp" "${PROJECT_SOURCE_DIR}/LeakFinder.cpp") + list(APPEND SOURCE "${SRCS}") + list(APPEND SOURCE "${HDRS}") # If building a windows version, but not using MSVC, add the resources directly to the makefile: if (WIN32) - FILE(GLOB ResourceFiles - "Resources/*.rc" - ) - list(APPEND SOURCE "${ResourceFiles}") + list(APPEND SOURCE "Resources/MCServer.rc") endif() else () # MSVC-specific handling: Put all files into one project, separate by the folders: - # Get all files in this folder: - file(GLOB_RECURSE SOURCE - "*.cpp" - "*.h" - "*.pkg" - ) - source_group("" FILES ${SOURCE}) - - LIST(APPEND SOURCE "Bindings/Bindings.cpp" "Bindings/Bindings.h") source_group(Bindings FILES "Bindings/Bindings.cpp" "Bindings/Bindings.h") # Add all subfolders as solution-folders: - list(APPEND FOLDERS "Resources") list(APPEND FOLDERS "Bindings") function(includefolder PATH) FILE(GLOB FOLDER_FILES @@ -204,9 +312,29 @@ else () endfunction(includefolder) foreach(folder ${FOLDERS}) + add_subdirectory(${folder}) includefolder(${folder}) + + # Get all source files in this folder: + get_directory_property(FOLDER_SRCS DIRECTORY ${folder} DEFINITION SRCS) + foreach (src ${FOLDER_SRCS}) + list(APPEND SOURCE "${folder}/${src}") + endforeach(src) + + # Get all headers in this folder: + get_directory_property(FOLDER_HDRS DIRECTORY ${folder} DEFINITION HDRS) + foreach (hdr ${FOLDER_HDRS}) + list(APPEND SOURCE "${folder}/${hdr}") + endforeach(hdr) endforeach(folder) + list(APPEND SOURCE "${SRCS}") + list(APPEND SOURCE "${HDRS}") + list(APPEND SOURCE "Bindings/AllToLua.pkg") + + includefolder("Resources") + source_group("" FILES ${SOURCE}) + include_directories("${PROJECT_SOURCE_DIR}") # Precompiled headers (1st part) -- cgit v1.2.3 From 832530469360020d5cc1bd0a4142c3450d4cd8f9 Mon Sep 17 00:00:00 2001 From: archshift Date: Fri, 18 Jul 2014 15:27:50 -0700 Subject: CMake: Add Bindings library from subdirectory --- src/Bindings/CMakeLists.txt | 6 ++++++ src/CMakeLists.txt | 29 ++++++----------------------- 2 files changed, 12 insertions(+), 23 deletions(-) diff --git a/src/Bindings/CMakeLists.txt b/src/Bindings/CMakeLists.txt index fd6223469..da6a6919a 100644 --- a/src/Bindings/CMakeLists.txt +++ b/src/Bindings/CMakeLists.txt @@ -30,3 +30,9 @@ SET (HDRS WebPlugin.h tolua++.h ) + +if(NOT MSVC) + add_library(Bindings ${SRCS} ${HDRS}) + + target_link_libraries(Bindings lua sqlite tolualib polarssl) +endif() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index dc6fec02f..afe766f13 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -6,7 +6,7 @@ include_directories (SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/../lib/jsoncpp/include" include_directories (SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/../lib/polarssl/include") set(FOLDERS - OSSupport HTTPServer Items Blocks Protocol Generating PolarSSL++ + OSSupport HTTPServer Items Blocks Protocol Generating PolarSSL++ Bindings WorldStorage Mobs Entities Simulator UI BlockEntities Generating/Prefabs ) @@ -250,26 +250,14 @@ set_source_files_properties(Bindings/Bindings.h PROPERTIES GENERATED TRUE) if (NOT MSVC) # Bindings need to reference other folders, so they are done here instead - + # lib dependencies are not included - - include_directories ("${CMAKE_CURRENT_SOURCE_DIR}/../lib/polarssl/include") - #add cpp files here - add_library(Bindings - Bindings/Bindings - Bindings/DeprecatedBindings - Bindings/LuaChunkStay - Bindings/LuaState - Bindings/LuaWindow - Bindings/ManualBindings - Bindings/Plugin - Bindings/PluginLua - Bindings/PluginManager - Bindings/WebPlugin - ) + include_directories ("${CMAKE_CURRENT_SOURCE_DIR}/../lib/polarssl/include") - target_link_libraries(Bindings lua sqlite tolualib polarssl) + foreach(folder ${FOLDERS}) + add_subdirectory(${folder}) + endforeach(folder) #clear file file(WRITE ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/BindingDependecies.txt) @@ -280,10 +268,6 @@ if (NOT MSVC) set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "Bindings.cpp Bindings.h") - foreach(folder ${FOLDERS}) - add_subdirectory(${folder}) - endforeach(folder) - list(APPEND SOURCE "${SRCS}") list(APPEND SOURCE "${HDRS}") @@ -299,7 +283,6 @@ else () source_group(Bindings FILES "Bindings/Bindings.cpp" "Bindings/Bindings.h") # Add all subfolders as solution-folders: - list(APPEND FOLDERS "Bindings") function(includefolder PATH) FILE(GLOB FOLDER_FILES "${PATH}/*.cpp" -- cgit v1.2.3 From 3d368b015e2032f86130b8a3f4d05ca72287c63a Mon Sep 17 00:00:00 2001 From: archshift Date: Fri, 18 Jul 2014 15:41:42 -0700 Subject: Blocks/CMakeLists.txt: Fixed header list after merge of master --- src/Blocks/CMakeLists.txt | 3 ++- src/CMakeLists.txt | 13 ++++--------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/Blocks/CMakeLists.txt b/src/Blocks/CMakeLists.txt index d7edf7f29..05b7bfab4 100644 --- a/src/Blocks/CMakeLists.txt +++ b/src/Blocks/CMakeLists.txt @@ -75,7 +75,7 @@ SET (HDRS BlockSand.h BlockSapling.h BlockSideways.h - BlockSign.h + BlockSignPost.h BlockSlab.h BlockSnow.h BlockStairs.h @@ -89,6 +89,7 @@ SET (HDRS BlockTripwire.h BlockTripwireHook.h BlockVine.h + BlockWallSign.h BlockWorkbench.h BroadcastInterface.h ChunkInterface.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index afe766f13..2fe436125 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -248,17 +248,10 @@ set_source_files_properties(Bindings/Bindings.cpp PROPERTIES GENERATED TRUE) set_source_files_properties(Bindings/Bindings.h PROPERTIES GENERATED TRUE) if (NOT MSVC) - # Bindings need to reference other folders, so they are done here instead - # lib dependencies are not included - include_directories ("${CMAKE_CURRENT_SOURCE_DIR}/../lib/polarssl/include") - foreach(folder ${FOLDERS}) - add_subdirectory(${folder}) - endforeach(folder) - #clear file file(WRITE ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/BindingDependecies.txt) foreach(dependecy ${BINDING_DEPENDECIES}) @@ -268,6 +261,10 @@ if (NOT MSVC) set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "Bindings.cpp Bindings.h") + foreach(folder ${FOLDERS}) + add_subdirectory(${folder}) + endforeach(folder) + list(APPEND SOURCE "${SRCS}") list(APPEND SOURCE "${HDRS}") @@ -275,8 +272,6 @@ if (NOT MSVC) if (WIN32) list(APPEND SOURCE "Resources/MCServer.rc") endif() - - else () # MSVC-specific handling: Put all files into one project, separate by the folders: -- cgit v1.2.3 From 135dc333c131a9bde32609351e2b495c80b49f53 Mon Sep 17 00:00:00 2001 From: archshift Date: Fri, 18 Jul 2014 16:04:07 -0700 Subject: CMakeLists: Moved Bindings-specific code to subdir --- src/Bindings/CMakeLists.txt | 111 ++++++++++++++++++++++++++++++++++++++ src/CMakeLists.txt | 122 +++--------------------------------------- src/PolarSSL++/CMakeLists.txt | 12 +++-- 3 files changed, 125 insertions(+), 120 deletions(-) diff --git a/src/Bindings/CMakeLists.txt b/src/Bindings/CMakeLists.txt index da6a6919a..723487ff0 100644 --- a/src/Bindings/CMakeLists.txt +++ b/src/Bindings/CMakeLists.txt @@ -2,6 +2,7 @@ cmake_minimum_required (VERSION 2.6) project (MCServer) include_directories ("${PROJECT_SOURCE_DIR}/../") +include_directories (".") SET (SRCS Bindings.cpp @@ -31,6 +32,116 @@ SET (HDRS tolua++.h ) +# List all the files that are generated as part of the Bindings build process +set (BINDING_OUTPUTS + ${CMAKE_CURRENT_SOURCE_DIR}/Bindings.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/Bindings.h + ${CMAKE_CURRENT_SOURCE_DIR}/LuaState_Call.inc +) + +set(BINDING_DEPENDECIES + tolua + ../Bindings/virtual_method_hooks.lua + ../Bindings/AllToLua.pkg + ../Bindings/gen_LuaState_Call.lua + ../Bindings/LuaFunctions.h + ../Bindings/LuaState_Call.inc + ../Bindings/LuaWindow.h + ../Bindings/Plugin.h + ../Bindings/PluginLua.h + ../Bindings/PluginManager.h + ../Bindings/WebPlugin.h + ../BiomeDef.h + ../BlockArea.h + ../BlockEntities/BlockEntity.h + ../BlockEntities/BlockEntityWithItems.h + ../BlockEntities/ChestEntity.h + ../BlockEntities/DispenserEntity.h + ../BlockEntities/DropSpenserEntity.h + ../BlockEntities/DropperEntity.h + ../BlockEntities/FurnaceEntity.h + ../BlockEntities/HopperEntity.h + ../BlockEntities/JukeboxEntity.h + ../BlockEntities/NoteEntity.h + ../BlockEntities/SignEntity.h + ../BlockEntities/MobHeadEntity.h + ../BlockEntities/FlowerPotEntity.h + ../BlockID.h + ../BoundingBox.h + ../ChatColor.h + ../ChunkDef.h + ../ClientHandle.h + ../CraftingRecipes.h + ../Cuboid.h + ../Defines.h + ../Enchantments.h + ../Entities/EntityEffect.h + ../Entities/Entity.h + ../Entities/Floater.h + ../Entities/Pawn.h + ../Entities/Painting.h + ../Entities/Pickup.h + ../Entities/Player.h + ../Entities/ProjectileEntity.h + ../Entities/ArrowEntity.h + ../Entities/ThrownEggEntity.h + ../Entities/ThrownEnderPearlEntity.h + ../Entities/ExpBottleEntity.h + ../Entities/ThrownSnowballEntity.h + ../Entities/FireChargeEntity.h + ../Entities/FireworkEntity.h + ../Entities/GhastFireballEntity.h + ../Entities/TNTEntity.h + ../Entities/ExpOrb.h + ../Entities/HangingEntity.h + ../Entities/ItemFrame.h + ../Generating/ChunkDesc.h + ../Group.h + ../Inventory.h + ../Item.h + ../ItemGrid.h + ../Mobs/Monster.h + ../OSSupport/File.h + ../Root.h + ../Server.h + ../StringUtils.h + ../Tracer.h + ../UI/Window.h + ../Vector3.h + ../WebAdmin.h + ../World.h +) + +if (WIN32) + ADD_CUSTOM_COMMAND( + OUTPUT ${BINDING_OUTPUTS} + + # Copy the Lua DLL into the Bindings folder, so that tolua can run from there: + COMMAND ${CMAKE_COMMAND} -E copy_if_different ../../MCServer/lua51.dll ./lua51.dll + + # Regenerate bindings: + COMMAND tolua -L virtual_method_hooks.lua -o Bindings.cpp -H Bindings.h AllToLua.pkg + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + + # add any new generation dependencies here + DEPENDS ${BINDING_DEPENDECIES} + ) +else () + ADD_CUSTOM_COMMAND( + # add any new generated bindings here + OUTPUT ${BINDING_OUTPUTS} + + # Regenerate bindings: + COMMAND tolua -L virtual_method_hooks.lua -o Bindings.cpp -H Bindings.h AllToLua.pkg + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + + # add any new generation dependencies here + DEPENDS ${BINDING_DEPENDECIES} + ) +endif () +set_source_files_properties(Bindings/Bindings.cpp PROPERTIES GENERATED TRUE) +set_source_files_properties(Bindings/Bindings.h PROPERTIES GENERATED TRUE) + if(NOT MSVC) add_library(Bindings ${SRCS} ${HDRS}) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2fe436125..6008d3174 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -10,78 +10,6 @@ set(FOLDERS WorldStorage Mobs Entities Simulator UI BlockEntities Generating/Prefabs ) -set(BINDING_DEPENDECIES - tolua - ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/virtual_method_hooks.lua - ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/AllToLua.pkg - Bindings/gen_LuaState_Call.lua - Bindings/LuaFunctions.h - Bindings/LuaWindow.h - Bindings/Plugin.h - Bindings/PluginLua.h - Bindings/PluginManager.h - Bindings/WebPlugin.h - BiomeDef.h - BlockArea.h - BlockEntities/BlockEntity.h - BlockEntities/BlockEntityWithItems.h - BlockEntities/ChestEntity.h - BlockEntities/DispenserEntity.h - BlockEntities/DropSpenserEntity.h - BlockEntities/DropperEntity.h - BlockEntities/FurnaceEntity.h - BlockEntities/HopperEntity.h - BlockEntities/JukeboxEntity.h - BlockEntities/NoteEntity.h - BlockEntities/SignEntity.h - BlockEntities/MobHeadEntity.h - BlockEntities/FlowerPotEntity.h - BlockID.h - BoundingBox.h - ChatColor.h - ChunkDef.h - ClientHandle.h - CraftingRecipes.h - Cuboid.h - Defines.h - Enchantments.h - Entities/EntityEffect.h - Entities/Entity.h - Entities/Floater.h - Entities/Pawn.h - Entities/Painting.h - Entities/Pickup.h - Entities/Player.h - Entities/ProjectileEntity.h - Entities/ArrowEntity.h - Entities/ThrownEggEntity.h - Entities/ThrownEnderPearlEntity.h - Entities/ExpBottleEntity.h - Entities/ThrownSnowballEntity.h - Entities/FireChargeEntity.h - Entities/FireworkEntity.h - Entities/GhastFireballEntity.h - Entities/TNTEntity.h - Entities/ExpOrb.h - Entities/HangingEntity.h - Entities/ItemFrame.h - Generating/ChunkDesc.h - Group.h - Inventory.h - Item.h - ItemGrid.h - Mobs/Monster.h - OSSupport/File.h - Root.h - Server.h - StringUtils.h - Tracer.h - UI/Window.h - Vector3.h - WebAdmin.h - World.h -) - SET (SRCS BiomeDef.cpp BlockArea.cpp @@ -207,51 +135,19 @@ SET (HDRS World.h XMLParser.h) -# List all the files that are generated as part of the Bindings build process -set (BINDING_OUTPUTS - ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/Bindings.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/Bindings.h - ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/LuaState_Call.inc -) - -include_directories(Bindings) -include_directories(.) - -if (WIN32) - ADD_CUSTOM_COMMAND( - OUTPUT ${BINDING_OUTPUTS} - - # Copy the Lua DLL into the Bindings folder, so that tolua can run from there: - COMMAND ${CMAKE_COMMAND} -E copy_if_different ../../MCServer/lua51.dll ./lua51.dll - - # Regenerate bindings: - COMMAND tolua -L virtual_method_hooks.lua -o Bindings.cpp -H Bindings.h AllToLua.pkg - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/ - - # add any new generation dependencies here - DEPENDS ${BINDING_DEPENDECIES} - ) -else () - ADD_CUSTOM_COMMAND( - # add any new generated bindings here - OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/Bindings.cpp ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/Bindings.h - - # Regenerate bindings: - COMMAND tolua -L virtual_method_hooks.lua -o Bindings.cpp -H Bindings.h AllToLua.pkg - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/ - - # add any new generation dependencies here - DEPENDS ${BINDING_DEPENDECIES} - ) -endif () -set_source_files_properties(Bindings/Bindings.cpp PROPERTIES GENERATED TRUE) -set_source_files_properties(Bindings/Bindings.h PROPERTIES GENERATED TRUE) +include_directories(".") if (NOT MSVC) # Bindings need to reference other folders, so they are done here instead # lib dependencies are not included include_directories ("${CMAKE_CURRENT_SOURCE_DIR}/../lib/polarssl/include") + foreach(folder ${FOLDERS}) + add_subdirectory(${folder}) + endforeach(folder) + + get_directory_property(BINDING_DEPENDENCIES DIRECTORY "Bindings" DEFINITION BINDING_DEPENDENCIES) + #clear file file(WRITE ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/BindingDependecies.txt) foreach(dependecy ${BINDING_DEPENDECIES}) @@ -261,10 +157,6 @@ if (NOT MSVC) set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "Bindings.cpp Bindings.h") - foreach(folder ${FOLDERS}) - add_subdirectory(${folder}) - endforeach(folder) - list(APPEND SOURCE "${SRCS}") list(APPEND SOURCE "${HDRS}") diff --git a/src/PolarSSL++/CMakeLists.txt b/src/PolarSSL++/CMakeLists.txt index 9a59cdb2c..39d41292d 100644 --- a/src/PolarSSL++/CMakeLists.txt +++ b/src/PolarSSL++/CMakeLists.txt @@ -3,7 +3,7 @@ project (MCServer) include_directories ("${PROJECT_SOURCE_DIR}/../") -set(SOURCES +set(SRCS AesCfb128Decryptor.cpp AesCfb128Encryptor.cpp BlockingSslClientSocket.cpp @@ -18,7 +18,7 @@ set(SOURCES X509Cert.cpp ) -set(HEADERS +set(HDRS AesCfb128Decryptor.h AesCfb128Encryptor.h BlockingSslClientSocket.h @@ -33,8 +33,10 @@ set(HEADERS X509Cert.h ) -add_library(PolarSSL++ ${SOURCES} ${HEADERS}) +if(NOT MSVC) + add_library(PolarSSL++ ${SRCS} ${HDRS}) -if (UNIX) - target_link_libraries(PolarSSL++ polarssl) + if (UNIX) + target_link_libraries(PolarSSL++ polarssl) + endif() endif() -- cgit v1.2.3 From 0960e6ae8ffe329ecd78b2f0f433fcb9e817a696 Mon Sep 17 00:00:00 2001 From: archshift Date: Fri, 18 Jul 2014 19:25:15 -0700 Subject: Moved Windows custom command to src/CMakeLists.txt --- src/Bindings/CMakeLists.txt | 16 +--------------- src/CMakeLists.txt | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/src/Bindings/CMakeLists.txt b/src/Bindings/CMakeLists.txt index 723487ff0..4726eea23 100644 --- a/src/Bindings/CMakeLists.txt +++ b/src/Bindings/CMakeLists.txt @@ -112,21 +112,7 @@ set(BINDING_DEPENDECIES ../World.h ) -if (WIN32) - ADD_CUSTOM_COMMAND( - OUTPUT ${BINDING_OUTPUTS} - - # Copy the Lua DLL into the Bindings folder, so that tolua can run from there: - COMMAND ${CMAKE_COMMAND} -E copy_if_different ../../MCServer/lua51.dll ./lua51.dll - - # Regenerate bindings: - COMMAND tolua -L virtual_method_hooks.lua -o Bindings.cpp -H Bindings.h AllToLua.pkg - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - - # add any new generation dependencies here - DEPENDS ${BINDING_DEPENDECIES} - ) -else () +if (NOT WIN32) ADD_CUSTOM_COMMAND( # add any new generated bindings here OUTPUT ${BINDING_OUTPUTS} diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6008d3174..168c576e2 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -230,6 +230,25 @@ endif() set(EXECUTABLE MCServer) +if (WIN32) + get_directory_property(BINDING_OUTPUTS DIRECTORY "Bindings" DEFINITION BINDING_OUTPUTS) + get_directory_property(BINDING_DEPENDENCIES DIRECTORY "Bindings" DEFINITION BINDING_DEPENDENCIES) + + ADD_CUSTOM_COMMAND( + OUTPUT ${BINDING_OUTPUTS} + + # Copy the Lua DLL into the Bindings folder, so that tolua can run from there: + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_SOURCE_DIR}/MCServer/lua51.dll ./lua51.dll + + # Regenerate bindings: + COMMAND tolua -L Bindings/virtual_method_hooks.lua -o Bindings/Bindings.cpp -H Bindings/Bindings.h Bindings/AllToLua.pkg + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + + # add any new generation dependencies here + DEPENDS ${BINDING_DEPENDECIES} + ) +endif() + add_executable(${EXECUTABLE} ${SOURCE}) -- cgit v1.2.3 From f94cf4998040428c2940b5f0d4dd27d740838d6f Mon Sep 17 00:00:00 2001 From: archshift Date: Fri, 18 Jul 2014 21:38:55 -0700 Subject: Authenticator.cpp: Killed a global destructor warning --- src/Protocol/Authenticator.cpp | 109 +++++++++++++++++++++-------------------- 1 file changed, 56 insertions(+), 53 deletions(-) diff --git a/src/Protocol/Authenticator.cpp b/src/Protocol/Authenticator.cpp index 18924db2f..2a7cbc7bc 100644 --- a/src/Protocol/Authenticator.cpp +++ b/src/Protocol/Authenticator.cpp @@ -20,57 +20,60 @@ /** This is the data of the root certs for Starfield Technologies, the CA that signed sessionserver.mojang.com's cert: Downloaded from http://certs.starfieldtech.com/repository/ */ -static const AString gStarfieldCACert( - // G2 cert - "-----BEGIN CERTIFICATE-----\n" - "MIID3TCCAsWgAwIBAgIBADANBgkqhkiG9w0BAQsFADCBjzELMAkGA1UEBhMCVVMx\n" - "EDAOBgNVBAgTB0FyaXpvbmExEzARBgNVBAcTClNjb3R0c2RhbGUxJTAjBgNVBAoT\n" - "HFN0YXJmaWVsZCBUZWNobm9sb2dpZXMsIEluYy4xMjAwBgNVBAMTKVN0YXJmaWVs\n" - "ZCBSb290IENlcnRpZmljYXRlIEF1dGhvcml0eSAtIEcyMB4XDTA5MDkwMTAwMDAw\n" - "MFoXDTM3MTIzMTIzNTk1OVowgY8xCzAJBgNVBAYTAlVTMRAwDgYDVQQIEwdBcml6\n" - "b25hMRMwEQYDVQQHEwpTY290dHNkYWxlMSUwIwYDVQQKExxTdGFyZmllbGQgVGVj\n" - "aG5vbG9naWVzLCBJbmMuMTIwMAYDVQQDEylTdGFyZmllbGQgUm9vdCBDZXJ0aWZp\n" - "Y2F0ZSBBdXRob3JpdHkgLSBHMjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC\n" - "ggEBAL3twQP89o/8ArFvW59I2Z154qK3A2FWGMNHttfKPTUuiUP3oWmb3ooa/RMg\n" - "nLRJdzIpVv257IzdIvpy3Cdhl+72WoTsbhm5iSzchFvVdPtrX8WJpRBSiUZV9Lh1\n" - "HOZ/5FSuS/hVclcCGfgXcVnrHigHdMWdSL5stPSksPNkN3mSwOxGXn/hbVNMYq/N\n" - "Hwtjuzqd+/x5AJhhdM8mgkBj87JyahkNmcrUDnXMN/uLicFZ8WJ/X7NfZTD4p7dN\n" - "dloedl40wOiWVpmKs/B/pM293DIxfJHP4F8R+GuqSVzRmZTRouNjWwl2tVZi4Ut0\n" - "HZbUJtQIBFnQmA4O5t78w+wfkPECAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAO\n" - "BgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFHwMMh+n2TB/xH1oo2Kooc6rB1snMA0G\n" - "CSqGSIb3DQEBCwUAA4IBAQARWfolTwNvlJk7mh+ChTnUdgWUXuEok21iXQnCoKjU\n" - "sHU48TRqneSfioYmUeYs0cYtbpUgSpIB7LiKZ3sx4mcujJUDJi5DnUox9g61DLu3\n" - "4jd/IroAow57UvtruzvE03lRTs2Q9GcHGcg8RnoNAX3FWOdt5oUwF5okxBDgBPfg\n" - "8n/Uqgr/Qh037ZTlZFkSIHc40zI+OIF1lnP6aI+xy84fxez6nH7PfrHxBy22/L/K\n" - "pL/QlwVKvOoYKAKQvVR4CSFx09F9HdkWsKlhPdAKACL8x3vLCWRFCztAgfd9fDL1\n" - "mMpYjn0q7pBZc2T5NnReJaH1ZgUufzkVqSr7UIuOhWn0\n" - "-----END CERTIFICATE-----\n\n" - // Original (G1) cert: - "-----BEGIN CERTIFICATE-----\n" - "MIIEDzCCAvegAwIBAgIBADANBgkqhkiG9w0BAQUFADBoMQswCQYDVQQGEwJVUzEl\n" - "MCMGA1UEChMcU3RhcmZpZWxkIFRlY2hub2xvZ2llcywgSW5jLjEyMDAGA1UECxMp\n" - "U3RhcmZpZWxkIENsYXNzIDIgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMDQw\n" - "NjI5MTczOTE2WhcNMzQwNjI5MTczOTE2WjBoMQswCQYDVQQGEwJVUzElMCMGA1UE\n" - "ChMcU3RhcmZpZWxkIFRlY2hub2xvZ2llcywgSW5jLjEyMDAGA1UECxMpU3RhcmZp\n" - "ZWxkIENsYXNzIDIgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwggEgMA0GCSqGSIb3\n" - "DQEBAQUAA4IBDQAwggEIAoIBAQC3Msj+6XGmBIWtDBFk385N78gDGIc/oav7PKaf\n" - "8MOh2tTYbitTkPskpD6E8J7oX+zlJ0T1KKY/e97gKvDIr1MvnsoFAZMej2YcOadN\n" - "+lq2cwQlZut3f+dZxkqZJRRU6ybH838Z1TBwj6+wRir/resp7defqgSHo9T5iaU0\n" - "X9tDkYI22WY8sbi5gv2cOj4QyDvvBmVmepsZGD3/cVE8MC5fvj13c7JdBmzDI1aa\n" - "K4UmkhynArPkPw2vCHmCuDY96pzTNbO8acr1zJ3o/WSNF4Azbl5KXZnJHoe0nRrA\n" - "1W4TNSNe35tfPe/W93bC6j67eA0cQmdrBNj41tpvi/JEoAGrAgEDo4HFMIHCMB0G\n" - "A1UdDgQWBBS/X7fRzt0fhvRbVazc1xDCDqmI5zCBkgYDVR0jBIGKMIGHgBS/X7fR\n" - "zt0fhvRbVazc1xDCDqmI56FspGowaDELMAkGA1UEBhMCVVMxJTAjBgNVBAoTHFN0\n" - "YXJmaWVsZCBUZWNobm9sb2dpZXMsIEluYy4xMjAwBgNVBAsTKVN0YXJmaWVsZCBD\n" - "bGFzcyAyIENlcnRpZmljYXRpb24gQXV0aG9yaXR5ggEAMAwGA1UdEwQFMAMBAf8w\n" - "DQYJKoZIhvcNAQEFBQADggEBAAWdP4id0ckaVaGsafPzWdqbAYcaT1epoXkJKtv3\n" - "L7IezMdeatiDh6GX70k1PncGQVhiv45YuApnP+yz3SFmH8lU+nLMPUxA2IGvd56D\n" - "eruix/U0F47ZEUD0/CwqTRV/p2JdLiXTAAsgGh1o+Re49L2L7ShZ3U0WixeDyLJl\n" - "xy16paq8U4Zt3VekyvggQQto8PT7dL5WXXp59fkdheMtlb71cZBDzI0fmgAKhynp\n" - "VSJYACPq4xJDKVtHCN2MQWplBqjlIapBtJUhlbl90TSrE9atvNziPTnNvT51cKEY\n" - "WQPJIrSPnNVeKtelttQKbfi3QBFGmh95DmK/D5fs4C8fF5Q=\n" - "-----END CERTIFICATE-----\n" -); +static const AString StarfieldCACert() +{ + return AString( + // G2 cert + "-----BEGIN CERTIFICATE-----\n" + "MIID3TCCAsWgAwIBAgIBADANBgkqhkiG9w0BAQsFADCBjzELMAkGA1UEBhMCVVMx\n" + "EDAOBgNVBAgTB0FyaXpvbmExEzARBgNVBAcTClNjb3R0c2RhbGUxJTAjBgNVBAoT\n" + "HFN0YXJmaWVsZCBUZWNobm9sb2dpZXMsIEluYy4xMjAwBgNVBAMTKVN0YXJmaWVs\n" + "ZCBSb290IENlcnRpZmljYXRlIEF1dGhvcml0eSAtIEcyMB4XDTA5MDkwMTAwMDAw\n" + "MFoXDTM3MTIzMTIzNTk1OVowgY8xCzAJBgNVBAYTAlVTMRAwDgYDVQQIEwdBcml6\n" + "b25hMRMwEQYDVQQHEwpTY290dHNkYWxlMSUwIwYDVQQKExxTdGFyZmllbGQgVGVj\n" + "aG5vbG9naWVzLCBJbmMuMTIwMAYDVQQDEylTdGFyZmllbGQgUm9vdCBDZXJ0aWZp\n" + "Y2F0ZSBBdXRob3JpdHkgLSBHMjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC\n" + "ggEBAL3twQP89o/8ArFvW59I2Z154qK3A2FWGMNHttfKPTUuiUP3oWmb3ooa/RMg\n" + "nLRJdzIpVv257IzdIvpy3Cdhl+72WoTsbhm5iSzchFvVdPtrX8WJpRBSiUZV9Lh1\n" + "HOZ/5FSuS/hVclcCGfgXcVnrHigHdMWdSL5stPSksPNkN3mSwOxGXn/hbVNMYq/N\n" + "Hwtjuzqd+/x5AJhhdM8mgkBj87JyahkNmcrUDnXMN/uLicFZ8WJ/X7NfZTD4p7dN\n" + "dloedl40wOiWVpmKs/B/pM293DIxfJHP4F8R+GuqSVzRmZTRouNjWwl2tVZi4Ut0\n" + "HZbUJtQIBFnQmA4O5t78w+wfkPECAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAO\n" + "BgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFHwMMh+n2TB/xH1oo2Kooc6rB1snMA0G\n" + "CSqGSIb3DQEBCwUAA4IBAQARWfolTwNvlJk7mh+ChTnUdgWUXuEok21iXQnCoKjU\n" + "sHU48TRqneSfioYmUeYs0cYtbpUgSpIB7LiKZ3sx4mcujJUDJi5DnUox9g61DLu3\n" + "4jd/IroAow57UvtruzvE03lRTs2Q9GcHGcg8RnoNAX3FWOdt5oUwF5okxBDgBPfg\n" + "8n/Uqgr/Qh037ZTlZFkSIHc40zI+OIF1lnP6aI+xy84fxez6nH7PfrHxBy22/L/K\n" + "pL/QlwVKvOoYKAKQvVR4CSFx09F9HdkWsKlhPdAKACL8x3vLCWRFCztAgfd9fDL1\n" + "mMpYjn0q7pBZc2T5NnReJaH1ZgUufzkVqSr7UIuOhWn0\n" + "-----END CERTIFICATE-----\n\n" + // Original (G1) cert: + "-----BEGIN CERTIFICATE-----\n" + "MIIEDzCCAvegAwIBAgIBADANBgkqhkiG9w0BAQUFADBoMQswCQYDVQQGEwJVUzEl\n" + "MCMGA1UEChMcU3RhcmZpZWxkIFRlY2hub2xvZ2llcywgSW5jLjEyMDAGA1UECxMp\n" + "U3RhcmZpZWxkIENsYXNzIDIgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMDQw\n" + "NjI5MTczOTE2WhcNMzQwNjI5MTczOTE2WjBoMQswCQYDVQQGEwJVUzElMCMGA1UE\n" + "ChMcU3RhcmZpZWxkIFRlY2hub2xvZ2llcywgSW5jLjEyMDAGA1UECxMpU3RhcmZp\n" + "ZWxkIENsYXNzIDIgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwggEgMA0GCSqGSIb3\n" + "DQEBAQUAA4IBDQAwggEIAoIBAQC3Msj+6XGmBIWtDBFk385N78gDGIc/oav7PKaf\n" + "8MOh2tTYbitTkPskpD6E8J7oX+zlJ0T1KKY/e97gKvDIr1MvnsoFAZMej2YcOadN\n" + "+lq2cwQlZut3f+dZxkqZJRRU6ybH838Z1TBwj6+wRir/resp7defqgSHo9T5iaU0\n" + "X9tDkYI22WY8sbi5gv2cOj4QyDvvBmVmepsZGD3/cVE8MC5fvj13c7JdBmzDI1aa\n" + "K4UmkhynArPkPw2vCHmCuDY96pzTNbO8acr1zJ3o/WSNF4Azbl5KXZnJHoe0nRrA\n" + "1W4TNSNe35tfPe/W93bC6j67eA0cQmdrBNj41tpvi/JEoAGrAgEDo4HFMIHCMB0G\n" + "A1UdDgQWBBS/X7fRzt0fhvRbVazc1xDCDqmI5zCBkgYDVR0jBIGKMIGHgBS/X7fR\n" + "zt0fhvRbVazc1xDCDqmI56FspGowaDELMAkGA1UEBhMCVVMxJTAjBgNVBAoTHFN0\n" + "YXJmaWVsZCBUZWNobm9sb2dpZXMsIEluYy4xMjAwBgNVBAsTKVN0YXJmaWVsZCBD\n" + "bGFzcyAyIENlcnRpZmljYXRpb24gQXV0aG9yaXR5ggEAMAwGA1UdEwQFMAMBAf8w\n" + "DQYJKoZIhvcNAQEFBQADggEBAAWdP4id0ckaVaGsafPzWdqbAYcaT1epoXkJKtv3\n" + "L7IezMdeatiDh6GX70k1PncGQVhiv45YuApnP+yz3SFmH8lU+nLMPUxA2IGvd56D\n" + "eruix/U0F47ZEUD0/CwqTRV/p2JdLiXTAAsgGh1o+Re49L2L7ShZ3U0WixeDyLJl\n" + "xy16paq8U4Zt3VekyvggQQto8PT7dL5WXXp59fkdheMtlb71cZBDzI0fmgAKhynp\n" + "VSJYACPq4xJDKVtHCN2MQWplBqjlIapBtJUhlbl90TSrE9atvNziPTnNvT51cKEY\n" + "WQPJIrSPnNVeKtelttQKbfi3QBFGmh95DmK/D5fs4C8fF5Q=\n" + "-----END CERTIFICATE-----\n" + ); +} @@ -263,7 +266,7 @@ bool cAuthenticator::AuthWithYggdrasil(AString & a_UserName, const AString & a_S Request += "\r\n"; AString Response; - if (!SecureGetFromAddress(gStarfieldCACert, m_Server, Request, Response)) + if (!SecureGetFromAddress(StarfieldCACert(), m_Server, Request, Response)) { return false; } @@ -343,7 +346,7 @@ bool cAuthenticator::GetPlayerProperties(const AString & a_UUID, Json::Value & a Request += "\r\n"; AString Response; - if (!ConnectSecurelyToAddress(gStarfieldCACert, m_Server, Request, Response)) + if (!ConnectSecurelyToAddress(StarfieldCACert(), m_Server, Request, Response)) { return false; } -- cgit v1.2.3 From c7b7938c04eb5bd801274f93465afdb2f63053c0 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 19 Jul 2014 09:57:03 +0200 Subject: Renamed AllToLua_lua script. Fixes #1222. --- src/Bindings/AllToLua_lua.bat | 27 +++++++++++++++++++++++++++ src/Bindings/AllToLua_lua.bat.bat | 27 --------------------------- 2 files changed, 27 insertions(+), 27 deletions(-) create mode 100644 src/Bindings/AllToLua_lua.bat delete mode 100644 src/Bindings/AllToLua_lua.bat.bat diff --git a/src/Bindings/AllToLua_lua.bat b/src/Bindings/AllToLua_lua.bat new file mode 100644 index 000000000..81c738f32 --- /dev/null +++ b/src/Bindings/AllToLua_lua.bat @@ -0,0 +1,27 @@ + +:: AllToLua_Lua.bat +:: This scripts updates the automatically-generates Lua bindings in Bindings.cpp / Bindings.h +:: When called without any parameters, it will pause for a keypress at the end +:: Call with any parameter to disable the wait (for buildserver use) +:: This script assumes "lua" executable to be in PATH, it uses a pure-lua implementation of the ToLua processor + +@echo off + + + + + +:: Regenerate the files: +echo Regenerating LUA bindings . . . +lua ..\..\lib\tolua++\src\bin\lua\_driver.lua -L virtual_method_hooks.lua -o Bindings.cpp -H Bindings.h AllToLua.pkg + + + + +: Wait for keypress, if no param given: +echo. +if %ALLTOLUA_WAIT%N == N pause + + + + diff --git a/src/Bindings/AllToLua_lua.bat.bat b/src/Bindings/AllToLua_lua.bat.bat deleted file mode 100644 index 81c738f32..000000000 --- a/src/Bindings/AllToLua_lua.bat.bat +++ /dev/null @@ -1,27 +0,0 @@ - -:: AllToLua_Lua.bat -:: This scripts updates the automatically-generates Lua bindings in Bindings.cpp / Bindings.h -:: When called without any parameters, it will pause for a keypress at the end -:: Call with any parameter to disable the wait (for buildserver use) -:: This script assumes "lua" executable to be in PATH, it uses a pure-lua implementation of the ToLua processor - -@echo off - - - - - -:: Regenerate the files: -echo Regenerating LUA bindings . . . -lua ..\..\lib\tolua++\src\bin\lua\_driver.lua -L virtual_method_hooks.lua -o Bindings.cpp -H Bindings.h AllToLua.pkg - - - - -: Wait for keypress, if no param given: -echo. -if %ALLTOLUA_WAIT%N == N pause - - - - -- cgit v1.2.3 From 041bfd5860cd8ef51db42eb6fb4b50b45549feba Mon Sep 17 00:00:00 2001 From: archshift Date: Sat, 19 Jul 2014 01:40:29 -0700 Subject: Fixed clamping issues --- src/ChunkMap.cpp | 5 +---- src/Defines.h | 13 +------------ src/Entities/Entity.cpp | 5 +---- src/Entities/Player.cpp | 5 +---- src/Entities/SplashPotionEntity.cpp | 5 +---- src/Mobs/Monster.cpp | 6 +----- 6 files changed, 6 insertions(+), 33 deletions(-) diff --git a/src/ChunkMap.cpp b/src/ChunkMap.cpp index e91f77d27..49e9245d2 100644 --- a/src/ChunkMap.cpp +++ b/src/ChunkMap.cpp @@ -1951,10 +1951,7 @@ void cChunkMap::DoExplosionAt(double a_ExplosionSize, double a_BlockX, double a_ double FinalDamage = (((1 / AbsoluteEntityPos.x) + (1 / AbsoluteEntityPos.y) + (1 / AbsoluteEntityPos.z)) * 2) * m_ExplosionSize; // Clip damage values - if (FinalDamage > a_Entity->GetMaxHealth()) - FinalDamage = a_Entity->GetMaxHealth(); - else if (FinalDamage < 0) - FinalDamage = 0; + FinalDamage = Clamp(FinalDamage, 0.0, (double)a_Entity->GetMaxHealth()); if (!a_Entity->IsTNT() && !a_Entity->IsFallingBlock()) // Don't apply damage to other TNT entities and falling blocks, they should be invincible { diff --git a/src/Defines.h b/src/Defines.h index f57e63c7f..f7c8d0fc5 100644 --- a/src/Defines.h +++ b/src/Defines.h @@ -470,18 +470,7 @@ inline void AddFaceDirection(int & a_BlockX, unsigned char & a_BlockY, int & a_B { int Y = a_BlockY; AddFaceDirection(a_BlockX, Y, a_BlockZ, a_BlockFace, a_bInverse); - if (Y < 0) - { - a_BlockY = 0; - } - else if (Y > 255) - { - a_BlockY = 255; - } - else - { - a_BlockY = (unsigned char)Y; - } + a_BlockY = Clamp(Y, 0, 255); } diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index 61b28ec70..f9331ede8 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -327,10 +327,7 @@ bool cEntity::DoTakeDamage(TakeDamageInfo & a_TDI) // TODO: Apply damage to armor - if (m_Health < 0) - { - m_Health = 0; - } + m_Health = std::max(m_Health, 0); if ((IsMob() || IsPlayer()) && (a_TDI.Attacker != NULL)) // Knockback for only players and mobs { diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index ea11926b8..7376441b4 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -382,10 +382,7 @@ short cPlayer::DeltaExperience(short a_Xp_delta) m_CurrentXp += a_Xp_delta; // Make sure they didn't subtract too much - if (m_CurrentXp < 0) - { - m_CurrentXp = 0; - } + m_CurrentXp = std::max(m_CurrentXp, 0); // Update total for score calculation if (a_Xp_delta > 0) diff --git a/src/Entities/SplashPotionEntity.cpp b/src/Entities/SplashPotionEntity.cpp index 3efb1f25d..ccadf9c8e 100644 --- a/src/Entities/SplashPotionEntity.cpp +++ b/src/Entities/SplashPotionEntity.cpp @@ -44,10 +44,7 @@ public: // y = -0.25x + 1, where x is the distance from the player. Approximation for potion splash. // TODO: better equation double Reduction = -0.25 * SplashDistance + 1.0; - if (Reduction < 0) - { - Reduction = 0; - } + Reduction = std::max(Reduction, 0.0); ((cPawn *) a_Entity)->AddEntityEffect(m_EntityEffectType, m_EntityEffect.GetDuration(), m_EntityEffect.GetIntensity(), Reduction); return false; diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp index e6c82a448..8d612fbaa 100644 --- a/src/Mobs/Monster.cpp +++ b/src/Mobs/Monster.cpp @@ -414,11 +414,7 @@ void cMonster::HandleFalling() int cMonster::FindFirstNonAirBlockPosition(double a_PosX, double a_PosZ) { int PosY = POSY_TOINT; - - if (PosY < 0) - PosY = 0; - else if (PosY > cChunkDef::Height) - PosY = cChunkDef::Height; + PosY = Clamp(PosY, 0, cChunkDef::Height); if (!cBlockInfo::IsSolid(m_World->GetBlock((int)floor(a_PosX), PosY, (int)floor(a_PosZ)))) { -- cgit v1.2.3 From 93c6520e1e6fa957c5d7b7aee71b7ae7e462d77d Mon Sep 17 00:00:00 2001 From: archshift Date: Sat, 19 Jul 2014 02:46:31 -0700 Subject: Fixed splash potion color on toss --- src/Entities/SplashPotionEntity.cpp | 14 ++++++++++++++ src/Entities/SplashPotionEntity.h | 2 ++ 2 files changed, 16 insertions(+) diff --git a/src/Entities/SplashPotionEntity.cpp b/src/Entities/SplashPotionEntity.cpp index 3efb1f25d..c379ab3fb 100644 --- a/src/Entities/SplashPotionEntity.cpp +++ b/src/Entities/SplashPotionEntity.cpp @@ -2,11 +2,15 @@ #include "SplashPotionEntity.h" #include "Pawn.h" +#include "../ClientHandle.h" +/// Converts an angle in radians into a byte representation used by the network protocol +#define ANGLE_TO_PROTO(X) (Byte)(X * 255 / 360) + //////////////////////////////////////////////////////////////////////////////// // cSplashPotionEntityCallback: @@ -118,3 +122,13 @@ void cSplashPotionEntity::Splash(const Vector3d & a_HitPos) + +void cSplashPotionEntity::SpawnOn(cClientHandle & a_Client) +{ + a_Client.SendSpawnObject(*this, 73, m_PotionParticleType, ANGLE_TO_PROTO(GetYaw()), ANGLE_TO_PROTO(GetPitch())); + a_Client.SendEntityMetadata(*this); +} + + + + diff --git a/src/Entities/SplashPotionEntity.h b/src/Entities/SplashPotionEntity.h index 2c78b55d2..1e056de68 100644 --- a/src/Entities/SplashPotionEntity.h +++ b/src/Entities/SplashPotionEntity.h @@ -56,4 +56,6 @@ protected: /** Splashes the potion, fires its particle effects and sounds @param a_HitPos The position where the potion will splash */ void Splash(const Vector3d & a_HitPos); + + virtual void SpawnOn(cClientHandle & a_Client) override; } ; // tolua_export -- cgit v1.2.3 From f5bcfdc58c7b5d69abbb222787bb2229c0b54088 Mon Sep 17 00:00:00 2001 From: archshift Date: Sat, 19 Jul 2014 02:51:39 -0700 Subject: Splash potions: Renamed PotionParticleType to PotionColor for clarity --- src/Entities/SplashPotionEntity.cpp | 8 ++++---- src/Entities/SplashPotionEntity.h | 12 ++++++------ src/Items/ItemPotion.h | 6 +++--- src/WorldStorage/NBTChunkSerializer.cpp | 2 +- src/WorldStorage/WSSAnvil.cpp | 2 +- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/Entities/SplashPotionEntity.cpp b/src/Entities/SplashPotionEntity.cpp index c379ab3fb..056700629 100644 --- a/src/Entities/SplashPotionEntity.cpp +++ b/src/Entities/SplashPotionEntity.cpp @@ -76,12 +76,12 @@ cSplashPotionEntity::cSplashPotionEntity( const Vector3d & a_Speed, cEntityEffect::eType a_EntityEffectType, cEntityEffect a_EntityEffect, - int a_PotionParticleType + int a_PotionColor ) : super(pkSplashPotion, a_Creator, a_X, a_Y, a_Z, 0.25, 0.25), m_EntityEffectType(a_EntityEffectType), m_EntityEffect(a_EntityEffect), - m_PotionParticleType(a_PotionParticleType) + m_PotionColor(a_PotionColor) { SetSpeed(a_Speed); } @@ -116,7 +116,7 @@ void cSplashPotionEntity::Splash(const Vector3d & a_HitPos) cSplashPotionCallback Callback(a_HitPos, m_EntityEffectType, m_EntityEffect); m_World->ForEachEntity(Callback); - m_World->BroadcastSoundParticleEffect(2002, (int)a_HitPos.x, (int)a_HitPos.y, (int)a_HitPos.z, m_PotionParticleType); + m_World->BroadcastSoundParticleEffect(2002, (int)a_HitPos.x, (int)a_HitPos.y, (int)a_HitPos.z, m_PotionColor); } @@ -125,7 +125,7 @@ void cSplashPotionEntity::Splash(const Vector3d & a_HitPos) void cSplashPotionEntity::SpawnOn(cClientHandle & a_Client) { - a_Client.SendSpawnObject(*this, 73, m_PotionParticleType, ANGLE_TO_PROTO(GetYaw()), ANGLE_TO_PROTO(GetPitch())); + a_Client.SendSpawnObject(*this, 73, m_PotionColor, ANGLE_TO_PROTO(GetYaw()), ANGLE_TO_PROTO(GetPitch())); a_Client.SendEntityMetadata(*this); } diff --git a/src/Entities/SplashPotionEntity.h b/src/Entities/SplashPotionEntity.h index 1e056de68..a33b06990 100644 --- a/src/Entities/SplashPotionEntity.h +++ b/src/Entities/SplashPotionEntity.h @@ -31,22 +31,22 @@ public: const Vector3d & a_Speed, cEntityEffect::eType a_EntityEffectType, cEntityEffect a_EntityEffect, - int a_PotionParticleType + int a_PotionColor ); - cEntityEffect::eType GetEntityEffectType (void) const { return m_EntityEffectType; } - cEntityEffect GetEntityEffect (void) const { return m_EntityEffect; } - int GetPotionParticleType(void) const { return m_PotionParticleType; } + cEntityEffect::eType GetEntityEffectType(void) const { return m_EntityEffectType; } + cEntityEffect GetEntityEffect(void) const { return m_EntityEffect; } + int GetPotionColor(void) const { return m_PotionColor; } void SetEntityEffectType(cEntityEffect::eType a_EntityEffectType) { m_EntityEffectType = a_EntityEffectType; } void SetEntityEffect(cEntityEffect a_EntityEffect) { m_EntityEffect = a_EntityEffect; } - void SetPotionParticleType(int a_PotionParticleType) { m_PotionParticleType = a_PotionParticleType; } + void SetPotionColor(int a_PotionColor) { m_PotionColor = a_PotionColor; } protected: cEntityEffect::eType m_EntityEffectType; cEntityEffect m_EntityEffect; - int m_PotionParticleType; + int m_PotionColor; // cProjectileEntity overrides: diff --git a/src/Items/ItemPotion.h b/src/Items/ItemPotion.h index f3afbf99b..f16d89b39 100644 --- a/src/Items/ItemPotion.h +++ b/src/Items/ItemPotion.h @@ -17,8 +17,8 @@ public: } - /** Returns the potion particle type (used by the client for visuals), based on the potion's damage value */ - static int GetPotionParticleType(short a_ItemDamage) + /** Returns the potion color (used by the client for visuals), based on the potion's damage value */ + static int GetPotionColor(short a_ItemDamage) { // Lowest six bits return (a_ItemDamage & 0x3f); @@ -156,7 +156,7 @@ public: cSplashPotionEntity * Projectile = new cSplashPotionEntity( a_Player, Pos.x, Pos.y, Pos.z, Speed, GetEntityEffectType(PotionDamage), cEntityEffect(GetEntityEffectDuration(PotionDamage), - GetEntityEffectIntensity(PotionDamage)), GetPotionParticleType(PotionDamage) + GetEntityEffectIntensity(PotionDamage)), GetPotionColor(PotionDamage) ); if (Projectile == NULL) { diff --git a/src/WorldStorage/NBTChunkSerializer.cpp b/src/WorldStorage/NBTChunkSerializer.cpp index e68903b26..62db302ef 100644 --- a/src/WorldStorage/NBTChunkSerializer.cpp +++ b/src/WorldStorage/NBTChunkSerializer.cpp @@ -613,7 +613,7 @@ void cNBTChunkSerializer::AddProjectileEntity(cProjectileEntity * a_Projectile) m_Writer.AddInt("EffectDuration", (Int16)Potion->GetEntityEffect().GetDuration()); m_Writer.AddShort("EffectIntensity", Potion->GetEntityEffect().GetIntensity()); m_Writer.AddDouble("EffectDistanceModifier", Potion->GetEntityEffect().GetDistanceModifier()); - m_Writer.AddInt("PotionName", Potion->GetPotionParticleType()); + m_Writer.AddInt("PotionName", Potion->GetPotionColor()); } case cProjectileEntity::pkGhastFireball: { diff --git a/src/WorldStorage/WSSAnvil.cpp b/src/WorldStorage/WSSAnvil.cpp index b4048b097..663d489bc 100644 --- a/src/WorldStorage/WSSAnvil.cpp +++ b/src/WorldStorage/WSSAnvil.cpp @@ -1681,7 +1681,7 @@ void cWSSAnvil::LoadSplashPotionFromNBT(cEntityList & a_Entities, const cParsedN SplashPotion->SetEntityEffectType((cEntityEffect::eType) a_NBT.FindChildByName(a_TagIdx, "EffectType")); SplashPotion->SetEntityEffect(cEntityEffect(EffectDuration, EffectIntensity, EffectDistanceModifier)); - SplashPotion->SetPotionParticleType(a_NBT.FindChildByName(a_TagIdx, "PotionName")); + SplashPotion->SetPotionColor(a_NBT.FindChildByName(a_TagIdx, "PotionName")); // Store the new splash potion in the entities list: a_Entities.push_back(SplashPotion.release()); -- cgit v1.2.3 From f86eefa2ae07c32772f4353f14de9625dc9c20de Mon Sep 17 00:00:00 2001 From: archshift Date: Sat, 19 Jul 2014 02:54:44 -0700 Subject: Trees.cpp: removed unused "debug" fields --- src/Generating/Trees.cpp | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/Generating/Trees.cpp b/src/Generating/Trees.cpp index b7a08999d..c40322630 100644 --- a/src/Generating/Trees.cpp +++ b/src/Generating/Trees.cpp @@ -10,13 +10,6 @@ -// DEBUG: -int gTotalLargeJungleTrees = 0; -int gOversizeLargeJungleTrees = 0; - - - - typedef struct { @@ -113,6 +106,7 @@ inline void PushCoordBlocks(int a_BlockX, int a_Height, int a_BlockZ, sSetBlockV + inline void PushCornerBlocks(int a_BlockX, int a_Height, int a_BlockZ, int a_Seq, cNoise & a_Noise, int a_Chance, sSetBlockVector & a_Blocks, int a_CornersDist, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta) { for (size_t i = 0; i < ARRAYCOUNT(Corners); i++) -- cgit v1.2.3 From 7c861f98a2933e125f100f239d0ae5e977d1a719 Mon Sep 17 00:00:00 2001 From: archshift Date: Sat, 19 Jul 2014 02:55:36 -0700 Subject: Minecart: slimmed down SpawnOn by keeping subtype in the payload enum --- src/Entities/Minecart.cpp | 16 +--------------- src/Entities/Minecart.h | 11 ++++++----- 2 files changed, 7 insertions(+), 20 deletions(-) diff --git a/src/Entities/Minecart.cpp b/src/Entities/Minecart.cpp index 03850c8a7..d4eadc5d5 100644 --- a/src/Entities/Minecart.cpp +++ b/src/Entities/Minecart.cpp @@ -103,21 +103,7 @@ cMinecart::cMinecart(ePayload a_Payload, double a_X, double a_Y, double a_Z) : void cMinecart::SpawnOn(cClientHandle & a_ClientHandle) { - char SubType = 0; - switch (m_Payload) - { - case mpNone: SubType = 0; break; - case mpChest: SubType = 1; break; - case mpFurnace: SubType = 2; break; - case mpTNT: SubType = 3; break; - case mpHopper: SubType = 5; break; - default: - { - ASSERT(!"Unknown payload, cannot spawn on client"); - return; - } - } - a_ClientHandle.SendSpawnVehicle(*this, 10, SubType); // 10 = Minecarts, SubType = What type of Minecart + a_ClientHandle.SendSpawnVehicle(*this, 10, (char)m_Payload); // 10 = Minecarts a_ClientHandle.SendEntityMetadata(*this); } diff --git a/src/Entities/Minecart.h b/src/Entities/Minecart.h index 798f844ce..c585cfab0 100644 --- a/src/Entities/Minecart.h +++ b/src/Entities/Minecart.h @@ -23,13 +23,14 @@ class cMinecart : public: CLASS_PROTODEF(cMinecart); + /** Minecart payload, values correspond to packet subtype */ enum ePayload { - mpNone, // Empty minecart, ridable by player or mobs - mpChest, // Minecart-with-chest, can store a grid of 3*8 items - mpFurnace, // Minecart-with-furnace, can be powered - mpTNT, // Minecart-with-TNT, can be blown up with activator rail - mpHopper, // Minecart-with-hopper, can be hopper + mpNone = 0, // Empty minecart, ridable by player or mobs + mpChest = 1, // Minecart-with-chest, can store a grid of 3*8 items + mpFurnace = 2, // Minecart-with-furnace, can be powered + mpTNT = 3, // Minecart-with-TNT, can be blown up with activator rail + mpHopper = 5, // Minecart-with-hopper, can be hopper // TODO: Spawner minecarts, (and possibly any block in a minecart with NBT editing) } ; -- cgit v1.2.3 From 11f8198a8054e2b50df3fdbd8a59a876d7db87f0 Mon Sep 17 00:00:00 2001 From: archshift Date: Sat, 19 Jul 2014 02:56:46 -0700 Subject: World.cpp: fixed not all enum fields being used in m_Dimension switch --- src/World.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/World.cpp b/src/World.cpp index 186842b20..c27fd462b 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -570,12 +570,13 @@ void cWorld::Start(void) m_TNTShrapnelLevel = (eShrapnelLevel)Clamp(TNTShrapnelLevel, (int)slNone, (int)slAll); // Load allowed mobs: - const char * DefaultMonsters = ""; + AString DefaultMonsters; switch (m_Dimension) { case dimOverworld: DefaultMonsters = "bat, cavespider, chicken, cow, creeper, enderman, horse, mooshroom, ocelot, pig, sheep, silverfish, skeleton, slime, spider, squid, wolf, zombie"; break; case dimNether: DefaultMonsters = "blaze, ghast, magmacube, skeleton, zombie, zombiepigman"; break; case dimEnd: DefaultMonsters = "enderman"; break; + case dimNotSet: break; } m_bAnimals = IniFile.GetValueSetB("Monsters", "AnimalsOn", true); AString AllMonsters = IniFile.GetValueSet("Monsters", "Types", DefaultMonsters); -- cgit v1.2.3 From 9e7958e7fbb5a2477e04d30724730e15335b969f Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 19 Jul 2014 13:22:16 +0200 Subject: Fixed MSVC bindings generation. --- src/Bindings/CMakeLists.txt | 2 +- src/CMakeLists.txt | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Bindings/CMakeLists.txt b/src/Bindings/CMakeLists.txt index 4726eea23..95b858f5d 100644 --- a/src/Bindings/CMakeLists.txt +++ b/src/Bindings/CMakeLists.txt @@ -112,7 +112,7 @@ set(BINDING_DEPENDECIES ../World.h ) -if (NOT WIN32) +if (NOT MSVC) ADD_CUSTOM_COMMAND( # add any new generated bindings here OUTPUT ${BINDING_OUTPUTS} diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 168c576e2..9feaf64fe 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -230,7 +230,7 @@ endif() set(EXECUTABLE MCServer) -if (WIN32) +if (MSVC) get_directory_property(BINDING_OUTPUTS DIRECTORY "Bindings" DEFINITION BINDING_OUTPUTS) get_directory_property(BINDING_DEPENDENCIES DIRECTORY "Bindings" DEFINITION BINDING_DEPENDENCIES) @@ -241,8 +241,8 @@ if (WIN32) COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_SOURCE_DIR}/MCServer/lua51.dll ./lua51.dll # Regenerate bindings: - COMMAND tolua -L Bindings/virtual_method_hooks.lua -o Bindings/Bindings.cpp -H Bindings/Bindings.h Bindings/AllToLua.pkg - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + COMMAND tolua -L virtual_method_hooks.lua -o Bindings.cpp -H Bindings.h AllToLua.pkg + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/ # add any new generation dependencies here DEPENDS ${BINDING_DEPENDECIES} -- cgit v1.2.3 From 00c524519ef6c7ceaf4ac91307617cfd65d7cf21 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 19 Jul 2014 14:53:41 +0200 Subject: Fixed style: spaces after commas. --- src/Bindings/DeprecatedBindings.cpp | 38 +++++++++++++------------- src/Bindings/LuaState.cpp | 3 +- src/Bindings/ManualBindings.cpp | 26 +++++++++--------- src/Blocks/BlockBed.cpp | 2 +- src/Blocks/BlockBed.h | 2 +- src/Blocks/BlockLadder.h | 2 +- src/Blocks/BlockLeaves.h | 2 +- src/Blocks/BlockPortal.h | 4 +-- src/Blocks/ChunkInterface.h | 2 +- src/BoundingBox.cpp | 2 +- src/BoundingBox.h | 2 +- src/Chunk.cpp | 6 ++-- src/ClientHandle.cpp | 4 +-- src/CraftingRecipes.h | 2 +- src/Entities/TNTEntity.cpp | 2 +- src/Generating/Caves.cpp | 2 +- src/Generating/ChunkGenerator.cpp | 2 +- src/Generating/Ravines.cpp | 12 ++++---- src/Generating/Trees.h | 2 +- src/Globals.h | 2 +- src/GroupManager.cpp | 4 +-- src/Items/ItemBucket.h | 2 +- src/Items/ItemShovel.h | 2 +- src/Log.cpp | 2 +- src/MobProximityCounter.cpp | 8 +++--- src/MobProximityCounter.h | 4 +-- src/MobSpawner.cpp | 2 +- src/Mobs/Monster.cpp | 2 +- src/Mobs/Monster.h | 2 +- src/OSSupport/Socket.cpp | 2 +- src/OSSupport/Thread.cpp | 8 +++--- src/Protocol/Protocol17x.cpp | 2 +- src/Protocol/ProtocolRecognizer.cpp | 2 +- src/Simulator/FireSimulator.cpp | 2 +- src/Simulator/IncrementalRedstoneSimulator.cpp | 10 +++---- src/StringUtils.cpp | 8 +++--- src/Tracer.cpp | 6 ++-- src/World.cpp | 2 +- src/World.h | 2 +- src/WorldStorage/WSSAnvil.h | 2 +- src/WorldStorage/WorldStorage.cpp | 6 ++-- src/WorldStorage/WorldStorage.h | 2 +- 42 files changed, 100 insertions(+), 101 deletions(-) diff --git a/src/Bindings/DeprecatedBindings.cpp b/src/Bindings/DeprecatedBindings.cpp index d2e60945d..07b1a29fd 100644 --- a/src/Bindings/DeprecatedBindings.cpp +++ b/src/Bindings/DeprecatedBindings.cpp @@ -25,9 +25,9 @@ static int tolua_get_AllToLua_g_BlockLightValue(lua_State* tolua_S) #ifndef TOLUA_RELEASE { tolua_Error tolua_err; - if (!tolua_isnumber(tolua_S,2,0,&tolua_err)) + if (!tolua_isnumber(tolua_S, 2, 0, &tolua_err)) { - tolua_error(tolua_S,"#vinvalid type in array indexing.",&tolua_err); + tolua_error(tolua_S, "#vinvalid type in array indexing.", &tolua_err); } } #endif @@ -36,7 +36,7 @@ static int tolua_get_AllToLua_g_BlockLightValue(lua_State* tolua_S) { tolua_error(tolua_S, "array indexing out of range.", NULL); } - tolua_pushnumber(tolua_S,(lua_Number)cBlockInfo::GetLightValue((BLOCKTYPE)BlockType)); + tolua_pushnumber(tolua_S, (lua_Number)cBlockInfo::GetLightValue((BLOCKTYPE)BlockType)); return 1; } #endif // #ifndef TOLUA_DISABLE @@ -53,8 +53,8 @@ static int tolua_get_AllToLua_g_BlockSpreadLightFalloff(lua_State* tolua_S) #ifndef TOLUA_RELEASE { tolua_Error tolua_err; - if (!tolua_isnumber(tolua_S,2,0,&tolua_err)) - tolua_error(tolua_S,"#vinvalid type in array indexing.",&tolua_err); + if (!tolua_isnumber(tolua_S, 2, 0, &tolua_err)) + tolua_error(tolua_S, "#vinvalid type in array indexing.", &tolua_err); } #endif BlockType = (int)tolua_tonumber(tolua_S, 2, 0); @@ -79,8 +79,8 @@ static int tolua_get_AllToLua_g_BlockTransparent(lua_State* tolua_S) #ifndef TOLUA_RELEASE { tolua_Error tolua_err; - if (!tolua_isnumber(tolua_S,2,0,&tolua_err)) - tolua_error(tolua_S,"#vinvalid type in array indexing.",&tolua_err); + if (!tolua_isnumber(tolua_S, 2, 0, &tolua_err)) + tolua_error(tolua_S, "#vinvalid type in array indexing.", &tolua_err); } #endif BlockType = (int)tolua_tonumber(tolua_S, 2, 0); @@ -105,8 +105,8 @@ static int tolua_get_AllToLua_g_BlockOneHitDig(lua_State* tolua_S) #ifndef TOLUA_RELEASE { tolua_Error tolua_err; - if (!tolua_isnumber(tolua_S,2,0,&tolua_err)) - tolua_error(tolua_S,"#vinvalid type in array indexing.",&tolua_err); + if (!tolua_isnumber(tolua_S, 2, 0, &tolua_err)) + tolua_error(tolua_S, "#vinvalid type in array indexing.", &tolua_err); } #endif BlockType = (int)tolua_tonumber(tolua_S, 2, 0); @@ -131,8 +131,8 @@ static int tolua_get_AllToLua_g_BlockPistonBreakable(lua_State* tolua_S) #ifndef TOLUA_RELEASE { tolua_Error tolua_err; - if (!tolua_isnumber(tolua_S,2,0,&tolua_err)) - tolua_error(tolua_S,"#vinvalid type in array indexing.",&tolua_err); + if (!tolua_isnumber(tolua_S, 2, 0, &tolua_err)) + tolua_error(tolua_S, "#vinvalid type in array indexing.", &tolua_err); } #endif BlockType = (int)tolua_tonumber(tolua_S, 2, 0); @@ -157,8 +157,8 @@ static int tolua_get_AllToLua_g_BlockIsSnowable(lua_State* tolua_S) #ifndef TOLUA_RELEASE { tolua_Error tolua_err; - if (!tolua_isnumber(tolua_S,2,0,&tolua_err)) - tolua_error(tolua_S,"#vinvalid type in array indexing.",&tolua_err); + if (!tolua_isnumber(tolua_S, 2, 0, &tolua_err)) + tolua_error(tolua_S, "#vinvalid type in array indexing.", &tolua_err); } #endif BlockType = (int)tolua_tonumber(tolua_S, 2, 0); @@ -183,8 +183,8 @@ static int tolua_get_AllToLua_g_BlockRequiresSpecialTool(lua_State* tolua_S) #ifndef TOLUA_RELEASE { tolua_Error tolua_err; - if (!tolua_isnumber(tolua_S,2,0,&tolua_err)) - tolua_error(tolua_S,"#vinvalid type in array indexing.",&tolua_err); + if (!tolua_isnumber(tolua_S, 2, 0, &tolua_err)) + tolua_error(tolua_S, "#vinvalid type in array indexing.", &tolua_err); } #endif BlockType = (int)tolua_tonumber(tolua_S, 2, 0); @@ -209,8 +209,8 @@ static int tolua_get_AllToLua_g_BlockIsSolid(lua_State* tolua_S) #ifndef TOLUA_RELEASE { tolua_Error tolua_err; - if (!tolua_isnumber(tolua_S,2,0,&tolua_err)) - tolua_error(tolua_S,"#vinvalid type in array indexing.",&tolua_err); + if (!tolua_isnumber(tolua_S, 2, 0, &tolua_err)) + tolua_error(tolua_S, "#vinvalid type in array indexing.", &tolua_err); } #endif BlockType = (int)tolua_tonumber(tolua_S, 2, 0); @@ -235,8 +235,8 @@ static int tolua_get_AllToLua_g_BlockFullyOccupiesVoxel(lua_State* tolua_S) #ifndef TOLUA_RELEASE { tolua_Error tolua_err; - if (!tolua_isnumber(tolua_S,2,0,&tolua_err)) - tolua_error(tolua_S,"#vinvalid type in array indexing.",&tolua_err); + if (!tolua_isnumber(tolua_S, 2, 0, &tolua_err)) + tolua_error(tolua_S, "#vinvalid type in array indexing.", &tolua_err); } #endif BlockType = (int)tolua_tonumber(tolua_S, 2, 0); diff --git a/src/Bindings/LuaState.cpp b/src/Bindings/LuaState.cpp index 7d918cf2b..e123a87c9 100644 --- a/src/Bindings/LuaState.cpp +++ b/src/Bindings/LuaState.cpp @@ -1336,9 +1336,8 @@ void cLuaState::LogStack(lua_State * a_LuaState, const char * a_Header) { UNUSED(a_Header); // The param seems unused when compiling for release, so the compiler warns - // Format string consisting only of %s is used to appease the compiler - LOGD("%s",(a_Header != NULL) ? a_Header : "Lua C API Stack contents:"); + LOGD("%s", (a_Header != NULL) ? a_Header : "Lua C API Stack contents:"); for (int i = lua_gettop(a_LuaState); i > 0; i--) { AString Value; diff --git a/src/Bindings/ManualBindings.cpp b/src/Bindings/ManualBindings.cpp index 530101d47..4047adc3a 100644 --- a/src/Bindings/ManualBindings.cpp +++ b/src/Bindings/ManualBindings.cpp @@ -958,7 +958,7 @@ tolua_lerror: static int tolua_cWorld_TryGetHeight(lua_State * tolua_S) { // Exported manually, because tolua would require the out-only param a_Height to be used when calling - // Takes (a_World,) a_BlockX, a_BlockZ + // Takes a_World, a_BlockX, a_BlockZ // Returns Height, IsValid #ifndef TOLUA_RELEASE tolua_Error tolua_err; @@ -1926,12 +1926,12 @@ static int tolua_cPluginLua_AddWebTab(lua_State * tolua_S) int Reference = LUA_REFNIL; if ( - tolua_isstring(tolua_S, 2, 0, &tolua_err ) && - lua_isfunction(tolua_S, 3 ) + tolua_isstring(tolua_S, 2, 0, &tolua_err) && + lua_isfunction(tolua_S, 3) ) { Reference = luaL_ref(tolua_S, LUA_REGISTRYINDEX); - Title = ((std::string) tolua_tocppstring(tolua_S,2,0)); + Title = ((std::string)tolua_tocppstring(tolua_S, 2, 0)); } else { @@ -2591,7 +2591,7 @@ static int tolua_cBlockArea_LoadFromSchematicFile(lua_State * tolua_S) } AString Filename = tolua_tostring(tolua_S, 2, 0); - bool res = cSchematicFileSerializer::LoadFromSchematicFile(*self,Filename); + bool res = cSchematicFileSerializer::LoadFromSchematicFile(*self, Filename); tolua_pushboolean(tolua_S, res); return 1; } @@ -2651,7 +2651,7 @@ static int tolua_cBlockArea_SaveToSchematicFile(lua_State * tolua_S) return 0; } AString Filename = tolua_tostring(tolua_S, 2, 0); - bool res = cSchematicFileSerializer::SaveToSchematicFile(*self,Filename); + bool res = cSchematicFileSerializer::SaveToSchematicFile(*self, Filename); tolua_pushboolean(tolua_S, res); return 1; } @@ -3065,13 +3065,13 @@ void ManualBindings::Bind(lua_State * tolua_S) tolua_function(tolua_S, "AddWebTab", tolua_cPluginLua_AddWebTab); tolua_endmodule(tolua_S); - tolua_cclass(tolua_S,"HTTPRequest","HTTPRequest","",NULL); - tolua_beginmodule(tolua_S,"HTTPRequest"); - // tolua_variable(tolua_S,"Method",tolua_get_HTTPRequest_Method,tolua_set_HTTPRequest_Method); - // tolua_variable(tolua_S,"Path",tolua_get_HTTPRequest_Path,tolua_set_HTTPRequest_Path); - tolua_variable(tolua_S,"FormData",tolua_get_HTTPRequest_FormData,0); - tolua_variable(tolua_S,"Params",tolua_get_HTTPRequest_Params,0); - tolua_variable(tolua_S,"PostParams",tolua_get_HTTPRequest_PostParams,0); + tolua_cclass(tolua_S, "HTTPRequest", "HTTPRequest", "", NULL); + tolua_beginmodule(tolua_S, "HTTPRequest"); + // tolua_variable(tolua_S, "Method", tolua_get_HTTPRequest_Method, tolua_set_HTTPRequest_Method); + // tolua_variable(tolua_S, "Path", tolua_get_HTTPRequest_Path, tolua_set_HTTPRequest_Path); + tolua_variable(tolua_S, "FormData", tolua_get_HTTPRequest_FormData, 0); + tolua_variable(tolua_S, "Params", tolua_get_HTTPRequest_Params, 0); + tolua_variable(tolua_S, "PostParams", tolua_get_HTTPRequest_PostParams, 0); tolua_endmodule(tolua_S); tolua_beginmodule(tolua_S, "cWebAdmin"); diff --git a/src/Blocks/BlockBed.cpp b/src/Blocks/BlockBed.cpp index fbf98044c..fbc82b440 100644 --- a/src/Blocks/BlockBed.cpp +++ b/src/Blocks/BlockBed.cpp @@ -15,7 +15,7 @@ void cBlockBedHandler::OnPlacedByPlayer( if (a_BlockMeta < 8) { Vector3i Direction = MetaDataToDirection(a_BlockMeta); - a_ChunkInterface.SetBlock(a_WorldInterface,a_BlockX + Direction.x, a_BlockY, a_BlockZ + Direction.z, E_BLOCK_BED, a_BlockMeta | 0x8); + a_ChunkInterface.SetBlock(a_WorldInterface, a_BlockX + Direction.x, a_BlockY, a_BlockZ + Direction.z, E_BLOCK_BED, a_BlockMeta | 0x8); } } diff --git a/src/Blocks/BlockBed.h b/src/Blocks/BlockBed.h index 51e79b888..bf9d9c01d 100644 --- a/src/Blocks/BlockBed.h +++ b/src/Blocks/BlockBed.h @@ -16,7 +16,7 @@ class cBlockBedHandler : { public: cBlockBedHandler(BLOCKTYPE a_BlockType) - : cMetaRotator(a_BlockType) + : cMetaRotator(a_BlockType) { } diff --git a/src/Blocks/BlockLadder.h b/src/Blocks/BlockLadder.h index 72acced41..284d1d732 100644 --- a/src/Blocks/BlockLadder.h +++ b/src/Blocks/BlockLadder.h @@ -103,7 +103,7 @@ public: } - virtual bool CanBeAt(cChunkInterface & a_ChunkInterface,int a_RelX, int a_RelY, int a_RelZ, 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 { // TODO: Use AdjustCoordsByMeta(), then cChunk::UnboundedRelGetBlock() and finally some comparison eBlockFace BlockFace = MetaDataToDirection(a_Chunk.GetMeta(a_RelX, a_RelY, a_RelZ)); diff --git a/src/Blocks/BlockLeaves.h b/src/Blocks/BlockLeaves.h index d0baab013..797824506 100644 --- a/src/Blocks/BlockLeaves.h +++ b/src/Blocks/BlockLeaves.h @@ -11,7 +11,7 @@ // Leaves can be this many blocks that away (inclusive) from the log not to decay #define LEAVES_CHECK_DISTANCE 6 -#define PROCESS_NEIGHBOR(x,y,z) \ +#define PROCESS_NEIGHBOR(x, y, z) \ switch (a_Area.GetBlockType(x, y, z)) \ { \ case E_BLOCK_LEAVES: a_Area.SetBlockType(x, y, z, (BLOCKTYPE)(E_BLOCK_SPONGE + i + 1)); break; \ diff --git a/src/Blocks/BlockPortal.h b/src/Blocks/BlockPortal.h index 9ee5d69e2..fc74e89d0 100644 --- a/src/Blocks/BlockPortal.h +++ b/src/Blocks/BlockPortal.h @@ -70,7 +70,7 @@ public: } PortalCheck[] = { { 0, 1, 0}, - { 0,-1, 0}, + { 0, -1, 0}, { 1, 0, 0}, {-1, 0, 0}, } ; @@ -95,7 +95,7 @@ public: } PortalCheck[] = { { 0, 1, 0}, - { 0,-1, 0}, + { 0, -1, 0}, { 0, 0, -1}, { 0, 0, 1}, } ; diff --git a/src/Blocks/ChunkInterface.h b/src/Blocks/ChunkInterface.h index f9cbe3a2d..3bab60be6 100644 --- a/src/Blocks/ChunkInterface.h +++ b/src/Blocks/ChunkInterface.h @@ -18,7 +18,7 @@ public: BLOCKTYPE GetBlock(int a_BlockX, int a_BlockY, int a_BlockZ) { - return m_ChunkMap->GetBlock(a_BlockX,a_BlockY,a_BlockZ); + return m_ChunkMap->GetBlock(a_BlockX, a_BlockY, a_BlockZ); } BLOCKTYPE GetBlock(const Vector3i & a_Pos) { diff --git a/src/BoundingBox.cpp b/src/BoundingBox.cpp index ce831c200..6b163b01e 100644 --- a/src/BoundingBox.cpp +++ b/src/BoundingBox.cpp @@ -191,7 +191,7 @@ bool cBoundingBox::IsInside(const Vector3d & a_Point) -bool cBoundingBox::IsInside(double a_X, double a_Y,double a_Z) +bool cBoundingBox::IsInside(double a_X, double a_Y, double a_Z) { return IsInside(m_Min, m_Max, a_X, a_Y, a_Z); } diff --git a/src/BoundingBox.h b/src/BoundingBox.h index a7c6c3eea..793466302 100644 --- a/src/BoundingBox.h +++ b/src/BoundingBox.h @@ -49,7 +49,7 @@ public: bool IsInside(const Vector3d & a_Point); /// Returns true if the point is inside the bounding box - bool IsInside(double a_X, double a_Y,double a_Z); + bool IsInside(double a_X, double a_Y, double a_Z); /// Returns true if a_Other is inside this bounding box bool IsInside(cBoundingBox & a_Other); diff --git a/src/Chunk.cpp b/src/Chunk.cpp index 6fb615f1c..6e2d3509d 100644 --- a/src/Chunk.cpp +++ b/src/Chunk.cpp @@ -455,7 +455,7 @@ void cChunk::CollectMobCensus(cMobCensus& toFill) currentPosition = Monster.GetPosition(); for (std::list::const_iterator itr2 = playerPositions.begin(); itr2 != playerPositions.end(); ++itr2) { - toFill.CollectMob(Monster,*this,(currentPosition-**itr2).SqrLength()); + toFill.CollectMob(Monster, *this, (currentPosition - **itr2).SqrLength()); } } } // for itr - m_Entitites[] @@ -464,7 +464,7 @@ void cChunk::CollectMobCensus(cMobCensus& toFill) -void cChunk::GetThreeRandomNumbers(int & a_X, int & a_Y, int & a_Z,int a_MaxX, int a_MaxY, int a_MaxZ) +void cChunk::GetThreeRandomNumbers(int & a_X, int & a_Y, int & a_Z, int a_MaxX, int a_MaxY, int a_MaxZ) { ASSERT(a_MaxX * a_MaxY * a_MaxZ * 8 < 0x00ffffff); int Random = m_World->GetTickRandomNumber(0x00ffffff); @@ -638,7 +638,7 @@ void cChunk::TickBlock(int a_RelX, int a_RelY, int a_RelZ) ASSERT(Handler != NULL); // Happenned on server restart, FS #243 cChunkInterface ChunkInterface(this->GetWorld()->GetChunkMap()); cBlockInServerPluginInterface PluginInterface(*this->GetWorld()); - Handler->OnUpdate(ChunkInterface, *this->GetWorld(), PluginInterface,*this, a_RelX, a_RelY, a_RelZ); + Handler->OnUpdate(ChunkInterface, *this->GetWorld(), PluginInterface, *this, a_RelX, a_RelY, a_RelZ); } diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index 58247a836..cf78b19c5 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -1070,7 +1070,7 @@ void cClientHandle::HandleBlockDigFinished(int a_BlockX, int a_BlockY, int a_Blo ItemHandler->OnBlockDestroyed(World, m_Player, m_Player->GetEquippedItem(), a_BlockX, a_BlockY, a_BlockZ); // The ItemHandler is also responsible for spawning the pickups cChunkInterface ChunkInterface(World->GetChunkMap()); - BlockHandler(a_OldBlock)->OnDestroyedByPlayer(ChunkInterface,*World, m_Player, a_BlockX, a_BlockY, a_BlockZ); + BlockHandler(a_OldBlock)->OnDestroyedByPlayer(ChunkInterface, *World, m_Player, a_BlockX, a_BlockY, a_BlockZ); World->BroadcastSoundParticleEffect(2001, a_BlockX, a_BlockY, a_BlockZ, a_OldBlock, this); World->DigBlock(a_BlockX, a_BlockY, a_BlockZ); @@ -1361,7 +1361,7 @@ void cClientHandle::HandlePlaceBlock(int a_BlockX, int a_BlockY, int a_BlockZ, e m_Player->GetInventory().RemoveOneEquippedItem(); } cChunkInterface ChunkInterface(World->GetChunkMap()); - NewBlock->OnPlacedByPlayer(ChunkInterface,*World, m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, BlockType, BlockMeta); + NewBlock->OnPlacedByPlayer(ChunkInterface, *World, m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, BlockType, BlockMeta); // Step sound with 0.8f pitch is used as block placement sound World->BroadcastSoundEffect(NewBlock->GetStepSound(), (double)a_BlockX, (double)a_BlockY, (double)a_BlockZ, 1.0f, 0.8f); diff --git a/src/CraftingRecipes.h b/src/CraftingRecipes.h index 90e41eddc..0250d2f68 100644 --- a/src/CraftingRecipes.h +++ b/src/CraftingRecipes.h @@ -127,7 +127,7 @@ protected: typedef std::vector cRecipeSlots; /** A single recipe, stored. Each recipe is normalized right after parsing (NormalizeIngredients()) - A normalized recipe starts at (0,0) + A normalized recipe starts at (0, 0) */ struct cRecipe { diff --git a/src/Entities/TNTEntity.cpp b/src/Entities/TNTEntity.cpp index fd9a4e7ac..53af446cc 100644 --- a/src/Entities/TNTEntity.cpp +++ b/src/Entities/TNTEntity.cpp @@ -42,7 +42,7 @@ void cTNTEntity::Explode(void) { m_FuseTicks = 0; Destroy(true); - LOGD("BOOM at {%f,%f,%f}", GetPosX(), GetPosY(), GetPosZ()); + LOGD("BOOM at {%f, %f, %f}", GetPosX(), GetPosY(), GetPosZ()); m_World->DoExplosionAt(4.0, GetPosX() + 0.49, GetPosY() + 0.49, GetPosZ() + 0.49, true, esPrimedTNT, this); } diff --git a/src/Generating/Caves.cpp b/src/Generating/Caves.cpp index 3571b29d4..21bfd98b8 100644 --- a/src/Generating/Caves.cpp +++ b/src/Generating/Caves.cpp @@ -559,7 +559,7 @@ AString cCaveTunnel::ExportAsSVG(int a_Color, int a_OffsetX, int a_OffsetZ) cons char Prefix = 'M'; // The first point needs "M" prefix, all the others need "L" for (cCaveDefPoints::const_iterator itr = m_Points.begin(); itr != m_Points.end(); ++itr) { - AppendPrintf(SVG, "%c %d,%d ", Prefix, a_OffsetX + itr->m_BlockX, a_OffsetZ + itr->m_BlockZ); + AppendPrintf(SVG, "%c %d, %d ", Prefix, a_OffsetX + itr->m_BlockX, a_OffsetZ + itr->m_BlockZ); Prefix = 'L'; } SVG.append("\"/>\n"); diff --git a/src/Generating/ChunkGenerator.cpp b/src/Generating/ChunkGenerator.cpp index 0947eeae5..9383a3adf 100644 --- a/src/Generating/ChunkGenerator.cpp +++ b/src/Generating/ChunkGenerator.cpp @@ -180,7 +180,7 @@ BLOCKTYPE cChunkGenerator::GetIniBlock(cIniFile & a_IniFile, const AString & a_S BLOCKTYPE Block = BlockStringToType(BlockType); if (Block < 0) { - LOGWARN("[%s].%s Could not parse block value \"%s\". Using default: \"%s\".", a_SectionName.c_str(), a_ValueName.c_str(), BlockType.c_str(),a_Default.c_str()); + LOGWARN("[%s].%s Could not parse block value \"%s\". Using default: \"%s\".", a_SectionName.c_str(), a_ValueName.c_str(), BlockType.c_str(), a_Default.c_str()); return BlockStringToType(a_Default); } return Block; diff --git a/src/Generating/Ravines.cpp b/src/Generating/Ravines.cpp index 86e27d8ed..70b9d0b62 100644 --- a/src/Generating/Ravines.cpp +++ b/src/Generating/Ravines.cpp @@ -287,34 +287,34 @@ AString cStructGenRavines::cRavine::ExportAsSVG(int a_Color, int a_OffsetX, int char Prefix = 'M'; // The first point needs "M" prefix, all the others need "L" for (cRavDefPoints::const_iterator itr = m_Points.begin(); itr != m_Points.end(); ++itr) { - AppendPrintf(SVG, "%c %d,%d ", Prefix, a_OffsetX + itr->m_BlockX, a_OffsetZ + itr->m_BlockZ); + AppendPrintf(SVG, "%c %d, %d ", Prefix, a_OffsetX + itr->m_BlockX, a_OffsetZ + itr->m_BlockZ); Prefix = 'L'; } SVG.append("\"/>\n"); // Base point highlight: - AppendPrintf(SVG, "\n", + AppendPrintf(SVG, "\n", a_OffsetX + m_OriginX - 5, a_OffsetZ + m_OriginZ, a_OffsetX + m_OriginX + 5, a_OffsetZ + m_OriginZ ); - AppendPrintf(SVG, "\n", + AppendPrintf(SVG, "\n", a_OffsetX + m_OriginX, a_OffsetZ + m_OriginZ - 5, a_OffsetX + m_OriginX, a_OffsetZ + m_OriginZ + 5 ); // A gray line from the base point to the first point of the ravine, for identification: - AppendPrintf(SVG, "\n", + AppendPrintf(SVG, "\n", a_OffsetX + m_OriginX, a_OffsetZ + m_OriginZ, a_OffsetX + m_Points.front().m_BlockX, a_OffsetZ + m_Points.front().m_BlockZ ); // Offset guides: if (a_OffsetX > 0) { - AppendPrintf(SVG, "\n", + AppendPrintf(SVG, "\n", a_OffsetX, a_OffsetX ); } if (a_OffsetZ > 0) { - AppendPrintf(SVG, "\n", + AppendPrintf(SVG, "\n", a_OffsetZ, a_OffsetZ ); } diff --git a/src/Generating/Trees.h b/src/Generating/Trees.h index 00f343a3d..1f6ac4dff 100644 --- a/src/Generating/Trees.h +++ b/src/Generating/Trees.h @@ -70,7 +70,7 @@ void GetAcaciaTreeImage(int a_BlockX, int a_BlockY, int a_BlockZ, cNoise & a_Noi void GetDarkoakTreeImage(int a_BlockX, int a_BlockY, int a_BlockZ, cNoise & a_Noise, int a_Seq, sSetBlockVector & a_LogBlocks, sSetBlockVector & a_OtherBlocks); /// Generates an image of a random large birch tree -void GetTallBirchTreeImage(int a_BlockX, int a_BlockY, int a_BlockZ, cNoise & a_Noise, int a_Seq, sSetBlockVector & a_LogBlocks,sSetBlockVector & a_OtherBlocks); +void GetTallBirchTreeImage(int a_BlockX, int a_BlockY, int a_BlockZ, cNoise & a_Noise, int a_Seq, sSetBlockVector & a_LogBlocks, sSetBlockVector & a_OtherBlocks); /// Generates an image of a random conifer tree void GetConiferTreeImage(int a_BlockX, int a_BlockY, int a_BlockZ, cNoise & a_Noise, int a_Seq, sSetBlockVector & a_LogBlocks, sSetBlockVector & a_OtherBlocks); diff --git a/src/Globals.h b/src/Globals.h index 9b2f25f36..932040ec2 100644 --- a/src/Globals.h +++ b/src/Globals.h @@ -252,7 +252,7 @@ template class SizeChecker; #include "MCLogger.h" #else // Logging functions -void inline LOGERROR(const char* a_Format, ...) FORMATSTRING(1,2); +void inline LOGERROR(const char* a_Format, ...) FORMATSTRING(1, 2); void inline LOGERROR(const char* a_Format, ...) { diff --git a/src/GroupManager.cpp b/src/GroupManager.cpp index ffba68200..135a1636a 100644 --- a/src/GroupManager.cpp +++ b/src/GroupManager.cpp @@ -125,7 +125,7 @@ bool cGroupManager::LoadGroups() IniFile.SetValue("Owner", "Permissions", "*", true); IniFile.SetValue("Owner", "Color", "2", true); - IniFile.SetValue("Moderator", "Permissions", "core.time,core.item,core.tpa,core.tpaccept,core.ban,core.unban,core.save-all,core.toggledownfall"); + IniFile.SetValue("Moderator", "Permissions", "core.time, core.item, core.tpa, core.tpaccept, core.ban, core.unban, core.save-all, core.toggledownfall"); IniFile.SetValue("Moderator", "Color", "2", true); IniFile.SetValue("Moderator", "Inherits", "Player", true); @@ -133,7 +133,7 @@ bool cGroupManager::LoadGroups() IniFile.SetValue("Player", "Color", "f", true); IniFile.SetValue("Player", "Inherits", "Default", true); - IniFile.SetValue("Default", "Permissions", "core.help,core.plugins,core.spawn,core.worlds,core.back,core.motd,core.build,core.locate,core.viewdistance", true); + IniFile.SetValue("Default", "Permissions", "core.help, core.plugins, core.spawn, core.worlds, core.back, core.motd, core.build, core.locate, core.viewdistance", true); IniFile.SetValue("Default", "Color", "f", true); IniFile.WriteFile("groups.ini"); diff --git a/src/Items/ItemBucket.h b/src/Items/ItemBucket.h index 6d7926fa4..a17c4838b 100644 --- a/src/Items/ItemBucket.h +++ b/src/Items/ItemBucket.h @@ -117,7 +117,7 @@ public: return false; } cItem Item(E_ITEM_BUCKET, 1); - if (!a_Player->GetInventory().AddItem(Item,true,true)) + if (!a_Player->GetInventory().AddItem(Item, true, true)) { return false; } diff --git a/src/Items/ItemShovel.h b/src/Items/ItemShovel.h index 333ba46e8..78cfe26fe 100644 --- a/src/Items/ItemShovel.h +++ b/src/Items/ItemShovel.h @@ -28,7 +28,7 @@ public: { cChunkInterface ChunkInterface(a_World->GetChunkMap()); cBlockInServerPluginInterface PluginInterface(*a_World); - BlockHandler(Block)->DropBlock(ChunkInterface,*a_World, PluginInterface, a_Player, a_BlockX, a_BlockY, a_BlockZ); + BlockHandler(Block)->DropBlock(ChunkInterface, *a_World, PluginInterface, a_Player, a_BlockX, a_BlockY, a_BlockZ); a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_AIR, 0); a_Player->UseEquippedItem(); diff --git a/src/Log.cpp b/src/Log.cpp index d96e3e9e4..69b9c13a2 100644 --- a/src/Log.cpp +++ b/src/Log.cpp @@ -130,7 +130,7 @@ void cLog::Log(const char * a_Format, va_list argList) // Print to console: #if defined(ANDROID_NDK) - // __android_log_vprint(ANDROID_LOG_ERROR,"MCServer", a_Format, argList); + // __android_log_vprint(ANDROID_LOG_ERROR, "MCServer", a_Format, argList); __android_log_print(ANDROID_LOG_ERROR, "MCServer", "%s", Line.c_str() ); // CallJavaFunction_Void_String(g_JavaThread, "AddToLog", Line ); #else diff --git a/src/MobProximityCounter.cpp b/src/MobProximityCounter.cpp index a89fa72df..f5d3e970c 100644 --- a/src/MobProximityCounter.cpp +++ b/src/MobProximityCounter.cpp @@ -8,12 +8,12 @@ void cMobProximityCounter::CollectMob(cEntity& a_Monster, cChunk& a_Chunk, double a_Distance) { - // LOGD("Collecting monster %s, with distance %f",a_Monster->GetClass(),a_Distance); + // LOGD("Collecting monster %s, with distance %f", a_Monster->GetClass(), a_Distance); tMonsterToDistance::iterator it = m_MonsterToDistance.find(&a_Monster); if (it == m_MonsterToDistance.end()) { - sDistanceAndChunk newDistanceAndChunk(a_Distance,a_Chunk); - std::pair result = m_MonsterToDistance.insert(tMonsterToDistance::value_type(&a_Monster,newDistanceAndChunk)); + sDistanceAndChunk newDistanceAndChunk(a_Distance, a_Chunk); + std::pair result = m_MonsterToDistance.insert(tMonsterToDistance::value_type(&a_Monster, newDistanceAndChunk)); if (!result.second) { ASSERT(!"A collected Monster was not found inside distance map using find(), but insert() said there already is a key for it"); @@ -36,7 +36,7 @@ void cMobProximityCounter::convertMaps() { for(tMonsterToDistance::const_iterator itr = m_MonsterToDistance.begin(); itr != m_MonsterToDistance.end(); ++itr) { - m_DistanceToMonster.insert(tDistanceToMonster::value_type(itr->second.m_Distance,sMonsterAndChunk(*itr->first,*itr->second.m_Chunk))); + m_DistanceToMonster.insert(tDistanceToMonster::value_type(itr->second.m_Distance, sMonsterAndChunk(*itr->first, *itr->second.m_Chunk))); } } diff --git a/src/MobProximityCounter.h b/src/MobProximityCounter.h index cadfc48ae..8c6c11d68 100644 --- a/src/MobProximityCounter.h +++ b/src/MobProximityCounter.h @@ -28,8 +28,8 @@ protected : }; public : - typedef std::map tMonsterToDistance; - typedef std::multimap tDistanceToMonster; + typedef std::map tMonsterToDistance; + typedef std::multimap tDistanceToMonster; protected : // this map is filled during collection phase, it will be later transformed into DistanceToMonster diff --git a/src/MobSpawner.cpp b/src/MobSpawner.cpp index da3e7c406..ce1187452 100644 --- a/src/MobSpawner.cpp +++ b/src/MobSpawner.cpp @@ -8,7 +8,7 @@ -cMobSpawner::cMobSpawner(cMonster::eFamily a_MonsterFamily,const std::set& a_AllowedTypes) : +cMobSpawner::cMobSpawner(cMonster::eFamily a_MonsterFamily, const std::set& a_AllowedTypes) : m_MonsterFamily(a_MonsterFamily), m_NewPack(true), m_MobType(cMonster::mtInvalidType) diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp index 8d612fbaa..db45db5b9 100644 --- a/src/Mobs/Monster.cpp +++ b/src/Mobs/Monster.cpp @@ -126,7 +126,7 @@ void cMonster::TickPathFinding() { 1, 0}, {-1, 0}, { 0, 1}, - { 0,-1}, + { 0, -1}, } ; if ((PosY - 1 < 0) || (PosY + 2 > cChunkDef::Height) /* PosY + 1 will never be true if PosY + 2 is not */) diff --git a/src/Mobs/Monster.h b/src/Mobs/Monster.h index 4af7cf4f1..bbc3ebd35 100644 --- a/src/Mobs/Monster.h +++ b/src/Mobs/Monster.h @@ -73,7 +73,7 @@ public: // tolua_end enum MState{ATTACKING, IDLE, CHASING, ESCAPING} m_EMState; - enum MPersonality{PASSIVE,AGGRESSIVE,COWARDLY} m_EMPersonality; + enum MPersonality{PASSIVE, AGGRESSIVE, COWARDLY} m_EMPersonality; /** Creates the mob object. If a_ConfigName is not empty, the configuration is loaded using GetMonsterConfig() diff --git a/src/OSSupport/Socket.cpp b/src/OSSupport/Socket.cpp index 7d4d9e598..47d9f331d 100644 --- a/src/OSSupport/Socket.cpp +++ b/src/OSSupport/Socket.cpp @@ -138,7 +138,7 @@ int cSocket::WSAStartup(void) #ifdef _WIN32 WSADATA wsaData; memset(&wsaData, 0, sizeof(wsaData)); - return ::WSAStartup(MAKEWORD(2, 2),&wsaData); + return ::WSAStartup(MAKEWORD(2, 2), &wsaData); #else return 0; #endif diff --git a/src/OSSupport/Thread.cpp b/src/OSSupport/Thread.cpp index 084e0810e..163c9b0c9 100644 --- a/src/OSSupport/Thread.cpp +++ b/src/OSSupport/Thread.cpp @@ -92,11 +92,11 @@ void cThread::Start( bool a_bWaitOnDelete /* = true */ ) #else DWORD ThreadID = 0; HANDLE hThread = CreateThread(NULL // security - ,0 // stack size + , 0 // stack size , (LPTHREAD_START_ROUTINE) MyThread // function name - ,this // parameters - ,0 // flags - ,&ThreadID ); // thread id + , this // parameters + , 0 // flags + , &ThreadID ); // thread id CloseHandle( hThread ); #ifdef _MSC_VER diff --git a/src/Protocol/Protocol17x.cpp b/src/Protocol/Protocol17x.cpp index 37a9fdf47..67a5e97b1 100644 --- a/src/Protocol/Protocol17x.cpp +++ b/src/Protocol/Protocol17x.cpp @@ -2533,7 +2533,7 @@ void cProtocol172::cPacketizer::WriteItem(const cItem & a_Item) if (!a_Item.m_Enchantments.IsEmpty()) { const char * TagName = (a_Item.m_ItemType == E_ITEM_BOOK) ? "StoredEnchantments" : "ench"; - EnchantmentSerializer::WriteToNBTCompound(a_Item.m_Enchantments,Writer, TagName); + EnchantmentSerializer::WriteToNBTCompound(a_Item.m_Enchantments, Writer, TagName); } if (!a_Item.IsBothNameAndLoreEmpty()) { diff --git a/src/Protocol/ProtocolRecognizer.cpp b/src/Protocol/ProtocolRecognizer.cpp index 3991b84de..e62f9d216 100644 --- a/src/Protocol/ProtocolRecognizer.cpp +++ b/src/Protocol/ProtocolRecognizer.cpp @@ -331,7 +331,7 @@ void cProtocolRecognizer::SendEntityVelocity(const cEntity & a_Entity) void cProtocolRecognizer::SendExplosion(double a_BlockX, double a_BlockY, double a_BlockZ, float a_Radius, const cVector3iArray & a_BlocksAffected, const Vector3d & a_PlayerMotion) { ASSERT(m_Protocol != NULL); - m_Protocol->SendExplosion(a_BlockX,a_BlockY,a_BlockZ,a_Radius, a_BlocksAffected, a_PlayerMotion); + m_Protocol->SendExplosion(a_BlockX, a_BlockY, a_BlockZ, a_Radius, a_BlocksAffected, a_PlayerMotion); } diff --git a/src/Simulator/FireSimulator.cpp b/src/Simulator/FireSimulator.cpp index 9433a8c68..2164b6b10 100644 --- a/src/Simulator/FireSimulator.cpp +++ b/src/Simulator/FireSimulator.cpp @@ -98,7 +98,7 @@ void cFireSimulator::SimulateChunk(float a_Dt, int a_ChunkX, int a_ChunkZ, cChun int x = itr->x; int y = itr->y; int z = itr->z; - BLOCKTYPE BlockType = a_Chunk->GetBlock(x,y,z); + BLOCKTYPE BlockType = a_Chunk->GetBlock(x, y, z); if (!IsAllowedBlock(BlockType)) { diff --git a/src/Simulator/IncrementalRedstoneSimulator.cpp b/src/Simulator/IncrementalRedstoneSimulator.cpp index 3dd6417dc..ada8de4b8 100644 --- a/src/Simulator/IncrementalRedstoneSimulator.cpp +++ b/src/Simulator/IncrementalRedstoneSimulator.cpp @@ -570,10 +570,10 @@ void cIncrementalRedstoneSimulator::HandleRedstoneWire(int a_RelBlockX, int a_Re {-1, 1, 0}, { 0, 1, 1}, { 0, 1, -1}, /* Wires one higher, surrounding self stop */ - { 1,-1, 0}, /* Wires one lower, surrounding self start */ - {-1,-1, 0}, - { 0,-1, 1}, - { 0,-1, -1}, /* Wires one lower, surrounding self stop */ + { 1, -1, 0}, /* Wires one lower, surrounding self start */ + {-1, -1, 0}, + { 0, -1, 1}, + { 0, -1, -1}, /* Wires one lower, surrounding self stop */ } ; static const struct // Define which directions the wire will check for repeater prescence @@ -584,7 +584,7 @@ void cIncrementalRedstoneSimulator::HandleRedstoneWire(int a_RelBlockX, int a_Re { 1, 0, 0 }, {-1, 0, 0 }, { 0, 0, 1 }, - { 0, 0,-1 }, + { 0, 0, -1 }, { 0, 1, 0 }, }; diff --git a/src/StringUtils.cpp b/src/StringUtils.cpp index f60ed1248..9074ac7c2 100644 --- a/src/StringUtils.cpp +++ b/src/StringUtils.cpp @@ -785,10 +785,10 @@ AString Base64Decode(const AString & a_Base64String) AString Base64Encode(const AString & a_Input) { static const char BASE64[64] = { - 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P', - 'Q','R','S','T','U','V','W','X','Y','Z','a','b','c','d','e','f', - 'g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v', - 'w','x','y','z','0','1','2','3','4','5','6','7','8','9','+','/' + 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', + 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', + 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', + 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/' }; AString output; diff --git a/src/Tracer.cpp b/src/Tracer.cpp index 54b4716e3..fd8a297c0 100644 --- a/src/Tracer.cpp +++ b/src/Tracer.cpp @@ -18,11 +18,11 @@ cTracer::cTracer(cWorld * a_World) : m_World(a_World) { m_NormalTable[0].Set(-1, 0, 0); - m_NormalTable[1].Set( 0, 0,-1); + m_NormalTable[1].Set( 0, 0, -1); m_NormalTable[2].Set( 1, 0, 0); m_NormalTable[3].Set( 0, 0, 1); m_NormalTable[4].Set( 0, 1, 0); - m_NormalTable[5].Set( 0,-1, 0); + m_NormalTable[5].Set( 0, -1, 0); } @@ -245,7 +245,7 @@ bool cTracer::Trace( const Vector3f & a_Start, const Vector3f & a_Direction, int // return 1 = hit, other is not hit -int LinesCross(float x0,float y0,float x1,float y1,float x2,float y2,float x3,float y3) +int LinesCross(float x0, float y0, float x1, float y1, float x2, float y2, float x3, float y3) { // float linx, liny; diff --git a/src/World.cpp b/src/World.cpp index c27fd462b..d90383884 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -2469,7 +2469,7 @@ cPlayer * cWorld::FindClosestPlayer(const Vector3d & a_Pos, float a_SightLimit, { if (a_CheckLineOfSight) { - if(!LineOfSight.Trace(a_Pos,(Pos - a_Pos),(int)(Pos - a_Pos).Length())) + if(!LineOfSight.Trace(a_Pos, (Pos - a_Pos), (int)(Pos - a_Pos).Length())) { ClosestDistance = Distance; ClosestPlayer = *itr; diff --git a/src/World.h b/src/World.h index f0e8d5cf3..5e0af6340 100644 --- a/src/World.h +++ b/src/World.h @@ -859,7 +859,7 @@ private: Int64 m_LastTimeUpdate; // The tick in which the last time update has been sent. Int64 m_LastUnload; // The last WorldAge (in ticks) in which unloading was triggerred Int64 m_LastSave; // The last WorldAge (in ticks) in which save-all was triggerred - std::map m_LastSpawnMonster; // The last WorldAge (in ticks) in which a monster was spawned (for each megatype of monster) // MG TODO : find a way to optimize without creating unmaintenability (if mob IDs are becoming unrowed) + std::map m_LastSpawnMonster; // The last WorldAge (in ticks) in which a monster was spawned (for each megatype of monster) // MG TODO : find a way to optimize without creating unmaintenability (if mob IDs are becoming unrowed) NIBBLETYPE m_SkyDarkness; diff --git a/src/WorldStorage/WSSAnvil.h b/src/WorldStorage/WSSAnvil.h index 5b629f017..9f8714404 100644 --- a/src/WorldStorage/WSSAnvil.h +++ b/src/WorldStorage/WSSAnvil.h @@ -153,7 +153,7 @@ protected: void LoadPickupFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx); void LoadTNTFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx); void LoadExpOrbFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx); - void LoadHangingFromNBT (cHangingEntity & a_Hanging,const cParsedNBT & a_NBT, int a_TagIdx); + void LoadHangingFromNBT (cHangingEntity & a_Hanging, const cParsedNBT & a_NBT, int a_TagIdx); void LoadItemFrameFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx); void LoadMinecartRFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx); diff --git a/src/WorldStorage/WorldStorage.cpp b/src/WorldStorage/WorldStorage.cpp index 155aa6b14..d0b2acf3b 100644 --- a/src/WorldStorage/WorldStorage.cpp +++ b/src/WorldStorage/WorldStorage.cpp @@ -163,7 +163,7 @@ void cWorldStorage::QueueSaveChunk(int a_ChunkX, int a_ChunkY, int a_ChunkZ) void cWorldStorage::UnqueueLoad(int a_ChunkX, int a_ChunkY, int a_ChunkZ) { - m_LoadQueue.Remove(sChunkLoad(a_ChunkX, a_ChunkY, a_ChunkZ,true)); + m_LoadQueue.Remove(sChunkLoad(a_ChunkX, a_ChunkY, a_ChunkZ, true)); } @@ -182,8 +182,8 @@ void cWorldStorage::UnqueueSave(const cChunkCoords & a_Chunk) void cWorldStorage::InitSchemas(int a_StorageCompressionFactor) { // The first schema added is considered the default - m_Schemas.push_back(new cWSSAnvil (m_World,a_StorageCompressionFactor)); - m_Schemas.push_back(new cWSSCompact (m_World,a_StorageCompressionFactor)); + m_Schemas.push_back(new cWSSAnvil (m_World, a_StorageCompressionFactor)); + m_Schemas.push_back(new cWSSCompact (m_World, a_StorageCompressionFactor)); m_Schemas.push_back(new cWSSForgetful(m_World)); // Add new schemas here diff --git a/src/WorldStorage/WorldStorage.h b/src/WorldStorage/WorldStorage.h index bf764a539..4d4c46a71 100644 --- a/src/WorldStorage/WorldStorage.h +++ b/src/WorldStorage/WorldStorage.h @@ -109,7 +109,7 @@ protected: }; }; - typedef cQueue sChunkLoadQueue; + typedef cQueue sChunkLoadQueue; cWorld * m_World; AString m_StorageSchemaName; -- cgit v1.2.3 From 1cb26bda8e3377fd092a348faeb39f7185f60934 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 19 Jul 2014 15:07:28 +0200 Subject: Fixed spaces after commas in protocol data. The JSON data is well-formatted with spaces, too; we can afford to waste the few bytes. --- src/Protocol/Protocol17x.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Protocol/Protocol17x.cpp b/src/Protocol/Protocol17x.cpp index 67a5e97b1..2707fbf9f 100644 --- a/src/Protocol/Protocol17x.cpp +++ b/src/Protocol/Protocol17x.cpp @@ -1712,16 +1712,16 @@ void cProtocol172::HandlePacketStatusPing(cByteBuffer & a_ByteBuffer) void cProtocol172::HandlePacketStatusRequest(cByteBuffer & a_ByteBuffer) { // Send the response: - AString Response = "{\"version\":{\"name\":\"1.7.2\",\"protocol\":4},\"players\":{"; + AString Response = "{\"version\":{\"name\":\"1.7.2\", \"protocol\":4}, \"players\":{"; cServer * Server = cRoot::Get()->GetServer(); - AppendPrintf(Response, "\"max\":%u,\"online\":%u,\"sample\":[]},", + AppendPrintf(Response, "\"max\":%u, \"online\":%u, \"sample\":[]},", Server->GetMaxPlayers(), Server->GetNumPlayers() ); AppendPrintf(Response, "\"description\":{\"text\":\"%s\"},", Server->GetDescription().c_str() ); - AppendPrintf(Response, "\"favicon\":\"data:image/png;base64,%s\"", + AppendPrintf(Response, "\"favicon\": \"data:image/png;base64,%s\"", Server->GetFaviconData().c_str() ); Response.append("}"); @@ -3047,15 +3047,15 @@ void cProtocol176::SendPlayerSpawn(const cPlayer & a_Player) void cProtocol176::HandlePacketStatusRequest(cByteBuffer & a_ByteBuffer) { // Send the response: - AString Response = "{\"version\":{\"name\":\"1.7.6\",\"protocol\":5},\"players\":{"; - AppendPrintf(Response, "\"max\":%u,\"online\":%u,\"sample\":[]},", + AString Response = "{\"version\": {\"name\": \"1.7.6\", \"protocol\":5}, \"players\": {"; + AppendPrintf(Response, "\"max\": %u, \"online\": %u, \"sample\": []},", cRoot::Get()->GetServer()->GetMaxPlayers(), cRoot::Get()->GetServer()->GetNumPlayers() ); - AppendPrintf(Response, "\"description\":{\"text\":\"%s\"},", + AppendPrintf(Response, "\"description\": {\"text\": \"%s\"},", cRoot::Get()->GetServer()->GetDescription().c_str() ); - AppendPrintf(Response, "\"favicon\":\"data:image/png;base64,%s\"", + AppendPrintf(Response, "\"favicon\": \"data:image/png;base64,%s\"", cRoot::Get()->GetServer()->GetFaviconData().c_str() ); Response.append("}"); -- cgit v1.2.3 From 822d83009d9ccc698e930907a707ba2451e95a20 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 19 Jul 2014 15:08:49 +0200 Subject: CheckBasicStyle: Check spaces around commas. We want no space in front of and at least one space after a comma. --- src/CheckBasicStyle.lua | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/CheckBasicStyle.lua b/src/CheckBasicStyle.lua index 6aad4125d..14e3caa26 100644 --- a/src/CheckBasicStyle.lua +++ b/src/CheckBasicStyle.lua @@ -6,13 +6,13 @@ Checks that all source files (*.cpp, *.h) use the basic style requirements of th - Tabs for indentation, spaces for alignment - Trailing whitespace on non-empty lines - Two spaces between code and line-end comment ("//") - - Spaces after comma, not before (except in #define argument list) + - Spaces after comma, not before - (TODO) Spaces before *, /, & - (TODO) Hex numbers with even digit length - (TODO) Hex numbers in lowercase - (TODO) Braces not on the end of line - (TODO) Line dividers (////...) exactly 80 slashes - - (TODO) Not using "* "-style doxy comments continuation lines + - (TODO) Not using "* "-style doxy comment continuation lines Violations that cannot be checked easily: - Spaces around "+" (there are things like "a++", "++a", "a += 1", "X+", "stack +1" and ascii-drawn tables) @@ -79,8 +79,8 @@ local g_NumViolations = 0 --- Reports one violation -- Pretty-prints the message -- Also increments g_NumViolations -local function ReportViolation(a_FileName, a_LineNumber, a_Message) - print(a_FileName .. "(" .. a_LineNumber .. "): " .. a_Message) +local function ReportViolation(a_FileName, a_LineNumber, a_PatStart, a_PatEnd, a_Message) + print(a_FileName .. "(" .. a_LineNumber .. "): " .. a_PatStart .. " .. " .. a_PatEnd .. ": " .. a_Message) g_NumViolations = g_NumViolations + 1 end @@ -94,7 +94,7 @@ local function ReportViolationIfFound(a_Line, a_FileName, a_LineNum, a_Pattern, if not(patStart) then return end - ReportViolation(a_FileName, a_LineNum, a_Message .. "(" .. patStart .. " .. " .. patEnd .. ")") + ReportViolation(a_FileName, a_LineNum, patStart, patEnd, a_Message) end @@ -120,7 +120,7 @@ local g_ViolationPatterns = -- Check that all commas have spaces after them and not in front of them: {" ,", "Extra space before a \",\""}, - {"^\t*[^#].*,[^%s]", "Needs a space after a \",\""}, -- Anywhere except lines starting with "#" - avoid #define params + {",[^%s\"%%]", "Needs a space after a \",\""}, -- Report all except >> "," << needed for splitting and >>,%s<< needed for formatting } -- cgit v1.2.3 From 08748bafe26145cd61a179abd131a9dba6065450 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 19 Jul 2014 15:23:40 +0200 Subject: Code style: Fixed braces on separate lines. --- src/BiomeDef.cpp | 3 ++- src/BlockEntities/ChestEntity.h | 3 ++- src/BlockEntities/DropSpenserEntity.h | 3 ++- src/BlockEntities/HopperEntity.h | 3 ++- src/BlockID.cpp | 3 ++- src/Entities/Player.cpp | 3 ++- src/MobProximityCounter.h | 3 ++- src/Noise.cpp | 12 ++++++++---- src/Protocol/Protocol125.h | 3 ++- src/Scoreboard.cpp | 3 ++- src/Server.cpp | 3 ++- src/Statistics.cpp | 3 ++- src/StringUtils.cpp | 8 +++++--- src/WorldStorage/WorldStorage.h | 5 +++-- 14 files changed, 38 insertions(+), 20 deletions(-) diff --git a/src/BiomeDef.cpp b/src/BiomeDef.cpp index d680377e2..02f8c2232 100644 --- a/src/BiomeDef.cpp +++ b/src/BiomeDef.cpp @@ -10,7 +10,8 @@ // The "map" used for biome <-> string conversions: -static struct { +static struct +{ EMCSBiome m_Biome; const char * m_String; } g_BiomeMap[] = diff --git a/src/BlockEntities/ChestEntity.h b/src/BlockEntities/ChestEntity.h index 310618504..cd06b3e2c 100644 --- a/src/BlockEntities/ChestEntity.h +++ b/src/BlockEntities/ChestEntity.h @@ -27,7 +27,8 @@ class cChestEntity : typedef cBlockEntityWithItems super; public: - enum { + enum + { ContentsHeight = 3, ContentsWidth = 9, } ; diff --git a/src/BlockEntities/DropSpenserEntity.h b/src/BlockEntities/DropSpenserEntity.h index 47d3bd492..9f58d0b07 100644 --- a/src/BlockEntities/DropSpenserEntity.h +++ b/src/BlockEntities/DropSpenserEntity.h @@ -35,7 +35,8 @@ class cDropSpenserEntity : typedef cBlockEntityWithItems super; public: - enum { + enum + { ContentsHeight = 3, ContentsWidth = 3, } ; diff --git a/src/BlockEntities/HopperEntity.h b/src/BlockEntities/HopperEntity.h index 6ef98f43a..8e856fcda 100644 --- a/src/BlockEntities/HopperEntity.h +++ b/src/BlockEntities/HopperEntity.h @@ -22,7 +22,8 @@ class cHopperEntity : typedef cBlockEntityWithItems super; public: - enum { + enum + { ContentsHeight = 1, ContentsWidth = 5, TICKS_PER_TRANSFER = 8, ///< How many ticks at minimum between two item transfers to or from the hopper diff --git a/src/BlockID.cpp b/src/BlockID.cpp index 023172ca1..af96b4414 100644 --- a/src/BlockID.cpp +++ b/src/BlockID.cpp @@ -255,7 +255,8 @@ AString ItemToFullString(const cItem & a_Item) int StringToMobType(const AString & a_MobString) { - static struct { + static struct + { int m_MobType; const char * m_String; } MobMap [] = diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index 7376441b4..698f77bf6 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -622,7 +622,8 @@ void cPlayer::FinishEating(void) GetInventory().RemoveOneEquippedItem(); // if the food is mushroom soup, return a bowl to the inventory - if( Item.m_ItemType == E_ITEM_MUSHROOM_SOUP ) { + if (Item.m_ItemType == E_ITEM_MUSHROOM_SOUP) + { cItem emptyBowl(E_ITEM_BOWL, 1, 0, ""); GetInventory().AddItem(emptyBowl, true, true); } diff --git a/src/MobProximityCounter.h b/src/MobProximityCounter.h index 8c6c11d68..2dabeaa21 100644 --- a/src/MobProximityCounter.h +++ b/src/MobProximityCounter.h @@ -55,7 +55,8 @@ public : // return the mobs that are within the range of distance of the closest player they are // that means that if a mob is 30 m from a player and 150 m from another one. It will be // in the range [0..50] but not in [100..200] - struct sIterablePair{ + struct sIterablePair + { tDistanceToMonster::const_iterator m_Begin; tDistanceToMonster::const_iterator m_End; int m_Count; diff --git a/src/Noise.cpp b/src/Noise.cpp index 145bcc5dd..a30661fe0 100644 --- a/src/Noise.cpp +++ b/src/Noise.cpp @@ -519,7 +519,8 @@ NOISE_DATATYPE cNoise::CubicNoise3D(NOISE_DATATYPE a_X, NOISE_DATATYPE a_Y, NOIS const int BaseY = FAST_FLOOR(a_Y); const int BaseZ = FAST_FLOOR(a_Z); - const NOISE_DATATYPE points1[4][4] = { + const NOISE_DATATYPE points1[4][4] = + { { IntNoise3D(BaseX - 1, BaseY - 1, BaseZ - 1), IntNoise3D(BaseX, BaseY - 1, BaseZ - 1), IntNoise3D(BaseX + 1, BaseY - 1, BaseZ - 1), IntNoise3D(BaseX + 2, BaseY - 1, BaseZ - 1), }, { IntNoise3D(BaseX - 1, BaseY, BaseZ - 1), IntNoise3D(BaseX, BaseY, BaseZ - 1), IntNoise3D(BaseX + 1, BaseY, BaseZ - 1), IntNoise3D(BaseX + 2, BaseY, BaseZ - 1), }, { IntNoise3D(BaseX - 1, BaseY + 1, BaseZ - 1), IntNoise3D(BaseX, BaseY + 1, BaseZ - 1), IntNoise3D(BaseX + 1, BaseY + 1, BaseZ - 1), IntNoise3D(BaseX + 2, BaseY + 1, BaseZ - 1), }, @@ -532,7 +533,8 @@ NOISE_DATATYPE cNoise::CubicNoise3D(NOISE_DATATYPE a_X, NOISE_DATATYPE a_Y, NOIS const NOISE_DATATYPE x1interp3 = CubicInterpolate( points1[2][0], points1[2][1], points1[2][2], points1[2][3], FracX ); const NOISE_DATATYPE x1interp4 = CubicInterpolate( points1[3][0], points1[3][1], points1[3][2], points1[3][3], FracX ); - const NOISE_DATATYPE points2[4][4] = { + const NOISE_DATATYPE points2[4][4] = + { { IntNoise3D(BaseX - 1, BaseY - 1, BaseZ), IntNoise3D(BaseX, BaseY - 1, BaseZ), IntNoise3D(BaseX + 1, BaseY - 1, BaseZ), IntNoise3D(BaseX + 2, BaseY - 1, BaseZ), }, { IntNoise3D(BaseX - 1, BaseY, BaseZ), IntNoise3D(BaseX, BaseY, BaseZ), IntNoise3D(BaseX + 1, BaseY, BaseZ), IntNoise3D(BaseX + 2, BaseY, BaseZ), }, { IntNoise3D(BaseX - 1, BaseY + 1, BaseZ), IntNoise3D(BaseX, BaseY + 1, BaseZ), IntNoise3D(BaseX + 1, BaseY + 1, BaseZ), IntNoise3D(BaseX + 2, BaseY + 1, BaseZ), }, @@ -544,7 +546,8 @@ NOISE_DATATYPE cNoise::CubicNoise3D(NOISE_DATATYPE a_X, NOISE_DATATYPE a_Y, NOIS const NOISE_DATATYPE x2interp3 = CubicInterpolate( points2[2][0], points2[2][1], points2[2][2], points2[2][3], FracX ); const NOISE_DATATYPE x2interp4 = CubicInterpolate( points2[3][0], points2[3][1], points2[3][2], points2[3][3], FracX ); - const NOISE_DATATYPE points3[4][4] = { + const NOISE_DATATYPE points3[4][4] = + { { IntNoise3D( BaseX-1, BaseY-1, BaseZ+1 ), IntNoise3D( BaseX, BaseY-1, BaseZ+1 ), IntNoise3D( BaseX+1, BaseY-1, BaseZ+1 ), IntNoise3D( BaseX+2, BaseY-1, BaseZ + 1), }, { IntNoise3D( BaseX-1, BaseY, BaseZ+1 ), IntNoise3D( BaseX, BaseY, BaseZ+1 ), IntNoise3D( BaseX+1, BaseY, BaseZ+1 ), IntNoise3D( BaseX+2, BaseY, BaseZ + 1), }, { IntNoise3D( BaseX-1, BaseY+1, BaseZ+1 ), IntNoise3D( BaseX, BaseY+1, BaseZ+1 ), IntNoise3D( BaseX+1, BaseY+1, BaseZ+1 ), IntNoise3D( BaseX+2, BaseY+1, BaseZ + 1), }, @@ -556,7 +559,8 @@ NOISE_DATATYPE cNoise::CubicNoise3D(NOISE_DATATYPE a_X, NOISE_DATATYPE a_Y, NOIS const NOISE_DATATYPE x3interp3 = CubicInterpolate( points3[2][0], points3[2][1], points3[2][2], points3[2][3], FracX ); const NOISE_DATATYPE x3interp4 = CubicInterpolate( points3[3][0], points3[3][1], points3[3][2], points3[3][3], FracX ); - const NOISE_DATATYPE points4[4][4] = { + const NOISE_DATATYPE points4[4][4] = + { { IntNoise3D( BaseX-1, BaseY-1, BaseZ+2 ), IntNoise3D( BaseX, BaseY-1, BaseZ+2 ), IntNoise3D( BaseX+1, BaseY-1, BaseZ+2 ), IntNoise3D( BaseX+2, BaseY-1, BaseZ+2 ), }, { IntNoise3D( BaseX-1, BaseY, BaseZ+2 ), IntNoise3D( BaseX, BaseY, BaseZ+2 ), IntNoise3D( BaseX+1, BaseY, BaseZ+2 ), IntNoise3D( BaseX+2, BaseY, BaseZ+2 ), }, { IntNoise3D( BaseX-1, BaseY+1, BaseZ+2 ), IntNoise3D( BaseX, BaseY+1, BaseZ+2 ), IntNoise3D( BaseX+1, BaseY+1, BaseZ+2 ), IntNoise3D( BaseX+2, BaseY+1, BaseZ+2 ), }, diff --git a/src/Protocol/Protocol125.h b/src/Protocol/Protocol125.h index c0696d206..588dd3473 100644 --- a/src/Protocol/Protocol125.h +++ b/src/Protocol/Protocol125.h @@ -103,7 +103,8 @@ public: protected: /// Results of packet-parsing: - enum { + enum + { PARSE_OK = 1, PARSE_ERROR = -1, PARSE_UNKNOWN = -2, diff --git a/src/Scoreboard.cpp b/src/Scoreboard.cpp index 8695f0fb7..def952029 100644 --- a/src/Scoreboard.cpp +++ b/src/Scoreboard.cpp @@ -45,7 +45,8 @@ AString cObjective::TypeToString(eType a_Type) cObjective::eType cObjective::StringToType(const AString & a_Name) { - static struct { + static struct + { eType m_Type; const char * m_String; } TypeMap [] = diff --git a/src/Server.cpp b/src/Server.cpp index 10a354a36..367d507bf 100644 --- a/src/Server.cpp +++ b/src/Server.cpp @@ -30,7 +30,8 @@ #include #include -extern "C" { +extern "C" +{ #include "zlib/zlib.h" } diff --git a/src/Statistics.cpp b/src/Statistics.cpp index 5c0524f9e..e0c0dd925 100644 --- a/src/Statistics.cpp +++ b/src/Statistics.cpp @@ -7,7 +7,8 @@ -cStatInfo cStatInfo::ms_Info[statCount] = { +cStatInfo cStatInfo::ms_Info[statCount] = +{ // The order must match the order of enum eStatistic // http://minecraft.gamepedia.com/Achievements diff --git a/src/StringUtils.cpp b/src/StringUtils.cpp index 9074ac7c2..b0e5a4ffe 100644 --- a/src/StringUtils.cpp +++ b/src/StringUtils.cpp @@ -509,8 +509,9 @@ The fall-through switches in UTF-8 reading code save a temp variable, some decrements & conditionals. The switches are equivalent to the following loop: { - int tmpBytesToRead = extraBytesToRead+1; - do { + int tmpBytesToRead = extraBytesToRead + 1; + do + { ch += *source++; --tmpBytesToRead; if (tmpBytesToRead) ch <<= 6; @@ -784,7 +785,8 @@ AString Base64Decode(const AString & a_Base64String) AString Base64Encode(const AString & a_Input) { - static const char BASE64[64] = { + static const char BASE64[64] = + { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', diff --git a/src/WorldStorage/WorldStorage.h b/src/WorldStorage/WorldStorage.h index 4d4c46a71..2d5d9c830 100644 --- a/src/WorldStorage/WorldStorage.h +++ b/src/WorldStorage/WorldStorage.h @@ -101,9 +101,10 @@ protected: } } ; - struct FuncTable { + struct FuncTable + { static void Delete(sChunkLoad) {}; - static void Combine(sChunkLoad& a_orig, const sChunkLoad a_new) + static void Combine(sChunkLoad & a_orig, const sChunkLoad a_new) { a_orig.m_Generate |= a_new.m_Generate; }; -- cgit v1.2.3 From e612d07eeae351cbdb413dbb8fb543284ea46628 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 19 Jul 2014 15:25:28 +0200 Subject: CheckBasicStyle: Checks for braces not on separate lines. Only the opening braces at the end of a line are checked, others (such as inline getters and setters or initializers) are valid. --- src/CheckBasicStyle.lua | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/CheckBasicStyle.lua b/src/CheckBasicStyle.lua index 14e3caa26..e4597a426 100644 --- a/src/CheckBasicStyle.lua +++ b/src/CheckBasicStyle.lua @@ -7,10 +7,11 @@ Checks that all source files (*.cpp, *.h) use the basic style requirements of th - Trailing whitespace on non-empty lines - Two spaces between code and line-end comment ("//") - Spaces after comma, not before + - Opening braces not at the end of a code line + - (TODO) Spaces after if, for, while - (TODO) Spaces before *, /, & - (TODO) Hex numbers with even digit length - (TODO) Hex numbers in lowercase - - (TODO) Braces not on the end of line - (TODO) Line dividers (////...) exactly 80 slashes - (TODO) Not using "* "-style doxy comment continuation lines @@ -121,6 +122,9 @@ local g_ViolationPatterns = -- Check that all commas have spaces after them and not in front of them: {" ,", "Extra space before a \",\""}, {",[^%s\"%%]", "Needs a space after a \",\""}, -- Report all except >> "," << needed for splitting and >>,%s<< needed for formatting + + -- Check that opening braces are not at the end of a code line: + {"[^%s].-{\n?$", "Brace should be on a separate line"}, } @@ -145,7 +149,7 @@ local function ProcessFile(a_FileName) if ((lastChar ~= 13) and (lastChar ~= 10)) then local numLines = 1 string.gsub(all, "\n", function() numLines = numLines + 1 end) -- Count the number of line-ends - ReportViolation(a_FileName, numLines, "Missing empty line at file end") + ReportViolation(a_FileName, numLines, 1, 1, "Missing empty line at file end") return end -- cgit v1.2.3 From dd7df288448230fa6becee18e4259ce19976e367 Mon Sep 17 00:00:00 2001 From: archshift Date: Thu, 17 Jul 2014 20:11:33 -0700 Subject: Refactored cChatColor - Changed std::string fields to const char-pointers in order to wipe out potential issues with static initialization and global destructors - Deprecated cChatColor::Color() because the name does not match the value --- src/ChatColor.cpp | 48 ++++++++++++++++++++++++------------------------ src/ChatColor.h | 52 +++++++++++++++++++++++++++------------------------- 2 files changed, 51 insertions(+), 49 deletions(-) diff --git a/src/ChatColor.cpp b/src/ChatColor.cpp index 72a0a6928..e1317c287 100644 --- a/src/ChatColor.cpp +++ b/src/ChatColor.cpp @@ -2,31 +2,31 @@ #include "ChatColor.h" -const std::string cChatColor::Color = "\xc2\xa7"; // or in other words: "§" in UTF-8 -const std::string cChatColor::Delimiter = "\xc2\xa7"; // or in other words: "§" in UTF-8 -const std::string cChatColor::Black = cChatColor::Color + "0"; -const std::string cChatColor::Navy = cChatColor::Color + "1"; -const std::string cChatColor::Green = cChatColor::Color + "2"; -const std::string cChatColor::Blue = cChatColor::Color + "3"; -const std::string cChatColor::Red = cChatColor::Color + "4"; -const std::string cChatColor::Purple = cChatColor::Color + "5"; -const std::string cChatColor::Gold = cChatColor::Color + "6"; -const std::string cChatColor::LightGray = cChatColor::Color + "7"; -const std::string cChatColor::Gray = cChatColor::Color + "8"; -const std::string cChatColor::DarkPurple = cChatColor::Color + "9"; -const std::string cChatColor::LightGreen = cChatColor::Color + "a"; -const std::string cChatColor::LightBlue = cChatColor::Color + "b"; -const std::string cChatColor::Rose = cChatColor::Color + "c"; -const std::string cChatColor::LightPurple = cChatColor::Color + "d"; -const std::string cChatColor::Yellow = cChatColor::Color + "e"; -const std::string cChatColor::White = cChatColor::Color + "f"; +const char * cChatColor::Color = "\xc2\xa7"; // or in other words: "§" in UTF-8 +const char * cChatColor::Delimiter = "\xc2\xa7"; // or in other words: "§" in UTF-8 +const char * cChatColor::Black = "\xc2\xa7""0"; +const char * cChatColor::Navy = "\xc2\xa7""1"; +const char * cChatColor::Green = "\xc2\xa7""2"; +const char * cChatColor::Blue = "\xc2\xa7""3"; +const char * cChatColor::Red = "\xc2\xa7""4"; +const char * cChatColor::Purple = "\xc2\xa7""5"; +const char * cChatColor::Gold = "\xc2\xa7""6"; +const char * cChatColor::LightGray = "\xc2\xa7""7"; +const char * cChatColor::Gray = "\xc2\xa7""8"; +const char * cChatColor::DarkPurple = "\xc2\xa7""9"; +const char * cChatColor::LightGreen = "\xc2\xa7""a"; +const char * cChatColor::LightBlue = "\xc2\xa7""b"; +const char * cChatColor::Rose = "\xc2\xa7""c"; +const char * cChatColor::LightPurple = "\xc2\xa7""d"; +const char * cChatColor::Yellow = "\xc2\xa7""e"; +const char * cChatColor::White = "\xc2\xa7""f"; -const std::string cChatColor::Random = cChatColor::Color + "k"; -const std::string cChatColor::Bold = cChatColor::Color + "l"; -const std::string cChatColor::Strikethrough = cChatColor::Color + "m"; -const std::string cChatColor::Underlined = cChatColor::Color + "n"; -const std::string cChatColor::Italic = cChatColor::Color + "o"; -const std::string cChatColor::Plain = cChatColor::Color + "r"; +const char * cChatColor::Random = "\xc2\xa7""k"; +const char * cChatColor::Bold = "\xc2\xa7""l"; +const char * cChatColor::Strikethrough = "\xc2\xa7""m"; +const char * cChatColor::Underlined = "\xc2\xa7""n"; +const char * cChatColor::Italic = "\xc2\xa7""o"; +const char * cChatColor::Plain = "\xc2\xa7""r"; diff --git a/src/ChatColor.h b/src/ChatColor.h index 2189fd395..5a81c7edd 100644 --- a/src/ChatColor.h +++ b/src/ChatColor.h @@ -9,33 +9,35 @@ class cChatColor { public: - static const std::string Color; - static const std::string Delimiter; - - static const std::string Black; - static const std::string Navy; - static const std::string Green; - static const std::string Blue; - static const std::string Red; - static const std::string Purple; - static const std::string Gold; - static const std::string LightGray; - static const std::string Gray; - static const std::string DarkPurple; - static const std::string LightGreen; - static const std::string LightBlue; - static const std::string Rose; - static const std::string LightPurple; - static const std::string Yellow; - static const std::string White; + static const char * Color; + + /** @deprecated use ChatColor::Delimiter instead */ + static const char * Delimiter; + + static const char * Black; + static const char * Navy; + static const char * Green; + static const char * Blue; + static const char * Red; + static const char * Purple; + static const char * Gold; + static const char * LightGray; + static const char * Gray; + static const char * DarkPurple; + static const char * LightGreen; + static const char * LightBlue; + static const char * Rose; + static const char * LightPurple; + static const char * Yellow; + static const char * White; // Styles ( source: http://wiki.vg/Chat ) - static const std::string Random; - static const std::string Bold; - static const std::string Strikethrough; - static const std::string Underlined; - static const std::string Italic; - static const std::string Plain; + static const char * Random; + static const char * Bold; + static const char * Strikethrough; + static const char * Underlined; + static const char * Italic; + static const char * Plain; }; -- cgit v1.2.3 From d5b163bd3d731ac88780e9042c39eed28982edc2 Mon Sep 17 00:00:00 2001 From: archshift Date: Sat, 19 Jul 2014 11:12:34 -0700 Subject: Removed references to deprecated cChatColor::Color --- src/Entities/Player.cpp | 2 +- src/GroupManager.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index 698f77bf6..808b74023 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -1524,7 +1524,7 @@ AString cPlayer::GetColor(void) const { if ( m_Color != '-' ) { - return cChatColor::Color + m_Color; + return cChatColor::Delimiter + m_Color; } if ( m_Groups.size() < 1 ) diff --git a/src/GroupManager.cpp b/src/GroupManager.cpp index 135a1636a..a1cc396cf 100644 --- a/src/GroupManager.cpp +++ b/src/GroupManager.cpp @@ -153,7 +153,7 @@ bool cGroupManager::LoadGroups() AString Color = IniFile.GetValue(KeyName, "Color", "-"); if ((Color != "-") && (Color.length() >= 1)) { - Group->SetColor(cChatColor::Color + Color[0]); + Group->SetColor(cChatColor::Delimiter + Color[0]); } else { -- cgit v1.2.3 From 52add840cf7fb25ff31da21265fa41bab5682020 Mon Sep 17 00:00:00 2001 From: archshift Date: Sat, 19 Jul 2014 11:15:21 -0700 Subject: Fixed attempts to call c_str on ChatColors --- src/ClientHandle.cpp | 8 ++++---- src/Protocol/ProtocolRecognizer.cpp | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index cf78b19c5..de4245b40 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -210,11 +210,11 @@ AString cClientHandle::FormatMessageType(bool ShouldAppendChatPrefixes, eMessage { if (ShouldAppendChatPrefixes) { - return Printf("%s[MSG: %s] %s%s", cChatColor::LightBlue.c_str(), a_AdditionalData.c_str(), cChatColor::White.c_str(), cChatColor::Italic.c_str()); + return Printf("%s[MSG: %s] %s%s", cChatColor::LightBlue, a_AdditionalData.c_str(), cChatColor::White, cChatColor::Italic); } else { - return Printf("%s: %s", a_AdditionalData.c_str(), cChatColor::LightBlue.c_str()); + return Printf("%s: %s", a_AdditionalData.c_str(), cChatColor::LightBlue); } } } @@ -533,9 +533,9 @@ void cClientHandle::HandlePing(void) Printf(Reply, "%s%s%i%s%i", Server.GetDescription().c_str(), - cChatColor::Delimiter.c_str(), + cChatColor::Delimiter, Server.GetNumPlayers(), - cChatColor::Delimiter.c_str(), + cChatColor::Delimiter, Server.GetMaxPlayers() ); Kick(Reply); diff --git a/src/Protocol/ProtocolRecognizer.cpp b/src/Protocol/ProtocolRecognizer.cpp index e62f9d216..205407a5b 100644 --- a/src/Protocol/ProtocolRecognizer.cpp +++ b/src/Protocol/ProtocolRecognizer.cpp @@ -1021,9 +1021,9 @@ void cProtocolRecognizer::SendLengthlessServerPing(void) // http://wiki.vg/wiki/index.php?title=Protocol&oldid=3099#Server_List_Ping_.280xFE.29 Printf(Reply, "%s%s%i%s%i", Server->GetDescription().c_str(), - cChatColor::Delimiter.c_str(), + cChatColor::Delimiter, Server->GetNumPlayers(), - cChatColor::Delimiter.c_str(), + cChatColor::Delimiter, Server->GetMaxPlayers() ); break; -- cgit v1.2.3 From ada88a58053e74c910982f7c3ebdfb791161c110 Mon Sep 17 00:00:00 2001 From: archshift Date: Sat, 19 Jul 2014 14:35:35 -0700 Subject: Monsters: Made IsUndead overridable by the respective mob classes --- src/Mobs/Monster.cpp | 10 ---------- src/Mobs/Monster.h | 2 +- src/Mobs/Skeleton.h | 2 ++ src/Mobs/Wither.h | 2 ++ src/Mobs/Zombie.h | 6 ++++-- src/Mobs/ZombiePigman.h | 2 ++ 6 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp index db45db5b9..753a44914 100644 --- a/src/Mobs/Monster.cpp +++ b/src/Mobs/Monster.cpp @@ -680,16 +680,6 @@ void cMonster::GetMonsterConfig(const AString & a_Name) bool cMonster::IsUndead(void) { - switch (GetMobType()) - { - case mtZombie: - case mtZombiePigman: - case mtSkeleton: - case mtWither: - { - return true; - } - } return false; } diff --git a/src/Mobs/Monster.h b/src/Mobs/Monster.h index bbc3ebd35..ffd078505 100644 --- a/src/Mobs/Monster.h +++ b/src/Mobs/Monster.h @@ -107,7 +107,7 @@ public: void GetMonsterConfig(const AString & a_Name); /** Returns whether this mob is undead (skeleton, zombie, etc.) */ - bool IsUndead(void); + virtual bool IsUndead(void); virtual void EventLosePlayer(void); virtual void CheckEventLostPlayer(void); diff --git a/src/Mobs/Skeleton.h b/src/Mobs/Skeleton.h index efb670c83..9a121ef48 100644 --- a/src/Mobs/Skeleton.h +++ b/src/Mobs/Skeleton.h @@ -22,6 +22,8 @@ public: virtual void Attack(float a_Dt) override; virtual void SpawnOn(cClientHandle & a_ClientHandle) override; + virtual bool IsUndead(void) override { return true; } + bool IsWither(void) const { return m_bIsWither; }; private: diff --git a/src/Mobs/Wither.h b/src/Mobs/Wither.h index 7d76f70f5..cc8d1459b 100644 --- a/src/Mobs/Wither.h +++ b/src/Mobs/Wither.h @@ -30,6 +30,8 @@ public: virtual bool DoTakeDamage(TakeDamageInfo & a_TDI) override; virtual void Tick(float a_Dt, cChunk & a_Chunk) override; virtual void KilledBy(TakeDamageInfo & a_TDI) override; + + virtual bool IsUndead(void) override { return true; } private: diff --git a/src/Mobs/Zombie.h b/src/Mobs/Zombie.h index c56409570..082573d8b 100644 --- a/src/Mobs/Zombie.h +++ b/src/Mobs/Zombie.h @@ -19,8 +19,10 @@ public: virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; virtual void MoveToPosition(const Vector3d & a_Position) override; - bool IsVillagerZombie(void) const {return m_IsVillagerZombie; } - bool IsConverting (void) const {return m_IsConverting; } + virtual bool IsUndead(void) override { return true; } + + bool IsVillagerZombie(void) const { return m_IsVillagerZombie; } + bool IsConverting (void) const { return m_IsConverting; } private: diff --git a/src/Mobs/ZombiePigman.h b/src/Mobs/ZombiePigman.h index a2ebc87cb..a4bad7efb 100644 --- a/src/Mobs/ZombiePigman.h +++ b/src/Mobs/ZombiePigman.h @@ -18,6 +18,8 @@ public: virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; virtual void KilledBy(TakeDamageInfo & a_TDI) override; + + virtual bool IsUndead(void) override { return true; } } ; -- cgit v1.2.3 From ed01e12ed732fc9e3516ed263ebb73978b6f82f6 Mon Sep 17 00:00:00 2001 From: archshift Date: Sat, 19 Jul 2014 14:50:01 -0700 Subject: main.cpp: Fixed warnings with g_TERMINATE_EVENT_RAISED and g_SERVER_TERMINATED --- src/Root.cpp | 2 -- src/Root.h | 2 ++ src/main.cpp | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Root.cpp b/src/Root.cpp index 6347adcf0..d727e34a3 100644 --- a/src/Root.cpp +++ b/src/Root.cpp @@ -30,8 +30,6 @@ #include #endif -extern bool g_TERMINATE_EVENT_RAISED; - diff --git a/src/Root.h b/src/Root.h index acd3e9754..b31059e71 100644 --- a/src/Root.h +++ b/src/Root.h @@ -40,6 +40,8 @@ namespace Json class cRoot { public: + static bool g_TERMINATE_EVENT_RAISED; + static cRoot * Get() { return s_Root; } // tolua_end diff --git a/src/main.cpp b/src/main.cpp index 0ff9361be..d8b14cacc 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -12,8 +12,8 @@ #endif // _MSC_VER // Here, we have some ALL CAPS variables, to give the impression that this is deeeep, gritty programming :P -bool g_TERMINATE_EVENT_RAISED = false; // If something has told the server to stop; checked periodically in cRoot -bool g_SERVER_TERMINATED = false; // Set to true when the server terminates, so our CTRL handler can then tell Windows to close the console +bool cRoot::g_TERMINATE_EVENT_RAISED = false; // If something has told the server to stop; checked periodically in cRoot +static bool g_SERVER_TERMINATED = false; // Set to true when the server terminates, so our CTRL handler can then tell the OS to close the console @@ -52,7 +52,7 @@ bool g_ShouldLogCommOut; void NonCtrlHandler(int a_Signal) { LOGD("Terminate event raised from std::signal"); - g_TERMINATE_EVENT_RAISED = true; + cRoot::g_TERMINATE_EVENT_RAISED = true; switch (a_Signal) { @@ -155,7 +155,7 @@ LONG WINAPI LastChanceExceptionFilter(__in struct _EXCEPTION_POINTERS * a_Except // Handle CTRL events in windows, including console window close BOOL CtrlHandler(DWORD fdwCtrlType) { - g_TERMINATE_EVENT_RAISED = true; + cRoot::g_TERMINATE_EVENT_RAISED = true; LOGD("Terminate event raised from the Windows CtrlHandler"); if (fdwCtrlType == CTRL_CLOSE_EVENT) // Console window closed via 'x' button, Windows will try to close immediately, therefore... -- cgit v1.2.3 From 1831c2e652a3cbcfb13a72cd1334d0959cb607a3 Mon Sep 17 00:00:00 2001 From: archshift Date: Sat, 19 Jul 2014 14:50:31 -0700 Subject: Socket: removed unused Socket destructor --- src/OSSupport/Socket.cpp | 9 --------- src/OSSupport/Socket.h | 1 - 2 files changed, 10 deletions(-) diff --git a/src/OSSupport/Socket.cpp b/src/OSSupport/Socket.cpp index 47d9f331d..c07d31c8b 100644 --- a/src/OSSupport/Socket.cpp +++ b/src/OSSupport/Socket.cpp @@ -25,15 +25,6 @@ cSocket::cSocket(xSocket a_Socket) -cSocket::~cSocket() -{ - // Do NOT close the socket; this class is an API wrapper, not a RAII! -} - - - - - cSocket::operator cSocket::xSocket() const { return m_Socket; diff --git a/src/OSSupport/Socket.h b/src/OSSupport/Socket.h index 35ecadfa0..e4ec895cb 100644 --- a/src/OSSupport/Socket.h +++ b/src/OSSupport/Socket.h @@ -41,7 +41,6 @@ public: cSocket(void) : m_Socket(INVALID_SOCKET) {} cSocket(xSocket a_Socket); - ~cSocket(); bool IsValid(void) const { return IsValidSocket(m_Socket); } void CloseSocket(void); -- cgit v1.2.3 From 638ea10027f0e01a37d2592185e735e4c6f28338 Mon Sep 17 00:00:00 2001 From: archshift Date: Sat, 19 Jul 2014 15:28:55 -0700 Subject: ChatColor.h: The @deprecated tag slipped. Oops. --- src/ChatColor.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ChatColor.h b/src/ChatColor.h index 5a81c7edd..74eb7d5dc 100644 --- a/src/ChatColor.h +++ b/src/ChatColor.h @@ -9,10 +9,10 @@ class cChatColor { public: - static const char * Color; + static const char * Delimiter; /** @deprecated use ChatColor::Delimiter instead */ - static const char * Delimiter; + static const char * Color; static const char * Black; static const char * Navy; -- cgit v1.2.3 From 14826b660649c87c002b4ba23a255007f141dab4 Mon Sep 17 00:00:00 2001 From: archshift Date: Sat, 19 Jul 2014 15:44:19 -0700 Subject: main.cpp: field style fixes --- src/Root.cpp | 8 ++++---- src/Root.h | 2 +- src/main.cpp | 14 +++++++------- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/Root.cpp b/src/Root.cpp index d727e34a3..ba25b97eb 100644 --- a/src/Root.cpp +++ b/src/Root.cpp @@ -77,7 +77,7 @@ void cRoot::InputThread(void * a_Params) cLogCommandOutputCallback Output; - while (!self.m_bStop && !self.m_bRestart && !g_TERMINATE_EVENT_RAISED && std::cin.good()) + while (!self.m_bStop && !self.m_bRestart && !m_TerminateEventRaised && std::cin.good()) { AString Command; std::getline(std::cin, Command); @@ -87,7 +87,7 @@ void cRoot::InputThread(void * a_Params) } } - if (g_TERMINATE_EVENT_RAISED || !std::cin.good()) + if (m_TerminateEventRaised || !std::cin.good()) { // We have come here because the std::cin has received an EOF / a terminate signal has been sent, and the server is still running; stop the server: self.m_bStop = true; @@ -203,12 +203,12 @@ void cRoot::Start(void) EnableMenuItem(hmenu, SC_CLOSE, MF_ENABLED); // Re-enable close button #endif - while (!m_bStop && !m_bRestart && !g_TERMINATE_EVENT_RAISED) // These are modified by external threads + while (!m_bStop && !m_bRestart && !m_TerminateEventRaised) // These are modified by external threads { cSleep::MilliSleep(1000); } - if (g_TERMINATE_EVENT_RAISED) + if (m_TerminateEventRaised) { m_bStop = true; } diff --git a/src/Root.h b/src/Root.h index b31059e71..08aafe3c9 100644 --- a/src/Root.h +++ b/src/Root.h @@ -40,7 +40,7 @@ namespace Json class cRoot { public: - static bool g_TERMINATE_EVENT_RAISED; + static bool m_TerminateEventRaised; static cRoot * Get() { return s_Root; } // tolua_end diff --git a/src/main.cpp b/src/main.cpp index d8b14cacc..3e91149af 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -11,9 +11,9 @@ #include #endif // _MSC_VER -// Here, we have some ALL CAPS variables, to give the impression that this is deeeep, gritty programming :P -bool cRoot::g_TERMINATE_EVENT_RAISED = false; // If something has told the server to stop; checked periodically in cRoot -static bool g_SERVER_TERMINATED = false; // Set to true when the server terminates, so our CTRL handler can then tell the OS to close the console + +bool cRoot::m_TerminateEventRaised = false; // If something has told the server to stop; checked periodically in cRoot +static bool g_ServerTerminated = false; // Set to true when the server terminates, so our CTRL handler can then tell the OS to close the console @@ -52,7 +52,7 @@ bool g_ShouldLogCommOut; void NonCtrlHandler(int a_Signal) { LOGD("Terminate event raised from std::signal"); - cRoot::g_TERMINATE_EVENT_RAISED = true; + cRoot::m_TerminateEventRaised = true; switch (a_Signal) { @@ -155,12 +155,12 @@ LONG WINAPI LastChanceExceptionFilter(__in struct _EXCEPTION_POINTERS * a_Except // Handle CTRL events in windows, including console window close BOOL CtrlHandler(DWORD fdwCtrlType) { - cRoot::g_TERMINATE_EVENT_RAISED = true; + cRoot::m_TerminateEventRaised = true; LOGD("Terminate event raised from the Windows CtrlHandler"); if (fdwCtrlType == CTRL_CLOSE_EVENT) // Console window closed via 'x' button, Windows will try to close immediately, therefore... { - while (!g_SERVER_TERMINATED) { cSleep::MilliSleep(100); } // Delay as much as possible to try to get the server to shut down cleanly + while (!g_ServerTerminated) { cSleep::MilliSleep(100); } // Delay as much as possible to try to get the server to shut down cleanly } return TRUE; @@ -296,7 +296,7 @@ int main( int argc, char **argv ) DeinitLeakFinder(); #endif - g_SERVER_TERMINATED = true; + g_ServerTerminated = true; return EXIT_SUCCESS; } -- cgit v1.2.3 From 9e155c6add9a6108ee86d775910e9a396466ee7b Mon Sep 17 00:00:00 2001 From: archshift Date: Sun, 20 Jul 2014 01:38:36 -0700 Subject: Added destroy-timer system to splash potion entities --- src/Entities/SplashPotionEntity.cpp | 7 ++++--- src/Entities/SplashPotionEntity.h | 20 ++++++++++++++++++++ 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/src/Entities/SplashPotionEntity.cpp b/src/Entities/SplashPotionEntity.cpp index 13cbcb0fc..c1623845f 100644 --- a/src/Entities/SplashPotionEntity.cpp +++ b/src/Entities/SplashPotionEntity.cpp @@ -78,7 +78,8 @@ cSplashPotionEntity::cSplashPotionEntity( super(pkSplashPotion, a_Creator, a_X, a_Y, a_Z, 0.25, 0.25), m_EntityEffectType(a_EntityEffectType), m_EntityEffect(a_EntityEffect), - m_PotionColor(a_PotionColor) + m_PotionColor(a_PotionColor), + m_DestroyTimer(-1) { SetSpeed(a_Speed); } @@ -90,7 +91,7 @@ cSplashPotionEntity::cSplashPotionEntity( void cSplashPotionEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) { Splash(a_HitPos); - Destroy(); + m_DestroyTimer = 2; } @@ -101,7 +102,7 @@ void cSplashPotionEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_ { a_EntityHit.TakeDamage(dtRangedAttack, this, 0, 1); Splash(a_HitPos); - Destroy(true); + m_DestroyTimer = 5; } diff --git a/src/Entities/SplashPotionEntity.h b/src/Entities/SplashPotionEntity.h index a33b06990..290dd81d4 100644 --- a/src/Entities/SplashPotionEntity.h +++ b/src/Entities/SplashPotionEntity.h @@ -52,10 +52,30 @@ protected: // cProjectileEntity overrides: virtual void OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) override; virtual void OnHitEntity (cEntity & a_EntityHit, const Vector3d & a_HitPos) override; + virtual void Tick (float a_Dt, cChunk & a_Chunk) override + { + if (m_DestroyTimer > 0) + { + m_DestroyTimer--; + if (m_DestroyTimer == 0) + { + Destroy(); + return; + } + } + else + { + super::Tick(a_Dt, a_Chunk); + } + } /** Splashes the potion, fires its particle effects and sounds @param a_HitPos The position where the potion will splash */ void Splash(const Vector3d & a_HitPos); virtual void SpawnOn(cClientHandle & a_Client) override; + +private: + /** Time in ticks to wait for the hit animation to begin before destroying */ + int m_DestroyTimer; } ; // tolua_export -- cgit v1.2.3 From 726312602d293117fc4999897ef56869f2fef534 Mon Sep 17 00:00:00 2001 From: archshift Date: Sun, 20 Jul 2014 01:43:07 -0700 Subject: Added m_TicksAlive to entities, allows projectiles to hit their creators --- src/Entities/Entity.cpp | 3 +++ src/Entities/Entity.h | 6 ++++++ src/Entities/ProjectileEntity.cpp | 8 +++++--- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index f9331ede8..5a3bbcdc4 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -49,6 +49,7 @@ cEntity::cEntity(eEntityType a_EntityType, double a_X, double a_Y, double a_Z, d , m_IsSubmerged(false) , m_AirLevel(0) , m_AirTickTimer(0) + , m_TicksAlive(0) , m_HeadYaw(0.0) , m_Rot(0.0, 0.0, 0.0) , m_Pos(a_X, a_Y, a_Z) @@ -559,6 +560,8 @@ void cEntity::SetHealth(int a_Health) void cEntity::Tick(float a_Dt, cChunk & a_Chunk) { + m_TicksAlive++; + if (m_InvulnerableTicks > 0) { m_InvulnerableTicks--; diff --git a/src/Entities/Entity.h b/src/Entities/Entity.h index 88f8528e9..83fe76e7e 100644 --- a/src/Entities/Entity.h +++ b/src/Entities/Entity.h @@ -416,6 +416,9 @@ public: /** Gets remaining air of a monster */ int GetAirLevel(void) const { return m_AirLevel; } + /** Gets number of ticks this entity has existed for */ + long int GetTicksAlive(void) const { return m_TicksAlive; } + /** Gets the invulnerable ticks from the entity */ int GetInvulnerableTicks(void) const { return m_InvulnerableTicks; } @@ -521,6 +524,9 @@ protected: int m_AirLevel; int m_AirTickTimer; + /** The number of ticks this entity has been alive for */ + long int m_TicksAlive; + private: /** Measured in degrees, [-180, +180) */ double m_HeadYaw; diff --git a/src/Entities/ProjectileEntity.cpp b/src/Entities/ProjectileEntity.cpp index a55c9b895..b5e81bc0c 100644 --- a/src/Entities/ProjectileEntity.cpp +++ b/src/Entities/ProjectileEntity.cpp @@ -146,9 +146,11 @@ public: (a_Entity->GetUniqueID() == m_Projectile->GetCreatorUniqueID()) // Do not check whoever shot the projectile ) { - // TODO: Don't check creator only for the first 5 ticks - // so that arrows stuck in ground and dug up can hurt the player - return false; + // Don't check creator only for the first 5 ticks so that projectiles can collide with the creator + if (m_Projectile->GetTicksAlive() <= 5) + { + return false; + } } cBoundingBox EntBox(a_Entity->GetPosition(), a_Entity->GetWidth() / 2, a_Entity->GetHeight()); -- cgit v1.2.3 From e8262373e1608c5527779953c9a677dac7b020d8 Mon Sep 17 00:00:00 2001 From: archshift Date: Sun, 20 Jul 2014 03:19:46 -0700 Subject: NBTChunkSerializer.cpp: Added break after serializing the splash potion --- src/WorldStorage/NBTChunkSerializer.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/WorldStorage/NBTChunkSerializer.cpp b/src/WorldStorage/NBTChunkSerializer.cpp index 62db302ef..4857da1b6 100644 --- a/src/WorldStorage/NBTChunkSerializer.cpp +++ b/src/WorldStorage/NBTChunkSerializer.cpp @@ -614,6 +614,7 @@ void cNBTChunkSerializer::AddProjectileEntity(cProjectileEntity * a_Projectile) m_Writer.AddShort("EffectIntensity", Potion->GetEntityEffect().GetIntensity()); m_Writer.AddDouble("EffectDistanceModifier", Potion->GetEntityEffect().GetDistanceModifier()); m_Writer.AddInt("PotionName", Potion->GetPotionColor()); + break; } case cProjectileEntity::pkGhastFireball: { -- cgit v1.2.3 From f68b04e0294e5bc854fa6daad061e0280e5bb4f6 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sun, 20 Jul 2014 12:00:20 +0100 Subject: Proper comment for DropBlock() --- src/Blocks/BlockHandler.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Blocks/BlockHandler.h b/src/Blocks/BlockHandler.h index ee4d4a6fe..a6810933c 100644 --- a/src/Blocks/BlockHandler.h +++ b/src/Blocks/BlockHandler.h @@ -71,13 +71,16 @@ public: /// 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, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) {}; - /** Called when a Right Click to this Block is cancelled */ + /** Called when a right click to this block is cancelled */ virtual void OnCancelRightClick(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace) {}; /// 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); - /// Handles the dropping of a block based on what ConvertToDrops() returns. This will not destroy the block. a_Digger is the entity causing the drop; it may be NULL + /** Handles the dropping, but not destruction, of a block based on what ConvertTo(Verbatim)Pickups() returns, including the spawning of pickups and alertion of plugins + @param a_Digger The entity causing the drop; it may be NULL + @param a_DropVerbatim Calls ConvertToVerbatimPickups() instead of its counterpart, meaning the block itself is dropped by default (due to a speical tool or enchantment) + */ virtual void DropBlock(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_BlockPluginInterface, cEntity * a_Digger, int a_BlockX, int a_BlockY, int a_BlockZ, bool a_DropVerbatim = false); /// Returns step sound name of block -- cgit v1.2.3 From ba24f50e5ec36c4f4a119900e2dce9ff4b037ca9 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sun, 20 Jul 2014 13:39:14 +0100 Subject: Line tracer invalid chunk fix * Fixes #1230 * Additionally improved speed in some scenarios --- src/Entities/SplashPotionEntity.cpp | 13 ++++++------ src/LineBlockTracer.cpp | 40 ++++++++++++++++++------------------- 2 files changed, 27 insertions(+), 26 deletions(-) diff --git a/src/Entities/SplashPotionEntity.cpp b/src/Entities/SplashPotionEntity.cpp index c1623845f..6d874e957 100644 --- a/src/Entities/SplashPotionEntity.cpp +++ b/src/Entities/SplashPotionEntity.cpp @@ -33,15 +33,16 @@ public: /** Called by cWorld::ForEachEntity(), adds the stored entity effect to the entity, if it is close enough. */ virtual bool Item(cEntity * a_Entity) override { - double SplashDistance = (a_Entity->GetPosition() - m_HitPos).Length(); - if (SplashDistance >= 20) + if (!a_Entity->IsPawn()) { - // Too far away + // Not an entity that can take effects return false; } - if (!a_Entity->IsPawn()) + + double SplashDistance = (a_Entity->GetPosition() - m_HitPos).Length(); + if (SplashDistance >= 20) { - // Not an entity that can take effects + // Too far away return false; } @@ -114,7 +115,7 @@ void cSplashPotionEntity::Splash(const Vector3d & a_HitPos) cSplashPotionCallback Callback(a_HitPos, m_EntityEffectType, m_EntityEffect); m_World->ForEachEntity(Callback); - m_World->BroadcastSoundParticleEffect(2002, (int)a_HitPos.x, (int)a_HitPos.y, (int)a_HitPos.z, m_PotionColor); + m_World->BroadcastSoundParticleEffect(2002, (int)floor(a_HitPos.x), (int)floor(a_HitPos.y), (int)floor(a_HitPos.z), m_PotionColor); } diff --git a/src/LineBlockTracer.cpp b/src/LineBlockTracer.cpp index 2395aa43e..f03e796d1 100644 --- a/src/LineBlockTracer.cpp +++ b/src/LineBlockTracer.cpp @@ -212,6 +212,26 @@ bool cLineBlockTracer::Item(cChunk * a_Chunk) return true; } + if ((m_CurrentY < 0) || (m_CurrentY >= cChunkDef::Height)) + { + // We've gone out of the world, that's the end of this trace + double IntersectX, IntersectZ; + CalcXZIntersection(m_CurrentY, IntersectX, IntersectZ); + if (m_Callbacks->OnOutOfWorld(IntersectX, m_CurrentY, IntersectZ)) + { + // The callback terminated the trace + return false; + } + m_Callbacks->OnNoMoreHits(); + return true; + } + + // Update the current chunk + if (a_Chunk != NULL) + { + a_Chunk = a_Chunk->GetNeighborChunk(m_CurrentX, m_CurrentZ); + } + if (a_Chunk->IsValid()) { BLOCKTYPE BlockType; @@ -233,26 +253,6 @@ bool cLineBlockTracer::Item(cChunk * a_Chunk) return false; } } - - // Update the current chunk - if (a_Chunk != NULL) - { - a_Chunk = a_Chunk->GetNeighborChunk(m_CurrentX, m_CurrentZ); - } - - if ((m_CurrentY < 0) || (m_CurrentY >= cChunkDef::Height)) - { - // We've gone out of the world, that's the end of this trace - double IntersectX, IntersectZ; - CalcXZIntersection(m_CurrentY, IntersectX, IntersectZ); - if (m_Callbacks->OnOutOfWorld(IntersectX, m_CurrentY, IntersectZ)) - { - // The callback terminated the trace - return false; - } - m_Callbacks->OnNoMoreHits(); - return true; - } } } -- cgit v1.2.3 From 2823ee9026e32eac068389bc3dcd439d905c87b3 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sun, 20 Jul 2014 13:49:15 +0100 Subject: Revert "Only one instance of server can be started" This reverts commit 6484e9814a3a540518606f552398e0b82f91ab4d. * Fixes #1200 --- src/Server.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Server.cpp b/src/Server.cpp index 367d507bf..180ec2ca6 100644 --- a/src/Server.cpp +++ b/src/Server.cpp @@ -222,12 +222,14 @@ bool cServer::InitServer(cIniFile & a_SettingsIni) bool HasAnyPorts = false; AString Ports = a_SettingsIni.GetValueSet("Server", "Port", "25565"); + m_ListenThreadIPv4.SetReuseAddr(true); if (m_ListenThreadIPv4.Initialize(Ports)) { HasAnyPorts = true; } Ports = a_SettingsIni.GetValueSet("Server", "PortsIPv6", "25565"); + m_ListenThreadIPv6.SetReuseAddr(true); if (m_ListenThreadIPv6.Initialize(Ports)) { HasAnyPorts = true; -- cgit v1.2.3 From 7bf9da74413c69cbd79a9db81ba098e13b847904 Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Sun, 20 Jul 2014 16:23:45 +0200 Subject: First attempt for a new foliage finisher --- src/Generating/ComposableGenerator.cpp | 4 ++++ src/Generating/FinishGen.cpp | 32 ++++++++++++++++++++++++++++ src/Generating/FinishGen.h | 38 ++++++++++++++++++++++++++++++++++ 3 files changed, 74 insertions(+) diff --git a/src/Generating/ComposableGenerator.cpp b/src/Generating/ComposableGenerator.cpp index 7b6234161..21626e76b 100644 --- a/src/Generating/ComposableGenerator.cpp +++ b/src/Generating/ComposableGenerator.cpp @@ -338,6 +338,10 @@ void cComposableGenerator::InitFinishGens(cIniFile & a_IniFile) float Threshold = (float)a_IniFile.GetValueSetF("Generator", "DualRidgeCavesThreshold", 0.3); m_FinishGens.push_back(new cStructGenDualRidgeCaves(Seed, Threshold)); } + else if (NoCaseCompare(*itr, "Foliage") == 0) + { + m_FinishGens.push_back(new cFinishGenFoliage(Seed)); + } else if (NoCaseCompare(*itr, "Ice") == 0) { m_FinishGens.push_back(new cFinishGenIce); diff --git a/src/Generating/FinishGen.cpp b/src/Generating/FinishGen.cpp index f2d66af70..06c1dcbbe 100644 --- a/src/Generating/FinishGen.cpp +++ b/src/Generating/FinishGen.cpp @@ -159,6 +159,38 @@ void cFinishGenNetherClumpFoliage::TryPlaceClump(cChunkDesc & a_ChunkDesc, int a +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// cFinishGenFoliage: + +void cFinishGenFoliage::GenFinish(cChunkDesc & a_ChunkDesc) +{ + for (int x = 1; x < cChunkDef::Width; x++) + { + int xx = x + a_ChunkDesc.GetChunkX(); + for (int z = 1; z < cChunkDef::Width; z++) + { + int zz = z + a_ChunkDesc.GetChunkZ(); + //if (true) + if (m_Noise.CubicNoise2D((float) xx + m_Noise.CubicNoise1D(xx), zz + m_Noise.CubicNoise1D(zz)) < GetBiomeDensity(a_ChunkDesc.GetBiome(x, z))) + { + for (int y = a_ChunkDesc.GetHeight(x, z) + 1; y >= 1; y--) + { + if ( + (a_ChunkDesc.GetBlockType(x, y, z) == E_BLOCK_AIR) && + (a_ChunkDesc.GetBlockType(x, y - 1, z) == E_BLOCK_GRASS) + ) + { + a_ChunkDesc.SetBlockTypeMeta(x, y, z, E_BLOCK_TALL_GRASS, m_Noise.CubicNoise2D(xx * 100, zz * 100) > -0.2 ? 1 : 2); + } + } + } + } + } +} + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // cFinishGenSprinkleFoliage: diff --git a/src/Generating/FinishGen.h b/src/Generating/FinishGen.h index 2e5732929..ea322c7ae 100644 --- a/src/Generating/FinishGen.h +++ b/src/Generating/FinishGen.h @@ -69,6 +69,44 @@ protected: +class cFinishGenFoliage : + public cFinishGen +{ +public: + cFinishGenFoliage(int a_Seed) : m_Noise(a_Seed), m_Seed(a_Seed) {} + +protected: + cNoise m_Noise; + int m_Seed; + + // cFinishGen override: + virtual void GenFinish(cChunkDesc & a_ChunkDesc) override; + + float GetBiomeDensity(EMCSBiome a_Biome) + { + switch (a_Biome) + { + case biSavanna: + case biSavannaM: + case biSavannaPlateau: + case biSavannaPlateauM: + case biPlains: + { + return 0.0; + } + default: + { + return -0.4; + } + } + return -0.3; + } +}; + + + + + class cFinishGenSprinkleFoliage : public cFinishGen { -- cgit v1.2.3 From 51ad6cd1b22914aecd7e27d6a4a35853459fdb94 Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Sun, 20 Jul 2014 16:31:28 +0200 Subject: Fixed warnings --- src/Generating/FinishGen.cpp | 3 +-- src/Generating/FinishGen.h | 6 +++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/Generating/FinishGen.cpp b/src/Generating/FinishGen.cpp index 06c1dcbbe..86f5711a7 100644 --- a/src/Generating/FinishGen.cpp +++ b/src/Generating/FinishGen.cpp @@ -170,8 +170,7 @@ void cFinishGenFoliage::GenFinish(cChunkDesc & a_ChunkDesc) for (int z = 1; z < cChunkDef::Width; z++) { int zz = z + a_ChunkDesc.GetChunkZ(); - //if (true) - if (m_Noise.CubicNoise2D((float) xx + m_Noise.CubicNoise1D(xx), zz + m_Noise.CubicNoise1D(zz)) < GetBiomeDensity(a_ChunkDesc.GetBiome(x, z))) + if (m_Noise.CubicNoise2D((float) xx + m_Noise.CubicNoise1D(xx), (float) zz + m_Noise.CubicNoise1D(zz)) < GetBiomeDensity(a_ChunkDesc.GetBiome(x, z))) { for (int y = a_ChunkDesc.GetHeight(x, z) + 1; y >= 1; y--) { diff --git a/src/Generating/FinishGen.h b/src/Generating/FinishGen.h index ea322c7ae..d2968e592 100644 --- a/src/Generating/FinishGen.h +++ b/src/Generating/FinishGen.h @@ -92,14 +92,14 @@ protected: case biSavannaPlateauM: case biPlains: { - return 0.0; + return 0.0f; } default: { - return -0.4; + return -0.4f; } } - return -0.3; + return -0.3f; } }; -- cgit v1.2.3 From 76b79b51adfd8e71312cf777595483bb1ec68910 Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Sun, 20 Jul 2014 19:22:41 +0200 Subject: Renamed cFinishGenFoliage to cFinishGenTallGrass Better grass density Added double tall grass. --- src/Generating/ComposableGenerator.cpp | 8 ++++---- src/Generating/FinishGen.cpp | 34 ++++++++++++++++++++++++++-------- src/Generating/FinishGen.h | 9 ++++----- 3 files changed, 34 insertions(+), 17 deletions(-) diff --git a/src/Generating/ComposableGenerator.cpp b/src/Generating/ComposableGenerator.cpp index 21626e76b..2717f4e41 100644 --- a/src/Generating/ComposableGenerator.cpp +++ b/src/Generating/ComposableGenerator.cpp @@ -338,10 +338,6 @@ void cComposableGenerator::InitFinishGens(cIniFile & a_IniFile) float Threshold = (float)a_IniFile.GetValueSetF("Generator", "DualRidgeCavesThreshold", 0.3); m_FinishGens.push_back(new cStructGenDualRidgeCaves(Seed, Threshold)); } - else if (NoCaseCompare(*itr, "Foliage") == 0) - { - m_FinishGens.push_back(new cFinishGenFoliage(Seed)); - } else if (NoCaseCompare(*itr, "Ice") == 0) { m_FinishGens.push_back(new cFinishGenIce); @@ -419,6 +415,10 @@ void cComposableGenerator::InitFinishGens(cIniFile & a_IniFile) { m_FinishGens.push_back(new cFinishGenSprinkleFoliage(Seed)); } + else if (NoCaseCompare(*itr, "TallGrass") == 0) + { + m_FinishGens.push_back(new cFinishGenTallGrass(Seed)); + } else if (NoCaseCompare(*itr, "TestRails") == 0) { m_FinishGens.push_back(new cTestRailsGen(Seed, 100, 1, 7, 50)); diff --git a/src/Generating/FinishGen.cpp b/src/Generating/FinishGen.cpp index 86f5711a7..3ee657e38 100644 --- a/src/Generating/FinishGen.cpp +++ b/src/Generating/FinishGen.cpp @@ -162,24 +162,42 @@ void cFinishGenNetherClumpFoliage::TryPlaceClump(cChunkDesc & a_ChunkDesc, int a /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // cFinishGenFoliage: -void cFinishGenFoliage::GenFinish(cChunkDesc & a_ChunkDesc) +void cFinishGenTallGrass::GenFinish(cChunkDesc & a_ChunkDesc) { - for (int x = 1; x < cChunkDef::Width; x++) + for (int x = 0; x < cChunkDef::Width; x++) { - int xx = x + a_ChunkDesc.GetChunkX(); - for (int z = 1; z < cChunkDef::Width; z++) + float xx = (float) x + a_ChunkDesc.GetChunkX(); + for (int z = 0; z < cChunkDef::Width; z++) { - int zz = z + a_ChunkDesc.GetChunkZ(); - if (m_Noise.CubicNoise2D((float) xx + m_Noise.CubicNoise1D(xx), (float) zz + m_Noise.CubicNoise1D(zz)) < GetBiomeDensity(a_ChunkDesc.GetBiome(x, z))) + float zz = (float) z + a_ChunkDesc.GetChunkZ(); + float BiomeDensity = GetBiomeDensity(a_ChunkDesc.GetBiome(x, z)); + if (m_Noise.CubicNoise2D(xx + m_Noise.CubicNoise1D(xx), zz + m_Noise.CubicNoise1D(zz)) < BiomeDensity) { for (int y = a_ChunkDesc.GetHeight(x, z) + 1; y >= 1; y--) { if ( (a_ChunkDesc.GetBlockType(x, y, z) == E_BLOCK_AIR) && - (a_ChunkDesc.GetBlockType(x, y - 1, z) == E_BLOCK_GRASS) + ((a_ChunkDesc.GetBlockType(x, y - 1, z) == E_BLOCK_GRASS) || (a_ChunkDesc.GetBlockType(x, y - 1, z) == E_BLOCK_DIRT)) ) { - a_ChunkDesc.SetBlockTypeMeta(x, y, z, E_BLOCK_TALL_GRASS, m_Noise.CubicNoise2D(xx * 100, zz * 100) > -0.2 ? 1 : 2); + float GrassType = m_Noise.CubicNoise2D(xx * 50, zz * 50); + if (GrassType < 0.2f) + { + a_ChunkDesc.SetBlockTypeMeta(x, y, z, E_BLOCK_TALL_GRASS, 1); + } + else if (GrassType < 0.8f) + { + a_ChunkDesc.SetBlockTypeMeta(x, y, z, E_BLOCK_TALL_GRASS, 2); + } + else + { + if (a_ChunkDesc.GetBlockType(x, y + 1, z) == E_BLOCK_AIR) + { + NIBBLETYPE Meta = m_Noise.CubicNoise2D(xx * 100, zz * 100) > -0.5f ? 2 : 3; + a_ChunkDesc.SetBlockTypeMeta(x, y, z, E_BLOCK_BIG_FLOWER, Meta); + a_ChunkDesc.SetBlockTypeMeta(x, y + 1, z, E_BLOCK_BIG_FLOWER, 8); + } + } } } } diff --git a/src/Generating/FinishGen.h b/src/Generating/FinishGen.h index d2968e592..17a807e9b 100644 --- a/src/Generating/FinishGen.h +++ b/src/Generating/FinishGen.h @@ -69,11 +69,11 @@ protected: -class cFinishGenFoliage : +class cFinishGenTallGrass : public cFinishGen { public: - cFinishGenFoliage(int a_Seed) : m_Noise(a_Seed), m_Seed(a_Seed) {} + cFinishGenTallGrass(int a_Seed) : m_Noise(a_Seed), m_Seed(a_Seed) {} protected: cNoise m_Noise; @@ -92,14 +92,13 @@ protected: case biSavannaPlateauM: case biPlains: { - return 0.0f; + return 0.4f; } default: { - return -0.4f; + return -0.6f; } } - return -0.3f; } }; -- cgit v1.2.3 From a4470da876f8588fb71733a961701461f320e084 Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Sun, 20 Jul 2014 22:43:31 +0200 Subject: Changed CubicNoiseXX to IntNoiseXX Added some comments --- src/Generating/FinishGen.cpp | 63 +++++++++++++++++++++++++------------------- src/Generating/FinishGen.h | 26 +++++++++--------- 2 files changed, 49 insertions(+), 40 deletions(-) diff --git a/src/Generating/FinishGen.cpp b/src/Generating/FinishGen.cpp index 3ee657e38..b332c4f9b 100644 --- a/src/Generating/FinishGen.cpp +++ b/src/Generating/FinishGen.cpp @@ -166,38 +166,47 @@ void cFinishGenTallGrass::GenFinish(cChunkDesc & a_ChunkDesc) { for (int x = 0; x < cChunkDef::Width; x++) { - float xx = (float) x + a_ChunkDesc.GetChunkX(); + int xx = x + a_ChunkDesc.GetChunkX() * cChunkDef::Width; for (int z = 0; z < cChunkDef::Width; z++) { - float zz = (float) z + a_ChunkDesc.GetChunkZ(); - float BiomeDensity = GetBiomeDensity(a_ChunkDesc.GetBiome(x, z)); - if (m_Noise.CubicNoise2D(xx + m_Noise.CubicNoise1D(xx), zz + m_Noise.CubicNoise1D(zz)) < BiomeDensity) + int zz = z + a_ChunkDesc.GetChunkZ() * cChunkDef::Width; + int BiomeDensity = GetBiomeDensity(a_ChunkDesc.GetBiome(x, z)); + + // Choose if we want to place long grass here. If not then bail out. + if ((m_Noise.IntNoise2DInt(xx + m_Noise.IntNoise1DInt(xx), zz + m_Noise.IntNoise1DInt(zz)) / 7 % 100) > BiomeDensity) { - for (int y = a_ChunkDesc.GetHeight(x, z) + 1; y >= 1; y--) - { - if ( - (a_ChunkDesc.GetBlockType(x, y, z) == E_BLOCK_AIR) && - ((a_ChunkDesc.GetBlockType(x, y - 1, z) == E_BLOCK_GRASS) || (a_ChunkDesc.GetBlockType(x, y - 1, z) == E_BLOCK_DIRT)) + continue; + } + + for (int y = a_ChunkDesc.GetHeight(x, z) + 1; y >= 1; y--) + { + // Check if long grass can be placed. + if ( + (a_ChunkDesc.GetBlockType(x, y, z) != E_BLOCK_AIR) || + ((a_ChunkDesc.GetBlockType(x, y - 1, z) != E_BLOCK_GRASS) && (a_ChunkDesc.GetBlockType(x, y - 1, z) != E_BLOCK_DIRT)) ) + { + continue; + } + + // Choose what long grass meta we should use. + int GrassType = m_Noise.IntNoise2DInt(xx * 50, zz * 50) / 7 % 100; + if (GrassType < 60) + { + a_ChunkDesc.SetBlockTypeMeta(x, y, z, E_BLOCK_TALL_GRASS, 1); + } + else if (GrassType < 90) + { + a_ChunkDesc.SetBlockTypeMeta(x, y, z, E_BLOCK_TALL_GRASS, 2); + } + else + { + // If double long grass we have to choose what type we should use. + if (a_ChunkDesc.GetBlockType(x, y + 1, z) == E_BLOCK_AIR) { - float GrassType = m_Noise.CubicNoise2D(xx * 50, zz * 50); - if (GrassType < 0.2f) - { - a_ChunkDesc.SetBlockTypeMeta(x, y, z, E_BLOCK_TALL_GRASS, 1); - } - else if (GrassType < 0.8f) - { - a_ChunkDesc.SetBlockTypeMeta(x, y, z, E_BLOCK_TALL_GRASS, 2); - } - else - { - if (a_ChunkDesc.GetBlockType(x, y + 1, z) == E_BLOCK_AIR) - { - NIBBLETYPE Meta = m_Noise.CubicNoise2D(xx * 100, zz * 100) > -0.5f ? 2 : 3; - a_ChunkDesc.SetBlockTypeMeta(x, y, z, E_BLOCK_BIG_FLOWER, Meta); - a_ChunkDesc.SetBlockTypeMeta(x, y + 1, z, E_BLOCK_BIG_FLOWER, 8); - } - } + NIBBLETYPE Meta = (m_Noise.IntNoise2DInt(xx * 100, zz * 100) / 7 % 100) > 25 ? 2 : 3; + a_ChunkDesc.SetBlockTypeMeta(x, y, z, E_BLOCK_BIG_FLOWER, Meta); + a_ChunkDesc.SetBlockTypeMeta(x, y + 1, z, E_BLOCK_BIG_FLOWER, 8); } } } diff --git a/src/Generating/FinishGen.h b/src/Generating/FinishGen.h index 17a807e9b..f673ac2c2 100644 --- a/src/Generating/FinishGen.h +++ b/src/Generating/FinishGen.h @@ -82,22 +82,22 @@ protected: // cFinishGen override: virtual void GenFinish(cChunkDesc & a_ChunkDesc) override; - float GetBiomeDensity(EMCSBiome a_Biome) + int GetBiomeDensity(EMCSBiome a_Biome) { switch (a_Biome) { - case biSavanna: - case biSavannaM: - case biSavannaPlateau: - case biSavannaPlateauM: - case biPlains: - { - return 0.4f; - } - default: - { - return -0.6f; - } + case biSavanna: + case biSavannaM: + case biSavannaPlateau: + case biSavannaPlateauM: + case biPlains: + { + return 70; + } + default: + { + return 20; + } } } }; -- cgit v1.2.3 From 8593d485799e04abd8d5a30bed5131f2608a915d Mon Sep 17 00:00:00 2001 From: archshift Date: Sun, 20 Jul 2014 15:01:15 -0700 Subject: Cuboid: added explicit copy assignment operator --- src/Cuboid.cpp | 11 +++++++++++ src/Cuboid.h | 2 ++ 2 files changed, 13 insertions(+) diff --git a/src/Cuboid.cpp b/src/Cuboid.cpp index d97447412..26e86c77b 100644 --- a/src/Cuboid.cpp +++ b/src/Cuboid.cpp @@ -24,6 +24,17 @@ static bool DoIntervalsIntersect(int a_Min1, int a_Max1, int a_Min2, int a_Max2) //////////////////////////////////////////////////////////////////////////////// // cCuboid: +cCuboid & cCuboid::operator=(cCuboid a_Other) +{ + std::swap(p1, a_Other.p1); + std::swap(p2, a_Other.p2); + return *this; +} + + + + + void cCuboid::Assign(int a_X1, int a_Y1, int a_Z1, int a_X2, int a_Y2, int a_Z2) { p1.x = a_X1; diff --git a/src/Cuboid.h b/src/Cuboid.h index 960af130b..7bdb21b00 100644 --- a/src/Cuboid.h +++ b/src/Cuboid.h @@ -19,6 +19,8 @@ public: cCuboid(const Vector3i & a_p1, const Vector3i & a_p2) : p1(a_p1), p2(a_p2) {} cCuboid(int a_X1, int a_Y1, int a_Z1) : p1(a_X1, a_Y1, a_Z1), p2(a_X1, a_Y1, a_Z1) {} cCuboid(int a_X1, int a_Y1, int a_Z1, int a_X2, int a_Y2, int a_Z2) : p1(a_X1, a_Y1, a_Z1), p2(a_X2, a_Y2, a_Z2) {} + + cCuboid & operator=(cCuboid a_Other); void Assign(int a_X1, int a_Y1, int a_Z1, int a_X2, int a_Y2, int a_Z2); void Assign(const cCuboid & a_SrcCuboid); -- cgit v1.2.3 From 0c816dd6973ea15863b3e6f0a842b9b1e5fe2f3d Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Mon, 21 Jul 2014 10:58:13 +0200 Subject: Fixed indentation --- src/Generating/FinishGen.h | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/Generating/FinishGen.h b/src/Generating/FinishGen.h index f673ac2c2..0688e1162 100644 --- a/src/Generating/FinishGen.h +++ b/src/Generating/FinishGen.h @@ -86,18 +86,18 @@ protected: { switch (a_Biome) { - case biSavanna: - case biSavannaM: - case biSavannaPlateau: - case biSavannaPlateauM: - case biPlains: - { - return 70; - } - default: - { - return 20; - } + case biSavanna: + case biSavannaM: + case biSavannaPlateau: + case biSavannaPlateauM: + case biPlains: + { + return 70; + } + default: + { + return 20; + } } } }; -- cgit v1.2.3 From ce956bcdf276daa288c35d702885bba90f6ce283 Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Mon, 21 Jul 2014 16:01:16 +0200 Subject: Removed y for-loop. Only the top block now gets long grass. --- src/Generating/FinishGen.cpp | 54 ++++++++++++++++++++++---------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/src/Generating/FinishGen.cpp b/src/Generating/FinishGen.cpp index b332c4f9b..26149f363 100644 --- a/src/Generating/FinishGen.cpp +++ b/src/Generating/FinishGen.cpp @@ -178,36 +178,36 @@ void cFinishGenTallGrass::GenFinish(cChunkDesc & a_ChunkDesc) continue; } - for (int y = a_ChunkDesc.GetHeight(x, z) + 1; y >= 1; y--) + // Get the top block + 1. This is the place where the grass would finaly be placed. + int y = a_ChunkDesc.GetHeight(x, z) + 1; + + // Check if long grass can be placed. + if ( + (a_ChunkDesc.GetBlockType(x, y, z) != E_BLOCK_AIR) || + ((a_ChunkDesc.GetBlockType(x, y - 1, z) != E_BLOCK_GRASS) && (a_ChunkDesc.GetBlockType(x, y - 1, z) != E_BLOCK_DIRT)) + ) { - // Check if long grass can be placed. - if ( - (a_ChunkDesc.GetBlockType(x, y, z) != E_BLOCK_AIR) || - ((a_ChunkDesc.GetBlockType(x, y - 1, z) != E_BLOCK_GRASS) && (a_ChunkDesc.GetBlockType(x, y - 1, z) != E_BLOCK_DIRT)) - ) - { - continue; - } + continue; + } - // Choose what long grass meta we should use. - int GrassType = m_Noise.IntNoise2DInt(xx * 50, zz * 50) / 7 % 100; - if (GrassType < 60) - { - a_ChunkDesc.SetBlockTypeMeta(x, y, z, E_BLOCK_TALL_GRASS, 1); - } - else if (GrassType < 90) - { - a_ChunkDesc.SetBlockTypeMeta(x, y, z, E_BLOCK_TALL_GRASS, 2); - } - else + // Choose what long grass meta we should use. + int GrassType = m_Noise.IntNoise2DInt(xx * 50, zz * 50) / 7 % 100; + if (GrassType < 60) + { + a_ChunkDesc.SetBlockTypeMeta(x, y, z, E_BLOCK_TALL_GRASS, 1); + } + else if (GrassType < 90) + { + a_ChunkDesc.SetBlockTypeMeta(x, y, z, E_BLOCK_TALL_GRASS, 2); + } + else + { + // If double long grass we have to choose what type we should use. + if (a_ChunkDesc.GetBlockType(x, y + 1, z) == E_BLOCK_AIR) { - // If double long grass we have to choose what type we should use. - if (a_ChunkDesc.GetBlockType(x, y + 1, z) == E_BLOCK_AIR) - { - NIBBLETYPE Meta = (m_Noise.IntNoise2DInt(xx * 100, zz * 100) / 7 % 100) > 25 ? 2 : 3; - a_ChunkDesc.SetBlockTypeMeta(x, y, z, E_BLOCK_BIG_FLOWER, Meta); - a_ChunkDesc.SetBlockTypeMeta(x, y + 1, z, E_BLOCK_BIG_FLOWER, 8); - } + NIBBLETYPE Meta = (m_Noise.IntNoise2DInt(xx * 100, zz * 100) / 7 % 100) > 25 ? 2 : 3; + a_ChunkDesc.SetBlockTypeMeta(x, y, z, E_BLOCK_BIG_FLOWER, Meta); + a_ChunkDesc.SetBlockTypeMeta(x, y + 1, z, E_BLOCK_BIG_FLOWER, 8); } } } -- cgit v1.2.3 From 39623251c4e41e882abba767123f21b49a181ffc Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Mon, 21 Jul 2014 16:34:35 +0200 Subject: Fixed a missing enter. --- src/Generating/FinishGen.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Generating/FinishGen.cpp b/src/Generating/FinishGen.cpp index 26149f363..e6c31e43f 100644 --- a/src/Generating/FinishGen.cpp +++ b/src/Generating/FinishGen.cpp @@ -217,6 +217,7 @@ void cFinishGenTallGrass::GenFinish(cChunkDesc & a_ChunkDesc) + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // cFinishGenSprinkleFoliage: -- cgit v1.2.3 From 6be79575fd50e37ac275bd0cb9d16f9e51e8a225 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sun, 20 Jul 2014 23:10:31 +0200 Subject: Style: Normalized spaces after if, for and while. --- src/Bindings/ManualBindings.cpp | 22 ++++++++-------- src/Bindings/PluginManager.cpp | 2 +- src/Bindings/WebPlugin.cpp | 10 +++---- src/Blocks/BlockTorch.h | 7 ++--- src/Chunk.cpp | 5 ++-- src/CraftingRecipes.cpp | 2 +- src/Defines.h | 2 +- src/Entities/Player.cpp | 56 ++++++++++++++++++++-------------------- src/Globals.h | 2 +- src/GroupManager.cpp | 4 +-- src/Inventory.cpp | 14 +++++----- src/Items/ItemHandler.cpp | 2 +- src/Log.cpp | 8 +++--- src/MobProximityCounter.cpp | 4 +-- src/MobSpawner.cpp | 2 +- src/Mobs/Monster.cpp | 2 +- src/OSSupport/Errors.cpp | 4 +-- src/OSSupport/Semaphore.cpp | 12 ++++----- src/OSSupport/Thread.cpp | 10 +++---- src/Protocol/Protocol17x.cpp | 2 +- src/Root.cpp | 6 ++--- src/Server.cpp | 2 +- src/Simulator/FireSimulator.cpp | 2 +- src/Simulator/FluidSimulator.cpp | 6 ++--- src/Tracer.cpp | 40 ++++++++++++++-------------- src/WebAdmin.cpp | 2 +- src/World.cpp | 6 ++--- src/WorldStorage/WSSCompact.cpp | 36 +++++++++++++------------- 28 files changed, 137 insertions(+), 135 deletions(-) diff --git a/src/Bindings/ManualBindings.cpp b/src/Bindings/ManualBindings.cpp index 4047adc3a..5e9e7349d 100644 --- a/src/Bindings/ManualBindings.cpp +++ b/src/Bindings/ManualBindings.cpp @@ -656,12 +656,12 @@ template< static int tolua_ForEach(lua_State * tolua_S) { int NumArgs = lua_gettop(tolua_S) - 1; /* This includes 'self' */ - if( NumArgs != 1 && NumArgs != 2) + if ((NumArgs != 1) && (NumArgs != 2)) { return lua_do_error(tolua_S, "Error in function call '#funcname#': Requires 1 or 2 arguments, got %i", NumArgs); } - Ty1 * self = (Ty1 *) tolua_tousertype(tolua_S, 1, NULL); + Ty1 * self = (Ty1 *)tolua_tousertype(tolua_S, 1, NULL); if (self == NULL) { return lua_do_error(tolua_S, "Error in function call '#funcname#': Not called on an object instance"); @@ -1360,7 +1360,7 @@ static int tolua_cPluginManager_AddHook(lua_State * tolua_S) static int tolua_cPluginManager_ForEachCommand(lua_State * tolua_S) { int NumArgs = lua_gettop(tolua_S) - 1; /* This includes 'self' */ - if( NumArgs != 1) + if (NumArgs != 1) { LOGWARN("Error in function call 'ForEachCommand': Requires 1 argument, got %i", NumArgs); return 0; @@ -1437,7 +1437,7 @@ static int tolua_cPluginManager_ForEachCommand(lua_State * tolua_S) static int tolua_cPluginManager_ForEachConsoleCommand(lua_State * tolua_S) { int NumArgs = lua_gettop(tolua_S) - 1; /* This includes 'self' */ - if( NumArgs != 1) + if (NumArgs != 1) { LOGWARN("Error in function call 'ForEachConsoleCommand': Requires 1 argument, got %i", NumArgs); return 0; @@ -1938,16 +1938,16 @@ static int tolua_cPluginLua_AddWebTab(lua_State * tolua_S) return tolua_do_error(tolua_S, "#ferror calling function '#funcname#'", &tolua_err); } - if( Reference != LUA_REFNIL ) + if (Reference != LUA_REFNIL) { - if( !self->AddWebTab( Title.c_str(), tolua_S, Reference ) ) + if (!self->AddWebTab(Title.c_str(), tolua_S, Reference)) { - luaL_unref( tolua_S, LUA_REGISTRYINDEX, Reference ); + luaL_unref(tolua_S, LUA_REGISTRYINDEX, Reference); } } else { - LOGERROR("ERROR: cPluginLua:AddWebTab invalid function reference in 2nd argument (Title: \"%s\")", Title.c_str() ); + LOGWARNING("cPluginLua:AddWebTab: invalid function reference in 2nd argument (Title: \"%s\")", Title.c_str()); } return 0; @@ -2016,7 +2016,7 @@ static int tolua_push_StringStringMap(lua_State* tolua_S, std::map< std::string, lua_newtable(tolua_S); int top = lua_gettop(tolua_S); - for( std::map< std::string, std::string >::iterator it = a_StringStringMap.begin(); it != a_StringStringMap.end(); ++it ) + for (std::map::iterator it = a_StringStringMap.begin(); it != a_StringStringMap.end(); ++it) { const char* key = it->first.c_str(); const char* value = it->second.c_str(); @@ -2060,7 +2060,7 @@ static int tolua_get_HTTPRequest_FormData(lua_State* tolua_S) lua_newtable(tolua_S); int top = lua_gettop(tolua_S); - for( std::map< std::string, HTTPFormData >::iterator it = FormData.begin(); it != FormData.end(); ++it ) + for (std::map::iterator it = FormData.begin(); it != FormData.end(); ++it) { lua_pushstring(tolua_S, it->first.c_str() ); tolua_pushusertype(tolua_S, &(it->second), "HTTPFormData" ); @@ -2109,7 +2109,7 @@ static int tolua_cWebPlugin_GetTabNames(lua_State * tolua_S) lua_newtable(tolua_S); int index = 1; cWebPlugin::TabNameList::const_iterator iter = TabNames.begin(); - while(iter != TabNames.end()) + while (iter != TabNames.end()) { const AString & FancyName = iter->first; const AString & WebName = iter->second; diff --git a/src/Bindings/PluginManager.cpp b/src/Bindings/PluginManager.cpp index 2c0ce701b..33ecb95ad 100644 --- a/src/Bindings/PluginManager.cpp +++ b/src/Bindings/PluginManager.cpp @@ -1434,7 +1434,7 @@ cPluginManager::CommandResult cPluginManager::HandleCommand(cPlayer * a_Player, cPlugin * cPluginManager::GetPlugin( const AString & a_Plugin ) const { - for( PluginMap::const_iterator itr = m_Plugins.begin(); itr != m_Plugins.end(); ++itr ) + for (PluginMap::const_iterator itr = m_Plugins.begin(); itr != m_Plugins.end(); ++itr) { if (itr->second == NULL ) continue; if (itr->second->GetName().compare(a_Plugin) == 0) diff --git a/src/Bindings/WebPlugin.cpp b/src/Bindings/WebPlugin.cpp index 57ed9f6a4..a22826d1b 100644 --- a/src/Bindings/WebPlugin.cpp +++ b/src/Bindings/WebPlugin.cpp @@ -45,7 +45,7 @@ cWebPlugin::~cWebPlugin() std::list > cWebPlugin::GetTabNames(void) { std::list< std::pair< AString, AString > > NameList; - for( TabList::iterator itr = GetTabs().begin(); itr != GetTabs().end(); ++itr ) + for (TabList::iterator itr = GetTabs().begin(); itr != GetTabs().end(); ++itr ) { std::pair< AString, AString > StringPair; StringPair.first = (*itr)->Title; @@ -69,7 +69,7 @@ std::pair< AString, AString > cWebPlugin::GetTabNameForRequest(const HTTPRequest sWebPluginTab * Tab = NULL; if (Split.size() > 2) // If we got the tab name, show that page { - for( TabList::iterator itr = GetTabs().begin(); itr != GetTabs().end(); ++itr ) + for (TabList::iterator itr = GetTabs().begin(); itr != GetTabs().end(); ++itr ) { if ((*itr)->SafeTitle.compare(Split[2]) == 0) // This is the one! { @@ -80,7 +80,7 @@ std::pair< AString, AString > cWebPlugin::GetTabNameForRequest(const HTTPRequest } else // Otherwise show the first tab { - if( GetTabs().size() > 0 ) + if (GetTabs().size() > 0 ) Tab = *GetTabs().begin(); } @@ -100,10 +100,10 @@ std::pair< AString, AString > cWebPlugin::GetTabNameForRequest(const HTTPRequest AString cWebPlugin::SafeString(const AString & a_String) { AString RetVal; - for( unsigned int i = 0; i < a_String.size(); ++i ) + for (unsigned int i = 0; i < a_String.size(); ++i ) { char c = a_String[i]; - if( c == ' ' ) + if (c == ' ' ) { c = '_'; } diff --git a/src/Blocks/BlockTorch.h b/src/Blocks/BlockTorch.h index 73f2bf9a8..b62268187 100644 --- a/src/Blocks/BlockTorch.h +++ b/src/Blocks/BlockTorch.h @@ -99,7 +99,7 @@ public: static bool CanBePlacedOn(BLOCKTYPE a_BlockType, eBlockFace a_BlockFace) { - if ( !cBlockInfo::FullyOccupiesVoxel(a_BlockType) ) + if (!cBlockInfo::FullyOccupiesVoxel(a_BlockType) ) { return (a_BlockFace == BLOCK_FACE_TOP); // Allow placement only when torch upright (for glass, etc.); exceptions won't even be sent by client, no need to handle } @@ -119,7 +119,8 @@ public: 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 + // If on a block that can only hold a torch if torch is standing on it, return that face + if ( ((BlockInQuestion == E_BLOCK_GLASS) || (BlockInQuestion == E_BLOCK_FENCE) || (BlockInQuestion == E_BLOCK_NETHER_BRICK_FENCE) || @@ -167,7 +168,7 @@ public: // No need to check for upright orientation, it was done when the torch was placed return true; } - else if ( !cBlockInfo::FullyOccupiesVoxel(BlockInQuestion) ) + else if (!cBlockInfo::FullyOccupiesVoxel(BlockInQuestion) ) { return false; } diff --git a/src/Chunk.cpp b/src/Chunk.cpp index 6e2d3509d..25a58458e 100644 --- a/src/Chunk.cpp +++ b/src/Chunk.cpp @@ -1530,11 +1530,12 @@ void cChunk::FastSetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockT m_ChunkData.SetBlock(a_RelX, a_RelY, a_RelZ, a_BlockType); - if ( // Queue block to be sent only if ... + // Queue block to be sent only if ... + if ( a_SendToClients && // ... we are told to do so AND ... ( (OldBlockMeta != a_BlockMeta) || // ... the meta value is different OR ... - !( // ... the old and new blocktypes AREN'T liquids (because client doesn't need to distinguish betwixt them); see below for specifics: + !( // ... the old and new blocktypes AREN'T liquids (because client doesn't need to distinguish betwixt them): ((OldBlockType == E_BLOCK_STATIONARY_WATER) && (a_BlockType == E_BLOCK_WATER)) || // Replacing stationary water with water ((OldBlockType == E_BLOCK_WATER) && (a_BlockType == E_BLOCK_STATIONARY_WATER)) || // Replacing water with stationary water ((OldBlockType == E_BLOCK_STATIONARY_LAVA) && (a_BlockType == E_BLOCK_LAVA)) || // Replacing stationary water with water diff --git a/src/CraftingRecipes.cpp b/src/CraftingRecipes.cpp index e60c407d0..85a373279 100644 --- a/src/CraftingRecipes.cpp +++ b/src/CraftingRecipes.cpp @@ -582,7 +582,7 @@ cCraftingRecipes::cRecipe * cCraftingRecipes::FindRecipe(const cItem * a_Craftin // Get the real bounds of the crafting grid: int GridLeft = MAX_GRID_WIDTH, GridTop = MAX_GRID_HEIGHT; int GridRight = 0, GridBottom = 0; - for (int y = 0; y < a_GridHeight; y++ ) for(int x = 0; x < a_GridWidth; x++) + for (int y = 0; y < a_GridHeight; y++ ) for (int x = 0; x < a_GridWidth; x++) { if (!a_CraftingGrid[x + y * a_GridWidth].IsEmpty()) { diff --git a/src/Defines.h b/src/Defines.h index f7c8d0fc5..f4ebbd9ff 100644 --- a/src/Defines.h +++ b/src/Defines.h @@ -717,7 +717,7 @@ namespace ItemCategory inline bool BlockRequiresSpecialTool(BLOCKTYPE a_BlockType) { - if(!IsValidBlock(a_BlockType)) return false; + if (!IsValidBlock(a_BlockType)) return false; return cBlockInfo::RequiresSpecialTool(a_BlockType); } diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index 808b74023..6a52d8e29 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -286,13 +286,13 @@ void cPlayer::Tick(float a_Dt, cChunk & a_Chunk) short cPlayer::CalcLevelFromXp(short a_XpTotal) { // level 0 to 15 - if(a_XpTotal <= XP_TO_LEVEL15) + if (a_XpTotal <= XP_TO_LEVEL15) { return a_XpTotal / XP_PER_LEVEL_TO15; } // level 30+ - if(a_XpTotal > XP_TO_LEVEL30) + if (a_XpTotal > XP_TO_LEVEL30) { return (short) (151.5 + sqrt( 22952.25 - (14 * (2220 - a_XpTotal)))) / 7; } @@ -308,13 +308,13 @@ short cPlayer::CalcLevelFromXp(short a_XpTotal) short cPlayer::XpForLevel(short a_Level) { // level 0 to 15 - if(a_Level <= 15) + if (a_Level <= 15) { return a_Level * XP_PER_LEVEL_TO15; } // level 30+ - if(a_Level >= 31) + if (a_Level >= 31) { return (short) ( (3.5 * a_Level * a_Level) - (151.5 * a_Level) + 2220 ); } @@ -351,7 +351,7 @@ float cPlayer::GetXpPercentage() bool cPlayer::SetCurrentExperience(short int a_CurrentXp) { - if(!(a_CurrentXp >= 0) || (a_CurrentXp > (SHRT_MAX - m_LifetimeTotalXp))) + if (!(a_CurrentXp >= 0) || (a_CurrentXp > (SHRT_MAX - m_LifetimeTotalXp))) { LOGWARNING("Tried to update experiece with an invalid Xp value: %d", a_CurrentXp); return false; // oops, they gave us a dodgey number @@ -1370,9 +1370,9 @@ void cPlayer::AddToGroup( const AString & a_GroupName ) void cPlayer::RemoveFromGroup( const AString & a_GroupName ) { bool bRemoved = false; - for( GroupList::iterator itr = m_Groups.begin(); itr != m_Groups.end(); ++itr ) + for (GroupList::iterator itr = m_Groups.begin(); itr != m_Groups.end(); ++itr ) { - if( (*itr)->GetName().compare(a_GroupName ) == 0 ) + if ((*itr)->GetName().compare(a_GroupName ) == 0 ) { m_Groups.erase( itr ); bRemoved = true; @@ -1380,7 +1380,7 @@ void cPlayer::RemoveFromGroup( const AString & a_GroupName ) } } - if( bRemoved ) + if (bRemoved ) { LOGD("Removed %s from group %s", GetName().c_str(), a_GroupName.c_str() ); ResolveGroups(); @@ -1407,24 +1407,24 @@ bool cPlayer::HasPermission(const AString & a_Permission) AStringVector Split = StringSplit( a_Permission, "." ); PermissionMap Possibilities = m_ResolvedPermissions; // Now search the namespaces - while( Possibilities.begin() != Possibilities.end() ) + while (Possibilities.begin() != Possibilities.end() ) { PermissionMap::iterator itr = Possibilities.begin(); - if( itr->second ) + if (itr->second ) { AStringVector OtherSplit = StringSplit( itr->first, "." ); - if( OtherSplit.size() <= Split.size() ) + if (OtherSplit.size() <= Split.size() ) { unsigned int i; - for( i = 0; i < OtherSplit.size(); ++i ) + for (i = 0; i < OtherSplit.size(); ++i ) { - if( OtherSplit[i].compare( Split[i] ) != 0 ) + if (OtherSplit[i].compare( Split[i] ) != 0 ) { - if( OtherSplit[i].compare("*") == 0 ) return true; // WildCard man!! WildCard! + if (OtherSplit[i].compare("*") == 0 ) return true; // WildCard man!! WildCard! break; } } - if( i == Split.size() ) return true; + if (i == Split.size() ) return true; } } Possibilities.erase( itr ); @@ -1440,9 +1440,9 @@ bool cPlayer::HasPermission(const AString & a_Permission) bool cPlayer::IsInGroup( const AString & a_Group ) { - for( GroupList::iterator itr = m_ResolvedGroups.begin(); itr != m_ResolvedGroups.end(); ++itr ) + for (GroupList::iterator itr = m_ResolvedGroups.begin(); itr != m_ResolvedGroups.end(); ++itr ) { - if( a_Group.compare( (*itr)->GetName().c_str() ) == 0 ) + if (a_Group.compare( (*itr)->GetName().c_str() ) == 0 ) return true; } return false; @@ -1457,15 +1457,15 @@ void cPlayer::ResolvePermissions() m_ResolvedPermissions.clear(); // Start with an empty map // Copy all player specific permissions into the resolved permissions map - for( PermissionMap::iterator itr = m_Permissions.begin(); itr != m_Permissions.end(); ++itr ) + for (PermissionMap::iterator itr = m_Permissions.begin(); itr != m_Permissions.end(); ++itr ) { m_ResolvedPermissions[ itr->first ] = itr->second; } - for( GroupList::iterator GroupItr = m_ResolvedGroups.begin(); GroupItr != m_ResolvedGroups.end(); ++GroupItr ) + for (GroupList::iterator GroupItr = m_ResolvedGroups.begin(); GroupItr != m_ResolvedGroups.end(); ++GroupItr ) { const cGroup::PermissionMap & Permissions = (*GroupItr)->GetPermissions(); - for( cGroup::PermissionMap::const_iterator itr = Permissions.begin(); itr != Permissions.end(); ++itr ) + for (cGroup::PermissionMap::const_iterator itr = Permissions.begin(); itr != Permissions.end(); ++itr ) { m_ResolvedPermissions[ itr->first ] = itr->second; } @@ -1484,14 +1484,14 @@ void cPlayer::ResolveGroups() // Get a complete resolved list of all groups the player is in std::map< cGroup*, bool > AllGroups; // Use a map, because it's faster than iterating through a list to find duplicates GroupList ToIterate; - for( GroupList::iterator GroupItr = m_Groups.begin(); GroupItr != m_Groups.end(); ++GroupItr ) + for (GroupList::iterator GroupItr = m_Groups.begin(); GroupItr != m_Groups.end(); ++GroupItr ) { ToIterate.push_back( *GroupItr ); } - while( ToIterate.begin() != ToIterate.end() ) + while (ToIterate.begin() != ToIterate.end() ) { cGroup* CurrentGroup = *ToIterate.begin(); - if( AllGroups.find( CurrentGroup ) != AllGroups.end() ) + if (AllGroups.find( CurrentGroup ) != AllGroups.end() ) { LOGWARNING("ERROR: Player \"%s\" is in the group multiple times (\"%s\"). Please fix your settings in users.ini!", GetName().c_str(), CurrentGroup->GetName().c_str() @@ -1502,9 +1502,9 @@ void cPlayer::ResolveGroups() AllGroups[ CurrentGroup ] = true; m_ResolvedGroups.push_back( CurrentGroup ); // Add group to resolved list const cGroup::GroupList & Inherits = CurrentGroup->GetInherits(); - for( cGroup::GroupList::const_iterator itr = Inherits.begin(); itr != Inherits.end(); ++itr ) + for (cGroup::GroupList::const_iterator itr = Inherits.begin(); itr != Inherits.end(); ++itr ) { - if( AllGroups.find( *itr ) != AllGroups.end() ) + if (AllGroups.find( *itr ) != AllGroups.end() ) { LOGERROR("ERROR: Player %s is in the same group multiple times due to inheritance (%s). FIX IT!", GetName().c_str(), (*itr)->GetName().c_str() ); continue; @@ -1522,12 +1522,12 @@ void cPlayer::ResolveGroups() AString cPlayer::GetColor(void) const { - if ( m_Color != '-' ) + if (m_Color != '-' ) { return cChatColor::Delimiter + m_Color; } - if ( m_Groups.size() < 1 ) + if (m_Groups.size() < 1 ) { return cChatColor::White; } @@ -1914,7 +1914,7 @@ cPlayer::StringList cPlayer::GetResolvedPermissions() StringList Permissions; const PermissionMap& ResolvedPermissions = m_ResolvedPermissions; - for( PermissionMap::const_iterator itr = ResolvedPermissions.begin(); itr != ResolvedPermissions.end(); ++itr ) + for (PermissionMap::const_iterator itr = ResolvedPermissions.begin(); itr != ResolvedPermissions.end(); ++itr ) { if (itr->second) { diff --git a/src/Globals.h b/src/Globals.h index 932040ec2..007fa10d0 100644 --- a/src/Globals.h +++ b/src/Globals.h @@ -309,7 +309,7 @@ void inline LOGERROR(const char* a_Format, ...) } #endif #define ASSERT(x) do { if (!(x)) { throw cAssertFailure();} } while (0) - #define testassert(x) do { if(!(x)) { REPORT_ERROR("Test failure: %s, file %s, line %d\n", #x, __FILE__, __LINE__); exit(1); } } while (0) + #define testassert(x) do { if (!(x)) { REPORT_ERROR("Test failure: %s, file %s, line %d\n", #x, __FILE__, __LINE__); exit(1); } } while (0) #define CheckAsserts(x) do { try {x} catch (cAssertFailure) { break; } REPORT_ERROR("Test failure: assert didn't fire for %s, file %s, line %d\n", #x, __FILE__, __LINE__); exit(1); } while (0) #else diff --git a/src/GroupManager.cpp b/src/GroupManager.cpp index a1cc396cf..685aece5a 100644 --- a/src/GroupManager.cpp +++ b/src/GroupManager.cpp @@ -27,7 +27,7 @@ struct cGroupManager::sGroupManagerState cGroupManager::~cGroupManager() { - for( GroupMap::iterator itr = m_pState->Groups.begin(); itr != m_pState->Groups.end(); ++itr ) + for (GroupMap::iterator itr = m_pState->Groups.begin(); itr != m_pState->Groups.end(); ++itr ) { delete itr->second; itr->second = NULL; @@ -211,7 +211,7 @@ bool cGroupManager::ExistsGroup( const AString & a_Name ) cGroup* cGroupManager::GetGroup( const AString & a_Name ) { GroupMap::iterator itr = m_pState->Groups.find( a_Name ); - if( itr != m_pState->Groups.end() ) + if (itr != m_pState->Groups.end() ) { return itr->second; } diff --git a/src/Inventory.cpp b/src/Inventory.cpp index 5f7c24b60..93b2c8eee 100644 --- a/src/Inventory.cpp +++ b/src/Inventory.cpp @@ -500,15 +500,15 @@ int cInventory::ArmorSlotNumToEntityEquipmentID(short a_ArmorSlotNum) bool cInventory::AddToBar( cItem & a_Item, const int a_Offset, const int a_Size, bool* a_bChangedSlots, int a_Mode /* = 0 */ ) { // Fill already present stacks - if( a_Mode < 2 ) + if (a_Mode < 2 ) { int MaxStackSize = cItemHandler::GetItemHandler(a_Item.m_ItemType)->GetMaxStackSize(); - for(int i = 0; i < a_Size; i++) + for (int i = 0; i < a_Size; i++) { - if( m_Slots[i + a_Offset].m_ItemType == a_Item.m_ItemType && m_Slots[i + a_Offset].m_ItemCount < MaxStackSize && m_Slots[i + a_Offset].m_ItemDamage == a_Item.m_ItemDamage ) + if (m_Slots[i + a_Offset].m_ItemType == a_Item.m_ItemType && m_Slots[i + a_Offset].m_ItemCount < MaxStackSize && m_Slots[i + a_Offset].m_ItemDamage == a_Item.m_ItemDamage ) { int NumFree = MaxStackSize - m_Slots[i + a_Offset].m_ItemCount; - if( NumFree >= a_Item.m_ItemCount ) + if (NumFree >= a_Item.m_ItemCount ) { // printf("1. Adding %i items ( free: %i )\n", a_Item.m_ItemCount, NumFree ); @@ -528,12 +528,12 @@ bool cInventory::AddToBar( cItem & a_Item, const int a_Offset, const int a_Size, } } - if( a_Mode > 0 ) + if (a_Mode > 0 ) { // If we got more left, find first empty slot - for(int i = 0; i < a_Size && a_Item.m_ItemCount > 0; i++) + for (int i = 0; i < a_Size && a_Item.m_ItemCount > 0; i++) { - if( m_Slots[i + a_Offset].m_ItemType == -1 ) + if (m_Slots[i + a_Offset].m_ItemType == -1 ) { m_Slots[i + a_Offset] = a_Item; a_Item.m_ItemCount = 0; diff --git a/src/Items/ItemHandler.cpp b/src/Items/ItemHandler.cpp index 178bc2fca..0a8638f3a 100644 --- a/src/Items/ItemHandler.cpp +++ b/src/Items/ItemHandler.cpp @@ -263,7 +263,7 @@ cItemHandler *cItemHandler::CreateItemHandler(int a_ItemType) void cItemHandler::Deinit() { - for(int i = 0; i < 2267; i++) + for (int i = 0; i < 2267; i++) { delete m_ItemHandler[i]; m_ItemHandler[i] = NULL; diff --git a/src/Log.cpp b/src/Log.cpp index 69b9c13a2..a70b09103 100644 --- a/src/Log.cpp +++ b/src/Log.cpp @@ -59,7 +59,7 @@ cLog * cLog::GetInstance() void cLog::CloseLog() { - if( m_File ) + if (m_File ) fclose (m_File); m_File = 0; } @@ -70,7 +70,7 @@ void cLog::CloseLog() void cLog::OpenLog( const char* a_FileName ) { - if(m_File) fclose (m_File); + if (m_File) fclose (m_File); #ifdef _MSC_VER fopen_s( &m_File, a_FileName, "a+" ); #else @@ -85,11 +85,11 @@ void cLog::OpenLog( const char* a_FileName ) void cLog::ClearLog() { #ifdef _MSC_VER - if( fopen_s( &m_File, "log.txt", "w" ) == 0) + if (fopen_s( &m_File, "log.txt", "w" ) == 0) fclose (m_File); #else m_File = fopen("log.txt", "w" ); - if( m_File ) + if (m_File ) fclose (m_File); #endif m_File = NULL; diff --git a/src/MobProximityCounter.cpp b/src/MobProximityCounter.cpp index f5d3e970c..82ba771ff 100644 --- a/src/MobProximityCounter.cpp +++ b/src/MobProximityCounter.cpp @@ -34,7 +34,7 @@ void cMobProximityCounter::CollectMob(cEntity& a_Monster, cChunk& a_Chunk, doubl void cMobProximityCounter::convertMaps() { - for(tMonsterToDistance::const_iterator itr = m_MonsterToDistance.begin(); itr != m_MonsterToDistance.end(); ++itr) + for (tMonsterToDistance::const_iterator itr = m_MonsterToDistance.begin(); itr != m_MonsterToDistance.end(); ++itr) { m_DistanceToMonster.insert(tDistanceToMonster::value_type(itr->second.m_Distance, sMonsterAndChunk(*itr->first, *itr->second.m_Chunk))); } @@ -55,7 +55,7 @@ cMobProximityCounter::sIterablePair cMobProximityCounter::getMobWithinThosesDist convertMaps(); } - for(tDistanceToMonster::const_iterator itr = m_DistanceToMonster.begin(); itr != m_DistanceToMonster.end(); ++itr) + for (tDistanceToMonster::const_iterator itr = m_DistanceToMonster.begin(); itr != m_DistanceToMonster.end(); ++itr) { if (toReturn.m_Begin == m_DistanceToMonster.end()) { diff --git a/src/MobSpawner.cpp b/src/MobSpawner.cpp index ce1187452..53c83f166 100644 --- a/src/MobSpawner.cpp +++ b/src/MobSpawner.cpp @@ -208,7 +208,7 @@ bool cMobSpawner::CanSpawnHere(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_R bool HasFloor = false; for (int x = 0; x < 2; ++x) { - for(int z = 0; z < 2; ++z) + for (int z = 0; z < 2; ++z) { CanSpawn = a_Chunk->UnboundedRelGetBlockType(a_RelX + x, a_RelY, a_RelZ + z, TargetBlock); CanSpawn = CanSpawn && (TargetBlock == E_BLOCK_AIR); diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp index 753a44914..c1247c1f8 100644 --- a/src/Mobs/Monster.cpp +++ b/src/Mobs/Monster.cpp @@ -281,7 +281,7 @@ void cMonster::Tick(float a_Dt, cChunk & a_Chunk) } Vector3f Distance = m_Destination - GetPosition(); - if(!ReachedDestination() && !ReachedFinalDestination()) // If we haven't reached any sort of destination, move + if (!ReachedDestination() && !ReachedFinalDestination()) // If we haven't reached any sort of destination, move { Distance.y = 0; Distance.Normalize(); diff --git a/src/OSSupport/Errors.cpp b/src/OSSupport/Errors.cpp index 6072b6ac6..02de28e4e 100644 --- a/src/OSSupport/Errors.cpp +++ b/src/OSSupport/Errors.cpp @@ -25,7 +25,7 @@ AString GetOSErrorString( int a_ErrNo ) #if !defined(__APPLE__) && ( _GNU_SOURCE ) && !defined(ANDROID_NDK) // GNU version of strerror_r() char * res = strerror_r( errno, buffer, ARRAYCOUNT(buffer) ); - if( res != NULL ) + if (res != NULL ) { Printf(Out, "%d: %s", a_ErrNo, res); return Out; @@ -34,7 +34,7 @@ AString GetOSErrorString( int a_ErrNo ) #else // XSI version of strerror_r(): int res = strerror_r( errno, buffer, ARRAYCOUNT(buffer) ); - if( res == 0 ) + if (res == 0 ) { Printf(Out, "%d: %s", a_ErrNo, buffer); return Out; diff --git a/src/OSSupport/Semaphore.cpp b/src/OSSupport/Semaphore.cpp index d919c4744..cb9ccc83b 100644 --- a/src/OSSupport/Semaphore.cpp +++ b/src/OSSupport/Semaphore.cpp @@ -22,13 +22,13 @@ cSemaphore::cSemaphore( unsigned int a_MaxCount, unsigned int a_InitialCount /* AString Name; Printf(Name, "cSemaphore%p", this ); m_Handle = sem_open(Name.c_str(), O_CREAT, 777, a_InitialCount); - if( m_Handle == SEM_FAILED ) + if (m_Handle == SEM_FAILED ) { LOG("ERROR: Could not create Semaphore. (%i)", errno ); } else { - if( sem_unlink(Name.c_str()) != 0 ) + if (sem_unlink(Name.c_str()) != 0 ) { LOG("ERROR: Could not unlink cSemaphore. (%i)", errno); } @@ -53,9 +53,9 @@ cSemaphore::~cSemaphore() #ifdef _WIN32 CloseHandle( m_Handle ); #else - if( m_bNamed ) + if (m_bNamed ) { - if( sem_close( (sem_t*)m_Handle ) != 0 ) + if (sem_close( (sem_t*)m_Handle ) != 0 ) { LOG("ERROR: Could not close cSemaphore. (%i)", errno); } @@ -77,7 +77,7 @@ cSemaphore::~cSemaphore() void cSemaphore::Wait() { #ifndef _WIN32 - if( sem_wait( (sem_t*)m_Handle ) != 0) + if (sem_wait( (sem_t*)m_Handle ) != 0) { LOG("ERROR: Could not wait for cSemaphore. (%i)", errno); } @@ -93,7 +93,7 @@ void cSemaphore::Wait() void cSemaphore::Signal() { #ifndef _WIN32 - if( sem_post( (sem_t*)m_Handle ) != 0 ) + if (sem_post( (sem_t*)m_Handle ) != 0 ) { LOG("ERROR: Could not signal cSemaphore. (%i)", errno); } diff --git a/src/OSSupport/Thread.cpp b/src/OSSupport/Thread.cpp index 163c9b0c9..811e7cb21 100644 --- a/src/OSSupport/Thread.cpp +++ b/src/OSSupport/Thread.cpp @@ -53,7 +53,7 @@ cThread::cThread( ThreadFunc a_ThreadFunction, void* a_Param, const char* a_Thre , m_Event( new cEvent() ) , m_StopEvent( 0 ) { - if( a_ThreadName ) + if (a_ThreadName ) { m_ThreadName.assign(a_ThreadName); } @@ -68,7 +68,7 @@ cThread::~cThread() delete m_Event; m_Event = NULL; - if( m_StopEvent ) + if (m_StopEvent ) { m_StopEvent->Wait(); delete m_StopEvent; @@ -82,12 +82,12 @@ cThread::~cThread() void cThread::Start( bool a_bWaitOnDelete /* = true */ ) { - if( a_bWaitOnDelete ) + if (a_bWaitOnDelete ) m_StopEvent = new cEvent(); #ifndef _WIN32 pthread_t SndThread; - if( pthread_create( &SndThread, NULL, MyThread, this) ) + if (pthread_create( &SndThread, NULL, MyThread, this) ) LOGERROR("ERROR: Could not create thread!"); #else DWORD ThreadID = 0; @@ -132,6 +132,6 @@ void *cThread::MyThread( void *a_Param ) ThreadFunction( ThreadParam ); - if( StopEvent ) StopEvent->Set(); + if (StopEvent ) StopEvent->Set(); return 0; } diff --git a/src/Protocol/Protocol17x.cpp b/src/Protocol/Protocol17x.cpp index 2707fbf9f..dadf82716 100644 --- a/src/Protocol/Protocol17x.cpp +++ b/src/Protocol/Protocol17x.cpp @@ -1587,7 +1587,7 @@ void cProtocol172::AddReceivedData(const char * a_Data, size_t a_Size) ASSERT(!"Read wrong number of bytes!"); m_Client->PacketError(PacketType); } - } // for(ever) + } // for (ever) // Log any leftover bytes into the logfile: if (g_ShouldLogCommIn && (m_ReceivedData.GetReadableSpace() > 0)) diff --git a/src/Root.cpp b/src/Root.cpp index ba25b97eb..e195b59ff 100644 --- a/src/Root.cpp +++ b/src/Root.cpp @@ -359,7 +359,7 @@ void cRoot::StopWorlds(void) void cRoot::UnloadWorlds(void) { m_pDefaultWorld = NULL; - for( WorldMap::iterator itr = m_WorldsByName.begin(); itr != m_WorldsByName.end(); ++itr ) + for (WorldMap::iterator itr = m_WorldsByName.begin(); itr != m_WorldsByName.end(); ++itr ) { delete itr->second; } @@ -382,7 +382,7 @@ cWorld* cRoot::GetDefaultWorld() cWorld* cRoot::GetWorld( const AString & a_WorldName ) { WorldMap::iterator itr = m_WorldsByName.find( a_WorldName ); - if( itr != m_WorldsByName.end() ) + if (itr != m_WorldsByName.end() ) return itr->second; return 0; } @@ -509,7 +509,7 @@ void cRoot::AuthenticateUser(int a_ClientID, const AString & a_Name, const AStri int cRoot::GetTotalChunkCount(void) { int res = 0; - for ( WorldMap::iterator itr = m_WorldsByName.begin(); itr != m_WorldsByName.end(); ++itr ) + for (WorldMap::iterator itr = m_WorldsByName.begin(); itr != m_WorldsByName.end(); ++itr ) { res += itr->second->GetNumChunks(); } diff --git a/src/Server.cpp b/src/Server.cpp index 180ec2ca6..0990fc398 100644 --- a/src/Server.cpp +++ b/src/Server.cpp @@ -631,7 +631,7 @@ void cServer::Shutdown(void) cRoot::Get()->SaveAllChunks(); cCSLock Lock(m_CSClients); - for( ClientList::iterator itr = m_Clients.begin(); itr != m_Clients.end(); ++itr ) + for (ClientList::iterator itr = m_Clients.begin(); itr != m_Clients.end(); ++itr ) { (*itr)->Destroy(); delete *itr; diff --git a/src/Simulator/FireSimulator.cpp b/src/Simulator/FireSimulator.cpp index 2164b6b10..69dc7164e 100644 --- a/src/Simulator/FireSimulator.cpp +++ b/src/Simulator/FireSimulator.cpp @@ -140,7 +140,7 @@ void cFireSimulator::SimulateChunk(float a_Dt, int a_ChunkX, int a_ChunkZ, cChun continue; } - if((itr->y > 0) && (!DoesBurnForever(a_Chunk->GetBlock(itr->x, itr->y - 1, itr->z)))) + if ((itr->y > 0) && (!DoesBurnForever(a_Chunk->GetBlock(itr->x, itr->y - 1, itr->z)))) { a_Chunk->SetMeta(x, y, z, BlockMeta + 1); } diff --git a/src/Simulator/FluidSimulator.cpp b/src/Simulator/FluidSimulator.cpp index 499e204a1..58501326f 100644 --- a/src/Simulator/FluidSimulator.cpp +++ b/src/Simulator/FluidSimulator.cpp @@ -159,18 +159,18 @@ Direction cFluidSimulator::GetFlowingDirection(int a_X, int a_Y, int a_Z, bool a { Vector3i *Pos = (*it); char BlockID = m_World.GetBlock(Pos->x, Pos->y, Pos->z); - if(IsAllowedBlock(BlockID)) + if (IsAllowedBlock(BlockID)) { char Meta = m_World.GetBlockMeta(Pos->x, Pos->y, Pos->z); - if(Meta > LowestPoint) + if (Meta > LowestPoint) { LowestPoint = Meta; X = Pos->x; Z = Pos->z; } } - else if(BlockID == E_BLOCK_AIR) + else if (BlockID == E_BLOCK_AIR) { LowestPoint = 9; // This always dominates X = Pos->x; diff --git a/src/Tracer.cpp b/src/Tracer.cpp index fd8a297c0..df01e9129 100644 --- a/src/Tracer.cpp +++ b/src/Tracer.cpp @@ -59,7 +59,7 @@ void cTracer::SetValues(const Vector3f & a_Start, const Vector3f & a_Direction) step.z = (int) SigNum(dir.z); // normalize the direction vector - if( dir.SqrLength() > 0.f ) dir.Normalize(); + if (dir.SqrLength() > 0.f ) dir.Normalize(); // how far we must move in the ray direction before // we encounter a new voxel in x-direction @@ -192,7 +192,7 @@ bool cTracer::Trace( const Vector3f & a_Start, const Vector3f & a_Direction, int if (step.y > 0.0f) { - if(pos.y >= end1.y) + if (pos.y >= end1.y) { reachedY = true; } @@ -313,7 +313,7 @@ int cTracer::GetHitNormal(const Vector3f & start, const Vector3f & end, const Ve Vector3i SmallBlockPos = a_BlockPos; char BlockID = m_World->GetBlock( a_BlockPos.x, a_BlockPos.y, a_BlockPos.z ); - if( BlockID == E_BLOCK_AIR || IsBlockWater(BlockID)) + if (BlockID == E_BLOCK_AIR || IsBlockWater(BlockID)) { return 0; } @@ -328,10 +328,10 @@ int cTracer::GetHitNormal(const Vector3f & start, const Vector3f & end, const Ve if (dot < 0) { int Lines = LinesCross( start.x, start.y, end.x, end.y, BlockPos.x, BlockPos.y, BlockPos.x, BlockPos.y + 1 ); - if(Lines == 1) + if (Lines == 1) { Lines = LinesCross( start.x, start.z, end.x, end.z, BlockPos.x, BlockPos.z, BlockPos.x, BlockPos.z + 1 ); - if(Lines == 1) + if (Lines == 1) { intersect3D_SegmentPlane( start, end, BlockPos, Vector3f(-1, 0, 0) ); return 1; @@ -339,13 +339,13 @@ int cTracer::GetHitNormal(const Vector3f & start, const Vector3f & end, const Ve } } dot = Look.Dot( Vector3f(0, 0, -1) ); // second face normal is z -1 - if(dot < 0) + if (dot < 0) { int Lines = LinesCross( start.z, start.y, end.z, end.y, BlockPos.z, BlockPos.y, BlockPos.z, BlockPos.y + 1 ); - if(Lines == 1) + if (Lines == 1) { Lines = LinesCross( start.z, start.x, end.z, end.x, BlockPos.z, BlockPos.x, BlockPos.z, BlockPos.x + 1 ); - if(Lines == 1) + if (Lines == 1) { intersect3D_SegmentPlane( start, end, BlockPos, Vector3f(0, 0, -1) ); return 2; @@ -353,13 +353,13 @@ int cTracer::GetHitNormal(const Vector3f & start, const Vector3f & end, const Ve } } dot = Look.Dot( Vector3f(1, 0, 0) ); // third face normal is x 1 - if(dot < 0) + if (dot < 0) { int Lines = LinesCross( start.x, start.y, end.x, end.y, BlockPos.x + 1, BlockPos.y, BlockPos.x + 1, BlockPos.y + 1 ); - if(Lines == 1) + if (Lines == 1) { Lines = LinesCross( start.x, start.z, end.x, end.z, BlockPos.x + 1, BlockPos.z, BlockPos.x + 1, BlockPos.z + 1 ); - if(Lines == 1) + if (Lines == 1) { intersect3D_SegmentPlane( start, end, BlockPos + Vector3f(1, 0, 0), Vector3f(1, 0, 0) ); return 3; @@ -367,13 +367,13 @@ int cTracer::GetHitNormal(const Vector3f & start, const Vector3f & end, const Ve } } dot = Look.Dot( Vector3f(0, 0, 1) ); // fourth face normal is z 1 - if(dot < 0) + if (dot < 0) { int Lines = LinesCross( start.z, start.y, end.z, end.y, BlockPos.z + 1, BlockPos.y, BlockPos.z + 1, BlockPos.y + 1 ); - if(Lines == 1) + if (Lines == 1) { Lines = LinesCross( start.z, start.x, end.z, end.x, BlockPos.z + 1, BlockPos.x, BlockPos.z + 1, BlockPos.x + 1 ); - if(Lines == 1) + if (Lines == 1) { intersect3D_SegmentPlane( start, end, BlockPos + Vector3f(0, 0, 1), Vector3f(0, 0, 1) ); return 4; @@ -381,13 +381,13 @@ int cTracer::GetHitNormal(const Vector3f & start, const Vector3f & end, const Ve } } dot = Look.Dot( Vector3f(0, 1, 0) ); // fifth face normal is y 1 - if(dot < 0) + if (dot < 0) { int Lines = LinesCross( start.y, start.x, end.y, end.x, BlockPos.y + 1, BlockPos.x, BlockPos.y + 1, BlockPos.x + 1 ); - if(Lines == 1) + if (Lines == 1) { Lines = LinesCross( start.y, start.z, end.y, end.z, BlockPos.y + 1, BlockPos.z, BlockPos.y + 1, BlockPos.z + 1 ); - if(Lines == 1) + if (Lines == 1) { intersect3D_SegmentPlane( start, end, BlockPos + Vector3f(0, 1, 0), Vector3f(0, 1, 0) ); return 5; @@ -395,13 +395,13 @@ int cTracer::GetHitNormal(const Vector3f & start, const Vector3f & end, const Ve } } dot = Look.Dot( Vector3f(0, -1, 0) ); // sixth face normal is y -1 - if(dot < 0) + if (dot < 0) { int Lines = LinesCross( start.y, start.x, end.y, end.x, BlockPos.y, BlockPos.x, BlockPos.y, BlockPos.x + 1 ); - if(Lines == 1) + if (Lines == 1) { Lines = LinesCross( start.y, start.z, end.y, end.z, BlockPos.y, BlockPos.z, BlockPos.y, BlockPos.z + 1 ); - if(Lines == 1) + if (Lines == 1) { intersect3D_SegmentPlane( start, end, BlockPos, Vector3f(0, -1, 0) ); return 6; diff --git a/src/WebAdmin.cpp b/src/WebAdmin.cpp index be72f2d5a..d8347e2b9 100644 --- a/src/WebAdmin.cpp +++ b/src/WebAdmin.cpp @@ -392,7 +392,7 @@ AString cWebAdmin::GetDefaultPage(void) cPlayerAccum PlayerAccum; cWorld * World = cRoot::Get()->GetDefaultWorld(); // TODO - Create a list of worlds and players - if( World != NULL ) + if (World != NULL ) { World->ForEachPlayer(PlayerAccum); Content.append(PlayerAccum.m_Contents); diff --git a/src/World.cpp b/src/World.cpp index d90383884..c146338d7 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -865,14 +865,14 @@ void cWorld::TickMobs(float a_Dt) // move close mobs cMobProximityCounter::sIterablePair allCloseEnoughToMoveMobs = MobCensus.GetProximityCounter().getMobWithinThosesDistances(-1, 64 * 16);// MG TODO : deal with this magic number (the 16 is the size of a block) - for(cMobProximityCounter::tDistanceToMonster::const_iterator itr = allCloseEnoughToMoveMobs.m_Begin; itr != allCloseEnoughToMoveMobs.m_End; ++itr) + for (cMobProximityCounter::tDistanceToMonster::const_iterator itr = allCloseEnoughToMoveMobs.m_Begin; itr != allCloseEnoughToMoveMobs.m_End; ++itr) { itr->second.m_Monster.Tick(a_Dt, itr->second.m_Chunk); } // remove too far mobs cMobProximityCounter::sIterablePair allTooFarMobs = MobCensus.GetProximityCounter().getMobWithinThosesDistances(128 * 16, -1);// MG TODO : deal with this magic number (the 16 is the size of a block) - for(cMobProximityCounter::tDistanceToMonster::const_iterator itr = allTooFarMobs.m_Begin; itr != allTooFarMobs.m_End; ++itr) + for (cMobProximityCounter::tDistanceToMonster::const_iterator itr = allTooFarMobs.m_Begin; itr != allTooFarMobs.m_End; ++itr) { itr->second.m_Monster.Destroy(true); } @@ -2469,7 +2469,7 @@ cPlayer * cWorld::FindClosestPlayer(const Vector3d & a_Pos, float a_SightLimit, { if (a_CheckLineOfSight) { - if(!LineOfSight.Trace(a_Pos, (Pos - a_Pos), (int)(Pos - a_Pos).Length())) + if (!LineOfSight.Trace(a_Pos, (Pos - a_Pos), (int)(Pos - a_Pos).Length())) { ClosestDistance = Distance; ClosestPlayer = *itr; diff --git a/src/WorldStorage/WSSCompact.cpp b/src/WorldStorage/WSSCompact.cpp index ff43b6905..aae94141c 100644 --- a/src/WorldStorage/WSSCompact.cpp +++ b/src/WorldStorage/WSSCompact.cpp @@ -486,12 +486,12 @@ cWSSCompact::cPAKFile::cPAKFile(const AString & a_FileName, int a_LayerX, int a_ return; } - if( m_ChunkVersion == 1 ) // Convert chunks to version 2 + if (m_ChunkVersion == 1 ) // Convert chunks to version 2 { UpdateChunk1To2(); } #if AXIS_ORDER == AXIS_ORDER_XZY - if( m_ChunkVersion == 2 ) // Convert chunks to version 3 + if (m_ChunkVersion == 2 ) // Convert chunks to version 3 { UpdateChunk2To3(); } @@ -574,7 +574,7 @@ void cWSSCompact::cPAKFile::UpdateChunk1To2() { sChunkHeader * Header = *itr; - if( ChunksConverted % 32 == 0 ) + if (ChunksConverted % 32 == 0 ) { LOGINFO("Updating \"%s\" version 1 to version 2: " SIZE_T_FMT " %%", m_FileName.c_str(), (ChunksConverted * 100) / m_ChunkHeaders.size() ); } @@ -627,9 +627,9 @@ void cWSSCompact::cPAKFile::UpdateChunk1To2() char ConvertedData[cChunkDef::BlockDataSize]; int Index = 0; unsigned int InChunkOffset = 0; - for( int x = 0; x < 16; ++x ) for( int z = 0; z < 16; ++z ) + for (int x = 0; x < 16; ++x ) for (int z = 0; z < 16; ++z ) { - for( int y = 0; y < 128; ++y ) + for (int y = 0; y < 128; ++y ) { ConvertedData[Index++] = UncompressedData[y + z * 128 + x * 128 * 16 + InChunkOffset]; } @@ -638,9 +638,9 @@ void cWSSCompact::cPAKFile::UpdateChunk1To2() Index += 128; } InChunkOffset += (16 * 128 * 16); - for( int x = 0; x < 16; ++x ) for( int z = 0; z < 16; ++z ) // Metadata + for (int x = 0; x < 16; ++x ) for (int z = 0; z < 16; ++z ) // Metadata { - for( int y = 0; y < 64; ++y ) + for (int y = 0; y < 64; ++y ) { ConvertedData[Index++] = UncompressedData[y + z * 64 + x * 64 * 16 + InChunkOffset]; } @@ -648,9 +648,9 @@ void cWSSCompact::cPAKFile::UpdateChunk1To2() Index += 64; } InChunkOffset += (16 * 128 * 16) / 2; - for( int x = 0; x < 16; ++x ) for( int z = 0; z < 16; ++z ) // Block light + for (int x = 0; x < 16; ++x ) for (int z = 0; z < 16; ++z ) // Block light { - for( int y = 0; y < 64; ++y ) + for (int y = 0; y < 64; ++y ) { ConvertedData[Index++] = UncompressedData[y + z * 64 + x * 64 * 16 + InChunkOffset]; } @@ -658,9 +658,9 @@ void cWSSCompact::cPAKFile::UpdateChunk1To2() Index += 64; } InChunkOffset += (16*128*16)/2; - for( int x = 0; x < 16; ++x ) for( int z = 0; z < 16; ++z ) // Sky light + for (int x = 0; x < 16; ++x ) for (int z = 0; z < 16; ++z ) // Sky light { - for( int y = 0; y < 64; ++y ) + for (int y = 0; y < 64; ++y ) { ConvertedData[Index++] = UncompressedData[y + z * 64 + x * 64 * 16 + InChunkOffset]; } @@ -718,7 +718,7 @@ void cWSSCompact::cPAKFile::UpdateChunk2To3() { sChunkHeader * Header = *itr; - if( ChunksConverted % 32 == 0 ) + if (ChunksConverted % 32 == 0 ) { LOGINFO("Updating \"%s\" version 2 to version 3: " SIZE_T_FMT " %%", m_FileName.c_str(), (ChunksConverted * 100) / m_ChunkHeaders.size() ); } @@ -774,7 +774,7 @@ void cWSSCompact::cPAKFile::UpdateChunk2To3() #define MAKE_3_INDEX( x, y, z ) ( x + (z * 16) + (y * 16 * 16) ) unsigned int InChunkOffset = 0; - for( int x = 0; x < 16; ++x ) for( int z = 0; z < 16; ++z ) for( int y = 0; y < 256; ++y ) // YZX Loop order is important, in 1.1 Y was first then Z then X + for (int x = 0; x < 16; ++x ) for (int z = 0; z < 16; ++z ) for (int y = 0; y < 256; ++y ) // YZX Loop order is important, in 1.1 Y was first then Z then X { ConvertedData[ MAKE_3_INDEX(x, y, z) ] = UncompressedData[InChunkOffset]; ++InChunkOffset; @@ -782,7 +782,7 @@ void cWSSCompact::cPAKFile::UpdateChunk2To3() unsigned int index2 = 0; - for( int x = 0; x < 16; ++x ) for( int z = 0; z < 16; ++z ) for( int y = 0; y < 256; ++y ) + for (int x = 0; x < 16; ++x ) for (int z = 0; z < 16; ++z ) for (int y = 0; y < 256; ++y ) { ConvertedData[ InChunkOffset + MAKE_3_INDEX(x, y, z)/2 ] |= ( (UncompressedData[ InChunkOffset + index2/2 ] >> ((index2&1)*4) ) & 0x0f ) << ((x&1)*4); ++index2; @@ -790,7 +790,7 @@ void cWSSCompact::cPAKFile::UpdateChunk2To3() InChunkOffset += index2 / 2; index2 = 0; - for( int x = 0; x < 16; ++x ) for( int z = 0; z < 16; ++z ) for( int y = 0; y < 256; ++y ) + for (int x = 0; x < 16; ++x ) for (int z = 0; z < 16; ++z ) for (int y = 0; y < 256; ++y ) { ConvertedData[ InChunkOffset + MAKE_3_INDEX(x, y, z)/2 ] |= ( (UncompressedData[ InChunkOffset + index2/2 ] >> ((index2&1)*4) ) & 0x0f ) << ((x&1)*4); ++index2; @@ -798,7 +798,7 @@ void cWSSCompact::cPAKFile::UpdateChunk2To3() InChunkOffset += index2 / 2; index2 = 0; - for( int x = 0; x < 16; ++x ) for( int z = 0; z < 16; ++z ) for( int y = 0; y < 256; ++y ) + for (int x = 0; x < 16; ++x ) for (int z = 0; z < 16; ++z ) for (int y = 0; y < 256; ++y ) { ConvertedData[ InChunkOffset + MAKE_3_INDEX(x, y, z)/2 ] |= ( (UncompressedData[ InChunkOffset + index2/2 ] >> ((index2&1)*4) ) & 0x0f ) << ((x&1)*4); ++index2; @@ -887,7 +887,7 @@ bool cWSSCompact::LoadChunkFromData(const cChunkCoords & a_Chunk, int a_Uncompre { Json::Value root; // will contain the root value after parsing. Json::Reader reader; - if ( !reader.parse( UncompressedData.data() + cChunkDef::BlockDataSize, root, false ) ) + if (!reader.parse( UncompressedData.data() + cChunkDef::BlockDataSize, root, false ) ) { LOGERROR("Failed to parse trailing JSON in chunk [%d, %d]!", a_Chunk.m_ChunkX, a_Chunk.m_ChunkZ @@ -970,7 +970,7 @@ bool cWSSCompact::cPAKFile::SaveChunkToData(const cChunkCoords & a_Chunk, cWorld // Compress the data: AString CompressedData; int errorcode = CompressString(Data.data(), Data.size(), CompressedData, m_CompressionFactor); - if ( errorcode != Z_OK ) + if (errorcode != Z_OK ) { LOGERROR("Error %i compressing data for chunk [%d, %d, %d]", errorcode, a_Chunk.m_ChunkX, a_Chunk.m_ChunkY, a_Chunk.m_ChunkZ); return false; -- cgit v1.2.3 From 93d29555e58df172bafba530afbc593c16ec66a3 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 21 Jul 2014 15:19:48 +0200 Subject: Style: Normalized to no spaces before closing parenthesis. --- src/Bindings/DeprecatedBindings.h | 2 +- src/Bindings/LuaFunctions.h | 2 +- src/Bindings/ManualBindings.cpp | 60 +++++++++--------- src/Bindings/ManualBindings.h | 2 +- src/Bindings/Plugin.h | 4 +- src/Bindings/PluginLua.cpp | 2 +- src/Bindings/PluginLua.h | 2 +- src/Bindings/PluginManager.cpp | 6 +- src/Bindings/PluginManager.h | 2 +- src/Bindings/WebPlugin.cpp | 14 ++--- src/Bindings/WebPlugin.h | 6 +- src/BlockEntities/BeaconEntity.cpp | 2 +- src/BlockEntities/BeaconEntity.h | 2 +- src/BlockEntities/BlockEntity.h | 2 +- src/BlockEntities/CommandBlockEntity.h | 4 +- src/BlockEntities/FlowerPotEntity.h | 4 +- src/BlockEntities/FurnaceEntity.cpp | 2 +- src/BlockEntities/MobHeadEntity.h | 4 +- src/BlockEntities/SignEntity.h | 4 +- src/Blocks/BlockBed.cpp | 4 +- src/Blocks/BlockHandler.cpp | 4 +- src/Blocks/BlockTorch.h | 4 +- src/Blocks/BlockVine.h | 2 +- src/Blocks/BroadcastInterface.h | 2 +- src/Blocks/ChunkInterface.h | 4 +- src/ChatColor.h | 4 +- src/Chunk.cpp | 86 +++++++++++++------------- src/Chunk.h | 12 ++-- src/ChunkDef.h | 8 +-- src/ChunkMap.cpp | 72 +++++++++++----------- src/ChunkMap.h | 8 +-- src/ChunkSender.h | 2 +- src/ClientHandle.cpp | 6 +- src/ClientHandle.h | 6 +- src/CraftingRecipes.cpp | 2 +- src/Cuboid.h | 4 +- src/Defines.h | 18 +++--- src/Enchantments.h | 2 +- src/Endianness.h | 10 +-- src/Entities/Entity.cpp | 4 +- src/Entities/ExpOrb.cpp | 6 +- src/Entities/Player.cpp | 108 ++++++++++++++++----------------- src/Entities/Player.h | 14 ++--- src/FurnaceRecipe.cpp | 2 +- src/Generating/Caves.cpp | 6 +- src/Generating/ChunkGenerator.cpp | 2 +- src/Generating/FinishGen.cpp | 8 +-- src/Generating/HeiGen.cpp | 2 +- src/Globals.h | 8 +-- src/Group.cpp | 10 +-- src/Group.h | 10 +-- src/GroupManager.cpp | 16 ++--- src/HTTPServer/HTTPConnection.cpp | 2 +- src/Inventory.cpp | 16 ++--- src/Inventory.h | 2 +- src/Item.cpp | 6 +- src/Items/ItemFood.h | 2 +- src/Items/ItemHandler.cpp | 2 +- src/Items/ItemPickaxe.h | 4 +- src/Log.cpp | 28 ++++----- src/MCLogger.cpp | 8 +-- src/MobSpawner.cpp | 2 +- src/Mobs/SnowGolem.cpp | 2 +- src/MonsterConfig.cpp | 2 +- src/Noise.cpp | 58 +++++++++--------- src/OSSupport/Errors.cpp | 12 ++-- src/OSSupport/Event.cpp | 4 +- src/OSSupport/Semaphore.cpp | 26 ++++---- src/OSSupport/Semaphore.h | 2 +- src/OSSupport/Sleep.cpp | 2 +- src/OSSupport/Sleep.h | 2 +- src/OSSupport/Thread.cpp | 32 +++++----- src/OSSupport/Thread.h | 8 +-- src/Protocol/Protocol.h | 2 +- src/Protocol/Protocol125.cpp | 8 +-- src/Protocol/Protocol125.h | 4 +- src/Protocol/Protocol132.cpp | 2 +- src/Protocol/Protocol17x.h | 2 +- src/Protocol/ProtocolRecognizer.cpp | 2 +- src/Protocol/ProtocolRecognizer.h | 2 +- src/Root.cpp | 24 ++++---- src/Server.cpp | 4 +- src/Simulator/NoopRedstoneSimulator.h | 2 +- src/Simulator/SimulatorManager.cpp | 6 +- src/Tracer.cpp | 64 +++++++++---------- src/Tracer.h | 6 +- src/UI/Window.cpp | 4 +- src/UI/Window.h | 4 +- src/WebAdmin.cpp | 6 +- src/World.cpp | 2 +- src/World.h | 8 +-- src/WorldStorage/WSSCompact.cpp | 108 +++++++++++++++++---------------- src/WorldStorage/WorldStorage.cpp | 2 +- src/main.cpp | 10 +-- 94 files changed, 541 insertions(+), 535 deletions(-) diff --git a/src/Bindings/DeprecatedBindings.h b/src/Bindings/DeprecatedBindings.h index 5fc3cfa80..037d50489 100644 --- a/src/Bindings/DeprecatedBindings.h +++ b/src/Bindings/DeprecatedBindings.h @@ -4,5 +4,5 @@ struct lua_State; class DeprecatedBindings { public: - static void Bind( lua_State* tolua_S ); + static void Bind( lua_State* tolua_S); }; diff --git a/src/Bindings/LuaFunctions.h b/src/Bindings/LuaFunctions.h index 629e2d77d..2ea37d7a4 100644 --- a/src/Bindings/LuaFunctions.h +++ b/src/Bindings/LuaFunctions.h @@ -9,7 +9,7 @@ inline unsigned int GetTime() return (unsigned int)time(0); } -inline std::string GetChar( std::string & a_Str, unsigned int a_Idx ) +inline std::string GetChar( std::string & a_Str, unsigned int a_Idx) { return std::string(1, a_Str[ a_Idx ]); } diff --git a/src/Bindings/ManualBindings.cpp b/src/Bindings/ManualBindings.cpp index 5e9e7349d..df9687fc0 100644 --- a/src/Bindings/ManualBindings.cpp +++ b/src/Bindings/ManualBindings.cpp @@ -319,9 +319,9 @@ static int tolua_DoWith(lua_State* tolua_S) { public: cLuaCallback(lua_State* a_LuaState, int a_FuncRef, int a_TableRef) - : LuaState( a_LuaState ) - , FuncRef( a_FuncRef ) - , TableRef( a_TableRef ) + : LuaState( a_LuaState) + , FuncRef( a_FuncRef) + , TableRef( a_TableRef) {} private: @@ -358,7 +358,7 @@ static int tolua_DoWith(lua_State* tolua_S) luaL_unref(tolua_S, LUA_REGISTRYINDEX, FuncRef); /* Push return value on stack */ - tolua_pushboolean(tolua_S, bRetVal ); + tolua_pushboolean(tolua_S, bRetVal); return 1; } @@ -448,7 +448,7 @@ static int tolua_DoWithID(lua_State* tolua_S) luaL_unref(tolua_S, LUA_REGISTRYINDEX, FuncRef); /* Push return value on stack */ - tolua_pushboolean(tolua_S, bRetVal ); + tolua_pushboolean(tolua_S, bRetVal); return 1; } @@ -478,7 +478,7 @@ static int tolua_DoWithXYZ(lua_State* tolua_S) int ItemX = ((int)tolua_tonumber(tolua_S, 2, 0)); int ItemY = ((int)tolua_tonumber(tolua_S, 3, 0)); int ItemZ = ((int)tolua_tonumber(tolua_S, 4, 0)); - LOG("x %i y %i z %i", ItemX, ItemY, ItemZ ); + LOG("x %i y %i z %i", ItemX, ItemY, ItemZ); if (!lua_isfunction( tolua_S, 5)) { return lua_do_error(tolua_S, "Error in function call '#funcname#': Expected a function for parameter #4"); @@ -506,9 +506,9 @@ static int tolua_DoWithXYZ(lua_State* tolua_S) { public: cLuaCallback(lua_State* a_LuaState, int a_FuncRef, int a_TableRef) - : LuaState( a_LuaState ) - , FuncRef( a_FuncRef ) - , TableRef( a_TableRef ) + : LuaState( a_LuaState) + , FuncRef( a_FuncRef) + , TableRef( a_TableRef) {} private: @@ -544,7 +544,7 @@ static int tolua_DoWithXYZ(lua_State* tolua_S) luaL_unref(tolua_S, LUA_REGISTRYINDEX, FuncRef); /* Push return value on stack */ - tolua_pushboolean(tolua_S, bRetVal ); + tolua_pushboolean(tolua_S, bRetVal); return 1; } @@ -601,9 +601,9 @@ static int tolua_ForEachInChunk(lua_State * tolua_S) { public: cLuaCallback(lua_State* a_LuaState, int a_FuncRef, int a_TableRef) - : LuaState( a_LuaState ) - , FuncRef( a_FuncRef ) - , TableRef( a_TableRef ) + : LuaState( a_LuaState) + , FuncRef( a_FuncRef) + , TableRef( a_TableRef) {} private: @@ -640,7 +640,7 @@ static int tolua_ForEachInChunk(lua_State * tolua_S) luaL_unref(tolua_S, LUA_REGISTRYINDEX, FuncRef); /* Push return value on stack */ - tolua_pushboolean(tolua_S, bRetVal ); + tolua_pushboolean(tolua_S, bRetVal); return 1; } @@ -694,16 +694,16 @@ static int tolua_ForEach(lua_State * tolua_S) { public: cLuaCallback(lua_State* a_LuaState, int a_FuncRef, int a_TableRef) - : LuaState( a_LuaState ) - , FuncRef( a_FuncRef ) - , TableRef( a_TableRef ) + : LuaState( a_LuaState) + , FuncRef( a_FuncRef) + , TableRef( a_TableRef) {} private: virtual bool Item(Ty2 * a_Item) override { lua_rawgeti( LuaState, LUA_REGISTRYINDEX, FuncRef); /* Push function reference */ - tolua_pushusertype( LuaState, a_Item, Ty2::GetClassStatic() ); + tolua_pushusertype( LuaState, a_Item, Ty2::GetClassStatic()); if (TableRef != LUA_REFNIL) { lua_rawgeti( LuaState, LUA_REGISTRYINDEX, TableRef); /* Push table reference */ @@ -733,7 +733,7 @@ static int tolua_ForEach(lua_State * tolua_S) luaL_unref(tolua_S, LUA_REGISTRYINDEX, FuncRef); /* Push return value on stack */ - tolua_pushboolean(tolua_S, bRetVal ); + tolua_pushboolean(tolua_S, bRetVal); return 1; } @@ -1390,8 +1390,8 @@ static int tolua_cPluginManager_ForEachCommand(lua_State * tolua_S) { public: cLuaCallback(lua_State * a_LuaState, int a_FuncRef) - : LuaState( a_LuaState ) - , FuncRef( a_FuncRef ) + : LuaState( a_LuaState) + , FuncRef( a_FuncRef) {} private: @@ -1467,8 +1467,8 @@ static int tolua_cPluginManager_ForEachConsoleCommand(lua_State * tolua_S) { public: cLuaCallback(lua_State * a_LuaState, int a_FuncRef) - : LuaState( a_LuaState ) - , FuncRef( a_FuncRef ) + : LuaState( a_LuaState) + , FuncRef( a_FuncRef) {} private: @@ -1963,7 +1963,7 @@ static int tolua_cPluginLua_AddTab(lua_State* tolua_S) LOGWARN("WARNING: Using deprecated function AddTab()! Use AddWebTab() instead. (plugin \"%s\" in folder \"%s\")", self->GetName().c_str(), self->GetDirectory().c_str() ); - return tolua_cPluginLua_AddWebTab( tolua_S ); + return tolua_cPluginLua_AddWebTab( tolua_S); } @@ -2011,7 +2011,7 @@ static int tolua_md5(lua_State* tolua_S) -static int tolua_push_StringStringMap(lua_State* tolua_S, std::map< std::string, std::string >& a_StringStringMap ) +static int tolua_push_StringStringMap(lua_State* tolua_S, std::map< std::string, std::string >& a_StringStringMap) { lua_newtable(tolua_S); int top = lua_gettop(tolua_S); @@ -2062,9 +2062,9 @@ static int tolua_get_HTTPRequest_FormData(lua_State* tolua_S) for (std::map::iterator it = FormData.begin(); it != FormData.end(); ++it) { - lua_pushstring(tolua_S, it->first.c_str() ); - tolua_pushusertype(tolua_S, &(it->second), "HTTPFormData" ); - // lua_pushlstring(tolua_S, it->second.Value.c_str(), it->second.Value.size() ); // Might contain binary data + lua_pushstring(tolua_S, it->first.c_str()); + tolua_pushusertype(tolua_S, &(it->second), "HTTPFormData"); + // lua_pushlstring(tolua_S, it->second.Value.c_str(), it->second.Value.size()); // Might contain binary data lua_settable(tolua_S, top); } @@ -2113,8 +2113,8 @@ static int tolua_cWebPlugin_GetTabNames(lua_State * tolua_S) { const AString & FancyName = iter->first; const AString & WebName = iter->second; - tolua_pushstring( tolua_S, WebName.c_str() ); // Because the WebName is supposed to be unique, use it as key - tolua_pushstring( tolua_S, FancyName.c_str() ); + tolua_pushstring( tolua_S, WebName.c_str()); // Because the WebName is supposed to be unique, use it as key + tolua_pushstring( tolua_S, FancyName.c_str()); // lua_rawset(tolua_S, -3); ++iter; diff --git a/src/Bindings/ManualBindings.h b/src/Bindings/ManualBindings.h index f38e26267..36161c6a2 100644 --- a/src/Bindings/ManualBindings.h +++ b/src/Bindings/ManualBindings.h @@ -4,5 +4,5 @@ struct lua_State; class ManualBindings { public: - static void Bind( lua_State* tolua_S ); + static void Bind( lua_State* tolua_S); }; diff --git a/src/Bindings/Plugin.h b/src/Bindings/Plugin.h index fc8aa1cdb..3882b7474 100644 --- a/src/Bindings/Plugin.h +++ b/src/Bindings/Plugin.h @@ -33,7 +33,7 @@ class cPlugin public: // tolua_end - cPlugin( const AString & a_PluginDirectory ); + cPlugin( const AString & a_PluginDirectory); virtual ~cPlugin(); virtual void OnDisable(void) {} @@ -141,7 +141,7 @@ public: E_SQUIRREL, // OBSOLETE, but kept in place to remind us of the horrors lurking in the history }; PluginLanguage GetLanguage() { return m_Language; } - void SetLanguage( PluginLanguage a_Language ) { m_Language = a_Language; } + void SetLanguage( PluginLanguage a_Language) { m_Language = a_Language; } private: PluginLanguage m_Language; diff --git a/src/Bindings/PluginLua.cpp b/src/Bindings/PluginLua.cpp index 5fa8adc66..0f3f25d75 100644 --- a/src/Bindings/PluginLua.cpp +++ b/src/Bindings/PluginLua.cpp @@ -1655,7 +1655,7 @@ int cPluginLua::CallFunctionFromForeignState( -AString cPluginLua::HandleWebRequest(const HTTPRequest * a_Request ) +AString cPluginLua::HandleWebRequest(const HTTPRequest * a_Request) { cCSLock Lock(m_CriticalSection); std::string RetVal = ""; diff --git a/src/Bindings/PluginLua.h b/src/Bindings/PluginLua.h index b2979a210..2cea644c1 100644 --- a/src/Bindings/PluginLua.h +++ b/src/Bindings/PluginLua.h @@ -144,7 +144,7 @@ public: virtual const AString GetWebTitle(void) const {return GetName(); } // cWebPlugin and WebAdmin stuff - virtual AString HandleWebRequest(const HTTPRequest * a_Request ) override; + virtual AString HandleWebRequest(const HTTPRequest * a_Request) override; bool AddWebTab(const AString & a_Title, lua_State * a_LuaState, int a_FunctionReference); // >> EXPORTED IN MANUALBINDINGS << /** Binds the command to call the function specified by a Lua function reference. Simply adds to CommandMap. */ diff --git a/src/Bindings/PluginManager.cpp b/src/Bindings/PluginManager.cpp index 33ecb95ad..088b92a6d 100644 --- a/src/Bindings/PluginManager.cpp +++ b/src/Bindings/PluginManager.cpp @@ -72,7 +72,7 @@ void cPluginManager::FindPlugins(void) { PluginMap::iterator thiz = itr; ++thiz; - m_Plugins.erase( itr ); + m_Plugins.erase( itr); itr = thiz; continue; } @@ -1432,11 +1432,11 @@ cPluginManager::CommandResult cPluginManager::HandleCommand(cPlayer * a_Player, -cPlugin * cPluginManager::GetPlugin( const AString & a_Plugin ) const +cPlugin * cPluginManager::GetPlugin( const AString & a_Plugin) const { for (PluginMap::const_iterator itr = m_Plugins.begin(); itr != m_Plugins.end(); ++itr) { - if (itr->second == NULL ) continue; + if (itr->second == NULL) continue; if (itr->second->GetName().compare(a_Plugin) == 0) { return itr->second; diff --git a/src/Bindings/PluginManager.h b/src/Bindings/PluginManager.h index cffd8d04b..44a94e316 100644 --- a/src/Bindings/PluginManager.h +++ b/src/Bindings/PluginManager.h @@ -163,7 +163,7 @@ public: typedef std::map< AString, cPlugin * > PluginMap; typedef std::list< cPlugin * > PluginList; - cPlugin * GetPlugin( const AString & a_Plugin ) const; // tolua_export + cPlugin * GetPlugin( const AString & a_Plugin) const; // tolua_export const PluginMap & GetAllPlugins() const; // >> EXPORTED IN MANUALBINDINGS << // tolua_begin diff --git a/src/Bindings/WebPlugin.cpp b/src/Bindings/WebPlugin.cpp index a22826d1b..1178c127a 100644 --- a/src/Bindings/WebPlugin.cpp +++ b/src/Bindings/WebPlugin.cpp @@ -45,12 +45,12 @@ cWebPlugin::~cWebPlugin() std::list > cWebPlugin::GetTabNames(void) { std::list< std::pair< AString, AString > > NameList; - for (TabList::iterator itr = GetTabs().begin(); itr != GetTabs().end(); ++itr ) + for (TabList::iterator itr = GetTabs().begin(); itr != GetTabs().end(); ++itr) { std::pair< AString, AString > StringPair; StringPair.first = (*itr)->Title; StringPair.second = (*itr)->SafeTitle; - NameList.push_back( StringPair ); + NameList.push_back( StringPair); } return NameList; } @@ -69,7 +69,7 @@ std::pair< AString, AString > cWebPlugin::GetTabNameForRequest(const HTTPRequest sWebPluginTab * Tab = NULL; if (Split.size() > 2) // If we got the tab name, show that page { - for (TabList::iterator itr = GetTabs().begin(); itr != GetTabs().end(); ++itr ) + for (TabList::iterator itr = GetTabs().begin(); itr != GetTabs().end(); ++itr) { if ((*itr)->SafeTitle.compare(Split[2]) == 0) // This is the one! { @@ -80,7 +80,7 @@ std::pair< AString, AString > cWebPlugin::GetTabNameForRequest(const HTTPRequest } else // Otherwise show the first tab { - if (GetTabs().size() > 0 ) + if (GetTabs().size() > 0) Tab = *GetTabs().begin(); } @@ -100,14 +100,14 @@ std::pair< AString, AString > cWebPlugin::GetTabNameForRequest(const HTTPRequest AString cWebPlugin::SafeString(const AString & a_String) { AString RetVal; - for (unsigned int i = 0; i < a_String.size(); ++i ) + for (unsigned int i = 0; i < a_String.size(); ++i) { char c = a_String[i]; - if (c == ' ' ) + if (c == ' ') { c = '_'; } - RetVal.push_back( c ); + RetVal.push_back( c); } return RetVal; } diff --git a/src/Bindings/WebPlugin.h b/src/Bindings/WebPlugin.h index 3587ac637..46bc0cd2d 100644 --- a/src/Bindings/WebPlugin.h +++ b/src/Bindings/WebPlugin.h @@ -19,9 +19,9 @@ public: // tolua_begin virtual const AString GetWebTitle(void) const = 0; - virtual AString HandleWebRequest(const HTTPRequest * a_Request ) = 0; + virtual AString HandleWebRequest(const HTTPRequest * a_Request) = 0; - static AString SafeString( const AString & a_String ); + static AString SafeString( const AString & a_String); // tolua_end struct sWebPluginTab @@ -37,7 +37,7 @@ public: typedef std::list< std::pair > TabNameList; TabNameList GetTabNames(); // >> EXPORTED IN MANUALBINDINGS << - std::pair< AString, AString > GetTabNameForRequest(const HTTPRequest* a_Request ); + std::pair< AString, AString > GetTabNameForRequest(const HTTPRequest* a_Request); private: TabList m_Tabs; diff --git a/src/BlockEntities/BeaconEntity.cpp b/src/BlockEntities/BeaconEntity.cpp index 9a6d85f1d..4b9662797 100644 --- a/src/BlockEntities/BeaconEntity.cpp +++ b/src/BlockEntities/BeaconEntity.cpp @@ -66,7 +66,7 @@ int cBeaconEntity::GetPyramidLevel(void) bool cBeaconEntity::IsMineralBlock(BLOCKTYPE a_BlockType) { - switch(a_BlockType) + switch (a_BlockType) { case E_BLOCK_DIAMOND_BLOCK: case E_BLOCK_GOLD_BLOCK: diff --git a/src/BlockEntities/BeaconEntity.h b/src/BlockEntities/BeaconEntity.h index b1df68bc4..ee1eda391 100644 --- a/src/BlockEntities/BeaconEntity.h +++ b/src/BlockEntities/BeaconEntity.h @@ -33,7 +33,7 @@ public: static bool IsMineralBlock(BLOCKTYPE a_BlockType); // cBlockEntity overrides: - virtual void SaveToJson(Json::Value& a_Value ) override; + virtual void SaveToJson(Json::Value& a_Value) override; virtual void SendTo(cClientHandle & a_Client) override; virtual void UsedBy(cPlayer * a_Player) override; virtual bool Tick(float a_Dt, cChunk & /* a_Chunk */) override; diff --git a/src/BlockEntities/BlockEntity.h b/src/BlockEntities/BlockEntity.h index 7c6688f8d..24c25e729 100644 --- a/src/BlockEntities/BlockEntity.h +++ b/src/BlockEntities/BlockEntity.h @@ -79,7 +79,7 @@ public: virtual void SaveToJson (Json::Value & a_Value) = 0; /// Called when a player uses this entity; should open the UI window - virtual void UsedBy( cPlayer * a_Player ) = 0; + virtual void UsedBy( cPlayer * a_Player) = 0; /** Sends the packet defining the block entity to the client specified. To send to all eligible clients, use cWorld::BroadcastBlockEntity() diff --git a/src/BlockEntities/CommandBlockEntity.h b/src/BlockEntities/CommandBlockEntity.h index d7c4eaabe..d02bf7d7b 100644 --- a/src/BlockEntities/CommandBlockEntity.h +++ b/src/BlockEntities/CommandBlockEntity.h @@ -38,8 +38,8 @@ public: /// Creates a new empty command block entity cCommandBlockEntity(int a_X, int a_Y, int a_Z, cWorld * a_World); - bool LoadFromJson( const Json::Value& a_Value ); - virtual void SaveToJson(Json::Value& a_Value ) override; + bool LoadFromJson( const Json::Value& a_Value); + virtual void SaveToJson(Json::Value& a_Value) override; virtual bool Tick(float a_Dt, cChunk & a_Chunk) override; virtual void SendTo(cClientHandle & a_Client) override; diff --git a/src/BlockEntities/FlowerPotEntity.h b/src/BlockEntities/FlowerPotEntity.h index 85cb810ad..89901cf2d 100644 --- a/src/BlockEntities/FlowerPotEntity.h +++ b/src/BlockEntities/FlowerPotEntity.h @@ -39,8 +39,8 @@ public: /** Creates a new flowerpot entity at the specified block coords. a_World may be NULL */ cFlowerPotEntity(int a_BlocX, int a_BlockY, int a_BlockZ, cWorld * a_World); - bool LoadFromJson( const Json::Value& a_Value ); - virtual void SaveToJson(Json::Value& a_Value ) override; + bool LoadFromJson( const Json::Value& a_Value); + virtual void SaveToJson(Json::Value& a_Value) override; virtual void Destroy(void) override; diff --git a/src/BlockEntities/FurnaceEntity.cpp b/src/BlockEntities/FurnaceEntity.cpp index 1b1741713..72fd7f2b3 100644 --- a/src/BlockEntities/FurnaceEntity.cpp +++ b/src/BlockEntities/FurnaceEntity.cpp @@ -160,7 +160,7 @@ bool cFurnaceEntity::LoadFromJson(const Json::Value & a_Value) -void cFurnaceEntity::SaveToJson( Json::Value& a_Value ) +void cFurnaceEntity::SaveToJson( Json::Value& a_Value) { a_Value["x"] = m_PosX; a_Value["y"] = m_PosY; diff --git a/src/BlockEntities/MobHeadEntity.h b/src/BlockEntities/MobHeadEntity.h index 2bc072d69..f91a3cc9e 100644 --- a/src/BlockEntities/MobHeadEntity.h +++ b/src/BlockEntities/MobHeadEntity.h @@ -37,8 +37,8 @@ public: /** Creates a new mob head entity at the specified block coords. a_World may be NULL */ cMobHeadEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World); - bool LoadFromJson( const Json::Value& a_Value ); - virtual void SaveToJson(Json::Value& a_Value ) override; + bool LoadFromJson( const Json::Value& a_Value); + virtual void SaveToJson(Json::Value& a_Value) override; // tolua_begin diff --git a/src/BlockEntities/SignEntity.h b/src/BlockEntities/SignEntity.h index 16e0e23bc..33af100a4 100644 --- a/src/BlockEntities/SignEntity.h +++ b/src/BlockEntities/SignEntity.h @@ -37,8 +37,8 @@ public: /// Creates a new empty sign entity at the specified block coords and block type (wall or standing). a_World may be NULL cSignEntity(BLOCKTYPE a_BlockType, int a_X, int a_Y, int a_Z, cWorld * a_World); - bool LoadFromJson( const Json::Value& a_Value ); - virtual void SaveToJson(Json::Value& a_Value ) override; + bool LoadFromJson( const Json::Value& a_Value); + virtual void SaveToJson(Json::Value& a_Value) override; // tolua_begin diff --git a/src/Blocks/BlockBed.cpp b/src/Blocks/BlockBed.cpp index fbc82b440..80ac18560 100644 --- a/src/Blocks/BlockBed.cpp +++ b/src/Blocks/BlockBed.cpp @@ -27,8 +27,8 @@ void cBlockBedHandler::OnDestroyed(cChunkInterface & a_ChunkInterface, cWorldInt { NIBBLETYPE OldMeta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ); - Vector3i ThisPos( a_BlockX, a_BlockY, a_BlockZ ); - Vector3i Direction = MetaDataToDirection( OldMeta & 0x7 ); + Vector3i ThisPos( a_BlockX, a_BlockY, a_BlockZ); + Vector3i Direction = MetaDataToDirection( OldMeta & 0x7); if (OldMeta & 0x8) { // Was pillow diff --git a/src/Blocks/BlockHandler.cpp b/src/Blocks/BlockHandler.cpp index 8ab4116f4..b6ef23cb9 100644 --- a/src/Blocks/BlockHandler.cpp +++ b/src/Blocks/BlockHandler.cpp @@ -175,7 +175,7 @@ public: cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType) { - switch(a_BlockType) + switch (a_BlockType) { // Block handlers, alphabetically sorted: case E_BLOCK_ACACIA_WOOD_STAIRS: return new cBlockStairsHandler (a_BlockType); @@ -254,7 +254,7 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE 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 ( ); + case E_BLOCK_PISTON_EXTENSION: return new cBlockPistonHeadHandler; case E_BLOCK_PLANKS: return new cBlockPlanksHandler (a_BlockType); case E_BLOCK_POTATOES: return new cBlockCropsHandler (a_BlockType); case E_BLOCK_POWERED_RAIL: return new cBlockRailHandler (a_BlockType); diff --git a/src/Blocks/BlockTorch.h b/src/Blocks/BlockTorch.h index b62268187..c73118870 100644 --- a/src/Blocks/BlockTorch.h +++ b/src/Blocks/BlockTorch.h @@ -99,7 +99,7 @@ public: static bool CanBePlacedOn(BLOCKTYPE a_BlockType, eBlockFace a_BlockFace) { - if (!cBlockInfo::FullyOccupiesVoxel(a_BlockType) ) + if (!cBlockInfo::FullyOccupiesVoxel(a_BlockType)) { return (a_BlockFace == BLOCK_FACE_TOP); // Allow placement only when torch upright (for glass, etc.); exceptions won't even be sent by client, no need to handle } @@ -168,7 +168,7 @@ public: // No need to check for upright orientation, it was done when the torch was placed return true; } - else if (!cBlockInfo::FullyOccupiesVoxel(BlockInQuestion) ) + else if (!cBlockInfo::FullyOccupiesVoxel(BlockInQuestion)) { return false; } diff --git a/src/Blocks/BlockVine.h b/src/Blocks/BlockVine.h index c2d82eb4d..61092af3e 100644 --- a/src/Blocks/BlockVine.h +++ b/src/Blocks/BlockVine.h @@ -59,7 +59,7 @@ public: static char MetaDataToDirection(NIBBLETYPE a_MetaData) { - switch(a_MetaData) + switch (a_MetaData) { case 0x1: return BLOCK_FACE_NORTH; case 0x4: return BLOCK_FACE_SOUTH; diff --git a/src/Blocks/BroadcastInterface.h b/src/Blocks/BroadcastInterface.h index c8593c76a..cf332b153 100644 --- a/src/Blocks/BroadcastInterface.h +++ b/src/Blocks/BroadcastInterface.h @@ -6,7 +6,7 @@ class cBroadcastInterface public: virtual ~cBroadcastInterface() {} - virtual void BroadcastUseBed (const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ ) = 0; + virtual void BroadcastUseBed (const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ) = 0; virtual void BroadcastSoundEffect(const AString & a_SoundName, double a_X, double a_Y, double a_Z, float a_Volume, float a_Pitch, const cClientHandle * a_Exclude = NULL) = 0; virtual void BroadcastEntityAnimation(const cEntity & a_Entity, char a_Animation, const cClientHandle * a_Exclude = NULL) = 0; }; diff --git a/src/Blocks/ChunkInterface.h b/src/Blocks/ChunkInterface.h index 3bab60be6..dea9d7c7e 100644 --- a/src/Blocks/ChunkInterface.h +++ b/src/Blocks/ChunkInterface.h @@ -61,9 +61,9 @@ public: m_ChunkMap->FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta); } - void FastSetBlock(const Vector3i & a_Pos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta ) + void FastSetBlock(const Vector3i & a_Pos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) { - FastSetBlock( a_Pos.x, a_Pos.y, a_Pos.z, a_BlockType, a_BlockMeta ); + FastSetBlock( a_Pos.x, a_Pos.y, a_Pos.z, a_BlockType, a_BlockMeta); } void UseBlockEntity(cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ) diff --git a/src/ChatColor.h b/src/ChatColor.h index 74eb7d5dc..21377e27f 100644 --- a/src/ChatColor.h +++ b/src/ChatColor.h @@ -31,14 +31,14 @@ public: static const char * Yellow; static const char * White; - // Styles ( source: http://wiki.vg/Chat ) + // Styles + // source: http://wiki.vg/Chat static const char * Random; static const char * Bold; static const char * Strikethrough; static const char * Underlined; static const char * Italic; static const char * Plain; - }; // tolua_end diff --git a/src/Chunk.cpp b/src/Chunk.cpp index 25a58458e..60987b070 100644 --- a/src/Chunk.cpp +++ b/src/Chunk.cpp @@ -44,12 +44,12 @@ //////////////////////////////////////////////////////////////////////////////// // sSetBlock: -sSetBlock::sSetBlock( int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta ) // absolute block position - : x( a_BlockX ) - , y( a_BlockY ) - , z( a_BlockZ ) - , BlockType( a_BlockType ) - , BlockMeta( a_BlockMeta ) +sSetBlock::sSetBlock( int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) // absolute block position + : x( a_BlockX) + , y( a_BlockY) + , z( a_BlockZ) + , BlockType( a_BlockType) + , BlockMeta( a_BlockMeta) { cChunkDef::AbsoluteToRelative(x, y, z, ChunkX, ChunkZ); } @@ -116,7 +116,7 @@ cChunk::~cChunk() { cPluginManager::Get()->CallHookChunkUnloaded(m_World, m_PosX, m_PosZ); - // LOGINFO("### delete cChunk() (%i, %i) from %p, thread 0x%x ###", m_PosX, m_PosZ, this, GetCurrentThreadId() ); + // LOGINFO("### delete cChunk() (%i, %i) from %p, thread 0x%x ###", m_PosX, m_PosZ, this, GetCurrentThreadId()); for (cBlockEntityList::iterator itr = m_BlockEntities.begin(); itr != m_BlockEntities.end(); ++itr) { @@ -781,7 +781,7 @@ void cChunk::CheckBlocks() void cChunk::TickBlocks(void) { // Tick dem blocks - // _X: We must limit the random number or else we get a nasty int overflow bug ( http://forum.mc-server.org/showthread.php?tid=457 ) + // _X: We must limit the random number or else we get a nasty int overflow bug - http://forum.mc-server.org/showthread.php?tid=457 int RandomX = m_World->GetTickRandomNumber(0x00ffffff); int RandomY = m_World->GetTickRandomNumber(0x00ffffff); int RandomZ = m_World->GetTickRandomNumber(0x00ffffff); @@ -1394,7 +1394,7 @@ void cChunk::CalculateHeightmap(const BLOCKTYPE * a_BlockTypes) { for (int y = Height - 1; y > -1; y--) { - int index = MakeIndex( x, y, z ); + int index = MakeIndex( x, y, z); if (a_BlockTypes[index] != E_BLOCK_AIR) { m_HeightMap[x + z * Width] = (HEIGHTTYPE)y; @@ -1730,9 +1730,9 @@ void cChunk::CollectPickupsByPlayer(cPlayer * a_Player) { continue; // Only pickups and projectiles can be picked up } - float DiffX = (float)((*itr)->GetPosX() - PosX ); - float DiffY = (float)((*itr)->GetPosY() - PosY ); - float DiffZ = (float)((*itr)->GetPosZ() - PosZ ); + float DiffX = (float)((*itr)->GetPosX() - PosX); + float DiffY = (float)((*itr)->GetPosY() - PosY); + float DiffZ = (float)((*itr)->GetPosZ() - PosZ); float SqrDist = DiffX * DiffX + DiffY * DiffY + DiffZ * DiffZ; if (SqrDist < 1.5f * 1.5f) // 1.5 block { @@ -1794,7 +1794,7 @@ bool cChunk::SetSignLines(int a_PosX, int a_PosY, int a_PosZ, const AString & a_ -void cChunk::RemoveBlockEntity( cBlockEntity* a_BlockEntity ) +void cChunk::RemoveBlockEntity( cBlockEntity* a_BlockEntity) { MarkDirty(); m_BlockEntities.remove(a_BlockEntity); @@ -1814,9 +1814,9 @@ bool cChunk::AddClient(cClientHandle* a_Client) return false; } } - m_LoadedByClient.push_back( a_Client ); + m_LoadedByClient.push_back( a_Client); - for (cEntityList::iterator itr = m_Entities.begin(); itr != m_Entities.end(); ++itr ) + for (cEntityList::iterator itr = m_Entities.begin(); itr != m_Entities.end(); ++itr) { /* // DEBUG: @@ -1835,7 +1835,7 @@ bool cChunk::AddClient(cClientHandle* a_Client) -void cChunk::RemoveClient( cClientHandle* a_Client ) +void cChunk::RemoveClient( cClientHandle* a_Client) { for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr) { @@ -1848,7 +1848,7 @@ void cChunk::RemoveClient( cClientHandle* a_Client ) if (!a_Client->IsDestroyed()) { - for (cEntityList::iterator itr = m_Entities.begin(); itr != m_Entities.end(); ++itr ) + for (cEntityList::iterator itr = m_Entities.begin(); itr != m_Entities.end(); ++itr) { /* // DEBUG: @@ -1868,7 +1868,7 @@ void cChunk::RemoveClient( cClientHandle* a_Client ) -bool cChunk::HasClient( cClientHandle* a_Client ) +bool cChunk::HasClient( cClientHandle* a_Client) { for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr) { @@ -2653,7 +2653,7 @@ cChunk * cChunk::GetRelNeighborChunkAdjustCoords(int & a_RelX, int & a_RelZ) con void cChunk::BroadcastAttachEntity(const cEntity & a_Entity, const cEntity * a_Vehicle) { - for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr ) + for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr) { (*itr)->SendAttachEntity(a_Entity, a_Vehicle); } // for itr - LoadedByClient[] @@ -2665,7 +2665,7 @@ void cChunk::BroadcastAttachEntity(const cEntity & a_Entity, const cEntity * a_V void cChunk::BroadcastBlockAction(int a_BlockX, int a_BlockY, int a_BlockZ, char a_Byte1, char a_Byte2, BLOCKTYPE a_BlockType, const cClientHandle * a_Exclude) { - for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr ) + for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr) { if (*itr == a_Exclude) { @@ -2681,7 +2681,7 @@ void cChunk::BroadcastBlockAction(int a_BlockX, int a_BlockY, int a_BlockZ, char void cChunk::BroadcastBlockBreakAnimation(int a_entityID, int a_blockX, int a_blockY, int a_blockZ, char a_stage, const cClientHandle * a_Exclude) { - for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr ) + for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr) { if (*itr == a_Exclude) { @@ -2703,7 +2703,7 @@ void cChunk::BroadcastBlockEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cons { return; } - for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr ) + for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr) { if (*itr == a_Exclude) { @@ -2719,7 +2719,7 @@ void cChunk::BroadcastBlockEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cons void cChunk::BroadcastChunkData(cChunkDataSerializer & a_Serializer, const cClientHandle * a_Exclude) { - for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr ) + for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr) { if (*itr == a_Exclude) { @@ -2735,7 +2735,7 @@ void cChunk::BroadcastChunkData(cChunkDataSerializer & a_Serializer, const cClie void cChunk::BroadcastCollectEntity(const cEntity & a_Entity, const cPlayer & a_Player, const cClientHandle * a_Exclude) { - for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr ) + for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr) { if (*itr == a_Exclude) { @@ -2751,7 +2751,7 @@ void cChunk::BroadcastCollectEntity(const cEntity & a_Entity, const cPlayer & a_ void cChunk::BroadcastDestroyEntity(const cEntity & a_Entity, const cClientHandle * a_Exclude) { - for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr ) + for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr) { if (*itr == a_Exclude) { @@ -2767,7 +2767,7 @@ void cChunk::BroadcastDestroyEntity(const cEntity & a_Entity, const cClientHandl void cChunk::BroadcastEntityEffect(const cEntity & a_Entity, int a_EffectID, int a_Amplifier, short a_Duration, const cClientHandle * a_Exclude) { - for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr ) + for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr) { if (*itr == a_Exclude) { @@ -2783,7 +2783,7 @@ void cChunk::BroadcastEntityEffect(const cEntity & a_Entity, int a_EffectID, int void cChunk::BroadcastEntityEquipment(const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item, const cClientHandle * a_Exclude) { - for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr ) + for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr) { if (*itr == a_Exclude) { @@ -2799,7 +2799,7 @@ void cChunk::BroadcastEntityEquipment(const cEntity & a_Entity, short a_SlotNum, void cChunk::BroadcastEntityHeadLook(const cEntity & a_Entity, const cClientHandle * a_Exclude) { - for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr ) + for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr) { if (*itr == a_Exclude) { @@ -2815,7 +2815,7 @@ void cChunk::BroadcastEntityHeadLook(const cEntity & a_Entity, const cClientHand void cChunk::BroadcastEntityLook(const cEntity & a_Entity, const cClientHandle * a_Exclude) { - for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr ) + for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr) { if (*itr == a_Exclude) { @@ -2831,7 +2831,7 @@ void cChunk::BroadcastEntityLook(const cEntity & a_Entity, const cClientHandle * void cChunk::BroadcastEntityMetadata(const cEntity & a_Entity, const cClientHandle * a_Exclude) { - for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr ) + for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr) { if (*itr == a_Exclude) { @@ -2847,7 +2847,7 @@ void cChunk::BroadcastEntityMetadata(const cEntity & a_Entity, const cClientHand void cChunk::BroadcastEntityRelMove(const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ, const cClientHandle * a_Exclude) { - for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr ) + for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr) { if (*itr == a_Exclude) { @@ -2863,7 +2863,7 @@ void cChunk::BroadcastEntityRelMove(const cEntity & a_Entity, char a_RelX, char void cChunk::BroadcastEntityRelMoveLook(const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ, const cClientHandle * a_Exclude) { - for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr ) + for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr) { if (*itr == a_Exclude) { @@ -2879,7 +2879,7 @@ void cChunk::BroadcastEntityRelMoveLook(const cEntity & a_Entity, char a_RelX, c void cChunk::BroadcastEntityStatus(const cEntity & a_Entity, char a_Status, const cClientHandle * a_Exclude) { - for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr ) + for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr) { if (*itr == a_Exclude) { @@ -2895,7 +2895,7 @@ void cChunk::BroadcastEntityStatus(const cEntity & a_Entity, char a_Status, cons void cChunk::BroadcastEntityVelocity(const cEntity & a_Entity, const cClientHandle * a_Exclude) { - for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr ) + for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr) { if (*itr == a_Exclude) { @@ -2911,7 +2911,7 @@ void cChunk::BroadcastEntityVelocity(const cEntity & a_Entity, const cClientHand void cChunk::BroadcastEntityAnimation(const cEntity & a_Entity, char a_Animation, const cClientHandle * a_Exclude) { - for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr ) + for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr) { if (*itr == a_Exclude) { @@ -2927,7 +2927,7 @@ void cChunk::BroadcastEntityAnimation(const cEntity & a_Entity, char a_Animation void cChunk::BroadcastParticleEffect(const AString & a_ParticleName, float a_SrcX, float a_SrcY, float a_SrcZ, float a_OffsetX, float a_OffsetY, float a_OffsetZ, float a_ParticleData, int a_ParticleAmmount, cClientHandle * a_Exclude) { - for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr ) + for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr) { if (*itr == a_Exclude) { @@ -2943,7 +2943,7 @@ void cChunk::BroadcastParticleEffect(const AString & a_ParticleName, float a_Src void cChunk::BroadcastRemoveEntityEffect(const cEntity & a_Entity, int a_EffectID, const cClientHandle * a_Exclude) { - for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr ) + for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr) { if (*itr == a_Exclude) { @@ -2959,7 +2959,7 @@ void cChunk::BroadcastRemoveEntityEffect(const cEntity & a_Entity, int a_EffectI void cChunk::BroadcastSoundEffect(const AString & a_SoundName, double a_X, double a_Y, double a_Z, float a_Volume, float a_Pitch, const cClientHandle * a_Exclude) { - for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr ) + for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr) { if (*itr == a_Exclude) { @@ -2975,7 +2975,7 @@ void cChunk::BroadcastSoundEffect(const AString & a_SoundName, double a_X, doubl void cChunk::BroadcastSoundParticleEffect(int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data, const cClientHandle * a_Exclude) { - for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr ) + for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr) { if (*itr == a_Exclude) { @@ -2991,7 +2991,7 @@ void cChunk::BroadcastSoundParticleEffect(int a_EffectID, int a_SrcX, int a_SrcY void cChunk::BroadcastSpawnEntity(cEntity & a_Entity, const cClientHandle * a_Exclude) { - for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr ) + for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr) { if (*itr == a_Exclude) { @@ -3007,7 +3007,7 @@ void cChunk::BroadcastSpawnEntity(cEntity & a_Entity, const cClientHandle * a_Ex void cChunk::BroadcastThunderbolt(int a_BlockX, int a_BlockY, int a_BlockZ, const cClientHandle * a_Exclude) { - for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr ) + for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr) { if (*itr == a_Exclude) { @@ -3021,9 +3021,9 @@ void cChunk::BroadcastThunderbolt(int a_BlockX, int a_BlockY, int a_BlockZ, cons -void cChunk::BroadcastUseBed(const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ ) +void cChunk::BroadcastUseBed(const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ) { - for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr ) + for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr) { (*itr)->SendUseBed(a_Entity, a_BlockX, a_BlockY, a_BlockZ); } // for itr - LoadedByClient[] diff --git a/src/Chunk.h b/src/Chunk.h index 2e2895c6e..9ab39a0a2 100644 --- a/src/Chunk.h +++ b/src/Chunk.h @@ -82,9 +82,9 @@ public: /* To save a chunk, the WSSchema must: - 1. Mark the chunk as being saved (MarkSaving() ) + 1. Mark the chunk as being saved (MarkSaving()) 2. Get the chunk's data using GetAllData() - 3. Mark the chunk as saved (MarkSaved() ) + 3. Mark the chunk as saved (MarkSaved()) If anywhere inside this sequence another thread mmodifies the chunk, the chunk will not get marked as saved in MarkSaved() */ void MarkSaving(void); // Marks the chunk as being saved. @@ -144,7 +144,7 @@ public: void SetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, bool a_SendToClients = true); // SetBlock() does a lot of work (heightmap, tickblocks, blockentities) so a BlockIdx version doesn't make sense - void SetBlock( const Vector3i & a_RelBlockPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta ) { SetBlock( a_RelBlockPos.x, a_RelBlockPos.y, a_RelBlockPos.z, a_BlockType, a_BlockMeta ); } + void SetBlock( const Vector3i & a_RelBlockPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) { SetBlock( a_RelBlockPos.x, a_RelBlockPos.y, a_RelBlockPos.z, a_BlockType, a_BlockMeta); } /** Queues a block change till the specified world tick */ void QueueSetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Int64 a_Tick, BLOCKTYPE a_PreviousBlockType = E_BLOCK_AIR); @@ -195,7 +195,7 @@ public: /** Sets the sign text. Returns true if successful. Also sends update packets to all clients in the chunk */ bool SetSignLines(int a_RelX, int a_RelY, int a_RelZ, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4); - int GetHeight( int a_X, int a_Z ); + int GetHeight( int a_X, int a_Z); void SendBlockTo(int a_RelX, int a_RelY, int a_RelZ, cClientHandle * a_Client); @@ -301,7 +301,7 @@ public: void BroadcastSoundParticleEffect(int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data, const cClientHandle * a_Exclude = NULL); void BroadcastSpawnEntity (cEntity & a_Entity, const cClientHandle * a_Exclude = NULL); void BroadcastThunderbolt (int a_BlockX, int a_BlockY, int a_BlockZ, const cClientHandle * a_Exclude = NULL); - void BroadcastUseBed (const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ ); + void BroadcastUseBed (const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ); void SendBlockEntity (int a_BlockX, int a_BlockY, int a_BlockZ, cClientHandle & a_Client); @@ -311,7 +311,7 @@ public: } void PositionToWorldPosition(int a_RelX, int a_RelY, int a_RelZ, int & a_BlockX, int & a_BlockY, int & a_BlockZ); - Vector3i PositionToWorldPosition(int a_RelX, int a_RelY, int a_RelZ ); + Vector3i PositionToWorldPosition(int a_RelX, int a_RelY, int a_RelZ); inline void MarkDirty(void) { diff --git a/src/ChunkDef.h b/src/ChunkDef.h index 334f8a6b9..dbb782d26 100644 --- a/src/ChunkDef.h +++ b/src/ChunkDef.h @@ -92,7 +92,7 @@ public: /// Converts absolute block coords into relative (chunk + block) coords: - inline static void AbsoluteToRelative(/* in-out */ int & a_X, int & a_Y, int & a_Z, /* out */ int & a_ChunkX, int & a_ChunkZ ) + inline static void AbsoluteToRelative(/* in-out */ int & a_X, int & a_Y, int & a_Z, /* out */ int & a_ChunkX, int & a_ChunkZ) { UNUSED(a_Y); BlockToChunk(a_X, a_Z, a_ChunkX, a_ChunkZ); @@ -118,7 +118,7 @@ public: } - inline static int MakeIndex(int x, int y, int z ) + inline static int MakeIndex(int x, int y, int z) { if ( (x < Width) && (x > -1) && @@ -145,7 +145,7 @@ public: } - inline static Vector3i IndexToCoordinate( unsigned int index ) + inline static Vector3i IndexToCoordinate( unsigned int index) { #if AXIS_ORDER == AXIS_ORDER_XZY return Vector3i( // 1.2 @@ -357,7 +357,7 @@ struct sSetBlock BLOCKTYPE BlockType; NIBBLETYPE BlockMeta; - sSetBlock( int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta ); // absolute block position + sSetBlock( int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta); // absolute block position sSetBlock(int a_ChunkX, int a_ChunkZ, int a_X, int a_Y, int a_Z, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) : x(a_X), y(a_Y), z(a_Z), ChunkX(a_ChunkX), ChunkZ(a_ChunkZ), diff --git a/src/ChunkMap.cpp b/src/ChunkMap.cpp index 49e9245d2..3ef981e94 100644 --- a/src/ChunkMap.cpp +++ b/src/ChunkMap.cpp @@ -64,7 +64,7 @@ cChunkMap::~cChunkMap() -void cChunkMap::RemoveLayer( cChunkLayer* a_Layer ) +void cChunkMap::RemoveLayer( cChunkLayer* a_Layer) { cCSLock Lock(m_CSLayers); m_Layers.remove(a_Layer); @@ -147,7 +147,7 @@ cChunkPtr cChunkMap::GetChunk(int a_ChunkX, int a_ChunkY, int a_ChunkZ) // No need to lock m_CSLayers, since it's already locked by the operation that called us ASSERT(m_CSLayers.IsLockedByCurrentThread()); - cChunkLayer * Layer = GetLayerForChunk( a_ChunkX, a_ChunkZ ); + cChunkLayer * Layer = GetLayerForChunk( a_ChunkX, a_ChunkZ); if (Layer == NULL) { // An error must have occurred, since layers are automatically created if they don't exist @@ -170,10 +170,10 @@ cChunkPtr cChunkMap::GetChunk(int a_ChunkX, int a_ChunkY, int a_ChunkZ) -cChunkPtr cChunkMap::GetChunkNoGen( int a_ChunkX, int a_ChunkY, int a_ChunkZ ) +cChunkPtr cChunkMap::GetChunkNoGen( int a_ChunkX, int a_ChunkY, int a_ChunkZ) { // No need to lock m_CSLayers, since it's already locked by the operation that called us - cChunkLayer * Layer = GetLayerForChunk( a_ChunkX, a_ChunkZ ); + cChunkLayer * Layer = GetLayerForChunk( a_ChunkX, a_ChunkZ); if (Layer == NULL) { // An error must have occurred, since layers are automatically created if they don't exist @@ -197,10 +197,10 @@ cChunkPtr cChunkMap::GetChunkNoGen( int a_ChunkX, int a_ChunkY, int a_ChunkZ ) -cChunkPtr cChunkMap::GetChunkNoLoad( int a_ChunkX, int a_ChunkY, int a_ChunkZ ) +cChunkPtr cChunkMap::GetChunkNoLoad( int a_ChunkX, int a_ChunkY, int a_ChunkZ) { // No need to lock m_CSLayers, since it's already locked by the operation that called us - cChunkLayer * Layer = GetLayerForChunk( a_ChunkX, a_ChunkZ ); + cChunkLayer * Layer = GetLayerForChunk( a_ChunkX, a_ChunkZ); if (Layer == NULL) { // An error must have occurred, since layers are automatically created if they don't exist @@ -720,7 +720,7 @@ void cChunkMap::BroadcastThunderbolt(int a_BlockX, int a_BlockY, int a_BlockZ, c -void cChunkMap::BroadcastUseBed(const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ ) +void cChunkMap::BroadcastUseBed(const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ) { cCSLock Lock(m_CSLayers); int ChunkX, ChunkZ; @@ -1154,9 +1154,9 @@ void cChunkMap::CollectPickupsByPlayer(cPlayer * a_Player) GetChunkNoLoad(ChunkX, ChunkY, ChunkZ)->CollectPickupsByPlayer(a_Player); // Check the neighboring chunks as well: - GetChunkNoLoad(OtherChunkX, ChunkY, ChunkZ )->CollectPickupsByPlayer(a_Player); + GetChunkNoLoad(OtherChunkX, ChunkY, ChunkZ)->CollectPickupsByPlayer (a_Player); GetChunkNoLoad(OtherChunkX, ChunkY, OtherChunkZ)->CollectPickupsByPlayer(a_Player); - GetChunkNoLoad(ChunkX, ChunkY, ChunkZ )->CollectPickupsByPlayer(a_Player); + GetChunkNoLoad(ChunkX, ChunkY, ChunkZ)->CollectPickupsByPlayer (a_Player); GetChunkNoLoad(ChunkX, ChunkY, OtherChunkZ)->CollectPickupsByPlayer(a_Player); } @@ -1181,7 +1181,7 @@ BLOCKTYPE cChunkMap::GetBlock(int a_BlockX, int a_BlockY, int a_BlockZ) } // for itr - m_FastSetBlockQueue[] } int ChunkX, ChunkZ; - cChunkDef::AbsoluteToRelative(a_BlockX, a_BlockY, a_BlockZ, ChunkX, ChunkZ ); + cChunkDef::AbsoluteToRelative(a_BlockX, a_BlockY, a_BlockZ, ChunkX, ChunkZ); cCSLock Lock(m_CSLayers); cChunkPtr Chunk = GetChunk(ChunkX, ZERO_CHUNK_Y, ChunkZ); @@ -1210,11 +1210,11 @@ NIBBLETYPE cChunkMap::GetBlockMeta(int a_BlockX, int a_BlockY, int a_BlockZ) } // for itr - m_FastSetBlockQueue[] } int ChunkX, ChunkZ; - cChunkDef::AbsoluteToRelative(a_BlockX, a_BlockY, a_BlockZ, ChunkX, ChunkZ ); + cChunkDef::AbsoluteToRelative(a_BlockX, a_BlockY, a_BlockZ, ChunkX, ChunkZ); cCSLock Lock(m_CSLayers); - cChunkPtr Chunk = GetChunk( ChunkX, ZERO_CHUNK_Y, ChunkZ ); - if ((Chunk != NULL) && Chunk->IsValid() ) + cChunkPtr Chunk = GetChunk( ChunkX, ZERO_CHUNK_Y, ChunkZ); + if ((Chunk != NULL) && Chunk->IsValid()) { return Chunk->GetMeta(a_BlockX, a_BlockY, a_BlockZ); } @@ -1228,11 +1228,11 @@ NIBBLETYPE cChunkMap::GetBlockMeta(int a_BlockX, int a_BlockY, int a_BlockZ) NIBBLETYPE cChunkMap::GetBlockSkyLight(int a_BlockX, int a_BlockY, int a_BlockZ) { int ChunkX, ChunkZ; - cChunkDef::AbsoluteToRelative(a_BlockX, a_BlockY, a_BlockZ, ChunkX, ChunkZ ); + cChunkDef::AbsoluteToRelative(a_BlockX, a_BlockY, a_BlockZ, ChunkX, ChunkZ); cCSLock Lock(m_CSLayers); - cChunkPtr Chunk = GetChunk( ChunkX, ZERO_CHUNK_Y, ChunkZ ); - if ((Chunk != NULL) && Chunk->IsValid() ) + cChunkPtr Chunk = GetChunk( ChunkX, ZERO_CHUNK_Y, ChunkZ); + if ((Chunk != NULL) && Chunk->IsValid()) { return Chunk->GetSkyLight(a_BlockX, a_BlockY, a_BlockZ); } @@ -1246,11 +1246,11 @@ NIBBLETYPE cChunkMap::GetBlockSkyLight(int a_BlockX, int a_BlockY, int a_BlockZ) NIBBLETYPE cChunkMap::GetBlockBlockLight(int a_BlockX, int a_BlockY, int a_BlockZ) { int ChunkX, ChunkZ; - cChunkDef::AbsoluteToRelative(a_BlockX, a_BlockY, a_BlockZ, ChunkX, ChunkZ ); + cChunkDef::AbsoluteToRelative(a_BlockX, a_BlockY, a_BlockZ, ChunkX, ChunkZ); cCSLock Lock(m_CSLayers); - cChunkPtr Chunk = GetChunk( ChunkX, ZERO_CHUNK_Y, ChunkZ ); - if ((Chunk != NULL) && Chunk->IsValid() ) + cChunkPtr Chunk = GetChunk( ChunkX, ZERO_CHUNK_Y, ChunkZ); + if ((Chunk != NULL) && Chunk->IsValid()) { return Chunk->GetBlockLight(a_BlockX, a_BlockY, a_BlockZ); } @@ -1288,10 +1288,10 @@ void cChunkMap::SetBlock(cWorldInterface & a_WorldInterface, int a_BlockX, int a } int ChunkX, ChunkZ, X = a_BlockX, Y = a_BlockY, Z = a_BlockZ; - cChunkDef::AbsoluteToRelative( X, Y, Z, ChunkX, ChunkZ ); + cChunkDef::AbsoluteToRelative( X, Y, Z, ChunkX, ChunkZ); cCSLock Lock(m_CSLayers); - cChunkPtr Chunk = GetChunk( ChunkX, ZERO_CHUNK_Y, ChunkZ ); + cChunkPtr Chunk = GetChunk( ChunkX, ZERO_CHUNK_Y, ChunkZ); if ((Chunk != NULL) && Chunk->IsValid()) { Chunk->SetBlock(X, Y, Z, a_BlockType, a_BlockMeta, a_SendToClients); @@ -1324,10 +1324,10 @@ void cChunkMap::QueueSetBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYP bool cChunkMap::GetBlockTypeMeta(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta) { int ChunkX, ChunkZ, X = a_BlockX, Y = a_BlockY, Z = a_BlockZ; - cChunkDef::AbsoluteToRelative( X, Y, Z, ChunkX, ChunkZ ); + cChunkDef::AbsoluteToRelative( X, Y, Z, ChunkX, ChunkZ); cCSLock Lock(m_CSLayers); - cChunkPtr Chunk = GetChunk( ChunkX, ZERO_CHUNK_Y, ChunkZ ); + cChunkPtr Chunk = GetChunk( ChunkX, ZERO_CHUNK_Y, ChunkZ); if ((Chunk != NULL) && Chunk->IsValid()) { Chunk->GetBlockTypeMeta(X, Y, Z, a_BlockType, a_BlockMeta); @@ -1343,10 +1343,10 @@ bool cChunkMap::GetBlockTypeMeta(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCK bool cChunkMap::GetBlockInfo(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_Meta, NIBBLETYPE & a_SkyLight, NIBBLETYPE & a_BlockLight) { int ChunkX, ChunkZ, X = a_BlockX, Y = a_BlockY, Z = a_BlockZ; - cChunkDef::AbsoluteToRelative( X, Y, Z, ChunkX, ChunkZ ); + cChunkDef::AbsoluteToRelative( X, Y, Z, ChunkX, ChunkZ); cCSLock Lock(m_CSLayers); - cChunkPtr Chunk = GetChunk( ChunkX, ZERO_CHUNK_Y, ChunkZ ); + cChunkPtr Chunk = GetChunk( ChunkX, ZERO_CHUNK_Y, ChunkZ); if ((Chunk != NULL) && Chunk->IsValid()) { Chunk->GetBlockInfo(X, Y, Z, a_BlockType, a_Meta, a_SkyLight, a_BlockLight); @@ -1364,7 +1364,7 @@ void cChunkMap::ReplaceBlocks(const sSetBlockVector & a_Blocks, BLOCKTYPE a_Filt cCSLock Lock(m_CSLayers); for (sSetBlockVector::const_iterator itr = a_Blocks.begin(); itr != a_Blocks.end(); ++itr) { - cChunkPtr Chunk = GetChunk(itr->ChunkX, ZERO_CHUNK_Y, itr->ChunkZ ); + cChunkPtr Chunk = GetChunk(itr->ChunkX, ZERO_CHUNK_Y, itr->ChunkZ); if ((Chunk == NULL) || !Chunk->IsValid()) { continue; @@ -1385,7 +1385,7 @@ void cChunkMap::ReplaceTreeBlocks(const sSetBlockVector & a_Blocks) cCSLock Lock(m_CSLayers); for (sSetBlockVector::const_iterator itr = a_Blocks.begin(); itr != a_Blocks.end(); ++itr) { - cChunkPtr Chunk = GetChunk(itr->ChunkX, ZERO_CHUNK_Y, itr->ChunkZ ); + cChunkPtr Chunk = GetChunk(itr->ChunkX, ZERO_CHUNK_Y, itr->ChunkZ); if ((Chunk == NULL) || !Chunk->IsValid()) { continue; @@ -1498,7 +1498,7 @@ bool cChunkMap::GetBlocks(sSetBlockVector & a_Blocks, bool a_ContinueOnFailure) cCSLock Lock(m_CSLayers); for (sSetBlockVector::iterator itr = a_Blocks.begin(); itr != a_Blocks.end(); ++itr) { - cChunkPtr Chunk = GetChunk(itr->ChunkX, ZERO_CHUNK_Y, itr->ChunkZ ); + cChunkPtr Chunk = GetChunk(itr->ChunkX, ZERO_CHUNK_Y, itr->ChunkZ); if ((Chunk == NULL) || !Chunk->IsValid()) { if (!a_ContinueOnFailure) @@ -1522,17 +1522,17 @@ bool cChunkMap::DigBlock(int a_X, int a_Y, int a_Z) { int PosX = a_X, PosY = a_Y, PosZ = a_Z, ChunkX, ChunkZ; - cChunkDef::AbsoluteToRelative( PosX, PosY, PosZ, ChunkX, ChunkZ ); + cChunkDef::AbsoluteToRelative( PosX, PosY, PosZ, ChunkX, ChunkZ); { cCSLock Lock(m_CSLayers); - cChunkPtr DestChunk = GetChunk( ChunkX, ZERO_CHUNK_Y, ChunkZ ); + cChunkPtr DestChunk = GetChunk( ChunkX, ZERO_CHUNK_Y, ChunkZ); if ((DestChunk == NULL) || !DestChunk->IsValid()) { return false; } - DestChunk->SetBlock(PosX, PosY, PosZ, E_BLOCK_AIR, 0 ); + DestChunk->SetBlock(PosX, PosY, PosZ, E_BLOCK_AIR, 0); m_World->GetSimulatorManager()->WakeUp(a_X, a_Y, a_Z, DestChunk); } @@ -2715,10 +2715,10 @@ cChunkMap::cChunkLayer::cChunkLayer( cChunkMap * a_Parent, cAllocationPool & a_Pool ) - : m_LayerX( a_LayerX ) - , m_LayerZ( a_LayerZ ) - , m_Parent( a_Parent ) - , m_NumChunksLoaded( 0 ) + : m_LayerX( a_LayerX) + , m_LayerZ( a_LayerZ) + , m_Parent( a_Parent) + , m_NumChunksLoaded( 0) , m_Pool(a_Pool) { memset(m_Chunks, 0, sizeof(m_Chunks)); @@ -2741,7 +2741,7 @@ cChunkMap::cChunkLayer::~cChunkLayer() -cChunkPtr cChunkMap::cChunkLayer::GetChunk( int a_ChunkX, int a_ChunkY, int a_ChunkZ ) +cChunkPtr cChunkMap::cChunkLayer::GetChunk( int a_ChunkX, int a_ChunkY, int a_ChunkZ) { // Always returns an assigned chunkptr, but the chunk needn't be valid (loaded / generated) - callers must check diff --git a/src/ChunkMap.h b/src/ChunkMap.h index 0bbd3dab1..4be1a4752 100644 --- a/src/ChunkMap.h +++ b/src/ChunkMap.h @@ -60,7 +60,7 @@ public: static const int LAYER_SIZE = 32; - cChunkMap(cWorld* a_World ); + cChunkMap(cWorld* a_World); ~cChunkMap(); // Broadcast respective packets to all clients of the chunk where the event is taking place @@ -89,7 +89,7 @@ public: void BroadcastSoundParticleEffect(int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data, const cClientHandle * a_Exclude = NULL); void BroadcastSpawnEntity(cEntity & a_Entity, const cClientHandle * a_Exclude = NULL); void BroadcastThunderbolt(int a_BlockX, int a_BlockY, int a_BlockZ, const cClientHandle * a_Exclude = NULL); - void BroadcastUseBed(const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ ); + void BroadcastUseBed(const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ); /** Sends the block entity, if it is at the coords specified, to a_Client */ void SendBlockEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cClientHandle & a_Client); @@ -289,7 +289,7 @@ public: /** Sets the sign text. Returns true if sign text changed. */ bool SetSignLines(int a_BlockX, int a_BlockY, int a_BlockZ, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4); - /** Marks the chunk as being regenerated - all its clients want that chunk again (used by cWorld::RegenerateChunk() ) */ + /** Marks the chunk as being regenerated - all its clients want that chunk again (used by cWorld::RegenerateChunk()) */ void MarkChunkRegenerating(int a_ChunkX, int a_ChunkZ); bool IsChunkLighted(int a_ChunkX, int a_ChunkZ); @@ -368,7 +368,7 @@ private: ~cChunkLayer(); /** Always returns an assigned chunkptr, but the chunk needn't be valid (loaded / generated) - callers must check */ - cChunkPtr GetChunk( int a_ChunkX, int a_ChunkY, int a_ChunkZ ); + cChunkPtr GetChunk( int a_ChunkX, int a_ChunkY, int a_ChunkZ); /** Returns the specified chunk, or NULL if not created yet */ cChunk * FindChunk(int a_ChunkX, int a_ChunkZ); diff --git a/src/ChunkSender.h b/src/ChunkSender.h index 095a99380..624a3a0bd 100644 --- a/src/ChunkSender.h +++ b/src/ChunkSender.h @@ -6,7 +6,7 @@ /* The whole thing is a thread that runs in a loop, waiting for either: "finished chunks" (ChunkReady()), or - "chunks to send" (QueueSendChunkTo() ) + "chunks to send" (QueueSendChunkTo()) to come to a queue. And once they do, it requests the chunk data and sends it all away, either broadcasting (ChunkReady), or diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index de4245b40..e4ad218a2 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -1170,7 +1170,7 @@ void cClientHandle::HandleRightClick(int a_BlockX, int a_BlockY, int a_BlockZ, e { // Only compare ItemType, not meta (torches have different metas) // The -1 check is there because sometimes the client sends -1 instead of the held item - // ( http://forum.mc-server.org/showthread.php?tid=549&pid=4502#pid4502 ) + // Ref.: http://forum.mc-server.org/showthread.php?tid=549&pid=4502#pid4502 LOGWARN("Player %s tried to place a block that was not equipped (exp %d, got %d)", m_Username.c_str(), Equipped.m_ItemType, a_HeldItem.m_ItemType ); @@ -2562,7 +2562,7 @@ void cClientHandle::SendUpdateSign( -void cClientHandle::SendUseBed(const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ ) +void cClientHandle::SendUseBed(const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ) { m_Protocol->SendUseBed(a_Entity, a_BlockX, a_BlockY, a_BlockZ); } @@ -2624,7 +2624,7 @@ const AString & cClientHandle::GetUsername(void) const -void cClientHandle::SetUsername( const AString & a_Username ) +void cClientHandle::SetUsername( const AString & a_Username) { m_Username = a_Username; } diff --git a/src/ClientHandle.h b/src/ClientHandle.h index 539e24ef6..538ecdad7 100644 --- a/src/ClientHandle.h +++ b/src/ClientHandle.h @@ -181,7 +181,7 @@ public: void SendUnloadChunk (int a_ChunkX, int a_ChunkZ); void SendUpdateBlockEntity (cBlockEntity & a_BlockEntity); void SendUpdateSign (int a_BlockX, int a_BlockY, int a_BlockZ, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4); - void SendUseBed (const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ ); + void SendUseBed (const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ); void SendWeather (eWeather a_Weather); void SendWholeInventory (const cWindow & a_Window); void SendWindowClose (const cWindow & a_Window); @@ -190,7 +190,7 @@ public: // tolua_begin const AString & GetUsername(void) const; - void SetUsername( const AString & a_Username ); + void SetUsername( const AString & a_Username); inline short GetPing(void) const { return m_Ping; } @@ -274,7 +274,7 @@ private: /** The type used for storing the names of registered plugin channels. */ typedef std::set cChannels; - /** Number of chunks the player can see in each direction; 4 is the minimum ( http://wiki.vg/Protocol_FAQ#.E2.80.A6all_connecting_clients_spasm_and_jerk_uncontrollably.21 ) */ + /** Number of chunks the player can see in each direction */ int m_ViewDistance; /** Server generates this many chunks AHEAD of player sight. */ diff --git a/src/CraftingRecipes.cpp b/src/CraftingRecipes.cpp index 85a373279..1a31a6e90 100644 --- a/src/CraftingRecipes.cpp +++ b/src/CraftingRecipes.cpp @@ -582,7 +582,7 @@ cCraftingRecipes::cRecipe * cCraftingRecipes::FindRecipe(const cItem * a_Craftin // Get the real bounds of the crafting grid: int GridLeft = MAX_GRID_WIDTH, GridTop = MAX_GRID_HEIGHT; int GridRight = 0, GridBottom = 0; - for (int y = 0; y < a_GridHeight; y++ ) for (int x = 0; x < a_GridWidth; x++) + for (int y = 0; y < a_GridHeight; y++) for (int x = 0; x < a_GridWidth; x++) { if (!a_CraftingGrid[x + y * a_GridWidth].IsEmpty()) { diff --git a/src/Cuboid.h b/src/Cuboid.h index 7bdb21b00..d62cf8063 100644 --- a/src/Cuboid.h +++ b/src/Cuboid.h @@ -15,7 +15,7 @@ public: Vector3i p1, p2; cCuboid(void) {} - cCuboid(const cCuboid & a_Cuboid ) : p1(a_Cuboid.p1), p2(a_Cuboid.p2) {} + cCuboid(const cCuboid & a_Cuboid) : p1(a_Cuboid.p1), p2(a_Cuboid.p2) {} cCuboid(const Vector3i & a_p1, const Vector3i & a_p2) : p1(a_p1), p2(a_p2) {} cCuboid(int a_X1, int a_Y1, int a_Z1) : p1(a_X1, a_Y1, a_Z1), p2(a_X1, a_Y1, a_Z1) {} cCuboid(int a_X1, int a_Y1, int a_Z1, int a_X2, int a_Y2, int a_Z2) : p1(a_X1, a_Y1, a_Z1), p2(a_X2, a_Y2, a_Z2) {} @@ -58,7 +58,7 @@ public: ); } - bool IsInside( const Vector3d & v ) const + bool IsInside( const Vector3d & v) const { return ( (v.x >= p1.x) && (v.x <= p2.x) && diff --git a/src/Defines.h b/src/Defines.h index f4ebbd9ff..f095069d9 100644 --- a/src/Defines.h +++ b/src/Defines.h @@ -479,9 +479,9 @@ inline void AddFaceDirection(int & a_BlockX, unsigned char & a_BlockY, int & a_B inline void EulerToVector(double a_Pan, double a_Pitch, double & a_X, double & a_Y, double & a_Z) { - // a_X = sinf ( a_Pan / 180 * PI ) * cosf ( a_Pitch / 180 * PI ); - // a_Y = -sinf ( a_Pitch / 180 * PI ); - // a_Z = -cosf ( a_Pan / 180 * PI ) * cosf ( a_Pitch / 180 * PI ); + // a_X = sinf ( a_Pan / 180 * PI) * cosf ( a_Pitch / 180 * PI); + // a_Y = -sinf ( a_Pitch / 180 * PI); + // a_Z = -cosf ( a_Pan / 180 * PI) * cosf ( a_Pitch / 180 * PI); a_X = cos(a_Pan / 180 * PI) * cos(a_Pitch / 180 * PI); a_Y = sin(a_Pan / 180 * PI) * cos(a_Pitch / 180 * PI); a_Z = sin(a_Pitch / 180 * PI); @@ -519,7 +519,7 @@ inline float GetSignf(float a_Val) -inline float GetSpecialSignf( float a_Val ) +inline float GetSpecialSignf( float a_Val) { return (a_Val <= 0.f) ? -1.f : 1.f; } @@ -640,11 +640,11 @@ namespace ItemCategory inline bool IsTool(short a_ItemID) { - return IsPickaxe( a_ItemID ) - || IsAxe ( a_ItemID ) - || IsSword ( a_ItemID ) - || IsHoe ( a_ItemID ) - || IsShovel ( a_ItemID ); + return IsPickaxe( a_ItemID) + || IsAxe ( a_ItemID) + || IsSword ( a_ItemID) + || IsHoe ( a_ItemID) + || IsShovel ( a_ItemID); } diff --git a/src/Enchantments.h b/src/Enchantments.h index 85a316414..98d7c0d36 100644 --- a/src/Enchantments.h +++ b/src/Enchantments.h @@ -40,7 +40,7 @@ Serialization will never put zero-level enchantments into the stringspec and wil class cEnchantments { public: - /** Individual enchantment IDs, corresponding to their NBT IDs ( http://www.minecraftwiki.net/wiki/Data_Values#Enchantment_IDs ) + /** Individual enchantment IDs, corresponding to their NBT IDs: http://www.minecraftwiki.net/wiki/Data_Values#Enchantment_IDs */ enum diff --git a/src/Endianness.h b/src/Endianness.h index 78f9a5d99..5997086e0 100644 --- a/src/Endianness.h +++ b/src/Endianness.h @@ -11,8 +11,8 @@ inline UInt64 HostToNetwork8(const void * a_Value) { unsigned long long __HostToNetwork8; - memcpy( &__HostToNetwork8, a_Value, sizeof( __HostToNetwork8 ) ); - __HostToNetwork8 = (( ( (unsigned long long)htonl((u_long)__HostToNetwork8) ) << 32) + htonl(__HostToNetwork8 >> 32)); + memcpy( &__HostToNetwork8, a_Value, sizeof( __HostToNetwork8)); + __HostToNetwork8 = (( ( (unsigned long long)htonl((u_long)__HostToNetwork8)) << 32) + htonl(__HostToNetwork8 >> 32)); return __HostToNetwork8; } @@ -20,11 +20,11 @@ inline UInt64 HostToNetwork8(const void * a_Value) -inline UInt32 HostToNetwork4(const void* a_Value ) +inline UInt32 HostToNetwork4(const void* a_Value) { unsigned int __HostToNetwork4; - memcpy( &__HostToNetwork4, a_Value, sizeof( __HostToNetwork4 ) ); - __HostToNetwork4 = ntohl( __HostToNetwork4 ); + memcpy( &__HostToNetwork4, a_Value, sizeof( __HostToNetwork4)); + __HostToNetwork4 = ntohl( __HostToNetwork4); return __HostToNetwork4; } diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index 5a3bbcdc4..db0fd0fd6 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -648,7 +648,7 @@ void cEntity::HandlePhysics(float a_Dt, cChunk & a_Chunk) int RelBlockX = BlockX - (NextChunk->GetPosX() * cChunkDef::Width); int RelBlockZ = BlockZ - (NextChunk->GetPosZ() * cChunkDef::Width); - BLOCKTYPE BlockIn = NextChunk->GetBlock( RelBlockX, BlockY, RelBlockZ ); + BLOCKTYPE BlockIn = NextChunk->GetBlock( RelBlockX, BlockY, RelBlockZ); BLOCKTYPE BlockBelow = (BlockY > 0) ? NextChunk->GetBlock(RelBlockX, BlockY - 1, RelBlockZ) : E_BLOCK_AIR; if (!cBlockInfo::IsSolid(BlockIn)) // Making sure we are not inside a solid block { @@ -758,7 +758,7 @@ void cEntity::HandlePhysics(float a_Dt, cChunk & a_Chunk) m_WaterSpeed *= 0.9f; // Reduce speed each tick - switch(WaterDir) + switch (WaterDir) { case X_PLUS: m_WaterSpeed.x = 0.2f; diff --git a/src/Entities/ExpOrb.cpp b/src/Entities/ExpOrb.cpp index ed225b8e6..73d5cbfed 100644 --- a/src/Entities/ExpOrb.cpp +++ b/src/Entities/ExpOrb.cpp @@ -62,9 +62,9 @@ void cExpOrb::Tick(float a_Dt, cChunk & a_Chunk) } a_Distance.Normalize(); a_Distance *= ((float) (5.5 - Distance)); - SetSpeedX( a_Distance.x ); - SetSpeedY( a_Distance.y ); - SetSpeedZ( a_Distance.z ); + SetSpeedX( a_Distance.x); + SetSpeedY( a_Distance.y); + SetSpeedZ( a_Distance.z); BroadcastMovementUpdate(); } HandlePhysics(a_Dt, a_Chunk); diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index 6a52d8e29..fcc8eb9a0 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -140,7 +140,7 @@ cPlayer::~cPlayer(void) SaveToDisk(); - m_World->RemovePlayer( this ); + m_World->RemovePlayer( this); m_ClientHandle = NULL; @@ -173,11 +173,11 @@ void cPlayer::SpawnOn(cClientHandle & a_Client) } a_Client.SendPlayerSpawn(*this); a_Client.SendEntityHeadLook(*this); - a_Client.SendEntityEquipment(*this, 0, m_Inventory.GetEquippedItem() ); - a_Client.SendEntityEquipment(*this, 1, m_Inventory.GetEquippedBoots() ); - a_Client.SendEntityEquipment(*this, 2, m_Inventory.GetEquippedLeggings() ); - a_Client.SendEntityEquipment(*this, 3, m_Inventory.GetEquippedChestplate() ); - a_Client.SendEntityEquipment(*this, 4, m_Inventory.GetEquippedHelmet() ); + a_Client.SendEntityEquipment(*this, 0, m_Inventory.GetEquippedItem()); + a_Client.SendEntityEquipment(*this, 1, m_Inventory.GetEquippedBoots()); + a_Client.SendEntityEquipment(*this, 2, m_Inventory.GetEquippedLeggings()); + a_Client.SendEntityEquipment(*this, 3, m_Inventory.GetEquippedChestplate()); + a_Client.SendEntityEquipment(*this, 4, m_Inventory.GetEquippedHelmet()); } @@ -298,7 +298,7 @@ short cPlayer::CalcLevelFromXp(short a_XpTotal) } // level 16 to 30 - return (short) ( 29.5 + sqrt( 870.25 - (6 * ( 360 - a_XpTotal )))) / 3; + return (short) ( 29.5 + sqrt( 870.25 - (6 * ( 360 - a_XpTotal)))) / 3; } @@ -316,11 +316,11 @@ short cPlayer::XpForLevel(short a_Level) // level 30+ if (a_Level >= 31) { - return (short) ( (3.5 * a_Level * a_Level) - (151.5 * a_Level) + 2220 ); + return (short) ( (3.5 * a_Level * a_Level) - (151.5 * a_Level) + 2220); } // level 16 to 30 - return (short) ( (1.5 * a_Level * a_Level) - (29.5 * a_Level) + 360 ); + return (short) ( (1.5 * a_Level * a_Level) - (29.5 * a_Level) + 360); } @@ -1007,7 +1007,7 @@ double cPlayer::GetEyeHeight(void) const Vector3d cPlayer::GetEyePosition(void) const { - return Vector3d( GetPosX(), m_Stance, GetPosZ() ); + return Vector3d( GetPosX(), m_Stance, GetPosZ()); } @@ -1169,7 +1169,7 @@ void cPlayer::SetGameMode(eGameMode a_GameMode) -void cPlayer::LoginSetGameMode( eGameMode a_GameMode ) +void cPlayer::LoginSetGameMode( eGameMode a_GameMode) { m_GameMode = a_GameMode; } @@ -1305,7 +1305,7 @@ void cPlayer::DoSetSpeed(double a_SpeedX, double a_SpeedY, double a_SpeedZ) -void cPlayer::MoveTo( const Vector3d & a_NewPos ) +void cPlayer::MoveTo( const Vector3d & a_NewPos) { if ((a_NewPos.y < -990) && (GetPosY() > -100)) { @@ -1328,7 +1328,7 @@ void cPlayer::MoveTo( const Vector3d & a_NewPos ) Vector3d DeltaPos = a_NewPos - GetPosition(); UpdateMovementStats(DeltaPos); - SetPosition( a_NewPos ); + SetPosition( a_NewPos); SetStance(a_NewPos.y + 1.62); } @@ -1354,11 +1354,11 @@ void cPlayer::SetVisible(bool a_bVisible) -void cPlayer::AddToGroup( const AString & a_GroupName ) +void cPlayer::AddToGroup( const AString & a_GroupName) { - cGroup* Group = cRoot::Get()->GetGroupManager()->GetGroup( a_GroupName ); - m_Groups.push_back( Group ); - LOGD("Added %s to group %s", GetName().c_str(), a_GroupName.c_str() ); + cGroup* Group = cRoot::Get()->GetGroupManager()->GetGroup( a_GroupName); + m_Groups.push_back( Group); + LOGD("Added %s to group %s", GetName().c_str(), a_GroupName.c_str()); ResolveGroups(); ResolvePermissions(); } @@ -1367,28 +1367,28 @@ void cPlayer::AddToGroup( const AString & a_GroupName ) -void cPlayer::RemoveFromGroup( const AString & a_GroupName ) +void cPlayer::RemoveFromGroup( const AString & a_GroupName) { bool bRemoved = false; - for (GroupList::iterator itr = m_Groups.begin(); itr != m_Groups.end(); ++itr ) + for (GroupList::iterator itr = m_Groups.begin(); itr != m_Groups.end(); ++itr) { - if ((*itr)->GetName().compare(a_GroupName ) == 0 ) + if ((*itr)->GetName().compare(a_GroupName) == 0) { - m_Groups.erase( itr ); + m_Groups.erase( itr); bRemoved = true; break; } } - if (bRemoved ) + if (bRemoved) { - LOGD("Removed %s from group %s", GetName().c_str(), a_GroupName.c_str() ); + LOGD("Removed %s from group %s", GetName().c_str(), a_GroupName.c_str()); ResolveGroups(); ResolvePermissions(); } else { - LOGWARN("Tried to remove %s from group %s but was not in that group", GetName().c_str(), a_GroupName.c_str() ); + LOGWARN("Tried to remove %s from group %s but was not in that group", GetName().c_str(), a_GroupName.c_str()); } } @@ -1404,30 +1404,30 @@ bool cPlayer::HasPermission(const AString & a_Permission) return true; } - AStringVector Split = StringSplit( a_Permission, "." ); + AStringVector Split = StringSplit( a_Permission, "."); PermissionMap Possibilities = m_ResolvedPermissions; // Now search the namespaces - while (Possibilities.begin() != Possibilities.end() ) + while (Possibilities.begin() != Possibilities.end()) { PermissionMap::iterator itr = Possibilities.begin(); - if (itr->second ) + if (itr->second) { - AStringVector OtherSplit = StringSplit( itr->first, "." ); - if (OtherSplit.size() <= Split.size() ) + AStringVector OtherSplit = StringSplit( itr->first, "."); + if (OtherSplit.size() <= Split.size()) { unsigned int i; - for (i = 0; i < OtherSplit.size(); ++i ) + for (i = 0; i < OtherSplit.size(); ++i) { - if (OtherSplit[i].compare( Split[i] ) != 0 ) + if (OtherSplit[i].compare( Split[i]) != 0) { - if (OtherSplit[i].compare("*") == 0 ) return true; // WildCard man!! WildCard! + if (OtherSplit[i].compare("*") == 0) return true; // WildCard man!! WildCard! break; } } - if (i == Split.size() ) return true; + if (i == Split.size()) return true; } } - Possibilities.erase( itr ); + Possibilities.erase( itr); } // Nothing that matched :( @@ -1438,11 +1438,11 @@ bool cPlayer::HasPermission(const AString & a_Permission) -bool cPlayer::IsInGroup( const AString & a_Group ) +bool cPlayer::IsInGroup( const AString & a_Group) { - for (GroupList::iterator itr = m_ResolvedGroups.begin(); itr != m_ResolvedGroups.end(); ++itr ) + for (GroupList::iterator itr = m_ResolvedGroups.begin(); itr != m_ResolvedGroups.end(); ++itr) { - if (a_Group.compare( (*itr)->GetName().c_str() ) == 0 ) + if (a_Group.compare( (*itr)->GetName().c_str()) == 0) return true; } return false; @@ -1457,15 +1457,15 @@ void cPlayer::ResolvePermissions() m_ResolvedPermissions.clear(); // Start with an empty map // Copy all player specific permissions into the resolved permissions map - for (PermissionMap::iterator itr = m_Permissions.begin(); itr != m_Permissions.end(); ++itr ) + for (PermissionMap::iterator itr = m_Permissions.begin(); itr != m_Permissions.end(); ++itr) { m_ResolvedPermissions[ itr->first ] = itr->second; } - for (GroupList::iterator GroupItr = m_ResolvedGroups.begin(); GroupItr != m_ResolvedGroups.end(); ++GroupItr ) + for (GroupList::iterator GroupItr = m_ResolvedGroups.begin(); GroupItr != m_ResolvedGroups.end(); ++GroupItr) { const cGroup::PermissionMap & Permissions = (*GroupItr)->GetPermissions(); - for (cGroup::PermissionMap::const_iterator itr = Permissions.begin(); itr != Permissions.end(); ++itr ) + for (cGroup::PermissionMap::const_iterator itr = Permissions.begin(); itr != Permissions.end(); ++itr) { m_ResolvedPermissions[ itr->first ] = itr->second; } @@ -1484,14 +1484,14 @@ void cPlayer::ResolveGroups() // Get a complete resolved list of all groups the player is in std::map< cGroup*, bool > AllGroups; // Use a map, because it's faster than iterating through a list to find duplicates GroupList ToIterate; - for (GroupList::iterator GroupItr = m_Groups.begin(); GroupItr != m_Groups.end(); ++GroupItr ) + for (GroupList::iterator GroupItr = m_Groups.begin(); GroupItr != m_Groups.end(); ++GroupItr) { - ToIterate.push_back( *GroupItr ); + ToIterate.push_back( *GroupItr); } - while (ToIterate.begin() != ToIterate.end() ) + while (ToIterate.begin() != ToIterate.end()) { cGroup* CurrentGroup = *ToIterate.begin(); - if (AllGroups.find( CurrentGroup ) != AllGroups.end() ) + if (AllGroups.find( CurrentGroup) != AllGroups.end()) { LOGWARNING("ERROR: Player \"%s\" is in the group multiple times (\"%s\"). Please fix your settings in users.ini!", GetName().c_str(), CurrentGroup->GetName().c_str() @@ -1500,19 +1500,19 @@ void cPlayer::ResolveGroups() else { AllGroups[ CurrentGroup ] = true; - m_ResolvedGroups.push_back( CurrentGroup ); // Add group to resolved list + m_ResolvedGroups.push_back( CurrentGroup); // Add group to resolved list const cGroup::GroupList & Inherits = CurrentGroup->GetInherits(); - for (cGroup::GroupList::const_iterator itr = Inherits.begin(); itr != Inherits.end(); ++itr ) + for (cGroup::GroupList::const_iterator itr = Inherits.begin(); itr != Inherits.end(); ++itr) { - if (AllGroups.find( *itr ) != AllGroups.end() ) + if (AllGroups.find( *itr) != AllGroups.end()) { - LOGERROR("ERROR: Player %s is in the same group multiple times due to inheritance (%s). FIX IT!", GetName().c_str(), (*itr)->GetName().c_str() ); + LOGERROR("ERROR: Player %s is in the same group multiple times due to inheritance (%s). FIX IT!", GetName().c_str(), (*itr)->GetName().c_str()); continue; } - ToIterate.push_back( *itr ); + ToIterate.push_back( *itr); } } - ToIterate.erase( ToIterate.begin() ); + ToIterate.erase( ToIterate.begin()); } } @@ -1522,12 +1522,12 @@ void cPlayer::ResolveGroups() AString cPlayer::GetColor(void) const { - if (m_Color != '-' ) + if (m_Color != '-') { return cChatColor::Delimiter + m_Color; } - if (m_Groups.size() < 1 ) + if (m_Groups.size() < 1) { return cChatColor::White; } @@ -1914,11 +1914,11 @@ cPlayer::StringList cPlayer::GetResolvedPermissions() StringList Permissions; const PermissionMap& ResolvedPermissions = m_ResolvedPermissions; - for (PermissionMap::const_iterator itr = ResolvedPermissions.begin(); itr != ResolvedPermissions.end(); ++itr ) + for (PermissionMap::const_iterator itr = ResolvedPermissions.begin(); itr != ResolvedPermissions.end(); ++itr) { if (itr->second) { - Permissions.push_back( itr->first ); + Permissions.push_back( itr->first); } } diff --git a/src/Entities/Player.h b/src/Entities/Player.h index 7c287d41b..26db2050b 100644 --- a/src/Entities/Player.h +++ b/src/Entities/Player.h @@ -117,8 +117,8 @@ public: /** Returns true if the player is currently charging the bow */ bool IsChargingBow(void) const { return m_IsChargingBow; } - void SetTouchGround( bool a_bTouchGround ); - inline void SetStance( const double a_Stance ) { m_Stance = a_Stance; } + void SetTouchGround( bool a_bTouchGround); + inline void SetStance( const double a_Stance) { m_Stance = a_Stance; } double GetEyeHeight(void) const; // tolua_export Vector3d GetEyePosition(void) const; // tolua_export inline bool IsOnGround(void) const {return m_bTouchGround; } // tolua_export @@ -239,15 +239,15 @@ public: typedef std::list< std::string > StringList; /** Adds a player to existing group or creates a new group when it doesn't exist */ - void AddToGroup( const AString & a_GroupName ); // tolua_export + void AddToGroup( const AString & a_GroupName); // tolua_export /** Removes a player from the group, resolves permissions and group inheritance (case sensitive) */ - void RemoveFromGroup( const AString & a_GroupName ); // tolua_export + void RemoveFromGroup( const AString & a_GroupName); // tolua_export - bool HasPermission( const AString & a_Permission ); // tolua_export + bool HasPermission( const AString & a_Permission); // tolua_export const GroupList & GetGroups() { return m_Groups; } // >> EXPORTED IN MANUALBINDINGS << StringList GetResolvedPermissions(); // >> EXPORTED IN MANUALBINDINGS << - bool IsInGroup( const AString & a_Group ); // tolua_export + bool IsInGroup( const AString & a_Group); // tolua_export // tolua_begin @@ -328,7 +328,7 @@ public: void Respawn(void); // tolua_export - void SetVisible( bool a_bVisible ); // tolua_export + void SetVisible( bool a_bVisible); // tolua_export bool IsVisible(void) const { return m_bVisible; } // tolua_export /** Moves the player to the specified world. diff --git a/src/FurnaceRecipe.cpp b/src/FurnaceRecipe.cpp index cf29e227f..ab772e97b 100644 --- a/src/FurnaceRecipe.cpp +++ b/src/FurnaceRecipe.cpp @@ -30,7 +30,7 @@ struct cFurnaceRecipe::sFurnaceRecipeState cFurnaceRecipe::cFurnaceRecipe() - : m_pState( new sFurnaceRecipeState ) + : m_pState( new sFurnaceRecipeState) { ReloadRecipes(); } diff --git a/src/Generating/Caves.cpp b/src/Generating/Caves.cpp index 21bfd98b8..3b71efb57 100644 --- a/src/Generating/Caves.cpp +++ b/src/Generating/Caves.cpp @@ -703,10 +703,10 @@ cGridStructGen::cStructurePtr cStructGenWormNestCaves::CreateStructure(int a_Gri //////////////////////////////////////////////////////////////////////////////// // cStructGenMarbleCaves: -static float GetMarbleNoise( float x, float y, float z, cNoise & a_Noise ) +static float GetMarbleNoise( float x, float y, float z, cNoise & a_Noise) { static const float PI_2 = 1.57079633f; - float oct1 = (a_Noise.CubicNoise3D(x * 0.1f, y * 0.1f, z * 0.1f )) * 4; + float oct1 = (a_Noise.CubicNoise3D(x * 0.1f, y * 0.1f, z * 0.1f)) * 4; oct1 = oct1 * oct1 * oct1; if (oct1 < 0.f) oct1 = PI_2; @@ -730,7 +730,7 @@ void cStructGenMarbleCaves::GenFinish(cChunkDesc & a_ChunkDesc) const float xx = (float)(a_ChunkDesc.GetChunkX() * cChunkDef::Width + x); int Top = a_ChunkDesc.GetHeight(x, z); - for (int y = 1; y < Top; ++y ) + for (int y = 1; y < Top; ++y) { if (a_ChunkDesc.GetBlockType(x, y, z) != E_BLOCK_STONE) { diff --git a/src/Generating/ChunkGenerator.cpp b/src/Generating/ChunkGenerator.cpp index 9383a3adf..0baf1e991 100644 --- a/src/Generating/ChunkGenerator.cpp +++ b/src/Generating/ChunkGenerator.cpp @@ -229,7 +229,7 @@ void cChunkGenerator::Execute(void) } cChunkCoords coords = m_Queue.front(); // Get next coord from queue - m_Queue.erase( m_Queue.begin() ); // Remove coordinate from queue + m_Queue.erase( m_Queue.begin()); // Remove coordinate from queue bool SkipEnabled = (m_Queue.size() > QUEUE_SKIP_LIMIT); Lock.Unlock(); // Unlock ASAP m_evtRemoved.Set(); diff --git a/src/Generating/FinishGen.cpp b/src/Generating/FinishGen.cpp index 00a93023d..dca346e52 100644 --- a/src/Generating/FinishGen.cpp +++ b/src/Generating/FinishGen.cpp @@ -239,14 +239,14 @@ void cFinishGenSprinkleFoliage::GenFinish(cChunkDesc & a_ChunkDesc) } const float xx = (float)BlockX; - float val1 = m_Noise.CubicNoise2D(xx * 0.1f, zz * 0.1f ); - float val2 = m_Noise.CubicNoise2D(xx * 0.01f, zz * 0.01f ); + float val1 = m_Noise.CubicNoise2D(xx * 0.1f, zz * 0.1f); + float val2 = m_Noise.CubicNoise2D(xx * 0.01f, zz * 0.01f); switch (a_ChunkDesc.GetBlockType(x, Top, z)) { case E_BLOCK_GRASS: { - float val3 = m_Noise.CubicNoise2D(xx * 0.01f + 10, zz * 0.01f + 10 ); - float val4 = m_Noise.CubicNoise2D(xx * 0.05f + 20, zz * 0.05f + 20 ); + float val3 = m_Noise.CubicNoise2D(xx * 0.01f + 10, zz * 0.01f + 10); + float val4 = m_Noise.CubicNoise2D(xx * 0.05f + 20, zz * 0.05f + 20); if (val1 + val2 > 0.2f) { a_ChunkDesc.SetBlockType(x, ++Top, z, E_BLOCK_YELLOW_FLOWER); diff --git a/src/Generating/HeiGen.cpp b/src/Generating/HeiGen.cpp index 3df1a90ff..870ceef7f 100644 --- a/src/Generating/HeiGen.cpp +++ b/src/Generating/HeiGen.cpp @@ -253,7 +253,7 @@ float cHeiGenClassic::GetNoise(float x, float y) float oct2 = m_Noise.CubicNoise2D(x * m_HeightFreq2, y * m_HeightFreq2) * m_HeightAmp2; float oct3 = m_Noise.CubicNoise2D(x * m_HeightFreq3, y * m_HeightFreq3) * m_HeightAmp3; - float height = m_Noise.CubicNoise2D(x * 0.1f, y * 0.1f ) * 2; + float height = m_Noise.CubicNoise2D(x * 0.1f, y * 0.1f) * 2; float flatness = ((m_Noise.CubicNoise2D(x * 0.5f, y * 0.5f) + 1.f) * 0.5f) * 1.1f; // 0 ... 1.5 flatness *= flatness * flatness; diff --git a/src/Globals.h b/src/Globals.h index 007fa10d0..b35af9604 100644 --- a/src/Globals.h +++ b/src/Globals.h @@ -272,12 +272,12 @@ void inline LOGERROR(const char* a_Format, ...) /// Evaluates to the number of elements in an array (compile-time!) #define ARRAYCOUNT(X) (sizeof(X) / sizeof(*(X))) -/// Allows arithmetic expressions like "32 KiB" (but consider using parenthesis around it, "(32 KiB)" ) +/// Allows arithmetic expressions like "32 KiB" (but consider using parenthesis around it, "(32 KiB)") #define KiB * 1024 #define MiB * 1024 * 1024 /// Faster than (int)floorf((float)x / (float)div) -#define FAST_FLOOR_DIV( x, div ) (((x) - (((x) < 0) ? ((div) - 1) : 0)) / (div)) +#define FAST_FLOOR_DIV( x, div) (((x) - (((x) < 0) ? ((div) - 1) : 0)) / (div)) // Own version of assert() that writes failed assertions to the log for review #ifdef TEST_GLOBALS @@ -314,14 +314,14 @@ void inline LOGERROR(const char* a_Format, ...) #else #ifdef _DEBUG - #define ASSERT( x ) ( !!(x) || ( LOGERROR("Assertion failed: %s, file %s, line %i", #x, __FILE__, __LINE__ ), assert(0), 0 ) ) + #define ASSERT( x) ( !!(x) || ( LOGERROR("Assertion failed: %s, file %s, line %i", #x, __FILE__, __LINE__), assert(0), 0)) #else #define ASSERT(x) ((void)(x)) #endif #endif // Pretty much the same as ASSERT() but stays in Release builds -#define VERIFY( x ) ( !!(x) || ( LOGERROR("Verification failed: %s, file %s, line %i", #x, __FILE__, __LINE__ ), exit(1), 0 ) ) +#define VERIFY( x) ( !!(x) || ( LOGERROR("Verification failed: %s, file %s, line %i", #x, __FILE__, __LINE__), exit(1), 0)) // Same as assert but in all Self test builds #ifdef SELF_TEST diff --git a/src/Group.cpp b/src/Group.cpp index 725740905..def585618 100644 --- a/src/Group.cpp +++ b/src/Group.cpp @@ -7,7 +7,7 @@ -void cGroup::AddCommand( const AString & a_Command ) +void cGroup::AddCommand( const AString & a_Command) { m_Commands[ a_Command ] = true; } @@ -16,7 +16,7 @@ void cGroup::AddCommand( const AString & a_Command ) -void cGroup::AddPermission( const AString & a_Permission ) +void cGroup::AddPermission( const AString & a_Permission) { m_Permissions[ a_Permission ] = true; } @@ -25,10 +25,10 @@ void cGroup::AddPermission( const AString & a_Permission ) -void cGroup::InheritFrom( cGroup* a_Group ) +void cGroup::InheritFrom( cGroup* a_Group) { - m_Inherits.remove( a_Group ); - m_Inherits.push_back( a_Group ); + m_Inherits.remove( a_Group); + m_Inherits.push_back( a_Group); } diff --git a/src/Group.h b/src/Group.h index 95063a987..5816f8a06 100644 --- a/src/Group.h +++ b/src/Group.h @@ -14,12 +14,12 @@ public: ~cGroup() {} // tolua_begin - void SetName( const AString & a_Name ) { m_Name = a_Name; } + void SetName( const AString & a_Name) { m_Name = a_Name; } const AString & GetName() const { return m_Name; } - void SetColor( const AString & a_Color ) { m_Color = a_Color; } - void AddCommand( const AString & a_Command ); - void AddPermission( const AString & a_Permission ); - void InheritFrom( cGroup* a_Group ); + void SetColor( const AString & a_Color) { m_Color = a_Color; } + void AddCommand( const AString & a_Command); + void AddPermission( const AString & a_Permission); + void InheritFrom( cGroup* a_Group); // tolua_end typedef std::map< AString, bool > PermissionMap; diff --git a/src/GroupManager.cpp b/src/GroupManager.cpp index 685aece5a..32c2f1c97 100644 --- a/src/GroupManager.cpp +++ b/src/GroupManager.cpp @@ -27,7 +27,7 @@ struct cGroupManager::sGroupManagerState cGroupManager::~cGroupManager() { - for (GroupMap::iterator itr = m_pState->Groups.begin(); itr != m_pState->Groups.end(); ++itr ) + for (GroupMap::iterator itr = m_pState->Groups.begin(); itr != m_pState->Groups.end(); ++itr) { delete itr->second; itr->second = NULL; @@ -43,7 +43,7 @@ cGroupManager::~cGroupManager() cGroupManager::cGroupManager() - : m_pState( new sGroupManagerState ) + : m_pState( new sGroupManagerState) { LOGD("-- Loading Groups --"); @@ -198,20 +198,20 @@ bool cGroupManager::LoadGroups() -bool cGroupManager::ExistsGroup( const AString & a_Name ) +bool cGroupManager::ExistsGroup( const AString & a_Name) { - GroupMap::iterator itr = m_pState->Groups.find( a_Name ); - return ( itr != m_pState->Groups.end() ); + GroupMap::iterator itr = m_pState->Groups.find( a_Name); + return ( itr != m_pState->Groups.end()); } -cGroup* cGroupManager::GetGroup( const AString & a_Name ) +cGroup* cGroupManager::GetGroup( const AString & a_Name) { - GroupMap::iterator itr = m_pState->Groups.find( a_Name ); - if (itr != m_pState->Groups.end() ) + GroupMap::iterator itr = m_pState->Groups.find( a_Name); + if (itr != m_pState->Groups.end()) { return itr->second; } diff --git a/src/HTTPServer/HTTPConnection.cpp b/src/HTTPServer/HTTPConnection.cpp index 21ff14373..b9c762e7c 100644 --- a/src/HTTPServer/HTTPConnection.cpp +++ b/src/HTTPServer/HTTPConnection.cpp @@ -100,7 +100,7 @@ void cHTTPConnection::AwaitNextRequest(void) { case wcsRecvHeaders: { - // Nothing has been received yet, or a special response was given (SendStatusAndReason() or SendNeedAuth() ) + // Nothing has been received yet, or a special response was given (SendStatusAndReason() or SendNeedAuth()) break; } diff --git a/src/Inventory.cpp b/src/Inventory.cpp index 93b2c8eee..0f9716d89 100644 --- a/src/Inventory.cpp +++ b/src/Inventory.cpp @@ -497,21 +497,21 @@ int cInventory::ArmorSlotNumToEntityEquipmentID(short a_ArmorSlotNum) #if 0 -bool cInventory::AddToBar( cItem & a_Item, const int a_Offset, const int a_Size, bool* a_bChangedSlots, int a_Mode /* = 0 */ ) +bool cInventory::AddToBar( cItem & a_Item, const int a_Offset, const int a_Size, bool* a_bChangedSlots, int a_Mode /* = 0 */) { // Fill already present stacks - if (a_Mode < 2 ) + if (a_Mode < 2) { int MaxStackSize = cItemHandler::GetItemHandler(a_Item.m_ItemType)->GetMaxStackSize(); for (int i = 0; i < a_Size; i++) { - if (m_Slots[i + a_Offset].m_ItemType == a_Item.m_ItemType && m_Slots[i + a_Offset].m_ItemCount < MaxStackSize && m_Slots[i + a_Offset].m_ItemDamage == a_Item.m_ItemDamage ) + if (m_Slots[i + a_Offset].m_ItemType == a_Item.m_ItemType && m_Slots[i + a_Offset].m_ItemCount < MaxStackSize && m_Slots[i + a_Offset].m_ItemDamage == a_Item.m_ItemDamage) { int NumFree = MaxStackSize - m_Slots[i + a_Offset].m_ItemCount; - if (NumFree >= a_Item.m_ItemCount ) + if (NumFree >= a_Item.m_ItemCount) { - // printf("1. Adding %i items ( free: %i )\n", a_Item.m_ItemCount, NumFree ); + // printf("1. Adding %i items ( free: %i)\n", a_Item.m_ItemCount, NumFree); m_Slots[i + a_Offset].m_ItemCount += a_Item.m_ItemCount; a_Item.m_ItemCount = 0; a_bChangedSlots[i + a_Offset] = true; @@ -519,7 +519,7 @@ bool cInventory::AddToBar( cItem & a_Item, const int a_Offset, const int a_Size, } else { - // printf("2. Adding %i items\n", NumFree ); + // printf("2. Adding %i items\n", NumFree); m_Slots[i + a_Offset].m_ItemCount += (char)NumFree; a_Item.m_ItemCount -= (char)NumFree; a_bChangedSlots[i + a_Offset] = true; @@ -528,12 +528,12 @@ bool cInventory::AddToBar( cItem & a_Item, const int a_Offset, const int a_Size, } } - if (a_Mode > 0 ) + if (a_Mode > 0) { // If we got more left, find first empty slot for (int i = 0; i < a_Size && a_Item.m_ItemCount > 0; i++) { - if (m_Slots[i + a_Offset].m_ItemType == -1 ) + if (m_Slots[i + a_Offset].m_ItemType == -1) { m_Slots[i + a_Offset] = a_Item; a_Item.m_ItemCount = 0; diff --git a/src/Inventory.h b/src/Inventory.h index 5175afd14..ed134aee4 100644 --- a/src/Inventory.h +++ b/src/Inventory.h @@ -169,7 +169,7 @@ public: bool LoadFromJson(Json::Value & a_Value); protected: - bool AddToBar( cItem & a_Item, const int a_Offset, const int a_Size, bool* a_bChangedSlots, int a_Mode = 0 ); + bool AddToBar( cItem & a_Item, const int a_Offset, const int a_Size, bool* a_bChangedSlots, int a_Mode = 0); cItemGrid m_ArmorSlots; cItemGrid m_InventorySlots; diff --git a/src/Item.cpp b/src/Item.cpp index 876abafd0..b44472e38 100644 --- a/src/Item.cpp +++ b/src/Item.cpp @@ -162,11 +162,11 @@ void cItem::GetJson(Json::Value & a_OutValue) const void cItem::FromJson(const Json::Value & a_Value) { - m_ItemType = (ENUM_ITEM_ID)a_Value.get("ID", -1 ).asInt(); + m_ItemType = (ENUM_ITEM_ID)a_Value.get("ID", -1).asInt(); if (m_ItemType > 0) { - m_ItemCount = (char)a_Value.get("Count", -1 ).asInt(); - m_ItemDamage = (short)a_Value.get("Health", -1 ).asInt(); + m_ItemCount = (char)a_Value.get("Count", -1).asInt(); + m_ItemDamage = (short)a_Value.get("Health", -1).asInt(); m_Enchantments.Clear(); m_Enchantments.AddFromString(a_Value.get("ench", "").asString()); m_CustomName = a_Value.get("Name", "").asString(); diff --git a/src/Items/ItemFood.h b/src/Items/ItemFood.h index 961cf482d..ff1d7991b 100644 --- a/src/Items/ItemFood.h +++ b/src/Items/ItemFood.h @@ -26,7 +26,7 @@ public: virtual FoodInfo GetFoodInfo(void) override { - switch(m_ItemType) + switch (m_ItemType) { // Please keep alpha-sorted. case E_ITEM_BAKED_POTATO: return FoodInfo(6, 7.2); diff --git a/src/Items/ItemHandler.cpp b/src/Items/ItemHandler.cpp index 0a8638f3a..bf1d4e4cb 100644 --- a/src/Items/ItemHandler.cpp +++ b/src/Items/ItemHandler.cpp @@ -94,7 +94,7 @@ cItemHandler * cItemHandler::GetItemHandler(int a_ItemType) cItemHandler *cItemHandler::CreateItemHandler(int a_ItemType) { - switch(a_ItemType) + switch (a_ItemType) { default: return new cItemHandler(a_ItemType); diff --git a/src/Items/ItemPickaxe.h b/src/Items/ItemPickaxe.h index 82bec52d4..647d59b5c 100644 --- a/src/Items/ItemPickaxe.h +++ b/src/Items/ItemPickaxe.h @@ -17,7 +17,7 @@ public: char PickaxeLevel() { - switch(m_ItemType) + switch (m_ItemType) { case E_ITEM_WOODEN_PICKAXE: return 1; case E_ITEM_GOLD_PICKAXE: return 1; @@ -31,7 +31,7 @@ public: virtual bool CanHarvestBlock(BLOCKTYPE a_BlockType) override { - switch(a_BlockType) + switch (a_BlockType) { case E_BLOCK_OBSIDIAN: { diff --git a/src/Log.cpp b/src/Log.cpp index a70b09103..7686a0fb4 100644 --- a/src/Log.cpp +++ b/src/Log.cpp @@ -17,7 +17,7 @@ cLog* cLog::s_Log = NULL; -cLog::cLog(const AString & a_FileName ) +cLog::cLog(const AString & a_FileName) : m_File(NULL) { s_Log = this; @@ -25,7 +25,7 @@ cLog::cLog(const AString & a_FileName ) // create logs directory cFile::CreateFolder(FILE_IO_PREFIX + AString("logs")); - OpenLog((FILE_IO_PREFIX + AString("logs/") + a_FileName).c_str() ); + OpenLog((FILE_IO_PREFIX + AString("logs/") + a_FileName).c_str()); } @@ -59,7 +59,7 @@ cLog * cLog::GetInstance() void cLog::CloseLog() { - if (m_File ) + if (m_File) fclose (m_File); m_File = 0; } @@ -68,13 +68,13 @@ void cLog::CloseLog() -void cLog::OpenLog( const char* a_FileName ) +void cLog::OpenLog( const char* a_FileName) { if (m_File) fclose (m_File); #ifdef _MSC_VER - fopen_s( &m_File, a_FileName, "a+" ); + fopen_s( &m_File, a_FileName, "a+"); #else - m_File = fopen(a_FileName, "a+" ); + m_File = fopen(a_FileName, "a+"); #endif } @@ -85,11 +85,11 @@ void cLog::OpenLog( const char* a_FileName ) void cLog::ClearLog() { #ifdef _MSC_VER - if (fopen_s( &m_File, "log.txt", "w" ) == 0) + if (fopen_s( &m_File, "log.txt", "w") == 0) fclose (m_File); #else - m_File = fopen("log.txt", "w" ); - if (m_File ) + m_File = fopen("log.txt", "w"); + if (m_File) fclose (m_File); #endif m_File = NULL; @@ -105,15 +105,15 @@ void cLog::Log(const char * a_Format, va_list argList) AppendVPrintf(Message, a_Format, argList); time_t rawtime; - time ( &rawtime ); + time ( &rawtime); struct tm* timeinfo; #ifdef _MSC_VER struct tm timeinforeal; timeinfo = &timeinforeal; - localtime_s(timeinfo, &rawtime ); + localtime_s(timeinfo, &rawtime); #else - timeinfo = localtime( &rawtime ); + timeinfo = localtime( &rawtime); #endif AString Line; @@ -131,8 +131,8 @@ void cLog::Log(const char * a_Format, va_list argList) // Print to console: #if defined(ANDROID_NDK) // __android_log_vprint(ANDROID_LOG_ERROR, "MCServer", a_Format, argList); - __android_log_print(ANDROID_LOG_ERROR, "MCServer", "%s", Line.c_str() ); - // CallJavaFunction_Void_String(g_JavaThread, "AddToLog", Line ); + __android_log_print(ANDROID_LOG_ERROR, "MCServer", "%s", Line.c_str()); + // CallJavaFunction_Void_String(g_JavaThread, "AddToLog", Line); #else printf("%s", Line.c_str()); #endif diff --git a/src/MCLogger.cpp b/src/MCLogger.cpp index 78eb19f3e..044e83937 100644 --- a/src/MCLogger.cpp +++ b/src/MCLogger.cpp @@ -234,7 +234,7 @@ void LOG(const char* a_Format, ...) { va_list argList; va_start(argList, a_Format); - cMCLogger::GetInstance()->Log( a_Format, argList ); + cMCLogger::GetInstance()->Log( a_Format, argList); va_end(argList); } @@ -242,7 +242,7 @@ void LOGINFO(const char* a_Format, ...) { va_list argList; va_start(argList, a_Format); - cMCLogger::GetInstance()->Info( a_Format, argList ); + cMCLogger::GetInstance()->Info( a_Format, argList); va_end(argList); } @@ -250,7 +250,7 @@ void LOGWARN(const char* a_Format, ...) { va_list argList; va_start(argList, a_Format); - cMCLogger::GetInstance()->Warn( a_Format, argList ); + cMCLogger::GetInstance()->Warn( a_Format, argList); va_end(argList); } @@ -258,7 +258,7 @@ void LOGERROR(const char* a_Format, ...) { va_list argList; va_start(argList, a_Format); - cMCLogger::GetInstance()->Error( a_Format, argList ); + cMCLogger::GetInstance()->Error( a_Format, argList); va_end(argList); } diff --git a/src/MobSpawner.cpp b/src/MobSpawner.cpp index 53c83f166..454fabce8 100644 --- a/src/MobSpawner.cpp +++ b/src/MobSpawner.cpp @@ -141,7 +141,7 @@ bool cMobSpawner::CanSpawnHere(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_R SkyLight = a_Chunk->GetTimeAlteredLight(SkyLight); - switch(a_MobType) + switch (a_MobType) { case cMonster::mtSquid: { diff --git a/src/Mobs/SnowGolem.cpp b/src/Mobs/SnowGolem.cpp index c1979a495..76334d970 100644 --- a/src/Mobs/SnowGolem.cpp +++ b/src/Mobs/SnowGolem.cpp @@ -30,7 +30,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(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/MonsterConfig.cpp b/src/MonsterConfig.cpp index f5e746ce8..f5e078213 100644 --- a/src/MonsterConfig.cpp +++ b/src/MonsterConfig.cpp @@ -35,7 +35,7 @@ struct cMonsterConfig::sMonsterConfigState cMonsterConfig::cMonsterConfig(void) - : m_pState( new sMonsterConfigState ) + : m_pState( new sMonsterConfigState) { Initialize(); } diff --git a/src/Noise.cpp b/src/Noise.cpp index a30661fe0..507d05ea5 100644 --- a/src/Noise.cpp +++ b/src/Noise.cpp @@ -528,10 +528,10 @@ NOISE_DATATYPE cNoise::CubicNoise3D(NOISE_DATATYPE a_X, NOISE_DATATYPE a_Y, NOIS }; const NOISE_DATATYPE FracX = (a_X) - BaseX; - const NOISE_DATATYPE x1interp1 = CubicInterpolate( points1[0][0], points1[0][1], points1[0][2], points1[0][3], FracX ); - const NOISE_DATATYPE x1interp2 = CubicInterpolate( points1[1][0], points1[1][1], points1[1][2], points1[1][3], FracX ); - const NOISE_DATATYPE x1interp3 = CubicInterpolate( points1[2][0], points1[2][1], points1[2][2], points1[2][3], FracX ); - const NOISE_DATATYPE x1interp4 = CubicInterpolate( points1[3][0], points1[3][1], points1[3][2], points1[3][3], FracX ); + const NOISE_DATATYPE x1interp1 = CubicInterpolate( points1[0][0], points1[0][1], points1[0][2], points1[0][3], FracX); + const NOISE_DATATYPE x1interp2 = CubicInterpolate( points1[1][0], points1[1][1], points1[1][2], points1[1][3], FracX); + const NOISE_DATATYPE x1interp3 = CubicInterpolate( points1[2][0], points1[2][1], points1[2][2], points1[2][3], FracX); + const NOISE_DATATYPE x1interp4 = CubicInterpolate( points1[3][0], points1[3][1], points1[3][2], points1[3][3], FracX); const NOISE_DATATYPE points2[4][4] = { @@ -541,45 +541,45 @@ NOISE_DATATYPE cNoise::CubicNoise3D(NOISE_DATATYPE a_X, NOISE_DATATYPE a_Y, NOIS { IntNoise3D(BaseX - 1, BaseY + 2, BaseZ), IntNoise3D(BaseX, BaseY + 2, BaseZ), IntNoise3D(BaseX + 1, BaseY + 2, BaseZ), IntNoise3D(BaseX + 2, BaseY + 2, BaseZ), }, }; - const NOISE_DATATYPE x2interp1 = CubicInterpolate( points2[0][0], points2[0][1], points2[0][2], points2[0][3], FracX ); - const NOISE_DATATYPE x2interp2 = CubicInterpolate( points2[1][0], points2[1][1], points2[1][2], points2[1][3], FracX ); - const NOISE_DATATYPE x2interp3 = CubicInterpolate( points2[2][0], points2[2][1], points2[2][2], points2[2][3], FracX ); - const NOISE_DATATYPE x2interp4 = CubicInterpolate( points2[3][0], points2[3][1], points2[3][2], points2[3][3], FracX ); + const NOISE_DATATYPE x2interp1 = CubicInterpolate( points2[0][0], points2[0][1], points2[0][2], points2[0][3], FracX); + const NOISE_DATATYPE x2interp2 = CubicInterpolate( points2[1][0], points2[1][1], points2[1][2], points2[1][3], FracX); + const NOISE_DATATYPE x2interp3 = CubicInterpolate( points2[2][0], points2[2][1], points2[2][2], points2[2][3], FracX); + const NOISE_DATATYPE x2interp4 = CubicInterpolate( points2[3][0], points2[3][1], points2[3][2], points2[3][3], FracX); const NOISE_DATATYPE points3[4][4] = { - { IntNoise3D( BaseX-1, BaseY-1, BaseZ+1 ), IntNoise3D( BaseX, BaseY-1, BaseZ+1 ), IntNoise3D( BaseX+1, BaseY-1, BaseZ+1 ), IntNoise3D( BaseX+2, BaseY-1, BaseZ + 1), }, - { IntNoise3D( BaseX-1, BaseY, BaseZ+1 ), IntNoise3D( BaseX, BaseY, BaseZ+1 ), IntNoise3D( BaseX+1, BaseY, BaseZ+1 ), IntNoise3D( BaseX+2, BaseY, BaseZ + 1), }, - { IntNoise3D( BaseX-1, BaseY+1, BaseZ+1 ), IntNoise3D( BaseX, BaseY+1, BaseZ+1 ), IntNoise3D( BaseX+1, BaseY+1, BaseZ+1 ), IntNoise3D( BaseX+2, BaseY+1, BaseZ + 1), }, - { IntNoise3D( BaseX-1, BaseY+2, BaseZ+1 ), IntNoise3D( BaseX, BaseY+2, BaseZ+1 ), IntNoise3D( BaseX+1, BaseY+2, BaseZ+1 ), IntNoise3D( BaseX+2, BaseY+2, BaseZ + 1), }, + { IntNoise3D( BaseX-1, BaseY-1, BaseZ+1), IntNoise3D( BaseX, BaseY-1, BaseZ+1), IntNoise3D( BaseX+1, BaseY-1, BaseZ+1), IntNoise3D( BaseX+2, BaseY-1, BaseZ + 1), }, + { IntNoise3D( BaseX-1, BaseY, BaseZ+1), IntNoise3D( BaseX, BaseY, BaseZ+1), IntNoise3D( BaseX+1, BaseY, BaseZ+1), IntNoise3D( BaseX+2, BaseY, BaseZ + 1), }, + { IntNoise3D( BaseX-1, BaseY+1, BaseZ+1), IntNoise3D( BaseX, BaseY+1, BaseZ+1), IntNoise3D( BaseX+1, BaseY+1, BaseZ+1), IntNoise3D( BaseX+2, BaseY+1, BaseZ + 1), }, + { IntNoise3D( BaseX-1, BaseY+2, BaseZ+1), IntNoise3D( BaseX, BaseY+2, BaseZ+1), IntNoise3D( BaseX+1, BaseY+2, BaseZ+1), IntNoise3D( BaseX+2, BaseY+2, BaseZ + 1), }, }; - const NOISE_DATATYPE x3interp1 = CubicInterpolate( points3[0][0], points3[0][1], points3[0][2], points3[0][3], FracX ); - const NOISE_DATATYPE x3interp2 = CubicInterpolate( points3[1][0], points3[1][1], points3[1][2], points3[1][3], FracX ); - const NOISE_DATATYPE x3interp3 = CubicInterpolate( points3[2][0], points3[2][1], points3[2][2], points3[2][3], FracX ); - const NOISE_DATATYPE x3interp4 = CubicInterpolate( points3[3][0], points3[3][1], points3[3][2], points3[3][3], FracX ); + const NOISE_DATATYPE x3interp1 = CubicInterpolate( points3[0][0], points3[0][1], points3[0][2], points3[0][3], FracX); + const NOISE_DATATYPE x3interp2 = CubicInterpolate( points3[1][0], points3[1][1], points3[1][2], points3[1][3], FracX); + const NOISE_DATATYPE x3interp3 = CubicInterpolate( points3[2][0], points3[2][1], points3[2][2], points3[2][3], FracX); + const NOISE_DATATYPE x3interp4 = CubicInterpolate( points3[3][0], points3[3][1], points3[3][2], points3[3][3], FracX); const NOISE_DATATYPE points4[4][4] = { - { IntNoise3D( BaseX-1, BaseY-1, BaseZ+2 ), IntNoise3D( BaseX, BaseY-1, BaseZ+2 ), IntNoise3D( BaseX+1, BaseY-1, BaseZ+2 ), IntNoise3D( BaseX+2, BaseY-1, BaseZ+2 ), }, - { IntNoise3D( BaseX-1, BaseY, BaseZ+2 ), IntNoise3D( BaseX, BaseY, BaseZ+2 ), IntNoise3D( BaseX+1, BaseY, BaseZ+2 ), IntNoise3D( BaseX+2, BaseY, BaseZ+2 ), }, - { IntNoise3D( BaseX-1, BaseY+1, BaseZ+2 ), IntNoise3D( BaseX, BaseY+1, BaseZ+2 ), IntNoise3D( BaseX+1, BaseY+1, BaseZ+2 ), IntNoise3D( BaseX+2, BaseY+1, BaseZ+2 ), }, - { IntNoise3D( BaseX-1, BaseY+2, BaseZ+2 ), IntNoise3D( BaseX, BaseY+2, BaseZ+2 ), IntNoise3D( BaseX+1, BaseY+2, BaseZ+2 ), IntNoise3D( BaseX+2, BaseY+2, BaseZ+2 ), }, + { IntNoise3D( BaseX-1, BaseY-1, BaseZ+2), IntNoise3D( BaseX, BaseY-1, BaseZ+2), IntNoise3D( BaseX+1, BaseY-1, BaseZ+2), IntNoise3D( BaseX+2, BaseY-1, BaseZ+2), }, + { IntNoise3D( BaseX-1, BaseY, BaseZ+2), IntNoise3D( BaseX, BaseY, BaseZ+2), IntNoise3D( BaseX+1, BaseY, BaseZ+2), IntNoise3D( BaseX+2, BaseY, BaseZ+2), }, + { IntNoise3D( BaseX-1, BaseY+1, BaseZ+2), IntNoise3D( BaseX, BaseY+1, BaseZ+2), IntNoise3D( BaseX+1, BaseY+1, BaseZ+2), IntNoise3D( BaseX+2, BaseY+1, BaseZ+2), }, + { IntNoise3D( BaseX-1, BaseY+2, BaseZ+2), IntNoise3D( BaseX, BaseY+2, BaseZ+2), IntNoise3D( BaseX+1, BaseY+2, BaseZ+2), IntNoise3D( BaseX+2, BaseY+2, BaseZ+2), }, }; - const NOISE_DATATYPE x4interp1 = CubicInterpolate( points4[0][0], points4[0][1], points4[0][2], points4[0][3], FracX ); - const NOISE_DATATYPE x4interp2 = CubicInterpolate( points4[1][0], points4[1][1], points4[1][2], points4[1][3], FracX ); - const NOISE_DATATYPE x4interp3 = CubicInterpolate( points4[2][0], points4[2][1], points4[2][2], points4[2][3], FracX ); - const NOISE_DATATYPE x4interp4 = CubicInterpolate( points4[3][0], points4[3][1], points4[3][2], points4[3][3], FracX ); + const NOISE_DATATYPE x4interp1 = CubicInterpolate( points4[0][0], points4[0][1], points4[0][2], points4[0][3], FracX); + const NOISE_DATATYPE x4interp2 = CubicInterpolate( points4[1][0], points4[1][1], points4[1][2], points4[1][3], FracX); + const NOISE_DATATYPE x4interp3 = CubicInterpolate( points4[2][0], points4[2][1], points4[2][2], points4[2][3], FracX); + const NOISE_DATATYPE x4interp4 = CubicInterpolate( points4[3][0], points4[3][1], points4[3][2], points4[3][3], FracX); const NOISE_DATATYPE FracY = (a_Y) - BaseY; - const NOISE_DATATYPE yinterp1 = CubicInterpolate( x1interp1, x1interp2, x1interp3, x1interp4, FracY ); - const NOISE_DATATYPE yinterp2 = CubicInterpolate( x2interp1, x2interp2, x2interp3, x2interp4, FracY ); - const NOISE_DATATYPE yinterp3 = CubicInterpolate( x3interp1, x3interp2, x3interp3, x3interp4, FracY ); - const NOISE_DATATYPE yinterp4 = CubicInterpolate( x4interp1, x4interp2, x4interp3, x4interp4, FracY ); + const NOISE_DATATYPE yinterp1 = CubicInterpolate( x1interp1, x1interp2, x1interp3, x1interp4, FracY); + const NOISE_DATATYPE yinterp2 = CubicInterpolate( x2interp1, x2interp2, x2interp3, x2interp4, FracY); + const NOISE_DATATYPE yinterp3 = CubicInterpolate( x3interp1, x3interp2, x3interp3, x3interp4, FracY); + const NOISE_DATATYPE yinterp4 = CubicInterpolate( x4interp1, x4interp2, x4interp3, x4interp4, FracY); const NOISE_DATATYPE FracZ = (a_Z) - BaseZ; - return CubicInterpolate( yinterp1, yinterp2, yinterp3, yinterp4, FracZ ); + return CubicInterpolate( yinterp1, yinterp2, yinterp3, yinterp4, FracZ); } diff --git a/src/OSSupport/Errors.cpp b/src/OSSupport/Errors.cpp index 02de28e4e..9401ec257 100644 --- a/src/OSSupport/Errors.cpp +++ b/src/OSSupport/Errors.cpp @@ -3,7 +3,7 @@ #include "Errors.h" -AString GetOSErrorString( int a_ErrNo ) +AString GetOSErrorString( int a_ErrNo) { char buffer[ 1024 ]; AString Out; @@ -22,10 +22,10 @@ AString GetOSErrorString( int a_ErrNo ) // According to http://linux.die.net/man/3/strerror_r there are two versions of strerror_r(): - #if !defined(__APPLE__) && ( _GNU_SOURCE ) && !defined(ANDROID_NDK) // GNU version of strerror_r() + #if !defined(__APPLE__) && ( _GNU_SOURCE) && !defined(ANDROID_NDK) // GNU version of strerror_r() - char * res = strerror_r( errno, buffer, ARRAYCOUNT(buffer) ); - if (res != NULL ) + char * res = strerror_r( errno, buffer, ARRAYCOUNT(buffer)); + if (res != NULL) { Printf(Out, "%d: %s", a_ErrNo, res); return Out; @@ -33,8 +33,8 @@ AString GetOSErrorString( int a_ErrNo ) #else // XSI version of strerror_r(): - int res = strerror_r( errno, buffer, ARRAYCOUNT(buffer) ); - if (res == 0 ) + int res = strerror_r( errno, buffer, ARRAYCOUNT(buffer)); + if (res == 0) { Printf(Out, "%d: %s", a_ErrNo, buffer); return Out; diff --git a/src/OSSupport/Event.cpp b/src/OSSupport/Event.cpp index 72bce4c3c..74f823216 100644 --- a/src/OSSupport/Event.cpp +++ b/src/OSSupport/Event.cpp @@ -32,7 +32,7 @@ cEvent::cEvent(void) AString EventName; Printf(EventName, "cEvent%p", this); - m_Event = sem_open(EventName.c_str(), O_CREAT, 777, 0 ); + m_Event = sem_open(EventName.c_str(), O_CREAT, 777, 0); if (m_Event == SEM_FAILED) { AString error = GetOSErrorString(errno); @@ -90,7 +90,7 @@ void cEvent::Wait(void) } #else int res = sem_wait(m_Event); - if (res != 0 ) + if (res != 0) { AString error = GetOSErrorString(errno); LOGWARN("cEvent: waiting for the event failed: %i, err = %s. Continuing, but server may be unstable.", res, error.c_str()); diff --git a/src/OSSupport/Semaphore.cpp b/src/OSSupport/Semaphore.cpp index cb9ccc83b..c1fc7d9c7 100644 --- a/src/OSSupport/Semaphore.cpp +++ b/src/OSSupport/Semaphore.cpp @@ -5,9 +5,9 @@ -cSemaphore::cSemaphore( unsigned int a_MaxCount, unsigned int a_InitialCount /* = 0 */ ) +cSemaphore::cSemaphore( unsigned int a_MaxCount, unsigned int a_InitialCount /* = 0 */) #ifndef _WIN32 - : m_bNamed( false ) + : m_bNamed( false) #endif { #ifndef _WIN32 @@ -20,15 +20,15 @@ cSemaphore::cSemaphore( unsigned int a_MaxCount, unsigned int a_InitialCount /* m_bNamed = true; AString Name; - Printf(Name, "cSemaphore%p", this ); + Printf(Name, "cSemaphore%p", this); m_Handle = sem_open(Name.c_str(), O_CREAT, 777, a_InitialCount); - if (m_Handle == SEM_FAILED ) + if (m_Handle == SEM_FAILED) { - LOG("ERROR: Could not create Semaphore. (%i)", errno ); + LOG("ERROR: Could not create Semaphore. (%i)", errno); } else { - if (sem_unlink(Name.c_str()) != 0 ) + if (sem_unlink(Name.c_str()) != 0) { LOG("ERROR: Could not unlink cSemaphore. (%i)", errno); } @@ -51,18 +51,18 @@ cSemaphore::cSemaphore( unsigned int a_MaxCount, unsigned int a_InitialCount /* cSemaphore::~cSemaphore() { #ifdef _WIN32 - CloseHandle( m_Handle ); + CloseHandle( m_Handle); #else - if (m_bNamed ) + if (m_bNamed) { - if (sem_close( (sem_t*)m_Handle ) != 0 ) + if (sem_close( (sem_t*)m_Handle) != 0) { LOG("ERROR: Could not close cSemaphore. (%i)", errno); } } else { - sem_destroy( (sem_t*)m_Handle ); + sem_destroy( (sem_t*)m_Handle); delete (sem_t*)m_Handle; } m_Handle = 0; @@ -77,7 +77,7 @@ cSemaphore::~cSemaphore() void cSemaphore::Wait() { #ifndef _WIN32 - if (sem_wait( (sem_t*)m_Handle ) != 0) + if (sem_wait( (sem_t*)m_Handle) != 0) { LOG("ERROR: Could not wait for cSemaphore. (%i)", errno); } @@ -93,12 +93,12 @@ void cSemaphore::Wait() void cSemaphore::Signal() { #ifndef _WIN32 - if (sem_post( (sem_t*)m_Handle ) != 0 ) + if (sem_post( (sem_t*)m_Handle) != 0) { LOG("ERROR: Could not signal cSemaphore. (%i)", errno); } #else - ReleaseSemaphore( m_Handle, 1, NULL ); + ReleaseSemaphore( m_Handle, 1, NULL); #endif } diff --git a/src/OSSupport/Semaphore.h b/src/OSSupport/Semaphore.h index ac574e8a1..adc531ed8 100644 --- a/src/OSSupport/Semaphore.h +++ b/src/OSSupport/Semaphore.h @@ -3,7 +3,7 @@ class cSemaphore { public: - cSemaphore( unsigned int a_MaxCount, unsigned int a_InitialCount = 0 ); + cSemaphore( unsigned int a_MaxCount, unsigned int a_InitialCount = 0); ~cSemaphore(); void Wait(); diff --git a/src/OSSupport/Sleep.cpp b/src/OSSupport/Sleep.cpp index 223a8b855..297d668d7 100644 --- a/src/OSSupport/Sleep.cpp +++ b/src/OSSupport/Sleep.cpp @@ -9,7 +9,7 @@ -void cSleep::MilliSleep( unsigned int a_MilliSeconds ) +void cSleep::MilliSleep( unsigned int a_MilliSeconds) { #ifdef _WIN32 Sleep(a_MilliSeconds); // Don't tick too much diff --git a/src/OSSupport/Sleep.h b/src/OSSupport/Sleep.h index 0ec0adf9d..57d29682c 100644 --- a/src/OSSupport/Sleep.h +++ b/src/OSSupport/Sleep.h @@ -3,5 +3,5 @@ class cSleep { public: - static void MilliSleep( unsigned int a_MilliSeconds ); + static void MilliSleep( unsigned int a_MilliSeconds); }; diff --git a/src/OSSupport/Thread.cpp b/src/OSSupport/Thread.cpp index 811e7cb21..faaccce96 100644 --- a/src/OSSupport/Thread.cpp +++ b/src/OSSupport/Thread.cpp @@ -47,13 +47,13 @@ static void SetThreadName(DWORD dwThreadID, const char * threadName) -cThread::cThread( ThreadFunc a_ThreadFunction, void* a_Param, const char* a_ThreadName /* = 0 */ ) - : m_ThreadFunction( a_ThreadFunction ) - , m_Param( a_Param ) - , m_Event( new cEvent() ) - , m_StopEvent( 0 ) +cThread::cThread( ThreadFunc a_ThreadFunction, void* a_Param, const char* a_ThreadName /* = 0 */) + : m_ThreadFunction( a_ThreadFunction) + , m_Param( a_Param) + , m_Event( new cEvent()) + , m_StopEvent( 0) { - if (a_ThreadName ) + if (a_ThreadName) { m_ThreadName.assign(a_ThreadName); } @@ -68,7 +68,7 @@ cThread::~cThread() delete m_Event; m_Event = NULL; - if (m_StopEvent ) + if (m_StopEvent) { m_StopEvent->Wait(); delete m_StopEvent; @@ -80,14 +80,14 @@ cThread::~cThread() -void cThread::Start( bool a_bWaitOnDelete /* = true */ ) +void cThread::Start( bool a_bWaitOnDelete /* = true */) { - if (a_bWaitOnDelete ) + if (a_bWaitOnDelete) m_StopEvent = new cEvent(); #ifndef _WIN32 pthread_t SndThread; - if (pthread_create( &SndThread, NULL, MyThread, this) ) + if (pthread_create( &SndThread, NULL, MyThread, this)) LOGERROR("ERROR: Could not create thread!"); #else DWORD ThreadID = 0; @@ -96,8 +96,8 @@ void cThread::Start( bool a_bWaitOnDelete /* = true */ ) , (LPTHREAD_START_ROUTINE) MyThread // function name , this // parameters , 0 // flags - , &ThreadID ); // thread id - CloseHandle( hThread ); + , &ThreadID); // thread id + CloseHandle( hThread); #ifdef _MSC_VER if (!m_ThreadName.empty()) @@ -116,9 +116,9 @@ void cThread::Start( bool a_bWaitOnDelete /* = true */ ) #ifdef _WIN32 -unsigned long cThread::MyThread(void* a_Param ) +unsigned long cThread::MyThread(void* a_Param) #else -void *cThread::MyThread( void *a_Param ) +void *cThread::MyThread( void *a_Param) #endif { cThread* self = (cThread*)a_Param; @@ -130,8 +130,8 @@ void *cThread::MyThread( void *a_Param ) // Set event to let other thread know this thread has been created and it's safe to delete the cThread object self->m_Event->Set(); - ThreadFunction( ThreadParam ); + ThreadFunction( ThreadParam); - if (StopEvent ) StopEvent->Set(); + if (StopEvent) StopEvent->Set(); return 0; } diff --git a/src/OSSupport/Thread.h b/src/OSSupport/Thread.h index 4153b2427..7ee352c82 100644 --- a/src/OSSupport/Thread.h +++ b/src/OSSupport/Thread.h @@ -4,18 +4,18 @@ class cThread { public: typedef void (ThreadFunc)(void*); - cThread( ThreadFunc a_ThreadFunction, void* a_Param, const char* a_ThreadName = 0 ); + cThread( ThreadFunc a_ThreadFunction, void* a_Param, const char* a_ThreadName = 0); ~cThread(); - void Start( bool a_bWaitOnDelete = true ); + void Start( bool a_bWaitOnDelete = true); void WaitForThread(); private: ThreadFunc* m_ThreadFunction; #ifdef _WIN32 - static unsigned long MyThread(void* a_Param ); + static unsigned long MyThread(void* a_Param); #else - static void *MyThread( void *lpParam ); + static void *MyThread( void *lpParam); #endif void* m_Param; diff --git a/src/Protocol/Protocol.h b/src/Protocol/Protocol.h index 00eeadd10..c5ba7a679 100644 --- a/src/Protocol/Protocol.h +++ b/src/Protocol/Protocol.h @@ -120,7 +120,7 @@ public: virtual void SendUnloadChunk (int a_ChunkX, int a_ChunkZ) = 0; virtual void SendUpdateBlockEntity (cBlockEntity & a_BlockEntity) = 0; virtual void SendUpdateSign (int a_BlockX, int a_BlockY, int a_BlockZ, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4) = 0; - virtual void SendUseBed (const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ ) = 0; + virtual void SendUseBed (const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ) = 0; virtual void SendWeather (eWeather a_Weather) = 0; virtual void SendWholeInventory (const cWindow & a_Window) = 0; virtual void SendWindowClose (const cWindow & a_Window) = 0; diff --git a/src/Protocol/Protocol125.cpp b/src/Protocol/Protocol125.cpp index 1ac035e26..cad47e6c2 100644 --- a/src/Protocol/Protocol125.cpp +++ b/src/Protocol/Protocol125.cpp @@ -1116,7 +1116,7 @@ void cProtocol125::SendUpdateSign( -void cProtocol125::SendUseBed(const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ ) +void cProtocol125::SendUseBed(const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ) { cCSLock Lock(m_CSPacket); WriteByte(PACKET_USE_BED); @@ -1135,7 +1135,7 @@ void cProtocol125::SendUseBed(const cEntity & a_Entity, int a_BlockX, int a_Bloc void cProtocol125::SendWeather(eWeather a_Weather) { cCSLock Lock(m_CSPacket); - switch( a_Weather ) + switch (a_Weather) { case eWeather_Sunny: { @@ -1454,7 +1454,7 @@ int cProtocol125::ParseHandshake(void) LOGD("HANDSHAKE %s", Username.c_str()); - if (!m_Client->HandleHandshake( m_Username )) + if (!m_Client->HandleHandshake( m_Username)) { return PARSE_OK; // Player is not allowed into the server } @@ -1916,7 +1916,7 @@ void cProtocol125::WriteEntityMetadata(const cEntity & a_Entity) { WriteByte(0x51); // No idea how Mojang makes their carts shakey shakey, so here is a complicated one-liner expression that does something similar - WriteInt( (((a_Entity.GetMaxHealth() / 2) - (a_Entity.GetHealth() - (a_Entity.GetMaxHealth() / 2))) * ((const cMinecart &)a_Entity).LastDamage()) * 4 ); + WriteInt( (((a_Entity.GetMaxHealth() / 2) - (a_Entity.GetHealth() - (a_Entity.GetMaxHealth() / 2))) * ((const cMinecart &)a_Entity).LastDamage()) * 4); WriteByte(0x52); WriteInt(1); // Shaking direction, doesn't seem to affect anything WriteByte(0x73); diff --git a/src/Protocol/Protocol125.h b/src/Protocol/Protocol125.h index 588dd3473..d7ebf535b 100644 --- a/src/Protocol/Protocol125.h +++ b/src/Protocol/Protocol125.h @@ -92,7 +92,7 @@ public: virtual void SendUnloadChunk (int a_ChunkX, int a_ChunkZ) override; virtual void SendUpdateBlockEntity (cBlockEntity & a_BlockEntity) override {}; virtual void SendUpdateSign (int a_BlockX, int a_BlockY, int a_BlockZ, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4) override; - virtual void SendUseBed (const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ ) override; + virtual void SendUseBed (const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ) override; virtual void SendWeather (eWeather a_Weather) override; virtual void SendWholeInventory (const cWindow & a_Window) override; virtual void SendWindowClose (const cWindow & a_Window) override; @@ -124,7 +124,7 @@ protected: /// Sends the Handshake packet void SendHandshake(const AString & a_ConnectionHash); - /// Parse the packet of the specified type from m_ReceivedData (switch into ParseXYZ() ) + /// Parse the packet of the specified type from m_ReceivedData (switch into ParseXYZ()) virtual int ParsePacket(unsigned char a_PacketType); // Specific packet parsers: diff --git a/src/Protocol/Protocol132.cpp b/src/Protocol/Protocol132.cpp index 8502702e8..5c58ab0ba 100644 --- a/src/Protocol/Protocol132.cpp +++ b/src/Protocol/Protocol132.cpp @@ -474,7 +474,7 @@ int cProtocol132::ParseHandshake(void) HANDLE_PACKET_READ(ReadBEInt, int, ServerPort); m_Username = Username; - if (!m_Client->HandleHandshake( m_Username )) + if (!m_Client->HandleHandshake( m_Username)) { return PARSE_OK; // Player is not allowed into the server } diff --git a/src/Protocol/Protocol17x.h b/src/Protocol/Protocol17x.h index e635a62c1..1a91d5203 100644 --- a/src/Protocol/Protocol17x.h +++ b/src/Protocol/Protocol17x.h @@ -124,7 +124,7 @@ public: virtual void SendUnloadChunk (int a_ChunkX, int a_ChunkZ) override; virtual void SendUpdateBlockEntity (cBlockEntity & a_BlockEntity) override; virtual void SendUpdateSign (int a_BlockX, int a_BlockY, int a_BlockZ, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4) override; - virtual void SendUseBed (const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ ) override; + virtual void SendUseBed (const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ) override; virtual void SendWeather (eWeather a_Weather) override; virtual void SendWholeInventory (const cWindow & a_Window) override; virtual void SendWindowClose (const cWindow & a_Window) override; diff --git a/src/Protocol/ProtocolRecognizer.cpp b/src/Protocol/ProtocolRecognizer.cpp index 205407a5b..bf46a15ef 100644 --- a/src/Protocol/ProtocolRecognizer.cpp +++ b/src/Protocol/ProtocolRecognizer.cpp @@ -756,7 +756,7 @@ void cProtocolRecognizer::SendUpdateSign(int a_BlockX, int a_BlockY, int a_Block -void cProtocolRecognizer::SendUseBed(const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ ) +void cProtocolRecognizer::SendUseBed(const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ) { ASSERT(m_Protocol != NULL); m_Protocol->SendUseBed(a_Entity, a_BlockX, a_BlockY, a_BlockZ); diff --git a/src/Protocol/ProtocolRecognizer.h b/src/Protocol/ProtocolRecognizer.h index 6bfd73d74..02143f17f 100644 --- a/src/Protocol/ProtocolRecognizer.h +++ b/src/Protocol/ProtocolRecognizer.h @@ -127,7 +127,7 @@ public: virtual void SendUnloadChunk (int a_ChunkX, int a_ChunkZ) override; virtual void SendUpdateBlockEntity (cBlockEntity & a_BlockEntity) override; virtual void SendUpdateSign (int a_BlockX, int a_BlockY, int a_BlockZ, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4) override; - virtual void SendUseBed (const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ ) override; + virtual void SendUseBed (const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ) override; virtual void SendWeather (eWeather a_Weather) override; virtual void SendWholeInventory (const cWindow & a_Window) override; virtual void SendWindowClose (const cWindow & a_Window) override; diff --git a/src/Root.cpp b/src/Root.cpp index e195b59ff..b03a13382 100644 --- a/src/Root.cpp +++ b/src/Root.cpp @@ -191,8 +191,8 @@ void cRoot::Start(void) #if !defined(ANDROID_NDK) LOGD("Starting InputThread..."); - m_InputThread = new cThread( InputThread, this, "cRoot::InputThread" ); - m_InputThread->Start( false ); // We should NOT wait? Otherwise we can't stop the server from other threads than the input thread + m_InputThread = new cThread( InputThread, this, "cRoot::InputThread"); + m_InputThread->Start( false); // We should NOT wait? Otherwise we can't stop the server from other threads than the input thread #endif long long finishmseconds = Time.GetNowTime(); @@ -269,12 +269,12 @@ void cRoot::LoadWorlds(cIniFile & IniFile) { // First get the default world AString DefaultWorldName = IniFile.GetValueSet("Worlds", "DefaultWorld", "world"); - m_pDefaultWorld = new cWorld( DefaultWorldName.c_str() ); + m_pDefaultWorld = new cWorld( DefaultWorldName.c_str()); m_WorldsByName[ DefaultWorldName ] = m_pDefaultWorld; // Then load the other worlds unsigned int KeyNum = IniFile.FindKey("Worlds"); - unsigned int NumWorlds = IniFile.GetNumValues( KeyNum ); + unsigned int NumWorlds = IniFile.GetNumValues( KeyNum); if (NumWorlds <= 0) { return; @@ -283,18 +283,18 @@ void cRoot::LoadWorlds(cIniFile & IniFile) bool FoundAdditionalWorlds = false; for (unsigned int i = 0; i < NumWorlds; i++) { - AString ValueName = IniFile.GetValueName(KeyNum, i ); + AString ValueName = IniFile.GetValueName(KeyNum, i); if (ValueName.compare("World") != 0) { continue; } - AString WorldName = IniFile.GetValue(KeyNum, i ); + AString WorldName = IniFile.GetValue(KeyNum, i); if (WorldName.empty()) { continue; } FoundAdditionalWorlds = true; - cWorld* NewWorld = new cWorld( WorldName.c_str() ); + cWorld* NewWorld = new cWorld( WorldName.c_str()); m_WorldsByName[ WorldName ] = NewWorld; } // for i - Worlds @@ -359,7 +359,7 @@ void cRoot::StopWorlds(void) void cRoot::UnloadWorlds(void) { m_pDefaultWorld = NULL; - for (WorldMap::iterator itr = m_WorldsByName.begin(); itr != m_WorldsByName.end(); ++itr ) + for (WorldMap::iterator itr = m_WorldsByName.begin(); itr != m_WorldsByName.end(); ++itr) { delete itr->second; } @@ -379,10 +379,10 @@ cWorld* cRoot::GetDefaultWorld() -cWorld* cRoot::GetWorld( const AString & a_WorldName ) +cWorld* cRoot::GetWorld( const AString & a_WorldName) { - WorldMap::iterator itr = m_WorldsByName.find( a_WorldName ); - if (itr != m_WorldsByName.end() ) + WorldMap::iterator itr = m_WorldsByName.find( a_WorldName); + if (itr != m_WorldsByName.end()) return itr->second; return 0; } @@ -509,7 +509,7 @@ void cRoot::AuthenticateUser(int a_ClientID, const AString & a_Name, const AStri int cRoot::GetTotalChunkCount(void) { int res = 0; - for (WorldMap::iterator itr = m_WorldsByName.begin(); itr != m_WorldsByName.end(); ++itr ) + for (WorldMap::iterator itr = m_WorldsByName.begin(); itr != m_WorldsByName.end(); ++itr) { res += itr->second->GetNumChunks(); } diff --git a/src/Server.cpp b/src/Server.cpp index 0990fc398..42ad133f1 100644 --- a/src/Server.cpp +++ b/src/Server.cpp @@ -398,7 +398,7 @@ void cServer::TickClients(float a_Dt) { if ((*itr)->IsDestroyed()) { - // Remove the client later, when CS is not held, to avoid deadlock ( http://forum.mc-server.org/showthread.php?tid=374 ) + // Remove the client later, when CS is not held, to avoid deadlock: http://forum.mc-server.org/showthread.php?tid=374 RemoveClients.push_back(*itr); itr = m_Clients.erase(itr); continue; @@ -631,7 +631,7 @@ void cServer::Shutdown(void) cRoot::Get()->SaveAllChunks(); cCSLock Lock(m_CSClients); - for (ClientList::iterator itr = m_Clients.begin(); itr != m_Clients.end(); ++itr ) + for (ClientList::iterator itr = m_Clients.begin(); itr != m_Clients.end(); ++itr) { (*itr)->Destroy(); delete *itr; diff --git a/src/Simulator/NoopRedstoneSimulator.h b/src/Simulator/NoopRedstoneSimulator.h index 4301b8aae..f9ed47982 100644 --- a/src/Simulator/NoopRedstoneSimulator.h +++ b/src/Simulator/NoopRedstoneSimulator.h @@ -28,7 +28,7 @@ public: UNUSED(a_ChunkZ); UNUSED(a_Chunk); } - virtual bool IsAllowedBlock( BLOCKTYPE a_BlockType ) override { return false; } + virtual bool IsAllowedBlock( BLOCKTYPE a_BlockType) override { return false; } virtual void AddBlock(int a_BlockX, int a_BlockY, int a_BlockZ, cChunk * a_Chunk) override { UNUSED(a_BlockX); diff --git a/src/Simulator/SimulatorManager.cpp b/src/Simulator/SimulatorManager.cpp index 2bc483cbd..918bac7a1 100644 --- a/src/Simulator/SimulatorManager.cpp +++ b/src/Simulator/SimulatorManager.cpp @@ -29,7 +29,7 @@ cSimulatorManager::~cSimulatorManager() void cSimulatorManager::Simulate(float a_Dt) { m_Ticks++; - for (cSimulators::iterator itr = m_Simulators.begin(); itr != m_Simulators.end(); ++itr ) + for (cSimulators::iterator itr = m_Simulators.begin(); itr != m_Simulators.end(); ++itr) { if ((m_Ticks % itr->second) == 0) { @@ -45,7 +45,7 @@ void cSimulatorManager::Simulate(float a_Dt) void cSimulatorManager::SimulateChunk(float a_Dt, int a_ChunkX, int a_ChunkZ, cChunk * a_Chunk) { // m_Ticks has already been increased in Simulate() - for (cSimulators::iterator itr = m_Simulators.begin(); itr != m_Simulators.end(); ++itr ) + for (cSimulators::iterator itr = m_Simulators.begin(); itr != m_Simulators.end(); ++itr) { if ((m_Ticks % itr->second) == 0) { @@ -60,7 +60,7 @@ void cSimulatorManager::SimulateChunk(float a_Dt, int a_ChunkX, int a_ChunkZ, cC void cSimulatorManager::WakeUp(int a_BlockX, int a_BlockY, int a_BlockZ, cChunk * a_Chunk) { - for (cSimulators::iterator itr = m_Simulators.begin(); itr != m_Simulators.end(); ++itr ) + for (cSimulators::iterator itr = m_Simulators.begin(); itr != m_Simulators.end(); ++itr) { itr->first->WakeUp(a_BlockX, a_BlockY, a_BlockZ, a_Chunk); } diff --git a/src/Tracer.cpp b/src/Tracer.cpp index df01e9129..756147a7b 100644 --- a/src/Tracer.cpp +++ b/src/Tracer.cpp @@ -37,7 +37,7 @@ cTracer::~cTracer() -float cTracer::SigNum( float a_Num ) +float cTracer::SigNum( float a_Num) { if (a_Num < 0.f) return -1.f; if (a_Num > 0.f) return 1.f; @@ -59,7 +59,7 @@ void cTracer::SetValues(const Vector3f & a_Start, const Vector3f & a_Direction) step.z = (int) SigNum(dir.z); // normalize the direction vector - if (dir.SqrLength() > 0.f ) dir.Normalize(); + if (dir.SqrLength() > 0.f) dir.Normalize(); // how far we must move in the ray direction before // we encounter a new voxel in x-direction @@ -229,7 +229,7 @@ bool cTracer::Trace( const Vector3f & a_Start, const Vector3f & a_Direction, int if ((!a_LineOfSight && cBlockInfo::IsSolid(BlockID)) || (a_LineOfSight && (BlockID != E_BLOCK_AIR) && !IsBlockWater(BlockID))) { BlockHitPosition = pos; - int Normal = GetHitNormal(a_Start, End, pos ); + int Normal = GetHitNormal(a_Start, End, pos); if (Normal > 0) { HitNormal = m_NormalTable[Normal-1]; @@ -271,13 +271,13 @@ int LinesCross(float x0, float y0, float x1, float y1, float x2, float y2, float // Return: 0 = disjoint (no intersection) // 1 = intersection in the unique point *I0 // 2 = the segment lies in the plane -int cTracer::intersect3D_SegmentPlane( const Vector3f & a_Origin, const Vector3f & a_End, const Vector3f & a_PlanePos, const Vector3f & a_PlaneNormal ) +int cTracer::intersect3D_SegmentPlane( const Vector3f & a_Origin, const Vector3f & a_End, const Vector3f & a_PlanePos, const Vector3f & a_PlaneNormal) { Vector3f u = a_End - a_Origin; // a_Ray.P1 - S.P0; Vector3f w = a_Origin - a_PlanePos; // S.P0 - Pn.V0; - float D = a_PlaneNormal.Dot( u ); // dot(Pn.n, u); - float N = -(a_PlaneNormal.Dot( w ) ); // -dot(a_Plane.n, w); + float D = a_PlaneNormal.Dot( u); // dot(Pn.n, u); + float N = -(a_PlaneNormal.Dot( w)); // -dot(a_Plane.n, w); const float EPSILON = 0.0001f; if (fabs(D) < EPSILON) @@ -299,7 +299,7 @@ int cTracer::intersect3D_SegmentPlane( const Vector3f & a_Origin, const Vector3f return 0; // no intersection } - // Vector3f I ( a_Ray->GetOrigin() + sI * u );// S.P0 + sI * u; // compute segment intersect point + // Vector3f I ( a_Ray->GetOrigin() + sI * u);// S.P0 + sI * u; // compute segment intersect point RealHit = a_Origin + u * sI; return 1; } @@ -311,7 +311,7 @@ int cTracer::intersect3D_SegmentPlane( const Vector3f & a_Origin, const Vector3f int cTracer::GetHitNormal(const Vector3f & start, const Vector3f & end, const Vector3i & a_BlockPos) { Vector3i SmallBlockPos = a_BlockPos; - char BlockID = m_World->GetBlock( a_BlockPos.x, a_BlockPos.y, a_BlockPos.z ); + char BlockID = m_World->GetBlock( a_BlockPos.x, a_BlockPos.y, a_BlockPos.z); if (BlockID == E_BLOCK_AIR || IsBlockWater(BlockID)) { @@ -324,86 +324,86 @@ int cTracer::GetHitNormal(const Vector3f & start, const Vector3f & end, const Ve Vector3f Look = (end - start); Look.Normalize(); - float dot = Look.Dot( Vector3f(-1, 0, 0) ); // first face normal is x -1 + float dot = Look.Dot( Vector3f(-1, 0, 0)); // first face normal is x -1 if (dot < 0) { - int Lines = LinesCross( start.x, start.y, end.x, end.y, BlockPos.x, BlockPos.y, BlockPos.x, BlockPos.y + 1 ); + int Lines = LinesCross( start.x, start.y, end.x, end.y, BlockPos.x, BlockPos.y, BlockPos.x, BlockPos.y + 1); if (Lines == 1) { - Lines = LinesCross( start.x, start.z, end.x, end.z, BlockPos.x, BlockPos.z, BlockPos.x, BlockPos.z + 1 ); + Lines = LinesCross( start.x, start.z, end.x, end.z, BlockPos.x, BlockPos.z, BlockPos.x, BlockPos.z + 1); if (Lines == 1) { - intersect3D_SegmentPlane( start, end, BlockPos, Vector3f(-1, 0, 0) ); + intersect3D_SegmentPlane( start, end, BlockPos, Vector3f(-1, 0, 0)); return 1; } } } - dot = Look.Dot( Vector3f(0, 0, -1) ); // second face normal is z -1 + dot = Look.Dot( Vector3f(0, 0, -1)); // second face normal is z -1 if (dot < 0) { - int Lines = LinesCross( start.z, start.y, end.z, end.y, BlockPos.z, BlockPos.y, BlockPos.z, BlockPos.y + 1 ); + int Lines = LinesCross( start.z, start.y, end.z, end.y, BlockPos.z, BlockPos.y, BlockPos.z, BlockPos.y + 1); if (Lines == 1) { - Lines = LinesCross( start.z, start.x, end.z, end.x, BlockPos.z, BlockPos.x, BlockPos.z, BlockPos.x + 1 ); + Lines = LinesCross( start.z, start.x, end.z, end.x, BlockPos.z, BlockPos.x, BlockPos.z, BlockPos.x + 1); if (Lines == 1) { - intersect3D_SegmentPlane( start, end, BlockPos, Vector3f(0, 0, -1) ); + intersect3D_SegmentPlane( start, end, BlockPos, Vector3f(0, 0, -1)); return 2; } } } - dot = Look.Dot( Vector3f(1, 0, 0) ); // third face normal is x 1 + dot = Look.Dot( Vector3f(1, 0, 0)); // third face normal is x 1 if (dot < 0) { - int Lines = LinesCross( start.x, start.y, end.x, end.y, BlockPos.x + 1, BlockPos.y, BlockPos.x + 1, BlockPos.y + 1 ); + int Lines = LinesCross( start.x, start.y, end.x, end.y, BlockPos.x + 1, BlockPos.y, BlockPos.x + 1, BlockPos.y + 1); if (Lines == 1) { - Lines = LinesCross( start.x, start.z, end.x, end.z, BlockPos.x + 1, BlockPos.z, BlockPos.x + 1, BlockPos.z + 1 ); + Lines = LinesCross( start.x, start.z, end.x, end.z, BlockPos.x + 1, BlockPos.z, BlockPos.x + 1, BlockPos.z + 1); if (Lines == 1) { - intersect3D_SegmentPlane( start, end, BlockPos + Vector3f(1, 0, 0), Vector3f(1, 0, 0) ); + intersect3D_SegmentPlane( start, end, BlockPos + Vector3f(1, 0, 0), Vector3f(1, 0, 0)); return 3; } } } - dot = Look.Dot( Vector3f(0, 0, 1) ); // fourth face normal is z 1 + dot = Look.Dot( Vector3f(0, 0, 1)); // fourth face normal is z 1 if (dot < 0) { - int Lines = LinesCross( start.z, start.y, end.z, end.y, BlockPos.z + 1, BlockPos.y, BlockPos.z + 1, BlockPos.y + 1 ); + int Lines = LinesCross( start.z, start.y, end.z, end.y, BlockPos.z + 1, BlockPos.y, BlockPos.z + 1, BlockPos.y + 1); if (Lines == 1) { - Lines = LinesCross( start.z, start.x, end.z, end.x, BlockPos.z + 1, BlockPos.x, BlockPos.z + 1, BlockPos.x + 1 ); + Lines = LinesCross( start.z, start.x, end.z, end.x, BlockPos.z + 1, BlockPos.x, BlockPos.z + 1, BlockPos.x + 1); if (Lines == 1) { - intersect3D_SegmentPlane( start, end, BlockPos + Vector3f(0, 0, 1), Vector3f(0, 0, 1) ); + intersect3D_SegmentPlane( start, end, BlockPos + Vector3f(0, 0, 1), Vector3f(0, 0, 1)); return 4; } } } - dot = Look.Dot( Vector3f(0, 1, 0) ); // fifth face normal is y 1 + dot = Look.Dot( Vector3f(0, 1, 0)); // fifth face normal is y 1 if (dot < 0) { - int Lines = LinesCross( start.y, start.x, end.y, end.x, BlockPos.y + 1, BlockPos.x, BlockPos.y + 1, BlockPos.x + 1 ); + int Lines = LinesCross( start.y, start.x, end.y, end.x, BlockPos.y + 1, BlockPos.x, BlockPos.y + 1, BlockPos.x + 1); if (Lines == 1) { - Lines = LinesCross( start.y, start.z, end.y, end.z, BlockPos.y + 1, BlockPos.z, BlockPos.y + 1, BlockPos.z + 1 ); + Lines = LinesCross( start.y, start.z, end.y, end.z, BlockPos.y + 1, BlockPos.z, BlockPos.y + 1, BlockPos.z + 1); if (Lines == 1) { - intersect3D_SegmentPlane( start, end, BlockPos + Vector3f(0, 1, 0), Vector3f(0, 1, 0) ); + intersect3D_SegmentPlane( start, end, BlockPos + Vector3f(0, 1, 0), Vector3f(0, 1, 0)); return 5; } } } - dot = Look.Dot( Vector3f(0, -1, 0) ); // sixth face normal is y -1 + dot = Look.Dot( Vector3f(0, -1, 0)); // sixth face normal is y -1 if (dot < 0) { - int Lines = LinesCross( start.y, start.x, end.y, end.x, BlockPos.y, BlockPos.x, BlockPos.y, BlockPos.x + 1 ); + int Lines = LinesCross( start.y, start.x, end.y, end.x, BlockPos.y, BlockPos.x, BlockPos.y, BlockPos.x + 1); if (Lines == 1) { - Lines = LinesCross( start.y, start.z, end.y, end.z, BlockPos.y, BlockPos.z, BlockPos.y, BlockPos.z + 1 ); + Lines = LinesCross( start.y, start.z, end.y, end.z, BlockPos.y, BlockPos.z, BlockPos.y, BlockPos.z + 1); if (Lines == 1) { - intersect3D_SegmentPlane( start, end, BlockPos, Vector3f(0, -1, 0) ); + intersect3D_SegmentPlane( start, end, BlockPos, Vector3f(0, -1, 0)); return 6; } } diff --git a/src/Tracer.h b/src/Tracer.h index 4d932e460..ec87d449e 100644 --- a/src/Tracer.h +++ b/src/Tracer.h @@ -48,20 +48,20 @@ public: private: /// Preps Tracer object for call of Trace function. Only used internally. - void SetValues( const Vector3f & a_Start, const Vector3f & a_Direction ); + void SetValues( const Vector3f & a_Start, const Vector3f & a_Direction); /// Calculates where on the block a collision occured, if it does occur /// Returns 0 if no intersection occured /// Returns 1 if an intersection occured at a single point /// Returns 2 if the line segment lies in the plane being checked - int intersect3D_SegmentPlane( const Vector3f & a_Origin, const Vector3f & a_End, const Vector3f & a_PlanePos, const Vector3f & a_PlaneNormal ); + int intersect3D_SegmentPlane( const Vector3f & a_Origin, const Vector3f & a_End, const Vector3f & a_PlanePos, const Vector3f & a_PlaneNormal); /// Determines which face on the block a collision occured, if it does occur /// Returns 0 if the block is air, water or no collision occured /// Return 1 through 6 for the following block faces, repectively: -x, -z, x, z, y, -y int GetHitNormal( const Vector3f & start, const Vector3f & end, const Vector3i & a_BlockPos); - float SigNum( float a_Num ); + float SigNum( float a_Num); cWorld* m_World; Vector3f m_NormalTable[6]; diff --git a/src/UI/Window.cpp b/src/UI/Window.cpp index 2558d15b8..2c22b41bd 100644 --- a/src/UI/Window.cpp +++ b/src/UI/Window.cpp @@ -319,9 +319,9 @@ void cWindow::OwnerDestroyed() // Close window for each player. Note that the last one needs special handling while (m_OpenedBy.size() > 1) { - (*m_OpenedBy.begin() )->CloseWindow(); + (*m_OpenedBy.begin())->CloseWindow(); } - (*m_OpenedBy.begin() )->CloseWindow(); + (*m_OpenedBy.begin())->CloseWindow(); } diff --git a/src/UI/Window.h b/src/UI/Window.h index 1872b2c20..97db0ca88 100644 --- a/src/UI/Window.h +++ b/src/UI/Window.h @@ -77,7 +77,7 @@ public: int GetWindowType(void) const { return m_WindowType; } // tolua_export cWindowOwner * GetOwner(void) { return m_Owner; } - void SetOwner( cWindowOwner * a_Owner ) { m_Owner = a_Owner; } + void SetOwner( cWindowOwner * a_Owner) { m_Owner = a_Owner; } /// Returns the total number of slots int GetNumSlots(void) const; @@ -134,7 +134,7 @@ public: // tolua_begin const AString & GetWindowTitle() const { return m_WindowTitle; } - void SetWindowTitle(const AString & a_WindowTitle ) { m_WindowTitle = a_WindowTitle; } + void SetWindowTitle(const AString & a_WindowTitle) { m_WindowTitle = a_WindowTitle; } /// Sends the UpdateWindowProperty (0x69) packet to all clients of the window virtual void SetProperty(int a_Property, int a_Value); diff --git a/src/WebAdmin.cpp b/src/WebAdmin.cpp index d8347e2b9..f5dc6fde7 100644 --- a/src/WebAdmin.cpp +++ b/src/WebAdmin.cpp @@ -374,7 +374,7 @@ AString cWebAdmin::GetDefaultPage(void) { AString Content; Content += "

Server Name:

"; - Content += "

" + AString( cRoot::Get()->GetServer()->GetServerID() ) + "

"; + Content += "

" + AString( cRoot::Get()->GetServer()->GetServerID()) + "

"; Content += "

Plugins:

    "; cPluginManager * PM = cPluginManager::Get(); @@ -392,7 +392,7 @@ AString cWebAdmin::GetDefaultPage(void) cPlayerAccum PlayerAccum; cWorld * World = cRoot::Get()->GetDefaultWorld(); // TODO - Create a list of worlds and players - if (World != NULL ) + if (World != NULL) { World->ForEachPlayer(PlayerAccum); Content.append(PlayerAccum.m_Contents); @@ -404,7 +404,7 @@ AString cWebAdmin::GetDefaultPage(void) -AString cWebAdmin::GetBaseURL( const AString& a_URL ) +AString cWebAdmin::GetBaseURL( const AString& a_URL) { return GetBaseURL(StringSplit(a_URL, "/")); } diff --git a/src/World.cpp b/src/World.cpp index c146338d7..4ddd11f59 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -617,7 +617,7 @@ void cWorld::Start(void) m_SimulatorManager->RegisterSimulator(m_FireSimulator, 1); m_Lighting.Start(this); - m_Storage.Start(this, m_StorageSchema, m_StorageCompressionFactor ); + m_Storage.Start(this, m_StorageSchema, m_StorageCompressionFactor); m_Generator.Start(m_GeneratorCallbacks, m_GeneratorCallbacks, IniFile); m_ChunkSender.Start(this); m_TickThread.Start(); diff --git a/src/World.h b/src/World.h index 5e0af6340..c78bc8c8c 100644 --- a/src/World.h +++ b/src/World.h @@ -436,10 +436,10 @@ public: // tolua_begin // Vector3i variants: - void FastSetBlock(const Vector3i & a_Pos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta ) { FastSetBlock( a_Pos.x, a_Pos.y, a_Pos.z, a_BlockType, a_BlockMeta ); } - BLOCKTYPE GetBlock (const Vector3i & a_Pos ) { return GetBlock( a_Pos.x, a_Pos.y, a_Pos.z ); } - NIBBLETYPE GetBlockMeta(const Vector3i & a_Pos ) { return GetBlockMeta( a_Pos.x, a_Pos.y, a_Pos.z ); } - void SetBlockMeta(const Vector3i & a_Pos, NIBBLETYPE a_MetaData ) { SetBlockMeta( a_Pos.x, a_Pos.y, a_Pos.z, a_MetaData ); } + void FastSetBlock(const Vector3i & a_Pos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) { FastSetBlock( a_Pos.x, a_Pos.y, a_Pos.z, a_BlockType, a_BlockMeta); } + BLOCKTYPE GetBlock (const Vector3i & a_Pos) { return GetBlock( a_Pos.x, a_Pos.y, a_Pos.z); } + NIBBLETYPE GetBlockMeta(const Vector3i & a_Pos) { return GetBlockMeta( a_Pos.x, a_Pos.y, a_Pos.z); } + void SetBlockMeta(const Vector3i & a_Pos, NIBBLETYPE a_MetaData) { SetBlockMeta( a_Pos.x, a_Pos.y, a_Pos.z, a_MetaData); } // tolua_end /** Writes the block area into the specified coords. diff --git a/src/WorldStorage/WSSCompact.cpp b/src/WorldStorage/WSSCompact.cpp index aae94141c..5382a3e01 100644 --- a/src/WorldStorage/WSSCompact.cpp +++ b/src/WorldStorage/WSSCompact.cpp @@ -196,7 +196,7 @@ cWSSCompact::cPAKFile * cWSSCompact::LoadPAKFile(const cChunkCoords & a_Chunk) // Load it anew: AString FileName; - Printf(FileName, "%s/X%i_Z%i.pak", m_World->GetName().c_str(), LayerX, LayerZ ); + Printf(FileName, "%s/X%i_Z%i.pak", m_World->GetName().c_str(), LayerX, LayerZ); cPAKFile * f = new cPAKFile(FileName, LayerX, LayerZ, m_CompressionFactor); if (f == NULL) { @@ -271,12 +271,12 @@ void cWSSCompact::LoadEntitiesFromJson(Json::Value & a_Value, cEntityList & a_En Json::Value AllChests = a_Value.get("Chests", Json::nullValue); if (!AllChests.empty()) { - for (Json::Value::iterator itr = AllChests.begin(); itr != AllChests.end(); ++itr ) + for (Json::Value::iterator itr = AllChests.begin(); itr != AllChests.end(); ++itr) { std::auto_ptr ChestEntity(new cChestEntity(0, 0, 0, a_World, E_BLOCK_CHEST)); if (!ChestEntity->LoadFromJson(*itr)) { - LOGWARNING("ERROR READING CHEST FROM JSON!" ); + LOGWARNING("ERROR READING CHEST FROM JSON!"); } else { @@ -292,7 +292,7 @@ void cWSSCompact::LoadEntitiesFromJson(Json::Value & a_Value, cEntityList & a_En std::auto_ptr DispenserEntity(new cDispenserEntity(0, 0, 0, a_World)); if (!DispenserEntity->LoadFromJson(*itr)) { - LOGWARNING("ERROR READING DISPENSER FROM JSON!" ); + LOGWARNING("ERROR READING DISPENSER FROM JSON!"); } else { @@ -307,7 +307,7 @@ void cWSSCompact::LoadEntitiesFromJson(Json::Value & a_Value, cEntityList & a_En std::auto_ptr FlowerPotEntity(new cFlowerPotEntity(0, 0, 0, a_World)); if (!FlowerPotEntity->LoadFromJson(*itr)) { - LOGWARNING("ERROR READING FLOWERPOT FROM JSON!" ); + LOGWARNING("ERROR READING FLOWERPOT FROM JSON!"); } else { @@ -323,7 +323,7 @@ void cWSSCompact::LoadEntitiesFromJson(Json::Value & a_Value, cEntityList & a_En std::auto_ptr FurnaceEntity(new cFurnaceEntity(0, 0, 0, E_BLOCK_FURNACE, 0, a_World)); if (!FurnaceEntity->LoadFromJson(*itr)) { - LOGWARNING("ERROR READING FURNACE FROM JSON!" ); + LOGWARNING("ERROR READING FURNACE FROM JSON!"); } else { @@ -353,7 +353,7 @@ void cWSSCompact::LoadEntitiesFromJson(Json::Value & a_Value, cEntityList & a_En std::auto_ptr NoteEntity(new cNoteEntity(0, 0, 0, a_World)); if (!NoteEntity->LoadFromJson(*itr)) { - LOGWARNING("ERROR READING NOTE BLOCK FROM JSON!" ); + LOGWARNING("ERROR READING NOTE BLOCK FROM JSON!"); } else { @@ -368,7 +368,7 @@ void cWSSCompact::LoadEntitiesFromJson(Json::Value & a_Value, cEntityList & a_En std::auto_ptr JukeboxEntity(new cJukeboxEntity(0, 0, 0, a_World)); if (!JukeboxEntity->LoadFromJson(*itr)) { - LOGWARNING("ERROR READING JUKEBOX FROM JSON!" ); + LOGWARNING("ERROR READING JUKEBOX FROM JSON!"); } else { @@ -383,7 +383,7 @@ void cWSSCompact::LoadEntitiesFromJson(Json::Value & a_Value, cEntityList & a_En std::auto_ptr CommandBlockEntity(new cCommandBlockEntity(0, 0, 0, a_World)); if (!CommandBlockEntity->LoadFromJson(*itr)) { - LOGWARNING("ERROR READING COMMAND BLOCK FROM JSON!" ); + LOGWARNING("ERROR READING COMMAND BLOCK FROM JSON!"); } else { @@ -398,7 +398,7 @@ void cWSSCompact::LoadEntitiesFromJson(Json::Value & a_Value, cEntityList & a_En std::auto_ptr MobHeadEntity(new cMobHeadEntity(0, 0, 0, a_World)); if (!MobHeadEntity->LoadFromJson(*itr)) { - LOGWARNING("ERROR READING MOB HEAD FROM JSON!" ); + LOGWARNING("ERROR READING MOB HEAD FROM JSON!"); } else { @@ -427,8 +427,8 @@ cWSSCompact::cPAKFile::cPAKFile(const AString & a_FileName, int a_LayerX, int a_ m_LayerX(a_LayerX), m_LayerZ(a_LayerZ), m_NumDirty(0), - m_ChunkVersion( CHUNK_VERSION ), // Init with latest version - m_PakVersion( PAK_VERSION ) + m_ChunkVersion( CHUNK_VERSION), // Init with latest version + m_PakVersion( PAK_VERSION) { cFile f; if (!f.Open(m_FileName, cFile::fmRead)) @@ -445,18 +445,24 @@ cWSSCompact::cPAKFile::cPAKFile(const AString & a_FileName, int a_LayerX, int a_ } READ(m_ChunkVersion); - switch( m_ChunkVersion ) + switch (m_ChunkVersion) { - case 1: - m_ChunkSize.Set(16, 128, 16); - break; - case 2: - case 3: - m_ChunkSize.Set(16, 256, 16); - break; - default: - LOGERROR("File \"%s\" is in an unknown chunk format (%d)", m_FileName.c_str(), m_ChunkVersion); - return; + case 1: + { + m_ChunkSize.Set(16, 128, 16); + break; + } + case 2: + case 3: + { + m_ChunkSize.Set(16, 256, 16); + break; + } + default: + { + LOGERROR("File \"%s\" is in an unknown chunk format (%d)", m_FileName.c_str(), m_ChunkVersion); + return; + } }; short NumChunks = 0; @@ -486,12 +492,12 @@ cWSSCompact::cPAKFile::cPAKFile(const AString & a_FileName, int a_LayerX, int a_ return; } - if (m_ChunkVersion == 1 ) // Convert chunks to version 2 + if (m_ChunkVersion == 1) // Convert chunks to version 2 { UpdateChunk1To2(); } #if AXIS_ORDER == AXIS_ORDER_XZY - if (m_ChunkVersion == 2 ) // Convert chunks to version 3 + if (m_ChunkVersion == 2) // Convert chunks to version 3 { UpdateChunk2To3(); } @@ -574,9 +580,9 @@ void cWSSCompact::cPAKFile::UpdateChunk1To2() { sChunkHeader * Header = *itr; - if (ChunksConverted % 32 == 0 ) + if (ChunksConverted % 32 == 0) { - LOGINFO("Updating \"%s\" version 1 to version 2: " SIZE_T_FMT " %%", m_FileName.c_str(), (ChunksConverted * 100) / m_ChunkHeaders.size() ); + LOGINFO("Updating \"%s\" version 1 to version 2: " SIZE_T_FMT " %%", m_FileName.c_str(), (ChunksConverted * 100) / m_ChunkHeaders.size()); } ChunksConverted++; @@ -627,9 +633,9 @@ void cWSSCompact::cPAKFile::UpdateChunk1To2() char ConvertedData[cChunkDef::BlockDataSize]; int Index = 0; unsigned int InChunkOffset = 0; - for (int x = 0; x < 16; ++x ) for (int z = 0; z < 16; ++z ) + for (int x = 0; x < 16; ++x) for (int z = 0; z < 16; ++z) { - for (int y = 0; y < 128; ++y ) + for (int y = 0; y < 128; ++y) { ConvertedData[Index++] = UncompressedData[y + z * 128 + x * 128 * 16 + InChunkOffset]; } @@ -638,9 +644,9 @@ void cWSSCompact::cPAKFile::UpdateChunk1To2() Index += 128; } InChunkOffset += (16 * 128 * 16); - for (int x = 0; x < 16; ++x ) for (int z = 0; z < 16; ++z ) // Metadata + for (int x = 0; x < 16; ++x) for (int z = 0; z < 16; ++z) // Metadata { - for (int y = 0; y < 64; ++y ) + for (int y = 0; y < 64; ++y) { ConvertedData[Index++] = UncompressedData[y + z * 64 + x * 64 * 16 + InChunkOffset]; } @@ -648,9 +654,9 @@ void cWSSCompact::cPAKFile::UpdateChunk1To2() Index += 64; } InChunkOffset += (16 * 128 * 16) / 2; - for (int x = 0; x < 16; ++x ) for (int z = 0; z < 16; ++z ) // Block light + for (int x = 0; x < 16; ++x) for (int z = 0; z < 16; ++z) // Block light { - for (int y = 0; y < 64; ++y ) + for (int y = 0; y < 64; ++y) { ConvertedData[Index++] = UncompressedData[y + z * 64 + x * 64 * 16 + InChunkOffset]; } @@ -658,9 +664,9 @@ void cWSSCompact::cPAKFile::UpdateChunk1To2() Index += 64; } InChunkOffset += (16*128*16)/2; - for (int x = 0; x < 16; ++x ) for (int z = 0; z < 16; ++z ) // Sky light + for (int x = 0; x < 16; ++x) for (int z = 0; z < 16; ++z) // Sky light { - for (int y = 0; y < 64; ++y ) + for (int y = 0; y < 64; ++y) { ConvertedData[Index++] = UncompressedData[y + z * 64 + x * 64 * 16 + InChunkOffset]; } @@ -674,7 +680,7 @@ void cWSSCompact::cPAKFile::UpdateChunk1To2() // Add JSON data afterwards if (UncompressedData.size() > InChunkOffset) { - Converted.append( UncompressedData.begin() + InChunkOffset, UncompressedData.end() ); + Converted.append( UncompressedData.begin() + InChunkOffset, UncompressedData.end()); } // Re-compress data @@ -702,7 +708,7 @@ void cWSSCompact::cPAKFile::UpdateChunk1To2() m_ChunkVersion = 2; SynchronizeFile(); - LOGINFO("Updated \"%s\" version 1 to version 2", m_FileName.c_str() ); + LOGINFO("Updated \"%s\" version 1 to version 2", m_FileName.c_str()); } @@ -718,9 +724,9 @@ void cWSSCompact::cPAKFile::UpdateChunk2To3() { sChunkHeader * Header = *itr; - if (ChunksConverted % 32 == 0 ) + if (ChunksConverted % 32 == 0) { - LOGINFO("Updating \"%s\" version 2 to version 3: " SIZE_T_FMT " %%", m_FileName.c_str(), (ChunksConverted * 100) / m_ChunkHeaders.size() ); + LOGINFO("Updating \"%s\" version 2 to version 3: " SIZE_T_FMT " %%", m_FileName.c_str(), (ChunksConverted * 100) / m_ChunkHeaders.size()); } ChunksConverted++; @@ -771,10 +777,10 @@ void cWSSCompact::cPAKFile::UpdateChunk2To3() // Cannot use cChunk::MakeIndex because it might change again????????? // For compatibility, use what we know is current - #define MAKE_3_INDEX( x, y, z ) ( x + (z * 16) + (y * 16 * 16) ) + #define MAKE_3_INDEX( x, y, z) ( x + (z * 16) + (y * 16 * 16)) unsigned int InChunkOffset = 0; - for (int x = 0; x < 16; ++x ) for (int z = 0; z < 16; ++z ) for (int y = 0; y < 256; ++y ) // YZX Loop order is important, in 1.1 Y was first then Z then X + for (int x = 0; x < 16; ++x) for (int z = 0; z < 16; ++z) for (int y = 0; y < 256; ++y) // YZX Loop order is important, in 1.1 Y was first then Z then X { ConvertedData[ MAKE_3_INDEX(x, y, z) ] = UncompressedData[InChunkOffset]; ++InChunkOffset; @@ -782,25 +788,25 @@ void cWSSCompact::cPAKFile::UpdateChunk2To3() unsigned int index2 = 0; - for (int x = 0; x < 16; ++x ) for (int z = 0; z < 16; ++z ) for (int y = 0; y < 256; ++y ) + for (int x = 0; x < 16; ++x) for (int z = 0; z < 16; ++z) for (int y = 0; y < 256; ++y) { - ConvertedData[ InChunkOffset + MAKE_3_INDEX(x, y, z)/2 ] |= ( (UncompressedData[ InChunkOffset + index2/2 ] >> ((index2&1)*4) ) & 0x0f ) << ((x&1)*4); + ConvertedData[ InChunkOffset + MAKE_3_INDEX(x, y, z)/2 ] |= ( (UncompressedData[ InChunkOffset + index2/2 ] >> ((index2&1)*4)) & 0x0f) << ((x&1)*4); ++index2; } InChunkOffset += index2 / 2; index2 = 0; - for (int x = 0; x < 16; ++x ) for (int z = 0; z < 16; ++z ) for (int y = 0; y < 256; ++y ) + for (int x = 0; x < 16; ++x) for (int z = 0; z < 16; ++z) for (int y = 0; y < 256; ++y) { - ConvertedData[ InChunkOffset + MAKE_3_INDEX(x, y, z)/2 ] |= ( (UncompressedData[ InChunkOffset + index2/2 ] >> ((index2&1)*4) ) & 0x0f ) << ((x&1)*4); + ConvertedData[ InChunkOffset + MAKE_3_INDEX(x, y, z)/2 ] |= ( (UncompressedData[ InChunkOffset + index2/2 ] >> ((index2&1)*4)) & 0x0f) << ((x&1)*4); ++index2; } InChunkOffset += index2 / 2; index2 = 0; - for (int x = 0; x < 16; ++x ) for (int z = 0; z < 16; ++z ) for (int y = 0; y < 256; ++y ) + for (int x = 0; x < 16; ++x) for (int z = 0; z < 16; ++z) for (int y = 0; y < 256; ++y) { - ConvertedData[ InChunkOffset + MAKE_3_INDEX(x, y, z)/2 ] |= ( (UncompressedData[ InChunkOffset + index2/2 ] >> ((index2&1)*4) ) & 0x0f ) << ((x&1)*4); + ConvertedData[ InChunkOffset + MAKE_3_INDEX(x, y, z)/2 ] |= ( (UncompressedData[ InChunkOffset + index2/2 ] >> ((index2&1)*4)) & 0x0f) << ((x&1)*4); ++index2; } InChunkOffset += index2 / 2; @@ -810,7 +816,7 @@ void cWSSCompact::cPAKFile::UpdateChunk2To3() // Add JSON data afterwards if (UncompressedData.size() > InChunkOffset) { - Converted.append( UncompressedData.begin() + InChunkOffset, UncompressedData.end() ); + Converted.append( UncompressedData.begin() + InChunkOffset, UncompressedData.end()); } // Re-compress data @@ -838,7 +844,7 @@ void cWSSCompact::cPAKFile::UpdateChunk2To3() m_ChunkVersion = 3; SynchronizeFile(); - LOGINFO("Updated \"%s\" version 2 to version 3", m_FileName.c_str() ); + LOGINFO("Updated \"%s\" version 2 to version 3", m_FileName.c_str()); } @@ -887,7 +893,7 @@ bool cWSSCompact::LoadChunkFromData(const cChunkCoords & a_Chunk, int a_Uncompre { Json::Value root; // will contain the root value after parsing. Json::Reader reader; - if (!reader.parse( UncompressedData.data() + cChunkDef::BlockDataSize, root, false ) ) + if (!reader.parse( UncompressedData.data() + cChunkDef::BlockDataSize, root, false)) { LOGERROR("Failed to parse trailing JSON in chunk [%d, %d]!", a_Chunk.m_ChunkX, a_Chunk.m_ChunkZ @@ -970,7 +976,7 @@ bool cWSSCompact::cPAKFile::SaveChunkToData(const cChunkCoords & a_Chunk, cWorld // Compress the data: AString CompressedData; int errorcode = CompressString(Data.data(), Data.size(), CompressedData, m_CompressionFactor); - if (errorcode != Z_OK ) + if (errorcode != Z_OK) { LOGERROR("Error %i compressing data for chunk [%d, %d, %d]", errorcode, a_Chunk.m_ChunkX, a_Chunk.m_ChunkY, a_Chunk.m_ChunkZ); return false; diff --git a/src/WorldStorage/WorldStorage.cpp b/src/WorldStorage/WorldStorage.cpp index d0b2acf3b..707e8f929 100644 --- a/src/WorldStorage/WorldStorage.cpp +++ b/src/WorldStorage/WorldStorage.cpp @@ -61,7 +61,7 @@ cWorldStorage::~cWorldStorage() -bool cWorldStorage::Start(cWorld * a_World, const AString & a_StorageSchemaName, int a_StorageCompressionFactor ) +bool cWorldStorage::Start(cWorld * a_World, const AString & a_StorageSchemaName, int a_StorageCompressionFactor) { m_World = a_World; m_StorageSchemaName = a_StorageSchemaName; diff --git a/src/main.cpp b/src/main.cpp index 3e91149af..93fa6af91 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -174,7 +174,7 @@ BOOL CtrlHandler(DWORD fdwCtrlType) //////////////////////////////////////////////////////////////////////////////// // main: -int main( int argc, char **argv ) +int main( int argc, char **argv) { UNUSED(argc); UNUSED(argv); @@ -218,7 +218,7 @@ int main( int argc, char **argv ) #endif #if defined(_DEBUG) && defined(_MSC_VER) - _CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF ); + _CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); // _X: The simple built-in CRT leak finder - simply break when allocating the Nth block ({N} is listed in the leak output) // Only useful when the leak is in the same sequence all the time @@ -281,11 +281,11 @@ int main( int argc, char **argv ) Root.Start(); } #if !defined(ANDROID_NDK) - catch( std::exception& e ) + catch( std::exception& e) { - LOGERROR("Standard exception: %s", e.what() ); + LOGERROR("Standard exception: %s", e.what()); } - catch( ... ) + catch( ...) { LOGERROR("Unknown exception!"); } -- cgit v1.2.3 From fe6a3b5d7229ae07b536afa794fdb5bedbeb37e4 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 21 Jul 2014 15:20:27 +0200 Subject: CheckBasicStyle: Checks spaces after keywords, no space before ")". --- src/CheckBasicStyle.lua | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/CheckBasicStyle.lua b/src/CheckBasicStyle.lua index e4597a426..ddc552fa4 100644 --- a/src/CheckBasicStyle.lua +++ b/src/CheckBasicStyle.lua @@ -8,7 +8,7 @@ Checks that all source files (*.cpp, *.h) use the basic style requirements of th - Two spaces between code and line-end comment ("//") - Spaces after comma, not before - Opening braces not at the end of a code line - - (TODO) Spaces after if, for, while + - Spaces after if, for, while - (TODO) Spaces before *, /, & - (TODO) Hex numbers with even digit length - (TODO) Hex numbers in lowercase @@ -125,6 +125,21 @@ local g_ViolationPatterns = -- Check that opening braces are not at the end of a code line: {"[^%s].-{\n?$", "Brace should be on a separate line"}, + + -- Space after keywords: + {"[^_]if%(", "Needs a space after \"if\""}, + {"for%(", "Needs a space after \"for\""}, + {"while%(", "Needs a space after \"while\""}, + {"switch%(", "Needs a space after \"switch\""}, + + -- No space after keyword's parenthesis: + {"[^%a#]if %( ", "Remove the space after \"(\""}, + {"for %( ", "Remove the space after \"(\""}, + {"while %( ", "Remove the space after \"(\""}, + {"switch %( ", "Remove the space after \"(\""}, + + -- No space before a closing parenthesis: + {" %)", "Remove the space before \")\""}, } -- cgit v1.2.3 From 9e7b9a4ebe815bd631d8b124e81f017fc7fa35a2 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 21 Jul 2014 15:21:54 +0200 Subject: Normalized spaces after "catch". --- src/CheckBasicStyle.lua | 3 ++- src/main.cpp | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/CheckBasicStyle.lua b/src/CheckBasicStyle.lua index ddc552fa4..fba30ea98 100644 --- a/src/CheckBasicStyle.lua +++ b/src/CheckBasicStyle.lua @@ -131,12 +131,13 @@ local g_ViolationPatterns = {"for%(", "Needs a space after \"for\""}, {"while%(", "Needs a space after \"while\""}, {"switch%(", "Needs a space after \"switch\""}, + {"catch%(", "Needs a space after \"catch\""}, -- No space after keyword's parenthesis: {"[^%a#]if %( ", "Remove the space after \"(\""}, {"for %( ", "Remove the space after \"(\""}, {"while %( ", "Remove the space after \"(\""}, - {"switch %( ", "Remove the space after \"(\""}, + {"catch %( ", "Remove the space after \"(\""}, -- No space before a closing parenthesis: {" %)", "Remove the space before \")\""}, diff --git a/src/main.cpp b/src/main.cpp index 93fa6af91..106233342 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -281,11 +281,11 @@ int main( int argc, char **argv) Root.Start(); } #if !defined(ANDROID_NDK) - catch( std::exception& e) + catch (std::exception & e) { LOGERROR("Standard exception: %s", e.what()); } - catch( ...) + catch (...) { LOGERROR("Unknown exception!"); } -- cgit v1.2.3 From 5194eef07d4fdb166af295bd5e6360d95175ff32 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 21 Jul 2014 17:35:09 +0200 Subject: CMake: generates a list of all source files. This will be used for the style-checking script. --- .gitignore | 1 + src/CMakeLists.txt | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/.gitignore b/.gitignore index 4a319c5ef..400bf2c91 100644 --- a/.gitignore +++ b/.gitignore @@ -65,6 +65,7 @@ lib/tolua++/tolua src/Bindings/Bindings.* src/Bindings/BindingDependecies.txt MCServer.dir/ +src/AllFiles.lst #win32 cmake stuff *.vcxproj diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 9feaf64fe..f494b52e5 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -228,6 +228,26 @@ else () set(CMAKE_MODULE_LINKER_FLAGS_RELEASE "${CMAKE_MODULE_LINKER_FLAGS_RELEASE} /DEBUG") endif() + +# Generate a list of all source files: +set(ALLFILES "") +foreach(folder ${FOLDERS}) + get_directory_property(FOLDER_SRCS DIRECTORY ${folder} DEFINITION SRCS) + foreach (src ${FOLDER_SRCS}) + list(APPEND ALLFILES "${folder}/${src}") + endforeach(src) + + get_directory_property(FOLDER_HDRS DIRECTORY ${folder} DEFINITION HDRS) + foreach (hdr ${FOLDER_HDRS}) + list(APPEND ALLFILES "${folder}/${hdr}") + endforeach(hdr) +endforeach(folder) +foreach(arg ${ALLFILES}) + set(ALLFILESLINES "${ALLFILESLINES}${arg}\n") +endforeach() +FILE(WRITE "AllFiles.lst" "${ALLFILESLINES}") + + set(EXECUTABLE MCServer) if (MSVC) -- cgit v1.2.3 From 26ad3dbee4aacef035e2d085fecdc5610469fc7d Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 21 Jul 2014 17:38:36 +0200 Subject: CheckBasicStyle: Doesn't require LuaFileSystem. Instead it uses the list of files generated by CMake. --- src/CheckBasicStyle.lua | 44 ++++++++++---------------------------------- 1 file changed, 10 insertions(+), 34 deletions(-) diff --git a/src/CheckBasicStyle.lua b/src/CheckBasicStyle.lua index fba30ea98..e85c074dc 100644 --- a/src/CheckBasicStyle.lua +++ b/src/CheckBasicStyle.lua @@ -23,26 +23,12 @@ the line brings the editor directly to the violation. Returns 0 on success, 1 on internal failure, 2 if any violations found -This script requires LuaFileSystem to be available in the current Lua interpreter. --]] --- Check that LFS is installed: -local hasLfs = pcall(require, "lfs") -if not(hasLfs) then - print("This script requires LuaFileSystem to be installed") - os.exit(1) -end -local lfs = require("lfs") -assert(lfs ~= nil) - - - - - -- The list of file extensions that are processed: local g_ShouldProcessExt = { @@ -53,13 +39,12 @@ local g_ShouldProcessExt = --- The list of files not to be processed: local g_IgnoredFiles = { - "./Bindings/Bindings.cpp", - "./Bindings/DeprecatedBindings.cpp", - "./LeakFinder.cpp", - "./LeakFinder.h", - "./MersenneTwister.h", - "./StackWalker.cpp", - "./StackWalker.h", + "Bindings/Bindings.cpp", + "LeakFinder.cpp", + "LeakFinder.h", + "MersenneTwister.h", + "StackWalker.cpp", + "StackWalker.h", } --- The list of files not to be processed, as a dictionary (filename => true), built from g_IgnoredFiles @@ -198,17 +183,6 @@ local function ProcessItem(a_ItemName) return end - -- If the item is a folder, recurse: - local attrs = lfs.attributes(a_ItemName) - if (attrs and (attrs.mode == "directory")) then - for fnam in lfs.dir(a_ItemName) do - if ((fnam ~= ".") and (fnam ~= "..")) then - ProcessItem(a_ItemName .. "/" .. fnam) - end - end - return - end - local ext = a_ItemName:match("%.([^/%.]-)$") if (g_ShouldProcessExt[ext]) then ProcessFile(a_ItemName) @@ -219,8 +193,10 @@ end --- Process the entire current folder: -ProcessItem(".") +-- Process all files in the AllFiles.lst file (generated by cmake): +for fnam in io.lines("AllFiles.lst") do + ProcessItem(fnam) +end -- Report final verdict: print("Number of violations found: " .. g_NumViolations) -- cgit v1.2.3 From 63cc008340a13428eb254e82acf886035c728025 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 21 Jul 2014 17:57:50 +0200 Subject: CheckBasicStyle: Added a lua shebang. --- src/CheckBasicStyle.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/src/CheckBasicStyle.lua b/src/CheckBasicStyle.lua index e85c074dc..13a6d15d2 100644 --- a/src/CheckBasicStyle.lua +++ b/src/CheckBasicStyle.lua @@ -1,3 +1,4 @@ +#!/usr/bin/env lua -- CheckBasicStyle.lua -- cgit v1.2.3 From dd0ab044810d87dc4233a652087808638c696d94 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 21 Jul 2014 18:07:51 +0200 Subject: Defines.h: Fixed a warning. --- src/Defines.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Defines.h b/src/Defines.h index f095069d9..9f66cbf9b 100644 --- a/src/Defines.h +++ b/src/Defines.h @@ -470,7 +470,7 @@ inline void AddFaceDirection(int & a_BlockX, unsigned char & a_BlockY, int & a_B { int Y = a_BlockY; AddFaceDirection(a_BlockX, Y, a_BlockZ, a_BlockFace, a_bInverse); - a_BlockY = Clamp(Y, 0, 255); + a_BlockY = Clamp((unsigned char)Y, 0, 255); } -- cgit v1.2.3 From bea574bf5425215bbed49ad4b3814804fd8757fc Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Mon, 21 Jul 2014 18:53:56 +0200 Subject: ExtremeHillsPlus and ExtremeHills spawn with grass only Turns out only the M variants have stone and gravel in them. --- src/Generating/DistortedHeightmap.cpp | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/src/Generating/DistortedHeightmap.cpp b/src/Generating/DistortedHeightmap.cpp index b46850a81..74d30c327 100644 --- a/src/Generating/DistortedHeightmap.cpp +++ b/src/Generating/DistortedHeightmap.cpp @@ -675,6 +675,8 @@ void cDistortedHeightmap::ComposeColumn(cChunkDesc & a_ChunkDesc, int a_RelX, in case biForestHills: case biTaigaHills: case biExtremeHillsEdge: + case biExtremeHillsPlus: + case biExtremeHills: case biJungle: case biJungleHills: case biJungleEdge: @@ -750,18 +752,6 @@ void cDistortedHeightmap::ComposeColumn(cChunkDesc & a_ChunkDesc, int a_RelX, in return; } - case biExtremeHillsPlus: - case biExtremeHills: - { - // Select the pattern to use - stone or grass: - NOISE_DATATYPE NoiseX = ((NOISE_DATATYPE)(m_CurChunkX * cChunkDef::Width + a_RelX)) / FrequencyX; - NOISE_DATATYPE NoiseY = ((NOISE_DATATYPE)(m_CurChunkZ * cChunkDef::Width + a_RelZ)) / FrequencyZ; - NOISE_DATATYPE Val = m_OceanFloorSelect.CubicNoise2D(NoiseX, NoiseY); - const sBlockInfo * Pattern = (Val < -0.1) ? patStone.Get() : patGrass.Get(); - FillColumnPattern(a_ChunkDesc, a_RelX, a_RelZ, Pattern); - return; - } - case biExtremeHillsPlusM: case biExtremeHillsM: { -- cgit v1.2.3 From 31b22e14b719e84d2e828ae474d9c6f596024a37 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 22 Jul 2014 10:04:53 +0200 Subject: Updated prefabs to current Gallery content. --- src/Generating/Prefabs/AlchemistVillagePrefabs.cpp | 38 +- src/Generating/Prefabs/JapaneseVillagePrefabs.cpp | 48 ++- src/Generating/Prefabs/PlainsVillagePrefabs.cpp | 383 ++++++++++----------- 3 files changed, 243 insertions(+), 226 deletions(-) diff --git a/src/Generating/Prefabs/AlchemistVillagePrefabs.cpp b/src/Generating/Prefabs/AlchemistVillagePrefabs.cpp index 8c935c2a5..c08e53ef6 100644 --- a/src/Generating/Prefabs/AlchemistVillagePrefabs.cpp +++ b/src/Generating/Prefabs/AlchemistVillagePrefabs.cpp @@ -2367,9 +2367,9 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = "a: 24: 2\n" /* sandstone */ "b: 4: 0\n" /* cobblestone */ "c: 24: 0\n" /* sandstone */ - "d: 12: 0\n" /* sand */ - "e: 13: 0\n" /* gravel */ - "f: 5: 0\n" /* wood */ + "d: 13: 0\n" /* gravel */ + "e: 5: 0\n" /* wood */ + "f: 12: 0\n" /* sand */ "g: 64: 3\n" /* wooddoorblock */ "h: 85: 0\n" /* fence */ "i: 64: 0\n" /* wooddoorblock */ @@ -2392,26 +2392,26 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = /* * 012345678901234 */ /* 0 */ "mmmabbbammmmmmm" /* 1 */ "mmmmbbbmmmmmmmm" - /* 2 */ "acccccccccadddd" - /* 3 */ "cccccccccccdddd" - /* 4 */ "cccccccccccdddd" - /* 5 */ "cccccccccccdddd" - /* 6 */ "cccccccccccdddd" - /* 7 */ "cccccccccccdddd" - /* 8 */ "acccccccccadddd" + /* 2 */ "acccccccccacccc" + /* 3 */ "ccccccccccccccc" + /* 4 */ "ccccccccccccccc" + /* 5 */ "ccccccccccccccc" + /* 6 */ "ccccccccccccccc" + /* 7 */ "ccccccccccccccc" + /* 8 */ "acccccccccacccc" // Level 1 /* z\x* 11111 */ /* * 012345678901234 */ - /* 0 */ "mmmaeeeammmmmmm" - /* 1 */ "mmmmeeemmmmmmmm" - /* 2 */ "accccfccccadddd" - /* 3 */ "cfffffffffcdddd" - /* 4 */ "cfffffffffcdddd" - /* 5 */ "cffffffffffdddd" - /* 6 */ "cfffffffffcdddd" - /* 7 */ "cfffffffffcdddd" - /* 8 */ "acccccccccadddd" + /* 0 */ "mmmadddammmmmmm" + /* 1 */ "mmmmdddmmmmmmmm" + /* 2 */ "acccceccccaffff" + /* 3 */ "ceeeeeeeeecffff" + /* 4 */ "ceeeeeeeeecffff" + /* 5 */ "ceeeeeeeeeeffff" + /* 6 */ "ceeeeeeeeecffff" + /* 7 */ "ceeeeeeeeecffff" + /* 8 */ "acccccccccaffff" // Level 2 /* z\x* 11111 */ diff --git a/src/Generating/Prefabs/JapaneseVillagePrefabs.cpp b/src/Generating/Prefabs/JapaneseVillagePrefabs.cpp index c49015e36..0362c9406 100644 --- a/src/Generating/Prefabs/JapaneseVillagePrefabs.cpp +++ b/src/Generating/Prefabs/JapaneseVillagePrefabs.cpp @@ -134,11 +134,11 @@ const cPrefab::sDef g_JapaneseVillagePrefabs[] = // The data has been exported from the gallery Plains, area index 166, ID 554, created by Aloe_vera { // Size: - 11, 7, 13, // SizeX = 11, SizeY = 7, SizeZ = 13 + 11, 8, 13, // SizeX = 11, SizeY = 8, SizeZ = 13 // Hitbox (relative to bounding box): 0, 0, 0, // MinX, MinY, MinZ - 10, 6, 12, // MaxX, MaxY, MaxZ + 10, 7, 12, // MaxX, MaxY, MaxZ // Block definitions: ".: 0: 0\n" /* air */ @@ -150,6 +150,7 @@ const cPrefab::sDef g_JapaneseVillagePrefabs[] = "f: 59: 7\n" /* crops */ "g: 83: 0\n" /* reedblock */ "h:113: 0\n" /* netherbrickfence */ + "i: 50: 5\n" /* torch */ "m: 19: 0\n" /* sponge */, // Block data: @@ -270,7 +271,24 @@ const cPrefab::sDef g_JapaneseVillagePrefabs[] = /* 9 */ "..........." /* 10 */ ".h.......h." /* 11 */ "hhh.....hhh" - /* 12 */ ".h.......h.", + /* 12 */ ".h.......h." + + // Level 7 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ ".i.......i." + /* 1 */ "i.i.....i.i" + /* 2 */ ".i.......i." + /* 3 */ "..........." + /* 4 */ "..........." + /* 5 */ "..........." + /* 6 */ "..........." + /* 7 */ "..........." + /* 8 */ "..........." + /* 9 */ "..........." + /* 10 */ ".i.......i." + /* 11 */ "i.i.....i.i" + /* 12 */ ".i.......i.", // Connectors: "-1: 10, 2, 6: 5\n" /* Type -1, direction X+ */, @@ -2195,33 +2213,33 @@ const cPrefab::sDef g_JapaneseVillagePrefabs[] = // Level 1 /* z\x* 0123456 */ - /* 0 */ "bmmmmmm" - /* 1 */ "bmmmmmm" - /* 2 */ "bmmmmmm" - /* 3 */ "bmmmmmm" - /* 4 */ "bmmmmmm" - /* 5 */ "bmmmmmm" + /* 0 */ "bbbbbbb" + /* 1 */ "bbbbbbb" + /* 2 */ "bbbbbbb" + /* 3 */ "bbbabbb" + /* 4 */ "bbbbbbb" + /* 5 */ "bbbbbbb" /* 6 */ "bbbbbbb" // Level 2 /* z\x* 0123456 */ - /* 0 */ "......." - /* 1 */ "..c.c.." + /* 0 */ "mm...mm" + /* 1 */ "m.c...m" /* 2 */ ".dccdc." /* 3 */ "..cefc." /* 4 */ ".ccfgh." - /* 5 */ "..ccc.." - /* 6 */ "......." + /* 5 */ "m.ccc.m" + /* 6 */ "mm...mm" // Level 3 /* z\x* 0123456 */ - /* 0 */ "......." + /* 0 */ "m.....m" /* 1 */ "......." /* 2 */ "......." /* 3 */ "...e..." /* 4 */ "......." /* 5 */ "......." - /* 6 */ "......." + /* 6 */ "m.....m" // Level 4 /* z\x* 0123456 */ diff --git a/src/Generating/Prefabs/PlainsVillagePrefabs.cpp b/src/Generating/Prefabs/PlainsVillagePrefabs.cpp index 714a66559..4613f76e2 100644 --- a/src/Generating/Prefabs/PlainsVillagePrefabs.cpp +++ b/src/Generating/Prefabs/PlainsVillagePrefabs.cpp @@ -356,8 +356,8 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = "e: 8: 0\n" /* water */ "f: 50: 5\n" /* torch */ "g: 59: 7\n" /* crops */ - "h: 59: 0\n" /* crops */ - "i: 59: 1\n" /* crops */ + "h: 59: 3\n" /* crops */ + "i: 59: 5\n" /* crops */ "m: 19: 0\n" /* sponge */, // Block data: @@ -368,7 +368,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 1 */ "aaaaaaaaaaaaaaa" /* 2 */ "aaaaaaaaaaaaaaa" /* 3 */ "aaaaaaaaaaaaaaa" - /* 4 */ "aaaaaaaaaaaaaaa" + /* 4 */ "aaaaaaabaaaaaaa" /* 5 */ "aaaaaaabaaaaaaa" /* 6 */ "aaaaaaabaaaaaaa" /* 7 */ "aaaaaaabaaaaaaa" @@ -405,12 +405,12 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* * 012345678901234 */ /* 0 */ "f.....f.f.....f" /* 1 */ ".gg.gg...gg.gg." - /* 2 */ ".gh.hg...gg.gg." - /* 3 */ ".gh.ih...gg.gg." - /* 4 */ ".gg.hg...gg.gg." - /* 5 */ ".gg.hg...gg.gg." - /* 6 */ ".ig.hg...gg.gg." - /* 7 */ ".hg.gh...gg.gg." + /* 2 */ ".gg.hg...gg.gg." + /* 3 */ ".gg.gi...gg.gg." + /* 4 */ ".gg.gg...gg.gg." + /* 5 */ ".gg.gg...gg.gg." + /* 6 */ ".gg.gg...gg.gg." + /* 7 */ ".gg.gg...gg.gg." /* 8 */ "f.....f.f.....f" // Level 4 @@ -3603,8 +3603,8 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = // Block definitions: ".: 0: 0\n" /* air */ - "a: 2: 0\n" /* grass */ - "b: 3: 0\n" /* dirt */ + "a: 3: 0\n" /* dirt */ + "b: 2: 0\n" /* grass */ "c: 4: 0\n" /* cobblestone */ "d: 67: 0\n" /* stairs */ "e: 67: 2\n" /* stairs */ @@ -3629,19 +3629,19 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = // Level 0 /* z\x* 1 */ /* * 01234567890 */ - /* 0 */ "aaaabbbaaaa" - /* 1 */ "abbbbbbbbba" - /* 2 */ "abbbbbbbbba" - /* 3 */ "abbbbbbbbba" - /* 4 */ "abbbbbbbbba" - /* 5 */ "abbbbbbbbba" - /* 6 */ "abbbbbbbbba" - /* 7 */ "abbbbbbbbba" - /* 8 */ "aabbbbbbbaa" - /* 9 */ "aabbbbbbbaa" - /* 10 */ "aabbbbbbbaa" - /* 11 */ "aabbbbbbbaa" - /* 12 */ "aabbbbbbbaa" + /* 0 */ "aaaaaaaaaaa" + /* 1 */ "aaaaaaaaaaa" + /* 2 */ "aaaaaaaaaaa" + /* 3 */ "aaaaaaaaaaa" + /* 4 */ "aaaaaaaaaab" + /* 5 */ "baaaaaaaaab" + /* 6 */ "aaaaaaaaaaa" + /* 7 */ "baaaaaaaaaa" + /* 8 */ "baaaaaaaaaa" + /* 9 */ "baaaaaaaaab" + /* 10 */ "aaaaaaaaaaa" + /* 11 */ "aaaaaaaaaba" + /* 12 */ "aaaaaaaaaba" // Level 1 /* z\x* 1 */ @@ -3654,11 +3654,11 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 5 */ "mcccccccccm" /* 6 */ "mcccccccccm" /* 7 */ "mcccccccccm" - /* 8 */ "mmbbbbbbbmm" - /* 9 */ "mmbbbbbbbmm" - /* 10 */ "mmbbbbbbbmm" - /* 11 */ "mmbbbbbbbmm" - /* 12 */ "mmbbbbbbbmm" + /* 8 */ "mmaaaaaaamm" + /* 9 */ "mmaaaaaaamm" + /* 10 */ "mmaaaaaaamm" + /* 11 */ "mmaaaaaaamm" + /* 12 */ "mmaaaaaaamm" // Level 2 /* z\x* 1 */ @@ -3671,11 +3671,11 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 5 */ ".cggggcccc." /* 6 */ ".cggggcccc." /* 7 */ ".ccccccccc." - /* 8 */ "..aaaaaaa.." - /* 9 */ "..aaaaaaa.." - /* 10 */ "..aaaaaaa.." - /* 11 */ "..aaaaaaa.." - /* 12 */ "..aaaaaaa.." + /* 8 */ "..bbbbbbb.." + /* 9 */ "mmbbbbbbbmm" + /* 10 */ "mmbbbbbbbmm" + /* 11 */ "mmbbbbbbbmm" + /* 12 */ "mmbbbbbbbmm" // Level 3 /* z\x* 1 */ @@ -3689,10 +3689,10 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 6 */ ".i.......i." /* 7 */ ".hiiijiiih." /* 8 */ "..l.....l.." - /* 9 */ "..l.....l.." - /* 10 */ "..l.....l.." - /* 11 */ "..l.....l.." - /* 12 */ "..lllllll.." + /* 9 */ "mml.....lmm" + /* 10 */ "mml.....lmm" + /* 11 */ "mml.....lmm" + /* 12 */ "mmlllllllmm" // Level 4 /* z\x* 1 */ @@ -3706,10 +3706,10 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 6 */ ".o.......o." /* 7 */ ".hooipiooh." /* 8 */ "..........." - /* 9 */ "..........." - /* 10 */ "..........." - /* 11 */ "..........." - /* 12 */ "..........." + /* 9 */ "mm.......mm" + /* 10 */ "mm.......mm" + /* 11 */ "mm.......mm" + /* 12 */ "mm.......mm" // Level 5 /* z\x* 1 */ @@ -3723,10 +3723,10 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 6 */ ".i.......i." /* 7 */ "uiiiiiiiiiu" /* 8 */ "kkkkkkkkkkk" - /* 9 */ "..........." - /* 10 */ "..........." - /* 11 */ "..........." - /* 12 */ "..........." + /* 9 */ "mm.......mm" + /* 10 */ "mm.......mm" + /* 11 */ "mm.......mm" + /* 12 */ "mm.......mm" // Level 6 /* z\x* 1 */ @@ -3740,10 +3740,10 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 6 */ "uiiiiiiiiiu" /* 7 */ "kkkkkkkkkkk" /* 8 */ "..........." - /* 9 */ "..........." - /* 10 */ "..........." - /* 11 */ "..........." - /* 12 */ "..........." + /* 9 */ "mm.......mm" + /* 10 */ "mm.......mm" + /* 11 */ "mm.......mm" + /* 12 */ "mm.......mm" // Level 7 /* z\x* 1 */ @@ -3757,10 +3757,10 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 6 */ "kkkkkkkkkkk" /* 7 */ "..........." /* 8 */ "..........." - /* 9 */ "..........." - /* 10 */ "..........." - /* 11 */ "..........." - /* 12 */ "..........." + /* 9 */ "mm.......mm" + /* 10 */ "mm.......mm" + /* 11 */ "mm.......mm" + /* 12 */ "mm.......mm" // Level 8 /* z\x* 1 */ @@ -3774,10 +3774,10 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 6 */ "..........." /* 7 */ "..........." /* 8 */ "..........." - /* 9 */ "..........." - /* 10 */ "..........." - /* 11 */ "..........." - /* 12 */ "...........", + /* 9 */ "mm.......mm" + /* 10 */ "mm.......mm" + /* 11 */ "mm.......mm" + /* 12 */ "mm.......mm", // Connectors: "-1: 5, 2, 0: 2\n" /* Type -1, direction Z- */, @@ -4237,30 +4237,29 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = // Block definitions: ".: 0: 0\n" /* air */ "a: 4: 0\n" /* cobblestone */ - "b: 2: 0\n" /* grass */ - "c: 67: 0\n" /* stairs */ - "d: 67: 2\n" /* stairs */ - "e: 67: 1\n" /* stairs */ - "f: 5: 0\n" /* wood */ - "g: 67: 3\n" /* stairs */ - "h: 17: 0\n" /* tree */ - "i: 64: 7\n" /* wooddoorblock */ - "j: 64: 5\n" /* wooddoorblock */ - "k:102: 0\n" /* glasspane */ - "l: 64:12\n" /* wooddoorblock */ + "b: 67: 0\n" /* stairs */ + "c: 67: 2\n" /* stairs */ + "d: 67: 1\n" /* stairs */ + "e: 5: 0\n" /* wood */ + "f: 67: 3\n" /* stairs */ + "g: 17: 0\n" /* tree */ + "h: 64: 7\n" /* wooddoorblock */ + "i: 64: 5\n" /* wooddoorblock */ + "j:102: 0\n" /* glasspane */ + "k: 64:12\n" /* wooddoorblock */ + "l: 53: 2\n" /* woodstairs */ "m: 19: 0\n" /* sponge */ - "n: 53: 2\n" /* woodstairs */ - "o: 53: 1\n" /* woodstairs */ - "p: 53: 7\n" /* woodstairs */ - "q: 53: 6\n" /* woodstairs */ - "r: 53: 3\n" /* woodstairs */ - "s: 53: 0\n" /* woodstairs */ - "t: 53: 5\n" /* woodstairs */ - "u: 53: 4\n" /* woodstairs */ - "v: 50: 3\n" /* torch */ - "w: 50: 2\n" /* torch */ - "x: 50: 4\n" /* torch */ - "y: 50: 1\n" /* torch */, + "n: 53: 1\n" /* woodstairs */ + "o: 53: 7\n" /* woodstairs */ + "p: 53: 6\n" /* woodstairs */ + "q: 53: 3\n" /* woodstairs */ + "r: 53: 0\n" /* woodstairs */ + "s: 53: 5\n" /* woodstairs */ + "t: 53: 4\n" /* woodstairs */ + "u: 50: 3\n" /* torch */ + "v: 50: 2\n" /* torch */ + "w: 50: 4\n" /* torch */ + "x: 50: 1\n" /* torch */, // Block data: // Level 0 @@ -4274,134 +4273,134 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 5 */ "maaaaaaaaaaaaaam" /* 6 */ "maaaaaaaaaaaaaam" /* 7 */ "maaaaaaaaaaaaaam" - /* 8 */ "bbbbbaaaaaaaaaam" - /* 9 */ "bbbbbbbbaaaaaaam" - /* 10 */ "bbbbbbbbaaaaaaam" - /* 11 */ "bbbbbbbbaaaaaaam" - /* 12 */ "bbbbbbbbaaaaaaam" - /* 13 */ "bbbbbbbbaaaaaaam" - /* 14 */ "bbbbbbbbaaaaaaam" - /* 15 */ "bbbbbbbbmmmmmmmm" + /* 8 */ "mmmmmaaaaaaaaaam" + /* 9 */ "mmmmmmmmaaaaaaam" + /* 10 */ "mmmmmmmmaaaaaaam" + /* 11 */ "mmmmmmmmaaaaaaam" + /* 12 */ "mmmmmmmmaaaaaaam" + /* 13 */ "mmmmmmmmaaaaaaam" + /* 14 */ "mmmmmmmmaaaaaaam" + /* 15 */ "mmmmmmmmmmmmmmmm" // Level 1 /* z\x* 111111 */ /* * 0123456789012345 */ - /* 0 */ "........cde....." + /* 0 */ "........bcd....." /* 1 */ ".aaaaaaaaaaaaaa." - /* 2 */ ".affffffffffffa." - /* 3 */ ".affffffffffffa." - /* 4 */ ".affffffffffffa." - /* 5 */ ".affffffffffffa." - /* 6 */ ".affffffffffffa." - /* 7 */ ".aaaaaaaafffffa." - /* 8 */ ".....cgeafffffa." - /* 9 */ "........afffffa." - /* 10 */ "........afffffa." - /* 11 */ "........afffffa." - /* 12 */ "........afffffa." - /* 13 */ "........afffffa." - /* 14 */ "........aaaaaaa." - /* 15 */ "................" + /* 2 */ ".aeeeeeeeeeeeea." + /* 3 */ ".aeeeeeeeeeeeea." + /* 4 */ ".aeeeeeeeeeeeea." + /* 5 */ ".aeeeeeeeeeeeea." + /* 6 */ ".aeeeeeeeeeeeea." + /* 7 */ ".aaaaaaaaeeeeea." + /* 8 */ ".....bfdaeeeeea." + /* 9 */ "mmmm....aeeeeea." + /* 10 */ "mmmmmmm.aeeeeea." + /* 11 */ "mmmmmmm.aeeeeea." + /* 12 */ "mmmmmmm.aeeeeea." + /* 13 */ "mmmmmmm.aeeeeea." + /* 14 */ "mmmmmmm.aaaaaaa." + /* 15 */ "mmmmmmm........." // Level 2 /* z\x* 111111 */ /* * 0123456789012345 */ /* 0 */ "................" - /* 1 */ ".hffffffhihfffh." - /* 2 */ ".f............f." - /* 3 */ ".f............f." - /* 4 */ ".f............f." - /* 5 */ ".f............f." - /* 6 */ ".f............f." - /* 7 */ ".hffffjfh.....f." - /* 8 */ "........f.....f." - /* 9 */ "........f.....f." - /* 10 */ "........f.....f." - /* 11 */ "........f.....f." - /* 12 */ "........f.....f." - /* 13 */ "........f.....f." - /* 14 */ "........hfffffh." - /* 15 */ "................" + /* 1 */ ".geeeeeeghgeeeg." + /* 2 */ ".e............e." + /* 3 */ ".e............e." + /* 4 */ ".e............e." + /* 5 */ ".e............e." + /* 6 */ ".e............e." + /* 7 */ ".geeeeieg.....e." + /* 8 */ "........e.....e." + /* 9 */ "mmmm....e.....e." + /* 10 */ "mmmmmmm.e.....e." + /* 11 */ "mmmmmmm.e.....e." + /* 12 */ "mmmmmmm.e.....e." + /* 13 */ "mmmmmmm.e.....e." + /* 14 */ "mmmmmmm.geeeeeg." + /* 15 */ "mmmmmmm........." // Level 3 /* z\x* 111111 */ /* * 0123456789012345 */ /* 0 */ "................" - /* 1 */ ".hfkkfkkhlhkkfh." - /* 2 */ ".k............f." - /* 3 */ ".k............k." - /* 4 */ ".k............k." - /* 5 */ ".k............f." - /* 6 */ ".k............k." - /* 7 */ ".hfkkflfh.....k." - /* 8 */ "........f.....f." - /* 9 */ "........k.....k." - /* 10 */ "........k.....k." - /* 11 */ "........f.....f." - /* 12 */ "........k.....k." - /* 13 */ "........k.....k." - /* 14 */ "........hkkkkkh." - /* 15 */ "................" + /* 1 */ ".gejjejjgkgjjeg." + /* 2 */ ".j............e." + /* 3 */ ".j............j." + /* 4 */ ".j............j." + /* 5 */ ".j............e." + /* 6 */ ".j............j." + /* 7 */ ".gejjekeg.....j." + /* 8 */ "........e.....e." + /* 9 */ "mmmm....j.....j." + /* 10 */ "mmmmmmm.j.....j." + /* 11 */ "mmmmmmm.e.....e." + /* 12 */ "mmmmmmm.j.....j." + /* 13 */ "mmmmmmm.j.....j." + /* 14 */ "mmmmmmm.gjjjjjg." + /* 15 */ "mmmmmmm........." // Level 4 /* z\x* 111111 */ /* * 0123456789012345 */ - /* 0 */ "nnnnnnnnnnnnnnno" - /* 1 */ "phffffffhfhfffho" - /* 2 */ ".f............fo" - /* 3 */ ".f............fo" - /* 4 */ ".f............fo" - /* 5 */ ".f............fo" - /* 6 */ ".f............fo" - /* 7 */ "qhffffffh.....fo" - /* 8 */ "rrrrrrrsf.....fo" - /* 9 */ ".......sf.....fo" - /* 10 */ ".......sf.....fo" - /* 11 */ ".......sf.....fo" - /* 12 */ ".......sf.....fo" - /* 13 */ ".......sf.....fo" - /* 14 */ ".......shfffffho" - /* 15 */ ".......st.....uo" + /* 0 */ "llllllllllllllln" + /* 1 */ "ogeeeeeegegeeegn" + /* 2 */ ".e............en" + /* 3 */ ".e............en" + /* 4 */ ".e............en" + /* 5 */ ".e............en" + /* 6 */ ".e............en" + /* 7 */ "pgeeeeeeg.....en" + /* 8 */ "qqqqqqqre.....en" + /* 9 */ "mmmm...re.....en" + /* 10 */ "mmmmmmmre.....en" + /* 11 */ "mmmmmmmre.....en" + /* 12 */ "mmmmmmmre.....en" + /* 13 */ "mmmmmmmre.....en" + /* 14 */ "mmmmmmmrgeeeeegn" + /* 15 */ "mmmmmmmrs.....tn" // Level 5 /* z\x* 111111 */ /* * 0123456789012345 */ /* 0 */ "................" - /* 1 */ "nnnnnnnnnnnnnnn." - /* 2 */ "pfffffffffffffo." - /* 3 */ ".f.........v.fo." - /* 4 */ ".f..........wfo." - /* 5 */ ".f......x....fo." - /* 6 */ "qfffffffff...fo." - /* 7 */ "rrrrrrrrsfy..fo." - /* 8 */ "........sf...fo." - /* 9 */ "........sf...fo." - /* 10 */ "........sf...fo." - /* 11 */ "........sf...fo." - /* 12 */ "........sf...fo." - /* 13 */ "........sf...fo." - /* 14 */ "........sfffffo." - /* 15 */ "........st...uo." + /* 1 */ "lllllllllllllll." + /* 2 */ "oeeeeeeeeeeeeen." + /* 3 */ ".e.........u.en." + /* 4 */ ".e..........ven." + /* 5 */ ".e......w....en." + /* 6 */ "peeeeeeeee...en." + /* 7 */ "qqqqqqqqrex..en." + /* 8 */ "........re...en." + /* 9 */ "mmmm....re...en." + /* 10 */ "mmmmmmm.re...en." + /* 11 */ "mmmmmmm.re...en." + /* 12 */ "mmmmmmm.re...en." + /* 13 */ "mmmmmmm.re...en." + /* 14 */ "mmmmmmm.reeeeen." + /* 15 */ "mmmmmmm.rs...tn." // Level 6 /* z\x* 111111 */ /* * 0123456789012345 */ /* 0 */ "................" /* 1 */ "................" - /* 2 */ "nnnnnnnnnnnnno.." - /* 3 */ "pffffffffffffo.." - /* 4 */ ".fy.........fo.." - /* 5 */ "qffffffffff.fo.." - /* 6 */ "rrrrrrrrrsf.fo.." - /* 7 */ ".........sf.fo.." - /* 8 */ ".........sf.fo.." - /* 9 */ ".........sf.fo.." - /* 10 */ ".........sf.fo.." - /* 11 */ ".........sf.fo.." - /* 12 */ ".........sf.fo.." - /* 13 */ ".........sfxfo.." - /* 14 */ ".........sfffo.." - /* 15 */ ".........st.uo.." + /* 2 */ "llllllllllllln.." + /* 3 */ "oeeeeeeeeeeeen.." + /* 4 */ ".ex.........en.." + /* 5 */ "peeeeeeeeee.en.." + /* 6 */ "qqqqqqqqqre.en.." + /* 7 */ ".........re.en.." + /* 8 */ ".........re.en.." + /* 9 */ "mmmm.....re.en.." + /* 10 */ "mmmmmmm..re.en.." + /* 11 */ "mmmmmmm..re.en.." + /* 12 */ "mmmmmmm..re.en.." + /* 13 */ "mmmmmmm..rewen.." + /* 14 */ "mmmmmmm..reeen.." + /* 15 */ "mmmmmmm..rs.tn.." // Level 7 /* z\x* 111111 */ @@ -4409,19 +4408,19 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = /* 0 */ "................" /* 1 */ "................" /* 2 */ "................" - /* 3 */ "nnnnnnnnnnnnn..." - /* 4 */ "ffffffffffffo..." - /* 5 */ "rrrrrrrrrrsfo..." - /* 6 */ "..........sfo..." - /* 7 */ "..........sfo..." - /* 8 */ "..........sfo..." - /* 9 */ "..........sfo..." - /* 10 */ "..........sfo..." - /* 11 */ "..........sfo..." - /* 12 */ "..........sfo..." - /* 13 */ "..........sfo..." - /* 14 */ "..........sfo..." - /* 15 */ "..........sfo...", + /* 3 */ "lllllllllllll..." + /* 4 */ "eeeeeeeeeeeen..." + /* 5 */ "qqqqqqqqqqren..." + /* 6 */ "..........ren..." + /* 7 */ "..........ren..." + /* 8 */ "..........ren..." + /* 9 */ "mmmm......ren..." + /* 10 */ "mmmmmmm...ren..." + /* 11 */ "mmmmmmm...ren..." + /* 12 */ "mmmmmmm...ren..." + /* 13 */ "mmmmmmm...ren..." + /* 14 */ "mmmmmmm...ren..." + /* 15 */ "mmmmmmm...ren...", // Connectors: "-1: 9, 1, 0: 2\n" /* Type -1, direction Z- */, -- cgit v1.2.3 From 5b148c30f71874d62b55a5134fd4c7897ebe106a Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Tue, 22 Jul 2014 14:44:26 +0200 Subject: Extreme Hills M variant only spawn with grass and stone Removed gravel. --- src/Generating/DistortedHeightmap.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Generating/DistortedHeightmap.cpp b/src/Generating/DistortedHeightmap.cpp index 74d30c327..1337896ab 100644 --- a/src/Generating/DistortedHeightmap.cpp +++ b/src/Generating/DistortedHeightmap.cpp @@ -759,7 +759,7 @@ void cDistortedHeightmap::ComposeColumn(cChunkDesc & a_ChunkDesc, int a_RelX, in NOISE_DATATYPE NoiseX = ((NOISE_DATATYPE)(m_CurChunkX * cChunkDef::Width + a_RelX)) / FrequencyX; NOISE_DATATYPE NoiseY = ((NOISE_DATATYPE)(m_CurChunkZ * cChunkDef::Width + a_RelZ)) / FrequencyZ; NOISE_DATATYPE Val = m_OceanFloorSelect.CubicNoise2D(NoiseX, NoiseY); - const sBlockInfo * Pattern = (Val < -0.9) ? patStone.Get() : ((Val > 0) ? patGravel.Get() : patGrass.Get()); + const sBlockInfo * Pattern = (Val < 0.0) ? patStone.Get() : patGrass.Get(); FillColumnPattern(a_ChunkDesc, a_RelX, a_RelZ, Pattern); return; } -- cgit v1.2.3 From 9045246e74e70ae711c85a88df63f007029e2849 Mon Sep 17 00:00:00 2001 From: archshift Date: Tue, 22 Jul 2014 13:02:28 -0700 Subject: Export BroadcastEntityAnimation with ToLua Fixes #752 --- src/World.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/World.h b/src/World.h index c78bc8c8c..2346ac523 100644 --- a/src/World.h +++ b/src/World.h @@ -217,7 +217,7 @@ public: void BroadcastEntityRelMoveLook (const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ, const cClientHandle * a_Exclude = NULL); void BroadcastEntityStatus (const cEntity & a_Entity, char a_Status, const cClientHandle * a_Exclude = NULL); void BroadcastEntityVelocity (const cEntity & a_Entity, const cClientHandle * a_Exclude = NULL); - virtual void BroadcastEntityAnimation(const cEntity & a_Entity, char a_Animation, const cClientHandle * a_Exclude = NULL) override; + virtual void BroadcastEntityAnimation(const cEntity & a_Entity, char a_Animation, const cClientHandle * a_Exclude = NULL) override; // tolua_export void BroadcastParticleEffect (const AString & a_ParticleName, float a_SrcX, float a_SrcY, float a_SrcZ, float a_OffsetX, float a_OffsetY, float a_OffsetZ, float a_ParticleData, int a_ParticleAmmount, cClientHandle * a_Exclude = NULL); // tolua_export void BroadcastPlayerListItem (const cPlayer & a_Player, bool a_IsOnline, const cClientHandle * a_Exclude = NULL); void BroadcastRemoveEntityEffect (const cEntity & a_Entity, int a_EffectID, const cClientHandle * a_Exclude = NULL); -- cgit v1.2.3 From bc5db3274fe101afcd9081857bd9b66c12e19906 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Tue, 22 Jul 2014 21:09:37 +0100 Subject: Fix misguided comment on bits... ...obviously written by someone very confused, also known as me --- src/Blocks/BlockSapling.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Blocks/BlockSapling.h b/src/Blocks/BlockSapling.h index e965809a3..de28273d5 100644 --- a/src/Blocks/BlockSapling.h +++ b/src/Blocks/BlockSapling.h @@ -20,7 +20,7 @@ public: virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override { - // Only the first 5 bits contain the display information, 8th bit for growth indicator (but we use 0x07 for forward compatibility) + // Only the first 2 bits contain the display information and the 4th bit is for the growth indicator, but, we use 0x07 for forward compatibility a_Pickups.push_back(cItem(E_BLOCK_SAPLING, 1, a_BlockMeta & 0x07)); } -- cgit v1.2.3 From 4044d0a6e6c586aa483ae19d986c8f12c474d057 Mon Sep 17 00:00:00 2001 From: archshift Date: Tue, 22 Jul 2014 13:10:12 -0700 Subject: Export SendEntityAnimation to ToLua --- src/ClientHandle.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ClientHandle.h b/src/ClientHandle.h index 538ecdad7..c1c4cdff9 100644 --- a/src/ClientHandle.h +++ b/src/ClientHandle.h @@ -151,7 +151,7 @@ public: void SendMapInfo (int a_ID, unsigned int a_Scale); void SendPaintingSpawn (const cPainting & a_Painting); void SendPickupSpawn (const cPickup & a_Pickup); - void SendEntityAnimation (const cEntity & a_Entity, char a_Animation); + void SendEntityAnimation (const cEntity & a_Entity, char a_Animation); // tolua_export void SendParticleEffect (const AString & a_ParticleName, float a_SrcX, float a_SrcY, float a_SrcZ, float a_OffsetX, float a_OffsetY, float a_OffsetZ, float a_ParticleData, int a_ParticleAmmount); void SendPlayerAbilities (void); void SendPlayerListItem (const cPlayer & a_Player, bool a_IsOnline); -- cgit v1.2.3 From e171285408028e858ec3a921bbfd97e8a5dcf6ca Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 22 Jul 2014 23:29:04 +0200 Subject: Fixed Bindings generation in MSVC. The bindings weren't regenerated because of the typo in the dependencies cmake variable. --- src/Bindings/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Bindings/CMakeLists.txt b/src/Bindings/CMakeLists.txt index 95b858f5d..2ea2fa8c0 100644 --- a/src/Bindings/CMakeLists.txt +++ b/src/Bindings/CMakeLists.txt @@ -39,7 +39,7 @@ set (BINDING_OUTPUTS ${CMAKE_CURRENT_SOURCE_DIR}/LuaState_Call.inc ) -set(BINDING_DEPENDECIES +set(BINDING_DEPENDENCIES tolua ../Bindings/virtual_method_hooks.lua ../Bindings/AllToLua.pkg @@ -122,7 +122,7 @@ if (NOT MSVC) WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} # add any new generation dependencies here - DEPENDS ${BINDING_DEPENDECIES} + DEPENDS ${BINDING_DEPENDENCIES} ) endif () set_source_files_properties(Bindings/Bindings.cpp PROPERTIES GENERATED TRUE) -- cgit v1.2.3 From ba8cb3b0a69be8db848e1feac4b05edb7953b1c6 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 22 Jul 2014 23:33:08 +0200 Subject: Fixed MSVC bindings regeneration. Still one typo had been left in the cmake file. --- src/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f494b52e5..b8780e8a6 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -265,7 +265,7 @@ if (MSVC) WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/ # add any new generation dependencies here - DEPENDS ${BINDING_DEPENDECIES} + DEPENDS ${BINDING_DEPENDENCIES} ) endif() -- cgit v1.2.3 From dfadcf745384f574e751e78bc3e2ddb262fe1fdf Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Wed, 23 Jul 2014 09:11:42 +0200 Subject: BlockLeaves: Fixed comment style. --- src/Blocks/BlockLeaves.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Blocks/BlockLeaves.h b/src/Blocks/BlockLeaves.h index 1635eba08..e426c89e0 100644 --- a/src/Blocks/BlockLeaves.h +++ b/src/Blocks/BlockLeaves.h @@ -40,14 +40,14 @@ public: { cFastRandom rand; - // Only the first 2 bits contain the display information, the others are for growing + // Old leaves - 3 bits contain display; new leaves - 1st bit, shifted left two for saplings to understand if (rand.NextInt(6) == 0) { a_Pickups.push_back( cItem( E_BLOCK_SAPLING, 1, - (m_BlockType == E_BLOCK_LEAVES) ? (a_BlockMeta & 0x03) : (2 << (a_BlockMeta & 0x01)) // Old leaves - 3 bits contain display; new leaves - 1st bit, shifted left two for saplings to understand + (m_BlockType == E_BLOCK_LEAVES) ? (a_BlockMeta & 0x03) : (2 << (a_BlockMeta & 0x01)) ) ); } -- cgit v1.2.3 From 9080f14dc2a1010d4169ba690c4bda8da1188ae9 Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Wed, 23 Jul 2014 11:02:42 +0200 Subject: Fixed possible crash in the NetherClumpFoliage finisher. --- src/Generating/FinishGen.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Generating/FinishGen.cpp b/src/Generating/FinishGen.cpp index 444af5022..c67cc574e 100644 --- a/src/Generating/FinishGen.cpp +++ b/src/Generating/FinishGen.cpp @@ -125,6 +125,11 @@ void cFinishGenNetherClumpFoliage::TryPlaceClump(cChunkDesc & a_ChunkDesc, int a float zz = (float) a_ChunkDesc.GetChunkZ() * cChunkDef::Width + z; for (int y = a_RelY - 2; y < a_RelY + 2; y++) { + if ((y < 1) || (y > cChunkDef::Height)) + { + continue; + } + if (a_ChunkDesc.GetBlockType(x, y, z) != E_BLOCK_AIR) // Don't replace non air blocks. { continue; -- cgit v1.2.3 From 7e38c123fcce1956f04aec2a57ee86c882e7840a Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Wed, 23 Jul 2014 11:23:35 +0200 Subject: TallGrass: Less grass on mountains. --- src/Generating/FinishGen.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/Generating/FinishGen.h b/src/Generating/FinishGen.h index a8a0e1e3b..810bb4a91 100644 --- a/src/Generating/FinishGen.h +++ b/src/Generating/FinishGen.h @@ -94,6 +94,17 @@ protected: { return 70; } + + case biExtremeHillsEdge: + case biExtremeHillsPlus: + case biExtremeHills: + case biExtremeHillsPlusM: + case biExtremeHillsM: + case biIceMountains: + { + return 3; + } + default: { return 20; -- cgit v1.2.3 From 997a643977ea901a3cd3a3d1d7171d65b82a828c Mon Sep 17 00:00:00 2001 From: tonibm19 Date: Wed, 23 Jul 2014 20:28:56 +0200 Subject: Moar view distance! Let's blow up our computers! :D --- src/ClientHandle.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ClientHandle.h b/src/ClientHandle.h index c1c4cdff9..50ed596d5 100644 --- a/src/ClientHandle.h +++ b/src/ClientHandle.h @@ -56,8 +56,8 @@ public: #else static const int DEFAULT_VIEW_DISTANCE = 10; #endif - static const int MAX_VIEW_DISTANCE = 15; - static const int MIN_VIEW_DISTANCE = 3; + static const int MAX_VIEW_DISTANCE = 32; + static const int MIN_VIEW_DISTANCE = 1; cClientHandle(const cSocket * a_Socket, int a_ViewDistance); virtual ~cClientHandle(); -- cgit v1.2.3 From 9678341a11caa08a40c3ddb562d893fc0cd2ba73 Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Thu, 24 Jul 2014 12:15:48 +0200 Subject: Made the cWorld::SpawnMobFinalize function more readable. --- src/World.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/World.cpp b/src/World.cpp index 4ddd11f59..104805209 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -2975,21 +2975,31 @@ int cWorld::SpawnMob(double a_PosX, double a_PosY, double a_PosZ, cMonster::eTyp int cWorld::SpawnMobFinalize(cMonster * a_Monster) { + // Invalid cMonster object. Bail out. if (!a_Monster) + { return -1; + } + + // Give the mob full health. a_Monster->SetHealth(a_Monster->GetMaxHealth()); + + // A plugin doesn't agree with the spawn. bail out. if (cPluginManager::Get()->CallHookSpawningMonster(*this, *a_Monster)) { delete a_Monster; a_Monster = NULL; return -1; } + + // Initialize the monster into the current world. if (!a_Monster->Initialize(*this)) { delete a_Monster; a_Monster = NULL; return -1; } + BroadcastSpawnEntity(*a_Monster); cPluginManager::Get()->CallHookSpawnedMonster(*this, *a_Monster); -- cgit v1.2.3 From c0b62ef139a65ca648135fb6999e6623438fdd71 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 24 Jul 2014 18:32:05 +0200 Subject: Added a queue for setting chunk data. Fixes #1196. --- src/CMakeLists.txt | 2 + src/Chunk.cpp | 40 ++++++-------- src/Chunk.h | 14 ++--- src/ChunkMap.cpp | 25 +++------ src/ChunkMap.h | 20 ++----- src/SetChunkData.cpp | 115 ++++++++++++++++++++++++++++++++++++++ src/SetChunkData.h | 120 ++++++++++++++++++++++++++++++++++++++++ src/World.cpp | 85 +++++++++++++++++----------- src/World.h | 36 ++++++------ src/WorldStorage/WSSAnvil.cpp | 5 +- src/WorldStorage/WSSCompact.cpp | 5 +- 11 files changed, 349 insertions(+), 118 deletions(-) create mode 100644 src/SetChunkData.cpp create mode 100644 src/SetChunkData.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b8780e8a6..29337cb2e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -56,6 +56,7 @@ SET (SRCS Root.cpp Scoreboard.cpp Server.cpp + SetChunkData.cpp Statistics.cpp StringCompression.cpp StringUtils.cpp @@ -124,6 +125,7 @@ SET (HDRS Root.h Scoreboard.h Server.h + SetChunkData.h StackWalker.h Statistics.h StringCompression.h diff --git a/src/Chunk.cpp b/src/Chunk.cpp index 60987b070..10bc2ff23 100644 --- a/src/Chunk.cpp +++ b/src/Chunk.cpp @@ -34,6 +34,7 @@ #include "MobCensus.h" #include "MobSpawner.h" #include "BlockInServerPluginInterface.h" +#include "SetChunkData.h" #include "json/json.h" @@ -265,41 +266,34 @@ void cChunk::GetAllData(cChunkDataCallback & a_Callback) -void cChunk::SetAllData( - const BLOCKTYPE * a_BlockTypes, - const NIBBLETYPE * a_BlockMeta, - const NIBBLETYPE * a_BlockLight, - const NIBBLETYPE * a_BlockSkyLight, - const HeightMap * a_HeightMap, - const BiomeMap & a_BiomeMap, - cBlockEntityList & a_BlockEntities -) +void cChunk::SetAllData(cSetChunkData & a_SetChunkData) { - memcpy(m_BiomeMap, a_BiomeMap, sizeof(m_BiomeMap)); + ASSERT(a_SetChunkData.IsHeightMapValid()); + ASSERT(a_SetChunkData.AreBiomesValid()); + + memcpy(m_BiomeMap, a_SetChunkData.GetBiomes(), sizeof(m_BiomeMap)); + memcpy(m_HeightMap, a_SetChunkData.GetHeightMap(), sizeof(m_HeightMap)); - if (a_HeightMap != NULL) + m_ChunkData.SetBlockTypes(a_SetChunkData.GetBlockTypes()); + m_ChunkData.SetMetas(a_SetChunkData.GetBlockMetas()); + if (a_SetChunkData.IsLightValid()) { - memcpy(m_HeightMap, a_HeightMap, sizeof(m_HeightMap)); + m_ChunkData.SetBlockLight(a_SetChunkData.GetBlockLight()); + m_ChunkData.SetSkyLight(a_SetChunkData.GetSkyLight()); + m_IsLightValid = true; } - - if (a_HeightMap == NULL) + else { - CalculateHeightmap(a_BlockTypes); + m_IsLightValid = false; } - m_ChunkData.SetBlockTypes(a_BlockTypes); - m_ChunkData.SetMetas(a_BlockMeta); - m_ChunkData.SetBlockLight(a_BlockLight); - m_ChunkData.SetSkyLight(a_BlockSkyLight); - - m_IsLightValid = (a_BlockLight != NULL) && (a_BlockSkyLight != NULL); - // Clear the block entities present - either the loader / saver has better, or we'll create empty ones: for (cBlockEntityList::iterator itr = m_BlockEntities.begin(); itr != m_BlockEntities.end(); ++itr) { delete *itr; } - std::swap(a_BlockEntities, m_BlockEntities); + m_BlockEntities.clear(); + std::swap(a_SetChunkData.GetBlockEntities(), m_BlockEntities); // Set all block entities' World variable: for (cBlockEntityList::iterator itr = m_BlockEntities.begin(); itr != m_BlockEntities.end(); ++itr) diff --git a/src/Chunk.h b/src/Chunk.h index 9ab39a0a2..5d50f9717 100644 --- a/src/Chunk.h +++ b/src/Chunk.h @@ -95,16 +95,10 @@ public: /** Gets all chunk data, calls the a_Callback's methods for each data type */ void GetAllData(cChunkDataCallback & a_Callback); - /** Sets all chunk data */ - void SetAllData( - const BLOCKTYPE * a_BlockTypes, - const NIBBLETYPE * a_BlockMeta, - const NIBBLETYPE * a_BlockLight, - const NIBBLETYPE * a_BlockSkyLight, - const cChunkDef::HeightMap * a_HeightMap, - const cChunkDef::BiomeMap & a_BiomeMap, - cBlockEntityList & a_BlockEntities - ); + /** Sets all chunk data as either loaded from the storage or generated. + BlockLight and BlockSkyLight are optional, if not present, chunk will be marked as unlighted. + Modifies the BlockEntity list in a_SetChunkData - moves the block entities into the chunk. */ + void SetAllData(cSetChunkData & a_SetChunkData); void SetLight( const cChunkDef::BlockNibbles & a_BlockLight, diff --git a/src/ChunkMap.cpp b/src/ChunkMap.cpp index 3ef981e94..05d219918 100644 --- a/src/ChunkMap.cpp +++ b/src/ChunkMap.cpp @@ -16,6 +16,7 @@ #include "MobCensus.h" #include "MobSpawner.h" #include "BoundingBox.h" +#include "SetChunkData.h" #include "Entities/Pickup.h" @@ -912,28 +913,20 @@ void cChunkMap::MarkChunkSaved (int a_ChunkX, int a_ChunkZ) -void cChunkMap::SetChunkData( - int a_ChunkX, int a_ChunkZ, - const BLOCKTYPE * a_BlockTypes, - const NIBBLETYPE * a_BlockMeta, - const NIBBLETYPE * a_BlockLight, - const NIBBLETYPE * a_BlockSkyLight, - const cChunkDef::HeightMap * a_HeightMap, - const cChunkDef::BiomeMap & a_BiomeMap, - cBlockEntityList & a_BlockEntities, - bool a_MarkDirty -) +void cChunkMap::SetChunkData(cSetChunkData & a_SetChunkData) { + int ChunkX = a_SetChunkData.GetChunkX(); + int ChunkZ = a_SetChunkData.GetChunkZ(); { cCSLock Lock(m_CSLayers); - cChunkPtr Chunk = GetChunkNoLoad(a_ChunkX, ZERO_CHUNK_Y, a_ChunkZ); + cChunkPtr Chunk = GetChunkNoLoad(ChunkX, ZERO_CHUNK_Y, ChunkZ); if (Chunk == NULL) { return; } - Chunk->SetAllData(a_BlockTypes, a_BlockMeta, a_BlockLight, a_BlockSkyLight, a_HeightMap, a_BiomeMap, a_BlockEntities); + Chunk->SetAllData(a_SetChunkData); - if (a_MarkDirty) + if (a_SetChunkData.ShouldMarkDirty()) { Chunk->MarkDirty(); } @@ -942,7 +935,7 @@ void cChunkMap::SetChunkData( cChunkStays ToBeDisabled; for (cChunkStays::iterator itr = m_ChunkStays.begin(), end = m_ChunkStays.end(); itr != end; ++itr) { - if ((*itr)->ChunkAvailable(a_ChunkX, a_ChunkZ)) + if ((*itr)->ChunkAvailable(ChunkX, ChunkZ)) { // The chunkstay wants to be disabled, add it to a list of to-be-disabled chunkstays for later processing: ToBeDisabled.push_back(*itr); @@ -957,7 +950,7 @@ void cChunkMap::SetChunkData( } // Notify plugins of the chunk becoming available - cPluginManager::Get()->CallHookChunkAvailable(m_World, a_ChunkX, a_ChunkZ); + cPluginManager::Get()->CallHookChunkAvailable(m_World, ChunkX, ChunkZ); } diff --git a/src/ChunkMap.h b/src/ChunkMap.h index 4be1a4752..e33d9f894 100644 --- a/src/ChunkMap.h +++ b/src/ChunkMap.h @@ -34,6 +34,7 @@ class cChunkDataSerializer; class cBlockArea; class cMobCensus; class cMobSpawner; +class cSetChunkData; typedef std::list cClientHandleList; typedef cChunk * cChunkPtr; @@ -112,22 +113,11 @@ public: void MarkChunkSaved (int a_ChunkX, int a_ChunkZ); /** Sets the chunk data as either loaded from the storage or generated. - a_BlockLight and a_BlockSkyLight are optional, if not present, chunk will be marked as unlighted. - a_BiomeMap is optional, if not present, biomes will be calculated by the generator - a_HeightMap is optional, if not present, will be calculated. - If a_MarkDirty is set, the chunk is set as dirty (used after generating) + BlockLight and BlockSkyLight are optional, if not present, chunk will be marked as unlighted. + If MarkDirty is set, the chunk is set as dirty (used after generating) + Modifies the BlockEntity list in a_SetChunkData - moves the block entities into the chunk. */ - void SetChunkData( - int a_ChunkX, int a_ChunkZ, - const BLOCKTYPE * a_BlockTypes, - const NIBBLETYPE * a_BlockMeta, - const NIBBLETYPE * a_BlockLight, - const NIBBLETYPE * a_BlockSkyLight, - const cChunkDef::HeightMap * a_HeightMap, - const cChunkDef::BiomeMap & a_BiomeMap, - cBlockEntityList & a_BlockEntities, - bool a_MarkDirty - ); + void SetChunkData(cSetChunkData & a_SetChunkData); void ChunkLighted( int a_ChunkX, int a_ChunkZ, diff --git a/src/SetChunkData.cpp b/src/SetChunkData.cpp new file mode 100644 index 000000000..6e0c2733e --- /dev/null +++ b/src/SetChunkData.cpp @@ -0,0 +1,115 @@ + +// SetChunkData.cpp + +// Implements the cSetChunkData class used for sending loaded / generated chunk + +#include "Globals.h" +#include "SetChunkData.h" + + + + + +cSetChunkData::cSetChunkData(int a_ChunkX, int a_ChunkZ, bool a_ShouldMarkDirty) : + m_ChunkX(a_ChunkX), + m_ChunkZ(a_ChunkZ), + m_ShouldMarkDirty(a_ShouldMarkDirty) +{ +} + + + + + +cSetChunkData::cSetChunkData( + int a_ChunkX, int a_ChunkZ, + const BLOCKTYPE * a_BlockTypes, + const NIBBLETYPE * a_BlockMetas, + const NIBBLETYPE * a_BlockLight, + const NIBBLETYPE * a_SkyLight, + const cChunkDef::HeightMap * a_HeightMap, + const cChunkDef::BiomeMap * a_Biomes, + cEntityList & a_Entities, + cBlockEntityList & a_BlockEntities, + bool a_ShouldMarkDirty +) : + m_ChunkX(a_ChunkX), + m_ChunkZ(a_ChunkZ), + m_ShouldMarkDirty(a_ShouldMarkDirty) +{ + // Check the params' validity: + ASSERT(a_BlockTypes != NULL); + ASSERT(a_BlockMetas != NULL); + ASSERT(a_Biomes != NULL); + + // Copy block types and metas: + memcpy(m_BlockTypes, a_BlockTypes, sizeof(cChunkDef::BlockTypes)); + memcpy(m_BlockMetas, a_BlockMetas, sizeof(cChunkDef::BlockNibbles)); + + // Copy lights, if both given: + if ((a_BlockLight != NULL) && (a_SkyLight != NULL)) + { + memcpy(m_BlockLight, a_BlockLight, sizeof(m_BlockLight)); + memcpy(m_SkyLight, a_SkyLight, sizeof(m_SkyLight)); + m_IsLightValid = true; + } + else + { + m_IsLightValid = false; + } + + // Copy the heightmap, if available: + if (a_HeightMap != NULL) + { + memcpy(m_HeightMap, a_HeightMap, sizeof(m_HeightMap)); + m_IsHeightMapValid = true; + } + else + { + m_IsHeightMapValid = false; + } + + // Copy biomes, if available: + if (a_Biomes != NULL) + { + memcpy(m_Biomes, a_Biomes, sizeof(m_Biomes)); + m_AreBiomesValid = true; + } + else + { + m_AreBiomesValid = false; + } + + // Move entities and blockentities: + std::swap(m_Entities, a_Entities); + std::swap(m_BlockEntities, a_BlockEntities); +} + + + + + +void cSetChunkData::CalculateHeightMap(void) +{ + for (int x = 0; x < cChunkDef::Width; x++) + { + for (int z = 0; z < cChunkDef::Width; z++) + { + for (int y = cChunkDef::Height - 1; y > -1; y--) + { + int index = cChunkDef::MakeIndexNoCheck(x, y, z); + if (m_BlockTypes[index] != E_BLOCK_AIR) + { + m_HeightMap[x + z * cChunkDef::Width] = (HEIGHTTYPE)y; + break; + } + } // for y + } // for z + } // for x + m_IsHeightMapValid = true; +} + + + + + diff --git a/src/SetChunkData.h b/src/SetChunkData.h new file mode 100644 index 000000000..a2f776f6b --- /dev/null +++ b/src/SetChunkData.h @@ -0,0 +1,120 @@ + +// SetChunkData.h + +// Declares the cSetChunkData class used for sending loaded / generated chunk data into cWorld + + + + + +#pragma once + + + + + +class cSetChunkData +{ +public: + /** Constructs a new instance with empty data. + Allocates new buffers for the block data. + Prefer to use this constructor, then fill the object with data and then send it to cWorld, as this will + reduce the copying required to queue the set operation. */ + cSetChunkData(int a_ChunkX, int a_ChunkZ, bool a_ShouldMarkDirty); + + /** Constructs a new instance based on data existing elsewhere, will copy all the memory. Prefer to use the + other constructor as much as possible. + Will move the entity and blockentity lists into the internal storage, and empty the a_Entities and + a_BlockEntities lists. + a_BlockTypes and a_BlockMetas must always be valid. + If either of the light arrays are NULL, the chunk data will be marked as not having any light at all and + will be scheduled for re-lighting once it is set into the chunkmap. + If a_Biomes is not valid, the internal flag is set and the world will calculate the biomes using the chunk + generator when setting the chunk data. + If a_HeightMap is not assigned, the world will calculate the heightmap based on the blocktypes when setting + the chunk data. */ + cSetChunkData( + int a_ChunkX, int a_ChunkZ, + const BLOCKTYPE * a_BlockTypes, + const NIBBLETYPE * a_BlockMetas, + const NIBBLETYPE * a_BlockLight, + const NIBBLETYPE * a_SkyLight, + const cChunkDef::HeightMap * a_HeightMap, + const cChunkDef::BiomeMap * a_Biomes, + cEntityList & a_Entities, + cBlockEntityList & a_BlockEntities, + bool a_ShouldMarkDirty + ); + + int GetChunkX(void) const { return m_ChunkX; } + int GetChunkZ(void) const { return m_ChunkZ; } + + /** Returns the internal storage of the block types, read-only. */ + const cChunkDef::BlockTypes & GetBlockTypes(void) const { return m_BlockTypes; } + + /** Returns the internal storage of the block types, read-only. */ + const cChunkDef::BlockNibbles & GetBlockMetas(void) const { return m_BlockMetas; } + + /** Returns the internal storage of the block light, read-only. */ + const cChunkDef::BlockNibbles & GetBlockLight(void) const { return m_BlockLight; } + + /** Returns the internal storage of the block types, read-only. */ + const cChunkDef::BlockNibbles & GetSkyLight(void) const { return m_SkyLight; } + + /** Returns the internal storage for heightmap, read-only. */ + const cChunkDef::HeightMap & GetHeightMap(void) const { return m_HeightMap; } + + /** Returns the internal storage for biomes, read-write. */ + cChunkDef::BiomeMap & GetBiomes(void) { return m_Biomes; } + + /** Returns the internal storage for entities, read-write. */ + cEntityList & GetEntities(void) { return m_Entities; } + + /** Returns the internal storage for block entities, read-write. */ + cBlockEntityList & GetBlockEntities(void) { return m_BlockEntities; } + + /** Returns whether both light arrays stored in this object are valid. */ + bool IsLightValid(void) const { return m_IsLightValid; } + + /** Returns whether the heightmap stored in this object is valid. */ + bool IsHeightMapValid(void) const { return m_IsHeightMapValid; } + + /** Returns whether the biomes stored in this object are valid. */ + bool AreBiomesValid(void) const { return m_AreBiomesValid; } + + /** Returns whether the chunk should be marked as dirty after its data is set. + Used by the generator to save chunks after generating. */ + bool ShouldMarkDirty(void) const { return m_ShouldMarkDirty; } + + /** Marks the biomes stored in this object as valid. */ + void MarkBiomesValid(void) { m_AreBiomesValid = true; } + + /** Calculates the heightmap based on the contained blocktypes and marks it valid. */ + void CalculateHeightMap(void); + +protected: + int m_ChunkX; + int m_ChunkZ; + + cChunkDef::BlockTypes m_BlockTypes; + cChunkDef::BlockNibbles m_BlockMetas; + cChunkDef::BlockNibbles m_BlockLight; + cChunkDef::BlockNibbles m_SkyLight; + cChunkDef::HeightMap m_HeightMap; + cChunkDef::BiomeMap m_Biomes; + cEntityList m_Entities; + cBlockEntityList m_BlockEntities; + + bool m_IsLightValid; + bool m_IsHeightMapValid; + bool m_AreBiomesValid; + bool m_ShouldMarkDirty; +}; + +typedef SharedPtr cSetChunkDataPtr; // TODO: Change to unique_ptr once we go C++11 +typedef std::vector cSetChunkDataPtrs; + + + + + diff --git a/src/World.cpp b/src/World.cpp index 104805209..7ad350e24 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -11,6 +11,7 @@ #include "ChunkMap.h" #include "Generating/ChunkDesc.h" #include "OSSupport/Timer.h" +#include "SetChunkData.h" // Serializers #include "WorldStorage/ScoreboardSerializer.h" @@ -719,6 +720,17 @@ void cWorld::Tick(float a_Dt, int a_LastTickDurationMSec) // Call the plugins cPluginManager::Get()->CallHookWorldTick(*this, a_Dt, a_LastTickDurationMSec); + // Set any chunk data that has been queued for setting: + cSetChunkDataPtrs SetChunkDataQueue; + { + cCSLock Lock(m_CSSetChunkDataQueue); + std::swap(SetChunkDataQueue, m_SetChunkDataQueue); + } + for (cSetChunkDataPtrs::iterator itr = SetChunkDataQueue.begin(), end = SetChunkDataQueue.end(); itr != end; ++itr) + { + SetChunkData(**itr); + } // for itr - SetChunkDataQueue[] + // We need sub-tick precision here, that's why we store the time in seconds and calculate ticks off of it m_WorldAgeSecs += (double)a_Dt / 1000.0; m_TimeOfDaySecs += (double)a_Dt / 1000.0; @@ -2217,47 +2229,59 @@ void cWorld::MarkChunkSaved (int a_ChunkX, int a_ChunkZ) -void cWorld::SetChunkData( - int a_ChunkX, int a_ChunkZ, - const BLOCKTYPE * a_BlockTypes, - const NIBBLETYPE * a_BlockMeta, - const NIBBLETYPE * a_BlockLight, - const NIBBLETYPE * a_BlockSkyLight, - const cChunkDef::HeightMap * a_HeightMap, - const cChunkDef::BiomeMap * a_BiomeMap, - cEntityList & a_Entities, - cBlockEntityList & a_BlockEntities, - bool a_MarkDirty -) +void cWorld::QueueSetChunkData(const cSetChunkDataPtr & a_SetChunkData) { // Validate biomes, if needed: - cChunkDef::BiomeMap BiomeMap; - const cChunkDef::BiomeMap * Biomes = a_BiomeMap; - if (a_BiomeMap == NULL) + if (!a_SetChunkData->AreBiomesValid()) { // The biomes are not assigned, get them from the generator: - Biomes = &BiomeMap; - m_Generator.GenerateBiomes(a_ChunkX, a_ChunkZ, BiomeMap); + m_Generator.GenerateBiomes(a_SetChunkData->GetChunkX(), a_SetChunkData->GetChunkZ(), a_SetChunkData->GetBiomes()); + a_SetChunkData->MarkBiomesValid(); } - m_ChunkMap->SetChunkData( - a_ChunkX, a_ChunkZ, - a_BlockTypes, a_BlockMeta, a_BlockLight, a_BlockSkyLight, - a_HeightMap, *Biomes, - a_BlockEntities, - a_MarkDirty - ); + // Validate heightmap, if needed: + if (!a_SetChunkData->IsHeightMapValid()) + { + a_SetChunkData->CalculateHeightMap(); + } + + // Store a copy of the data in the queue: + // TODO: If the queue is too large, wait for it to get processed. Not likely, though. + cCSLock Lock(m_CSSetChunkDataQueue); + m_SetChunkDataQueue.push_back(a_SetChunkData); +} + + + + + +void cWorld::SetChunkData(cSetChunkData & a_SetChunkData) +{ + ASSERT(a_SetChunkData.AreBiomesValid()); + ASSERT(a_SetChunkData.IsHeightMapValid()); + + m_ChunkMap->SetChunkData(a_SetChunkData); // Initialize the entities (outside the m_ChunkMap's CS, to fix FS #347): - for (cEntityList::iterator itr = a_Entities.begin(), end = a_Entities.end(); itr != end; ++itr) + cEntityList Entities; + std::swap(a_SetChunkData.GetEntities(), Entities); + for (cEntityList::iterator itr = Entities.begin(), end = Entities.end(); itr != end; ++itr) { (*itr)->Initialize(*this); } // If a client is requesting this chunk, send it to them: - if (m_ChunkMap->HasChunkAnyClients(a_ChunkX, a_ChunkZ)) + int ChunkX = a_SetChunkData.GetChunkX(); + int ChunkZ = a_SetChunkData.GetChunkZ(); + if (m_ChunkMap->HasChunkAnyClients(ChunkX, ChunkZ)) + { + m_ChunkSender.ChunkReady(ChunkX, ChunkZ); + } + + // Save the chunk right after generating, so that we don't have to generate it again on next run + if (a_SetChunkData.ShouldMarkDirty()) { - m_ChunkSender.ChunkReady(a_ChunkX, a_ChunkZ); + m_Storage.QueueSaveChunk(ChunkX, 0, ChunkZ); } } @@ -3295,17 +3319,14 @@ void cWorld::cChunkGeneratorCallbacks::OnChunkGenerated(cChunkDesc & a_ChunkDesc cChunkDef::BlockNibbles BlockMetas; a_ChunkDesc.CompressBlockMetas(BlockMetas); - m_World->SetChunkData( + m_World->QueueSetChunkData(cSetChunkDataPtr(new cSetChunkData( a_ChunkDesc.GetChunkX(), a_ChunkDesc.GetChunkZ(), a_ChunkDesc.GetBlockTypes(), BlockMetas, NULL, NULL, // We don't have lighting, chunk will be lighted when needed &a_ChunkDesc.GetHeightMap(), &a_ChunkDesc.GetBiomeMap(), a_ChunkDesc.GetEntities(), a_ChunkDesc.GetBlockEntities(), true - ); - - // Save the chunk right after generating, so that we don't have to generate it again on next run - m_World->GetStorage().QueueSaveChunk(a_ChunkDesc.GetChunkX(), 0, a_ChunkDesc.GetChunkZ()); + ))); } diff --git a/src/World.h b/src/World.h index 2346ac523..6613b495a 100644 --- a/src/World.h +++ b/src/World.h @@ -49,9 +49,14 @@ class cNoteEntity; class cMobHeadEntity; class cCompositeChat; class cCuboid; +class cSetChunkData; + typedef std::list< cPlayer * > cPlayerList; +typedef SharedPtr cSetChunkDataPtr; // TODO: Change to unique_ptr once we go C++11 +typedef std::vector cSetChunkDataPtrs; + typedef cItemCallback cPlayerListCallback; typedef cItemCallback cEntityCallback; typedef cItemCallback cChestCallback; @@ -246,24 +251,9 @@ public: void MarkChunkSaving(int a_ChunkX, int a_ChunkZ); void MarkChunkSaved (int a_ChunkX, int a_ChunkZ); - /** Sets the chunk data as either loaded from the storage or generated. - a_BlockLight and a_BlockSkyLight are optional, if not present, chunk will be marked as unlighted. - a_BiomeMap is optional, if not present, biomes will be calculated by the generator - a_HeightMap is optional, if not present, will be calculated. - If a_MarkDirty is set, the chunk is set as dirty (used after generating) - */ - void SetChunkData( - int a_ChunkX, int a_ChunkZ, - const BLOCKTYPE * a_BlockTypes, - const NIBBLETYPE * a_BlockMeta, - const NIBBLETYPE * a_BlockLight, - const NIBBLETYPE * a_BlockSkyLight, - const cChunkDef::HeightMap * a_HeightMap, - const cChunkDef::BiomeMap * a_BiomeMap, - cEntityList & a_Entities, - cBlockEntityList & a_BlockEntities, - bool a_MarkDirty - ); + /** Puts the chunk data into a queue to be set into the chunkmap in the tick thread. + If the chunk data doesn't contain valid biomes, the biomes are calculated before adding the data into the queue. */ + void QueueSetChunkData(const cSetChunkDataPtr & a_SetChunkData); void ChunkLighted( int a_ChunkX, int a_ChunkZ, @@ -969,6 +959,12 @@ private: /** List of players that are scheduled for adding, waiting for the Tick thread to add them. */ cPlayerList m_PlayersToAdd; + + /** CS protecting m_SetChunkDataQueue. */ + cCriticalSection m_CSSetChunkDataQueue; + + /** Queue for the chunk data to be set into m_ChunkMap by the tick thread. Protected by m_CSSetChunkDataQueue */ + cSetChunkDataPtrs m_SetChunkDataQueue; cWorld(const AString & a_WorldName); @@ -1011,6 +1007,10 @@ private: /** Adds the players queued in the m_PlayersToAdd queue into the m_Players list. Assumes it is called from the Tick thread. */ void AddQueuedPlayers(void); + + /** Sets the specified chunk data into the chunkmap. Called in the tick thread. + Modifies the a_SetChunkData - moves the entities contained in it into the chunk. */ + void SetChunkData(cSetChunkData & a_SetChunkData); }; // tolua_export diff --git a/src/WorldStorage/WSSAnvil.cpp b/src/WorldStorage/WSSAnvil.cpp index 663d489bc..2851647fe 100644 --- a/src/WorldStorage/WSSAnvil.cpp +++ b/src/WorldStorage/WSSAnvil.cpp @@ -14,6 +14,7 @@ #include "../Item.h" #include "../ItemGrid.h" #include "../StringCompression.h" +#include "../SetChunkData.h" #include "../BlockEntities/ChestEntity.h" #include "../BlockEntities/CommandBlockEntity.h" @@ -391,7 +392,7 @@ bool cWSSAnvil::LoadChunkFromNBT(const cChunkCoords & a_Chunk, const cParsedNBT } // for y //*/ - m_World->SetChunkData( + m_World->QueueSetChunkData(cSetChunkDataPtr(new cSetChunkData( a_Chunk.m_ChunkX, a_Chunk.m_ChunkZ, BlockTypes, MetaData, IsLightValid ? BlockLight : NULL, @@ -399,7 +400,7 @@ bool cWSSAnvil::LoadChunkFromNBT(const cChunkCoords & a_Chunk, const cParsedNBT NULL, Biomes, Entities, BlockEntities, false - ); + ))); return true; } diff --git a/src/WorldStorage/WSSCompact.cpp b/src/WorldStorage/WSSCompact.cpp index 5382a3e01..ee47047a0 100644 --- a/src/WorldStorage/WSSCompact.cpp +++ b/src/WorldStorage/WSSCompact.cpp @@ -18,6 +18,7 @@ #include "../BlockEntities/MobHeadEntity.h" #include "../BlockEntities/NoteEntity.h" #include "../BlockEntities/SignEntity.h" +#include "../SetChunkData.h" @@ -911,7 +912,7 @@ bool cWSSCompact::LoadChunkFromData(const cChunkCoords & a_Chunk, int a_Uncompre NIBBLETYPE * BlockLight = (NIBBLETYPE *)(BlockData + LightOffset); NIBBLETYPE * SkyLight = (NIBBLETYPE *)(BlockData + SkyLightOffset); - a_World->SetChunkData( + a_World->QueueSetChunkData(cSetChunkDataPtr(new cSetChunkData( a_Chunk.m_ChunkX, a_Chunk.m_ChunkZ, BlockData, MetaData, IsLightValid ? BlockLight : NULL, @@ -919,7 +920,7 @@ bool cWSSCompact::LoadChunkFromData(const cChunkCoords & a_Chunk, int a_Uncompre NULL, NULL, Entities, BlockEntities, false - ); + ))); return true; } -- cgit v1.2.3 From 4191be7ddba820af4ed0c505a8d62416c2b7a8b4 Mon Sep 17 00:00:00 2001 From: archshift Date: Tue, 22 Jul 2014 15:36:13 -0700 Subject: Removed redundant semicolons and re-added warning --- SetFlags.cmake | 14 +++++++------- src/Bindings/Plugin.h | 4 ++-- src/BlockEntities/BlockEntity.h | 4 ++-- src/BlockEntities/JukeboxEntity.h | 2 +- src/BlockEntities/NoteEntity.h | 2 +- src/Blocks/BlockHandler.h | 8 ++++---- src/Chunk.h | 6 +++--- src/ChunkDataCallback.h | 14 +++++++------- src/CommandOutput.h | 6 +++--- src/Entities/ArrowEntity.h | 2 +- src/Entities/Boat.h | 2 +- src/Entities/EnderCrystal.h | 2 +- src/Entities/Entity.h | 2 +- src/Entities/EntityEffect.h | 2 +- src/Entities/ExpBottleEntity.h | 2 +- src/Entities/ExpOrb.h | 2 +- src/Entities/FallingBlock.h | 2 +- src/Entities/FireChargeEntity.h | 2 +- src/Entities/FireworkEntity.h | 2 +- src/Entities/Floater.h | 2 +- src/Entities/GhastFireballEntity.h | 2 +- src/Entities/HangingEntity.h | 4 ++-- src/Entities/ItemFrame.h | 4 ++-- src/Entities/Minecart.h | 12 ++++++------ src/Entities/Painting.h | 2 +- src/Entities/Pawn.h | 2 +- src/Entities/Pickup.h | 2 +- src/Entities/Player.h | 2 +- src/Entities/ProjectileEntity.h | 2 +- src/Entities/SplashPotionEntity.h | 2 +- src/Entities/TNTEntity.h | 2 +- src/Entities/ThrownEggEntity.h | 2 +- src/Entities/ThrownEnderPearlEntity.h | 2 +- src/Entities/ThrownSnowballEntity.h | 2 +- src/Entities/WitherSkullEntity.h | 2 +- src/Generating/ChunkGenerator.h | 2 +- src/HTTPServer/HTTPMessage.h | 2 +- src/Mobs/Bat.h | 2 +- src/Mobs/Blaze.h | 2 +- src/Mobs/CaveSpider.h | 2 +- src/Mobs/Chicken.h | 2 +- src/Mobs/Cow.h | 2 +- src/Mobs/Creeper.h | 2 +- src/Mobs/EnderDragon.h | 2 +- src/Mobs/Enderman.h | 2 +- src/Mobs/Ghast.h | 2 +- src/Mobs/Giant.h | 2 +- src/Mobs/Horse.h | 2 +- src/Mobs/IronGolem.h | 2 +- src/Mobs/MagmaCube.h | 2 +- src/Mobs/Monster.h | 2 +- src/Mobs/Mooshroom.h | 2 +- src/Mobs/Ocelot.h | 2 +- src/Mobs/Pig.h | 2 +- src/Mobs/Sheep.h | 2 +- src/Mobs/Silverfish.h | 2 +- src/Mobs/Skeleton.h | 4 ++-- src/Mobs/Slime.h | 2 +- src/Mobs/SnowGolem.h | 2 +- src/Mobs/Spider.h | 2 +- src/Mobs/Squid.h | 2 +- src/Mobs/Villager.h | 2 +- src/Mobs/Witch.h | 2 +- src/Mobs/Wither.h | 2 +- src/Mobs/Wolf.h | 2 +- src/Mobs/Zombie.h | 2 +- src/Mobs/ZombiePigman.h | 2 +- src/OSSupport/Queue.h | 4 ++-- src/Protocol/Protocol.h | 2 +- src/Protocol/Protocol125.h | 2 +- src/Simulator/Simulator.h | 2 +- src/World.h | 12 ++++++------ src/WorldStorage/FastNBT.h | 2 +- src/WorldStorage/WorldStorage.h | 4 ++-- 74 files changed, 110 insertions(+), 110 deletions(-) diff --git a/SetFlags.cmake b/SetFlags.cmake index bf467ca01..cf8082503 100644 --- a/SetFlags.cmake +++ b/SetFlags.cmake @@ -28,7 +28,7 @@ endmacro() macro(set_flags) # Add coverage processing, if requested: if (NOT MSVC) - + if (CMAKE_BUILD_TYPE STREQUAL "COVERAGE") message("Including CodeCoverage") set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/lib/cmake-coverage/") @@ -85,7 +85,7 @@ macro(set_flags) # We use a signed char (fixes #640 on RasPi) add_flags_cxx("-fsigned-char") - + endif() @@ -202,7 +202,7 @@ macro(enable_profile) set(CMAKE_CONFIGURATION_TYPES "Debug;Release;DebugProfile;ReleaseProfile;Coverage" CACHE STRING "" FORCE) endif() endmacro() - + macro(set_exe_flags) # Remove disabling the maximum warning level: # clang does not like a command line that reads -Wall -Wextra -w -Wall -Wextra and does not output any warnings @@ -216,22 +216,22 @@ macro(set_exe_flags) string(REPLACE "-w" "" CMAKE_CXX_FLAGS_COVERAGE "${CMAKE_CXX_FLAGS_COVERAGE}") string(REPLACE "-w" "" CMAKE_C_FLAGS_COVERAGE "${CMAKE_C_FLAGS_COVERAGE}") add_flags_cxx("-Wall -Wextra -Wno-unused-parameter -Wno-error=switch") - + # we support non-IEEE 754 fpus so can make no guarentees about error add_flags_cxx("-ffast-math") - + if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") # clang does not provide the __extern_always_inline macro and a part of libm depends on this when using fast-math add_flags_cxx("-D__extern_always_inline=inline") add_flags_cxx("-Werror -Weverything -Wno-c++98-compat-pedantic -Wno-string-conversion") - add_flags_cxx("-Wno-extra-semi -Wno-error=switch-enum -Wno-documentation") + add_flags_cxx("-Wno-error=switch-enum -Wno-documentation -Wno-exit-time-destructors") add_flags_cxx("-Wno-error=sign-conversion -Wno-error=conversion -Wno-padded") add_flags_cxx("-Wno-error=deprecated -Wno-error=weak-vtables -Wno-error=float-equal") add_flags_cxx("-Wno-error=missing-prototypes -Wno-error=non-virtual-dtor") add_flags_cxx("-Wno-error=covered-switch-default -Wno-error=shadow") add_flags_cxx("-Wno-error=exit-time-destructors -Wno-error=missing-variable-declarations") add_flags_cxx("-Wno-error=global-constructors -Wno-implicit-fallthrough") - add_flags_cxx("-Wno-weak-vtables -Wno-switch-enum -Wno-exit-time-destructors") + add_flags_cxx("-Wno-weak-vtables -Wno-switch-enum") endif() endif() diff --git a/src/Bindings/Plugin.h b/src/Bindings/Plugin.h index 3882b7474..39d53674b 100644 --- a/src/Bindings/Plugin.h +++ b/src/Bindings/Plugin.h @@ -115,10 +115,10 @@ public: virtual bool HandleConsoleCommand(const AStringVector & a_Split, cCommandOutputCallback & a_Output) = 0; /// All bound commands are to be removed, do any language-dependent cleanup here - virtual void ClearCommands(void) {} ; + virtual void ClearCommands(void) {} /// All bound console commands are to be removed, do any language-dependent cleanup here - virtual void ClearConsoleCommands(void) {} ; + virtual void ClearConsoleCommands(void) {} // tolua_begin const AString & GetName(void) const { return m_Name; } diff --git a/src/BlockEntities/BlockEntity.h b/src/BlockEntities/BlockEntity.h index 24c25e729..5710f8543 100644 --- a/src/BlockEntities/BlockEntity.h +++ b/src/BlockEntities/BlockEntity.h @@ -38,9 +38,9 @@ protected: public: // tolua_end - virtual ~cBlockEntity() {}; // force a virtual destructor in all descendants + virtual ~cBlockEntity() {} // force a virtual destructor in all descendants - virtual void Destroy(void) {}; + virtual void Destroy(void) {} void SetWorld(cWorld * a_World) { diff --git a/src/BlockEntities/JukeboxEntity.h b/src/BlockEntities/JukeboxEntity.h index 8bb3009eb..d677d340f 100644 --- a/src/BlockEntities/JukeboxEntity.h +++ b/src/BlockEntities/JukeboxEntity.h @@ -58,7 +58,7 @@ public: static const char * GetClassStatic(void) { return "cJukeboxEntity"; } virtual void UsedBy(cPlayer * a_Player) override; - virtual void SendTo(cClientHandle &) override { }; + virtual void SendTo(cClientHandle &) override {} private: int m_Record; diff --git a/src/BlockEntities/NoteEntity.h b/src/BlockEntities/NoteEntity.h index 07b8fd259..e8497da3e 100644 --- a/src/BlockEntities/NoteEntity.h +++ b/src/BlockEntities/NoteEntity.h @@ -52,7 +52,7 @@ public: // tolua_end virtual void UsedBy(cPlayer * a_Player) override; - virtual void SendTo(cClientHandle &) override { }; + virtual void SendTo(cClientHandle &) override {} static const char * GetClassStatic(void) { return "cNoteEntity"; } diff --git a/src/Blocks/BlockHandler.h b/src/Blocks/BlockHandler.h index 01c64b457..94ab8d8c6 100644 --- a/src/Blocks/BlockHandler.h +++ b/src/Blocks/BlockHandler.h @@ -60,19 +60,19 @@ public: virtual void OnDestroyed(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, int a_BlockX, int a_BlockY, int a_BlockZ); /// Called when a direct neighbor of this block has been changed (The position is the own position, not the neighbor position) - virtual void OnNeighborChanged(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ) {}; + virtual void OnNeighborChanged(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ) {} /// Notifies all neighbors of the given block about a change static void NeighborChanged(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ); /// Called while the player diggs the block. - virtual void OnDigging(cChunkInterface & cChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ) {}; + 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, eBlockFace 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 a right click to this block is cancelled */ - virtual void OnCancelRightClick(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace) {}; + virtual void OnCancelRightClick(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace) {} /// 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/Chunk.h b/src/Chunk.h index 5d50f9717..7eee3999c 100644 --- a/src/Chunk.h +++ b/src/Chunk.h @@ -380,9 +380,9 @@ public: cRedstoneSimulatorChunkData * GetRedstoneSimulatorData(void) { return &m_RedstoneSimulatorData; } cRedstoneSimulatorChunkData * GetRedstoneSimulatorQueuedData(void) { return &m_RedstoneSimulatorQueuedData; } cIncrementalRedstoneSimulator::PoweredBlocksList * GetRedstoneSimulatorPoweredBlocksList(void) { return &m_RedstoneSimulatorPoweredBlocksList; } - cIncrementalRedstoneSimulator::LinkedBlocksList * GetRedstoneSimulatorLinkedBlocksList(void) { return &m_RedstoneSimulatorLinkedBlocksList; }; - cIncrementalRedstoneSimulator::SimulatedPlayerToggleableList * GetRedstoneSimulatorSimulatedPlayerToggleableList(void) { return &m_RedstoneSimulatorSimulatedPlayerToggleableList; }; - cIncrementalRedstoneSimulator::RepeatersDelayList * GetRedstoneSimulatorRepeatersDelayList(void) { return &m_RedstoneSimulatorRepeatersDelayList; }; + cIncrementalRedstoneSimulator::LinkedBlocksList * GetRedstoneSimulatorLinkedBlocksList(void) { return &m_RedstoneSimulatorLinkedBlocksList; } + cIncrementalRedstoneSimulator::SimulatedPlayerToggleableList * GetRedstoneSimulatorSimulatedPlayerToggleableList(void) { return &m_RedstoneSimulatorSimulatedPlayerToggleableList; } + cIncrementalRedstoneSimulator::RepeatersDelayList * GetRedstoneSimulatorRepeatersDelayList(void) { return &m_RedstoneSimulatorRepeatersDelayList; } bool IsRedstoneDirty(void) const { return m_IsRedstoneDirty; } void SetIsRedstoneDirty(bool a_Flag) { m_IsRedstoneDirty = a_Flag; } diff --git a/src/ChunkDataCallback.h b/src/ChunkDataCallback.h index 53d44d038..804299816 100644 --- a/src/ChunkDataCallback.h +++ b/src/ChunkDataCallback.h @@ -29,25 +29,25 @@ public: (only in processes where multiple chunks can be processed, such as cWorld::ForEachChunkInRect()). If false is returned, the chunk is skipped. */ - virtual bool Coords(int a_ChunkX, int a_ChunkZ) { UNUSED(a_ChunkX); UNUSED(a_ChunkZ); return true; }; + virtual bool Coords(int a_ChunkX, int a_ChunkZ) { UNUSED(a_ChunkX); UNUSED(a_ChunkZ); return true; } /// Called once to provide heightmap data - virtual void HeightMap(const cChunkDef::HeightMap * a_HeightMap) {UNUSED(a_HeightMap); }; + virtual void HeightMap(const cChunkDef::HeightMap * a_HeightMap) { UNUSED(a_HeightMap); } /// Called once to provide biome data - virtual void BiomeData(const cChunkDef::BiomeMap * a_BiomeMap) {UNUSED(a_BiomeMap); }; + virtual void BiomeData(const cChunkDef::BiomeMap * a_BiomeMap) { UNUSED(a_BiomeMap); } /// Called once to let know if the chunk lighting is valid. Return value is ignored - virtual void LightIsValid(bool a_IsLightValid) {UNUSED(a_IsLightValid); }; + virtual void LightIsValid(bool a_IsLightValid) { UNUSED(a_IsLightValid); } /// Called once to export block info - virtual void ChunkData(const cChunkData & a_Buffer) {UNUSED(a_Buffer); }; + virtual void ChunkData(const cChunkData & a_Buffer) { UNUSED(a_Buffer); } /// Called for each entity in the chunk - virtual void Entity(cEntity * a_Entity) {UNUSED(a_Entity); }; + virtual void Entity(cEntity * a_Entity) { UNUSED(a_Entity); } /// Called for each blockentity in the chunk - virtual void BlockEntity(cBlockEntity * a_Entity) {UNUSED(a_Entity); }; + virtual void BlockEntity(cBlockEntity * a_Entity) { UNUSED(a_Entity); } } ; diff --git a/src/CommandOutput.h b/src/CommandOutput.h index 5682b4fd8..daa9430c0 100644 --- a/src/CommandOutput.h +++ b/src/CommandOutput.h @@ -14,16 +14,16 @@ Descendants override that function to provide specific processing of the output. class cCommandOutputCallback { public: - virtual ~cCommandOutputCallback() {}; // Force a virtual destructor in subclasses + virtual ~cCommandOutputCallback() {} // Force a virtual destructor in subclasses - /// Syntax sugar function, calls Out() with Printf()-ed parameters; appends a "\n" + /// Syntax sugar function, calls Out() with Printf()-ed parameters; appends a newline" void Out(const char * a_Fmt, ...) FORMATSTRING(2, 3); /// Called when the command wants to output anything; may be called multiple times virtual void Out(const AString & a_Text) = 0; /// Called when the command processing has been finished - virtual void Finished(void) {}; + virtual void Finished(void) {} } ; diff --git a/src/Entities/ArrowEntity.h b/src/Entities/ArrowEntity.h index ad93dba6c..4bfcb1f6d 100644 --- a/src/Entities/ArrowEntity.h +++ b/src/Entities/ArrowEntity.h @@ -28,7 +28,7 @@ public: // tolua_end - CLASS_PROTODEF(cArrowEntity); + CLASS_PROTODEF(cArrowEntity) /// Creates a new arrow with psNoPickup state and default damage modifier coeff cArrowEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed); diff --git a/src/Entities/Boat.h b/src/Entities/Boat.h index 0fcfbd602..8de88d165 100644 --- a/src/Entities/Boat.h +++ b/src/Entities/Boat.h @@ -21,7 +21,7 @@ class cBoat : typedef cEntity super; public: - CLASS_PROTODEF(cBoat); + CLASS_PROTODEF(cBoat) // cEntity overrides: virtual void SpawnOn(cClientHandle & a_ClientHandle) override; diff --git a/src/Entities/EnderCrystal.h b/src/Entities/EnderCrystal.h index 30211de13..c98c3b681 100644 --- a/src/Entities/EnderCrystal.h +++ b/src/Entities/EnderCrystal.h @@ -15,7 +15,7 @@ class cEnderCrystal : typedef cEntity super; public: - CLASS_PROTODEF(cEnderCrystal); + CLASS_PROTODEF(cEnderCrystal) cEnderCrystal(double a_X, double a_Y, double a_Z); diff --git a/src/Entities/Entity.h b/src/Entities/Entity.h index 83fe76e7e..efca60a6c 100644 --- a/src/Entities/Entity.h +++ b/src/Entities/Entity.h @@ -428,7 +428,7 @@ public: // tolua_end /// Called when the specified player right-clicks this entity - virtual void OnRightClicked(cPlayer &) {}; + virtual void OnRightClicked(cPlayer &) {} /// Returns the list of drops for this pawn when it is killed. May check a_Killer for special handling (sword of looting etc.). Called from KilledBy(). virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) diff --git a/src/Entities/EntityEffect.h b/src/Entities/EntityEffect.h index ebd611ff0..396a9bbe0 100644 --- a/src/Entities/EntityEffect.h +++ b/src/Entities/EntityEffect.h @@ -55,7 +55,7 @@ public: @param a_OtherEffect The other effect to copy */ cEntityEffect & operator=(cEntityEffect a_OtherEffect); - virtual ~cEntityEffect(void) {}; + virtual ~cEntityEffect(void) {} /** Creates a pointer to the proper entity effect from the effect type @warning This function creates raw pointers that must be manually managed. diff --git a/src/Entities/ExpBottleEntity.h b/src/Entities/ExpBottleEntity.h index e9536452c..d62a84469 100644 --- a/src/Entities/ExpBottleEntity.h +++ b/src/Entities/ExpBottleEntity.h @@ -21,7 +21,7 @@ public: // tolua_end - CLASS_PROTODEF(cExpBottleEntity); + CLASS_PROTODEF(cExpBottleEntity) cExpBottleEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed); diff --git a/src/Entities/ExpOrb.h b/src/Entities/ExpOrb.h index 2cd4ef31f..bdb9a5b19 100644 --- a/src/Entities/ExpOrb.h +++ b/src/Entities/ExpOrb.h @@ -16,7 +16,7 @@ class cExpOrb : public: // tolua_end - CLASS_PROTODEF(cExpOrb); + CLASS_PROTODEF(cExpOrb) cExpOrb(double a_X, double a_Y, double a_Z, int a_Reward); cExpOrb(const Vector3d & a_Pos, int a_Reward); diff --git a/src/Entities/FallingBlock.h b/src/Entities/FallingBlock.h index 5ba9909bb..c20fe8eb9 100644 --- a/src/Entities/FallingBlock.h +++ b/src/Entities/FallingBlock.h @@ -20,7 +20,7 @@ class cFallingBlock : typedef cEntity super; public: - CLASS_PROTODEF(cFallingBlock); + CLASS_PROTODEF(cFallingBlock) /// Creates a new falling block. a_BlockPosition is expected in world coords cFallingBlock(const Vector3i & a_BlockPosition, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta); diff --git a/src/Entities/FireChargeEntity.h b/src/Entities/FireChargeEntity.h index 42ecc7d74..5df55bec4 100644 --- a/src/Entities/FireChargeEntity.h +++ b/src/Entities/FireChargeEntity.h @@ -21,7 +21,7 @@ public: // tolua_end - CLASS_PROTODEF(cFireChargeEntity); + CLASS_PROTODEF(cFireChargeEntity) cFireChargeEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed); diff --git a/src/Entities/FireworkEntity.h b/src/Entities/FireworkEntity.h index 7dbdc49e1..20f18b6dc 100644 --- a/src/Entities/FireworkEntity.h +++ b/src/Entities/FireworkEntity.h @@ -21,7 +21,7 @@ public: // tolua_end - CLASS_PROTODEF(cFireworkEntity); + CLASS_PROTODEF(cFireworkEntity) cFireworkEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const cItem & a_Item); const cItem & GetItem(void) const { return m_FireworkItem; } diff --git a/src/Entities/Floater.h b/src/Entities/Floater.h index 5d2720b6a..96d77ac82 100644 --- a/src/Entities/Floater.h +++ b/src/Entities/Floater.h @@ -16,7 +16,7 @@ class cFloater : public: // tolua_end - CLASS_PROTODEF(cFloater); + CLASS_PROTODEF(cFloater) cFloater(double a_X, double a_Y, double a_Z, Vector3d a_Speed, int a_PlayerID, int a_CountDownTime); diff --git a/src/Entities/GhastFireballEntity.h b/src/Entities/GhastFireballEntity.h index fa59fa642..3ed72d9ef 100644 --- a/src/Entities/GhastFireballEntity.h +++ b/src/Entities/GhastFireballEntity.h @@ -21,7 +21,7 @@ public: // tolua_end - CLASS_PROTODEF(cGhastFireballEntity); + CLASS_PROTODEF(cGhastFireballEntity) cGhastFireballEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed); diff --git a/src/Entities/HangingEntity.h b/src/Entities/HangingEntity.h index 6498e4b5b..3593f9ede 100644 --- a/src/Entities/HangingEntity.h +++ b/src/Entities/HangingEntity.h @@ -16,7 +16,7 @@ class cHangingEntity : public: - CLASS_PROTODEF(cHangingEntity); + CLASS_PROTODEF(cHangingEntity) cHangingEntity(eEntityType a_EntityType, eBlockFace a_BlockFace, double a_X, double a_Y, double a_Z); @@ -38,7 +38,7 @@ public: private: virtual void SpawnOn(cClientHandle & a_ClientHandle) override; - virtual void Tick(float a_Dt, cChunk & a_Chunk) override {}; + virtual void Tick(float a_Dt, cChunk & a_Chunk) override {} eBlockFace m_BlockFace; diff --git a/src/Entities/ItemFrame.h b/src/Entities/ItemFrame.h index 9261e52cc..a63b78b70 100644 --- a/src/Entities/ItemFrame.h +++ b/src/Entities/ItemFrame.h @@ -16,7 +16,7 @@ class cItemFrame : public: - CLASS_PROTODEF(cItemFrame); + CLASS_PROTODEF(cItemFrame) cItemFrame(eBlockFace a_BlockFace, double a_X, double a_Y, double a_Z); @@ -24,7 +24,7 @@ public: const cItem & GetItem(void) { return m_Item; } // tolua_export /** Set the item in the frame */ - void SetItem(cItem & a_Item) { m_Item = a_Item; }; // tolua_export + void SetItem(cItem & a_Item) { m_Item = a_Item; } // tolua_export /** Returns the rotation from the item in the frame */ Byte GetRotation(void) const { return m_Rotation; } // tolua_export diff --git a/src/Entities/Minecart.h b/src/Entities/Minecart.h index c585cfab0..410d3c77d 100644 --- a/src/Entities/Minecart.h +++ b/src/Entities/Minecart.h @@ -21,7 +21,7 @@ class cMinecart : typedef cEntity super; public: - CLASS_PROTODEF(cMinecart); + CLASS_PROTODEF(cMinecart) /** Minecart payload, values correspond to packet subtype */ enum ePayload @@ -89,7 +89,7 @@ class cRideableMinecart : typedef cMinecart super; public: - CLASS_PROTODEF(cRideableMinecart); + CLASS_PROTODEF(cRideableMinecart) cRideableMinecart(double a_X, double a_Y, double a_Z, const cItem & a_Content, int a_Height); @@ -113,7 +113,7 @@ class cMinecartWithChest : typedef cMinecart super; public: - CLASS_PROTODEF(cMinecartWithChest); + CLASS_PROTODEF(cMinecartWithChest) /// Number of item slots in the chest static const int NumSlots = 9 * 3; @@ -144,7 +144,7 @@ class cMinecartWithFurnace : typedef cMinecart super; public: - CLASS_PROTODEF(cMinecartWithFurnace); + CLASS_PROTODEF(cMinecartWithFurnace) cMinecartWithFurnace(double a_X, double a_Y, double a_Z); @@ -176,7 +176,7 @@ class cMinecartWithTNT : typedef cMinecart super; public: - CLASS_PROTODEF(cMinecartWithTNT); + CLASS_PROTODEF(cMinecartWithTNT) cMinecartWithTNT(double a_X, double a_Y, double a_Z); } ; @@ -191,7 +191,7 @@ class cMinecartWithHopper : typedef cMinecart super; public: - CLASS_PROTODEF(cMinecartWithHopper); + CLASS_PROTODEF(cMinecartWithHopper) cMinecartWithHopper(double a_X, double a_Y, double a_Z); } ; diff --git a/src/Entities/Painting.h b/src/Entities/Painting.h index ce7c6f3de..9877c95c5 100644 --- a/src/Entities/Painting.h +++ b/src/Entities/Painting.h @@ -15,7 +15,7 @@ class cPainting : typedef cEntity super; public: - CLASS_PROTODEF(cPainting); + CLASS_PROTODEF(cPainting) cPainting(const AString & a_Name, int a_Direction, double a_X, double a_Y, double a_Z); const AString & GetName(void) const { return m_Name; } // tolua_export diff --git a/src/Entities/Pawn.h b/src/Entities/Pawn.h index 63c7cfbb6..d50bcd8af 100644 --- a/src/Entities/Pawn.h +++ b/src/Entities/Pawn.h @@ -16,7 +16,7 @@ class cPawn : typedef cEntity super; public: - CLASS_PROTODEF(cPawn); + CLASS_PROTODEF(cPawn) cPawn(eEntityType a_EntityType, double a_Width, double a_Height); diff --git a/src/Entities/Pickup.h b/src/Entities/Pickup.h index d7c5d2b26..4d5250819 100644 --- a/src/Entities/Pickup.h +++ b/src/Entities/Pickup.h @@ -23,7 +23,7 @@ class cPickup : public: // tolua_end - CLASS_PROTODEF(cPickup); + CLASS_PROTODEF(cPickup) cPickup(double a_PosX, double a_PosY, double a_PosZ, const cItem & a_Item, bool IsPlayerCreated, float a_SpeedX = 0.f, float a_SpeedY = 0.f, float a_SpeedZ = 0.f); diff --git a/src/Entities/Player.h b/src/Entities/Player.h index 26db2050b..488884602 100644 --- a/src/Entities/Player.h +++ b/src/Entities/Player.h @@ -48,7 +48,7 @@ public: virtual void Tick(float a_Dt, cChunk & a_Chunk) override; - virtual void HandlePhysics(float a_Dt, cChunk &) override { UNUSED(a_Dt); }; + virtual void HandlePhysics(float a_Dt, cChunk &) override { UNUSED(a_Dt); } /** Returns the curently equipped weapon; empty item if none */ virtual cItem GetEquippedWeapon(void) const override { return m_Inventory.GetEquippedItem(); } diff --git a/src/Entities/ProjectileEntity.h b/src/Entities/ProjectileEntity.h index e6b05714e..0ebc32f36 100644 --- a/src/Entities/ProjectileEntity.h +++ b/src/Entities/ProjectileEntity.h @@ -41,7 +41,7 @@ public: // tolua_end - CLASS_PROTODEF(cProjectileEntity); + CLASS_PROTODEF(cProjectileEntity) cProjectileEntity(eKind a_Kind, cEntity * a_Creator, double a_X, double a_Y, double a_Z, double a_Width, double a_Height); cProjectileEntity(eKind a_Kind, cEntity * a_Creator, const Vector3d & a_Pos, const Vector3d & a_Speed, double a_Width, double a_Height); diff --git a/src/Entities/SplashPotionEntity.h b/src/Entities/SplashPotionEntity.h index 290dd81d4..dd14ea82f 100644 --- a/src/Entities/SplashPotionEntity.h +++ b/src/Entities/SplashPotionEntity.h @@ -23,7 +23,7 @@ public: // tolua_end - CLASS_PROTODEF(cSplashPotionEntity); + CLASS_PROTODEF(cSplashPotionEntity) cSplashPotionEntity( cEntity * a_Creator, diff --git a/src/Entities/TNTEntity.h b/src/Entities/TNTEntity.h index df61b14f5..48503cf76 100644 --- a/src/Entities/TNTEntity.h +++ b/src/Entities/TNTEntity.h @@ -14,7 +14,7 @@ class cTNTEntity : public: // tolua_end - CLASS_PROTODEF(cTNTEntity); + CLASS_PROTODEF(cTNTEntity) cTNTEntity(double a_X, double a_Y, double a_Z, int a_FuseTicks = 80); cTNTEntity(const Vector3d & a_Pos, int a_FuseTicks = 80); diff --git a/src/Entities/ThrownEggEntity.h b/src/Entities/ThrownEggEntity.h index f93731256..a0b7d5340 100644 --- a/src/Entities/ThrownEggEntity.h +++ b/src/Entities/ThrownEggEntity.h @@ -21,7 +21,7 @@ public: // tolua_end - CLASS_PROTODEF(cThrownEggEntity); + CLASS_PROTODEF(cThrownEggEntity) cThrownEggEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed); diff --git a/src/Entities/ThrownEnderPearlEntity.h b/src/Entities/ThrownEnderPearlEntity.h index 549d8a3eb..436450013 100644 --- a/src/Entities/ThrownEnderPearlEntity.h +++ b/src/Entities/ThrownEnderPearlEntity.h @@ -21,7 +21,7 @@ public: // tolua_end - CLASS_PROTODEF(cThrownEnderPearlEntity); + CLASS_PROTODEF(cThrownEnderPearlEntity) cThrownEnderPearlEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed); diff --git a/src/Entities/ThrownSnowballEntity.h b/src/Entities/ThrownSnowballEntity.h index 6f3efdd7e..8d195ced1 100644 --- a/src/Entities/ThrownSnowballEntity.h +++ b/src/Entities/ThrownSnowballEntity.h @@ -21,7 +21,7 @@ public: // tolua_end - CLASS_PROTODEF(cThrownSnowballEntity); + CLASS_PROTODEF(cThrownSnowballEntity) cThrownSnowballEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed); diff --git a/src/Entities/WitherSkullEntity.h b/src/Entities/WitherSkullEntity.h index ebc1550e3..c59acd807 100644 --- a/src/Entities/WitherSkullEntity.h +++ b/src/Entities/WitherSkullEntity.h @@ -22,7 +22,7 @@ public: // tolua_end - CLASS_PROTODEF(cWitherSkullEntity); + CLASS_PROTODEF(cWitherSkullEntity) cWitherSkullEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed); diff --git a/src/Generating/ChunkGenerator.h b/src/Generating/ChunkGenerator.h index 9b2d9eb3c..88d71f3f9 100644 --- a/src/Generating/ChunkGenerator.h +++ b/src/Generating/ChunkGenerator.h @@ -44,7 +44,7 @@ public: { public: cGenerator(cChunkGenerator & a_ChunkGenerator); - virtual ~cGenerator() {} ; // Force a virtual destructor + virtual ~cGenerator() {} // Force a virtual destructor /// Called to initialize the generator on server startup. virtual void Initialize(cIniFile & a_IniFile); diff --git a/src/HTTPServer/HTTPMessage.h b/src/HTTPServer/HTTPMessage.h index dab942136..e402c8ad6 100644 --- a/src/HTTPServer/HTTPMessage.h +++ b/src/HTTPServer/HTTPMessage.h @@ -33,7 +33,7 @@ public: cHTTPMessage(eKind a_Kind); // Force a virtual destructor in all descendants - virtual ~cHTTPMessage() {}; + virtual ~cHTTPMessage() {} /** Adds a header into the internal map of headers. Recognizes special headers: Content-Type and Content-Length */ void AddHeader(const AString & a_Key, const AString & a_Value); diff --git a/src/Mobs/Bat.h b/src/Mobs/Bat.h index e878d0ee8..6b06aeb4f 100644 --- a/src/Mobs/Bat.h +++ b/src/Mobs/Bat.h @@ -15,7 +15,7 @@ class cBat : public: cBat(void); - CLASS_PROTODEF(cBat); + CLASS_PROTODEF(cBat) bool IsHanging(void) const {return false; } } ; diff --git a/src/Mobs/Blaze.h b/src/Mobs/Blaze.h index 5970451c7..f283b1070 100644 --- a/src/Mobs/Blaze.h +++ b/src/Mobs/Blaze.h @@ -15,7 +15,7 @@ class cBlaze : public: cBlaze(void); - CLASS_PROTODEF(cBlaze); + CLASS_PROTODEF(cBlaze) virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; virtual void Attack(float a_Dt) override; diff --git a/src/Mobs/CaveSpider.h b/src/Mobs/CaveSpider.h index 3f8b2cece..f9ed10e1b 100644 --- a/src/Mobs/CaveSpider.h +++ b/src/Mobs/CaveSpider.h @@ -14,7 +14,7 @@ class cCaveSpider : public: cCaveSpider(void); - CLASS_PROTODEF(cCaveSpider); + CLASS_PROTODEF(cCaveSpider) virtual void Tick(float a_Dt, cChunk & a_Chunk) override; virtual void Attack(float a_Dt) override; diff --git a/src/Mobs/Chicken.h b/src/Mobs/Chicken.h index a4c1d6b9e..b1a50b61c 100644 --- a/src/Mobs/Chicken.h +++ b/src/Mobs/Chicken.h @@ -14,7 +14,7 @@ class cChicken : public: cChicken(void); - CLASS_PROTODEF(cChicken); + CLASS_PROTODEF(cChicken) virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; virtual void Tick(float a_Dt, cChunk & a_Chunk) override; diff --git a/src/Mobs/Cow.h b/src/Mobs/Cow.h index 973171ab5..8814b7e09 100644 --- a/src/Mobs/Cow.h +++ b/src/Mobs/Cow.h @@ -15,7 +15,7 @@ class cCow : public: cCow(); - CLASS_PROTODEF(cCow); + CLASS_PROTODEF(cCow) virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; virtual void OnRightClicked(cPlayer & a_Player) override; diff --git a/src/Mobs/Creeper.h b/src/Mobs/Creeper.h index fc7db6716..747daca09 100644 --- a/src/Mobs/Creeper.h +++ b/src/Mobs/Creeper.h @@ -15,7 +15,7 @@ class cCreeper : public: cCreeper(void); - CLASS_PROTODEF(cCreeper); + CLASS_PROTODEF(cCreeper) virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; virtual bool DoTakeDamage(TakeDamageInfo & a_TDI) override; diff --git a/src/Mobs/EnderDragon.h b/src/Mobs/EnderDragon.h index 77177edfe..1d4cd657c 100644 --- a/src/Mobs/EnderDragon.h +++ b/src/Mobs/EnderDragon.h @@ -15,7 +15,7 @@ class cEnderDragon : public: cEnderDragon(void); - CLASS_PROTODEF(cEnderDragon); + CLASS_PROTODEF(cEnderDragon) virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; } ; diff --git a/src/Mobs/Enderman.h b/src/Mobs/Enderman.h index 32e40e70b..aa2eff682 100644 --- a/src/Mobs/Enderman.h +++ b/src/Mobs/Enderman.h @@ -15,7 +15,7 @@ class cEnderman : public: cEnderman(void); - CLASS_PROTODEF(cEnderman); + CLASS_PROTODEF(cEnderman) virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; diff --git a/src/Mobs/Ghast.h b/src/Mobs/Ghast.h index 43e8bedb6..1d4e6b94a 100644 --- a/src/Mobs/Ghast.h +++ b/src/Mobs/Ghast.h @@ -15,7 +15,7 @@ class cGhast : public: cGhast(void); - CLASS_PROTODEF(cGhast); + CLASS_PROTODEF(cGhast) virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; virtual void Attack(float a_Dt) override; diff --git a/src/Mobs/Giant.h b/src/Mobs/Giant.h index 356dd4352..7c04c9b4f 100644 --- a/src/Mobs/Giant.h +++ b/src/Mobs/Giant.h @@ -15,7 +15,7 @@ class cGiant : public: cGiant(void); - CLASS_PROTODEF(cGiant); + CLASS_PROTODEF(cGiant) virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; } ; diff --git a/src/Mobs/Horse.h b/src/Mobs/Horse.h index be0c23f9b..47189b3b0 100644 --- a/src/Mobs/Horse.h +++ b/src/Mobs/Horse.h @@ -15,7 +15,7 @@ class cHorse : public: cHorse(int Type, int Color, int Style, int TameTimes); - CLASS_PROTODEF(cHorse); + CLASS_PROTODEF(cHorse) virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; virtual void Tick(float a_Dt, cChunk & a_Chunk) override; diff --git a/src/Mobs/IronGolem.h b/src/Mobs/IronGolem.h index 30f9bedff..c5341ed76 100644 --- a/src/Mobs/IronGolem.h +++ b/src/Mobs/IronGolem.h @@ -15,7 +15,7 @@ class cIronGolem : public: cIronGolem(void); - CLASS_PROTODEF(cIronGolem); + CLASS_PROTODEF(cIronGolem) virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; diff --git a/src/Mobs/MagmaCube.h b/src/Mobs/MagmaCube.h index 43065cae5..bfe63fa2e 100644 --- a/src/Mobs/MagmaCube.h +++ b/src/Mobs/MagmaCube.h @@ -15,7 +15,7 @@ public: /// Creates a MagmaCube of the specified size; size is 1 .. 3, with 1 being the smallest cMagmaCube(int a_Size); - CLASS_PROTODEF(cMagmaCube); + CLASS_PROTODEF(cMagmaCube) virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; int GetSize(void) const { return m_Size; } diff --git a/src/Mobs/Monster.h b/src/Mobs/Monster.h index ffd078505..cdbd26c09 100644 --- a/src/Mobs/Monster.h +++ b/src/Mobs/Monster.h @@ -82,7 +82,7 @@ public: */ cMonster(const AString & a_ConfigName, eType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height); - CLASS_PROTODEF(cMonster); + CLASS_PROTODEF(cMonster) virtual void SpawnOn(cClientHandle & a_ClientHandle) override; diff --git a/src/Mobs/Mooshroom.h b/src/Mobs/Mooshroom.h index 16f6c8248..fb002c2bf 100644 --- a/src/Mobs/Mooshroom.h +++ b/src/Mobs/Mooshroom.h @@ -15,7 +15,7 @@ class cMooshroom : public: cMooshroom(void); - CLASS_PROTODEF(cMooshroom); + CLASS_PROTODEF(cMooshroom) virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; virtual void OnRightClicked(cPlayer & a_Player) override; diff --git a/src/Mobs/Ocelot.h b/src/Mobs/Ocelot.h index adb7a1f75..f2727d354 100644 --- a/src/Mobs/Ocelot.h +++ b/src/Mobs/Ocelot.h @@ -18,7 +18,7 @@ public: { } - CLASS_PROTODEF(cOcelot); + CLASS_PROTODEF(cOcelot) } ; diff --git a/src/Mobs/Pig.h b/src/Mobs/Pig.h index 313af2f44..534a0ca6f 100644 --- a/src/Mobs/Pig.h +++ b/src/Mobs/Pig.h @@ -15,7 +15,7 @@ class cPig : public: cPig(void); - CLASS_PROTODEF(cPig); + CLASS_PROTODEF(cPig) virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; virtual void OnRightClicked(cPlayer & a_Player) override; diff --git a/src/Mobs/Sheep.h b/src/Mobs/Sheep.h index 5ffd3e4fe..28e1c7254 100644 --- a/src/Mobs/Sheep.h +++ b/src/Mobs/Sheep.h @@ -20,7 +20,7 @@ public: with the GenerateNaturalRandomColor() function. */ cSheep(int a_Color = -1); - CLASS_PROTODEF(cSheep); + CLASS_PROTODEF(cSheep) virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; virtual void OnRightClicked(cPlayer & a_Player) override; diff --git a/src/Mobs/Silverfish.h b/src/Mobs/Silverfish.h index a6e11c49d..2df333dbc 100644 --- a/src/Mobs/Silverfish.h +++ b/src/Mobs/Silverfish.h @@ -18,7 +18,7 @@ public: { } - CLASS_PROTODEF(cSilverfish); + CLASS_PROTODEF(cSilverfish) } ; diff --git a/src/Mobs/Skeleton.h b/src/Mobs/Skeleton.h index 9a121ef48..577588b32 100644 --- a/src/Mobs/Skeleton.h +++ b/src/Mobs/Skeleton.h @@ -15,7 +15,7 @@ class cSkeleton : public: cSkeleton(bool IsWither); - CLASS_PROTODEF(cSkeleton); + CLASS_PROTODEF(cSkeleton) virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; virtual void MoveToPosition(const Vector3d & a_Position) override; @@ -24,7 +24,7 @@ public: virtual bool IsUndead(void) override { return true; } - bool IsWither(void) const { return m_bIsWither; }; + bool IsWither(void) const { return m_bIsWither; } private: diff --git a/src/Mobs/Slime.h b/src/Mobs/Slime.h index 15ae113dc..f0b800f94 100644 --- a/src/Mobs/Slime.h +++ b/src/Mobs/Slime.h @@ -16,7 +16,7 @@ public: /** Creates a slime of the specified size; size can be 1, 2 or 4, with 1 is the smallest and 4 is the tallest. */ cSlime(int a_Size); - CLASS_PROTODEF(cSlime); + CLASS_PROTODEF(cSlime) // cAggressiveMonster overrides: virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; diff --git a/src/Mobs/SnowGolem.h b/src/Mobs/SnowGolem.h index ff5e90da8..aba89e52d 100644 --- a/src/Mobs/SnowGolem.h +++ b/src/Mobs/SnowGolem.h @@ -15,7 +15,7 @@ class cSnowGolem : public: cSnowGolem(void); - CLASS_PROTODEF(cSnowGolem); + CLASS_PROTODEF(cSnowGolem) virtual void Tick(float a_Dt, cChunk & a_Chunk) override; virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; diff --git a/src/Mobs/Spider.h b/src/Mobs/Spider.h index 51e65d028..813d2e266 100644 --- a/src/Mobs/Spider.h +++ b/src/Mobs/Spider.h @@ -15,7 +15,7 @@ class cSpider : public: cSpider(void); - CLASS_PROTODEF(cSpider); + CLASS_PROTODEF(cSpider) virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; } ; diff --git a/src/Mobs/Squid.h b/src/Mobs/Squid.h index a9dba8b70..b57340427 100644 --- a/src/Mobs/Squid.h +++ b/src/Mobs/Squid.h @@ -17,7 +17,7 @@ public: virtual void Tick(float a_Dt, cChunk & a_Chunk) override; - CLASS_PROTODEF(cSquid); + CLASS_PROTODEF(cSquid) virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; diff --git a/src/Mobs/Villager.h b/src/Mobs/Villager.h index 068dfd835..aa81f0790 100644 --- a/src/Mobs/Villager.h +++ b/src/Mobs/Villager.h @@ -27,7 +27,7 @@ public: cVillager(eVillagerType VillagerType); - CLASS_PROTODEF(cVillager); + CLASS_PROTODEF(cVillager) // cEntity overrides virtual bool DoTakeDamage(TakeDamageInfo & a_TDI) override; diff --git a/src/Mobs/Witch.h b/src/Mobs/Witch.h index 51c63322a..bd059f61d 100644 --- a/src/Mobs/Witch.h +++ b/src/Mobs/Witch.h @@ -16,7 +16,7 @@ class cWitch : public: cWitch(); - CLASS_PROTODEF(cWitch); + CLASS_PROTODEF(cWitch) virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; diff --git a/src/Mobs/Wither.h b/src/Mobs/Wither.h index cc8d1459b..2403823ed 100644 --- a/src/Mobs/Wither.h +++ b/src/Mobs/Wither.h @@ -15,7 +15,7 @@ class cWither : public: cWither(void); - CLASS_PROTODEF(cWither); + CLASS_PROTODEF(cWither) unsigned int GetWitherInvulnerableTicks(void) const { return m_WitherInvulnerableTicks; } diff --git a/src/Mobs/Wolf.h b/src/Mobs/Wolf.h index fb8a7c995..2e83db701 100644 --- a/src/Mobs/Wolf.h +++ b/src/Mobs/Wolf.h @@ -16,7 +16,7 @@ class cWolf : public: cWolf(void); - CLASS_PROTODEF(cWolf); + CLASS_PROTODEF(cWolf) virtual bool DoTakeDamage(TakeDamageInfo & a_TDI) override; virtual void OnRightClicked(cPlayer & a_Player) override; diff --git a/src/Mobs/Zombie.h b/src/Mobs/Zombie.h index 082573d8b..118b6e6e7 100644 --- a/src/Mobs/Zombie.h +++ b/src/Mobs/Zombie.h @@ -14,7 +14,7 @@ class cZombie : public: cZombie(bool a_IsVillagerZombie); - CLASS_PROTODEF(cZombie); + CLASS_PROTODEF(cZombie) virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; virtual void MoveToPosition(const Vector3d & a_Position) override; diff --git a/src/Mobs/ZombiePigman.h b/src/Mobs/ZombiePigman.h index a4bad7efb..bae0115eb 100644 --- a/src/Mobs/ZombiePigman.h +++ b/src/Mobs/ZombiePigman.h @@ -14,7 +14,7 @@ class cZombiePigman : public: cZombiePigman(void); - CLASS_PROTODEF(cZombiePigman); + CLASS_PROTODEF(cZombiePigman) virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; virtual void KilledBy(TakeDamageInfo & a_TDI) override; diff --git a/src/OSSupport/Queue.h b/src/OSSupport/Queue.h index 269f9db41..bf4d7f004 100644 --- a/src/OSSupport/Queue.h +++ b/src/OSSupport/Queue.h @@ -26,14 +26,14 @@ struct cQueueFuncs public: /// Called when an Item is deleted from the queue without being returned - static void Delete(T) {}; + static void Delete(T) {} /// Called when an Item is inserted with EnqueueItemIfNotPresent and there is another equal value already inserted static void Combine(T & a_existing, const T & a_new) { UNUSED(a_existing); UNUSED(a_new); - }; + } }; diff --git a/src/Protocol/Protocol.h b/src/Protocol/Protocol.h index c5ba7a679..166e9ab1b 100644 --- a/src/Protocol/Protocol.h +++ b/src/Protocol/Protocol.h @@ -138,7 +138,7 @@ protected: virtual void SendData(const char * a_Data, size_t a_Size) = 0; /// Called after writing each packet, enables descendants to flush their buffers - virtual void Flush(void) {}; + virtual void Flush(void) {} // Helpers for writing partial packet data, write using SendData() void WriteByte(Byte a_Value) diff --git a/src/Protocol/Protocol125.h b/src/Protocol/Protocol125.h index d7ebf535b..bf08b6c50 100644 --- a/src/Protocol/Protocol125.h +++ b/src/Protocol/Protocol125.h @@ -90,7 +90,7 @@ public: virtual void SendThunderbolt (int a_BlockX, int a_BlockY, int a_BlockZ) override; virtual void SendTimeUpdate (Int64 a_WorldAge, Int64 a_TimeOfDay) override; virtual void SendUnloadChunk (int a_ChunkX, int a_ChunkZ) override; - virtual void SendUpdateBlockEntity (cBlockEntity & a_BlockEntity) override {}; + virtual void SendUpdateBlockEntity (cBlockEntity & a_BlockEntity) override {} virtual void SendUpdateSign (int a_BlockX, int a_BlockY, int a_BlockZ, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4) override; virtual void SendUseBed (const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ) override; virtual void SendWeather (eWeather a_Weather) override; diff --git a/src/Simulator/Simulator.h b/src/Simulator/Simulator.h index 171eba91c..4d9a18867 100644 --- a/src/Simulator/Simulator.h +++ b/src/Simulator/Simulator.h @@ -32,7 +32,7 @@ public: UNUSED(a_ChunkX); UNUSED(a_ChunkZ); UNUSED(a_Chunk); - }; + } /// Called when a block changes virtual void WakeUp(int a_BlockX, int a_BlockY, int a_BlockZ, cChunk * a_Chunk); diff --git a/src/World.h b/src/World.h index 6613b495a..9658178ae 100644 --- a/src/World.h +++ b/src/World.h @@ -96,7 +96,7 @@ public: class cTask { public: - virtual ~cTask(){}; + virtual ~cTask() {} virtual void Run(cWorld & a_World) = 0; } ; @@ -645,7 +645,7 @@ public: void GetChunkStats(int & a_NumValid, int & a_NumDirty, int & a_NumInLightingQueue); // Various queues length queries (cannot be const, they lock their CS): - inline int GetGeneratorQueueLength (void) { return m_Generator.GetQueueLength(); } // tolua_export + inline int GetGeneratorQueueLength (void) { return m_Generator.GetQueueLength(); } // tolua_export inline size_t GetLightingQueueLength (void) { return m_Lighting.GetQueueLength(); } // tolua_export inline size_t GetStorageLoadQueueLength(void) { return m_Storage.GetLoadQueueLength(); } // tolua_export inline size_t GetStorageSaveQueueLength(void) { return m_Storage.GetSaveQueueLength(); } // tolua_export @@ -677,13 +677,13 @@ public: void CastThunderbolt(int a_BlockX, int a_BlockY, int a_BlockZ); /** Sets the specified weather; resets weather interval; asks and notifies plugins of the change */ - void SetWeather (eWeather a_NewWeather); + void SetWeather(eWeather a_NewWeather); /** Forces a weather change in the next game tick */ - void ChangeWeather (void); + void ChangeWeather(void); /** Returns the current weather. Instead of comparing values directly to the weather constants, use IsWeatherXXX() functions, if possible */ - eWeather GetWeather (void) const { return m_Weather; }; + eWeather GetWeather(void) const { return m_Weather; } /** Returns true if the current weather is sun */ bool IsWeatherSunny(void) const { return (m_Weather == wSunny); } @@ -698,7 +698,7 @@ public: bool IsWeatherRain(void) const { return (m_Weather == wRain); } /** Returns true if it is raining at the specified location. This takes into account biomes. */ - bool IsWeatherRainAt (int a_BlockX, int a_BlockZ) + bool IsWeatherRainAt(int a_BlockX, int a_BlockZ) { return (IsWeatherRain() && !IsBiomeNoDownfall(GetBiomeAt(a_BlockX, a_BlockZ))); } diff --git a/src/WorldStorage/FastNBT.h b/src/WorldStorage/FastNBT.h index 7aa83fc24..4ef72e379 100644 --- a/src/WorldStorage/FastNBT.h +++ b/src/WorldStorage/FastNBT.h @@ -160,7 +160,7 @@ public: /** Returns the direct child tag of the specified name, or -1 if no such tag. */ int FindChildByName(int a_Tag, const char * a_Name, size_t a_NameLength = 0) const; - /** Returns the child tag of the specified path (Name1\Name2\Name3...), or -1 if no such tag. */ + /** Returns the child tag of the specified path (Name1/Name2/Name3...), or -1 if no such tag. */ int FindTagByPath(int a_Tag, const AString & a_Path) const; eTagType GetType(int a_Tag) const { return m_Tags[(size_t)a_Tag].m_Type; } diff --git a/src/WorldStorage/WorldStorage.h b/src/WorldStorage/WorldStorage.h index 2d5d9c830..978a5b5d1 100644 --- a/src/WorldStorage/WorldStorage.h +++ b/src/WorldStorage/WorldStorage.h @@ -103,11 +103,11 @@ protected: struct FuncTable { - static void Delete(sChunkLoad) {}; + static void Delete(sChunkLoad) {} static void Combine(sChunkLoad & a_orig, const sChunkLoad a_new) { a_orig.m_Generate |= a_new.m_Generate; - }; + } }; typedef cQueue sChunkLoadQueue; -- cgit v1.2.3 From 431d898a813ce65eeb1d0dfca449d310b2b2811b Mon Sep 17 00:00:00 2001 From: archshift Date: Thu, 24 Jul 2014 11:19:49 -0700 Subject: Made redundant semi not an error, fixed one more. --- SetFlags.cmake | 2 +- Tools/MCADefrag/Globals.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/SetFlags.cmake b/SetFlags.cmake index cf8082503..abd7bae2b 100644 --- a/SetFlags.cmake +++ b/SetFlags.cmake @@ -231,7 +231,7 @@ macro(set_exe_flags) add_flags_cxx("-Wno-error=covered-switch-default -Wno-error=shadow") add_flags_cxx("-Wno-error=exit-time-destructors -Wno-error=missing-variable-declarations") add_flags_cxx("-Wno-error=global-constructors -Wno-implicit-fallthrough") - add_flags_cxx("-Wno-weak-vtables -Wno-switch-enum") + add_flags_cxx("-Wno-error=extra-semi -Wno-weak-vtables -Wno-switch-enum") endif() endif() diff --git a/Tools/MCADefrag/Globals.h b/Tools/MCADefrag/Globals.h index 6593187e6..288069599 100644 --- a/Tools/MCADefrag/Globals.h +++ b/Tools/MCADefrag/Globals.h @@ -240,7 +240,7 @@ template class cItemCallback public: /// Called for each item in the internal list; return true to stop the loop, or false to continue enumerating virtual bool Item(Type * a_Type) = 0; - virtual ~cItemCallback() {}; + virtual ~cItemCallback() {} } ; -- cgit v1.2.3 From 3a6002de5b13c1cd56d904892e5af6123978225d Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Thu, 24 Jul 2014 21:38:25 +0100 Subject: Fixed block drops * Fixes #1242 (the issue addressed within) --- src/Blocks/BlockBigFlower.h | 6 +++--- src/Blocks/BlockHandler.cpp | 19 ++++++++++-------- src/Blocks/BlockHandler.h | 3 ++- src/Items/ItemHandler.cpp | 47 +++++++++++++++++++++++++++++++++++++++++---- src/Items/ItemSword.h | 1 - 5 files changed, 59 insertions(+), 17 deletions(-) diff --git a/src/Blocks/BlockBigFlower.h b/src/Blocks/BlockBigFlower.h index bc7098aa0..0b6ac9d8a 100644 --- a/src/Blocks/BlockBigFlower.h +++ b/src/Blocks/BlockBigFlower.h @@ -19,16 +19,16 @@ public: } - virtual void DropBlock(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_BlockPluginInterface, cEntity * a_Digger, int a_BlockX, int a_BlockY, int a_BlockZ, bool a_DropVerbatim) override + virtual void DropBlock(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_BlockPluginInterface, cEntity * a_Digger, int a_BlockX, int a_BlockY, int a_BlockZ, bool a_CanDrop, bool a_DropVerbatim) override { NIBBLETYPE Meta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ); if (Meta & 0x8) { - super::DropBlock(a_ChunkInterface, a_WorldInterface, a_BlockPluginInterface, a_Digger, a_BlockX, a_BlockY - 1, a_BlockZ, a_DropVerbatim); + super::DropBlock(a_ChunkInterface, a_WorldInterface, a_BlockPluginInterface, a_Digger, a_BlockX, a_BlockY - 1, a_BlockZ, a_CanDrop, a_DropVerbatim); } else { - super::DropBlock(a_ChunkInterface, a_WorldInterface, a_BlockPluginInterface, a_Digger, a_BlockX, a_BlockY, a_BlockZ, a_DropVerbatim); + super::DropBlock(a_ChunkInterface, a_WorldInterface, a_BlockPluginInterface, a_Digger, a_BlockX, a_BlockY, a_BlockZ, a_CanDrop, a_DropVerbatim); } } diff --git a/src/Blocks/BlockHandler.cpp b/src/Blocks/BlockHandler.cpp index 3e16f970a..ddb0186c9 100644 --- a/src/Blocks/BlockHandler.cpp +++ b/src/Blocks/BlockHandler.cpp @@ -418,19 +418,22 @@ void cBlockHandler::ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) -void cBlockHandler::DropBlock(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_BlockPluginInterface, cEntity * a_Digger, int a_BlockX, int a_BlockY, int a_BlockZ, bool a_DropVerbatim) +void cBlockHandler::DropBlock(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_BlockPluginInterface, cEntity * a_Digger, int a_BlockX, int a_BlockY, int a_BlockZ, bool a_CanDrop, bool a_DropVerbatim) { cItems Pickups; NIBBLETYPE Meta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ); - if (!a_DropVerbatim) + if (a_CanDrop) { - ConvertToPickups(Pickups, Meta); - } - else - { - // TODO: Add a proper overridable function for this - Pickups.Add(m_BlockType, 1, Meta); + if (!a_DropVerbatim) + { + ConvertToPickups(Pickups, Meta); + } + else + { + // TODO: Add a proper overridable function for this + Pickups.Add(m_BlockType, 1, Meta); + } } // Allow plugins to modify the pickups: diff --git a/src/Blocks/BlockHandler.h b/src/Blocks/BlockHandler.h index 01c64b457..a5d15d930 100644 --- a/src/Blocks/BlockHandler.h +++ b/src/Blocks/BlockHandler.h @@ -79,9 +79,10 @@ public: /** Handles the dropping, but not destruction, of a block based on what ConvertTo(Verbatim)Pickups() returns, including the spawning of pickups and alertion of plugins @param a_Digger The entity causing the drop; it may be NULL + @param a_CanDrop Informs the handler whether the block should be dropped at all. One example when this is false is when stone is destroyed by hand @param a_DropVerbatim Calls ConvertToVerbatimPickups() instead of its counterpart, meaning the block itself is dropped by default (due to a speical tool or enchantment) */ - virtual void DropBlock(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_BlockPluginInterface, cEntity * a_Digger, int a_BlockX, int a_BlockY, int a_BlockZ, bool a_DropVerbatim = false); + virtual void DropBlock(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_BlockPluginInterface, cEntity * a_Digger, int a_BlockX, int a_BlockY, int a_BlockZ, bool a_CanDrop = true, bool a_DropVerbatim = false); /// Returns step sound name of block virtual const char * GetStepSound(void); diff --git a/src/Items/ItemHandler.cpp b/src/Items/ItemHandler.cpp index 1671a8145..23dbb4348 100644 --- a/src/Items/ItemHandler.cpp +++ b/src/Items/ItemHandler.cpp @@ -330,7 +330,7 @@ void cItemHandler::OnBlockDestroyed(cWorld * a_World, cPlayer * a_Player, const { cChunkInterface ChunkInterface(a_World->GetChunkMap()); cBlockInServerPluginInterface PluginInterface(*a_World); - Handler->DropBlock(ChunkInterface, *a_World, PluginInterface, a_Player, a_BlockX, a_BlockY, a_BlockZ, CanHarvestBlock(Block)); + Handler->DropBlock(ChunkInterface, *a_World, PluginInterface, a_Player, a_BlockX, a_BlockY, a_BlockZ, CanHarvestBlock(Block), a_Player->GetEquippedItem().m_Enchantments.GetLevel(cEnchantments::enchSilkTouch) > 0); } a_Player->UseEquippedItem(); @@ -511,9 +511,48 @@ bool cItemHandler::CanRepairWithRawMaterial(short a_ItemType) bool cItemHandler::CanHarvestBlock(BLOCKTYPE a_BlockType) { - UNUSED(a_BlockType); - - return false; + switch (a_BlockType) + { + case E_BLOCK_ANVIL: + case E_BLOCK_ENCHANTMENT_TABLE: + case E_BLOCK_FURNACE: + case E_BLOCK_LIT_FURNACE: + case E_BLOCK_COAL_ORE: + case E_BLOCK_STONE: + case E_BLOCK_COBBLESTONE: + case E_BLOCK_END_STONE: + case E_BLOCK_MOSSY_COBBLESTONE: + case E_BLOCK_SANDSTONE_STAIRS: + case E_BLOCK_SANDSTONE: + case E_BLOCK_STONE_BRICKS: + case E_BLOCK_NETHER_BRICK: + case E_BLOCK_NETHERRACK: + case E_BLOCK_STONE_SLAB: + case E_BLOCK_DOUBLE_STONE_SLAB: + case E_BLOCK_STONE_PRESSURE_PLATE: + case E_BLOCK_BRICK: + case E_BLOCK_COBBLESTONE_STAIRS: + case E_BLOCK_COBBLESTONE_WALL: + case E_BLOCK_STONE_BRICK_STAIRS: + case E_BLOCK_NETHER_BRICK_STAIRS: + case E_BLOCK_CAULDRON: + case E_BLOCK_OBSIDIAN: + case E_BLOCK_DIAMOND_BLOCK: + case E_BLOCK_DIAMOND_ORE: + case E_BLOCK_GOLD_BLOCK: + case E_BLOCK_GOLD_ORE: + case E_BLOCK_REDSTONE_ORE: + case E_BLOCK_REDSTONE_ORE_GLOWING: + case E_BLOCK_EMERALD_ORE: + case E_BLOCK_IRON_BLOCK: + case E_BLOCK_IRON_ORE: + case E_BLOCK_LAPIS_ORE: + case E_BLOCK_LAPIS_BLOCK: + { + return false; + } + default: return true; + } } diff --git a/src/Items/ItemSword.h b/src/Items/ItemSword.h index 44feb2d83..368b8724e 100644 --- a/src/Items/ItemSword.h +++ b/src/Items/ItemSword.h @@ -16,7 +16,6 @@ public: cItemSwordHandler(int a_ItemType) : cItemHandler(a_ItemType) { - } virtual bool CanHarvestBlock(BLOCKTYPE a_BlockType) override -- cgit v1.2.3 From 0f298c8b84756cf5bc055ff82d43ffa9ea8d577b Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Fri, 25 Jul 2014 14:23:36 +0200 Subject: Speed up the NetherClumpFoliage finisher. Using IntNoiseXX instead of CubicNoiseXX. --- src/Generating/FinishGen.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/Generating/FinishGen.cpp b/src/Generating/FinishGen.cpp index c67cc574e..b2585bfee 100644 --- a/src/Generating/FinishGen.cpp +++ b/src/Generating/FinishGen.cpp @@ -48,8 +48,8 @@ void cFinishGenNetherClumpFoliage::GenFinish(cChunkDesc & a_ChunkDesc) double ChunkX = a_ChunkDesc.GetChunkX() + 0.1; // We can't devide through 0 so lets add 0.1 to all the chunk coordinates. double ChunkZ = a_ChunkDesc.GetChunkZ() + 0.1; - NOISE_DATATYPE Val1 = m_Noise.CubicNoise2D((float) (ChunkX * ChunkZ * 0.01f), (float) (ChunkZ / ChunkX * 0.01f)); - NOISE_DATATYPE Val2 = m_Noise.CubicNoise2D((float) (ChunkX / ChunkZ / 0.01f), (float) (ChunkZ * ChunkX / 0.01f)); + NOISE_DATATYPE Val1 = m_Noise.IntNoise2D((int) (ChunkX * ChunkZ * 0.01f), (int) (ChunkZ / ChunkX * 0.01f)); + NOISE_DATATYPE Val2 = m_Noise.IntNoise2D((int) (ChunkX / ChunkZ / 0.01f), (int) (ChunkZ * ChunkX / 0.01f)); if (Val1 < 0) { @@ -88,12 +88,14 @@ void cFinishGenNetherClumpFoliage::GenFinish(cChunkDesc & a_ChunkDesc) { continue; } + if (!cBlockInfo::IsSolid(a_ChunkDesc.GetBlockType(PosX, y - 1, PosZ))) // Only place on solid blocks { continue; } - NOISE_DATATYPE BlockType = m_Noise.CubicNoise1D((float) (ChunkX * ChunkZ) / (y * 0.1f)); + // Choose what block to use. + NOISE_DATATYPE BlockType = m_Noise.IntNoise3D((int) ChunkX, y, (int) ChunkZ); if (BlockType < -0.7) { TryPlaceClump(a_ChunkDesc, PosX, y, PosZ, E_BLOCK_BROWN_MUSHROOM); @@ -119,10 +121,10 @@ void cFinishGenNetherClumpFoliage::TryPlaceClump(cChunkDesc & a_ChunkDesc, int a for (int x = a_RelX - 4; x < a_RelX + 4; x++) { - float xx = (float) a_ChunkDesc.GetChunkX() * cChunkDef::Width + x; + int xx = a_ChunkDesc.GetChunkX() * cChunkDef::Width + x; for (int z = a_RelZ - 4; z < a_RelZ + 4; z++) { - float zz = (float) a_ChunkDesc.GetChunkZ() * cChunkDef::Width + z; + int zz = a_ChunkDesc.GetChunkZ() * cChunkDef::Width + z; for (int y = a_RelY - 2; y < a_RelY + 2; y++) { if ((y < 1) || (y > cChunkDef::Height)) @@ -149,9 +151,8 @@ void cFinishGenNetherClumpFoliage::TryPlaceClump(cChunkDesc & a_ChunkDesc, int a } } - - NOISE_DATATYPE Val = m_Noise.CubicNoise2D(xx, zz); - if (Val < -0.70) + NOISE_DATATYPE Val = m_Noise.IntNoise2D(xx, zz); + if (Val < -0.5) { a_ChunkDesc.SetBlockType(x, y, z, a_Block); } -- cgit v1.2.3 From a39e19e94a1086cc2c5974cecc5d383cd26b3d12 Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Fri, 25 Jul 2014 21:01:40 +0200 Subject: Tweaks to NetherClumpFoliage Simplefied the way NetherClupFoliage creates the X and Z coordinate. --- src/Generating/FinishGen.cpp | 40 ++++++---------------------------------- 1 file changed, 6 insertions(+), 34 deletions(-) diff --git a/src/Generating/FinishGen.cpp b/src/Generating/FinishGen.cpp index b2585bfee..4c40270e8 100644 --- a/src/Generating/FinishGen.cpp +++ b/src/Generating/FinishGen.cpp @@ -45,42 +45,14 @@ static inline bool IsWater(BLOCKTYPE a_BlockType) void cFinishGenNetherClumpFoliage::GenFinish(cChunkDesc & a_ChunkDesc) { - double ChunkX = a_ChunkDesc.GetChunkX() + 0.1; // We can't devide through 0 so lets add 0.1 to all the chunk coordinates. - double ChunkZ = a_ChunkDesc.GetChunkZ() + 0.1; - - NOISE_DATATYPE Val1 = m_Noise.IntNoise2D((int) (ChunkX * ChunkZ * 0.01f), (int) (ChunkZ / ChunkX * 0.01f)); - NOISE_DATATYPE Val2 = m_Noise.IntNoise2D((int) (ChunkX / ChunkZ / 0.01f), (int) (ChunkZ * ChunkX / 0.01f)); + int ChunkX = a_ChunkDesc.GetChunkX(); + int ChunkZ = a_ChunkDesc.GetChunkZ(); - if (Val1 < 0) - { - Val1 = -Val1; - } - - if (Val2 < 0) - { - Val2 = -Val2; - } + int Val1 = m_Noise.IntNoise2DInt(ChunkX ^ ChunkZ, ChunkZ + ChunkX); + int Val2 = m_Noise.IntNoise2DInt(ChunkZ ^ ChunkX, ChunkZ - ChunkX); - int PosX, PosZ; - // Calculate PosX - if (Val1 <= 1) - { - PosX = (int) floor(Val1 * 16); - } - else - { - PosX = (int) floor(16 / Val1); - } - - // Calculate PosZ - if (Val2 <= 1) - { - PosZ = (int) floor(Val2 * 16); - } - else - { - PosZ = (int) floor(16 / Val2); - } + int PosX = Val1 % 16; + int PosZ = Val2 % 16; for (int y = 1; y < cChunkDef::Height; y++) { -- cgit v1.2.3 From 443112d70e2483bb25594a83ded87d45aff880f6 Mon Sep 17 00:00:00 2001 From: archshift Date: Sat, 26 Jul 2014 03:34:23 -0700 Subject: Removed the new old-style-cast warning from error treatment This is a new warning included in clang that ships with OS X 10.10 Yosemite. --- SetFlags.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SetFlags.cmake b/SetFlags.cmake index abd7bae2b..a5a61eaa4 100644 --- a/SetFlags.cmake +++ b/SetFlags.cmake @@ -228,7 +228,7 @@ macro(set_exe_flags) add_flags_cxx("-Wno-error=sign-conversion -Wno-error=conversion -Wno-padded") add_flags_cxx("-Wno-error=deprecated -Wno-error=weak-vtables -Wno-error=float-equal") add_flags_cxx("-Wno-error=missing-prototypes -Wno-error=non-virtual-dtor") - add_flags_cxx("-Wno-error=covered-switch-default -Wno-error=shadow") + add_flags_cxx("-Wno-error=covered-switch-default -Wno-error=shadow -Wno-error=old-style-cast") add_flags_cxx("-Wno-error=exit-time-destructors -Wno-error=missing-variable-declarations") add_flags_cxx("-Wno-error=global-constructors -Wno-implicit-fallthrough") add_flags_cxx("-Wno-error=extra-semi -Wno-weak-vtables -Wno-switch-enum") -- cgit v1.2.3 From 1595ef73dcd6f6a525744185bd24343c3f8050c8 Mon Sep 17 00:00:00 2001 From: archshift Date: Sat, 26 Jul 2014 03:42:42 -0700 Subject: Endianness.h: undefined ntohll before redefining --- src/Endianness.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Endianness.h b/src/Endianness.h index 5997086e0..9aeb44986 100644 --- a/src/Endianness.h +++ b/src/Endianness.h @@ -1,6 +1,7 @@ #pragma once +#undef ntohll #define ntohll(x) ((((UInt64)ntohl((u_long)x)) << 32) + ntohl(x >> 32)) -- cgit v1.2.3 From e23f0238a825669ffdf75cb8cd157a7df68ae363 Mon Sep 17 00:00:00 2001 From: archshift Date: Sat, 26 Jul 2014 03:58:59 -0700 Subject: Git: Ignore AllFiles.lst (generated by cmake) --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 400bf2c91..51987336c 100644 --- a/.gitignore +++ b/.gitignore @@ -15,6 +15,7 @@ cloc.xsl *.suo /EveryNight.cmd /UploadLuaAPI.cmd +AllFiles.lst # IDE Stuff ## Sublime Text -- cgit v1.2.3