From e07c54f7f80fc6fe6f2abd8f81b45c8d6dc4e2d7 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sun, 1 Dec 2013 16:34:04 +0100 Subject: APIDump: Added missing params to OnPlayerRightClick() hook. --- MCServer/Plugins/APIDump/Hooks/OnPlayerRightClick.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/MCServer/Plugins/APIDump/Hooks/OnPlayerRightClick.lua b/MCServer/Plugins/APIDump/Hooks/OnPlayerRightClick.lua index d767b449d..de9b3662c 100644 --- a/MCServer/Plugins/APIDump/Hooks/OnPlayerRightClick.lua +++ b/MCServer/Plugins/APIDump/Hooks/OnPlayerRightClick.lua @@ -21,6 +21,9 @@ return { Name = "BlockY", Type = "number", Notes = "Y-coord of the block" }, { Name = "BlockZ", Type = "number", Notes = "Z-coord of the block" }, { Name = "BlockFace", Type = "number", Notes = "Face of the block upon which the player interacted. One of the BLOCK_FACE_ constants" }, + { Name = "CursorX", Type = "number", Notes = "X-coord of the mouse crosshair on the block" }, + { Name = "CursorY", Type = "number", Notes = "Y-coord of the mouse crosshair on the block" }, + { Name = "CursorZ", Type = "number", Notes = "Z-coord of the mouse crosshair on the block" }, }, Returns = [[ If the function returns false or no value, MCServer calls other plugins' callbacks and finally sends -- cgit v1.2.3 From 70cf0c09a875f578cc9be9ebf7a900c3e857a2a5 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 2 Dec 2013 22:36:43 +0100 Subject: The server builds and uses Lua as DLL in Debug mode. This is a test to see how LuaRocks will interact. Only debug mode on Windows is affected, all other platforms and modes are unchanged. --- MCServer/.gitignore | 4 ++++ VC2008/Lua.vcproj | 18 +++++++++++------- VC2008/MCServer.vcproj | 2 +- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/MCServer/.gitignore b/MCServer/.gitignore index c03bcbe99..1fed134fe 100644 --- a/MCServer/.gitignore +++ b/MCServer/.gitignore @@ -1,4 +1,7 @@ *.exe +*.dll +*.exp +*.lib *.ini MCServer logs @@ -20,3 +23,4 @@ valgrind.log motd.txt *.deuser *.dmp +*.xml diff --git a/VC2008/Lua.vcproj b/VC2008/Lua.vcproj index 326ba6411..4dee8c06e 100644 --- a/VC2008/Lua.vcproj +++ b/VC2008/Lua.vcproj @@ -20,7 +20,7 @@ Name="Debug|Win32" OutputDirectory="$(SolutionDir)$(ConfigurationName)\Lua" IntermediateDirectory="$(ConfigurationName)\Lua" - ConfigurationType="4" + ConfigurationType="2" CharacterSet="1" > + @@ -73,6 +78,9 @@ + @@ -375,10 +383,6 @@ RelativePath="..\lib\lua\src\ltm.c" > - - diff --git a/VC2008/MCServer.vcproj b/VC2008/MCServer.vcproj index 95e10ba40..e5de93f98 100644 --- a/VC2008/MCServer.vcproj +++ b/VC2008/MCServer.vcproj @@ -43,7 +43,7 @@ AdditionalOptions="/MP" Optimization="0" AdditionalIncludeDirectories=""../lib/jsoncpp/include";../lib" - PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;XML_STATIC" + PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;XML_STATIC;LUA_BUILD_AS_DLL" MinimalRebuild="false" BasicRuntimeChecks="3" RuntimeLibrary="1" -- cgit v1.2.3 From 0e48fd35bdabe79d3dc625eedda9eb5d12cc53de Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 3 Dec 2013 21:37:34 +0100 Subject: Made Lua compila as a standalone DLL on Windows. This enables us to use LuaRocks. --- Install/Zip2008.list | 1 + VC2008/Lua.vcproj | 39 ++++++++++++++++++++++++++++++--------- 2 files changed, 31 insertions(+), 9 deletions(-) diff --git a/Install/Zip2008.list b/Install/Zip2008.list index fbfc06e0c..b118ccbf9 100644 --- a/Install/Zip2008.list +++ b/Install/Zip2008.list @@ -1,4 +1,5 @@ ..\MCServer\MCServer.exe +..\MCServer\*.dll ..\MCServer\Plugins ..\MCServer\webadmin ..\MCServer\crafting.txt diff --git a/VC2008/Lua.vcproj b/VC2008/Lua.vcproj index 4dee8c06e..1119d542b 100644 --- a/VC2008/Lua.vcproj +++ b/VC2008/Lua.vcproj @@ -89,7 +89,7 @@ Name="Release|Win32" OutputDirectory="$(SolutionDir)$(ConfigurationName)\Lua" IntermediateDirectory="$(ConfigurationName)\Lua" - ConfigurationType="4" + ConfigurationType="2" CharacterSet="1" WholeProgramOptimization="1" > @@ -112,7 +112,7 @@ Name="VCCLCompilerTool" Optimization="2" EnableIntrinsicFunctions="true" - PreprocessorDefinitions="WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_WARNINGS" + PreprocessorDefinitions="WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;LUA_BUILD_AS_DLL" RuntimeLibrary="0" EnableFunctionLevelLinking="true" UsePrecompiledHeader="0" @@ -129,11 +129,15 @@ Name="VCPreLinkEventTool" /> + @@ -143,6 +147,9 @@ + @@ -151,7 +158,7 @@ Name="Release profiled|Win32" OutputDirectory="$(SolutionDir)$(ConfigurationName)\Lua" IntermediateDirectory="$(ConfigurationName)\Lua" - ConfigurationType="4" + ConfigurationType="2" CharacterSet="1" WholeProgramOptimization="1" > @@ -174,7 +181,7 @@ Name="VCCLCompilerTool" Optimization="2" EnableIntrinsicFunctions="true" - PreprocessorDefinitions="WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_WARNINGS" + PreprocessorDefinitions="WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;LUA_BUILD_AS_DLL" RuntimeLibrary="0" EnableFunctionLevelLinking="true" UsePrecompiledHeader="0" @@ -191,11 +198,15 @@ Name="VCPreLinkEventTool" /> + @@ -205,6 +216,9 @@ + @@ -213,7 +227,7 @@ Name="Debug profiled|Win32" OutputDirectory="$(SolutionDir)$(ConfigurationName)\Lua" IntermediateDirectory="$(ConfigurationName)\Lua" - ConfigurationType="4" + ConfigurationType="2" CharacterSet="1" > + @@ -266,6 +284,9 @@ + -- cgit v1.2.3 From 8cb3fb58937c233a8ccc75fb206b287c9816d701 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 3 Dec 2013 21:40:58 +0100 Subject: Allowed Linux builds to use LuaRocks. This works by exporting all the symbols for the dynamic loader so that LuaRocks' shared libraries may bind to them on load. Also allowed lua's dlopen(). --- GNUmakefile | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/GNUmakefile b/GNUmakefile index e0e606d90..c8cdd35e1 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -47,8 +47,8 @@ ifeq ($(release),1) # release build - fastest run-time, no gdb support ################ -CC_OPTIONS = -O3 -DNDEBUG -CXX_OPTIONS = -O3 -DNDEBUG +CC_OPTIONS = -O3 -DNDEBUG -DLUA_USE_DLOPEN +CXX_OPTIONS = -O3 -DNDEBUG -DLUA_USE_DLOPEN LNK_OPTIONS = -pthread -O3 BUILDDIR = build/release/ @@ -59,8 +59,8 @@ ifeq ($(profile),1) # profile build - a release build with symbols and profiling engine built in ################ -CC_OPTIONS = -g -ggdb -O3 -pg -DNDEBUG -CXX_OPTIONS = -g -ggdb -O3 -pg -DNDEBUG +CC_OPTIONS = -g -ggdb -O3 -pg -DNDEBUG -DLUA_USE_DLOPEN +CXX_OPTIONS = -g -ggdb -O3 -pg -DNDEBUG -DLUA_USE_DLOPEN LNK_OPTIONS = -pthread -ggdb -O3 -pg BUILDDIR = build/profile/ @@ -71,8 +71,8 @@ else # Since C code is used only for supporting libraries (zlib, lua), it is still Ofast-optimized ################ -CC_OPTIONS = -ggdb -g -D_DEBUG -O3 -CXX_OPTIONS = -ggdb -g -D_DEBUG -O1 +CC_OPTIONS = -ggdb -g -D_DEBUG -O3 -DLUA_USE_DLOPEN +CXX_OPTIONS = -ggdb -g -D_DEBUG -O1 -DLUA_USE_DLOPEN LNK_OPTIONS = -pthread -g -ggdb -O1 BUILDDIR = build/debug/ @@ -111,6 +111,14 @@ endif +################################################### +# Export all symbols from the executable, so that LuaRocks may bind to Lua routines: +LNK_OPTIONS += -rdynamic + + + + + ################################################### # 32-bit build override in 64-bit build environments -- cgit v1.2.3 From 0a2fcf909c5affcb13ef42377c6e0c880dd887c7 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 3 Dec 2013 21:48:40 +0100 Subject: Added a quick LuaRocks testing plugin. You need to install the luarocks system and through it the luasocket and 30log rocks. --- MCServer/Plugins/TestLuaRocks/TestLuaRocks.lua | 49 ++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 MCServer/Plugins/TestLuaRocks/TestLuaRocks.lua diff --git a/MCServer/Plugins/TestLuaRocks/TestLuaRocks.lua b/MCServer/Plugins/TestLuaRocks/TestLuaRocks.lua new file mode 100644 index 000000000..6e90b1ae9 --- /dev/null +++ b/MCServer/Plugins/TestLuaRocks/TestLuaRocks.lua @@ -0,0 +1,49 @@ + +-- TestLuaRocks.lua + +-- This is a mockup plugin that does a quick test of LuaRocks capability in MCServer + +-- "Success" is when the plugin loads, downloads the forum webpage and displays the headers and length and then displays both libs as loaded. +-- "Failure" usually manifests as one of the "require" lines failing, although you have the luarock installed. +-- Note that the plugin deliberately never fully loads, so that it can be reloaded fast by pressing its Enable button in the webadmin's plugin list. + + + + + + +local log30 = require("30log"); +local socket = require("socket"); +local http = require("socket.http"); + + + + + +LOGINFO("Trying to download a webpage..."); +local body, code, headers = http.request('http://forum.mc-server.org/index.php'); +LOG("code: " .. tostring(code)); +LOG("headers: "); +for k, v in pairs(headers or {}) do + LOG(" " .. k .. ": " .. v); +end +LOG("body length: " .. string.length(body)); + + + + + +function Initialize(a_Plugin) + if (socket == nil) then + LOG("LuaSocket not found"); + else + LOG("LuaSocket loaded"); + end + if (log30 == nil) then + LOG("30log not found"); + else + LOG("30log loaded"); + end + LOGINFO("Preventing plugin load so that it may be requested again from the webadmin."); + return false; +end \ No newline at end of file -- cgit v1.2.3 From 5832781727784c9926e397f3ff61d0d456c64797 Mon Sep 17 00:00:00 2001 From: Alexander Harkness Date: Tue, 3 Dec 2013 21:15:43 +0000 Subject: Updated TransAPI, fixes #389 @madmaxoft is this the right API usage? --- MCServer/Plugins/TransAPI | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MCServer/Plugins/TransAPI b/MCServer/Plugins/TransAPI index 52e1de433..da2723724 160000 --- a/MCServer/Plugins/TransAPI +++ b/MCServer/Plugins/TransAPI @@ -1 +1 @@ -Subproject commit 52e1de4332a026e58fda843aae98c1f51e57199e +Subproject commit da272372406e0990235b008dba73b7bfbda040e8 -- cgit v1.2.3 From 28e905bfffad48181e6e05f199eb8afc6312e9c9 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 3 Dec 2013 22:17:49 +0100 Subject: Fixed a linker warning in MSVC debug build. --- VC2008/MCServer.vcproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VC2008/MCServer.vcproj b/VC2008/MCServer.vcproj index e5de93f98..95e10ba40 100644 --- a/VC2008/MCServer.vcproj +++ b/VC2008/MCServer.vcproj @@ -43,7 +43,7 @@ AdditionalOptions="/MP" Optimization="0" AdditionalIncludeDirectories=""../lib/jsoncpp/include";../lib" - PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;XML_STATIC;LUA_BUILD_AS_DLL" + PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;XML_STATIC" MinimalRebuild="false" BasicRuntimeChecks="3" RuntimeLibrary="1" -- cgit v1.2.3 From be1cdadda76ca00998355c4b52da55d012ceae4a Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Wed, 4 Dec 2013 19:47:08 +0100 Subject: Fixed an error in cChunk's block ticking. Absolute coords were passed to a handler expecting relative coords. --- src/Chunk.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Chunk.cpp b/src/Chunk.cpp index 45825a30f..5c9eb892b 100644 --- a/src/Chunk.cpp +++ b/src/Chunk.cpp @@ -641,7 +641,7 @@ void cChunk::TickBlock(int a_RelX, int a_RelY, int a_RelZ) } cBlockHandler * Handler = BlockHandler(m_BlockTypes[Index]); ASSERT(Handler != NULL); // Happenned on server restart, FS #243 - Handler->OnUpdate(*this, a_RelX + m_PosX * Width, a_RelY, a_RelZ + m_PosZ * Width); + Handler->OnUpdate(*this, a_RelX, a_RelY, a_RelZ); } @@ -794,7 +794,7 @@ void cChunk::TickBlocks(void) unsigned int Index = MakeIndexNoCheck(m_BlockTickX, m_BlockTickY, m_BlockTickZ); cBlockHandler * Handler = BlockHandler(m_BlockTypes[Index]); ASSERT(Handler != NULL); // Happenned on server restart, FS #243 - Handler->OnUpdate(*this, m_BlockTickX + m_PosX * Width, m_BlockTickY, m_BlockTickZ + m_PosZ * Width); + Handler->OnUpdate(*this, m_BlockTickX, m_BlockTickY, m_BlockTickZ); } // for i - tickblocks } -- cgit v1.2.3 From e48168aa136f0243dca2d059d9e8039558a93c2d Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Wed, 4 Dec 2013 19:48:42 +0100 Subject: Lava can spawn fire. Settable in world.ini, lava can spawn fire to fuel blocks near it. Fix #65. --- src/Blocks/BlockFluid.h | 81 +++++++++++++++++++++++++++++++++++++++++++ src/Blocks/BlockHandler.cpp | 12 +++---- src/Simulator/FireSimulator.h | 4 +-- src/World.cpp | 1 + src/World.h | 3 ++ 5 files changed, 93 insertions(+), 8 deletions(-) diff --git a/src/Blocks/BlockFluid.h b/src/Blocks/BlockFluid.h index 0db2f60c4..bce5064bc 100644 --- a/src/Blocks/BlockFluid.h +++ b/src/Blocks/BlockFluid.h @@ -54,3 +54,84 @@ public: + +class cBlockLavaHandler : + public cBlockFluidHandler +{ + typedef cBlockFluidHandler super; +public: + + cBlockLavaHandler(BLOCKTYPE a_BlockType) : + super(a_BlockType) + { + } + + + /// Called to tick the block + virtual void OnUpdate(cChunk & a_Chunk, int a_RelX, int a_RelY, int a_RelZ) override + { + if (a_Chunk.GetWorld()->ShouldLavaSpawnFire()) + { + // Try to start up to 5 fires: + for (int i = 0; i < 5; i++) + { + TryStartFireNear(a_RelX, a_RelY, a_RelZ, a_Chunk); + } + } + } + + + /// Tries to start a fire near the lava at given coords. Returns true if fire started. + static bool TryStartFireNear(int a_RelX, int a_RelY, int a_RelZ, cChunk & a_Chunk) + { + // Pick a block next to this lava block: + int rnd = a_Chunk.GetWorld()->GetTickRandomNumber(cChunkDef::NumBlocks * 8) / 7; + int x = (rnd % 3) - 1; // -1 .. 1 + int y = ((rnd / 4) % 4) - 1; // -1 .. 2 + int z = ((rnd / 16) % 3) - 1; // -1 .. 1 + + // Check if it's fuel: + BLOCKTYPE BlockType; + if ( + !a_Chunk.UnboundedRelGetBlockType(a_RelX + x, a_RelY + y, a_RelZ + z, BlockType) || + !cFireSimulator::IsFuel(BlockType) + ) + { + return false; + } + + // Try to set it on fire: + static struct + { + int x, y, z; + } CrossCoords[] = + { + {-1, 0, 0}, + { 1, 0, 0}, + { 0, -1, 0}, + { 0, 1, 0}, + { 0, 0, -1}, + { 0, 0, 1}, + } ; + int RelX = a_RelX + x; + int RelY = a_RelY + y; + int RelZ = a_RelZ + z; + for (size_t i = 0; i < ARRAYCOUNT(CrossCoords); i++) + { + if ( + a_Chunk.UnboundedRelGetBlockType(RelX + CrossCoords[i].x, RelY + CrossCoords[i].y, RelZ + CrossCoords[i].z, BlockType) && + (BlockType == E_BLOCK_AIR) + ) + { + // This is an air block next to a fuel next to lava, light it up: + a_Chunk.UnboundedRelSetBlock(RelX + CrossCoords[i].x, RelY + CrossCoords[i].y, RelZ + CrossCoords[i].z, E_BLOCK_FIRE, 0); + return true; + } + } // for i - CrossCoords[] + return false; + } +} ; + + + + diff --git a/src/Blocks/BlockHandler.cpp b/src/Blocks/BlockHandler.cpp index 7bb35efeb..4a6d49449 100644 --- a/src/Blocks/BlockHandler.cpp +++ b/src/Blocks/BlockHandler.cpp @@ -144,6 +144,7 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType) case E_BLOCK_INACTIVE_COMPARATOR: return new cBlockComparatorHandler (a_BlockType); case E_BLOCK_IRON_DOOR: return new cBlockDoorHandler (a_BlockType); case E_BLOCK_IRON_ORE: return new cBlockOreHandler (a_BlockType); + case E_BLOCK_JACK_O_LANTERN: return new cBlockPumpkinHandler (a_BlockType); case E_BLOCK_JUKEBOX: return new cBlockEntityHandler (a_BlockType); case E_BLOCK_JUNGLE_WOOD_STAIRS: return new cBlockStairsHandler (a_BlockType); case E_BLOCK_LADDER: return new cBlockLadderHandler (a_BlockType); @@ -157,18 +158,17 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType) case E_BLOCK_MELON_STEM: return new cBlockStemsHandler (a_BlockType); case E_BLOCK_MYCELIUM: return new cBlockMyceliumHandler (a_BlockType); case E_BLOCK_NETHER_BRICK_STAIRS: return new cBlockStairsHandler (a_BlockType); + case E_BLOCK_NETHER_PORTAL: return new cBlockPortalHandler (a_BlockType); case E_BLOCK_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_PLANKS: return new cBlockPlanksHandler (a_BlockType); - case E_BLOCK_NETHER_PORTAL: return new cBlockPortalHandler (a_BlockType); + case E_BLOCK_POTATOES: return new cBlockCropsHandler (a_BlockType); + case E_BLOCK_POWERED_RAIL: return new cBlockRailHandler (a_BlockType); case E_BLOCK_PUMPKIN: return new cBlockPumpkinHandler (a_BlockType); - case E_BLOCK_JACK_O_LANTERN: return new cBlockPumpkinHandler (a_BlockType); case E_BLOCK_PUMPKIN_STEM: return new cBlockStemsHandler (a_BlockType); case E_BLOCK_QUARTZ_STAIRS: return new cBlockStairsHandler (a_BlockType); case E_BLOCK_RAIL: return new cBlockRailHandler (a_BlockType); - case E_BLOCK_POTATOES: return new cBlockCropsHandler (a_BlockType); - case E_BLOCK_POWERED_RAIL: return new cBlockRailHandler (a_BlockType); case E_BLOCK_REDSTONE_ORE: return new cBlockOreHandler (a_BlockType); case E_BLOCK_REDSTONE_ORE_GLOWING: return new cBlockOreHandler (a_BlockType); case E_BLOCK_REDSTONE_REPEATER_OFF: return new cBlockRedstoneRepeaterHandler(a_BlockType); @@ -184,8 +184,8 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType) case E_BLOCK_SIGN_POST: return new cBlockSignHandler (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_STATIONARY_LAVA: return new cBlockFluidHandler (a_BlockType); - case E_BLOCK_STATIONARY_WATER: return new cBlockFluidHandler (a_BlockType); + case E_BLOCK_STATIONARY_LAVA: return new cBlockLavaHandler (a_BlockType); + case E_BLOCK_STATIONARY_WATER: return new cBlockLavaHandler (a_BlockType); case E_BLOCK_STICKY_PISTON: return new cBlockPistonHandler (a_BlockType); case E_BLOCK_STONE: return new cBlockStoneHandler (a_BlockType); case E_BLOCK_STONE_BRICK_STAIRS: return new cBlockStairsHandler (a_BlockType); diff --git a/src/Simulator/FireSimulator.h b/src/Simulator/FireSimulator.h index 0d8a548ef..a788ed327 100644 --- a/src/Simulator/FireSimulator.h +++ b/src/Simulator/FireSimulator.h @@ -27,8 +27,8 @@ public: virtual bool IsAllowedBlock(BLOCKTYPE a_BlockType) override; - bool IsFuel (BLOCKTYPE a_BlockType); - bool IsForever(BLOCKTYPE a_BlockType); + static bool IsFuel (BLOCKTYPE a_BlockType); + static bool IsForever(BLOCKTYPE a_BlockType); protected: /// Time (in msec) that a fire block takes to burn with a fuel block into the next step diff --git a/src/World.cpp b/src/World.cpp index bed5d6701..7982924ae 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -522,6 +522,7 @@ void cWorld::Start(void) m_IsSugarcaneBonemealable = IniFile.GetValueSetB("Plants", "IsSugarcaneBonemealable", false); m_bEnabledPVP = IniFile.GetValueSetB("PVP", "Enabled", true); m_IsDeepSnowEnabled = IniFile.GetValueSetB("Physics", "DeepSnow", false); + m_ShouldLavaSpawnFire = IniFile.GetValueSetB("Physics", "ShouldLavaSpawnFire", true); m_GameMode = (eGameMode)IniFile.GetValueSetI("GameMode", "GameMode", m_GameMode); diff --git a/src/World.h b/src/World.h index a6b61f2e2..ea0db53e6 100644 --- a/src/World.h +++ b/src/World.h @@ -129,6 +129,8 @@ public: bool IsPVPEnabled(void) const { return m_bEnabledPVP; } bool IsDeepSnowEnabled(void) const { return m_IsDeepSnowEnabled; } + bool ShouldLavaSpawnFire(void) const { return m_ShouldLavaSpawnFire; } + eDimension GetDimension(void) const { return m_Dimension; } /// Returns the world height at the specified coords; waits for the chunk to get loaded / generated @@ -654,6 +656,7 @@ private: eGameMode m_GameMode; bool m_bEnabledPVP; bool m_IsDeepSnowEnabled; + bool m_ShouldLavaSpawnFire; // The cRedstone class simulates redstone and needs access to m_RSList // friend class cRedstone; -- cgit v1.2.3 From 9f1efbdf21255643e29566d7656d3f15555c7b70 Mon Sep 17 00:00:00 2001 From: Alexander Harkness Date: Wed, 4 Dec 2013 18:57:23 +0000 Subject: Hopefully fixed the sparc not being detected --- src/ByteBuffer.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/ByteBuffer.cpp b/src/ByteBuffer.cpp index a6be09ad3..29f3afbfc 100644 --- a/src/ByteBuffer.cpp +++ b/src/ByteBuffer.cpp @@ -26,7 +26,9 @@ (defined(_WIN32) && defined(__ARM__) && defined(_MSC_VER)) \ ) #define IS_LITTLE_ENDIAN -#elif defined (__ARMEB__) +#elif ( \ + defined (__ARMEB__) || defined(__sparc) \ +) #define IS_BIG_ENDIAN #else #error Cannot determine endianness of this platform -- cgit v1.2.3 From 4fd876aa7c1b4ca80fd3c35ecf3d7bef7934bfae Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Wed, 4 Dec 2013 20:34:57 +0100 Subject: Added a new Debug_LuaStatic configuration. This re-enables plugin debugging using Decoda, lost when we moved Lua out to a DLL. --- VC2008/.gitignore | 1 + VC2008/CryptoPP.vcproj | 743 ++++++++++++++++++++++++++++++++++++++++++++++++- VC2008/JsonCpp.vcproj | 62 +++++ VC2008/Lua.vcproj | 61 ++++ VC2008/MCServer.sln | 15 + VC2008/MCServer.vcproj | 207 ++++++++++++++ VC2008/ToLua.vcproj | 62 +++++ VC2008/expat.vcproj | 61 ++++ VC2008/zlib.vcproj | 62 +++++ 9 files changed, 1272 insertions(+), 2 deletions(-) diff --git a/VC2008/.gitignore b/VC2008/.gitignore index 27d2f5ebe..e31475ed0 100644 --- a/VC2008/.gitignore +++ b/VC2008/.gitignore @@ -1,5 +1,6 @@ Debug/ Debug profiled/ +Debug_LuaStatic/ Release/ Release profiled/ *.user diff --git a/VC2008/CryptoPP.vcproj b/VC2008/CryptoPP.vcproj index 530467eeb..c36312f4d 100644 --- a/VC2008/CryptoPP.vcproj +++ b/VC2008/CryptoPP.vcproj @@ -159,6 +159,74 @@ Name="VCPostBuildEventTool" /> + + + + + + + + + + + + + + + + + + + + @@ -514,6 +591,15 @@ PreprocessorDefinitions="" /> + + + @@ -570,6 +656,15 @@ PreprocessorDefinitions="" /> + + + @@ -626,6 +721,15 @@ PreprocessorDefinitions="" /> + + + @@ -686,6 +790,15 @@ PreprocessorDefinitions="" /> + + + @@ -742,6 +855,15 @@ PreprocessorDefinitions="" /> + + + @@ -798,6 +920,15 @@ PreprocessorDefinitions="" /> + + + @@ -854,6 +985,15 @@ PreprocessorDefinitions="" /> + + + @@ -914,6 +1054,15 @@ PreprocessorDefinitions="" /> + + + @@ -978,6 +1127,15 @@ PreprocessorDefinitions="" /> + + + @@ -1034,6 +1192,15 @@ PreprocessorDefinitions="" /> + + + @@ -1090,6 +1257,15 @@ PreprocessorDefinitions="" /> + + + @@ -1154,6 +1330,15 @@ PreprocessorDefinitions="" /> + + + @@ -1210,6 +1395,15 @@ PreprocessorDefinitions="" /> + + + @@ -1268,6 +1462,16 @@ UsePrecompiledHeader="0" /> + + + @@ -1328,6 +1532,15 @@ PreprocessorDefinitions="" /> + + + @@ -1388,6 +1601,15 @@ PreprocessorDefinitions="" /> + + + @@ -1446,6 +1668,16 @@ PreprocessorDefinitions="" /> + + + + + + @@ -1562,6 +1803,15 @@ PreprocessorDefinitions="" /> + + + @@ -1624,6 +1874,16 @@ PreprocessorDefinitions="" /> + + + + + + @@ -1740,6 +2009,15 @@ PreprocessorDefinitions="" /> + + + @@ -1796,6 +2074,15 @@ PreprocessorDefinitions="" /> + + + @@ -1852,6 +2139,15 @@ PreprocessorDefinitions="" /> + + + @@ -1912,6 +2208,15 @@ PreprocessorDefinitions="" /> + + + @@ -1968,6 +2273,15 @@ PreprocessorDefinitions="" /> + + + @@ -2024,6 +2338,15 @@ PreprocessorDefinitions="" /> + + + @@ -2080,6 +2403,15 @@ PreprocessorDefinitions="" /> + + + @@ -2136,6 +2468,15 @@ PreprocessorDefinitions="" /> + + + @@ -2192,6 +2533,15 @@ PreprocessorDefinitions="" /> + + + @@ -2248,6 +2598,15 @@ PreprocessorDefinitions="" /> + + + @@ -2304,6 +2663,15 @@ PreprocessorDefinitions="" /> + + + @@ -2363,6 +2731,16 @@ UsePrecompiledHeader="0" /> + + + @@ -2423,6 +2801,15 @@ PreprocessorDefinitions="" /> + + + @@ -2479,6 +2866,15 @@ PreprocessorDefinitions="" /> + + + @@ -2535,6 +2931,15 @@ PreprocessorDefinitions="" /> + + + @@ -2591,6 +2996,15 @@ PreprocessorDefinitions="" /> + + + @@ -2647,6 +3061,15 @@ PreprocessorDefinitions="" /> + + + @@ -2703,6 +3126,15 @@ PreprocessorDefinitions="" /> + + + @@ -2759,6 +3191,15 @@ PreprocessorDefinitions="" /> + + + @@ -2815,6 +3256,15 @@ PreprocessorDefinitions="" /> + + + @@ -2855,15 +3305,24 @@ RelativePath="..\lib\cryptopp\nbtheory.cpp" > + + + + + + @@ -2983,6 +3451,15 @@ PreprocessorDefinitions="" /> + + + @@ -3039,6 +3516,15 @@ PreprocessorDefinitions="" /> + + + @@ -3097,6 +3583,16 @@ UsePrecompiledHeader="1" /> + + + @@ -3157,6 +3653,15 @@ PreprocessorDefinitions="" /> + + + @@ -3213,6 +3718,15 @@ PreprocessorDefinitions="" /> + + + @@ -3273,6 +3787,15 @@ PreprocessorDefinitions="" /> + + + @@ -3329,6 +3852,15 @@ PreprocessorDefinitions="" /> + + + @@ -3385,6 +3917,15 @@ PreprocessorDefinitions="" /> + + + @@ -3441,6 +3982,15 @@ PreprocessorDefinitions="" /> + + + @@ -3497,6 +4047,15 @@ PreprocessorDefinitions="" /> + + + @@ -3553,6 +4112,15 @@ PreprocessorDefinitions="" /> + + + @@ -3609,6 +4177,15 @@ PreprocessorDefinitions="" /> + + + @@ -3665,6 +4242,15 @@ PreprocessorDefinitions="" /> + + + @@ -3721,6 +4307,15 @@ PreprocessorDefinitions="" /> + + + @@ -3777,6 +4372,15 @@ PreprocessorDefinitions="" /> + + + @@ -3833,6 +4437,15 @@ PreprocessorDefinitions="" /> + + + @@ -3893,6 +4506,15 @@ PreprocessorDefinitions="" /> + + + @@ -3949,6 +4571,15 @@ PreprocessorDefinitions="" /> + + + @@ -4005,6 +4636,15 @@ PreprocessorDefinitions="" /> + + + @@ -4061,6 +4701,15 @@ PreprocessorDefinitions="" /> + + + @@ -4117,6 +4766,15 @@ PreprocessorDefinitions="" /> + + + @@ -4173,6 +4831,15 @@ PreprocessorDefinitions="" /> + + + @@ -4229,6 +4896,15 @@ PreprocessorDefinitions="" /> + + + @@ -4285,6 +4961,15 @@ PreprocessorDefinitions="" /> + + + @@ -4341,6 +5026,15 @@ PreprocessorDefinitions="" /> + + + @@ -4397,6 +5091,15 @@ PreprocessorDefinitions="" /> + + + @@ -4453,6 +5156,15 @@ PreprocessorDefinitions="" /> + + + @@ -4509,6 +5221,15 @@ PreprocessorDefinitions="" /> + + + @@ -4569,6 +5290,15 @@ PreprocessorDefinitions="" /> + + + @@ -4625,6 +5355,15 @@ PreprocessorDefinitions="" /> + + + diff --git a/VC2008/JsonCpp.vcproj b/VC2008/JsonCpp.vcproj index 8b35f170b..f18f53471 100644 --- a/VC2008/JsonCpp.vcproj +++ b/VC2008/JsonCpp.vcproj @@ -266,6 +266,68 @@ Name="VCPostBuildEventTool" /> + + + + + + + + + + + + + + + + + diff --git a/VC2008/Lua.vcproj b/VC2008/Lua.vcproj index 1119d542b..3a7f9d0d5 100644 --- a/VC2008/Lua.vcproj +++ b/VC2008/Lua.vcproj @@ -291,6 +291,67 @@ Name="VCPostBuildEventTool" /> + + + + + + + + + + + + + + + + + diff --git a/VC2008/MCServer.sln b/VC2008/MCServer.sln index aeabaf252..a36150483 100644 --- a/VC2008/MCServer.sln +++ b/VC2008/MCServer.sln @@ -25,6 +25,7 @@ EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug profiled|Win32 = Debug profiled|Win32 + Debug_LuaStatic|Win32 = Debug_LuaStatic|Win32 Debug|Win32 = Debug|Win32 Release profiled|Win32 = Release profiled|Win32 Release|Win32 = Release|Win32 @@ -32,6 +33,8 @@ Global GlobalSection(ProjectConfigurationPlatforms) = postSolution {32012054-0C96-4C43-AB27-174FF8E72D66}.Debug profiled|Win32.ActiveCfg = Debug profiled|Win32 {32012054-0C96-4C43-AB27-174FF8E72D66}.Debug profiled|Win32.Build.0 = Debug profiled|Win32 + {32012054-0C96-4C43-AB27-174FF8E72D66}.Debug_LuaStatic|Win32.ActiveCfg = Debug_LuaStatic|Win32 + {32012054-0C96-4C43-AB27-174FF8E72D66}.Debug_LuaStatic|Win32.Build.0 = Debug_LuaStatic|Win32 {32012054-0C96-4C43-AB27-174FF8E72D66}.Debug|Win32.ActiveCfg = Debug|Win32 {32012054-0C96-4C43-AB27-174FF8E72D66}.Debug|Win32.Build.0 = Debug|Win32 {32012054-0C96-4C43-AB27-174FF8E72D66}.Release profiled|Win32.ActiveCfg = Release profiled|Win32 @@ -40,6 +43,8 @@ Global {32012054-0C96-4C43-AB27-174FF8E72D66}.Release|Win32.Build.0 = Release|Win32 {EA9D50FD-937A-4EF5-8C37-5F4175AF4FEA}.Debug profiled|Win32.ActiveCfg = Debug profiled|Win32 {EA9D50FD-937A-4EF5-8C37-5F4175AF4FEA}.Debug profiled|Win32.Build.0 = Debug profiled|Win32 + {EA9D50FD-937A-4EF5-8C37-5F4175AF4FEA}.Debug_LuaStatic|Win32.ActiveCfg = Debug_LuaStatic|Win32 + {EA9D50FD-937A-4EF5-8C37-5F4175AF4FEA}.Debug_LuaStatic|Win32.Build.0 = Debug_LuaStatic|Win32 {EA9D50FD-937A-4EF5-8C37-5F4175AF4FEA}.Debug|Win32.ActiveCfg = Debug|Win32 {EA9D50FD-937A-4EF5-8C37-5F4175AF4FEA}.Debug|Win32.Build.0 = Debug|Win32 {EA9D50FD-937A-4EF5-8C37-5F4175AF4FEA}.Release profiled|Win32.ActiveCfg = Release profiled|Win32 @@ -48,6 +53,8 @@ Global {EA9D50FD-937A-4EF5-8C37-5F4175AF4FEA}.Release|Win32.Build.0 = Release|Win32 {5AAA90B9-946D-4034-83F3-676B06A6E326}.Debug profiled|Win32.ActiveCfg = Debug profiled|Win32 {5AAA90B9-946D-4034-83F3-676B06A6E326}.Debug profiled|Win32.Build.0 = Debug profiled|Win32 + {5AAA90B9-946D-4034-83F3-676B06A6E326}.Debug_LuaStatic|Win32.ActiveCfg = Debug_LuaStatic|Win32 + {5AAA90B9-946D-4034-83F3-676B06A6E326}.Debug_LuaStatic|Win32.Build.0 = Debug_LuaStatic|Win32 {5AAA90B9-946D-4034-83F3-676B06A6E326}.Debug|Win32.ActiveCfg = Debug|Win32 {5AAA90B9-946D-4034-83F3-676B06A6E326}.Debug|Win32.Build.0 = Debug|Win32 {5AAA90B9-946D-4034-83F3-676B06A6E326}.Release profiled|Win32.ActiveCfg = Release profiled|Win32 @@ -56,6 +63,8 @@ Global {5AAA90B9-946D-4034-83F3-676B06A6E326}.Release|Win32.Build.0 = Release|Win32 {082E8185-7B3A-4945-8C82-9132341A329D}.Debug profiled|Win32.ActiveCfg = Debug profiled|Win32 {082E8185-7B3A-4945-8C82-9132341A329D}.Debug profiled|Win32.Build.0 = Debug profiled|Win32 + {082E8185-7B3A-4945-8C82-9132341A329D}.Debug_LuaStatic|Win32.ActiveCfg = Debug_LuaStatic|Win32 + {082E8185-7B3A-4945-8C82-9132341A329D}.Debug_LuaStatic|Win32.Build.0 = Debug_LuaStatic|Win32 {082E8185-7B3A-4945-8C82-9132341A329D}.Debug|Win32.ActiveCfg = Debug|Win32 {082E8185-7B3A-4945-8C82-9132341A329D}.Debug|Win32.Build.0 = Debug|Win32 {082E8185-7B3A-4945-8C82-9132341A329D}.Release profiled|Win32.ActiveCfg = Release profiled|Win32 @@ -64,6 +73,8 @@ Global {082E8185-7B3A-4945-8C82-9132341A329D}.Release|Win32.Build.0 = Release|Win32 {EEAB54AD-114C-4AB8-8482-0A52D502BD35}.Debug profiled|Win32.ActiveCfg = Debug profiled|Win32 {EEAB54AD-114C-4AB8-8482-0A52D502BD35}.Debug profiled|Win32.Build.0 = Debug profiled|Win32 + {EEAB54AD-114C-4AB8-8482-0A52D502BD35}.Debug_LuaStatic|Win32.ActiveCfg = Debug_LuaStatic|Win32 + {EEAB54AD-114C-4AB8-8482-0A52D502BD35}.Debug_LuaStatic|Win32.Build.0 = Debug_LuaStatic|Win32 {EEAB54AD-114C-4AB8-8482-0A52D502BD35}.Debug|Win32.ActiveCfg = Debug|Win32 {EEAB54AD-114C-4AB8-8482-0A52D502BD35}.Debug|Win32.Build.0 = Debug|Win32 {EEAB54AD-114C-4AB8-8482-0A52D502BD35}.Release profiled|Win32.ActiveCfg = Release profiled|Win32 @@ -72,6 +83,8 @@ Global {EEAB54AD-114C-4AB8-8482-0A52D502BD35}.Release|Win32.Build.0 = Release|Win32 {3423EC9A-52E4-4A4D-9753-EDEBC38785EF}.Debug profiled|Win32.ActiveCfg = Debug|Win32 {3423EC9A-52E4-4A4D-9753-EDEBC38785EF}.Debug profiled|Win32.Build.0 = Debug|Win32 + {3423EC9A-52E4-4A4D-9753-EDEBC38785EF}.Debug_LuaStatic|Win32.ActiveCfg = Debug_LuaStatic|Win32 + {3423EC9A-52E4-4A4D-9753-EDEBC38785EF}.Debug_LuaStatic|Win32.Build.0 = Debug_LuaStatic|Win32 {3423EC9A-52E4-4A4D-9753-EDEBC38785EF}.Debug|Win32.ActiveCfg = Debug|Win32 {3423EC9A-52E4-4A4D-9753-EDEBC38785EF}.Debug|Win32.Build.0 = Debug|Win32 {3423EC9A-52E4-4A4D-9753-EDEBC38785EF}.Release profiled|Win32.ActiveCfg = Release|Win32 @@ -80,6 +93,8 @@ Global {3423EC9A-52E4-4A4D-9753-EDEBC38785EF}.Release|Win32.Build.0 = Release|Win32 {5FCFAF8D-FF2C-456D-A72C-1D76F913AD96}.Debug profiled|Win32.ActiveCfg = Debug|Win32 {5FCFAF8D-FF2C-456D-A72C-1D76F913AD96}.Debug profiled|Win32.Build.0 = Debug|Win32 + {5FCFAF8D-FF2C-456D-A72C-1D76F913AD96}.Debug_LuaStatic|Win32.ActiveCfg = Debug_LuaStatic|Win32 + {5FCFAF8D-FF2C-456D-A72C-1D76F913AD96}.Debug_LuaStatic|Win32.Build.0 = Debug_LuaStatic|Win32 {5FCFAF8D-FF2C-456D-A72C-1D76F913AD96}.Debug|Win32.ActiveCfg = Debug|Win32 {5FCFAF8D-FF2C-456D-A72C-1D76F913AD96}.Debug|Win32.Build.0 = Debug|Win32 {5FCFAF8D-FF2C-456D-A72C-1D76F913AD96}.Release profiled|Win32.ActiveCfg = Release|Win32 diff --git a/VC2008/MCServer.vcproj b/VC2008/MCServer.vcproj index 95e10ba40..c5dedb677 100644 --- a/VC2008/MCServer.vcproj +++ b/VC2008/MCServer.vcproj @@ -327,6 +327,82 @@ Name="VCPostBuildEventTool" /> + + + + + + + + + + + + + + + + + + + @@ -549,6 +625,14 @@ UsePrecompiledHeader="1" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1742,6 +1897,17 @@ Outputs="Bindings.cpp" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/VC2008/expat.vcproj b/VC2008/expat.vcproj index a02549192..59aa0d973 100644 --- a/VC2008/expat.vcproj +++ b/VC2008/expat.vcproj @@ -139,6 +139,67 @@ Name="VCPostBuildEventTool" /> + + + + + + + + + + + + + + + + + diff --git a/VC2008/zlib.vcproj b/VC2008/zlib.vcproj index 1e07afc4c..c5d5ebe76 100644 --- a/VC2008/zlib.vcproj +++ b/VC2008/zlib.vcproj @@ -266,6 +266,68 @@ Name="VCPostBuildEventTool" /> + + + + + + + + + + + + + + + + + -- cgit v1.2.3 From fb2df4445810490ed06eed72e6a96f5fcc0c0155 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Wed, 4 Dec 2013 21:35:29 +0100 Subject: Fixed LuaStatic intermediate and output folders. --- VC2008/CryptoPP.vcproj | 4 ++-- VC2008/JsonCpp.vcproj | 4 ++-- VC2008/Lua.vcproj | 4 ++-- VC2008/ToLua.vcproj | 4 ++-- VC2008/expat.vcproj | 4 ++-- VC2008/zlib.vcproj | 4 ++-- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/VC2008/CryptoPP.vcproj b/VC2008/CryptoPP.vcproj index c36312f4d..a818e9aa1 100644 --- a/VC2008/CryptoPP.vcproj +++ b/VC2008/CryptoPP.vcproj @@ -161,8 +161,8 @@ diff --git a/VC2008/Lua.vcproj b/VC2008/Lua.vcproj index 3a7f9d0d5..d08d738ea 100644 --- a/VC2008/Lua.vcproj +++ b/VC2008/Lua.vcproj @@ -293,8 +293,8 @@ diff --git a/VC2008/ToLua.vcproj b/VC2008/ToLua.vcproj index e7fb5c3df..428591638 100644 --- a/VC2008/ToLua.vcproj +++ b/VC2008/ToLua.vcproj @@ -268,8 +268,8 @@ diff --git a/VC2008/expat.vcproj b/VC2008/expat.vcproj index 59aa0d973..b92b95737 100644 --- a/VC2008/expat.vcproj +++ b/VC2008/expat.vcproj @@ -141,8 +141,8 @@ diff --git a/VC2008/zlib.vcproj b/VC2008/zlib.vcproj index c5d5ebe76..cdc5bab8c 100644 --- a/VC2008/zlib.vcproj +++ b/VC2008/zlib.vcproj @@ -268,8 +268,8 @@ -- cgit v1.2.3 From 321b25921379ad7c5196b9468acc4291ed375ba9 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 5 Dec 2013 10:33:26 +0100 Subject: ByteBuffer: Fixed optimization failures with threading checks. --- src/ByteBuffer.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ByteBuffer.h b/src/ByteBuffer.h index a9dd7f5ea..95c690203 100644 --- a/src/ByteBuffer.h +++ b/src/ByteBuffer.h @@ -123,7 +123,7 @@ protected: int m_BufferSize; // Total size of the ringbuffer #ifdef _DEBUG - unsigned long m_ThreadID; // Thread that is currently accessing the object, checked via cSingleThreadAccessChecker + volatile unsigned long m_ThreadID; // Thread that is currently accessing the object, checked via cSingleThreadAccessChecker #endif // _DEBUG int m_DataStart; // Where the data starts in the ringbuffer -- cgit v1.2.3 From 1373539bceba112c6ecc2c01f9a215e40427b979 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 5 Dec 2013 12:20:37 +0100 Subject: ProtoProxy: Fixed metadata parsing. --- Tools/ProtoProxy/Connection.cpp | 36 +++++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/Tools/ProtoProxy/Connection.cpp b/Tools/ProtoProxy/Connection.cpp index 385caa2ce..0b49859cb 100644 --- a/Tools/ProtoProxy/Connection.cpp +++ b/Tools/ProtoProxy/Connection.cpp @@ -260,6 +260,9 @@ void cConnection::Log(const char * a_Format, ...) // Log to file: cCSLock Lock(m_CSLog); fputs(FullMsg.c_str(), m_LogFile); + #ifdef _DEBUG + fflush(m_LogFile); + #endif // _DEBUG // Log to screen: // std::cout << FullMsg; @@ -2678,15 +2681,20 @@ bool cConnection::ParseMetadata(cByteBuffer & a_Buffer, AString & a_Metadata) case 1: Length = 2; break; // short case 2: Length = 4; break; // int case 3: Length = 4; break; // float - case 4: // string16 + case 4: // UTF-8 string with VarInt length { - short Len = 0; - if (!a_Buffer.ReadBEShort(Len)) + UInt32 Len; + int rs = a_Buffer.GetReadableSpace(); + if (!a_Buffer.ReadVarInt(Len)) { return false; } - short NetLen = htons(Len); - a_Metadata.append((char *)&NetLen, 2); + rs = rs - a_Buffer.GetReadableSpace(); + cByteBuffer LenBuf(8); + LenBuf.WriteVarInt(Len); + AString VarLen; + LenBuf.ReadAll(VarLen); + a_Metadata.append(VarLen); Length = Len; break; } @@ -2766,11 +2774,21 @@ void cConnection::LogMetadata(const AString & a_Metadata, size_t a_IndentCount) pos += 4; break; } - case 4: // string16 + case 4: // UTF-8 string with VarInt length { - short Length = (a_Metadata[pos + 1] << 8) | a_Metadata[pos + 2]; - Log("%sstring[%d] = \"%*s\"", Indent.c_str(), Index, Length, a_Metadata.c_str() + pos + 3); - pos += Length + 2; + cByteBuffer bb(10); + int RestLen = (int)a_Metadata.size() - pos - 1; + if (RestLen > 8) + { + RestLen = 8; + } + bb.Write(a_Metadata.data() + pos + 1, RestLen); + UInt32 Length; + int rs = bb.GetReadableSpace(); + bb.ReadVarInt(Length); + rs = rs - bb.GetReadableSpace(); + Log("%sstring[%d] = \"%*s\"", Indent.c_str(), Index, Length, a_Metadata.c_str() + pos + rs + 1); + pos += Length + rs + 2; break; } case 5: -- cgit v1.2.3