From b35771ca0d7faa6572025f8e9e61007df498e14c Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Tue, 20 Aug 2013 22:47:10 +0100 Subject: [PATCH 01/25] Fixed broken carpet handler [SEE DESC] Made BlockHandler pass on control to carpet handler Declared thinggummies in carpet handler Fixed carpet block pushback using incorrect format --- source/Blocks/BlockCarpet.h | 12 +++++++++--- source/Blocks/BlockHandler.cpp | 1 + 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/source/Blocks/BlockCarpet.h b/source/Blocks/BlockCarpet.h index f70ff45b6..9ac998131 100644 --- a/source/Blocks/BlockCarpet.h +++ b/source/Blocks/BlockCarpet.h @@ -8,6 +8,8 @@ #pragma once +#include "BlockHandler.h" + @@ -16,7 +18,11 @@ class cBlockCarpetHandler : public cBlockHandler { public: - cBlockCarpetHandler(BLOCKTYPE a_BlockType); + cBlockCarpetHandler(BLOCKTYPE a_BlockType) + : cBlockHandler(a_BlockType) + { + } + virtual const char * GetStepSound(void) override { @@ -39,13 +45,13 @@ public: virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override { - a_Pickups.push_back(cItem(E_BLOCK_CARPET, a_BlockMeta)); + a_Pickups.push_back(cItem(E_BLOCK_CARPET, 1, a_BlockMeta)); } virtual bool CanBeAt(int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override { - return ((a_RelY > 0) && (a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ) != E_BLOCK_AIR)); + return (a_RelY > 0) && (a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ) != E_BLOCK_AIR); } } ; diff --git a/source/Blocks/BlockHandler.cpp b/source/Blocks/BlockHandler.cpp index 6584eeed4..0fa013058 100644 --- a/source/Blocks/BlockHandler.cpp +++ b/source/Blocks/BlockHandler.cpp @@ -104,6 +104,7 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType) case E_BLOCK_BROWN_MUSHROOM: return new cBlockMushroomHandler (a_BlockType); case E_BLOCK_CACTUS: return new cBlockCactusHandler (a_BlockType); case E_BLOCK_CARROTS: return new cBlockCropsHandler (a_BlockType); + case E_BLOCK_CARPET: return new cBlockCarpetHandler (a_BlockType); case E_BLOCK_CAULDRON: return new cBlockCauldronHandler (a_BlockType); case E_BLOCK_CHEST: return new cBlockChestHandler (a_BlockType); case E_BLOCK_COAL_ORE: return new cBlockOreHandler (a_BlockType); From 8e153f6689880da1380af1bf9d858d1d3a8461bb Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Tue, 20 Aug 2013 23:17:49 +0100 Subject: [PATCH 02/25] Fixed longstanding issue with slabs Fixes FS#298 --- source/Blocks/BlockSlab.h | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/source/Blocks/BlockSlab.h b/source/Blocks/BlockSlab.h index f34f42bae..dd80da27e 100644 --- a/source/Blocks/BlockSlab.h +++ b/source/Blocks/BlockSlab.h @@ -35,7 +35,18 @@ public: NIBBLETYPE Meta = (NIBBLETYPE)(a_Player->GetEquippedItem().m_ItemDamage & 0x07); switch (a_BlockFace) { - case BLOCK_FACE_TOP: a_BlockMeta = Meta & 0x7; break; // Always bottom half of the slab when placing on top of something + case BLOCK_FACE_TOP: + { + if (a_World->GetBlock(a_BlockX, a_BlockY - 1, a_BlockZ) == E_BLOCK_STONE_SLAB) + { + a_World->FastSetBlock(a_BlockX, a_BlockY - 1, a_BlockZ, E_BLOCK_DOUBLE_STONE_SLAB, Meta); + a_BlockType = E_BLOCK_AIR; + } + else + { + a_BlockMeta = Meta & 0x7; break; // Always bottom half of the slab when placing on top of something + } + } case BLOCK_FACE_BOTTOM: a_BlockMeta = Meta | 0x8; break; // Always top half of the slab when placing on bottom of something case BLOCK_FACE_EAST: case BLOCK_FACE_NORTH: From 0c44904766ee835dc07a96d563d3d109fcda293a Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Tue, 20 Aug 2013 23:24:29 +0100 Subject: [PATCH 03/25] Changed comments to be more accurate --- source/Blocks/BlockSlab.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/source/Blocks/BlockSlab.h b/source/Blocks/BlockSlab.h index dd80da27e..44e1962b9 100644 --- a/source/Blocks/BlockSlab.h +++ b/source/Blocks/BlockSlab.h @@ -39,15 +39,15 @@ public: { if (a_World->GetBlock(a_BlockX, a_BlockY - 1, a_BlockZ) == E_BLOCK_STONE_SLAB) { - a_World->FastSetBlock(a_BlockX, a_BlockY - 1, a_BlockZ, E_BLOCK_DOUBLE_STONE_SLAB, Meta); - a_BlockType = E_BLOCK_AIR; + a_World->FastSetBlock(a_BlockX, a_BlockY - 1, a_BlockZ, E_BLOCK_DOUBLE_STONE_SLAB, Meta); //Set it to a slabby block + a_BlockType = E_BLOCK_AIR; //Stop the server trying to place another slab on top } else { - a_BlockMeta = Meta & 0x7; break; // Always bottom half of the slab when placing on top of something + a_BlockMeta = Meta & 0x7; break; //Bottom half if on top of non slab block } } - case BLOCK_FACE_BOTTOM: a_BlockMeta = Meta | 0x8; break; // Always top half of the slab when placing on bottom of something + case BLOCK_FACE_BOTTOM: a_BlockMeta = Meta | 0x8; break; //Always top when placing on bottom of something case BLOCK_FACE_EAST: case BLOCK_FACE_NORTH: case BLOCK_FACE_SOUTH: From c565950e1fd336e08bda35c26cb9b8983681fd60 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 22 Aug 2013 08:51:40 +0200 Subject: [PATCH 04/25] Removed unwanted VirtualHooks remnants. cEntity no longer needs its SpawnOn() default-implemented, it can now be a true pure virtual function. --- source/Entities/Entity.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/source/Entities/Entity.h b/source/Entities/Entity.h index 820405cb9..7a070a5dd 100644 --- a/source/Entities/Entity.h +++ b/source/Entities/Entity.h @@ -276,9 +276,8 @@ public: /** Descendants override this function to send a command to the specified client to spawn the entity on the client. To spawn on all eligible clients, use cChunkMap::BroadcastSpawnEntity() - Needs to have a default implementation due to Lua bindings. */ - virtual void SpawnOn(cClientHandle & a_Client) {ASSERT(!"SpawnOn() unimplemented!"); } + virtual void SpawnOn(cClientHandle & a_Client) = 0; // tolua_begin From 7eae58281a1c912f298ac8d5f463a2c60cdc2440 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 22 Aug 2013 21:03:20 +0200 Subject: [PATCH 05/25] Fixed AddHook() wanting old-style function names. Error reported by STR_Warrior in the forum http://forum.mc-server.org/showthread.php?tid=1227&pid=9620#pid9620 --- source/Plugin.h | 7 ------- source/PluginLua.cpp | 30 ++++++++++++++++++++---------- source/PluginLua.h | 3 ++- source/PluginManager.cpp | 4 ---- 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/source/Plugin.h b/source/Plugin.h index 6e3e5f1d2..be803bab2 100644 --- a/source/Plugin.h +++ b/source/Plugin.h @@ -113,13 +113,6 @@ public: /// All bound console commands are to be removed, do any language-dependent cleanup here virtual void ClearConsoleCommands(void) {} ; - /** Called from cPluginManager::AddHook() to check if the hook can be added. - Plugin API providers may check if the plugin is written correctly (has the hook handler function) - Returns true if the hook can be added (handler exists) - Descendants should also log the specific error message as a warning if they return false. - */ - virtual bool CanAddHook(int a_Hook) = 0; - // tolua_begin const AString & GetName(void) const { return m_Name; } void SetName(const AString & a_Name) { m_Name = a_Name; } diff --git a/source/PluginLua.cpp b/source/PluginLua.cpp index 1c8cbef47..81a536838 100644 --- a/source/PluginLua.cpp +++ b/source/PluginLua.cpp @@ -1240,13 +1240,16 @@ void cPluginLua::ClearConsoleCommands(void) -bool cPluginLua::CanAddHook(int a_Hook) +bool cPluginLua::CanAddOldStyleHook(int a_HookType) { - const char * FnName = GetHookFnName(a_Hook); + const char * FnName = GetHookFnName(a_HookType); if (FnName == NULL) { // Unknown hook ID - LOGWARNING("Plugin %s wants to add an unknown hook ID (%d). The plugin need not work properly.", GetName().c_str(), a_Hook); + LOGWARNING("Plugin %s wants to add an unknown hook ID (%d). The plugin need not work properly.", + GetName().c_str(), a_HookType + ); + m_LuaState.LogStackTrace(); return false; } @@ -1257,12 +1260,9 @@ bool cPluginLua::CanAddHook(int a_Hook) } LOGWARNING("Plugin %s wants to add a hook (%d), but it doesn't provide the callback function \"%s\" for it. The plugin need not work properly.", - GetName().c_str(), a_Hook, FnName + GetName().c_str(), a_HookType, FnName ); - - // Lua stacktrace: m_LuaState.LogStackTrace(); - return false; } @@ -1270,9 +1270,9 @@ bool cPluginLua::CanAddHook(int a_Hook) -const char * cPluginLua::GetHookFnName(int a_Hook) +const char * cPluginLua::GetHookFnName(int a_HookType) { - switch (a_Hook) + switch (a_HookType) { case cPluginManager::HOOK_BLOCK_TO_PICKUPS: return "OnBlockToPickups"; case cPluginManager::HOOK_CHAT: return "OnChat"; @@ -1331,7 +1331,17 @@ bool cPluginLua::AddHookRef(int a_HookType, int a_FnRefIdx) { ASSERT(m_CriticalSection.IsLockedByCurrentThread()); // It probably has to be, how else would we have a LuaState? - m_HookMap[a_HookType].push_back(new cLuaState::cRef(m_LuaState, a_FnRefIdx)); + // Check if the function reference is valid: + cLuaState::cRef * Ref = new cLuaState::cRef(m_LuaState, a_FnRefIdx); + if ((Ref == NULL) || !Ref->IsValid()) + { + LOGWARNING("Plugin %s tried to add a hook %d with bad handler function.", GetName().c_str(), a_HookType); + m_LuaState.LogStackTrace(); + delete Ref; + return false; + } + + m_HookMap[a_HookType].push_back(Ref); return true; } diff --git a/source/PluginLua.h b/source/PluginLua.h index 877de2274..fee9c4986 100644 --- a/source/PluginLua.h +++ b/source/PluginLua.h @@ -100,7 +100,8 @@ public: virtual void ClearConsoleCommands(void) override; - virtual bool CanAddHook(int a_Hook) override; + /// Returns true if the plugin contains the function for the specified hook type, using the old-style registration (#121) + bool CanAddOldStyleHook(int a_HookType); // cWebPlugin override virtual const AString GetWebTitle(void) const {return GetName(); } diff --git a/source/PluginManager.cpp b/source/PluginManager.cpp index a2726bd58..93ee71926 100644 --- a/source/PluginManager.cpp +++ b/source/PluginManager.cpp @@ -1619,10 +1619,6 @@ void cPluginManager::AddHook(cPlugin * a_Plugin, int a_Hook) LOGWARN("Called cPluginManager::AddHook() with a_Plugin == NULL"); return; } - if (!a_Plugin->CanAddHook(a_Hook)) - { - return; - } PluginList & Plugins = m_Hooks[a_Hook]; Plugins.remove(a_Plugin); Plugins.push_back(a_Plugin); From 52d8da6ebe30be046566ba6a34099ba5ebb843a1 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Fri, 23 Aug 2013 18:13:54 +0100 Subject: [PATCH 06/25] Fixed lighters replacing blocks --- source/Items/ItemLighter.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/source/Items/ItemLighter.h b/source/Items/ItemLighter.h index 39534c7b1..4281a2d0c 100644 --- a/source/Items/ItemLighter.h +++ b/source/Items/ItemLighter.h @@ -40,10 +40,13 @@ public: } default: { - // Light a fire next to the block: + // Light a fire next to/on top of the block if air: AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace); - a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_FIRE, 0); - break; + if (a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ) == E_BLOCK_AIR) + { + a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_FIRE, 0); + break; + } } } From a671e45cd55adc4ae477225e59afb2969454b1d4 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Fri, 23 Aug 2013 19:38:39 +0100 Subject: [PATCH 07/25] Double slabs work *choke choke* --- VC2008/MCServer.vcproj | 3 ++ source/Blocks/BlockDoubleSlab.h | 36 +++++++++++++++++ source/Blocks/BlockHandler.cpp | 5 ++- source/Blocks/BlockSlab.h | 58 ++++++++++++++++++++++----- source/ClientHandle.cpp | 69 +++++++++++++++++++++++---------- source/ClientHandle.h | 2 +- 6 files changed, 140 insertions(+), 33 deletions(-) create mode 100644 source/Blocks/BlockDoubleSlab.h diff --git a/VC2008/MCServer.vcproj b/VC2008/MCServer.vcproj index fbbd999a9..9688aa981 100644 --- a/VC2008/MCServer.vcproj +++ b/VC2008/MCServer.vcproj @@ -2015,6 +2015,9 @@ RelativePath="..\source\Blocks\BlockDeadBush.h" > + diff --git a/source/Blocks/BlockDoubleSlab.h b/source/Blocks/BlockDoubleSlab.h new file mode 100644 index 000000000..c91fe64e6 --- /dev/null +++ b/source/Blocks/BlockDoubleSlab.h @@ -0,0 +1,36 @@ + +#pragma once + +#include "BlockHandler.h" +#include "../Items/ItemHandler.h" + + + + + +class cBlockDoubleSlabHandler : + public cBlockHandler +{ +public: + cBlockDoubleSlabHandler(BLOCKTYPE a_BlockType) + : cBlockHandler(a_BlockType) + { + } + + + virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override + { + char Count = ((m_BlockType == E_BLOCK_DOUBLE_STONE_SLAB) || (m_BlockType == E_BLOCK_DOUBLE_WOODEN_SLAB)) ? 2 : 1; + a_Pickups.push_back(cItem(m_BlockType, Count, a_BlockMeta)); + } + + + virtual const char * GetStepSound(void) override + { + return ((m_BlockType == E_BLOCK_DOUBLE_WOODEN_SLAB) || (m_BlockType == E_BLOCK_DOUBLE_WOODEN_SLAB)) ? "step.wood" : "step.stone"; + } +} ; + + + + diff --git a/source/Blocks/BlockHandler.cpp b/source/Blocks/BlockHandler.cpp index 0fa013058..22efa25f5 100644 --- a/source/Blocks/BlockHandler.cpp +++ b/source/Blocks/BlockHandler.cpp @@ -17,6 +17,7 @@ #include "BlockDeadBush.h" #include "BlockDirt.h" #include "BlockDoor.h" +#include "BlockDoubleSlab.h" #include "BlockDropSpenser.h" #include "BlockEnderchest.h" #include "BlockEntity.h" @@ -117,8 +118,8 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType) case E_BLOCK_DIAMOND_ORE: return new cBlockOreHandler (a_BlockType); case E_BLOCK_DIRT: return new cBlockDirtHandler (a_BlockType); case E_BLOCK_DISPENSER: return new cBlockDropSpenserHandler (a_BlockType); - case E_BLOCK_DOUBLE_STONE_SLAB: return new cBlockSlabHandler (a_BlockType); - case E_BLOCK_DOUBLE_WOODEN_SLAB: return new cBlockSlabHandler (a_BlockType); + case E_BLOCK_DOUBLE_STONE_SLAB: return new cBlockDoubleSlabHandler (a_BlockType); + case E_BLOCK_DOUBLE_WOODEN_SLAB: return new cBlockDoubleSlabHandler (a_BlockType); case E_BLOCK_DROPPER: return new cBlockDropSpenserHandler (a_BlockType); case E_BLOCK_EMERALD_ORE: return new cBlockOreHandler (a_BlockType); case E_BLOCK_ENDER_CHEST: return new cBlockEnderchestHandler (a_BlockType); diff --git a/source/Blocks/BlockSlab.h b/source/Blocks/BlockSlab.h index 44e1962b9..881a85615 100644 --- a/source/Blocks/BlockSlab.h +++ b/source/Blocks/BlockSlab.h @@ -6,7 +6,6 @@ - class cBlockSlabHandler : public cBlockHandler { @@ -19,7 +18,7 @@ public: virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override { - char Count = ((m_BlockType == E_BLOCK_DOUBLE_STONE_SLAB) || (m_BlockType == E_BLOCK_DOUBLE_WOODEN_SLAB)) ? 2 : 1; + char Count = ((m_BlockType == E_BLOCK_STONE_SLAB) || (m_BlockType == E_BLOCK_WOODEN_SLAB)) ? 1 : 1; a_Pickups.push_back(cItem(m_BlockType, Count, a_BlockMeta)); } @@ -32,22 +31,46 @@ public: ) override { a_BlockType = m_BlockType; + BLOCKTYPE Type = (BLOCKTYPE)(a_Player->GetEquippedItem().m_ItemType); NIBBLETYPE Meta = (NIBBLETYPE)(a_Player->GetEquippedItem().m_ItemDamage & 0x07); + + int DoubleType; + if (Type == E_BLOCK_STONE_SLAB) + { + DoubleType = 43; //Make it a double slab (with old type wood) + } + else + { + DoubleType = 125; //Make it a wooden double slab (new type) + } + cItemHandler * ItemHandler = cItemHandler::GetItemHandler(DoubleType); + switch (a_BlockFace) { case BLOCK_FACE_TOP: { - if (a_World->GetBlock(a_BlockX, a_BlockY - 1, a_BlockZ) == E_BLOCK_STONE_SLAB) + if ((a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ) == E_BLOCK_STONE_SLAB) || (a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ) == E_BLOCK_WOODEN_SLAB)) { - a_World->FastSetBlock(a_BlockX, a_BlockY - 1, a_BlockZ, E_BLOCK_DOUBLE_STONE_SLAB, Meta); //Set it to a slabby block - a_BlockType = E_BLOCK_AIR; //Stop the server trying to place another slab on top + a_Player->GetClientHandle()->HandlePlaceBlock(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, *ItemHandler); + return false; } else { a_BlockMeta = Meta & 0x7; break; //Bottom half if on top of non slab block } } - case BLOCK_FACE_BOTTOM: a_BlockMeta = Meta | 0x8; break; //Always top when placing on bottom of something + case BLOCK_FACE_BOTTOM: + { + if ((a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ) == E_BLOCK_STONE_SLAB) || (a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ) == E_BLOCK_WOODEN_SLAB)) + { + a_Player->GetClientHandle()->HandlePlaceBlock(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, *ItemHandler); + return false; + } + else + { + a_BlockMeta = Meta | 0x8; break; //Bottom half if on top of non slab block + } + } case BLOCK_FACE_EAST: case BLOCK_FACE_NORTH: case BLOCK_FACE_SOUTH: @@ -56,14 +79,29 @@ public: if (a_CursorY > 7) { // Cursor at the top half of the face, place a top half of slab - a_BlockMeta = Meta | 0x8; + if ((a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ) == E_BLOCK_STONE_SLAB) || (a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ) == E_BLOCK_WOODEN_SLAB)) + { + a_Player->GetClientHandle()->HandlePlaceBlock(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, *ItemHandler); + return false; + } + else + { + a_BlockMeta = Meta | 0x8; break; + } } else { // Cursor at the bottom half of the face, place a bottom half of slab: - a_BlockMeta = Meta & 0x7; + if ((a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ) == E_BLOCK_STONE_SLAB) || (a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ) == E_BLOCK_WOODEN_SLAB)) + { + a_Player->GetClientHandle()->HandlePlaceBlock(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, *ItemHandler); + return false; + } + else + { + a_BlockMeta = Meta & 0x7; break; + } } - break; } } // switch (a_BlockFace) return true; @@ -72,7 +110,7 @@ public: virtual const char * GetStepSound(void) override { - return ((m_BlockType == E_BLOCK_WOODEN_SLAB) || (m_BlockType == E_BLOCK_DOUBLE_WOODEN_SLAB)) ? "step.wood" : "step.stone"; + return ((m_BlockType == E_BLOCK_WOODEN_SLAB) || (m_BlockType == E_BLOCK_STONE_SLAB)) ? "step.wood" : "step.stone"; } } ; diff --git a/source/ClientHandle.cpp b/source/ClientHandle.cpp index 57830f63c..937aebd1a 100644 --- a/source/ClientHandle.cpp +++ b/source/ClientHandle.cpp @@ -846,33 +846,62 @@ void cClientHandle::HandlePlaceBlock(int a_BlockX, int a_BlockY, int a_BlockZ, c } cWorld * World = m_Player->GetWorld(); - - // Check if the block ignores build collision (water, grass etc.): - BLOCKTYPE ClickedBlock = World->GetBlock(a_BlockX, a_BlockY, a_BlockZ); - cBlockHandler * Handler = cBlockHandler::GetBlockHandler(ClickedBlock); - if (Handler->DoesIgnoreBuildCollision()) + + BLOCKTYPE ClickedBlock; + NIBBLETYPE ClickedBlockMeta; + BLOCKTYPE EquippedBlock = (BLOCKTYPE)(m_Player->GetEquippedItem().m_ItemType); + NIBBLETYPE EquippedBlockDamage = (NIBBLETYPE)(m_Player->GetEquippedItem().m_ItemDamage); + + World->GetBlockTypeMeta(a_BlockX, a_BlockY, a_BlockZ, ClickedBlock, ClickedBlockMeta); + + //Special slab handler coding + if ( + ((a_BlockFace == BLOCK_FACE_TOP) || (a_BlockFace == BLOCK_FACE_BOTTOM)) && + ((ClickedBlock == E_BLOCK_STONE_SLAB) || (ClickedBlock == E_BLOCK_WOODEN_SLAB)) && //Is clicked a slab? + ((EquippedBlock == E_BLOCK_STONE_SLAB) || (EquippedBlock == E_BLOCK_WOODEN_SLAB)) && //Is equipped a slab? + ((ClickedBlockMeta & 0x07) == (EquippedBlockDamage & 0x07)) //Is clicked same type of slab as item in hand? + ) { - Handler->OnDestroyedByPlayer(World, m_Player, a_BlockX, a_BlockY, a_BlockZ); - // World->FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_AIR, 0); + //Don't move the coordinates } else { - AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace); - // Check for Blocks not allowing placement on top - if ((a_BlockFace == BLOCK_FACE_TOP) && !Handler->DoesAllowBlockOnTop()) + //Check if the block ignores build collision (water, grass etc.): + cBlockHandler * Handler = cBlockHandler::GetBlockHandler(ClickedBlock); + if (Handler->DoesIgnoreBuildCollision()) { - // Resend the old block - // Some times the client still places the block O.o - World->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, m_Player); - return; + Handler->OnDestroyedByPlayer(World, m_Player, a_BlockX, a_BlockY, a_BlockZ); + //World->FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_AIR, 0); } - - - BLOCKTYPE PlaceBlock = World->GetBlock(a_BlockX, a_BlockY, a_BlockZ); - if (!BlockHandler(PlaceBlock)->DoesIgnoreBuildCollision()) + else { - // Tried to place a block *into* another? - return; // Happens when you place a block aiming at side of block like torch or stem + AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace); + //On side of block, make sure that placement won't be cancelled if there is a slab there + //No need to combinability checks, client will do that + if ((World->GetBlock(a_BlockX, a_BlockY, a_BlockZ) == E_BLOCK_STONE_SLAB) || (World->GetBlock(a_BlockX, a_BlockY, a_BlockZ) == E_BLOCK_WOODEN_SLAB)) + { + //Is a slab, don't do checks and proceed to double-slabbing + } + else + { + // Check for Blocks not allowing placement on top + if ((a_BlockFace == BLOCK_FACE_TOP) && !Handler->DoesAllowBlockOnTop()) + { + // Resend the old block + // Some times the client still places the block O.o + World->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, m_Player); + return; + } + + + BLOCKTYPE PlaceBlock = World->GetBlock(a_BlockX, a_BlockY, a_BlockZ); + if (!BlockHandler(PlaceBlock)->DoesIgnoreBuildCollision()) + { + // Tried to place a block *into* another? + // Happens when you place a block aiming at side of block like torch or stem + return; + } + } } } diff --git a/source/ClientHandle.h b/source/ClientHandle.h index c85257df1..a2e29f9dc 100644 --- a/source/ClientHandle.h +++ b/source/ClientHandle.h @@ -312,7 +312,7 @@ private: void HandleBlockDigFinished(int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, BLOCKTYPE a_OldBlock, NIBBLETYPE a_OldMeta); /// Handles the block placing packet when it is a real block placement (not block-using, item-using or eating) - void HandlePlaceBlock(int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, cItemHandler & a_ItemHandler); + public: void HandlePlaceBlock(int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, cItemHandler & a_ItemHandler); // cSocketThreads::cCallback overrides: virtual void DataReceived (const char * a_Data, int a_Size) override; // Data is received from the client From a6f068927a186e70fac62367f766bcf4ab1fed51 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Fri, 23 Aug 2013 19:45:11 +0100 Subject: [PATCH 08/25] Fix VSProject path issue --- VC2008/MCServer.vcproj | 1 + 1 file changed, 1 insertion(+) diff --git a/VC2008/MCServer.vcproj b/VC2008/MCServer.vcproj index 9688aa981..16737e0ef 100644 --- a/VC2008/MCServer.vcproj +++ b/VC2008/MCServer.vcproj @@ -2017,6 +2017,7 @@ Date: Fri, 23 Aug 2013 20:12:21 +0100 Subject: [PATCH 09/25] Fixed incorrect double slab drops --- source/Blocks/BlockDoubleSlab.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/source/Blocks/BlockDoubleSlab.h b/source/Blocks/BlockDoubleSlab.h index c91fe64e6..ed6ae9a70 100644 --- a/source/Blocks/BlockDoubleSlab.h +++ b/source/Blocks/BlockDoubleSlab.h @@ -20,8 +20,15 @@ public: virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override { - char Count = ((m_BlockType == E_BLOCK_DOUBLE_STONE_SLAB) || (m_BlockType == E_BLOCK_DOUBLE_WOODEN_SLAB)) ? 2 : 1; - a_Pickups.push_back(cItem(m_BlockType, Count, a_BlockMeta)); + if (m_BlockType == E_BLOCK_DOUBLE_STONE_SLAB) + { + m_BlockType = E_BLOCK_STONE_SLAB; + } + else + { + m_BlockType = E_BLOCK_WOODEN_SLAB; + } + a_Pickups.push_back(cItem(m_BlockType, 2, a_BlockMeta)); } From 728eb9b6a71f316217936533de2bc57229d7433e Mon Sep 17 00:00:00 2001 From: Alexander Harkness Date: Sat, 24 Aug 2013 11:08:44 +0100 Subject: [PATCH 10/25] Change the gitignore, fix #122 --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index b8a60a580..7706ecc0a 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,4 @@ cloc.xsl *.user *.suo /EveryNight.cmd +*.sublime-* From 8bb2cab9930f807b8434ca6d75da0377605c84da Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sat, 24 Aug 2013 11:10:30 +0100 Subject: [PATCH 11/25] Fixed final slab bug This bug allowed a double slab to be made below by placing a compatible slab on a "top" slab. The coordinates are always one lower, so now it checks to see if the slab orientation can be made into a double. --- source/ClientHandle.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/ClientHandle.cpp b/source/ClientHandle.cpp index 937aebd1a..8ff93ec1b 100644 --- a/source/ClientHandle.cpp +++ b/source/ClientHandle.cpp @@ -856,7 +856,7 @@ void cClientHandle::HandlePlaceBlock(int a_BlockX, int a_BlockY, int a_BlockZ, c //Special slab handler coding if ( - ((a_BlockFace == BLOCK_FACE_TOP) || (a_BlockFace == BLOCK_FACE_BOTTOM)) && + (((a_BlockFace == BLOCK_FACE_TOP) && (ClickedBlockMeta == (EquippedBlockDamage & 0x07))) || ((a_BlockFace == BLOCK_FACE_BOTTOM) && (ClickedBlockMeta == (EquippedBlockDamage | 0x08)))) && ((ClickedBlock == E_BLOCK_STONE_SLAB) || (ClickedBlock == E_BLOCK_WOODEN_SLAB)) && //Is clicked a slab? ((EquippedBlock == E_BLOCK_STONE_SLAB) || (EquippedBlock == E_BLOCK_WOODEN_SLAB)) && //Is equipped a slab? ((ClickedBlockMeta & 0x07) == (EquippedBlockDamage & 0x07)) //Is clicked same type of slab as item in hand? From e1578087378caa7d70e29e1aef993688d5494473 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 24 Aug 2013 16:12:27 +0200 Subject: [PATCH 12/25] Added Unicode, Inc.'s notice. Fixes #123. --- source/StringUtils.cpp | 43 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 38 insertions(+), 5 deletions(-) diff --git a/source/StringUtils.cpp b/source/StringUtils.cpp index 403b10a7c..cb91a4da7 100644 --- a/source/StringUtils.cpp +++ b/source/StringUtils.cpp @@ -350,6 +350,33 @@ AString & RawBEToUTF8(short * a_RawData, int a_NumShorts, AString & a_UTF8) // UTF-8 conversion code adapted from: // http://stackoverflow.com/questions/2867123/convert-utf-16-to-utf-8-under-windows-and-linux-in-c +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// Begin of Unicode, Inc.'s code / information +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +/* +Notice from the original file: +* Copyright 2001-2004 Unicode, Inc. +* +* Disclaimer +* +* This source code is provided as is by Unicode, Inc. No claims are +* made as to fitness for any particular purpose. No warranties of any +* kind are expressed or implied. The recipient agrees to determine +* applicability of information provided. If this file has been +* purchased on magnetic or optical media from Unicode, Inc., the +* sole remedy for any claim will be exchange of defective media +* within 90 days of receipt. +* +* Limitations on Rights to Redistribute This Code +* +* Unicode, Inc. hereby grants the right to freely use the information +* supplied in this file in the creation of products supporting the +* Unicode Standard, and to make copies of this file in any form +* for internal or external distribution as long as this notice +* remains attached. +*/ + #define UNI_MAX_BMP 0x0000FFFF #define UNI_MAX_UTF16 0x0010FFFF #define UNI_MAX_UTF32 0x7FFFFFFF @@ -505,18 +532,24 @@ AString & UTF8ToRawBEUTF16(const char * a_UTF8, size_t a_UTF8Length, AString & a } while (tmpBytesToRead > 0); } - --------------------------------------------------------------------- */ - + --------------------------------------------------------------------- +*/ + +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// End of Unicode, Inc.'s code / information +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -/* + + +#define HEX(x) ((x) > 9 ? (x) + 'A' - 10 : (x) + '0') + +/** format binary data this way: 00001234: 31 32 33 34 35 36 37 38 39 30 61 62 63 64 65 66 1234567890abcdef */ -#define HEX(x) ((x) > 9 ? (x) + 'A' - 10 : (x) + '0') - AString & CreateHexDump(AString & a_Out, const void * a_Data, int a_Size, int a_LineLength) { ASSERT(a_LineLength <= 120); // Due to using a fixed size line buffer; increase line[]'s size to lift this max From d1cc6d9a9cd76eca7ab98ef5253b29573f8d6959 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sat, 24 Aug 2013 18:46:19 +0100 Subject: [PATCH 13/25] Added comments and fixed a bug Bug was placing slabs between slabs not making a double slab. --- source/Blocks/BlockSlab.h | 76 +++++++++++++++++++-------------------- source/ClientHandle.cpp | 30 +++++++++++----- 2 files changed, 58 insertions(+), 48 deletions(-) diff --git a/source/Blocks/BlockSlab.h b/source/Blocks/BlockSlab.h index 881a85615..6caa3a27a 100644 --- a/source/Blocks/BlockSlab.h +++ b/source/Blocks/BlockSlab.h @@ -18,8 +18,7 @@ public: virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override { - char Count = ((m_BlockType == E_BLOCK_STONE_SLAB) || (m_BlockType == E_BLOCK_WOODEN_SLAB)) ? 1 : 1; - a_Pickups.push_back(cItem(m_BlockType, Count, a_BlockMeta)); + a_Pickups.push_back(cItem(m_BlockType, 1, a_BlockMeta)); } @@ -37,39 +36,54 @@ public: int DoubleType; if (Type == E_BLOCK_STONE_SLAB) { - DoubleType = 43; //Make it a double slab (with old type wood) + DoubleType = 43; // Make it a double slab (with old type wood) } else { - DoubleType = 125; //Make it a wooden double slab (new type) + DoubleType = 125; // Make it a wooden double slab (new type) } + // HandlePlaceBlock wants a cItemHandler pointer thing, so let's give it one cItemHandler * ItemHandler = cItemHandler::GetItemHandler(DoubleType); - switch (a_BlockFace) + // Check if the block at the coordinates is a slab. Eligibility for combining etc. were processed in ClientHandle + BLOCKTYPE IsSlab; + IsSlab = a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ); + if ((IsSlab == E_BLOCK_STONE_SLAB) || (IsSlab == E_BLOCK_WOODEN_SLAB)) { - case BLOCK_FACE_TOP: + // Special handling for non top/bottom clicks + if ((a_BlockFace == BLOCK_FACE_TOP) || (a_BlockFace == BLOCK_FACE_BOTTOM)) { - if ((a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ) == E_BLOCK_STONE_SLAB) || (a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ) == E_BLOCK_WOODEN_SLAB)) + // As with previous, call the function in ClientHandle that places a block when the client sends the packet + // This effectively simulates a client placing a double slab, so it goes through plugins etc. so the slabbing can be cancelled + a_Player->GetClientHandle()->HandlePlaceBlock(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, *ItemHandler); + } + else + { + // If player cursor is at top half of block + if (a_CursorY > 7) { - a_Player->GetClientHandle()->HandlePlaceBlock(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, *ItemHandler); - return false; + // Edit the call to use BLOCK_FACE_BOTTOM, otherwise it places incorrectly + a_Player->GetClientHandle()->HandlePlaceBlock(a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_TOP, a_CursorX, a_CursorY, a_CursorZ, *ItemHandler); } else { - a_BlockMeta = Meta & 0x7; break; //Bottom half if on top of non slab block + // Edit the call to use BLOCK_FACE_TOP, otherwise it places incorrectly + a_Player->GetClientHandle()->HandlePlaceBlock(a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_BOTTOM, a_CursorX, a_CursorY, a_CursorZ, *ItemHandler); } } + return false; // Cancel the event because dblslabs were already placed, nothing else needed + } + + switch (a_BlockFace) + { + // Previous IF condition didn't cancel the event (not a slab at coords), so place slab with correct metas + case BLOCK_FACE_TOP: + { + a_BlockMeta = Meta & 0x7; break; // Bottom half slab block + } case BLOCK_FACE_BOTTOM: { - if ((a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ) == E_BLOCK_STONE_SLAB) || (a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ) == E_BLOCK_WOODEN_SLAB)) - { - a_Player->GetClientHandle()->HandlePlaceBlock(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, *ItemHandler); - return false; - } - else - { - a_BlockMeta = Meta | 0x8; break; //Bottom half if on top of non slab block - } + a_BlockMeta = Meta | 0x8; break; // Top half slab block } case BLOCK_FACE_EAST: case BLOCK_FACE_NORTH: @@ -78,29 +92,13 @@ public: { if (a_CursorY > 7) { - // Cursor at the top half of the face, place a top half of slab - if ((a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ) == E_BLOCK_STONE_SLAB) || (a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ) == E_BLOCK_WOODEN_SLAB)) - { - a_Player->GetClientHandle()->HandlePlaceBlock(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, *ItemHandler); - return false; - } - else - { - a_BlockMeta = Meta | 0x8; break; - } + // Cursor at top half of block, place top slab + a_BlockMeta = Meta | 0x8; break; } else { - // Cursor at the bottom half of the face, place a bottom half of slab: - if ((a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ) == E_BLOCK_STONE_SLAB) || (a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ) == E_BLOCK_WOODEN_SLAB)) - { - a_Player->GetClientHandle()->HandlePlaceBlock(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, *ItemHandler); - return false; - } - else - { - a_BlockMeta = Meta & 0x7; break; - } + // Cursor at bottom half of block, place bottom slab + a_BlockMeta = Meta & 0x7; break; } } } // switch (a_BlockFace) diff --git a/source/ClientHandle.cpp b/source/ClientHandle.cpp index 8ff93ec1b..199f43014 100644 --- a/source/ClientHandle.cpp +++ b/source/ClientHandle.cpp @@ -854,19 +854,29 @@ void cClientHandle::HandlePlaceBlock(int a_BlockX, int a_BlockY, int a_BlockZ, c World->GetBlockTypeMeta(a_BlockX, a_BlockY, a_BlockZ, ClickedBlock, ClickedBlockMeta); - //Special slab handler coding + // Special slab handler coding if ( + // If clicked face top: is slab there in the "bottom" position? + // If clicked face bottom: is the slab there in the "top" position? + // This prevents a dblslab forming below if you click the top face of a "top" slab. (((a_BlockFace == BLOCK_FACE_TOP) && (ClickedBlockMeta == (EquippedBlockDamage & 0x07))) || ((a_BlockFace == BLOCK_FACE_BOTTOM) && (ClickedBlockMeta == (EquippedBlockDamage | 0x08)))) && - ((ClickedBlock == E_BLOCK_STONE_SLAB) || (ClickedBlock == E_BLOCK_WOODEN_SLAB)) && //Is clicked a slab? - ((EquippedBlock == E_BLOCK_STONE_SLAB) || (EquippedBlock == E_BLOCK_WOODEN_SLAB)) && //Is equipped a slab? - ((ClickedBlockMeta & 0x07) == (EquippedBlockDamage & 0x07)) //Is clicked same type of slab as item in hand? + + // Is clicked a slab? This is a SLAB handler, not stone or something! + ((ClickedBlock == E_BLOCK_STONE_SLAB) || (ClickedBlock == E_BLOCK_WOODEN_SLAB)) && + + // Is equipped a some type of slab? + // This prevents a bug where, well, you get a dblslab by placing TNT or something not a slab. + ((EquippedBlock == E_BLOCK_STONE_SLAB) || (EquippedBlock == E_BLOCK_WOODEN_SLAB)) && + + // Is equipped slab type same as the slab in the world? After all, we can't combine different slabs! + ((ClickedBlockMeta & 0x07) == (EquippedBlockDamage & 0x07)) ) { - //Don't move the coordinates + // Coordinates at CLICKED block, don't move them anywhere } else { - //Check if the block ignores build collision (water, grass etc.): + // Check if the block ignores build collision (water, grass etc.): cBlockHandler * Handler = cBlockHandler::GetBlockHandler(ClickedBlock); if (Handler->DoesIgnoreBuildCollision()) { @@ -876,8 +886,9 @@ void cClientHandle::HandlePlaceBlock(int a_BlockX, int a_BlockY, int a_BlockZ, c else { AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace); - //On side of block, make sure that placement won't be cancelled if there is a slab there - //No need to combinability checks, client will do that + + // Clicked on side of block, make sure that placement won't be cancelled if there is a slab able to be double slabbed. + // No need to do combinability (dblslab) checks, client will do that here. if ((World->GetBlock(a_BlockX, a_BlockY, a_BlockZ) == E_BLOCK_STONE_SLAB) || (World->GetBlock(a_BlockX, a_BlockY, a_BlockZ) == E_BLOCK_WOODEN_SLAB)) { //Is a slab, don't do checks and proceed to double-slabbing @@ -904,7 +915,8 @@ void cClientHandle::HandlePlaceBlock(int a_BlockX, int a_BlockY, int a_BlockZ, c } } } - + // Special slab handler coding end + BLOCKTYPE BlockType; NIBBLETYPE BlockMeta; if (!a_ItemHandler.GetPlacementBlockTypeMeta(World, m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, BlockType, BlockMeta)) From 2081b6dfdeff7ee8253c97fc78c1a44191a09871 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sat, 24 Aug 2013 18:54:03 +0100 Subject: [PATCH 14/25] Fixed inconsistent metas and added snow metas --- source/Bindings.cpp | 56 ++++++++++++++++++++---------------- source/BlockID.h | 70 ++++++++++++++++++++++++++------------------- 2 files changed, 73 insertions(+), 53 deletions(-) diff --git a/source/Bindings.cpp b/source/Bindings.cpp index 9d6b6d959..7d51f7a4e 100644 --- a/source/Bindings.cpp +++ b/source/Bindings.cpp @@ -27443,14 +27443,14 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S) tolua_constant(tolua_S,"E_META_DROPSPENSER_FACING_ZP",E_META_DROPSPENSER_FACING_ZP); tolua_constant(tolua_S,"E_META_DROPSPENSER_FACING_XM",E_META_DROPSPENSER_FACING_XM); tolua_constant(tolua_S,"E_META_DROPSPENSER_FACING_XP",E_META_DROPSPENSER_FACING_XP); - tolua_constant(tolua_S,"E_META_DOUBLE_STEP_STONE",E_META_DOUBLE_STEP_STONE); - tolua_constant(tolua_S,"E_META_DOUBLE_STEP_SANDSTONE",E_META_DOUBLE_STEP_SANDSTONE); - tolua_constant(tolua_S,"E_META_DOUBLE_STEP_WOODEN",E_META_DOUBLE_STEP_WOODEN); - tolua_constant(tolua_S,"E_META_DOUBLE_STEP_COBBLESTONE",E_META_DOUBLE_STEP_COBBLESTONE); - tolua_constant(tolua_S,"E_META_DOUBLE_STEP_BRICK",E_META_DOUBLE_STEP_BRICK); - tolua_constant(tolua_S,"E_META_DOUBLE_STEP_STONE_BRICK",E_META_DOUBLE_STEP_STONE_BRICK); - tolua_constant(tolua_S,"E_META_DOUBLE_STEP_NETHER_BRICK",E_META_DOUBLE_STEP_NETHER_BRICK); - tolua_constant(tolua_S,"E_META_DOUBLE_STEP_STONE_SECRET",E_META_DOUBLE_STEP_STONE_SECRET); + tolua_constant(tolua_S,"E_META_DOUBLE_STONE_SLAB_STONE",E_META_DOUBLE_STONE_SLAB_STONE); + tolua_constant(tolua_S,"E_META_DOUBLE_STONE_SLAB_SANDSTONE",E_META_DOUBLE_STONE_SLAB_SANDSTONE); + tolua_constant(tolua_S,"E_META_DOUBLE_STONE_SLAB_WOODEN",E_META_DOUBLE_STONE_SLAB_WOODEN); + tolua_constant(tolua_S,"E_META_DOUBLE_STONE_SLAB_COBBLESTONE",E_META_DOUBLE_STONE_SLAB_COBBLESTONE); + tolua_constant(tolua_S,"E_META_DOUBLE_STONE_SLAB_BRICK",E_META_DOUBLE_STONE_SLAB_BRICK); + tolua_constant(tolua_S,"E_META_DOUBLE_STONE_SLAB_STONE_BRICK",E_META_DOUBLE_STONE_SLAB_STONE_BRICK); + tolua_constant(tolua_S,"E_META_DOUBLE_STONE_SLAB_NETHER_BRICK",E_META_DOUBLE_STONE_SLAB_NETHER_BRICK); + tolua_constant(tolua_S,"E_META_DOUBLE_STONE_SLAB_STONE_SECRET",E_META_DOUBLE_STONE_SLAB_STONE_SECRET); tolua_constant(tolua_S,"E_META_HOPPER_FACING_YM",E_META_HOPPER_FACING_YM); tolua_constant(tolua_S,"E_META_HOPPER_UNATTACHED",E_META_HOPPER_UNATTACHED); tolua_constant(tolua_S,"E_META_HOPPER_FACING_ZM",E_META_HOPPER_FACING_ZM); @@ -27479,14 +27479,14 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S) tolua_constant(tolua_S,"E_META_SILVERFISH_EGG_STONE",E_META_SILVERFISH_EGG_STONE); tolua_constant(tolua_S,"E_META_SILVERFISH_EGG_COBBLESTONE",E_META_SILVERFISH_EGG_COBBLESTONE); tolua_constant(tolua_S,"E_META_SILVERFISH_EGG_STONE_BRICK",E_META_SILVERFISH_EGG_STONE_BRICK); - tolua_constant(tolua_S,"E_META_STEP_STONE",E_META_STEP_STONE); - tolua_constant(tolua_S,"E_META_STEP_SANDSTONE",E_META_STEP_SANDSTONE); - tolua_constant(tolua_S,"E_META_STEP_PLANKS",E_META_STEP_PLANKS); - tolua_constant(tolua_S,"E_META_STEP_COBBLESTONE",E_META_STEP_COBBLESTONE); - tolua_constant(tolua_S,"E_META_STEP_BRICK",E_META_STEP_BRICK); - tolua_constant(tolua_S,"E_META_STEP_STONE_BRICK",E_META_STEP_STONE_BRICK); - tolua_constant(tolua_S,"E_META_STEP_NETHER_BRICK",E_META_STEP_NETHER_BRICK); - tolua_constant(tolua_S,"E_META_STEP_STONE_SECRET",E_META_STEP_STONE_SECRET); + tolua_constant(tolua_S,"E_META_STONE_SLAB_STONE",E_META_STONE_SLAB_STONE); + tolua_constant(tolua_S,"E_META_STONE_SLAB_SANDSTONE",E_META_STONE_SLAB_SANDSTONE); + tolua_constant(tolua_S,"E_META_STONE_SLAB_PLANKS",E_META_STONE_SLAB_PLANKS); + tolua_constant(tolua_S,"E_META_STONE_SLAB_COBBLESTONE",E_META_STONE_SLAB_COBBLESTONE); + tolua_constant(tolua_S,"E_META_STONE_SLAB_BRICK",E_META_STONE_SLAB_BRICK); + tolua_constant(tolua_S,"E_META_STONE_SLAB_STONE_BRICK",E_META_STONE_SLAB_STONE_BRICK); + tolua_constant(tolua_S,"E_META_STONE_SLAB_NETHER_BRICK",E_META_STONE_SLAB_NETHER_BRICK); + tolua_constant(tolua_S,"E_META_STONE_SLAB_STONE_SECRET",E_META_STONE_SLAB_STONE_SECRET); tolua_constant(tolua_S,"E_META_STONE_BRICK_NORMAL",E_META_STONE_BRICK_NORMAL); tolua_constant(tolua_S,"E_META_STONE_BRICK_MOSSY",E_META_STONE_BRICK_MOSSY); tolua_constant(tolua_S,"E_META_STONE_BRICK_CRACKED",E_META_STONE_BRICK_CRACKED); @@ -27503,14 +27503,14 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S) tolua_constant(tolua_S,"E_META_TORCH_XP",E_META_TORCH_XP); tolua_constant(tolua_S,"E_META_TORCH_ZM",E_META_TORCH_ZM); tolua_constant(tolua_S,"E_META_TORCH_ZP",E_META_TORCH_ZP); - tolua_constant(tolua_S,"E_META_WOODEN_DOUBLE_STEP_APPLE",E_META_WOODEN_DOUBLE_STEP_APPLE); - tolua_constant(tolua_S,"E_META_WOODEN_DOUBLE_STEP_CONIFER",E_META_WOODEN_DOUBLE_STEP_CONIFER); - tolua_constant(tolua_S,"E_META_WOODEN_DOUBLE_STEP_BIRCH",E_META_WOODEN_DOUBLE_STEP_BIRCH); - tolua_constant(tolua_S,"E_META_WOODEN_DOUBLE_STEP_JUNGLE",E_META_WOODEN_DOUBLE_STEP_JUNGLE); - tolua_constant(tolua_S,"E_META_WOODEN_STEP_APPLE",E_META_WOODEN_STEP_APPLE); - tolua_constant(tolua_S,"E_META_WOODEN_STEP_CONIFER",E_META_WOODEN_STEP_CONIFER); - tolua_constant(tolua_S,"E_META_WOODEN_STEP_BIRCH",E_META_WOODEN_STEP_BIRCH); - tolua_constant(tolua_S,"E_META_WOODEN_STEP_JUNGLE",E_META_WOODEN_STEP_JUNGLE); + tolua_constant(tolua_S,"E_META_WOODEN_DOUBLE_SLAB_APPLE",E_META_WOODEN_DOUBLE_SLAB_APPLE); + tolua_constant(tolua_S,"E_META_WOODEN_DOUBLE_SLAB_CONIFER",E_META_WOODEN_DOUBLE_SLAB_CONIFER); + tolua_constant(tolua_S,"E_META_WOODEN_DOUBLE_SLAB_BIRCH",E_META_WOODEN_DOUBLE_SLAB_BIRCH); + tolua_constant(tolua_S,"E_META_WOODEN_DOUBLE_SLAB_JUNGLE",E_META_WOODEN_DOUBLE_SLAB_JUNGLE); + tolua_constant(tolua_S,"E_META_WOODEN_SLAB_APPLE",E_META_WOODEN_SLAB_APPLE); + tolua_constant(tolua_S,"E_META_WOODEN_SLAB_CONIFER",E_META_WOODEN_SLAB_CONIFER); + tolua_constant(tolua_S,"E_META_WOODEN_SLAB_BIRCH",E_META_WOODEN_SLAB_BIRCH); + tolua_constant(tolua_S,"E_META_WOODEN_SLAB_JUNGLE",E_META_WOODEN_SLAB_JUNGLE); tolua_constant(tolua_S,"E_META_WOOL_WHITE",E_META_WOOL_WHITE); tolua_constant(tolua_S,"E_META_WOOL_ORANGE",E_META_WOOL_ORANGE); tolua_constant(tolua_S,"E_META_WOOL_MAGENTA",E_META_WOOL_MAGENTA); @@ -27559,6 +27559,14 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S) tolua_constant(tolua_S,"E_META_STAINED_CLAY_GREEN",E_META_STAINED_CLAY_GREEN); tolua_constant(tolua_S,"E_META_STAINED_CLAY_RED",E_META_STAINED_CLAY_RED); tolua_constant(tolua_S,"E_META_STAINED_CLAY_BLACK",E_META_STAINED_CLAY_BLACK); + tolua_constant(tolua_S,"E_META_SNOW_LAYER_ONE",E_META_SNOW_LAYER_ONE); + tolua_constant(tolua_S,"E_META_SNOW_LAYER_TWO",E_META_SNOW_LAYER_TWO); + tolua_constant(tolua_S,"E_META_SNOW_LAYER_THREE",E_META_SNOW_LAYER_THREE); + tolua_constant(tolua_S,"E_META_SNOW_LAYER_FOUR",E_META_SNOW_LAYER_FOUR); + tolua_constant(tolua_S,"E_META_SNOW_LAYER_FIVE",E_META_SNOW_LAYER_FIVE); + tolua_constant(tolua_S,"E_META_SNOW_LAYER_SIX",E_META_SNOW_LAYER_SIX); + tolua_constant(tolua_S,"E_META_SNOW_LAYER_SEVEN",E_META_SNOW_LAYER_SEVEN); + tolua_constant(tolua_S,"E_META_SNOW_LAYER_EIGHT",E_META_SNOW_LAYER_EIGHT); tolua_constant(tolua_S,"E_META_COAL_NORMAL",E_META_COAL_NORMAL); tolua_constant(tolua_S,"E_META_COAL_CHARCOAL",E_META_COAL_CHARCOAL); tolua_constant(tolua_S,"E_META_DYE_BLACK",E_META_DYE_BLACK); diff --git a/source/BlockID.h b/source/BlockID.h index 3c4381ae1..0eb3df96d 100644 --- a/source/BlockID.h +++ b/source/BlockID.h @@ -396,15 +396,17 @@ enum E_META_DROPSPENSER_FACING_XM = 4, E_META_DROPSPENSER_FACING_XP = 5, - // E_BLOCK_DOUBLE_STEP metas: - E_META_DOUBLE_STEP_STONE = 0, - E_META_DOUBLE_STEP_SANDSTONE = 1, - E_META_DOUBLE_STEP_WOODEN = 2, - E_META_DOUBLE_STEP_COBBLESTONE = 3, - E_META_DOUBLE_STEP_BRICK = 4, - E_META_DOUBLE_STEP_STONE_BRICK = 5, - E_META_DOUBLE_STEP_NETHER_BRICK = 6, - E_META_DOUBLE_STEP_STONE_SECRET = 7, + // E_BLOCK_DOUBLE_STONE_SLAB metas: + E_META_DOUBLE_STONE_SLAB_STONE = 0, + E_META_DOUBLE_STONE_SLAB_SANDSTONE = 1, + E_META_DOUBLE_STONE_SLAB_WOODEN = 2, + E_META_DOUBLE_STONE_SLAB_COBBLESTONE = 3, + E_META_DOUBLE_STONE_SLAB_BRICK = 4, + E_META_DOUBLE_STONE_SLAB_STONE_BRICK = 5, + E_META_DOUBLE_STONE_SLAB_NETHER_BRICK = 6, + E_META_DOUBLE_STONE_SLAB_STONE_SECRET = 7, + + // E_BLOCK_HOPPER metas: E_META_HOPPER_FACING_YM = 0, @@ -448,15 +450,15 @@ enum E_META_SILVERFISH_EGG_COBBLESTONE = 1, E_META_SILVERFISH_EGG_STONE_BRICK = 2, - // E_BLOCK_STEP metas: - E_META_STEP_STONE = 0, - E_META_STEP_SANDSTONE = 1, - E_META_STEP_PLANKS = 2, - E_META_STEP_COBBLESTONE = 3, - E_META_STEP_BRICK = 4, - E_META_STEP_STONE_BRICK = 5, - E_META_STEP_NETHER_BRICK = 6, - E_META_STEP_STONE_SECRET = 7, + // E_BLOCK_STONE_SLAB metas: + E_META_STONE_SLAB_STONE = 0, + E_META_STONE_SLAB_SANDSTONE = 1, + E_META_STONE_SLAB_PLANKS = 2, + E_META_STONE_SLAB_COBBLESTONE = 3, + E_META_STONE_SLAB_BRICK = 4, + E_META_STONE_SLAB_STONE_BRICK = 5, + E_META_STONE_SLAB_NETHER_BRICK = 6, + E_META_STONE_SLAB_STONE_SECRET = 7, // E_BLOCK_STONE_BRICKS metas: E_META_STONE_BRICK_NORMAL = 0, @@ -480,17 +482,17 @@ enum E_META_TORCH_ZM = 3, // Torch attached to the ZM side of its block E_META_TORCH_ZP = 4, // Torch attached to the ZP side of its block - // E_BLOCK_WOODEN_DOUBLE_STEP metas: - E_META_WOODEN_DOUBLE_STEP_APPLE = 0, - E_META_WOODEN_DOUBLE_STEP_CONIFER = 1, - E_META_WOODEN_DOUBLE_STEP_BIRCH = 2, - E_META_WOODEN_DOUBLE_STEP_JUNGLE = 3, + // E_BLOCK_WOODEN_DOUBLE_SLAB metas: + E_META_WOODEN_DOUBLE_SLAB_APPLE = 0, + E_META_WOODEN_DOUBLE_SLAB_CONIFER = 1, + E_META_WOODEN_DOUBLE_SLAB_BIRCH = 2, + E_META_WOODEN_DOUBLE_SLAB_JUNGLE = 3, - // E_BLOCK_WOODEN_STEP metas: - E_META_WOODEN_STEP_APPLE = 0, - E_META_WOODEN_STEP_CONIFER = 1, - E_META_WOODEN_STEP_BIRCH = 2, - E_META_WOODEN_STEP_JUNGLE = 3, + // E_BLOCK_WOODEN_SLAB metas: + E_META_WOODEN_SLAB_APPLE = 0, + E_META_WOODEN_SLAB_CONIFER = 1, + E_META_WOODEN_SLAB_BIRCH = 2, + E_META_WOODEN_SLAB_JUNGLE = 3, // E_BLOCK_WOOL metas: E_META_WOOL_WHITE = 0, @@ -545,7 +547,17 @@ enum E_META_STAINED_CLAY_GREEN = 13, E_META_STAINED_CLAY_RED = 14, E_META_STAINED_CLAY_BLACK = 15, - + + // E_BLOCK_SNOW metas: + E_META_SNOW_LAYER_ONE = 0, + E_META_SNOW_LAYER_TWO = 1, + E_META_SNOW_LAYER_THREE = 2, + E_META_SNOW_LAYER_FOUR = 3, + E_META_SNOW_LAYER_FIVE = 4, + E_META_SNOW_LAYER_SIX = 5, + E_META_SNOW_LAYER_SEVEN = 6, + E_META_SNOW_LAYER_EIGHT = 7, + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Item metas: From 259f08aac88c5e5ac49e5ec06f13c8b4759766c3 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 24 Aug 2013 21:25:36 +0200 Subject: [PATCH 15/25] Client can no longer place blocks outside the Y range of the world. Fixes #128. --- source/ClientHandle.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/source/ClientHandle.cpp b/source/ClientHandle.cpp index ed76ee086..8125fc127 100644 --- a/source/ClientHandle.cpp +++ b/source/ClientHandle.cpp @@ -871,7 +871,12 @@ void cClientHandle::HandlePlaceBlock(int a_BlockX, int a_BlockY, int a_BlockZ, c return; } - + if ((a_BlockY < 0) || (a_BlockY >= cChunkDef::Height)) + { + // The block is being placed outside the world, ignore this packet altogether (#128) + return; + } + BLOCKTYPE PlaceBlock = World->GetBlock(a_BlockX, a_BlockY, a_BlockZ); if (!BlockHandler(PlaceBlock)->DoesIgnoreBuildCollision()) { From b1ad3f83369924fed0232ce66eabbb24f3c6cd9e Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 24 Aug 2013 21:34:42 +0200 Subject: [PATCH 16/25] Fixed pickup behavior outside the world. One part of #131. --- source/Entities/Pickup.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/source/Entities/Pickup.cpp b/source/Entities/Pickup.cpp index 0417b861d..c8f36d503 100644 --- a/source/Entities/Pickup.cpp +++ b/source/Entities/Pickup.cpp @@ -73,18 +73,19 @@ void cPickup::Tick(float a_Dt, cChunk & a_Chunk) if (!m_bCollected) { int BlockY = (int) floor(GetPosY()); - if (BlockY < cChunkDef::Height) // Don't do anything except for falling when above the world + if ((BlockY >= 0) && (BlockY < cChunkDef::Height)) // Don't do anything except for falling when outside the world { int BlockX = (int) floor(GetPosX()); int BlockZ = (int) floor(GetPosZ()); - //Position might have changed due to physics. So we have to make sure we have the correct chunk. + // Position might have changed due to physics. So we have to make sure we have the correct chunk. cChunk * CurrentChunk = a_Chunk.GetNeighborChunk(BlockX, BlockZ); if (CurrentChunk != NULL) // Make sure the chunk is loaded { int RelBlockX = BlockX - (CurrentChunk->GetPosX() * cChunkDef::Width); int RelBlockZ = BlockZ - (CurrentChunk->GetPosZ() * cChunkDef::Width); - BLOCKTYPE BlockBelow = CurrentChunk->GetBlock(RelBlockX, BlockY - 1, RelBlockZ); + // If the pickup is on the bottommost block position, make it think the void is made of air: (#131) + BLOCKTYPE BlockBelow = (BlockY > 0) ? CurrentChunk->GetBlock(RelBlockX, BlockY - 1, RelBlockZ) : E_BLOCK_AIR; BLOCKTYPE BlockIn = CurrentChunk->GetBlock(RelBlockX, BlockY, RelBlockZ); if ( From 46a8b77151e7cce23d5294c1c48e93a05821db34 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 24 Aug 2013 21:42:11 +0200 Subject: [PATCH 17/25] cTracer doesn't attempt a trace above the world. This fixes some crashes with out-of-world entities. --- source/Tracer.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/Tracer.cpp b/source/Tracer.cpp index 6d37f2ed8..0f756756a 100644 --- a/source/Tracer.cpp +++ b/source/Tracer.cpp @@ -133,9 +133,9 @@ void cTracer::SetValues(const Vector3f & a_Start, const Vector3f & a_Direction) int cTracer::Trace( const Vector3f & a_Start, const Vector3f & a_Direction, int a_Distance) { - if (a_Start.y < 0) + if ((a_Start.y < 0) || (a_Start.y >= cChunkDef::Height)) { - LOGD("%s: Start is below the world", __FUNCTION__); + LOGD("%s: Start Y is outside the world (%d), not tracing.", __FUNCTION__, a_Start.y); return 0; } From de3aae5c75ded73c938d3fe690abdcbace4de36d Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 24 Aug 2013 22:43:17 +0200 Subject: [PATCH 18/25] Slight performance improvement in cWorld::FindClosestPlayer() --- source/World.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/source/World.cpp b/source/World.cpp index 053eaedc7..1985f01ec 100644 --- a/source/World.cpp +++ b/source/World.cpp @@ -2202,15 +2202,12 @@ cPlayer * cWorld::FindClosestPlayer(const Vector3f & a_Pos, float a_SightLimit) Vector3f Pos = (*itr)->GetPosition(); float Distance = (Pos - a_Pos).Length(); - if (Distance <= a_SightLimit) + if (Distance < ClosestDistance) { if (!LineOfSight.Trace(a_Pos,(Pos - a_Pos),(int)(Pos - a_Pos).Length())) { - if (Distance < ClosestDistance) - { - ClosestDistance = Distance; - ClosestPlayer = *itr; - } + ClosestDistance = Distance; + ClosestPlayer = *itr; } } } From d55aaf818cffa292839ceec7ee2a6d3223c9f4d5 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 24 Aug 2013 22:45:11 +0200 Subject: [PATCH 19/25] Lifted the debugging 1 GiB RAM limit in LeakFinder to 1.5 GiB --- source/LeakFinder.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/LeakFinder.cpp b/source/LeakFinder.cpp index 3242bba04..9af259e88 100644 --- a/source/LeakFinder.cpp +++ b/source/LeakFinder.cpp @@ -942,10 +942,10 @@ static int MyAllocHook(int nAllocType, void *pvData, g_CurrentMemUsage += nSize ; g_pCRTTable->Insert(lRequest, c, nSize); - if (g_CurrentMemUsage > 1073741824) //This is 1 gb = 1024 * 1024* 1024. + if (g_CurrentMemUsage > 1536 * 1024* 1024) { printf("******************************************\n"); - printf("** Server reached 1 GiB memory usage, **\n"); + printf("** Server reached 1.5 GiB memory usage, **\n"); printf("** something is probably wrong. **\n"); printf("** Writing memory dump into memdump.xml **\n"); printf("******************************************\n"); From f3ab7d1873081d07cf5a451430b077d148697b09 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 24 Aug 2013 22:48:19 +0200 Subject: [PATCH 20/25] Fixed logging in cTracer. --- source/Tracer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/Tracer.cpp b/source/Tracer.cpp index 0f756756a..42f1ae5dd 100644 --- a/source/Tracer.cpp +++ b/source/Tracer.cpp @@ -135,7 +135,7 @@ int cTracer::Trace( const Vector3f & a_Start, const Vector3f & a_Direction, int { if ((a_Start.y < 0) || (a_Start.y >= cChunkDef::Height)) { - LOGD("%s: Start Y is outside the world (%d), not tracing.", __FUNCTION__, a_Start.y); + LOGD("%s: Start Y is outside the world (%.2f), not tracing.", __FUNCTION__, a_Start.y); return 0; } From 11ca2f96a08f8eaba95a7c8ecc2ddd5f761565f9 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sat, 24 Aug 2013 22:00:24 +0100 Subject: [PATCH 21/25] Vines now spread when updated --- source/Blocks/BlockVine.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/source/Blocks/BlockVine.h b/source/Blocks/BlockVine.h index 0bc935272..37d9f1a45 100644 --- a/source/Blocks/BlockVine.h +++ b/source/Blocks/BlockVine.h @@ -168,6 +168,13 @@ public: return false; } + virtual void OnUpdate(cWorld * a_World, int X, int Y, int Z) + { + if (a_World->GetBlock(X, Y - 1, Z) == E_BLOCK_AIR) + { + a_World->SetBlock(X, Y - 1, Z, E_BLOCK_VINES, a_World->GetBlockMeta(X, Y, Z)); + } + } virtual NIBBLETYPE MetaRotateCCW(NIBBLETYPE a_Meta) override { From 3640f2c482b05281bc6c8905961050bc694a1248 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sun, 25 Aug 2013 11:45:47 +0100 Subject: [PATCH 22/25] Redstone fixes [SEE DESC] Fixed pistons not correctly powering down Fixed dispensers not correctly powering down Fixed droppers not correctly power down Fixed TNT not correctly powering up Fixed redstone lamps not correctly powering up Fixed redstone lamps not correctly powering down --- source/Simulator/RedstoneSimulator.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/source/Simulator/RedstoneSimulator.cpp b/source/Simulator/RedstoneSimulator.cpp index 615e36a49..8526a888e 100644 --- a/source/Simulator/RedstoneSimulator.cpp +++ b/source/Simulator/RedstoneSimulator.cpp @@ -53,6 +53,10 @@ void cRedstoneSimulator::WakeUp(int a_BlockX, int a_BlockY, int a_BlockZ, cChunk } switch (BlockType) { + case E_BLOCK_PISTON: + case E_BLOCK_STICKY_PISTON: + case E_BLOCK_DISPENSER: + case E_BLOCK_DROPPER: case E_BLOCK_REDSTONE_LAMP_OFF: case E_BLOCK_REDSTONE_LAMP_ON: case E_BLOCK_REDSTONE_REPEATER_OFF: @@ -514,6 +518,20 @@ bool cRedstoneSimulator::PowerBlock(const Vector3i & a_BlockPos, const Vector3i break; } + case E_BLOCK_REDSTONE_LAMP_OFF: + { + m_World.FastSetBlock(a_BlockPos.x, a_BlockPos.y, a_BlockPos.z, E_BLOCK_REDSTONE_LAMP_ON, 0); + break; + } + + case E_BLOCK_TNT: + { + m_World.BroadcastSoundEffect("random.fuse", a_BlockPos.x * 8, a_BlockPos.y * 8, a_BlockPos.z * 8, 0.5f, 0.6f); + m_World.SpawnPrimedTNT(a_BlockPos.x + 0.5, a_BlockPos.y + 0.5, a_BlockPos.z + 0.5, 4); // 4 seconds to boom + m_World.SetBlock(a_BlockPos.x, a_BlockPos.y, a_BlockPos.z, E_BLOCK_AIR, 0); + break; + } + default: { if ( @@ -614,6 +632,12 @@ int cRedstoneSimulator::UnPowerBlock(const Vector3i & a_BlockPos, const Vector3i } break; } + + case E_BLOCK_REDSTONE_LAMP_ON: + { + m_World.FastSetBlock(a_BlockPos.x, a_BlockPos.y, a_BlockPos.z, E_BLOCK_REDSTONE_LAMP_OFF, 0); + break; + } default: { From ebc3d040745d1c1677237cca370535ad65a71091 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sun, 25 Aug 2013 13:40:43 +0100 Subject: [PATCH 23/25] Fixed public thing in ClientHandle --- source/ClientHandle.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source/ClientHandle.h b/source/ClientHandle.h index a2e29f9dc..f1a2dbc3d 100644 --- a/source/ClientHandle.h +++ b/source/ClientHandle.h @@ -198,6 +198,9 @@ public: /// Called when the player moves into a different world; queues sreaming the new chunks void MoveToWorld(cWorld & a_World, bool a_SendRespawnPacket); + /// Handles the block placing packet when it is a real block placement (not block-using, item-using or eating) + void HandlePlaceBlock(int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, cItemHandler & a_ItemHandler); + private: int m_ViewDistance; // 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 ) @@ -310,9 +313,6 @@ private: /// Handles the DIG_FINISHED dig packet: void HandleBlockDigFinished(int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, BLOCKTYPE a_OldBlock, NIBBLETYPE a_OldMeta); - - /// Handles the block placing packet when it is a real block placement (not block-using, item-using or eating) - public: void HandlePlaceBlock(int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, cItemHandler & a_ItemHandler); // cSocketThreads::cCallback overrides: virtual void DataReceived (const char * a_Data, int a_Size) override; // Data is received from the client From 55e3fc53f65fe3073a9453a9aa2cb86132a28bc3 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sun, 25 Aug 2013 13:41:02 +0100 Subject: [PATCH 24/25] Fixed iron door opening by hand --- source/Blocks/BlockDoor.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/source/Blocks/BlockDoor.cpp b/source/Blocks/BlockDoor.cpp index 267486c47..02cbd28e2 100644 --- a/source/Blocks/BlockDoor.cpp +++ b/source/Blocks/BlockDoor.cpp @@ -47,7 +47,10 @@ void cBlockDoorHandler::OnDestroyed(cWorld * a_World, int a_BlockX, int a_BlockY void cBlockDoorHandler::OnUse(cWorld * a_World, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) { - cDoors::ChangeDoor(a_World, a_BlockX, a_BlockY, a_BlockZ); + if (a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ) == E_BLOCK_WOODEN_DOOR) + { + cDoors::ChangeDoor(a_World, a_BlockX, a_BlockY, a_BlockZ); + } } From 6ea7c2b772ce889b2b9d3c3ee2f9c05aaef7c477 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sun, 25 Aug 2013 16:47:49 +0200 Subject: [PATCH 25/25] Reduced LeakFinder's stack buffers to half. The LeakFinder's stack buffers were causing too much RAM usage in the Debug mode, rising about 50 MiB per each cLuaState created. --- source/LeakFinder.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/source/LeakFinder.cpp b/source/LeakFinder.cpp index 9af259e88..272e313a0 100644 --- a/source/LeakFinder.cpp +++ b/source/LeakFinder.cpp @@ -116,12 +116,15 @@ /* _X: MSVC 2012 (MSC 1700) seems to use a different allocation scheme for STL containers, * allocating lots of small objects and running out of memory very soon * Thus for MSVC 2012 we cut the callstack buffer length in half +* +* _X 2013_08_25: The callstack tracking gets worse even for MSVC 2008, a single lua_state eats 50 MiB of RAM +* Therefore I decided to further reduce the buffers from 0x2000 to 0x1000 */ // Controlling the callstack depth #if (_MSC_VER < 1700) - #define MAX_CALLSTACK_LEN_BUF 0x2000 -#else #define MAX_CALLSTACK_LEN_BUF 0x1000 +#else + #define MAX_CALLSTACK_LEN_BUF 0x0800 #endif