From 303e086e7390a097d1cd0d1c18dabc15cffa8139 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Mon, 9 Dec 2013 17:58:44 +0000 Subject: Fixed VS013 compile --- VC2013/CryptoPP.vcxproj.filters | 6 +-- VC2013/MCServer.vcxproj | 17 +++---- VC2013/MCServer.vcxproj.filters | 105 ++++++++++++++++++---------------------- VC2013/ToLua.vcxproj | 11 ++--- VC2013/ToLua.vcxproj.filters | 3 -- 5 files changed, 63 insertions(+), 79 deletions(-) diff --git a/VC2013/CryptoPP.vcxproj.filters b/VC2013/CryptoPP.vcxproj.filters index bc8e51b81..d9d18befa 100644 --- a/VC2013/CryptoPP.vcxproj.filters +++ b/VC2013/CryptoPP.vcxproj.filters @@ -2,15 +2,15 @@ - {9cc4f7b9-4c1a-4f43-ba70-d1780e59b9af} + {de7b3b89-9cfa-4441-97a1-a41eb499d273} .cpp - {4570686f-18a1-4d38-a53b-062a4c223d4d} + {1ddea6e2-83c2-4c5f-962a-7ad7f117cc85} .;.h - {6c599481-412e-461e-b3b3-949c4f43474a} + {41edc228-f641-4aea-ad4b-14a4918be0a3} diff --git a/VC2013/MCServer.vcxproj b/VC2013/MCServer.vcxproj index 56fbdc165..334aa875c 100644 --- a/VC2013/MCServer.vcxproj +++ b/VC2013/MCServer.vcxproj @@ -1,4 +1,4 @@ - + @@ -224,8 +224,6 @@ - - @@ -365,16 +363,15 @@ true true - - + + - - + @@ -506,6 +503,7 @@ + @@ -535,7 +533,7 @@ true true - + true GenerateBindings.cmd @@ -617,7 +615,6 @@ - @@ -919,6 +916,7 @@ + @@ -933,7 +931,6 @@ - diff --git a/VC2013/MCServer.vcxproj.filters b/VC2013/MCServer.vcxproj.filters index 2f0794e85..724e1866d 100644 --- a/VC2013/MCServer.vcxproj.filters +++ b/VC2013/MCServer.vcxproj.filters @@ -10,73 +10,73 @@ cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - {52f3d533-108a-4cd8-8be2-19c799667e26} + {977716f7-b383-498a-950f-49afc6d551f6} - {727392f6-6dc8-4c0f-8380-2affc45d20d4} + {14ac2998-63d0-4bb3-97e3-1bd0007ffc74} - {169eedf6-1244-49d1-9a74-79002dee80a7} + {272cba2d-aa26-4c69-b6fa-94465078e351} - {78798af4-7e8b-4f86-8175-c34995b71a7f} + {1fabcea5-dba3-4265-b691-5795c69c4471} - {a9d6163b-75c5-47ef-8ebd-192c0053d987} + {c29beffd-33f6-44eb-8310-3e0462cdddf9} - {4e664e9b-8741-4701-9f32-60dcc29f6463} + {430cae6d-cfb2-49a2-9fb2-614fde244868} - {5496fc08-0db0-4de0-adff-760fa67a8a78} + {87060076-8ef4-4535-88ee-7a609e4391ae} - {0162bb1a-bed1-4e87-9ab7-c3da55911060} + {4e33e863-d055-4476-bb95-efd5ebc115d3} - {82c6a5ba-3211-4c01-a643-9cdf2983630f} + {ae97007e-0940-4f87-9786-8ed1d201e52c} - {fc99053a-c609-4646-ad85-9cbaccbcf1c5} + {99483c91-c76c-47c7-838d-ba25c2066c79} - {83b41e57-43fe-4bfc-8ca5-d0d460834d59} + {51b8f5f3-83b3-4068-8825-503f19b42542} - {d53d761d-7d28-41dd-9623-6b489fbba65a} + {959da118-757d-44c1-a4bd-d3345cfeb637} - {d3534b5b-4684-4857-befa-b78b9198eed8} + {be413233-b7df-4ef1-9eb3-8aa1de96bf3e} - {96831397-1e56-4d07-9a3f-d97b9caa3f64} + {224e8323-4bcc-4d7e-bdba-09fa22f42d66} - {6c6cceb3-545c-4698-a5c9-c01497e80022} + {f9ad84f7-9199-45d1-a609-128f60baa996} - {7491cc4f-d735-4546-8aad-24d11a7396b0} + {74088e2e-f7dc-478a-ae7f-bcfcb1a13dcc} - {201c626a-b869-407a-9c2a-e06cf8c8e127} + {5e5eae6e-3154-4f85-868e-2682d072a5b2} - {cd93064b-e465-4562-a09b-de2363d0fab4} + {124dfea0-3dcd-45c0-a196-ec9bd6e00b6a} - {8947d9a2-b1dc-4c3e-8c27-05ca5260843d} + {bc156df0-b3f8-4bf2-a434-59e63f5eafcc} - {26e14e8c-ffde-4f83-b3a0-e0001d590e7a} + {2bbb71f4-860a-4fc4-b9d9-ac05f806fea1} - {44ae2ab1-5552-4e84-b8b5-f28a59af0c4f} + {05facd8b-76e8-4bc5-9135-831b49ac5c65} - {ac8a4c54-36f2-4505-a0dc-66f2817ccfa7} + {6b70646e-a784-4617-8b26-941de4f8fd20} - {3e58b3c7-097f-4688-a619-2771353180fe} + {a2b234d1-1013-47c0-8a44-f3b294d83d19} @@ -486,37 +486,34 @@ Source Files\OSSupport - + Source Files\Bindings - + Source Files\Bindings - + Source Files\Bindings - + Source Files\Bindings - + Source Files\Bindings - + Source Files\Bindings - + Source Files\Bindings - + Source Files\Bindings - + Source Files\Bindings - - Source Files\Bindings - - + Source Files\Bindings @@ -909,6 +906,9 @@ Source Files\BlockEntities + + Source Files\BlockEntities + Source Files\BlockEntities @@ -945,12 +945,6 @@ Source Files\HTTPServer - - Source Files\BlockEntities - - - Source Files\Blocks - @@ -1471,28 +1465,28 @@ Source Files\OSSupport\Android Specific - + Source Files\Bindings - + Source Files\Bindings - + Source Files\Bindings - + Source Files\Bindings - + Source Files\Bindings - + Source Files\Bindings - + Source Files\Bindings - + Source Files\Bindings @@ -1624,6 +1618,9 @@ Source Files\BlockEntities + + Source Files\BlockEntities + Source Files\BlockEntities @@ -1660,14 +1657,8 @@ Source Files\HTTPServer - - Source Files\BlockEntities - - - Source Files\Bindings - Source Files\SQLite @@ -1688,7 +1679,7 @@ Source Files\OSSupport\Android Specific - + Source Files\Bindings diff --git a/VC2013/ToLua.vcxproj b/VC2013/ToLua.vcxproj index 4895f0a61..86f80d691 100644 --- a/VC2013/ToLua.vcxproj +++ b/VC2013/ToLua.vcxproj @@ -100,7 +100,7 @@ Disabled - ../lib/tolua++/include;../lib/lua/src;%(AdditionalIncludeDirectories) + ../lib/jsoncpp/include;../lib;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) true EnableFastChecks @@ -114,7 +114,7 @@ MaxSpeed true - ../lib/tolua++/include;../lib/lua/src;%(AdditionalIncludeDirectories) + ../lib/jsoncpp/include;../lib;%(AdditionalIncludeDirectories) WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) MultiThreaded true @@ -127,7 +127,7 @@ MaxSpeed true - ../lib/tolua++/include;../lib/lua/src;%(AdditionalIncludeDirectories) + ../lib/jsoncpp/include;../lib;%(AdditionalIncludeDirectories) WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) MultiThreaded true @@ -139,7 +139,7 @@ Disabled - ../lib/tolua++/include;../lib/lua/src;%(AdditionalIncludeDirectories) + ../lib/jsoncpp/include;../lib;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) true EnableFastChecks @@ -152,7 +152,7 @@ Disabled - ../lib/tolua++/include;../lib/lua/src;%(AdditionalIncludeDirectories) + ../lib/jsoncpp/include;../lib;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) true EnableFastChecks @@ -163,7 +163,6 @@ - diff --git a/VC2013/ToLua.vcxproj.filters b/VC2013/ToLua.vcxproj.filters index 5d104d7d0..095111dc8 100644 --- a/VC2013/ToLua.vcxproj.filters +++ b/VC2013/ToLua.vcxproj.filters @@ -7,9 +7,6 @@ - - Source Files - Source Files -- cgit v1.2.3 From 97a1147acaf3a994fb1c62cf79a70dfd10f22fe0 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Mon, 9 Dec 2013 23:43:06 +0000 Subject: Improved pickups spawning speed again --- src/Blocks/BlockHandler.cpp | 5 ++--- src/World.cpp | 8 ++++---- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/Blocks/BlockHandler.cpp b/src/Blocks/BlockHandler.cpp index 99559ed02..fde6bd803 100644 --- a/src/Blocks/BlockHandler.cpp +++ b/src/Blocks/BlockHandler.cpp @@ -376,9 +376,8 @@ void cBlockHandler::DropBlock(cWorld * a_World, cEntity * a_Digger, int a_BlockX MicroZ = a_BlockZ + 0.5; // Add random offset second (this causes pickups to spawn inside blocks most times, it's a little buggy) - //MicroX += (int)(r1.randInt(16) + r1.randInt(16) - 16); - //MicroY += (int)(r1.randInt(16) + r1.randInt(16) - 16); - //MicroZ += (int)(r1.randInt(16) + r1.randInt(16) - 16); + MicroX += r1.rand(1) - 0.5; + MicroZ += r1.rand(1) - 0.5; a_World->SpawnItemPickups(Pickups, MicroX, MicroY, MicroZ); } diff --git a/src/World.cpp b/src/World.cpp index eecd02027..564905d33 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -1588,7 +1588,7 @@ bool cWorld::WriteBlockArea(cBlockArea & a_Area, int a_MinBlockX, int a_MinBlock void cWorld::SpawnItemPickups(const cItems & a_Pickups, double a_BlockX, double a_BlockY, double a_BlockZ, double a_FlyAwaySpeed, bool IsPlayerCreated) { MTRand r1; - a_FlyAwaySpeed /= 1000; // Pre-divide, so that we don't have to divide each time inside the loop + a_FlyAwaySpeed /= 100; // Pre-divide, so that we don't have to divide each time inside the loop for (cItems::const_iterator itr = a_Pickups.begin(); itr != a_Pickups.end(); ++itr) { if (!IsValidItem(itr->m_ItemType)) @@ -1597,9 +1597,9 @@ void cWorld::SpawnItemPickups(const cItems & a_Pickups, double a_BlockX, double continue; } - float SpeedX = (float)(a_FlyAwaySpeed * (r1.randInt(1000) - 500)); - float SpeedY = (float)(a_FlyAwaySpeed * (r1.randInt(1000) - 500)); - float SpeedZ = (float)(a_FlyAwaySpeed * (r1.randInt(1000) - 500)); + float SpeedX = (float)(a_FlyAwaySpeed * (r1.randInt(10) - 5)); + float SpeedY = (float)(a_FlyAwaySpeed * r1.randInt(50)); + float SpeedZ = (float)(a_FlyAwaySpeed * (r1.randInt(10) - 5)); cPickup * Pickup = new cPickup( a_BlockX, a_BlockY, a_BlockZ, -- cgit v1.2.3 From aecdfebf365d462e5405e21f1998e99d50bc1028 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Mon, 9 Dec 2013 23:43:26 +0000 Subject: Changed more FastSetBlocks to SetBlocks Fixes duplication bugs. --- src/Simulator/RedstoneSimulator.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Simulator/RedstoneSimulator.cpp b/src/Simulator/RedstoneSimulator.cpp index 63e4f04a8..424e22ca4 100644 --- a/src/Simulator/RedstoneSimulator.cpp +++ b/src/Simulator/RedstoneSimulator.cpp @@ -285,7 +285,7 @@ void cRedstoneSimulator::HandleRedstoneTorch(int a_BlockX, int a_BlockY, int a_B if (AreCoordsPowered(X, Y, Z)) { // There was a match, torch goes off - m_World.FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_REDSTONE_TORCH_OFF, m_World.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ)); + m_World.SetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_REDSTONE_TORCH_OFF, m_World.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ)); return; } @@ -335,7 +335,7 @@ void cRedstoneSimulator::HandleRedstoneTorch(int a_BlockX, int a_BlockY, int a_B } // Block torch on not powered, can be turned on again! - m_World.FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_REDSTONE_TORCH_ON, m_World.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ)); + m_World.SetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_REDSTONE_TORCH_ON, m_World.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ)); } } @@ -572,7 +572,7 @@ void cRedstoneSimulator::HandleRedstoneRepeater(int a_BlockX, int a_BlockY, int { if (IsOn) { - m_World.FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_REDSTONE_REPEATER_OFF, a_Meta); + m_World.SetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_REDSTONE_REPEATER_OFF, a_Meta); } } } -- cgit v1.2.3 From ebad87d870174ed2e99be5d4f4404a8ad2aa8ab8 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Mon, 9 Dec 2013 23:48:06 +0000 Subject: Slight redstone wire performance improvement --- src/Simulator/RedstoneSimulator.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Simulator/RedstoneSimulator.cpp b/src/Simulator/RedstoneSimulator.cpp index 424e22ca4..c5fc1fb3f 100644 --- a/src/Simulator/RedstoneSimulator.cpp +++ b/src/Simulator/RedstoneSimulator.cpp @@ -420,6 +420,7 @@ void cRedstoneSimulator::HandleRedstoneWire(int a_BlockX, int a_BlockY, int a_Bl } else { + NIBBLETYPE MetaToSet = 0; NIBBLETYPE MyMeta = m_World.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ); int TimesMetaSmaller = 0, TimesFoundAWire = 0; @@ -439,7 +440,7 @@ void cRedstoneSimulator::HandleRedstoneWire(int a_BlockX, int a_BlockY, int a_Bl // >= to fix a bug where wires bordering each other with the same power level will appear (in terms of meta) to power each other, when they aren't actually in the powered list if (SurroundMeta >= MyMeta) { - m_World.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, SurroundMeta - 1); + MetaToSet = SurroundMeta - 1; // To improve performance } } @@ -459,6 +460,10 @@ void cRedstoneSimulator::HandleRedstoneWire(int a_BlockX, int a_BlockY, int a_Bl m_World.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, 0); return; // No need to process block power sets because self not powered } + else + { + m_World.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, MetaToSet); + } SetBlockPowered(a_BlockX, a_BlockY - 1, a_BlockZ, a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_REDSTONE_WIRE); // Power block beneath } -- cgit v1.2.3 From 1dec73be0b3967796fc0baf43e19cbb6abd09c1e Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Tue, 10 Dec 2013 00:21:24 +0000 Subject: Added repeater delays They DO sometimes get stuck though :P --- src/Simulator/RedstoneSimulator.cpp | 54 ++++++++++++++++++++++++++++++++++++- src/Simulator/RedstoneSimulator.h | 9 +++++++ 2 files changed, 62 insertions(+), 1 deletion(-) diff --git a/src/Simulator/RedstoneSimulator.cpp b/src/Simulator/RedstoneSimulator.cpp index c5fc1fb3f..2325ce6b6 100644 --- a/src/Simulator/RedstoneSimulator.cpp +++ b/src/Simulator/RedstoneSimulator.cpp @@ -543,6 +543,33 @@ void cRedstoneSimulator::HandleRedstoneRepeater(int a_BlockX, int a_BlockY, int { if (!IsOn) { + // If repeater is not on already (and is POWERED), see if it is in repeater list, or has reached delay time + for (RepeatersDelayList::iterator itr = m_RepeatersDelayList.begin(); itr != m_RepeatersDelayList.end(); itr++) + { + if (itr->a_BlockPos.Equals(Vector3i(a_BlockX, a_BlockY, a_BlockZ))) + { + if (itr->a_DelayTicks <= itr->a_ElapsedTicks) // Shouldn't need <=; just in case something happens + { + m_RepeatersDelayList.erase(itr); + goto powerrepeater; // Delay time reached, break straight out, and into the powering code + } + else + { + itr->a_ElapsedTicks++; // Increment elapsed ticks and quit + return; + } + } + } + + // Self not in list, add self to list + sRepeatersDelayList RC; + RC.a_BlockPos = Vector3i(a_BlockX, a_BlockY, a_BlockZ); + RC.a_DelayTicks = ((a_Meta & 0xC) >> 0x2) + 1; // Gets the top two bits (delay time), shifts them into the lower two bits, and adds one (meta 0 = 1 tick; 1 = 2 etc.) + RC.a_ElapsedTicks = 0; + m_RepeatersDelayList.push_back(RC); + return; + +powerrepeater: m_World.SetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_REDSTONE_REPEATER_ON, a_Meta); // Only set if not on; SetBlock otherwise server doesn't set it in time for SimulateChunk's invalidation } switch (a_Meta & 0x3) // We only want the direction (bottom) bits @@ -577,7 +604,32 @@ void cRedstoneSimulator::HandleRedstoneRepeater(int a_BlockX, int a_BlockY, int { if (IsOn) { - m_World.SetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_REDSTONE_REPEATER_OFF, a_Meta); + // If repeater is not off already (and is NOT POWERED), see if it is in repeater list, or has reached delay time + for (RepeatersDelayList::iterator itr = m_RepeatersDelayList.begin(); itr != m_RepeatersDelayList.end(); itr++) + { + if (itr->a_BlockPos.Equals(Vector3i(a_BlockX, a_BlockY, a_BlockZ))) + { + if (itr->a_DelayTicks <= itr->a_ElapsedTicks) // Shouldn't need <=; just in case something happens + { + m_RepeatersDelayList.erase(itr); + m_World.SetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_REDSTONE_REPEATER_OFF, a_Meta); + return; + } + else + { + itr->a_ElapsedTicks++; // Increment elapsed ticks and quit + return; + } + } + } + + // Self not in list, add self to list + sRepeatersDelayList RC; + RC.a_BlockPos = Vector3i(a_BlockX, a_BlockY, a_BlockZ); + RC.a_DelayTicks = ((a_Meta & 0xC) >> 0x2) + 1; + RC.a_ElapsedTicks = 0; + m_RepeatersDelayList.push_back(RC); + return; } } } diff --git a/src/Simulator/RedstoneSimulator.h b/src/Simulator/RedstoneSimulator.h index e094150e8..1d85c0634 100644 --- a/src/Simulator/RedstoneSimulator.h +++ b/src/Simulator/RedstoneSimulator.h @@ -56,14 +56,23 @@ private: Vector3i a_BlockPos; bool WasLastStatePowered; }; + + struct sRepeatersDelayList + { + Vector3i a_BlockPos; + short a_DelayTicks; + short a_ElapsedTicks; + }; typedef std::vector PoweredBlocksList; typedef std::vector LinkedBlocksList; typedef std::vector SimulatedPlayerToggleableList; + typedef std::vector RepeatersDelayList; PoweredBlocksList m_PoweredBlocks; LinkedBlocksList m_LinkedPoweredBlocks; SimulatedPlayerToggleableList m_SimulatedPlayerToggleableBlocks; + RepeatersDelayList m_RepeatersDelayList; virtual void AddBlock(int a_BlockX, int a_BlockY, int a_BlockZ, cChunk * a_Chunk) override; -- cgit v1.2.3 From 0905369fc721fe0057e9e140777dc93f938646c6 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Tue, 10 Dec 2013 00:29:59 +0000 Subject: Fixed Floody lava to stone fizzle --- .../Plugins/APIDump/Hooks/OnEntityAnimation.lua | 28 ++++++++++++++++++++++ .../Plugins/APIDump/Hooks/OnPlayerAnimation.lua | 28 ---------------------- src/Simulator/FloodyFluidSimulator.cpp | 18 ++++++++++++-- 3 files changed, 44 insertions(+), 30 deletions(-) create mode 100644 MCServer/Plugins/APIDump/Hooks/OnEntityAnimation.lua delete mode 100644 MCServer/Plugins/APIDump/Hooks/OnPlayerAnimation.lua diff --git a/MCServer/Plugins/APIDump/Hooks/OnEntityAnimation.lua b/MCServer/Plugins/APIDump/Hooks/OnEntityAnimation.lua new file mode 100644 index 000000000..baf99834e --- /dev/null +++ b/MCServer/Plugins/APIDump/Hooks/OnEntityAnimation.lua @@ -0,0 +1,28 @@ +return +{ + HOOK_PLAYER_ANIMATION = + { + CalledWhen = "A client has sent an Animation packet (0x12)", + DefaultFnName = "OnPlayerAnimation", -- also used as pagename + Desc = [[ + This hook is called when the server receives an Animation packet (0x12) from the client.

+

+ For the list of animations that are sent by the client, see the + Protocol wiki. + ]], + Params = + { + { Name = "Player", Type = "{{cPlayer}}", Notes = "The player from whom the packet was received" }, + { Name = "Animation", Type = "number", Notes = "The kind of animation" }, + }, + Returns = [[ + If the function returns false or no value, the next plugin's callback is called. Afterwards, the + server broadcasts the animation packet to all nearby clients. If the function returns true, no other + callback is called for this event and the packet is not broadcasted. + ]], + }, -- HOOK_PLAYER_ANIMATION +} + + + + diff --git a/MCServer/Plugins/APIDump/Hooks/OnPlayerAnimation.lua b/MCServer/Plugins/APIDump/Hooks/OnPlayerAnimation.lua deleted file mode 100644 index baf99834e..000000000 --- a/MCServer/Plugins/APIDump/Hooks/OnPlayerAnimation.lua +++ /dev/null @@ -1,28 +0,0 @@ -return -{ - HOOK_PLAYER_ANIMATION = - { - CalledWhen = "A client has sent an Animation packet (0x12)", - DefaultFnName = "OnPlayerAnimation", -- also used as pagename - Desc = [[ - This hook is called when the server receives an Animation packet (0x12) from the client.

-

- For the list of animations that are sent by the client, see the - Protocol wiki. - ]], - Params = - { - { Name = "Player", Type = "{{cPlayer}}", Notes = "The player from whom the packet was received" }, - { Name = "Animation", Type = "number", Notes = "The kind of animation" }, - }, - Returns = [[ - If the function returns false or no value, the next plugin's callback is called. Afterwards, the - server broadcasts the animation packet to all nearby clients. If the function returns true, no other - callback is called for this event and the packet is not broadcasted. - ]], - }, -- HOOK_PLAYER_ANIMATION -} - - - - diff --git a/src/Simulator/FloodyFluidSimulator.cpp b/src/Simulator/FloodyFluidSimulator.cpp index d204a1f8b..58e5d614b 100644 --- a/src/Simulator/FloodyFluidSimulator.cpp +++ b/src/Simulator/FloodyFluidSimulator.cpp @@ -224,7 +224,14 @@ void cFloodyFluidSimulator::SpreadToNeighbor(cChunk * a_NearChunk, int a_RelX, i ItemTypeToString(NewBlock).c_str() ); a_NearChunk->UnboundedRelSetBlock(a_RelX, a_RelY, a_RelZ, NewBlock, 0); - m_World.BroadcastSoundEffect("random.fizz", a_RelX * 8, a_RelY * 8, a_RelZ * 8, 0.5f, 1.5f); + + int BaseX = a_NearChunk->GetPosX() * cChunkDef::Width; + int BaseZ = a_NearChunk->GetPosZ() * cChunkDef::Width; + + BaseX += a_RelX; + BaseZ += a_RelZ; + + a_NearChunk->BroadcastSoundEffect("random.fizz", BaseX * 8, a_RelY * 8, BaseZ * 8, 0.5f, 1.5f); return; } } @@ -238,7 +245,14 @@ void cFloodyFluidSimulator::SpreadToNeighbor(cChunk * a_NearChunk, int a_RelX, i a_RelX, a_RelY, a_RelZ, ItemTypeToString(NewBlock).c_str() ); a_NearChunk->UnboundedRelSetBlock(a_RelX, a_RelY, a_RelZ, NewBlock, 0); - m_World.BroadcastSoundEffect("random.fizz", a_RelX * 8, a_RelY * 8, a_RelZ * 8, 0.5f, 1.5f); + + int BaseX = a_NearChunk->GetPosX() * cChunkDef::Width; + int BaseZ = a_NearChunk->GetPosZ() * cChunkDef::Width; + + BaseX += a_RelX; + BaseZ += a_RelZ; + + a_NearChunk->BroadcastSoundEffect("random.fizz", BaseX * 8, a_RelY * 8, BaseZ * 8, 0.5f, 1.5f); return; } } -- cgit v1.2.3 From bc8d926398fd173b1e4345f2c68c04f5e1bc0a56 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Tue, 10 Dec 2013 00:33:48 +0000 Subject: Reverted APIDump changes They were wrong! --- .../Plugins/APIDump/Hooks/OnEntityAnimation.lua | 28 ---------------------- .../Plugins/APIDump/Hooks/OnPlayerAnimation.lua | 28 ++++++++++++++++++++++ 2 files changed, 28 insertions(+), 28 deletions(-) delete mode 100644 MCServer/Plugins/APIDump/Hooks/OnEntityAnimation.lua create mode 100644 MCServer/Plugins/APIDump/Hooks/OnPlayerAnimation.lua diff --git a/MCServer/Plugins/APIDump/Hooks/OnEntityAnimation.lua b/MCServer/Plugins/APIDump/Hooks/OnEntityAnimation.lua deleted file mode 100644 index baf99834e..000000000 --- a/MCServer/Plugins/APIDump/Hooks/OnEntityAnimation.lua +++ /dev/null @@ -1,28 +0,0 @@ -return -{ - HOOK_PLAYER_ANIMATION = - { - CalledWhen = "A client has sent an Animation packet (0x12)", - DefaultFnName = "OnPlayerAnimation", -- also used as pagename - Desc = [[ - This hook is called when the server receives an Animation packet (0x12) from the client.

-

- For the list of animations that are sent by the client, see the - Protocol wiki. - ]], - Params = - { - { Name = "Player", Type = "{{cPlayer}}", Notes = "The player from whom the packet was received" }, - { Name = "Animation", Type = "number", Notes = "The kind of animation" }, - }, - Returns = [[ - If the function returns false or no value, the next plugin's callback is called. Afterwards, the - server broadcasts the animation packet to all nearby clients. If the function returns true, no other - callback is called for this event and the packet is not broadcasted. - ]], - }, -- HOOK_PLAYER_ANIMATION -} - - - - diff --git a/MCServer/Plugins/APIDump/Hooks/OnPlayerAnimation.lua b/MCServer/Plugins/APIDump/Hooks/OnPlayerAnimation.lua new file mode 100644 index 000000000..baf99834e --- /dev/null +++ b/MCServer/Plugins/APIDump/Hooks/OnPlayerAnimation.lua @@ -0,0 +1,28 @@ +return +{ + HOOK_PLAYER_ANIMATION = + { + CalledWhen = "A client has sent an Animation packet (0x12)", + DefaultFnName = "OnPlayerAnimation", -- also used as pagename + Desc = [[ + This hook is called when the server receives an Animation packet (0x12) from the client.

+

+ For the list of animations that are sent by the client, see the + Protocol wiki. + ]], + Params = + { + { Name = "Player", Type = "{{cPlayer}}", Notes = "The player from whom the packet was received" }, + { Name = "Animation", Type = "number", Notes = "The kind of animation" }, + }, + Returns = [[ + If the function returns false or no value, the next plugin's callback is called. Afterwards, the + server broadcasts the animation packet to all nearby clients. If the function returns true, no other + callback is called for this event and the packet is not broadcasted. + ]], + }, -- HOOK_PLAYER_ANIMATION +} + + + + -- cgit v1.2.3 From b6e02349858a31028e0faacc2d717556a4f1b5dd Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Tue, 10 Dec 2013 10:29:36 +0000 Subject: Fixed compile (alas, no more goto) --- src/Simulator/RedstoneSimulator.cpp | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/src/Simulator/RedstoneSimulator.cpp b/src/Simulator/RedstoneSimulator.cpp index 2325ce6b6..93ad5890b 100644 --- a/src/Simulator/RedstoneSimulator.cpp +++ b/src/Simulator/RedstoneSimulator.cpp @@ -1,4 +1,3 @@ - #include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules #include "RedstoneSimulator.h" @@ -543,6 +542,7 @@ void cRedstoneSimulator::HandleRedstoneRepeater(int a_BlockX, int a_BlockY, int { if (!IsOn) { + bool ShouldCreate = true; // If repeater is not on already (and is POWERED), see if it is in repeater list, or has reached delay time for (RepeatersDelayList::iterator itr = m_RepeatersDelayList.begin(); itr != m_RepeatersDelayList.end(); itr++) { @@ -551,7 +551,8 @@ void cRedstoneSimulator::HandleRedstoneRepeater(int a_BlockX, int a_BlockY, int if (itr->a_DelayTicks <= itr->a_ElapsedTicks) // Shouldn't need <=; just in case something happens { m_RepeatersDelayList.erase(itr); - goto powerrepeater; // Delay time reached, break straight out, and into the powering code + ShouldCreate = false; + break; // Delay time reached, break straight out, and into the powering code } else { @@ -561,15 +562,17 @@ void cRedstoneSimulator::HandleRedstoneRepeater(int a_BlockX, int a_BlockY, int } } - // Self not in list, add self to list - sRepeatersDelayList RC; - RC.a_BlockPos = Vector3i(a_BlockX, a_BlockY, a_BlockZ); - RC.a_DelayTicks = ((a_Meta & 0xC) >> 0x2) + 1; // Gets the top two bits (delay time), shifts them into the lower two bits, and adds one (meta 0 = 1 tick; 1 = 2 etc.) - RC.a_ElapsedTicks = 0; - m_RepeatersDelayList.push_back(RC); - return; - -powerrepeater: + if (ShouldCreate) + { + // Self not in list, add self to list + sRepeatersDelayList RC; + RC.a_BlockPos = Vector3i(a_BlockX, a_BlockY, a_BlockZ); + RC.a_DelayTicks = ((a_Meta & 0xC) >> 0x2) + 1; // Gets the top two bits (delay time), shifts them into the lower two bits, and adds one (meta 0 = 1 tick; 1 = 2 etc.) + RC.a_ElapsedTicks = 0; + m_RepeatersDelayList.push_back(RC); + return; + } + m_World.SetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_REDSTONE_REPEATER_ON, a_Meta); // Only set if not on; SetBlock otherwise server doesn't set it in time for SimulateChunk's invalidation } switch (a_Meta & 0x3) // We only want the direction (bottom) bits -- cgit v1.2.3 From e2e8c9624c62999114f0c84b33317172b3a7ca4a Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Tue, 10 Dec 2013 10:31:42 +0000 Subject: Readded initial line --- src/Simulator/RedstoneSimulator.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Simulator/RedstoneSimulator.cpp b/src/Simulator/RedstoneSimulator.cpp index 93ad5890b..9328b9fcb 100644 --- a/src/Simulator/RedstoneSimulator.cpp +++ b/src/Simulator/RedstoneSimulator.cpp @@ -1,3 +1,4 @@ + #include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules #include "RedstoneSimulator.h" -- cgit v1.2.3