From cfbb2563604e77e044be9a0f12b2152a7d626b51 Mon Sep 17 00:00:00 2001 From: Julian Laubstein Date: Mon, 19 May 2014 10:37:43 +0200 Subject: Fixed some warnings --- src/Simulator/IncrementalRedstoneSimulator.h | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/Simulator/IncrementalRedstoneSimulator.h b/src/Simulator/IncrementalRedstoneSimulator.h index 233a3d408..a57a17328 100644 --- a/src/Simulator/IncrementalRedstoneSimulator.h +++ b/src/Simulator/IncrementalRedstoneSimulator.h @@ -202,8 +202,13 @@ private: case E_BLOCK_POWERED_RAIL: { return true; + break; + } + default: + { + return false; + break; } - default: return false; } } @@ -275,8 +280,13 @@ private: case E_BLOCK_PISTON: { return true; + break; + } + default: + { + return false; + break; } - default: return false; } } }; -- cgit v1.2.3 From e9abf9a4987835a52dab508f9b8a8feb57e9a103 Mon Sep 17 00:00:00 2001 From: Julian Laubstein Date: Mon, 19 May 2014 13:02:02 +0200 Subject: Rolled some changes back --- src/Simulator/IncrementalRedstoneSimulator.h | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/Simulator/IncrementalRedstoneSimulator.h b/src/Simulator/IncrementalRedstoneSimulator.h index a57a17328..233a3d408 100644 --- a/src/Simulator/IncrementalRedstoneSimulator.h +++ b/src/Simulator/IncrementalRedstoneSimulator.h @@ -202,13 +202,8 @@ private: case E_BLOCK_POWERED_RAIL: { return true; - break; - } - default: - { - return false; - break; } + default: return false; } } @@ -280,13 +275,8 @@ private: case E_BLOCK_PISTON: { return true; - break; - } - default: - { - return false; - break; } + default: return false; } } }; -- cgit v1.2.3 From fb7f2993bf3b62c00d4502b846018b035ffbdb7a Mon Sep 17 00:00:00 2001 From: Julian Laubstein Date: Mon, 19 May 2014 14:34:34 +0200 Subject: Fixed some warnings in Server.cpp, and in UI/ --- src/Server.cpp | 8 +++++++- src/UI/SlotArea.cpp | 3 ++- src/UI/Window.cpp | 3 ++- 3 files changed, 11 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/Server.cpp b/src/Server.cpp index aa731cdd2..66bccd680 100644 --- a/src/Server.cpp +++ b/src/Server.cpp @@ -107,10 +107,16 @@ void cServer::cTickThread::Execute(void) cServer::cServer(void) : m_ListenThreadIPv4(*this, cSocket::IPv4, "Client IPv4"), m_ListenThreadIPv6(*this, cSocket::IPv6, "Client IPv6"), + m_PlayerCount(0), + m_PlayerCountDiff(0), + m_ClientViewDistance(0), m_bIsConnected(false), m_bRestarting(false), m_RCONServer(*this), - m_TickThread(*this) + m_MaxPlayers(0), + m_bIsHardcore(false), + m_TickThread(*this), + m_ShouldAuthenticate(false) { } diff --git a/src/UI/SlotArea.cpp b/src/UI/SlotArea.cpp index 8833a767a..be3ce1f8d 100644 --- a/src/UI/SlotArea.cpp +++ b/src/UI/SlotArea.cpp @@ -600,7 +600,8 @@ cCraftingRecipe & cSlotAreaCrafting::GetRecipeForPlayer(cPlayer & a_Player) cSlotAreaAnvil::cSlotAreaAnvil(cAnvilWindow & a_ParentWindow) : cSlotAreaTemporary(3, a_ParentWindow), - m_MaximumCost(0) + m_MaximumCost(0), + m_StackSizeToBeUsedInRepair(0) { } diff --git a/src/UI/Window.cpp b/src/UI/Window.cpp index 46885390b..24b718156 100644 --- a/src/UI/Window.cpp +++ b/src/UI/Window.cpp @@ -856,7 +856,8 @@ cEnchantingWindow::cEnchantingWindow(int a_BlockX, int a_BlockY, int a_BlockZ) : cWindow(wtEnchantment, "Enchant"), m_BlockX(a_BlockX), m_BlockY(a_BlockY), - m_BlockZ(a_BlockZ) + m_BlockZ(a_BlockZ), + m_SlotArea() { m_SlotAreas.push_back(new cSlotAreaEnchanting(*this)); m_SlotAreas.push_back(new cSlotAreaInventory(*this)); -- cgit v1.2.3 From 6687848a7ec1a65ed2c99264ecf9e8119b19c964 Mon Sep 17 00:00:00 2001 From: Julian Laubstein Date: Mon, 19 May 2014 14:49:18 +0200 Subject: Fixed warnings in IncrementalRedstoneSimulator --- src/Simulator/IncrementalRedstoneSimulator.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/Simulator/IncrementalRedstoneSimulator.cpp b/src/Simulator/IncrementalRedstoneSimulator.cpp index 074063add..8d29fbec7 100644 --- a/src/Simulator/IncrementalRedstoneSimulator.cpp +++ b/src/Simulator/IncrementalRedstoneSimulator.cpp @@ -18,7 +18,13 @@ cIncrementalRedstoneSimulator::cIncrementalRedstoneSimulator(cWorld & a_World) - : super(a_World) + : super(a_World), + m_RedstoneSimulatorChunkData(), + m_PoweredBlocks(), + m_LinkedPoweredBlocks(), + m_SimulatedPlayerToggleableBlocks(), + m_RepeatersDelayList(), + m_Chunk() { } -- cgit v1.2.3 From 7e2effb2d8297ddb99d86844e1b06b37c6e30d63 Mon Sep 17 00:00:00 2001 From: Julian Laubstein Date: Mon, 19 May 2014 15:46:36 +0200 Subject: Changed the m_slotarea position --- src/UI/Window.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/UI/Window.cpp b/src/UI/Window.cpp index 24b718156..98a9a0cec 100644 --- a/src/UI/Window.cpp +++ b/src/UI/Window.cpp @@ -854,10 +854,10 @@ void cAnvilWindow::GetBlockPos(int & a_PosX, int & a_PosY, int & a_PosZ) cEnchantingWindow::cEnchantingWindow(int a_BlockX, int a_BlockY, int a_BlockZ) : cWindow(wtEnchantment, "Enchant"), + m_SlotArea(), m_BlockX(a_BlockX), m_BlockY(a_BlockY), - m_BlockZ(a_BlockZ), - m_SlotArea() + m_BlockZ(a_BlockZ) { m_SlotAreas.push_back(new cSlotAreaEnchanting(*this)); m_SlotAreas.push_back(new cSlotAreaInventory(*this)); -- cgit v1.2.3 From b4ba2209342d536e83b3461db00e9f9fd811120e Mon Sep 17 00:00:00 2001 From: Howaner Date: Thu, 29 May 2014 19:21:56 +0200 Subject: Add SetOpen() and IsOpen() to BlockDoor.h and fix door redstone bug. --- src/Blocks/BlockDoor.h | 89 +++++++++++++++++++++++--- src/Simulator/IncrementalRedstoneSimulator.cpp | 14 ++-- 2 files changed, 90 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/Blocks/BlockDoor.h b/src/Blocks/BlockDoor.h index 797fe484c..b5bfe4082 100644 --- a/src/Blocks/BlockDoor.h +++ b/src/Blocks/BlockDoor.h @@ -20,12 +20,12 @@ public: virtual void OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override; virtual void OnCancelRightClick(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace) override; virtual const char * GetStepSound(void) override; - + virtual NIBBLETYPE MetaRotateCCW(NIBBLETYPE a_Meta) override; virtual NIBBLETYPE MetaRotateCW(NIBBLETYPE a_Meta) override; virtual NIBBLETYPE MetaMirrorXY(NIBBLETYPE a_Meta) override; virtual NIBBLETYPE MetaMirrorYZ(NIBBLETYPE a_Meta) override; - + virtual bool GetPlacementBlockTypeMeta( cChunkInterface & a_ChunkInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, @@ -52,7 +52,7 @@ public: return true; } - + virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override { a_Pickups.push_back(cItem((m_BlockType == E_BLOCK_WOODEN_DOOR) ? E_ITEM_WOODEN_DOOR : E_ITEM_IRON_DOOR, 1, 0)); @@ -77,8 +77,8 @@ public: { return ((a_RelY > 0) && (a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ) != E_BLOCK_AIR)); } - - + + bool CanReplaceBlock(BLOCKTYPE a_BlockType) { switch (a_BlockType) @@ -99,7 +99,7 @@ public: } - /// Converts the player's yaw to placed door's blockmeta + /** Converts the player's yaw to placed door's blockmeta */ inline static NIBBLETYPE PlayerYawToMetaData(double a_Yaw) { ASSERT((a_Yaw >= -180) && (a_Yaw < 180)); @@ -128,21 +128,92 @@ public: } - /// Returns true if the specified blocktype is any kind of door + /** Returns true if the specified blocktype is any kind of door */ inline static bool IsDoor(BLOCKTYPE a_Block) { return (a_Block == E_BLOCK_WOODEN_DOOR) || (a_Block == E_BLOCK_IRON_DOOR); } - /// Returns the metadata for the opposite door state (open vs closed) + /** Returns the metadata for the opposite door state (open vs closed) */ static NIBBLETYPE ChangeStateMetaData(NIBBLETYPE a_MetaData) { return a_MetaData ^ 4; } - /// Changes the door at the specified coords from open to close or vice versa + static bool IsOpen(cChunkInterface & a_ChunkInterface, int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ) + { + BLOCKTYPE Block; + NIBBLETYPE Meta; + a_ChunkInterface.GetBlockTypeMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ, Block, Meta); + + if (!IsDoor(Block)) + { + return false; + } + + return ((Meta & 0x4) == 4); + } + + + static void SetOpen(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ, bool a_Open) + { + BLOCKTYPE Block; + NIBBLETYPE Meta; + a_ChunkInterface.GetBlockTypeMeta(a_BlockX, a_BlockY, a_BlockZ, Block, Meta); + + if (!IsDoor(Block) || ((Meta & 0x4) == a_Open)) + { + return; + } + + // Change the door + if (a_Open) + { + a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, Meta | 0x4); + } + else + { + a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, Meta & 0xFFFFFFFB); + } + + int OtherPartY = a_BlockY; + if (Meta & 0x8) + { + // Current block is top of the door + a_ChunkInterface.GetBlockTypeMeta(a_BlockX, a_BlockY - 1, a_BlockZ, Block, Meta); + if (IsDoor(Block) && !(Meta & 0x8)) + { + OtherPartY--; + } + } + else + { + // Current block is bottom of the door + a_ChunkInterface.GetBlockTypeMeta(a_BlockX, a_BlockY + 1, a_BlockZ, Block, Meta); + if (IsDoor(Block) && (Meta & 0x8)) + { + OtherPartY++; + } + } + + // Change the other door part + if (a_BlockY != OtherPartY) + { + if (a_Open) + { + a_ChunkInterface.SetBlockMeta(a_BlockX, OtherPartY, a_BlockZ, Meta | 0x4); + } + else + { + a_ChunkInterface.SetBlockMeta(a_BlockX, OtherPartY, a_BlockZ, Meta & 0xFFFFFFFB); + } + } + } + + + /** Changes the door at the specified coords from open to close or vice versa */ static void ChangeDoor(cChunkInterface & a_ChunkInterface, int a_X, int a_Y, int a_Z) { NIBBLETYPE OldMetaData = a_ChunkInterface.GetBlockMeta(a_X, a_Y, a_Z); diff --git a/src/Simulator/IncrementalRedstoneSimulator.cpp b/src/Simulator/IncrementalRedstoneSimulator.cpp index 074063add..d49142e4f 100644 --- a/src/Simulator/IncrementalRedstoneSimulator.cpp +++ b/src/Simulator/IncrementalRedstoneSimulator.cpp @@ -906,8 +906,11 @@ void cIncrementalRedstoneSimulator::HandleDoor(int a_RelBlockX, int a_RelBlockY, if (!AreCoordsSimulated(a_RelBlockX, a_RelBlockY, a_RelBlockZ, true)) { cChunkInterface ChunkInterface(m_World.GetChunkMap()); - cBlockDoorHandler::ChangeDoor(ChunkInterface, a_RelBlockX, a_RelBlockY, a_RelBlockZ); - m_Chunk->BroadcastSoundParticleEffect(1003, BlockX, a_RelBlockY, BlockZ, 0); + if (!cBlockDoorHandler::IsOpen(ChunkInterface, BlockX, a_RelBlockY, BlockZ)) + { + cBlockDoorHandler::SetOpen(ChunkInterface, BlockX, a_RelBlockY, BlockZ, true); + m_Chunk->BroadcastSoundParticleEffect(1003, BlockX, a_RelBlockY, BlockZ, 0); + } SetPlayerToggleableBlockAsSimulated(a_RelBlockX, a_RelBlockY, a_RelBlockZ, true); } } @@ -916,8 +919,11 @@ void cIncrementalRedstoneSimulator::HandleDoor(int a_RelBlockX, int a_RelBlockY, if (!AreCoordsSimulated(a_RelBlockX, a_RelBlockY, a_RelBlockZ, false)) { cChunkInterface ChunkInterface(m_World.GetChunkMap()); - cBlockDoorHandler::ChangeDoor(ChunkInterface, a_RelBlockX, a_RelBlockY, a_RelBlockZ); - m_Chunk->BroadcastSoundParticleEffect(1003, BlockX, a_RelBlockY, BlockZ, 0); + if (cBlockDoorHandler::IsOpen(ChunkInterface, BlockX, a_RelBlockY, BlockZ)) + { + cBlockDoorHandler::SetOpen(ChunkInterface, BlockX, a_RelBlockY, BlockZ, false); + m_Chunk->BroadcastSoundParticleEffect(1003, BlockX, a_RelBlockY, BlockZ, 0); + } SetPlayerToggleableBlockAsSimulated(a_RelBlockX, a_RelBlockY, a_RelBlockZ, false); } } -- cgit v1.2.3 From d8e16f8c1fa771f77ef7505b45b9114b1f75aa61 Mon Sep 17 00:00:00 2001 From: Howaner Date: Fri, 30 May 2014 22:22:42 +0200 Subject: Better SetOpen() and IsOpen() function from the doors. --- src/Blocks/BlockDoor.cpp | 2 +- src/Blocks/BlockDoor.h | 102 ++++++++++++----------------------------------- 2 files changed, 27 insertions(+), 77 deletions(-) (limited to 'src') diff --git a/src/Blocks/BlockDoor.cpp b/src/Blocks/BlockDoor.cpp index 479c68153..fb2d6f2dc 100644 --- a/src/Blocks/BlockDoor.cpp +++ b/src/Blocks/BlockDoor.cpp @@ -62,7 +62,7 @@ void cBlockDoorHandler::OnCancelRightClick(cChunkInterface & a_ChunkInterface, c a_WorldInterface.SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, a_Player); NIBBLETYPE Meta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ); - if (Meta & 8) + if (Meta & 0x8) { // Current block is top of the door a_WorldInterface.SendBlockTo(a_BlockX, a_BlockY - 1, a_BlockZ, a_Player); diff --git a/src/Blocks/BlockDoor.h b/src/Blocks/BlockDoor.h index b5bfe4082..c1e4de9d4 100644 --- a/src/Blocks/BlockDoor.h +++ b/src/Blocks/BlockDoor.h @@ -135,113 +135,63 @@ public: } - /** Returns the metadata for the opposite door state (open vs closed) */ - static NIBBLETYPE ChangeStateMetaData(NIBBLETYPE a_MetaData) + static NIBBLETYPE IsOpen(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ) { - return a_MetaData ^ 4; + NIBBLETYPE Meta = GetMetaFromRightDoor(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ); + return ((Meta & 0x4) != 0); } - static bool IsOpen(cChunkInterface & a_ChunkInterface, int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ) + static NIBBLETYPE GetMetaFromRightDoor(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ) { - BLOCKTYPE Block; - NIBBLETYPE Meta; - a_ChunkInterface.GetBlockTypeMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ, Block, Meta); + NIBBLETYPE Meta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ); - if (!IsDoor(Block)) + if ((Meta & 0x8) != 0) { - return false; + NIBBLETYPE DownMeta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY - 1, a_BlockZ); + return (DownMeta & 0x7) | 0x8 | (((Meta & 0x1) != 0) ? 16 : 0); + } + else + { + NIBBLETYPE UpMeta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY + 1, a_BlockZ); + return (Meta & 0x7) | (((UpMeta & 0x1) != 0) ? 16 : 0); } - - return ((Meta & 0x4) == 4); } static void SetOpen(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ, bool a_Open) { - BLOCKTYPE Block; - NIBBLETYPE Meta; - a_ChunkInterface.GetBlockTypeMeta(a_BlockX, a_BlockY, a_BlockZ, Block, Meta); + BLOCKTYPE Block = a_ChunkInterface.GetBlock(a_BlockX, a_BlockY, a_BlockZ); + NIBBLETYPE Meta = GetMetaFromRightDoor(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ); - if (!IsDoor(Block) || ((Meta & 0x4) == a_Open)) + if (!IsDoor(Block)) { return; } - // Change the door - if (a_Open) + bool Opened = (Meta & 0x4) != 0; + if (Opened == a_Open) { - a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, Meta | 0x4); - } - else - { - a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, Meta & 0xFFFFFFFB); + return; } - int OtherPartY = a_BlockY; - if (Meta & 0x8) + // Change the door + NIBBLETYPE NewMeta = (Meta & 0x7) ^ 0x4; + if ((Meta & 0x8) == 0) { - // Current block is top of the door - a_ChunkInterface.GetBlockTypeMeta(a_BlockX, a_BlockY - 1, a_BlockZ, Block, Meta); - if (IsDoor(Block) && !(Meta & 0x8)) - { - OtherPartY--; - } + a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, NewMeta); } else { - // Current block is bottom of the door - a_ChunkInterface.GetBlockTypeMeta(a_BlockX, a_BlockY + 1, a_BlockZ, Block, Meta); - if (IsDoor(Block) && (Meta & 0x8)) - { - OtherPartY++; - } - } - - // Change the other door part - if (a_BlockY != OtherPartY) - { - if (a_Open) - { - a_ChunkInterface.SetBlockMeta(a_BlockX, OtherPartY, a_BlockZ, Meta | 0x4); - } - else - { - a_ChunkInterface.SetBlockMeta(a_BlockX, OtherPartY, a_BlockZ, Meta & 0xFFFFFFFB); - } + a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY - 1, a_BlockZ, NewMeta); } } /** Changes the door at the specified coords from open to close or vice versa */ - static void ChangeDoor(cChunkInterface & a_ChunkInterface, int a_X, int a_Y, int a_Z) + static void ChangeDoor(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ) { - NIBBLETYPE OldMetaData = a_ChunkInterface.GetBlockMeta(a_X, a_Y, a_Z); - - a_ChunkInterface.SetBlockMeta(a_X, a_Y, a_Z, ChangeStateMetaData(OldMetaData)); - - if (OldMetaData & 8) - { - // Current block is top of the door - BLOCKTYPE BottomBlock = a_ChunkInterface.GetBlock(a_X, a_Y - 1, a_Z); - NIBBLETYPE BottomMeta = a_ChunkInterface.GetBlockMeta(a_X, a_Y - 1, a_Z); - - if (IsDoor(BottomBlock) && !(BottomMeta & 8)) - { - a_ChunkInterface.SetBlockMeta(a_X, a_Y - 1, a_Z, ChangeStateMetaData(BottomMeta)); - } - } - else - { - // Current block is bottom of the door - BLOCKTYPE TopBlock = a_ChunkInterface.GetBlock(a_X, a_Y + 1, a_Z); - NIBBLETYPE TopMeta = a_ChunkInterface.GetBlockMeta(a_X, a_Y + 1, a_Z); - - if (IsDoor(TopBlock) && (TopMeta & 8)) - { - a_ChunkInterface.SetBlockMeta(a_X, a_Y + 1, a_Z, ChangeStateMetaData(TopMeta)); - } - } + SetOpen(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, !IsOpen(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ)); } } ; -- cgit v1.2.3 From 0b7ed0f4934b75f959d13ce7b8a4c73cb88ce318 Mon Sep 17 00:00:00 2001 From: Howaner Date: Sat, 31 May 2014 11:47:03 +0200 Subject: Add doxy-comment --- src/Blocks/BlockDoor.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/Blocks/BlockDoor.h b/src/Blocks/BlockDoor.h index c1e4de9d4..d8ce916fa 100644 --- a/src/Blocks/BlockDoor.h +++ b/src/Blocks/BlockDoor.h @@ -137,12 +137,13 @@ public: static NIBBLETYPE IsOpen(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ) { - NIBBLETYPE Meta = GetMetaFromRightDoor(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ); + NIBBLETYPE Meta = GetTrueDoorMeta(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ); return ((Meta & 0x4) != 0); } - static NIBBLETYPE GetMetaFromRightDoor(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ) + /** Read the meta from the true part of the door and returns a meta with all infos include. */ + static NIBBLETYPE GetTrueDoorMeta(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ) { NIBBLETYPE Meta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ); @@ -162,7 +163,7 @@ public: static void SetOpen(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ, bool a_Open) { BLOCKTYPE Block = a_ChunkInterface.GetBlock(a_BlockX, a_BlockY, a_BlockZ); - NIBBLETYPE Meta = GetMetaFromRightDoor(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ); + NIBBLETYPE Meta = GetTrueDoorMeta(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ); if (!IsDoor(Block)) { -- cgit v1.2.3 From 683da71c0fa33c2542e28bed5d2f106ddfc68b64 Mon Sep 17 00:00:00 2001 From: Howaner Date: Sat, 31 May 2014 11:48:54 +0200 Subject: Moved the IsDoor check before the meta get. --- src/Blocks/BlockDoor.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src') diff --git a/src/Blocks/BlockDoor.h b/src/Blocks/BlockDoor.h index d8ce916fa..eaa039c50 100644 --- a/src/Blocks/BlockDoor.h +++ b/src/Blocks/BlockDoor.h @@ -163,13 +163,12 @@ public: static void SetOpen(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ, bool a_Open) { BLOCKTYPE Block = a_ChunkInterface.GetBlock(a_BlockX, a_BlockY, a_BlockZ); - NIBBLETYPE Meta = GetTrueDoorMeta(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ); - if (!IsDoor(Block)) { return; } + NIBBLETYPE Meta = GetTrueDoorMeta(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ); bool Opened = (Meta & 0x4) != 0; if (Opened == a_Open) { -- cgit v1.2.3 From 8604dedfdf4e9522fa99e6280e09180523ecce09 Mon Sep 17 00:00:00 2001 From: Julian Laubstein Date: Wed, 4 Jun 2014 10:20:20 +0200 Subject: Update IncrementalRedstoneSimulator.cpp --- src/Simulator/IncrementalRedstoneSimulator.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/Simulator/IncrementalRedstoneSimulator.cpp b/src/Simulator/IncrementalRedstoneSimulator.cpp index 8d29fbec7..a89c017df 100644 --- a/src/Simulator/IncrementalRedstoneSimulator.cpp +++ b/src/Simulator/IncrementalRedstoneSimulator.cpp @@ -17,14 +17,14 @@ -cIncrementalRedstoneSimulator::cIncrementalRedstoneSimulator(cWorld & a_World) - : super(a_World), - m_RedstoneSimulatorChunkData(), - m_PoweredBlocks(), - m_LinkedPoweredBlocks(), - m_SimulatedPlayerToggleableBlocks(), - m_RepeatersDelayList(), - m_Chunk() +cIncrementalRedstoneSimulator::cIncrementalRedstoneSimulator(cWorld & a_World) : + super(a_World), + m_RedstoneSimulatorChunkData(), + m_PoweredBlocks(), + m_LinkedPoweredBlocks(), + m_SimulatedPlayerToggleableBlocks(), + m_RepeatersDelayList(), + m_Chunk() { } -- cgit v1.2.3 From 33fbdedea3b9d48f2bec329b93d86024befbb6ab Mon Sep 17 00:00:00 2001 From: Howaner Date: Wed, 4 Jun 2014 15:16:30 +0200 Subject: Fix itemframe break. --- src/Entities/ItemFrame.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/Entities/ItemFrame.cpp b/src/Entities/ItemFrame.cpp index 9dd909880..7bc7bda8d 100644 --- a/src/Entities/ItemFrame.cpp +++ b/src/Entities/ItemFrame.cpp @@ -55,6 +55,7 @@ void cItemFrame::KilledBy(cEntity * a_Killer) { if (m_Item.IsEmpty()) { + SetHealth(0); super::KilledBy(a_Killer); Destroy(); return; @@ -69,8 +70,9 @@ void cItemFrame::KilledBy(cEntity * a_Killer) } SetHealth(GetMaxHealth()); - m_Item.Clear(); + m_Item.Empty(); m_Rotation = 0; + SetInvulnerableTicks(0); GetWorld()->BroadcastEntityMetadata(*this); } -- cgit v1.2.3 From 22236a103ac506b27236469f353f6ec24bd5f9c6 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Wed, 4 Jun 2014 23:23:09 +0100 Subject: Redstone fixes and improvements [SEE DESC] Haha, see desc. * Improved redstone speed through a marking dirty system. Only a select few devices are still continuously simulated * Fixed redstone crashing with recent piston changes --- src/Chunk.cpp | 1 + src/Chunk.h | 9 +- src/Simulator/IncrementalRedstoneSimulator.cpp | 147 +++++++++++++++---------- 3 files changed, 96 insertions(+), 61 deletions(-) (limited to 'src') diff --git a/src/Chunk.cpp b/src/Chunk.cpp index 1aaf076df..44fcefbe1 100644 --- a/src/Chunk.cpp +++ b/src/Chunk.cpp @@ -1514,6 +1514,7 @@ void cChunk::FastSetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockT } MarkDirty(); + m_IsRedstoneDirty = true; m_ChunkData.SetBlock(a_RelX, a_RelY, a_RelZ, a_BlockType); diff --git a/src/Chunk.h b/src/Chunk.h index e92a5bc29..dfdabea04 100644 --- a/src/Chunk.h +++ b/src/Chunk.h @@ -332,6 +332,7 @@ public: if (hasChanged) { MarkDirty(); + m_IsRedstoneDirty = true; m_PendingSendBlocks.push_back(sSetBlock(m_PosX, m_PosZ, a_RelX, a_RelY, a_RelZ, GetBlock(a_RelX, a_RelY, a_RelZ), a_Meta)); } @@ -378,10 +379,13 @@ public: cSandSimulatorChunkData & GetSandSimulatorData (void) { return m_SandSimulatorData; } cRedstoneSimulatorChunkData * GetRedstoneSimulatorData(void) { return &m_RedstoneSimulatorData; } + cRedstoneSimulatorChunkData * GetRedstoneSimulatorQueuedData(void) { return &m_RedstoneSimulatorQueuedData; } cIncrementalRedstoneSimulator::PoweredBlocksList * GetRedstoneSimulatorPoweredBlocksList(void) { return &m_RedstoneSimulatorPoweredBlocksList; } cIncrementalRedstoneSimulator::LinkedBlocksList * GetRedstoneSimulatorLinkedBlocksList(void) { return &m_RedstoneSimulatorLinkedBlocksList; }; cIncrementalRedstoneSimulator::SimulatedPlayerToggleableList * GetRedstoneSimulatorSimulatedPlayerToggleableList(void) { return &m_RedstoneSimulatorSimulatedPlayerToggleableList; }; cIncrementalRedstoneSimulator::RepeatersDelayList * GetRedstoneSimulatorRepeatersDelayList(void) { return &m_RedstoneSimulatorRepeatersDelayList; }; + bool IsRedstoneDirty(void) const { return m_IsRedstoneDirty; } + void SetIsRedstoneDirty(bool a_Flag) { m_IsRedstoneDirty = a_Flag; } cBlockEntity * GetBlockEntity(int a_BlockX, int a_BlockY, int a_BlockZ); cBlockEntity * GetBlockEntity(const Vector3i & a_BlockPos) { return GetBlockEntity(a_BlockPos.x, a_BlockPos.y, a_BlockPos.z); } @@ -449,13 +453,16 @@ private: cSandSimulatorChunkData m_SandSimulatorData; cRedstoneSimulatorChunkData m_RedstoneSimulatorData; + cRedstoneSimulatorChunkData m_RedstoneSimulatorQueuedData; cIncrementalRedstoneSimulator::PoweredBlocksList m_RedstoneSimulatorPoweredBlocksList; cIncrementalRedstoneSimulator::LinkedBlocksList m_RedstoneSimulatorLinkedBlocksList; cIncrementalRedstoneSimulator::SimulatedPlayerToggleableList m_RedstoneSimulatorSimulatedPlayerToggleableList; cIncrementalRedstoneSimulator::RepeatersDelayList m_RedstoneSimulatorRepeatersDelayList; + /** Indicates if simulate-once blocks should be updated by the redstone simulator */ + bool m_IsRedstoneDirty; - // pick up a random block of this chunk + // Pick up a random block of this chunk void getRandomBlockCoords(int& a_X, int& a_Y, int& a_Z); void getThreeRandomNumber(int& a_X, int& a_Y, int& a_Z,int a_MaxX, int a_MaxY, int a_MaxZ); diff --git a/src/Simulator/IncrementalRedstoneSimulator.cpp b/src/Simulator/IncrementalRedstoneSimulator.cpp index f4355b33b..fb8a3e81d 100644 --- a/src/Simulator/IncrementalRedstoneSimulator.cpp +++ b/src/Simulator/IncrementalRedstoneSimulator.cpp @@ -89,6 +89,7 @@ void cIncrementalRedstoneSimulator::RedstoneAddBlock(int a_BlockX, int a_BlockY, { LOGD("cIncrementalRedstoneSimulator: Erased block @ {%i, %i, %i} from powered blocks list as it no longer connected to a source", itr->a_BlockPos.x, itr->a_BlockPos.y, itr->a_BlockPos.z); itr = PoweredBlocks->erase(itr); + a_Chunk->SetIsRedstoneDirty(true); continue; } else if ( @@ -103,6 +104,7 @@ void cIncrementalRedstoneSimulator::RedstoneAddBlock(int a_BlockX, int a_BlockY, { LOGD("cIncrementalRedstoneSimulator: Erased block @ {%i, %i, %i} from powered blocks list due to present/past metadata mismatch", itr->a_BlockPos.x, itr->a_BlockPos.y, itr->a_BlockPos.z); itr = PoweredBlocks->erase(itr); + a_Chunk->SetIsRedstoneDirty(true); continue; } ++itr; @@ -118,6 +120,7 @@ void cIncrementalRedstoneSimulator::RedstoneAddBlock(int a_BlockX, int a_BlockY, { LOGD("cIncrementalRedstoneSimulator: Erased block @ {%i, %i, %i} from linked powered blocks list as it is no longer connected to a source", itr->a_BlockPos.x, itr->a_BlockPos.y, itr->a_BlockPos.z); itr = LinkedPoweredBlocks->erase(itr); + a_Chunk->SetIsRedstoneDirty(true); continue; } else if ( @@ -131,6 +134,7 @@ void cIncrementalRedstoneSimulator::RedstoneAddBlock(int a_BlockX, int a_BlockY, { LOGD("cIncrementalRedstoneSimulator: Erased block @ {%i, %i, %i} from linked powered blocks list due to present/past metadata mismatch", itr->a_BlockPos.x, itr->a_BlockPos.y, itr->a_BlockPos.z); itr = LinkedPoweredBlocks->erase(itr); + a_Chunk->SetIsRedstoneDirty(true); continue; } } @@ -140,6 +144,7 @@ void cIncrementalRedstoneSimulator::RedstoneAddBlock(int a_BlockX, int a_BlockY, { LOGD("cIncrementalRedstoneSimulator: Erased block @ {%i, %i, %i} from linked powered blocks list as it is no longer powered through a valid middle block", itr->a_BlockPos.x, itr->a_BlockPos.y, itr->a_BlockPos.z); itr = LinkedPoweredBlocks->erase(itr); + a_Chunk->SetIsRedstoneDirty(true); continue; } } @@ -205,7 +210,7 @@ void cIncrementalRedstoneSimulator::RedstoneAddBlock(int a_BlockX, int a_BlockY, return; } - RedstoneSimulatorChunkData->push_back(cCoordWithBlockAndBool(RelX, a_BlockY, RelZ, Block, false)); + a_Chunk->GetRedstoneSimulatorQueuedData()->push_back(cCoordWithBlockAndBool(RelX, a_BlockY, RelZ, Block, false)); } @@ -214,22 +219,29 @@ void cIncrementalRedstoneSimulator::RedstoneAddBlock(int a_BlockX, int a_BlockY, void cIncrementalRedstoneSimulator::SimulateChunk(float a_Dt, int a_ChunkX, int a_ChunkZ, cChunk * a_Chunk) { - // We still attempt to simulate all blocks in the chunk every tick, because of outside influence that needs to be taken into account - // For example, repeaters need to be ticked, pressure plates checked for entities, daylight sensor checked for light changes, etc. - // The easiest way to make this more efficient is probably just to reduce code within the handlers that put too much strain on server, like getting or setting blocks - // A marking dirty system might be a TODO for later on, perhaps - m_RedstoneSimulatorChunkData = a_Chunk->GetRedstoneSimulatorData(); - if (m_RedstoneSimulatorChunkData->empty()) + if (m_RedstoneSimulatorChunkData->empty() && a_Chunk->GetRedstoneSimulatorQueuedData()->empty()) { return; } + m_RedstoneSimulatorChunkData->insert(m_RedstoneSimulatorChunkData->end(), a_Chunk->GetRedstoneSimulatorQueuedData()->begin(), a_Chunk->GetRedstoneSimulatorQueuedData()->end()); + a_Chunk->GetRedstoneSimulatorQueuedData()->clear(); + m_PoweredBlocks = a_Chunk->GetRedstoneSimulatorPoweredBlocksList(); m_RepeatersDelayList = a_Chunk->GetRedstoneSimulatorRepeatersDelayList(); m_SimulatedPlayerToggleableBlocks = a_Chunk->GetRedstoneSimulatorSimulatedPlayerToggleableList(); m_LinkedPoweredBlocks = a_Chunk->GetRedstoneSimulatorLinkedBlocksList(); m_Chunk = a_Chunk; + bool ShouldUpdateSimulateOnceBlocks = false; + + if (a_Chunk->IsRedstoneDirty()) + { + // Simulate the majority of devices only if something (blockwise or power-wise) has changed + // Make sure to allow the chunk to resimulate after the initial run if there was a power change (ShouldUpdateSimulateOnceBlocks helps to do this) + a_Chunk->SetIsRedstoneDirty(false); // + ShouldUpdateSimulateOnceBlocks = true; + } for (cRedstoneSimulatorChunkData::iterator dataitr = m_RedstoneSimulatorChunkData->begin(); dataitr != m_RedstoneSimulatorChunkData->end();) { @@ -241,65 +253,15 @@ void cIncrementalRedstoneSimulator::SimulateChunk(float a_Dt, int a_ChunkX, int switch (dataitr->Data) { - case E_BLOCK_BLOCK_OF_REDSTONE: HandleRedstoneBlock(dataitr->x, dataitr->y, dataitr->z); break; - case E_BLOCK_LEVER: HandleRedstoneLever(dataitr->x, dataitr->y, dataitr->z); break; - case E_BLOCK_FENCE_GATE: HandleFenceGate(dataitr->x, dataitr->y, dataitr->z); break; - case E_BLOCK_TNT: HandleTNT(dataitr->x, dataitr->y, dataitr->z); break; - case E_BLOCK_TRAPDOOR: HandleTrapdoor(dataitr->x, dataitr->y, dataitr->z); break; case E_BLOCK_REDSTONE_WIRE: HandleRedstoneWire(dataitr->x, dataitr->y, dataitr->z); break; - case E_BLOCK_NOTE_BLOCK: HandleNoteBlock(dataitr->x, dataitr->y, dataitr->z); break; case E_BLOCK_DAYLIGHT_SENSOR: HandleDaylightSensor(dataitr->x, dataitr->y, dataitr->z); break; - case E_BLOCK_COMMAND_BLOCK: HandleCommandBlock(dataitr->x, dataitr->y, dataitr->z); break; - case E_BLOCK_REDSTONE_TORCH_OFF: - case E_BLOCK_REDSTONE_TORCH_ON: - { - HandleRedstoneTorch(dataitr->x, dataitr->y, dataitr->z, dataitr->Data); - break; - } - case E_BLOCK_STONE_BUTTON: - case E_BLOCK_WOODEN_BUTTON: - { - HandleRedstoneButton(dataitr->x, dataitr->y, dataitr->z); - break; - } case E_BLOCK_REDSTONE_REPEATER_OFF: case E_BLOCK_REDSTONE_REPEATER_ON: { HandleRedstoneRepeater(dataitr->x, dataitr->y, dataitr->z, dataitr->Data); break; } - case E_BLOCK_PISTON: - case E_BLOCK_STICKY_PISTON: - { - HandlePiston(dataitr->x, dataitr->y, dataitr->z); - break; - } - case E_BLOCK_REDSTONE_LAMP_OFF: - case E_BLOCK_REDSTONE_LAMP_ON: - { - HandleRedstoneLamp(dataitr->x, dataitr->y, dataitr->z, dataitr->Data); - break; - } - case E_BLOCK_DISPENSER: - case E_BLOCK_DROPPER: - { - HandleDropSpenser(dataitr->x, dataitr->y, dataitr->z); - break; - } - case E_BLOCK_WOODEN_DOOR: - case E_BLOCK_IRON_DOOR: - { - HandleDoor(dataitr->x, dataitr->y, dataitr->z); - break; - } - case E_BLOCK_ACTIVATOR_RAIL: - case E_BLOCK_DETECTOR_RAIL: - case E_BLOCK_POWERED_RAIL: - { - HandleRail(dataitr->x, dataitr->y, dataitr->z, dataitr->Data); - break; - } case E_BLOCK_WOODEN_PRESSURE_PLATE: case E_BLOCK_STONE_PRESSURE_PLATE: case E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE: @@ -308,7 +270,66 @@ void cIncrementalRedstoneSimulator::SimulateChunk(float a_Dt, int a_ChunkX, int HandlePressurePlate(dataitr->x, dataitr->y, dataitr->z, dataitr->Data); break; } - default: LOGD("Unhandled block (!) or unimplemented redstone block: %s", ItemToString(dataitr->Data).c_str()); break; + default: break; + } + + if (ShouldUpdateSimulateOnceBlocks) + { + switch (dataitr->Data) + { + case E_BLOCK_COMMAND_BLOCK: HandleCommandBlock(dataitr->x, dataitr->y, dataitr->z); break; + case E_BLOCK_NOTE_BLOCK: HandleNoteBlock(dataitr->x, dataitr->y, dataitr->z); break; + case E_BLOCK_BLOCK_OF_REDSTONE: HandleRedstoneBlock(dataitr->x, dataitr->y, dataitr->z); break; + case E_BLOCK_LEVER: HandleRedstoneLever(dataitr->x, dataitr->y, dataitr->z); break; + case E_BLOCK_FENCE_GATE: HandleFenceGate(dataitr->x, dataitr->y, dataitr->z); break; + case E_BLOCK_TNT: HandleTNT(dataitr->x, dataitr->y, dataitr->z); break; + case E_BLOCK_TRAPDOOR: HandleTrapdoor(dataitr->x, dataitr->y, dataitr->z); break; + + case E_BLOCK_ACTIVATOR_RAIL: + case E_BLOCK_DETECTOR_RAIL: + case E_BLOCK_POWERED_RAIL: + { + HandleRail(dataitr->x, dataitr->y, dataitr->z, dataitr->Data); + break; + } + case E_BLOCK_WOODEN_DOOR: + case E_BLOCK_IRON_DOOR: + { + HandleDoor(dataitr->x, dataitr->y, dataitr->z); + break; + } + case E_BLOCK_REDSTONE_LAMP_OFF: + case E_BLOCK_REDSTONE_LAMP_ON: + { + HandleRedstoneLamp(dataitr->x, dataitr->y, dataitr->z, dataitr->Data); + break; + } + case E_BLOCK_DISPENSER: + case E_BLOCK_DROPPER: + { + HandleDropSpenser(dataitr->x, dataitr->y, dataitr->z); + break; + } + case E_BLOCK_PISTON: + case E_BLOCK_STICKY_PISTON: + { + HandlePiston(dataitr->x, dataitr->y, dataitr->z); + break; + } + case E_BLOCK_REDSTONE_TORCH_OFF: + case E_BLOCK_REDSTONE_TORCH_ON: + { + HandleRedstoneTorch(dataitr->x, dataitr->y, dataitr->z, dataitr->Data); + break; + } + case E_BLOCK_STONE_BUTTON: + case E_BLOCK_WOODEN_BUTTON: + { + HandleRedstoneButton(dataitr->x, dataitr->y, dataitr->z); + break; + } + default: break; + } } ++dataitr; } @@ -1736,7 +1757,8 @@ void cIncrementalRedstoneSimulator::SetBlockPowered(int a_RelBlockX, int a_RelBl return; } - PoweredBlocksList * Powered = m_Chunk->GetNeighborChunk(BlockX, BlockZ)->GetRedstoneSimulatorPoweredBlocksList(); + cChunk * Neighbour = m_Chunk->GetNeighborChunk(BlockX, BlockZ); + PoweredBlocksList * Powered = Neighbour->GetRedstoneSimulatorPoweredBlocksList(); for (PoweredBlocksList::iterator itr = Powered->begin(); itr != Powered->end(); ++itr) // Check powered list { if ( @@ -1768,6 +1790,8 @@ void cIncrementalRedstoneSimulator::SetBlockPowered(int a_RelBlockX, int a_RelBl RC.a_SourcePos = Vector3i(SourceX, a_RelSourceY, SourceZ); RC.a_PowerLevel = a_PowerLevel; Powered->push_back(RC); + Neighbour->SetIsRedstoneDirty(true); + m_Chunk->SetIsRedstoneDirty(true); } @@ -1807,7 +1831,8 @@ void cIncrementalRedstoneSimulator::SetBlockLinkedPowered( return; } - LinkedBlocksList * Linked = m_Chunk->GetNeighborChunk(BlockX, BlockZ)->GetRedstoneSimulatorLinkedBlocksList(); + cChunk * Neighbour = m_Chunk->GetNeighborChunk(BlockX, BlockZ); + LinkedBlocksList * Linked = Neighbour->GetRedstoneSimulatorLinkedBlocksList(); for (LinkedBlocksList::iterator itr = Linked->begin(); itr != Linked->end(); ++itr) // Check linked powered list { if ( @@ -1828,6 +1853,8 @@ void cIncrementalRedstoneSimulator::SetBlockLinkedPowered( RC.a_SourcePos = Vector3i(SourceX, a_RelSourceY, SourceZ); RC.a_PowerLevel = a_PowerLevel; Linked->push_back(RC); + Neighbour->SetIsRedstoneDirty(true); + m_Chunk->SetIsRedstoneDirty(true); } -- cgit v1.2.3 From 5f56773dde8d06a291f42def9302ad932c490a28 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Fri, 6 Jun 2014 20:36:50 +0100 Subject: Further reduced redstone idle CPU consumption * Repeaters and wires are no longer unnecessarily ticked * Fixed #1063, likely addressed #1062 * Fixed bugs regarding duplicate values --- src/Simulator/IncrementalRedstoneSimulator.cpp | 34 ++++++++++++++++++++------ 1 file changed, 27 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/Simulator/IncrementalRedstoneSimulator.cpp b/src/Simulator/IncrementalRedstoneSimulator.cpp index fb8a3e81d..21326c7c4 100644 --- a/src/Simulator/IncrementalRedstoneSimulator.cpp +++ b/src/Simulator/IncrementalRedstoneSimulator.cpp @@ -209,7 +209,15 @@ void cIncrementalRedstoneSimulator::RedstoneAddBlock(int a_BlockX, int a_BlockY, { return; } - + + for (cRedstoneSimulatorChunkData::iterator itr = a_Chunk->GetRedstoneSimulatorQueuedData()->begin(); itr != a_Chunk->GetRedstoneSimulatorQueuedData()->end(); ++itr) + { + if ((itr->x == RelX) && (itr->y == a_BlockY) && (itr->z == RelZ)) + { + // Can't have duplicates in here either, in case something adds the block again before the structure can written to the main chunk data + return; + } + } a_Chunk->GetRedstoneSimulatorQueuedData()->push_back(cCoordWithBlockAndBool(RelX, a_BlockY, RelZ, Block, false)); } @@ -239,7 +247,7 @@ void cIncrementalRedstoneSimulator::SimulateChunk(float a_Dt, int a_ChunkX, int { // Simulate the majority of devices only if something (blockwise or power-wise) has changed // Make sure to allow the chunk to resimulate after the initial run if there was a power change (ShouldUpdateSimulateOnceBlocks helps to do this) - a_Chunk->SetIsRedstoneDirty(false); // + a_Chunk->SetIsRedstoneDirty(false); ShouldUpdateSimulateOnceBlocks = true; } @@ -253,13 +261,24 @@ void cIncrementalRedstoneSimulator::SimulateChunk(float a_Dt, int a_ChunkX, int switch (dataitr->Data) { - case E_BLOCK_REDSTONE_WIRE: HandleRedstoneWire(dataitr->x, dataitr->y, dataitr->z); break; - case E_BLOCK_DAYLIGHT_SENSOR: HandleDaylightSensor(dataitr->x, dataitr->y, dataitr->z); break; + case E_BLOCK_DAYLIGHT_SENSOR: HandleDaylightSensor(dataitr->x, dataitr->y, dataitr->z); break; case E_BLOCK_REDSTONE_REPEATER_OFF: case E_BLOCK_REDSTONE_REPEATER_ON: { - HandleRedstoneRepeater(dataitr->x, dataitr->y, dataitr->z, dataitr->Data); + if (ShouldUpdateSimulateOnceBlocks) + { + HandleRedstoneRepeater(dataitr->x, dataitr->y, dataitr->z, dataitr->Data); + break; + } + for (RepeatersDelayList::const_iterator repeateritr = m_RepeatersDelayList->begin(); repeateritr != m_RepeatersDelayList->end(); ++repeateritr) + { + if (repeateritr->a_RelBlockPos == Vector3i(dataitr->x, dataitr->y, dataitr->z)) + { + HandleRedstoneRepeater(dataitr->x, dataitr->y, dataitr->z, dataitr->Data); + break; + } + } break; } case E_BLOCK_WOODEN_PRESSURE_PLATE: @@ -277,10 +296,11 @@ void cIncrementalRedstoneSimulator::SimulateChunk(float a_Dt, int a_ChunkX, int { switch (dataitr->Data) { + case E_BLOCK_REDSTONE_WIRE: HandleRedstoneWire(dataitr->x, dataitr->y, dataitr->z); break; case E_BLOCK_COMMAND_BLOCK: HandleCommandBlock(dataitr->x, dataitr->y, dataitr->z); break; case E_BLOCK_NOTE_BLOCK: HandleNoteBlock(dataitr->x, dataitr->y, dataitr->z); break; - case E_BLOCK_BLOCK_OF_REDSTONE: HandleRedstoneBlock(dataitr->x, dataitr->y, dataitr->z); break; - case E_BLOCK_LEVER: HandleRedstoneLever(dataitr->x, dataitr->y, dataitr->z); break; + case E_BLOCK_BLOCK_OF_REDSTONE: HandleRedstoneBlock(dataitr->x, dataitr->y, dataitr->z); break; + case E_BLOCK_LEVER: HandleRedstoneLever(dataitr->x, dataitr->y, dataitr->z); break; case E_BLOCK_FENCE_GATE: HandleFenceGate(dataitr->x, dataitr->y, dataitr->z); break; case E_BLOCK_TNT: HandleTNT(dataitr->x, dataitr->y, dataitr->z); break; case E_BLOCK_TRAPDOOR: HandleTrapdoor(dataitr->x, dataitr->y, dataitr->z); break; -- cgit v1.2.3 From b768e54ce88819f3363b55879c0550b2830b3a56 Mon Sep 17 00:00:00 2001 From: archshift Date: Sat, 7 Jun 2014 00:40:01 -0700 Subject: Fixed mob hitbox sizes, removed TODOs Measured bat and blaze in vanilla, updated values. Cavespiders are, in fact, passive in the day. --- src/Mobs/Bat.cpp | 3 +-- src/Mobs/Blaze.cpp | 3 +-- src/Mobs/CaveSpider.cpp | 1 - 3 files changed, 2 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/Mobs/Bat.cpp b/src/Mobs/Bat.cpp index 1417ddd9e..c072d4f48 100644 --- a/src/Mobs/Bat.cpp +++ b/src/Mobs/Bat.cpp @@ -7,8 +7,7 @@ cBat::cBat(void) : - // TODO: The size is only a guesstimate, measure in vanilla and fix the size values here - super("Bat", mtBat, "mob.bat.hurt", "mob.bat.death", 0.7, 0.7) + super("Bat", mtBat, "mob.bat.hurt", "mob.bat.death", 0.5, 0.9) { } diff --git a/src/Mobs/Blaze.cpp b/src/Mobs/Blaze.cpp index 326b42f07..2a6a761bf 100644 --- a/src/Mobs/Blaze.cpp +++ b/src/Mobs/Blaze.cpp @@ -9,8 +9,7 @@ cBlaze::cBlaze(void) : - // TODO: The size is only a guesstimate, measure in vanilla and fix the size values here - super("Blaze", mtBlaze, "mob.blaze.hit", "mob.blaze.death", 0.7, 1.8) + super("Blaze", mtBlaze, "mob.blaze.hit", "mob.blaze.death", 0.6, 1.8) { } diff --git a/src/Mobs/CaveSpider.cpp b/src/Mobs/CaveSpider.cpp index 56ecd2d28..1157b81f9 100644 --- a/src/Mobs/CaveSpider.cpp +++ b/src/Mobs/CaveSpider.cpp @@ -20,7 +20,6 @@ void cCaveSpider::Tick(float a_Dt, cChunk & a_Chunk) { super::Tick(a_Dt, a_Chunk); - // TODO: Check vanilla if cavespiders really get passive during the day / in daylight m_EMPersonality = (GetWorld()->GetTimeOfDay() < (12000 + 1000)) ? PASSIVE : AGGRESSIVE; } -- cgit v1.2.3 From d5649df326d90361bbf64e2ebb4893caa0499521 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Fri, 6 Jun 2014 23:23:28 +0100 Subject: Further improvements on redstone speed Based on suggestions of @worktycho * Repeaters now walk their data structure only when needed * Fixed a bug with cChunkData returning an incorrect value for whether a meta had changed --- src/ChunkData.cpp | 2 +- src/Simulator/IncrementalRedstoneSimulator.cpp | 141 ++++++++++++++----------- src/Simulator/IncrementalRedstoneSimulator.h | 6 +- 3 files changed, 81 insertions(+), 68 deletions(-) (limited to 'src') diff --git a/src/ChunkData.cpp b/src/ChunkData.cpp index 1fa2fd212..f2d220bd2 100644 --- a/src/ChunkData.cpp +++ b/src/ChunkData.cpp @@ -258,7 +258,7 @@ bool cChunkData::SetMeta(int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_Nibble (m_Sections[Section]->m_BlockMetas[Index / 2] & (0xf0 >> ((Index & 1) * 4))) | // The untouched nibble ((a_Nibble & 0x0f) << ((Index & 1) * 4)) // The nibble being set ); - return oldval == a_Nibble; + return oldval != a_Nibble; } diff --git a/src/Simulator/IncrementalRedstoneSimulator.cpp b/src/Simulator/IncrementalRedstoneSimulator.cpp index 21326c7c4..aef332e9f 100644 --- a/src/Simulator/IncrementalRedstoneSimulator.cpp +++ b/src/Simulator/IncrementalRedstoneSimulator.cpp @@ -266,19 +266,20 @@ void cIncrementalRedstoneSimulator::SimulateChunk(float a_Dt, int a_ChunkX, int case E_BLOCK_REDSTONE_REPEATER_OFF: case E_BLOCK_REDSTONE_REPEATER_ON: { - if (ShouldUpdateSimulateOnceBlocks) - { - HandleRedstoneRepeater(dataitr->x, dataitr->y, dataitr->z, dataitr->Data); - break; - } - for (RepeatersDelayList::const_iterator repeateritr = m_RepeatersDelayList->begin(); repeateritr != m_RepeatersDelayList->end(); ++repeateritr) + bool FoundItem = false; + for (RepeatersDelayList::iterator repeateritr = m_RepeatersDelayList->begin(); repeateritr != m_RepeatersDelayList->end(); ++repeateritr) { if (repeateritr->a_RelBlockPos == Vector3i(dataitr->x, dataitr->y, dataitr->z)) { - HandleRedstoneRepeater(dataitr->x, dataitr->y, dataitr->z, dataitr->Data); + HandleRedstoneRepeater(dataitr->x, dataitr->y, dataitr->z, dataitr->Data, repeateritr); + FoundItem = true; break; } } + if (!FoundItem && ShouldUpdateSimulateOnceBlocks) + { + HandleRedstoneRepeater(dataitr->x, dataitr->y, dataitr->z, dataitr->Data, m_RepeatersDelayList->end()); + } break; } case E_BLOCK_WOODEN_PRESSURE_PLATE: @@ -746,7 +747,7 @@ void cIncrementalRedstoneSimulator::HandleRedstoneWire(int a_RelBlockX, int a_Re -void cIncrementalRedstoneSimulator::HandleRedstoneRepeater(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, BLOCKTYPE a_MyState) +void cIncrementalRedstoneSimulator::HandleRedstoneRepeater(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, BLOCKTYPE a_MyState, RepeatersDelayList::iterator a_Itr) { /* Repeater Orientation Mini Guide: =================================== @@ -772,87 +773,99 @@ void cIncrementalRedstoneSimulator::HandleRedstoneRepeater(int a_RelBlockX, int // Create a variable holding my meta to avoid multiple lookups. NIBBLETYPE a_Meta = m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ); bool IsOn = (a_MyState == E_BLOCK_REDSTONE_REPEATER_ON); - + + bool WereItrsChanged = false; if (!IsRepeaterLocked(a_RelBlockX, a_RelBlockY, a_RelBlockZ, a_Meta)) // If we're locked, change nothing. Otherwise: { bool IsSelfPowered = IsRepeaterPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, a_Meta); if (IsSelfPowered && !IsOn) // Queue a power change if powered, but not on and not locked. { - QueueRepeaterPowerChange(a_RelBlockX, a_RelBlockY, a_RelBlockZ, a_Meta, true); + WereItrsChanged = QueueRepeaterPowerChange(a_RelBlockX, a_RelBlockY, a_RelBlockZ, a_Meta, true); } else if (!IsSelfPowered && IsOn) // Queue a power change if unpowered, on, and not locked. { - QueueRepeaterPowerChange(a_RelBlockX, a_RelBlockY, a_RelBlockZ, a_Meta, false); + WereItrsChanged = QueueRepeaterPowerChange(a_RelBlockX, a_RelBlockY, a_RelBlockZ, a_Meta, false); + } + else + { + return; } } + else + { + return; + } - for (RepeatersDelayList::iterator itr = m_RepeatersDelayList->begin(); itr != m_RepeatersDelayList->end(); ++itr) + if (WereItrsChanged) { - if (!itr->a_RelBlockPos.Equals(Vector3i(a_RelBlockX, a_RelBlockY, a_RelBlockZ))) + for (a_Itr = m_RepeatersDelayList->begin(); a_Itr != m_RepeatersDelayList->end(); ++a_Itr) { - continue; + if (a_Itr->a_RelBlockPos == Vector3i(a_RelBlockX, a_RelBlockY, a_RelBlockZ)) + { + break; + } } + } - if (itr->a_ElapsedTicks >= itr->a_DelayTicks) // Has the elapsed ticks reached the target ticks? + if (a_Itr->a_ElapsedTicks >= a_Itr->a_DelayTicks) // Has the elapsed ticks reached the target ticks? + { + if (a_Itr->ShouldPowerOn) { - if (itr->ShouldPowerOn) + if (!IsOn) { - if (!IsOn) + m_Chunk->SetBlock(a_RelBlockX, a_RelBlockY, a_RelBlockZ, E_BLOCK_REDSTONE_REPEATER_ON, a_Meta); // For performance + } + + switch (a_Meta & 0x3) // We only want the direction (bottom) bits + { + case 0x0: { - m_Chunk->SetBlock(a_RelBlockX, a_RelBlockY, a_RelBlockZ, E_BLOCK_REDSTONE_REPEATER_ON, a_Meta); // For performance + SetBlockPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ - 1, a_RelBlockX, a_RelBlockY, a_RelBlockZ); + SetDirectionLinkedPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, BLOCK_FACE_ZM); + break; } - - switch (a_Meta & 0x3) // We only want the direction (bottom) bits + case 0x1: { - case 0x0: - { - SetBlockPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ - 1, a_RelBlockX, a_RelBlockY, a_RelBlockZ); - SetDirectionLinkedPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, BLOCK_FACE_ZM); - break; - } - case 0x1: - { - SetBlockPowered(a_RelBlockX + 1, a_RelBlockY, a_RelBlockZ, a_RelBlockX, a_RelBlockY, a_RelBlockZ); - SetDirectionLinkedPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, BLOCK_FACE_XP); - break; - } - case 0x2: - { - SetBlockPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ + 1, a_RelBlockX, a_RelBlockY, a_RelBlockZ); - SetDirectionLinkedPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, BLOCK_FACE_ZP); - break; - } - case 0x3: - { - SetBlockPowered(a_RelBlockX - 1, a_RelBlockY, a_RelBlockZ, a_RelBlockX, a_RelBlockY, a_RelBlockZ); - SetDirectionLinkedPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, BLOCK_FACE_XM); - break; - } + SetBlockPowered(a_RelBlockX + 1, a_RelBlockY, a_RelBlockZ, a_RelBlockX, a_RelBlockY, a_RelBlockZ); + SetDirectionLinkedPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, BLOCK_FACE_XP); + break; } - - // Removal of the data entry will be handled in SimChunk - we still want to continue trying to power blocks, even if our delay time has reached - // Otherwise, the power state of blocks in front won't update after we have powered on - return; - } - else - { - if (IsOn) + case 0x2: + { + SetBlockPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ + 1, a_RelBlockX, a_RelBlockY, a_RelBlockZ); + SetDirectionLinkedPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, BLOCK_FACE_ZP); + break; + } + case 0x3: { - m_Chunk->SetBlock(a_RelBlockX, a_RelBlockY, a_RelBlockZ, E_BLOCK_REDSTONE_REPEATER_OFF, a_Meta); + SetBlockPowered(a_RelBlockX - 1, a_RelBlockY, a_RelBlockZ, a_RelBlockX, a_RelBlockY, a_RelBlockZ); + SetDirectionLinkedPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, BLOCK_FACE_XM); + break; } - m_RepeatersDelayList->erase(itr); // We can remove off repeaters which don't need further updating - return; } + + // Removal of the data entry will be handled in SimChunk - we still want to continue trying to power blocks, even if our delay time has reached + // Otherwise, the power state of blocks in front won't update after we have powered on + return; } else { - // Apparently, incrementing ticks only works reliably here, and not in SimChunk; - // With a world with lots of redstone, the repeaters simply do not delay - // I am confounded to say why. Perhaps optimisation failure. - LOGD("Incremented a repeater @ {%i %i %i} | Elapsed ticks: %i | Target delay: %i", itr->a_RelBlockPos.x, itr->a_RelBlockPos.y, itr->a_RelBlockPos.z, itr->a_ElapsedTicks, itr->a_DelayTicks); - itr->a_ElapsedTicks++; + if (IsOn) + { + m_Chunk->SetBlock(a_RelBlockX, a_RelBlockY, a_RelBlockZ, E_BLOCK_REDSTONE_REPEATER_OFF, a_Meta); + } + m_RepeatersDelayList->erase(a_Itr); // We can remove off repeaters which don't need further updating + return; } } + else + { + // Apparently, incrementing ticks only works reliably here, and not in SimChunk; + // With a world with lots of redstone, the repeaters simply do not delay + // I am confounded to say why. Perhaps optimisation failure. + LOGD("Incremented a repeater @ {%i %i %i} | Elapsed ticks: %i | Target delay: %i", a_Itr->a_RelBlockPos.x, a_Itr->a_RelBlockPos.y, a_Itr->a_RelBlockPos.z, a_Itr->a_ElapsedTicks, a_Itr->a_DelayTicks); + a_Itr->a_ElapsedTicks++; + } } @@ -1914,7 +1927,7 @@ void cIncrementalRedstoneSimulator::SetPlayerToggleableBlockAsSimulated(int a_Re -void cIncrementalRedstoneSimulator::QueueRepeaterPowerChange(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, NIBBLETYPE a_Meta, bool ShouldPowerOn) +bool cIncrementalRedstoneSimulator::QueueRepeaterPowerChange(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, NIBBLETYPE a_Meta, bool ShouldPowerOn) { for (RepeatersDelayList::iterator itr = m_RepeatersDelayList->begin(); itr != m_RepeatersDelayList->end(); ++itr) { @@ -1922,14 +1935,14 @@ void cIncrementalRedstoneSimulator::QueueRepeaterPowerChange(int a_RelBlockX, in { if (ShouldPowerOn == itr->ShouldPowerOn) // We are queued already for the same thing, don't replace entry { - return; + return false; } // Already in here (normal to allow repeater to continue on powering and updating blocks in front) - just update info and quit itr->a_DelayTicks = (((a_Meta & 0xC) >> 0x2) + 1) * 2; // See below for description itr->a_ElapsedTicks = 0; itr->ShouldPowerOn = ShouldPowerOn; - return; + return false; } } @@ -1944,7 +1957,7 @@ void cIncrementalRedstoneSimulator::QueueRepeaterPowerChange(int a_RelBlockX, in RC.a_ElapsedTicks = 0; RC.ShouldPowerOn = ShouldPowerOn; m_RepeatersDelayList->push_back(RC); - return; + return true; } diff --git a/src/Simulator/IncrementalRedstoneSimulator.h b/src/Simulator/IncrementalRedstoneSimulator.h index 233a3d408..83076311a 100644 --- a/src/Simulator/IncrementalRedstoneSimulator.h +++ b/src/Simulator/IncrementalRedstoneSimulator.h @@ -108,7 +108,7 @@ private: /** Handles redstone wire */ void HandleRedstoneWire(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ); /** Handles repeaters */ - void HandleRedstoneRepeater(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, BLOCKTYPE a_MyState); + void HandleRedstoneRepeater(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, BLOCKTYPE a_MyState, RepeatersDelayList::iterator a_Itr); /* ====================== */ /* ====== DEVICES ====== */ @@ -145,8 +145,8 @@ private: void SetDirectionLinkedPowered(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, char a_Direction, unsigned char a_PowerLevel = MAX_POWER_LEVEL); /** Marks all blocks immediately surrounding a coordinate as powered */ void SetAllDirsAsPowered(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, unsigned char a_PowerLevel = MAX_POWER_LEVEL); - /** Queues a repeater to be powered or unpowered */ - void QueueRepeaterPowerChange(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, NIBBLETYPE a_Meta, bool ShouldPowerOn); + /** Queues a repeater to be powered or unpowered and returns if the m_RepeatersDelayList iterators were invalidated */ + bool QueueRepeaterPowerChange(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, NIBBLETYPE a_Meta, bool ShouldPowerOn); /** Returns if a coordinate is powered or linked powered */ bool AreCoordsPowered(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ) { return AreCoordsDirectlyPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ) || AreCoordsLinkedPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ); } -- cgit v1.2.3 From ec40c7c83ad1ef62b2c8e759bd9a76cf916f5e5b Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 5 Jun 2014 23:44:31 +0200 Subject: Added RainbowRoads finisher generator. --- src/Generating/ComposableGenerator.cpp | 14 +- src/Generating/Prefabs/RainbowRoadPrefabs.cpp | 1406 +++++++++++++++++++++++++ src/Generating/Prefabs/RainbowRoadPrefabs.h | 15 + src/Generating/RainbowRoadsGen.cpp | 115 ++ src/Generating/RainbowRoadsGen.h | 47 + 5 files changed, 1594 insertions(+), 3 deletions(-) create mode 100644 src/Generating/Prefabs/RainbowRoadPrefabs.cpp create mode 100644 src/Generating/Prefabs/RainbowRoadPrefabs.h create mode 100644 src/Generating/RainbowRoadsGen.cpp create mode 100644 src/Generating/RainbowRoadsGen.h (limited to 'src') diff --git a/src/Generating/ComposableGenerator.cpp b/src/Generating/ComposableGenerator.cpp index cf736ce64..1801b7375 100644 --- a/src/Generating/ComposableGenerator.cpp +++ b/src/Generating/ComposableGenerator.cpp @@ -24,6 +24,7 @@ #include "NetherFortGen.h" #include "Noise3DGenerator.h" #include "POCPieceGenerator.h" +#include "RainbowRoadsGen.h" #include "Ravines.h" #include "UnderwaterBaseGen.h" #include "VillageGen.h" @@ -391,6 +392,13 @@ void cComposableGenerator::InitFinishGens(cIniFile & a_IniFile) { m_FinishGens.push_back(new cFinishGenPreSimulator); } + else if (NoCaseCompare(*itr, "RainbowRoads") == 0) + { + int GridSize = a_IniFile.GetValueSetI("Generator", "RainbowRoadsGridSize", 512); + int MaxDepth = a_IniFile.GetValueSetI("Generator", "RainbowRoadsMaxDepth", 30); + int MaxSize = a_IniFile.GetValueSetI("Generator", "RainbowRoadsMaxSize", 260); + m_FinishGens.push_back(new cRainbowRoadsGen(Seed, GridSize, MaxDepth, MaxSize)); + } else if (NoCaseCompare(*itr, "Ravines") == 0) { m_FinishGens.push_back(new cStructGenRavines(Seed, 128)); @@ -409,9 +417,9 @@ void cComposableGenerator::InitFinishGens(cIniFile & a_IniFile) } else if (NoCaseCompare(*itr, "UnderwaterBases") == 0) { - int GridSize = a_IniFile.GetValueSetI("Generator", "UnderwaterBaseGridSize", 1024); - int MaxDepth = a_IniFile.GetValueSetI("Generator", "UnderwaterBaseMaxDepth", 7); - int MaxSize = a_IniFile.GetValueSetI("Generator", "UnderwaterBaseMaxSize", 128); + int GridSize = a_IniFile.GetValueSetI("Generator", "UnderwaterBaseGridSize", 1024); + int MaxDepth = a_IniFile.GetValueSetI("Generator", "UnderwaterBaseMaxDepth", 7); + int MaxSize = a_IniFile.GetValueSetI("Generator", "UnderwaterBaseMaxSize", 128); m_FinishGens.push_back(new cUnderwaterBaseGen(Seed, GridSize, MaxDepth, MaxSize, *m_BiomeGen)); } else if (NoCaseCompare(*itr, "Villages") == 0) diff --git a/src/Generating/Prefabs/RainbowRoadPrefabs.cpp b/src/Generating/Prefabs/RainbowRoadPrefabs.cpp new file mode 100644 index 000000000..1a3765c5a --- /dev/null +++ b/src/Generating/Prefabs/RainbowRoadPrefabs.cpp @@ -0,0 +1,1406 @@ + +// RainbowRoadPrefabs.cpp + +// Defines the prefabs in the group RainbowRoad + +// NOTE: This file has been generated automatically by GalExport! +// Any manual changes will be overwritten by the next automatic export! + +#include "Globals.h" +#include "RainbowRoadPrefabs.h" + + + + + +const cPrefab::sDef g_RainbowRoadPrefabs[] = +{ + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // CurveDouble: + // The data has been exported from the gallery Cube, area index 89, ID 467, created by Aloe_vera + { + // Size: + 14, 1, 14, // SizeX = 14, SizeY = 1, SizeZ = 14 + + // Hitbox (relative to bounding box): + 0, -2, 0, // MinX, MinY, MinZ + 13, 2, 13, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 35:11\n" /* wool */ + "b: 35: 3\n" /* wool */ + "c: 35: 5\n" /* wool */ + "d: 35: 4\n" /* wool */ + "e: 35: 1\n" /* wool */ + "f: 35:14\n" /* wool */ + "m: 19: 0\n" /* sponge */, + + // Block data: + // Level 0 + /* z\x* 1111 */ + /* * 01234567890123 */ + /* 0 */ "aaaaaa........" + /* 1 */ "bbbbbba......." + /* 2 */ "cccccbbaaa...." + /* 3 */ "dddddccbbaa..." + /* 4 */ "eeeeeddccbaa.." + /* 5 */ "fffffeddccba.." + /* 6 */ "ffffffeedcbaa." + /* 7 */ "eeeefffeddcba." + /* 8 */ "dddeefffedcbba" + /* 9 */ "cccddefffedcba" + /* 10 */ "bbccdeeffedcba" + /* 11 */ "abbccdeffedcba" + /* 12 */ ".abbcdeffedcba" + /* 13 */ "..abcdeffedcba", + + // Connectors: + "2: 2, 1, 13: 3\n" /* Type 2, direction Z+ */ + "2: 0, 1, 0: 4\n" /* Type 2, direction X- */ + "-2: 0, 1, 11: 4\n" /* Type -2, direction X- */ + "-2: 13, 1, 13: 3\n" /* Type -2, direction Z+ */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + false, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + + // MoveToGround: + false, + }, // CurveDouble + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // CurveDownFromTopSingle: + // The data has been exported from the gallery Cube, area index 100, ID 478, created by Aloe_vera + { + // Size: + 11, 8, 11, // SizeX = 11, SizeY = 8, SizeZ = 11 + + // Hitbox (relative to bounding box): + 0, -2, 0, // MinX, MinY, MinZ + 10, 9, 10, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 35:14\n" /* wool */ + "b: 35: 5\n" /* wool */ + "c: 35: 4\n" /* wool */ + "d: 35: 1\n" /* wool */ + "e: 35:11\n" /* wool */ + "f: 35: 3\n" /* wool */ + "m: 19: 0\n" /* sponge */, + + // Block data: + // Level 0 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ "..........." + /* 2 */ "..........." + /* 3 */ "..........." + /* 4 */ "..........." + /* 5 */ "..........." + /* 6 */ "..........." + /* 7 */ "..........." + /* 8 */ "..........a" + /* 9 */ ".......bcda" + /* 10 */ ".....efbcda" + + // Level 1 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ "..........." + /* 2 */ "..........." + /* 3 */ "..........." + /* 4 */ "..........." + /* 5 */ "..........." + /* 6 */ "........cda" + /* 7 */ ".......bcda" + /* 8 */ ".......bcd." + /* 9 */ ".....ef...." + /* 10 */ "..........." + + // Level 2 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ "..........." + /* 2 */ "..........." + /* 3 */ "..........." + /* 4 */ ".........a." + /* 5 */ ".......cdda" + /* 6 */ "......bc..." + /* 7 */ "......b...." + /* 8 */ ".....ff...." + /* 9 */ "....ee....." + /* 10 */ "..........." + + // Level 3 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ "..........." + /* 2 */ "..........." + /* 3 */ "........aa." + /* 4 */ "......ccd.." + /* 5 */ ".....bb...." + /* 6 */ ".....f....." + /* 7 */ "....ef....." + /* 8 */ "....e......" + /* 9 */ "..........." + /* 10 */ "..........." + + // Level 4 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ "..........." + /* 2 */ "......daa.." + /* 3 */ ".....ccd..." + /* 4 */ "....bb....." + /* 5 */ "....f......" + /* 6 */ "...ef......" + /* 7 */ "...ee......" + /* 8 */ "..........." + /* 9 */ "..........." + /* 10 */ "..........." + + // Level 5 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ ".....daa..." + /* 2 */ "...ccd....." + /* 3 */ "...bc......" + /* 4 */ "...b......." + /* 5 */ "..ff......." + /* 6 */ "..ee......." + /* 7 */ "..........." + /* 8 */ "..........." + /* 9 */ "..........." + /* 10 */ "..........." + + // Level 6 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "...aaa....." + /* 1 */ "..ddd......" + /* 2 */ ".cc........" + /* 3 */ ".bb........" + /* 4 */ ".ff........" + /* 5 */ ".e........." + /* 6 */ ".ee........" + /* 7 */ "..........." + /* 8 */ "..........." + /* 9 */ "..........." + /* 10 */ "..........." + + // Level 7 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "aaa........" + /* 1 */ "dd........." + /* 2 */ "cc........." + /* 3 */ "bb........." + /* 4 */ "ff........." + /* 5 */ "e.........." + /* 6 */ "..........." + /* 7 */ "..........." + /* 8 */ "..........." + /* 9 */ "..........." + /* 10 */ "...........", + + // Connectors: + "-1: 0, 8, 5: 4\n" /* Type -1, direction X- */ + "1: 5, 1, 10: 3\n" /* Type 1, direction Z+ */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + false, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + + // MoveToGround: + false, + }, // CurveDownFromTopSingle + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // CurveSingle: + // The data has been exported from the gallery Cube, area index 84, ID 462, created by Aloe_vera + { + // Size: + 11, 1, 11, // SizeX = 11, SizeY = 1, SizeZ = 11 + + // Hitbox (relative to bounding box): + 0, -2, 0, // MinX, MinY, MinZ + 10, 2, 10, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 35:14\n" /* wool */ + "b: 35: 1\n" /* wool */ + "c: 35: 4\n" /* wool */ + "d: 35: 5\n" /* wool */ + "e: 35: 3\n" /* wool */ + "f: 35:11\n" /* wool */ + "m: 19: 0\n" /* sponge */, + + // Block data: + // Level 0 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "aaaaaa....." + /* 1 */ "bbbbbbaa..." + /* 2 */ "cccccbbaa.." + /* 3 */ "ddddcccbaa." + /* 4 */ "eeedddccba." + /* 5 */ "ffeeeddcbba" + /* 6 */ ".fffeedccba" + /* 7 */ "...ffeddcba" + /* 8 */ "....feedcba" + /* 9 */ "....ffedcba" + /* 10 */ ".....fedcba", + + // Connectors: + "-1: 0, 1, 5: 4\n" /* Type -1, direction X- */ + "1: 5, 1, 10: 3\n" /* Type 1, direction Z+ */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + false, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + + // MoveToGround: + false, + }, // CurveSingle + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // CurveSingleLeft: + // The data has been exported from the gallery Cube, area index 97, ID 475, created by Aloe_vera + { + // Size: + 11, 1, 11, // SizeX = 11, SizeY = 1, SizeZ = 11 + + // Hitbox (relative to bounding box): + 0, -2, 0, // MinX, MinY, MinZ + 10, 2, 10, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 35:14\n" /* wool */ + "b: 35: 1\n" /* wool */ + "c: 35: 4\n" /* wool */ + "d: 35: 5\n" /* wool */ + "e: 35: 3\n" /* wool */ + "f: 35:11\n" /* wool */ + "m: 19: 0\n" /* sponge */, + + // Block data: + // Level 0 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ ".....abcdef" + /* 1 */ "....aabcdef" + /* 2 */ "....abbcdef" + /* 3 */ "...aabccdef" + /* 4 */ ".aaabbcddef" + /* 5 */ "aabbbccdeef" + /* 6 */ "bbbcccddef." + /* 7 */ "ccccdddeff." + /* 8 */ "dddddeeff.." + /* 9 */ "eeeeeeff..." + /* 10 */ "ffffff.....", + + // Connectors: + "-1: 0, 1, 10: 4\n" /* Type -1, direction X- */ + "1: 10, 1, 0: 2\n" /* Type 1, direction Z- */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + false, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + + // MoveToGround: + false, + }, // CurveSingleLeft + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // CurveUpDouble: + // The data has been exported from the gallery Cube, area index 92, ID 470, created by Aloe_vera + { + // Size: + 14, 8, 14, // SizeX = 14, SizeY = 8, SizeZ = 14 + + // Hitbox (relative to bounding box): + 0, -2, 0, // MinX, MinY, MinZ + 13, 9, 13, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 35:11\n" /* wool */ + "b: 35: 3\n" /* wool */ + "c: 35: 5\n" /* wool */ + "d: 35: 4\n" /* wool */ + "e: 35: 1\n" /* wool */ + "f: 35:14\n" /* wool */ + "m: 19: 0\n" /* sponge */, + + // Block data: + // Level 0 + /* z\x* 1111 */ + /* * 01234567890123 */ + /* 0 */ "a............." + /* 1 */ "b............." + /* 2 */ "c............." + /* 3 */ "d............." + /* 4 */ "e............." + /* 5 */ "f............." + /* 6 */ "f............." + /* 7 */ "e............." + /* 8 */ "d............." + /* 9 */ "c............." + /* 10 */ "b............." + /* 11 */ "a............." + /* 12 */ ".............." + /* 13 */ ".............." + + // Level 1 + /* z\x* 1111 */ + /* * 01234567890123 */ + /* 0 */ ".aa..........." + /* 1 */ ".bb..........." + /* 2 */ ".cc..........." + /* 3 */ ".dd..........." + /* 4 */ ".ee..........." + /* 5 */ ".f............" + /* 6 */ ".f............" + /* 7 */ ".e............" + /* 8 */ ".d............" + /* 9 */ ".c............" + /* 10 */ ".b............" + /* 11 */ ".b............" + /* 12 */ ".............." + /* 13 */ ".............." + + // Level 2 + /* z\x* 1111 */ + /* * 01234567890123 */ + /* 0 */ "...aaa........" + /* 1 */ "...bb........." + /* 2 */ "...cc........." + /* 3 */ "...dd........." + /* 4 */ "...ee........." + /* 5 */ "..ff.........." + /* 6 */ "..ff.........." + /* 7 */ "..ee.........." + /* 8 */ "..de.........." + /* 9 */ "..c..........." + /* 10 */ ".b............" + /* 11 */ ".b............" + /* 12 */ ".............." + /* 13 */ ".............." + + // Level 3 + /* z\x* 1111 */ + /* * 01234567890123 */ + /* 0 */ ".............." + /* 1 */ ".....baa......" + /* 2 */ ".....bbaaa...." + /* 3 */ "....dccbba...." + /* 4 */ "....eddcc....." + /* 5 */ "....fedd......" + /* 6 */ "....ffee......" + /* 7 */ "....ff........" + /* 8 */ "....e........." + /* 9 */ "...dd........." + /* 10 */ "..cc.........." + /* 11 */ "..b..........." + /* 12 */ ".a............" + /* 13 */ ".............." + + // Level 4 + /* z\x* 1111 */ + /* * 01234567890123 */ + /* 0 */ ".............." + /* 1 */ ".............." + /* 2 */ ".............." + /* 3 */ "..........a..." + /* 4 */ ".........ba..." + /* 5 */ "........cc...." + /* 6 */ ".......edc...." + /* 7 */ "......fedd...." + /* 8 */ ".....ff......." + /* 9 */ "....de........" + /* 10 */ "...cde........" + /* 11 */ "..b..........." + /* 12 */ ".a............" + /* 13 */ ".............." + + // Level 5 + /* z\x* 1111 */ + /* * 01234567890123 */ + /* 0 */ ".............." + /* 1 */ ".............." + /* 2 */ ".............." + /* 3 */ ".............." + /* 4 */ "...........a.." + /* 5 */ "..........ba.." + /* 6 */ "..........baa." + /* 7 */ "..........cba." + /* 8 */ ".......fedcb.." + /* 9 */ "......fffed..." + /* 10 */ ".....eef......" + /* 11 */ "...ccd........" + /* 12 */ "..b..........." + /* 13 */ ".............." + + // Level 6 + /* z\x* 1111 */ + /* * 01234567890123 */ + /* 0 */ ".............." + /* 1 */ ".............." + /* 2 */ ".............." + /* 3 */ ".............." + /* 4 */ ".............." + /* 5 */ ".............." + /* 6 */ ".............." + /* 7 */ ".............." + /* 8 */ "............ba" + /* 9 */ "...........cba" + /* 10 */ "........fedcba" + /* 11 */ "......effedc.." + /* 12 */ "..bbcdef......" + /* 13 */ "..a..........." + + // Level 7 + /* z\x* 1111 */ + /* * 01234567890123 */ + /* 0 */ ".............." + /* 1 */ ".............." + /* 2 */ ".............." + /* 3 */ ".............." + /* 4 */ ".............." + /* 5 */ ".............." + /* 6 */ ".............." + /* 7 */ ".............." + /* 8 */ ".............." + /* 9 */ ".............." + /* 10 */ ".............." + /* 11 */ "............ba" + /* 12 */ "........fedcba" + /* 13 */ "..abcdeffedcba", + + // Connectors: + "-2: 0, 1, 11: 4\n" /* Type -2, direction X- */ + "2: 0, 1, 0: 4\n" /* Type 2, direction X- */ + "2: 2, 8, 13: 3\n" /* Type 2, direction Z+ */ + "-2: 13, 8, 13: 3\n" /* Type -2, direction Z+ */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + false, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + + // MoveToGround: + false, + }, // CurveUpDouble + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // CurveUpSingle: + // The data has been exported from the gallery Cube, area index 87, ID 465, created by Aloe_vera + { + // Size: + 11, 8, 11, // SizeX = 11, SizeY = 8, SizeZ = 11 + + // Hitbox (relative to bounding box): + 0, -2, 0, // MinX, MinY, MinZ + 10, 9, 10, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 35:14\n" /* wool */ + "b: 35: 1\n" /* wool */ + "c: 35: 4\n" /* wool */ + "d: 35: 5\n" /* wool */ + "e: 35: 3\n" /* wool */ + "f: 35:11\n" /* wool */ + "m: 19: 0\n" /* sponge */, + + // Block data: + // Level 0 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "aaa........" + /* 1 */ "bb........." + /* 2 */ "cc........." + /* 3 */ "dd........." + /* 4 */ "ee........." + /* 5 */ "f.........." + /* 6 */ "..........." + /* 7 */ "..........." + /* 8 */ "..........." + /* 9 */ "..........." + /* 10 */ "..........." + + // Level 1 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "...aaa....." + /* 1 */ "..bbb......" + /* 2 */ ".cc........" + /* 3 */ ".dd........" + /* 4 */ ".ee........" + /* 5 */ ".f........." + /* 6 */ ".ff........" + /* 7 */ "..........." + /* 8 */ "..........." + /* 9 */ "..........." + /* 10 */ "..........." + + // Level 2 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ ".....baa..." + /* 2 */ "...ccb....." + /* 3 */ "...dc......" + /* 4 */ "...d......." + /* 5 */ "..ee......." + /* 6 */ "..ff......." + /* 7 */ "..........." + /* 8 */ "..........." + /* 9 */ "..........." + /* 10 */ "..........." + + // Level 3 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ "..........." + /* 2 */ "......baa.." + /* 3 */ ".....ccb..." + /* 4 */ "....dd....." + /* 5 */ "....e......" + /* 6 */ "...fe......" + /* 7 */ "...ff......" + /* 8 */ "..........." + /* 9 */ "..........." + /* 10 */ "..........." + + // Level 4 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ "..........." + /* 2 */ "..........." + /* 3 */ "........aa." + /* 4 */ "......ccb.." + /* 5 */ ".....dd...." + /* 6 */ ".....e....." + /* 7 */ "....fe....." + /* 8 */ "....f......" + /* 9 */ "..........." + /* 10 */ "..........." + + // Level 5 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ "..........." + /* 2 */ "..........." + /* 3 */ "..........." + /* 4 */ ".........a." + /* 5 */ ".......cbba" + /* 6 */ "......dc..." + /* 7 */ "......d...." + /* 8 */ ".....ee...." + /* 9 */ "....ff....." + /* 10 */ "..........." + + // Level 6 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ "..........." + /* 2 */ "..........." + /* 3 */ "..........." + /* 4 */ "..........." + /* 5 */ "..........." + /* 6 */ "........cba" + /* 7 */ ".......dcba" + /* 8 */ ".......dcb." + /* 9 */ ".....fe...." + /* 10 */ ".....f....." + + // Level 7 + /* z\x* 1 */ + /* * 01234567890 */ + /* 0 */ "..........." + /* 1 */ "..........." + /* 2 */ "..........." + /* 3 */ "..........." + /* 4 */ "..........." + /* 5 */ "..........." + /* 6 */ "..........." + /* 7 */ "..........." + /* 8 */ "..........a" + /* 9 */ ".......dcba" + /* 10 */ ".....fedcba", + + // Connectors: + "-1: 0, 1, 5: 4\n" /* Type -1, direction X- */ + "1: 5, 8, 10: 3\n" /* Type 1, direction Z+ */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + false, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + + // MoveToGround: + false, + }, // CurveUpSingle + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // SlopeDownFromTopSingle: + // The data has been exported from the gallery Cube, area index 98, ID 476, created by Aloe_vera + { + // Size: + 16, 8, 6, // SizeX = 16, SizeY = 8, SizeZ = 6 + + // Hitbox (relative to bounding box): + 0, -2, 0, // MinX, MinY, MinZ + 15, 9, 5, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 35:14\n" /* wool */ + "b: 35: 1\n" /* wool */ + "c: 35: 4\n" /* wool */ + "d: 35: 5\n" /* wool */ + "e: 35: 3\n" /* wool */ + "f: 35:11\n" /* wool */ + "m: 19: 0\n" /* sponge */, + + // Block data: + // Level 0 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "..............aa" + /* 1 */ "..............bb" + /* 2 */ "..............cc" + /* 3 */ "..............dd" + /* 4 */ "..............ee" + /* 5 */ "..............ff" + + // Level 1 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "............aa.." + /* 1 */ "............bb.." + /* 2 */ "............cc.." + /* 3 */ "............dd.." + /* 4 */ "............ee.." + /* 5 */ "............ff.." + + // Level 2 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "..........aa...." + /* 1 */ "..........bb...." + /* 2 */ "..........cc...." + /* 3 */ "..........dd...." + /* 4 */ "..........ee...." + /* 5 */ "..........ff...." + + // Level 3 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "........aa......" + /* 1 */ "........bb......" + /* 2 */ "........cc......" + /* 3 */ "........dd......" + /* 4 */ "........ee......" + /* 5 */ "........ff......" + + // Level 4 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "......aa........" + /* 1 */ "......bb........" + /* 2 */ "......cc........" + /* 3 */ "......dd........" + /* 4 */ "......ee........" + /* 5 */ "......ff........" + + // Level 5 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "....aa.........." + /* 1 */ "....bb.........." + /* 2 */ "....cc.........." + /* 3 */ "....dd.........." + /* 4 */ "....ee.........." + /* 5 */ "....ff.........." + + // Level 6 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "..aa............" + /* 1 */ "..bb............" + /* 2 */ "..cc............" + /* 3 */ "..dd............" + /* 4 */ "..ee............" + /* 5 */ "..ff............" + + // Level 7 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "aa.............." + /* 1 */ "bb.............." + /* 2 */ "cc.............." + /* 3 */ "dd.............." + /* 4 */ "ee.............." + /* 5 */ "ff..............", + + // Connectors: + "-1: 0, 8, 5: 4\n" /* Type -1, direction X- */ + "1: 15, 1, 5: 5\n" /* Type 1, direction X+ */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + false, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + + // MoveToGround: + false, + }, // SlopeDownFromTopSingle + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // SlopeUpDouble: + // The data has been exported from the gallery Cube, area index 90, ID 468, created by Aloe_vera + { + // Size: + 16, 8, 12, // SizeX = 16, SizeY = 8, SizeZ = 12 + + // Hitbox (relative to bounding box): + 0, -2, 0, // MinX, MinY, MinZ + 15, 9, 11, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 35:11\n" /* wool */ + "b: 35: 3\n" /* wool */ + "c: 35: 5\n" /* wool */ + "d: 35: 4\n" /* wool */ + "e: 35: 1\n" /* wool */ + "f: 35:14\n" /* wool */ + "m: 19: 0\n" /* sponge */, + + // Block data: + // Level 0 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "aa.............." + /* 1 */ "bb.............." + /* 2 */ "cc.............." + /* 3 */ "dd.............." + /* 4 */ "ee.............." + /* 5 */ "ff.............." + /* 6 */ "ff.............." + /* 7 */ "ee.............." + /* 8 */ "dd.............." + /* 9 */ "cc.............." + /* 10 */ "bb.............." + /* 11 */ "aa.............." + + // Level 1 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "..aa............" + /* 1 */ "..bb............" + /* 2 */ "..cc............" + /* 3 */ "..dd............" + /* 4 */ "..ee............" + /* 5 */ "..ff............" + /* 6 */ "..ff............" + /* 7 */ "..ee............" + /* 8 */ "..dd............" + /* 9 */ "..cc............" + /* 10 */ "..bb............" + /* 11 */ "..aa............" + + // Level 2 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "....aa.........." + /* 1 */ "....bb.........." + /* 2 */ "....cc.........." + /* 3 */ "....dd.........." + /* 4 */ "....ee.........." + /* 5 */ "....ff.........." + /* 6 */ "....ff.........." + /* 7 */ "....ee.........." + /* 8 */ "....dd.........." + /* 9 */ "....cc.........." + /* 10 */ "....bb.........." + /* 11 */ "....aa.........." + + // Level 3 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "......aa........" + /* 1 */ "......bb........" + /* 2 */ "......cc........" + /* 3 */ "......dd........" + /* 4 */ "......ee........" + /* 5 */ "......ff........" + /* 6 */ "......ff........" + /* 7 */ "......ee........" + /* 8 */ "......dd........" + /* 9 */ "......cc........" + /* 10 */ "......bb........" + /* 11 */ "......aa........" + + // Level 4 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "........aa......" + /* 1 */ "........bb......" + /* 2 */ "........cc......" + /* 3 */ "........dd......" + /* 4 */ "........ee......" + /* 5 */ "........ff......" + /* 6 */ "........ff......" + /* 7 */ "........ee......" + /* 8 */ "........dd......" + /* 9 */ "........cc......" + /* 10 */ "........bb......" + /* 11 */ "........aa......" + + // Level 5 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "..........aa...." + /* 1 */ "..........bb...." + /* 2 */ "..........cc...." + /* 3 */ "..........dd...." + /* 4 */ "..........ee...." + /* 5 */ "..........ff...." + /* 6 */ "..........ff...." + /* 7 */ "..........ee...." + /* 8 */ "..........dd...." + /* 9 */ "..........cc...." + /* 10 */ "..........bb...." + /* 11 */ "..........aa...." + + // Level 6 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "............aa.." + /* 1 */ "............bb.." + /* 2 */ "............cc.." + /* 3 */ "............dd.." + /* 4 */ "............ee.." + /* 5 */ "............ff.." + /* 6 */ "............ff.." + /* 7 */ "............ee.." + /* 8 */ "............dd.." + /* 9 */ "............cc.." + /* 10 */ "............bb.." + /* 11 */ "............aa.." + + // Level 7 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "..............aa" + /* 1 */ "..............bb" + /* 2 */ "..............cc" + /* 3 */ "..............dd" + /* 4 */ "..............ee" + /* 5 */ "..............ff" + /* 6 */ "..............ff" + /* 7 */ "..............ee" + /* 8 */ "..............dd" + /* 9 */ "..............cc" + /* 10 */ "..............bb" + /* 11 */ "..............aa", + + // Connectors: + "-2: 0, 1, 11: 4\n" /* Type -2, direction X- */ + "2: 0, 1, 0: 4\n" /* Type 2, direction X- */ + "-2: 15, 8, 0: 5\n" /* Type -2, direction X+ */ + "2: 15, 8, 11: 5\n" /* Type 2, direction X+ */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + false, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + + // MoveToGround: + false, + }, // SlopeUpDouble + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // SlopeUpSingle: + // The data has been exported from the gallery Cube, area index 85, ID 463, created by Aloe_vera + { + // Size: + 16, 8, 6, // SizeX = 16, SizeY = 8, SizeZ = 6 + + // Hitbox (relative to bounding box): + 0, -2, 0, // MinX, MinY, MinZ + 15, 9, 5, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 35:14\n" /* wool */ + "b: 35: 1\n" /* wool */ + "c: 35: 4\n" /* wool */ + "d: 35: 5\n" /* wool */ + "e: 35: 3\n" /* wool */ + "f: 35:11\n" /* wool */ + "m: 19: 0\n" /* sponge */, + + // Block data: + // Level 0 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "aa.............." + /* 1 */ "bb.............." + /* 2 */ "cc.............." + /* 3 */ "dd.............." + /* 4 */ "ee.............." + /* 5 */ "ff.............." + + // Level 1 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "..aa............" + /* 1 */ "..bb............" + /* 2 */ "..cc............" + /* 3 */ "..dd............" + /* 4 */ "..ee............" + /* 5 */ "..ff............" + + // Level 2 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "....aa.........." + /* 1 */ "....bb.........." + /* 2 */ "....cc.........." + /* 3 */ "....dd.........." + /* 4 */ "....ee.........." + /* 5 */ "....ff.........." + + // Level 3 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "......aa........" + /* 1 */ "......bb........" + /* 2 */ "......cc........" + /* 3 */ "......dd........" + /* 4 */ "......ee........" + /* 5 */ "......ff........" + + // Level 4 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "........aa......" + /* 1 */ "........bb......" + /* 2 */ "........cc......" + /* 3 */ "........dd......" + /* 4 */ "........ee......" + /* 5 */ "........ff......" + + // Level 5 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "..........aa...." + /* 1 */ "..........bb...." + /* 2 */ "..........cc...." + /* 3 */ "..........dd...." + /* 4 */ "..........ee...." + /* 5 */ "..........ff...." + + // Level 6 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "............aa.." + /* 1 */ "............bb.." + /* 2 */ "............cc.." + /* 3 */ "............dd.." + /* 4 */ "............ee.." + /* 5 */ "............ff.." + + // Level 7 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "..............aa" + /* 1 */ "..............bb" + /* 2 */ "..............cc" + /* 3 */ "..............dd" + /* 4 */ "..............ee" + /* 5 */ "..............ff", + + // Connectors: + "-1: 0, 1, 5: 4\n" /* Type -1, direction X- */ + "1: 15, 8, 5: 5\n" /* Type 1, direction X+ */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + false, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + -1000, + + // MoveToGround: + false, + }, // SlopeUpSingle + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // SplitTee: + // The data has been exported from the gallery Cube, area index 93, ID 471, created by Aloe_vera + { + // Size: + 16, 1, 14, // SizeX = 16, SizeY = 1, SizeZ = 14 + + // Hitbox (relative to bounding box): + 0, -2, 0, // MinX, MinY, MinZ + 15, 2, 13, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 35:11\n" /* wool */ + "b: 35: 3\n" /* wool */ + "c: 35: 5\n" /* wool */ + "d: 35: 4\n" /* wool */ + "e: 35: 1\n" /* wool */ + "f: 35:14\n" /* wool */ + "m: 19: 0\n" /* sponge */, + + // Block data: + // Level 0 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "aaaaaa.........." + /* 1 */ "bbbbbbaaa......." + /* 2 */ "ccccccbbbaaa...." + /* 3 */ "ddddddcccbbbaaaa" + /* 4 */ "eeeeeedddcccbbbb" + /* 5 */ "ffffffeeedddcccc" + /* 6 */ "fffffffffeeedddd" + /* 7 */ "eeeeff...fffeeee" + /* 8 */ "dddeeff.....ffff" + /* 9 */ "cccddeff........" + /* 10 */ "bbbccdeef......." + /* 11 */ "aaabbcddef......" + /* 12 */ "...aabcddef....." + /* 13 */ ".....abcdef.....", + + // Connectors: + "-2: 0, 1, 11: 4\n" /* Type -2, direction X- */ + "2: 0, 1, 0: 4\n" /* Type 2, direction X- */ + "-1: 15, 1, 3: 5\n" /* Type -1, direction X+ */ + "1: 5, 1, 13: 3\n" /* Type 1, direction Z+ */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + false, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + + // MoveToGround: + false, + }, // SplitTee + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // StraightDouble: + // The data has been exported from the gallery Cube, area index 88, ID 466, created by Aloe_vera + { + // Size: + 16, 1, 12, // SizeX = 16, SizeY = 1, SizeZ = 12 + + // Hitbox (relative to bounding box): + 0, -2, 0, // MinX, MinY, MinZ + 15, 2, 11, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 35:11\n" /* wool */ + "b: 35: 3\n" /* wool */ + "c: 35: 5\n" /* wool */ + "d: 35: 4\n" /* wool */ + "e: 35: 1\n" /* wool */ + "f: 35:14\n" /* wool */ + "m: 19: 0\n" /* sponge */, + + // Block data: + // Level 0 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "aaaaaaaaaaaaaaaa" + /* 1 */ "bbbbbbbbbbbbbbbb" + /* 2 */ "cccccccccccccccc" + /* 3 */ "dddddddddddddddd" + /* 4 */ "eeeeeeeeeeeeeeee" + /* 5 */ "ffffffffffffffff" + /* 6 */ "ffffffffffffffff" + /* 7 */ "eeeeeeeeeeeeeeee" + /* 8 */ "dddddddddddddddd" + /* 9 */ "cccccccccccccccc" + /* 10 */ "bbbbbbbbbbbbbbbb" + /* 11 */ "aaaaaaaaaaaaaaaa", + + // Connectors: + "-2: 0, 1, 11: 4\n" /* Type -2, direction X- */ + "2: 0, 1, 0: 4\n" /* Type 2, direction X- */ + "-2: 15, 1, 0: 5\n" /* Type -2, direction X+ */ + "2: 15, 1, 11: 5\n" /* Type 2, direction X+ */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + false, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + + // MoveToGround: + false, + }, // StraightDouble +}; // g_RainbowRoadPrefabs + + + + + + +const cPrefab::sDef g_RainbowRoadStartingPrefabs[] = +{ + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // StraightSingle: + // The data has been exported from the gallery Cube, area index 83, ID 461, created by Aloe_vera + { + // Size: + 16, 1, 6, // SizeX = 16, SizeY = 1, SizeZ = 6 + + // Hitbox (relative to bounding box): + 0, -2, 0, // MinX, MinY, MinZ + 15, 2, 5, // MaxX, MaxY, MaxZ + + // Block definitions: + ".: 0: 0\n" /* air */ + "a: 35:14\n" /* wool */ + "b: 35: 1\n" /* wool */ + "c: 35: 4\n" /* wool */ + "d: 35: 5\n" /* wool */ + "e: 35: 3\n" /* wool */ + "f: 35:11\n" /* wool */ + "m: 19: 0\n" /* sponge */, + + // Block data: + // Level 0 + /* z\x* 111111 */ + /* * 0123456789012345 */ + /* 0 */ "aaaaaaaaaaaaaaaa" + /* 1 */ "bbbbbbbbbbbbbbbb" + /* 2 */ "cccccccccccccccc" + /* 3 */ "dddddddddddddddd" + /* 4 */ "eeeeeeeeeeeeeeee" + /* 5 */ "ffffffffffffffff", + + // Connectors: + "-1: 0, 1, 5: 4\n" /* Type -1, direction X- */ + "1: 15, 1, 5: 5\n" /* Type 1, direction X+ */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + false, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 500, + + // MoveToGround: + false, + }, // StraightSingle +}; + + + + + +// The prefab counts: + +const size_t g_RainbowRoadPrefabsCount = ARRAYCOUNT(g_RainbowRoadPrefabs); + +const size_t g_RainbowRoadStartingPrefabsCount = ARRAYCOUNT(g_RainbowRoadStartingPrefabs); + diff --git a/src/Generating/Prefabs/RainbowRoadPrefabs.h b/src/Generating/Prefabs/RainbowRoadPrefabs.h new file mode 100644 index 000000000..ab0a0fbb2 --- /dev/null +++ b/src/Generating/Prefabs/RainbowRoadPrefabs.h @@ -0,0 +1,15 @@ + +// RainbowRoadPrefabs.h + +// Declares the prefabs in the group RainbowRoad + +#include "../Prefab.h" + + + + + +extern const cPrefab::sDef g_RainbowRoadPrefabs[]; +extern const cPrefab::sDef g_RainbowRoadStartingPrefabs[]; +extern const size_t g_RainbowRoadPrefabsCount; +extern const size_t g_RainbowRoadStartingPrefabsCount; diff --git a/src/Generating/RainbowRoadsGen.cpp b/src/Generating/RainbowRoadsGen.cpp new file mode 100644 index 000000000..d1e1f4bda --- /dev/null +++ b/src/Generating/RainbowRoadsGen.cpp @@ -0,0 +1,115 @@ + +// RainbowRoadsGen.cpp + +// Implements the cRainbowRoadsGen class representing the rainbow road generator + +#include "Globals.h" +#include "RainbowRoadsGen.h" +#include "Prefabs/RainbowRoadPrefabs.h" +#include "PieceGenerator.h" + + + + + +static cPrefabPiecePool g_RainbowRoads(g_RainbowRoadPrefabs, g_RainbowRoadPrefabsCount, g_RainbowRoadStartingPrefabs, g_RainbowRoadStartingPrefabsCount); + + + + + +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// cRainbowRoadsGen::cRainbowRoads: + +class cRainbowRoadsGen::cRainbowRoads : + public cGridStructGen::cStructure +{ + typedef cGridStructGen::cStructure super; + +public: + cRainbowRoads( + int a_Seed, + int a_OriginX, int a_OriginZ, + int a_MaxDepth, + int a_MaxSize + ) : + super(a_OriginX, a_OriginZ), + m_Seed(a_Seed), + m_Noise(a_Seed), + m_MaxSize(a_MaxSize), + m_Borders(a_OriginX - a_MaxSize, 0, a_OriginZ - a_MaxSize, a_OriginX + a_MaxSize, 255, a_OriginZ + a_MaxSize) + { + // Generate the pieces for this base: + cBFSPieceGenerator pg(g_RainbowRoads, a_Seed); + pg.PlacePieces(a_OriginX, 190, a_OriginZ, a_MaxDepth, m_Pieces); + if (m_Pieces.empty()) + { + return; + } + } + + ~cRainbowRoads() + { + cPieceGenerator::FreePieces(m_Pieces); + } + +protected: + /** Seed for the random functions */ + int m_Seed; + + /** The noise used as a pseudo-random generator */ + cNoise m_Noise; + + /** Maximum size, in X/Z blocks, of the village (radius from the origin) */ + int m_MaxSize; + + /** Borders of the vilalge - no item may reach out of this cuboid. */ + cCuboid m_Borders; + + /** The village pieces, placed by the generator. */ + cPlacedPieces m_Pieces; + + + // cGridStructGen::cStructure overrides: + virtual void DrawIntoChunk(cChunkDesc & a_Chunk) override + { + for (cPlacedPieces::iterator itr = m_Pieces.begin(), end = m_Pieces.end(); itr != end; ++itr) + { + cPrefab & Prefab = (cPrefab &)((*itr)->GetPiece()); + Prefab.Draw(a_Chunk, *itr); + } // for itr - m_PlacedPieces[] + } +} ; + + + + + +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// cRainbowRoadsGen: + + + + + +cRainbowRoadsGen::cRainbowRoadsGen(int a_Seed, int a_GridSize, int a_MaxDepth, int a_MaxSize) : + super(a_Seed, a_GridSize, a_GridSize, a_MaxSize, a_MaxSize, 100), + m_Noise(a_Seed + 9000), + m_MaxDepth(a_MaxDepth), + m_MaxSize(a_MaxSize) +{ +} + + + + + +cGridStructGen::cStructurePtr cRainbowRoadsGen::CreateStructure(int a_OriginX, int a_OriginZ) +{ + // Create a base based on the chosen prefabs: + return cStructurePtr(new cRainbowRoads(m_Seed, a_OriginX, a_OriginZ, m_MaxDepth, m_MaxSize)); +} + + + + diff --git a/src/Generating/RainbowRoadsGen.h b/src/Generating/RainbowRoadsGen.h new file mode 100644 index 000000000..acbd5abf9 --- /dev/null +++ b/src/Generating/RainbowRoadsGen.h @@ -0,0 +1,47 @@ + +// RainbowRoadsGen.h + +// Declares the cRainbowRoadsGen class representing the underwater base generator + + + + + +#pragma once + +#include "GridStructGen.h" +#include "PrefabPiecePool.h" + + + + + +class cRainbowRoadsGen : + public cGridStructGen +{ + typedef cGridStructGen super; + +public: + cRainbowRoadsGen(int a_Seed, int a_GridSize, int a_MaxDepth, int a_MaxSize); + +protected: + class cRainbowRoads; // fwd: RainbowRoadsGen.cpp + + + /** The noise used for generating random numbers */ + cNoise m_Noise; + + /** Maximum depth of the generator tree*/ + int m_MaxDepth; + + /** Maximum size, in X/Z blocks, of the base (radius from the origin) */ + int m_MaxSize; + + + // cGridStructGen overrides: + virtual cStructurePtr CreateStructure(int a_OriginX, int a_OriginZ) override; +} ; + + + + -- cgit v1.2.3 From 0544b96f8041e5dd31b4da84b52d23883d0853f0 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 7 Jun 2014 13:59:10 +0200 Subject: docs/Generator: Added the easy Finishers. --- src/Generating/CompoGen.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/Generating/CompoGen.cpp b/src/Generating/CompoGen.cpp index 578bb2481..688d19c40 100644 --- a/src/Generating/CompoGen.cpp +++ b/src/Generating/CompoGen.cpp @@ -561,10 +561,16 @@ void cCompoGenNether::ComposeTerrain(cChunkDesc & a_ChunkDesc) // Interpolate the lowest floor: for (int z = 0; z <= 16 / INTERPOL_Z; z++) for (int x = 0; x <= 16 / INTERPOL_X; x++) { - FloorLo[INTERPOL_X * x + 17 * INTERPOL_Z * z] = + //* + FloorLo[INTERPOL_X * x + 17 * INTERPOL_Z * z] = m_Noise1.IntNoise3DInt(BaseX + INTERPOL_X * x, 0, BaseZ + INTERPOL_Z * z) * m_Noise2.IntNoise3DInt(BaseX + INTERPOL_X * x, 0, BaseZ + INTERPOL_Z * z) / 256; + //*/ + /* + FloorLo[INTERPOL_X * x + 17 * INTERPOL_Z * z] = + m_Noise1.IntNoise3DInt(BaseX + INTERPOL_X * x, 0, BaseZ + INTERPOL_Z * z) / 256; + //*/ } // for x, z - FloorLo[] LinearUpscale2DArrayInPlace<17, 17, INTERPOL_X, INTERPOL_Z>(FloorLo); @@ -574,10 +580,16 @@ void cCompoGenNether::ComposeTerrain(cChunkDesc & a_ChunkDesc) // First update the high floor: for (int z = 0; z <= 16 / INTERPOL_Z; z++) for (int x = 0; x <= 16 / INTERPOL_X; x++) { + //* FloorHi[INTERPOL_X * x + 17 * INTERPOL_Z * z] = m_Noise1.IntNoise3DInt(BaseX + INTERPOL_X * x, Segment + SEGMENT_HEIGHT, BaseZ + INTERPOL_Z * z) * m_Noise2.IntNoise3DInt(BaseX + INTERPOL_Z * x, Segment + SEGMENT_HEIGHT, BaseZ + INTERPOL_Z * z) / 256; + //*/ + /* + FloorHi[INTERPOL_X * x + 17 * INTERPOL_Z * z] = + m_Noise1.IntNoise3DInt(BaseX + INTERPOL_X * x, Segment + SEGMENT_HEIGHT, BaseZ + INTERPOL_Z * z) / 256; + //*/ } // for x, z - FloorLo[] LinearUpscale2DArrayInPlace<17, 17, INTERPOL_X, INTERPOL_Z>(FloorHi); -- cgit v1.2.3 From 28b82d5bbb4a0c7df901bea9e9f65a66186379ec Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sun, 8 Jun 2014 11:32:52 +0200 Subject: Proper fix for long interaction. Fixes #1078 and #1038. --- src/ClientHandle.cpp | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index d47ceff0e..77f3b274a 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -1089,18 +1089,25 @@ void cClientHandle::HandleRightClick(int a_BlockX, int a_BlockY, int a_BlockZ, e cWorld * World = m_Player->GetWorld(); if ( - (Diff(m_Player->GetPosX(), (double)a_BlockX) > 6) || - (Diff(m_Player->GetPosY(), (double)a_BlockY) > 6) || - (Diff(m_Player->GetPosZ(), (double)a_BlockZ) > 6) + (a_BlockFace != BLOCK_FACE_NONE) && // The client is interacting with a specific block + ( + (Diff(m_Player->GetPosX(), (double)a_BlockX) > 6) || // The block is too far away + (Diff(m_Player->GetPosY(), (double)a_BlockY) > 6) || + (Diff(m_Player->GetPosZ(), (double)a_BlockZ) > 6) + ) ) { - if (a_BlockFace != BLOCK_FACE_NONE) + AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace); + World->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, m_Player); + if (a_BlockY < cChunkDef::Height - 1) { - AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace); - World->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, m_Player); World->SendBlockTo(a_BlockX, a_BlockY + 1, a_BlockZ, m_Player); // 2 block high things - m_Player->GetInventory().SendEquippedSlot(); } + if (a_BlockY > 0) + { + World->SendBlockTo(a_BlockX, a_BlockY - 1, a_BlockZ, m_Player); // 2 block high things + } + m_Player->GetInventory().SendEquippedSlot(); return; } -- cgit v1.2.3 From b904223b9dbbe7b696dbd30e748bc131742e11ea Mon Sep 17 00:00:00 2001 From: Mattes D Date: Fri, 6 Jun 2014 22:31:16 +0200 Subject: Added queue for adding entities to cWorld. This alone doesn't work properly yet, further changes to cPlayer are needed. --- src/ClientHandle.h | 3 ++- src/Entities/Entity.h | 5 +++-- src/Entities/Player.cpp | 2 -- src/Entities/Player.h | 2 ++ src/World.cpp | 28 +++++++++++++++++++++++++++- src/World.h | 9 ++++++++- 6 files changed, 42 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/ClientHandle.h b/src/ClientHandle.h index 659c67658..3f1cdf55a 100644 --- a/src/ClientHandle.h +++ b/src/ClientHandle.h @@ -250,7 +250,8 @@ public: void SendData(const char * a_Data, size_t a_Size); - /** Called when the player moves into a different world; queues sreaming the new chunks */ + /** Called when the player moves into a different world. + Locks the current world, doesn't lock the new world. */ void MoveToWorld(cWorld & a_World, bool a_SendRespawnPacket); /** Called when the player will enchant a Item */ diff --git a/src/Entities/Entity.h b/src/Entities/Entity.h index 0c393c0f5..9fe771120 100644 --- a/src/Entities/Entity.h +++ b/src/Entities/Entity.h @@ -421,6 +421,9 @@ public: UNUSED(a_Killer); } + /** Sets the internal world pointer to a new cWorld, doesn't update anything else. */ + void SetWorld(cWorld * a_World) { m_World = a_World; } + protected: static cCriticalSection m_CSCount; static int m_EntityCount; @@ -485,8 +488,6 @@ protected: virtual void Destroyed(void) {} // Called after the entity has been destroyed - void SetWorld(cWorld * a_World) { m_World = a_World; } - /** Called in each tick to handle air-related processing i.e. drowning */ virtual void HandleAir(); diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index 3a9324d09..b83419903 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -1595,8 +1595,6 @@ bool cPlayer::MoveToWorld(const char * a_WorldName) m_ClientHandle->MoveToWorld(*World, (OldDimension != World->GetDimension())); // Add player to all the necessary parts of the new world - SetWorld(World); - m_ClientHandle->StreamChunks(); World->AddEntity(this); World->AddPlayer(this); diff --git a/src/Entities/Player.h b/src/Entities/Player.h index b7cb27d6c..83b9ad593 100644 --- a/src/Entities/Player.h +++ b/src/Entities/Player.h @@ -328,6 +328,8 @@ public: void SetVisible( bool a_bVisible ); // tolua_export bool IsVisible(void) const { return m_bVisible; } // tolua_export + /** Moves the player to the specified world. + Returns true if successful, false on failure (world not found). */ bool MoveToWorld(const char * a_WorldName); // tolua_export bool SaveToDisk(void); diff --git a/src/World.cpp b/src/World.cpp index 88e9c32e6..ccd47d3b0 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -743,6 +743,17 @@ void cWorld::Tick(float a_Dt, int a_LastTickDurationMSec) m_LastTimeUpdate = m_WorldAge; } + // Add entities waiting in the queue to be added: + { + cCSLock Lock(m_CSEntitiesToAdd); + for (cEntityList::iterator itr = m_EntitiesToAdd.begin(), end = m_EntitiesToAdd.end(); itr != end; ++itr) + { + (*itr)->SetWorld(this); + m_ChunkMap->AddEntity(*itr); + } + m_EntitiesToAdd.clear(); + } + m_ChunkMap->Tick(a_Dt); TickClients(a_Dt); @@ -2808,9 +2819,11 @@ void cWorld::ScheduleTask(int a_DelayTicks, cTask * a_Task) + void cWorld::AddEntity(cEntity * a_Entity) { - m_ChunkMap->AddEntity(a_Entity); + cCSLock Lock(m_CSEntitiesToAdd); + m_EntitiesToAdd.push_back(a_Entity); } @@ -2819,6 +2832,19 @@ void cWorld::AddEntity(cEntity * a_Entity) bool cWorld::HasEntity(int a_UniqueID) { + // Check if the entity is in the queue to be added to the world: + { + cCSLock Lock(m_CSEntitiesToAdd); + for (cEntityList::const_iterator itr = m_EntitiesToAdd.begin(), end = m_EntitiesToAdd.end(); itr != end; ++itr) + { + if ((*itr)->GetUniqueID() == a_UniqueID) + { + return true; + } + } // for itr - m_EntitiesToAdd[] + } + + // Check if the entity is in the chunkmap: return m_ChunkMap->HasEntity(a_UniqueID); } diff --git a/src/World.h b/src/World.h index 98b241a2b..4c014a976 100644 --- a/src/World.h +++ b/src/World.h @@ -301,7 +301,8 @@ public: void SendPlayerList(cPlayer * a_DestPlayer); // Sends playerlist to the player - /** Adds the entity into its appropriate chunk; takes ownership of the entity ptr */ + /** Adds the entity into its appropriate chunk; takes ownership of the entity ptr. + The entity is added lazily - this function only puts it in a queue that is then processed by the Tick thread. */ void AddEntity(cEntity * a_Entity); bool HasEntity(int a_UniqueID); @@ -926,6 +927,12 @@ private: /** Clients that are scheduled for adding, waiting for TickClients to add them */ cClientHandleList m_ClientsToAdd; + /** Guards m_EntitiesToAdd */ + cCriticalSection m_CSEntitiesToAdd; + + /** List of entities that are scheduled for adding, waiting for the Tick thread to add them. */ + cEntityList m_EntitiesToAdd; + cWorld(const AString & a_WorldName); virtual ~cWorld(); -- cgit v1.2.3 From af4a21ea0689107b377818574cb07dc4a2e8b755 Mon Sep 17 00:00:00 2001 From: Mattes D Date: Sun, 8 Jun 2014 21:58:08 +0200 Subject: Fixed deadlock when moving players to other worlds. Fixes #1039, fixes #851 --- src/BlockID.h | 1 + src/ClientHandle.cpp | 21 ++----- src/ClientHandle.h | 6 +- src/Entities/Entity.cpp | 10 ++-- src/Entities/Entity.h | 5 +- src/Entities/Player.cpp | 18 +++--- src/Items/ItemBoat.h | 2 +- src/Items/ItemBow.h | 2 +- src/Items/ItemFishingRod.h | 2 +- src/Items/ItemItemFrame.h | 2 +- src/Items/ItemMinecart.h | 2 +- src/Items/ItemPainting.h | 2 +- src/Mobs/Blaze.cpp | 2 +- src/Mobs/Ghast.cpp | 2 +- src/Mobs/Skeleton.cpp | 2 +- src/Mobs/Wither.cpp | 2 +- src/Mobs/Wither.h | 2 +- src/OSSupport/IsThread.cpp | 21 ++++++- src/OSSupport/IsThread.h | 4 ++ src/Protocol/Protocol.h | 2 +- src/Protocol/Protocol125.cpp | 15 ++++- src/Protocol/Protocol125.h | 6 +- src/Protocol/Protocol132.cpp | 2 +- src/Protocol/Protocol16x.cpp | 4 +- src/Protocol/Protocol16x.h | 2 +- src/Protocol/Protocol17x.cpp | 15 ++++- src/Protocol/Protocol17x.h | 6 +- src/Protocol/ProtocolRecognizer.cpp | 4 +- src/Protocol/ProtocolRecognizer.h | 2 +- src/Simulator/SandSimulator.cpp | 2 +- src/World.cpp | 111 ++++++++++++++++++++++++++---------- src/World.h | 21 ++++++- 32 files changed, 204 insertions(+), 96 deletions(-) (limited to 'src') diff --git a/src/BlockID.h b/src/BlockID.h index a227245aa..272fd319d 100644 --- a/src/BlockID.h +++ b/src/BlockID.h @@ -790,6 +790,7 @@ enum eDimension dimNether = -1, dimOverworld = 0, dimEnd = 1, + dimNotSet = 255, // For things that need an "indeterminate" state, such as cProtocol's LastSentDimension } ; diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index 77f3b274a..e4bb9d8e9 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -327,7 +327,7 @@ void cClientHandle::Authenticate(const AString & a_Name, const AString & a_UUID) // Send experience m_Player->SendExperience(); - m_Player->Initialize(World); + m_Player->Initialize(*World); m_State = csAuthenticated; // Query player team @@ -356,7 +356,7 @@ void cClientHandle::StreamChunks(void) } ASSERT(m_Player != NULL); - + int ChunkPosX = FAST_FLOOR_DIV((int)m_Player->GetPosX(), cChunkDef::Width); int ChunkPosZ = FAST_FLOOR_DIV((int)m_Player->GetPosZ(), cChunkDef::Width); if ((ChunkPosX == m_LastStreamedChunkX) && (ChunkPosZ == m_LastStreamedChunkZ)) @@ -1753,18 +1753,8 @@ void cClientHandle::SendData(const char * a_Data, size_t a_Size) -void cClientHandle::MoveToWorld(cWorld & a_World, bool a_SendRespawnPacket) +void cClientHandle::RemoveFromWorld(void) { - UNUSED(a_World); - ASSERT(m_Player != NULL); - - if (a_SendRespawnPacket) - { - SendRespawn(); - } - - cWorld * World = m_Player->GetWorld(); - // Remove all associated chunks: cChunkCoordsList Chunks; { @@ -1774,7 +1764,6 @@ void cClientHandle::MoveToWorld(cWorld & a_World, bool a_SendRespawnPacket) } for (cChunkCoordsList::iterator itr = Chunks.begin(), end = Chunks.end(); itr != end; ++itr) { - World->RemoveChunkClient(itr->m_ChunkX, itr->m_ChunkZ, this); m_Protocol->SendUnloadChunk(itr->m_ChunkX, itr->m_ChunkZ); } // for itr - Chunks[] @@ -2379,9 +2368,9 @@ void cClientHandle::SendRemoveEntityEffect(const cEntity & a_Entity, int a_Effec -void cClientHandle::SendRespawn(void) +void cClientHandle::SendRespawn(const cWorld & a_World) { - m_Protocol->SendRespawn(); + m_Protocol->SendRespawn(a_World); } diff --git a/src/ClientHandle.h b/src/ClientHandle.h index 3f1cdf55a..0d883f3af 100644 --- a/src/ClientHandle.h +++ b/src/ClientHandle.h @@ -149,7 +149,7 @@ public: void SendPlayerSpawn (const cPlayer & a_Player); void SendPluginMessage (const AString & a_Channel, const AString & a_Message); // Exported in ManualBindings.cpp void SendRemoveEntityEffect (const cEntity & a_Entity, int a_EffectID); - void SendRespawn (void); + void SendRespawn (const cWorld & a_World); void SendExperience (void); void SendExperienceOrb (const cExpOrb & a_ExpOrb); void SendScoreboardObjective (const AString & a_Name, const AString & a_DisplayName, Byte a_Mode); @@ -251,8 +251,8 @@ public: void SendData(const char * a_Data, size_t a_Size); /** Called when the player moves into a different world. - Locks the current world, doesn't lock the new world. */ - void MoveToWorld(cWorld & a_World, bool a_SendRespawnPacket); + Sends an UnloadChunk packet for each loaded chunk and resets the streamed chunks. */ + void RemoveFromWorld(void); /** Called when the player will enchant a Item */ void HandleEnchantItem(Byte & WindowID, Byte & Enchantment); diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index 1226a2319..8f736a269 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -129,9 +129,9 @@ const char * cEntity::GetParentClass(void) const -bool cEntity::Initialize(cWorld * a_World) +bool cEntity::Initialize(cWorld & a_World) { - if (cPluginManager::Get()->CallHookSpawningEntity(*a_World, *this)) + if (cPluginManager::Get()->CallHookSpawningEntity(a_World, *this)) { return false; } @@ -144,13 +144,13 @@ bool cEntity::Initialize(cWorld * a_World) */ m_IsInitialized = true; - m_World = a_World; + m_World = &a_World; m_World->AddEntity(this); - cPluginManager::Get()->CallHookSpawnedEntity(*a_World, *this); + cPluginManager::Get()->CallHookSpawnedEntity(a_World, *this); // Spawn the entity on the clients: - a_World->BroadcastSpawnEntity(*this); + a_World.BroadcastSpawnEntity(*this); return true; } diff --git a/src/Entities/Entity.h b/src/Entities/Entity.h index 9fe771120..85ad42d54 100644 --- a/src/Entities/Entity.h +++ b/src/Entities/Entity.h @@ -146,8 +146,9 @@ public: cEntity(eEntityType a_EntityType, double a_X, double a_Y, double a_Z, double a_Width, double a_Height); virtual ~cEntity(); - /// Spawns the entity in the world; returns true if spawned, false if not (plugin disallowed) - virtual bool Initialize(cWorld * a_World); + /** Spawns the entity in the world; returns true if spawned, false if not (plugin disallowed). + Adds the entity to the world. */ + virtual bool Initialize(cWorld & a_World); // tolua_begin diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index b83419903..feb09b5d2 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -940,6 +940,8 @@ void cPlayer::Killed(cEntity * a_Victim) void cPlayer::Respawn(void) { + ASSERT(m_World != NULL); + m_Health = GetMaxHealth(); SetInvulnerableTicks(20); @@ -952,7 +954,7 @@ void cPlayer::Respawn(void) m_LifetimeTotalXp = 0; // ToDo: send score to client? How? - m_ClientHandle->SendRespawn(); + m_ClientHandle->SendRespawn(*m_World); // Extinguish the fire: StopBurning(); @@ -1583,19 +1585,19 @@ bool cPlayer::MoveToWorld(const char * a_WorldName) return false; } - eDimension OldDimension = m_World->GetDimension(); - + // Send the respawn packet: + if (m_ClientHandle != NULL) + { + m_ClientHandle->SendRespawn(*World); + } + // Remove all links to the old world m_World->RemovePlayer(this); - m_ClientHandle->RemoveFromAllChunks(); - m_World->RemoveEntity(this); // If the dimension is different, we can send the respawn packet // http://wiki.vg/Protocol#0x09 says "don't send if dimension is the same" as of 2013_07_02 - m_ClientHandle->MoveToWorld(*World, (OldDimension != World->GetDimension())); - // Add player to all the necessary parts of the new world - World->AddEntity(this); + // Queue adding player to the new world, including all the necessary adjustments to the object World->AddPlayer(this); return true; diff --git a/src/Items/ItemBoat.h b/src/Items/ItemBoat.h index 42f4ffc8f..7faac1e32 100644 --- a/src/Items/ItemBoat.h +++ b/src/Items/ItemBoat.h @@ -75,7 +75,7 @@ public: double z = Callbacks.m_Pos.z; cBoat * Boat = new cBoat(x + 0.5, y + 1, z + 0.5); - Boat->Initialize(a_World); + Boat->Initialize(*a_World); return true; } diff --git a/src/Items/ItemBow.h b/src/Items/ItemBow.h index 8c0b3a0a3..e0ab339d3 100644 --- a/src/Items/ItemBow.h +++ b/src/Items/ItemBow.h @@ -66,7 +66,7 @@ public: { return; } - if (!Arrow->Initialize(a_Player->GetWorld())) + if (!Arrow->Initialize(*a_Player->GetWorld())) { delete Arrow; return; diff --git a/src/Items/ItemFishingRod.h b/src/Items/ItemFishingRod.h index 32c151db5..3b1ad1717 100644 --- a/src/Items/ItemFishingRod.h +++ b/src/Items/ItemFishingRod.h @@ -231,7 +231,7 @@ public: else { cFloater * Floater = new cFloater(a_Player->GetPosX(), a_Player->GetStance(), a_Player->GetPosZ(), a_Player->GetLookVector() * 15, a_Player->GetUniqueID(), 100 + a_World->GetTickRandomNumber(800) - (a_Player->GetEquippedItem().m_Enchantments.GetLevel(cEnchantments::enchLure) * 100)); - Floater->Initialize(a_World); + Floater->Initialize(*a_World); a_Player->SetIsFishing(true, Floater->GetUniqueID()); } return true; diff --git a/src/Items/ItemItemFrame.h b/src/Items/ItemItemFrame.h index 27e7dba35..097f04d0b 100644 --- a/src/Items/ItemItemFrame.h +++ b/src/Items/ItemItemFrame.h @@ -34,7 +34,7 @@ public: if (Block == E_BLOCK_AIR) { cItemFrame * ItemFrame = new cItemFrame(a_Dir, a_BlockX, a_BlockY, a_BlockZ); - if (!ItemFrame->Initialize(a_World)) + if (!ItemFrame->Initialize(*a_World)) { delete ItemFrame; return false; diff --git a/src/Items/ItemMinecart.h b/src/Items/ItemMinecart.h index 4e7d8fcff..63038de51 100644 --- a/src/Items/ItemMinecart.h +++ b/src/Items/ItemMinecart.h @@ -70,7 +70,7 @@ public: return false; } } // switch (m_ItemType) - Minecart->Initialize(a_World); + Minecart->Initialize(*a_World); if (!a_Player->IsGameModeCreative()) { diff --git a/src/Items/ItemPainting.h b/src/Items/ItemPainting.h index b85098221..e4bb76ebe 100644 --- a/src/Items/ItemPainting.h +++ b/src/Items/ItemPainting.h @@ -79,7 +79,7 @@ public: }; cPainting * Painting = new cPainting(gPaintingTitlesList[a_World->GetTickRandomNumber(ARRAYCOUNT(gPaintingTitlesList) - 1)].Title, Dir, a_BlockX, a_BlockY, a_BlockZ); - Painting->Initialize(a_World); + Painting->Initialize(*a_World); if (!a_Player->IsGameModeCreative()) { diff --git a/src/Mobs/Blaze.cpp b/src/Mobs/Blaze.cpp index 2a6a761bf..19bdf8737 100644 --- a/src/Mobs/Blaze.cpp +++ b/src/Mobs/Blaze.cpp @@ -44,7 +44,7 @@ void cBlaze::Attack(float a_Dt) { return; } - if (!FireCharge->Initialize(m_World)) + if (!FireCharge->Initialize(*m_World)) { delete FireCharge; return; diff --git a/src/Mobs/Ghast.cpp b/src/Mobs/Ghast.cpp index d8a7663f8..4df8e165c 100644 --- a/src/Mobs/Ghast.cpp +++ b/src/Mobs/Ghast.cpp @@ -46,7 +46,7 @@ void cGhast::Attack(float a_Dt) { return; } - if (!GhastBall->Initialize(m_World)) + if (!GhastBall->Initialize(*m_World)) { delete GhastBall; return; diff --git a/src/Mobs/Skeleton.cpp b/src/Mobs/Skeleton.cpp index 1e62d7987..e7f3971cc 100644 --- a/src/Mobs/Skeleton.cpp +++ b/src/Mobs/Skeleton.cpp @@ -81,7 +81,7 @@ void cSkeleton::Attack(float a_Dt) { return; } - if (!Arrow->Initialize(m_World)) + if (!Arrow->Initialize(*m_World)) { delete Arrow; return; diff --git a/src/Mobs/Wither.cpp b/src/Mobs/Wither.cpp index 170f4fdc0..da4cc7765 100644 --- a/src/Mobs/Wither.cpp +++ b/src/Mobs/Wither.cpp @@ -30,7 +30,7 @@ bool cWither::IsArmored(void) const -bool cWither::Initialize(cWorld * a_World) +bool cWither::Initialize(cWorld & a_World) { // Set health before BroadcastSpawnEntity() SetHealth(GetMaxHealth() / 3); diff --git a/src/Mobs/Wither.h b/src/Mobs/Wither.h index 93b4f8bfc..03a320788 100644 --- a/src/Mobs/Wither.h +++ b/src/Mobs/Wither.h @@ -25,7 +25,7 @@ public: bool IsArmored(void) const; // cEntity overrides - virtual bool Initialize(cWorld * a_World) override; + virtual bool Initialize(cWorld & a_World) override; virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; virtual bool DoTakeDamage(TakeDamageInfo & a_TDI) override; virtual void Tick(float a_Dt, cChunk & a_Chunk) override; diff --git a/src/OSSupport/IsThread.cpp b/src/OSSupport/IsThread.cpp index 04fc818e4..67f336c97 100644 --- a/src/OSSupport/IsThread.cpp +++ b/src/OSSupport/IsThread.cpp @@ -60,6 +60,9 @@ static void SetThreadName(DWORD dwThreadID, const char * threadName) cIsThread::cIsThread(const AString & iThreadName) : m_ShouldTerminate(false), m_ThreadName(iThreadName), + #ifdef _WIN32 + m_ThreadID(0), + #endif m_Handle(NULL_HANDLE) { } @@ -83,8 +86,8 @@ bool cIsThread::Start(void) ASSERT(m_Handle == NULL_HANDLE); // Has already started one thread? #ifdef _WIN32 // Create the thread suspended, so that the mHandle variable is valid in the thread procedure - DWORD ThreadID = 0; - m_Handle = CreateThread(NULL, 0, thrExecute, this, CREATE_SUSPENDED, &ThreadID); + m_ThreadID = 0; + m_Handle = CreateThread(NULL, 0, thrExecute, this, CREATE_SUSPENDED, &m_ThreadID); if (m_Handle == NULL) { LOGERROR("ERROR: Could not create thread \"%s\", GLE = %d!", m_ThreadName.c_str(), GetLastError()); @@ -96,7 +99,7 @@ bool cIsThread::Start(void) // Thread naming is available only in MSVC if (!m_ThreadName.empty()) { - SetThreadName(ThreadID, m_ThreadName.c_str()); + SetThreadName(m_ThreadID, m_ThreadName.c_str()); } #endif // _DEBUG and _MSC_VER @@ -177,3 +180,15 @@ unsigned long cIsThread::GetCurrentID(void) +bool cIsThread::IsCurrentThread(void) const +{ + #ifdef _WIN32 + return (GetCurrentThreadId() == m_ThreadID); + #else + return (m_Handle == pthread_self()); + #endif +} + + + + diff --git a/src/OSSupport/IsThread.h b/src/OSSupport/IsThread.h index 57651a490..c20fc3e7e 100644 --- a/src/OSSupport/IsThread.h +++ b/src/OSSupport/IsThread.h @@ -48,6 +48,9 @@ public: /// Returns the OS-dependent thread ID for the caller's thread static unsigned long GetCurrentID(void); + /** Returns true if the thread calling this function is the thread contained within this object. */ + bool IsCurrentThread(void) const; + protected: AString m_ThreadName; @@ -60,6 +63,7 @@ protected: #ifdef _WIN32 + DWORD m_ThreadID; HANDLE m_Handle; static DWORD __stdcall thrExecute(LPVOID a_Param) diff --git a/src/Protocol/Protocol.h b/src/Protocol/Protocol.h index a543c6361..c6e569919 100644 --- a/src/Protocol/Protocol.h +++ b/src/Protocol/Protocol.h @@ -100,7 +100,7 @@ public: virtual void SendPlayerSpawn (const cPlayer & a_Player) = 0; virtual void SendPluginMessage (const AString & a_Channel, const AString & a_Message) = 0; virtual void SendRemoveEntityEffect (const cEntity & a_Entity, int a_EffectID) = 0; - virtual void SendRespawn (void) = 0; + virtual void SendRespawn (const cWorld & a_World) = 0; virtual void SendExperience (void) = 0; virtual void SendExperienceOrb (const cExpOrb & a_ExpOrb) = 0; virtual void SendScoreboardObjective (const AString & a_Name, const AString & a_DisplayName, Byte a_Mode) = 0; diff --git a/src/Protocol/Protocol125.cpp b/src/Protocol/Protocol125.cpp index f3bdae3ac..491058919 100644 --- a/src/Protocol/Protocol125.cpp +++ b/src/Protocol/Protocol125.cpp @@ -133,7 +133,8 @@ typedef unsigned char Byte; cProtocol125::cProtocol125(cClientHandle * a_Client) : super(a_Client), - m_ReceivedData(32 KiB) + m_ReceivedData(32 KiB), + m_LastSentDimension(dimNotSet) { } @@ -591,6 +592,7 @@ void cProtocol125::SendLogin(const cPlayer & a_Player, const cWorld & a_World) WriteByte (0); // Unused WriteByte (60); // Client list width or something Flush(); + m_LastSentDimension = a_World.GetDimension(); } @@ -831,16 +833,23 @@ void cProtocol125::SendRemoveEntityEffect(const cEntity & a_Entity, int a_Effect -void cProtocol125::SendRespawn(void) +void cProtocol125::SendRespawn(const cWorld & a_World) { cCSLock Lock(m_CSPacket); + if (m_LastSentDimension == a_World.GetDimension()) + { + // Must not send a respawn for the world with the same dimension, the client goes cuckoo if we do + return; + } cPlayer * Player = m_Client->GetPlayer(); WriteByte (PACKET_RESPAWN); - WriteInt ((int)(Player->GetWorld()->GetDimension())); + WriteInt (a_World.GetDimension()); WriteByte (2); // TODO: Difficulty; 2 = Normal WriteChar ((char)Player->GetGameMode()); WriteShort (256); // Current world height WriteString("default"); + Flush(); + m_LastSentDimension = a_World.GetDimension(); } diff --git a/src/Protocol/Protocol125.h b/src/Protocol/Protocol125.h index 18a626a2d..85418f71f 100644 --- a/src/Protocol/Protocol125.h +++ b/src/Protocol/Protocol125.h @@ -72,7 +72,7 @@ public: virtual void SendPlayerSpawn (const cPlayer & a_Player) override; virtual void SendPluginMessage (const AString & a_Channel, const AString & a_Message) override; virtual void SendRemoveEntityEffect (const cEntity & a_Entity, int a_EffectID) override; - virtual void SendRespawn (void) override; + virtual void SendRespawn (const cWorld & a_World) override; virtual void SendExperience (void) override; virtual void SendExperienceOrb (const cExpOrb & a_ExpOrb) override; virtual void SendScoreboardObjective (const AString & a_Name, const AString & a_DisplayName, Byte a_Mode) override; @@ -113,6 +113,10 @@ protected: cByteBuffer m_ReceivedData; ///< Buffer for the received data AString m_Username; ///< Stored in ParseHandshake(), compared to Login username + + /** The dimension that was last sent to a player in a Respawn or Login packet. + Used to avoid Respawning into the same dimension, which confuses the client. */ + eDimension m_LastSentDimension; virtual void SendData(const char * a_Data, size_t a_Size) override; diff --git a/src/Protocol/Protocol132.cpp b/src/Protocol/Protocol132.cpp index f4717f592..1e3fc8de8 100644 --- a/src/Protocol/Protocol132.cpp +++ b/src/Protocol/Protocol132.cpp @@ -253,7 +253,7 @@ void cProtocol132::SendLogin(const cPlayer & a_Player, const cWorld & a_World) WriteByte (0); // Unused, used to be world height WriteByte (8); // Client list width or something Flush(); - + m_LastSentDimension = a_World.GetDimension(); SendCompass(a_World); } diff --git a/src/Protocol/Protocol16x.cpp b/src/Protocol/Protocol16x.cpp index 714bf5e46..9e0f3f852 100644 --- a/src/Protocol/Protocol16x.cpp +++ b/src/Protocol/Protocol16x.cpp @@ -158,10 +158,10 @@ void cProtocol161::SendPlayerMaxSpeed(void) -void cProtocol161::SendRespawn(void) +void cProtocol161::SendRespawn(const cWorld & a_World) { // Besides sending the respawn, we need to also send the player max speed, otherwise the client reverts to super-fast - super::SendRespawn(); + super::SendRespawn(a_World); SendPlayerMaxSpeed(); } diff --git a/src/Protocol/Protocol16x.h b/src/Protocol/Protocol16x.h index 8eedce8d5..e91dc8a1c 100644 --- a/src/Protocol/Protocol16x.h +++ b/src/Protocol/Protocol16x.h @@ -42,7 +42,7 @@ protected: virtual void SendGameMode (eGameMode a_GameMode) override; virtual void SendHealth (void) override; virtual void SendPlayerMaxSpeed(void) override; - virtual void SendRespawn (void) override; + virtual void SendRespawn (const cWorld & a_World) override; virtual void SendWindowOpen (const cWindow & a_Window) override; virtual int ParseEntityAction (void) override; diff --git a/src/Protocol/Protocol17x.cpp b/src/Protocol/Protocol17x.cpp index f7564fe6d..02c577dc8 100644 --- a/src/Protocol/Protocol17x.cpp +++ b/src/Protocol/Protocol17x.cpp @@ -92,7 +92,8 @@ cProtocol172::cProtocol172(cClientHandle * a_Client, const AString & a_ServerAdd m_ReceivedData(32 KiB), m_OutPacketBuffer(64 KiB), m_OutPacketLenBuffer(20), // 20 bytes is more than enough for one VarInt - m_IsEncrypted(false) + m_IsEncrypted(false), + m_LastSentDimension(dimNotSet) { // Create the comm log file, if so requested: if (g_ShouldLogCommIn || g_ShouldLogCommOut) @@ -656,6 +657,7 @@ void cProtocol172::SendLogin(const cPlayer & a_Player, const cWorld & a_World) Pkt.WriteByte(std::min(Server->GetMaxPlayers(), 60)); Pkt.WriteString("default"); // Level type - wtf? } + m_LastSentDimension = a_World.GetDimension(); // Send the spawn position: { @@ -984,14 +986,21 @@ void cProtocol172::SendRemoveEntityEffect(const cEntity & a_Entity, int a_Effect -void cProtocol172::SendRespawn(void) +void cProtocol172::SendRespawn(const cWorld & a_World) { + if (m_LastSentDimension == a_World.GetDimension()) + { + // Must not send a respawn for the world with the same dimension, the client goes cuckoo if we do + return; + } + cPacketizer Pkt(*this, 0x07); // Respawn packet cPlayer * Player = m_Client->GetPlayer(); - Pkt.WriteInt(Player->GetWorld()->GetDimension()); + Pkt.WriteInt(a_World.GetDimension()); Pkt.WriteByte(2); // TODO: Difficulty (set to Normal) Pkt.WriteByte((Byte)Player->GetEffectiveGameMode()); Pkt.WriteString("default"); + m_LastSentDimension = a_World.GetDimension(); } diff --git a/src/Protocol/Protocol17x.h b/src/Protocol/Protocol17x.h index 3c6a8c085..8be1d9211 100644 --- a/src/Protocol/Protocol17x.h +++ b/src/Protocol/Protocol17x.h @@ -104,7 +104,7 @@ public: virtual void SendPlayerSpawn (const cPlayer & a_Player) override; virtual void SendPluginMessage (const AString & a_Channel, const AString & a_Message) override; virtual void SendRemoveEntityEffect (const cEntity & a_Entity, int a_EffectID) override; - virtual void SendRespawn (void) override; + virtual void SendRespawn (const cWorld & a_World) override; virtual void SendSoundEffect (const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch) override; // a_Src coords are Block * 8 virtual void SendExperience (void) override; virtual void SendExperienceOrb (const cExpOrb & a_ExpOrb) override; @@ -244,6 +244,10 @@ protected: /** The logfile where the comm is logged, when g_ShouldLogComm is true */ cFile m_CommLogFile; + /** The dimension that was last sent to a player in a Respawn or Login packet. + Used to avoid Respawning into the same dimension, which confuses the client. */ + eDimension m_LastSentDimension; + /** Adds the received (unencrypted) data to m_ReceivedData, parses complete packets */ void AddReceivedData(const char * a_Data, size_t a_Size); diff --git a/src/Protocol/ProtocolRecognizer.cpp b/src/Protocol/ProtocolRecognizer.cpp index b0cbb6def..35a331f43 100644 --- a/src/Protocol/ProtocolRecognizer.cpp +++ b/src/Protocol/ProtocolRecognizer.cpp @@ -555,10 +555,10 @@ void cProtocolRecognizer::SendRemoveEntityEffect(const cEntity & a_Entity, int a -void cProtocolRecognizer::SendRespawn(void) +void cProtocolRecognizer::SendRespawn(const cWorld & a_World) { ASSERT(m_Protocol != NULL); - m_Protocol->SendRespawn(); + m_Protocol->SendRespawn(a_World); } diff --git a/src/Protocol/ProtocolRecognizer.h b/src/Protocol/ProtocolRecognizer.h index 3a291bf7a..5e178447c 100644 --- a/src/Protocol/ProtocolRecognizer.h +++ b/src/Protocol/ProtocolRecognizer.h @@ -107,7 +107,7 @@ public: virtual void SendPlayerSpawn (const cPlayer & a_Player) override; virtual void SendPluginMessage (const AString & a_Channel, const AString & a_Message) override; virtual void SendRemoveEntityEffect (const cEntity & a_Entity, int a_EffectID) override; - virtual void SendRespawn (void) override; + virtual void SendRespawn (const cWorld & a_World) override; virtual void SendExperience (void) override; virtual void SendExperienceOrb (const cExpOrb & a_ExpOrb) override; virtual void SendScoreboardObjective (const AString & a_Name, const AString & a_DisplayName, Byte a_Mode) override; diff --git a/src/Simulator/SandSimulator.cpp b/src/Simulator/SandSimulator.cpp index b8f34559f..1380f8841 100644 --- a/src/Simulator/SandSimulator.cpp +++ b/src/Simulator/SandSimulator.cpp @@ -60,7 +60,7 @@ void cSandSimulator::SimulateChunk(float a_Dt, int a_ChunkX, int a_ChunkZ, cChun ); */ cFallingBlock * FallingBlock = new cFallingBlock(Pos, BlockType, a_Chunk->GetMeta(itr->x, itr->y, itr->z)); - FallingBlock->Initialize(&m_World); + FallingBlock->Initialize(m_World); a_Chunk->SetBlock(itr->x, itr->y, itr->z, E_BLOCK_AIR, 0); } } diff --git a/src/World.cpp b/src/World.cpp index ccd47d3b0..ebe6b53e6 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -754,6 +754,9 @@ void cWorld::Tick(float a_Dt, int a_LastTickDurationMSec) m_EntitiesToAdd.clear(); } + // Add players waiting in the queue to be added: + AddQueuedPlayers(); + m_ChunkMap->Tick(a_Dt); TickClients(a_Dt); @@ -1642,7 +1645,7 @@ void cWorld::SpawnItemPickups(const cItems & a_Pickups, double a_BlockX, double a_BlockX, a_BlockY, a_BlockZ, *itr, IsPlayerCreated, SpeedX, SpeedY, SpeedZ ); - Pickup->Initialize(this); + Pickup->Initialize(*this); } } @@ -1663,7 +1666,7 @@ void cWorld::SpawnItemPickups(const cItems & a_Pickups, double a_BlockX, double a_BlockX, a_BlockY, a_BlockZ, *itr, IsPlayerCreated, (float)a_SpeedX, (float)a_SpeedY, (float)a_SpeedZ ); - Pickup->Initialize(this); + Pickup->Initialize(*this); } } @@ -1674,7 +1677,7 @@ void cWorld::SpawnItemPickups(const cItems & a_Pickups, double a_BlockX, double int cWorld::SpawnFallingBlock(int a_X, int a_Y, int a_Z, BLOCKTYPE BlockType, NIBBLETYPE BlockMeta) { cFallingBlock * FallingBlock = new cFallingBlock(Vector3i(a_X, a_Y, a_Z), BlockType, BlockMeta); - FallingBlock->Initialize(this); + FallingBlock->Initialize(*this); return FallingBlock->GetUniqueID(); } @@ -1690,7 +1693,7 @@ int cWorld::SpawnExperienceOrb(double a_X, double a_Y, double a_Z, int a_Reward) } cExpOrb * ExpOrb = new cExpOrb(a_X, a_Y, a_Z, a_Reward); - ExpOrb->Initialize(this); + ExpOrb->Initialize(*this); return ExpOrb->GetUniqueID(); } @@ -1713,7 +1716,7 @@ int cWorld::SpawnMinecart(double a_X, double a_Y, double a_Z, int a_MinecartType return -1; } } // switch (a_MinecartType) - Minecart->Initialize(this); + Minecart->Initialize(*this); return Minecart->GetUniqueID(); } @@ -1724,7 +1727,7 @@ int cWorld::SpawnMinecart(double a_X, double a_Y, double a_Z, int a_MinecartType void cWorld::SpawnPrimedTNT(double a_X, double a_Y, double a_Z, int a_FuseTicks, double a_InitialVelocityCoeff) { cTNTEntity * TNT = new cTNTEntity(a_X, a_Y, a_Z, a_FuseTicks); - TNT->Initialize(this); + TNT->Initialize(*this); TNT->SetSpeed( a_InitialVelocityCoeff * (GetTickRandomNumber(2) - 1), /** -1, 0, 1 */ a_InitialVelocityCoeff * 2, @@ -2240,7 +2243,7 @@ void cWorld::SetChunkData( // Initialize the entities (outside the m_ChunkMap's CS, to fix FS #347): for (cEntityList::iterator itr = a_Entities.begin(), end = a_Entities.end(); itr != end; ++itr) { - (*itr)->Initialize(this); + (*itr)->Initialize(*this); } // If a client is requesting this chunk, send it to them: @@ -2333,23 +2336,8 @@ void cWorld::CollectPickupsByPlayer(cPlayer * a_Player) void cWorld::AddPlayer(cPlayer * a_Player) { - { - cCSLock Lock(m_CSPlayers); - - ASSERT(std::find(m_Players.begin(), m_Players.end(), a_Player) == m_Players.end()); // Is it already in the list? HOW? - - m_Players.remove(a_Player); // Make sure the player is registered only once - m_Players.push_back(a_Player); - } - - // Add the player's client to the list of clients to be ticked: - if (a_Player->GetClientHandle() != NULL) - { - cCSLock Lock(m_CSClients); - m_ClientsToAdd.push_back(a_Player->GetClientHandle()); - } - - // The player has already been added to the chunkmap as the entity, do NOT add again! + cCSLock Lock(m_CSPlayersToAdd); + m_PlayersToAdd.push_back(a_Player); } @@ -2358,17 +2346,26 @@ void cWorld::AddPlayer(cPlayer * a_Player) void cWorld::RemovePlayer(cPlayer * a_Player) { + m_ChunkMap->RemoveEntity(a_Player); + { + cCSLock Lock(m_CSPlayersToAdd); + m_PlayersToAdd.remove(a_Player); + } { cCSLock Lock(m_CSPlayers); + LOGD("Removing player \"%s\" from world \"%s\".", a_Player->GetName().c_str(), m_WorldName.c_str()); m_Players.remove(a_Player); } // Remove the player's client from the list of clients to be ticked: - if (a_Player->GetClientHandle() != NULL) + cClientHandle * Client = a_Player->GetClientHandle(); + if (Client != NULL) { + Client->RemoveFromWorld(); + m_ChunkMap->RemoveClientFromChunks(Client); cCSLock Lock(m_CSClients); - m_ClientsToRemove.push_back(a_Player->GetClientHandle()); + m_ClientsToRemove.push_back(Client); } } @@ -2977,7 +2974,7 @@ int cWorld::SpawnMobFinalize(cMonster * a_Monster) delete a_Monster; return -1; } - if (!a_Monster->Initialize(this)) + if (!a_Monster->Initialize(*this)) { delete a_Monster; return -1; @@ -2999,7 +2996,7 @@ int cWorld::CreateProjectile(double a_PosX, double a_PosY, double a_PosZ, cProje { return -1; } - if (!Projectile->Initialize(this)) + if (!Projectile->Initialize(*this)) { delete Projectile; return -1; @@ -3129,6 +3126,63 @@ cFluidSimulator * cWorld::InitializeFluidSimulator(cIniFile & a_IniFile, const c +void cWorld::AddQueuedPlayers(void) +{ + ASSERT(m_TickThread.IsCurrentThread()); + + // Grab the list of players to add, it has to be locked to access it: + cPlayerList PlayersToAdd; + { + cCSLock Lock(m_CSPlayersToAdd); + std::swap(PlayersToAdd, m_PlayersToAdd); + } + + // Add all the players in the grabbed list: + { + cCSLock Lock(m_CSPlayers); + for (cPlayerList::iterator itr = PlayersToAdd.begin(), end = PlayersToAdd.end(); itr != end; ++itr) + { + ASSERT(std::find(m_Players.begin(), m_Players.end(), *itr) == m_Players.end()); // Is it already in the list? HOW? + + m_Players.push_back(*itr); + (*itr)->SetWorld(this); + + // Add to chunkmap, if not already there (Spawn vs MoveToWorld): + if (!m_ChunkMap->HasEntity((*itr)->GetUniqueID())) + { + m_ChunkMap->AddEntity(*itr); + } + } // for itr - PlayersToAdd[] + } // Lock(m_CSPlayers) + + // Add all the players' clienthandles: + { + cCSLock Lock(m_CSClients); + for (cPlayerList::iterator itr = PlayersToAdd.begin(), end = PlayersToAdd.end(); itr != end; ++itr) + { + cClientHandle * Client = (*itr)->GetClientHandle(); + if (Client != NULL) + { + m_Clients.push_back(Client); + } + } // for itr - PlayersToAdd[] + } // Lock(m_CSClients) + + // Stream chunks to all eligible clients: + for (cPlayerList::iterator itr = PlayersToAdd.begin(), end = PlayersToAdd.end(); itr != end; ++itr) + { + cClientHandle * Client = (*itr)->GetClientHandle(); + if (Client != NULL) + { + Client->StreamChunks(); + } + } // for itr - PlayersToAdd[] +} + + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // cWorld::cTaskSaveAllChunks: @@ -3269,4 +3323,3 @@ void cWorld::cChunkGeneratorCallbacks::CallHookChunkGenerated (cChunkDesc & a_Ch - diff --git a/src/World.h b/src/World.h index 4c014a976..abdc3120c 100644 --- a/src/World.h +++ b/src/World.h @@ -284,8 +284,15 @@ public: void CollectPickupsByPlayer(cPlayer * a_Player); - void AddPlayer( cPlayer* a_Player ); - void RemovePlayer( cPlayer* a_Player ); + /** Adds the player to the world. + Uses a queue to store the player object until the Tick thread processes the addition event. + Also adds the player as an entity in the chunkmap, and the player's ClientHandle, if any, for ticking. */ + void AddPlayer(cPlayer * a_Player); + + /** Removes the player from the world. + Removes the player from the addition queue, too, if appropriate. + If the player has a ClientHandle, the ClientHandle is removed from all chunks in the world and will not be ticked by this world anymore. */ + void RemovePlayer(cPlayer * a_Player); /** Calls the callback for each player in the list; returns true if all players processed, false if the callback aborted by returning true */ virtual bool ForEachPlayer(cPlayerListCallback & a_Callback) override; // >> EXPORTED IN MANUALBINDINGS << @@ -933,6 +940,12 @@ private: /** List of entities that are scheduled for adding, waiting for the Tick thread to add them. */ cEntityList m_EntitiesToAdd; + /** Guards m_PlayersToAdd */ + cCriticalSection m_CSPlayersToAdd; + + /** List of players that are scheduled for adding, waiting for the Tick thread to add them. */ + cPlayerList m_PlayersToAdd; + cWorld(const AString & a_WorldName); virtual ~cWorld(); @@ -970,6 +983,10 @@ private: /** Creates a new redstone simulator.*/ cRedstoneSimulator * InitializeRedstoneSimulator(cIniFile & a_IniFile); + + /** Adds the players queued in the m_PlayersToAdd queue into the m_Players list. + Assumes it is called from the Tick thread. */ + void AddQueuedPlayers(void); }; // tolua_export -- cgit v1.2.3 From ec0976f9b0ace946022f48fdb360830985e7ee14 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 9 Jun 2014 00:49:02 +0200 Subject: Fixed a crash when creating negative-size blockareas. Now the server emits a warning instead and continues execution. --- src/BlockArea.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src') diff --git a/src/BlockArea.cpp b/src/BlockArea.cpp index e3a859e4f..4fe6cd51e 100644 --- a/src/BlockArea.cpp +++ b/src/BlockArea.cpp @@ -309,6 +309,14 @@ void cBlockArea::Clear(void) void cBlockArea::Create(int a_SizeX, int a_SizeY, int a_SizeZ, int a_DataTypes) { + if ((a_SizeX < 0) || (a_SizeY < 0) || (a_SizeZ < 0)) + { + LOGWARNING("Creating a cBlockArea with a negative size! Call to Create ignored. (%d, %d, %d)", + a_SizeX, a_SizeY, a_SizeZ + ); + return; + } + Clear(); int BlockCount = a_SizeX * a_SizeY * a_SizeZ; if ((a_DataTypes & baTypes) != 0) -- cgit v1.2.3 From 02b509b81d4543a958caaad8389fa0cebd0a8e1a Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 9 Jun 2014 17:05:22 +0200 Subject: ToLua can now be run in pure-lua mode. See the src/Bindings/AllToLua_lua.bat for usage example. --- src/Bindings/AllToLua_lua.bat.bat | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/Bindings/AllToLua_lua.bat.bat (limited to 'src') diff --git a/src/Bindings/AllToLua_lua.bat.bat b/src/Bindings/AllToLua_lua.bat.bat new file mode 100644 index 000000000..81c738f32 --- /dev/null +++ b/src/Bindings/AllToLua_lua.bat.bat @@ -0,0 +1,27 @@ + +:: AllToLua_Lua.bat +:: This scripts updates the automatically-generates Lua bindings in Bindings.cpp / Bindings.h +:: When called without any parameters, it will pause for a keypress at the end +:: Call with any parameter to disable the wait (for buildserver use) +:: This script assumes "lua" executable to be in PATH, it uses a pure-lua implementation of the ToLua processor + +@echo off + + + + + +:: Regenerate the files: +echo Regenerating LUA bindings . . . +lua ..\..\lib\tolua++\src\bin\lua\_driver.lua -L virtual_method_hooks.lua -o Bindings.cpp -H Bindings.h AllToLua.pkg + + + + +: Wait for keypress, if no param given: +echo. +if %ALLTOLUA_WAIT%N == N pause + + + + -- cgit v1.2.3 From 2b45e720adc801ece3dc562772747791efc3567e Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 9 Jun 2014 21:35:46 +0200 Subject: Added Y coord checks and documentation to cBlockDoorHandler. --- src/Blocks/BlockDoor.h | 59 ++++++++++++++++++++++++++++++++++---------------- 1 file changed, 40 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/Blocks/BlockDoor.h b/src/Blocks/BlockDoor.h index eaa039c50..bc59051c3 100644 --- a/src/Blocks/BlockDoor.h +++ b/src/Blocks/BlockDoor.h @@ -111,19 +111,19 @@ public: } if ((a_Yaw >= 0) && (a_Yaw < 90)) { - return 0x0; + return 0x00; } else if ((a_Yaw >= 180) && (a_Yaw < 270)) { - return 0x2; + return 0x02; } else if ((a_Yaw >= 90) && (a_Yaw < 180)) { - return 0x1; + return 0x01; } else { - return 0x3; + return 0x03; } } @@ -137,29 +137,45 @@ public: static NIBBLETYPE IsOpen(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ) { - NIBBLETYPE Meta = GetTrueDoorMeta(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ); - return ((Meta & 0x4) != 0); + NIBBLETYPE Meta = GetCompleteDoorMeta(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ); + return ((Meta & 0x04) != 0); } - /** Read the meta from the true part of the door and returns a meta with all infos include. */ - static NIBBLETYPE GetTrueDoorMeta(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ) + /** Returns the complete meta composed from the both parts of the door as (TopMeta << 4) | BottomMeta + The coords may point to either part of the door. + The returned value has bit 3 (0x08) set iff the coords point to the top part of the door. + Fails gracefully for (invalid) doors on the world's top and bottom. */ + static NIBBLETYPE GetCompleteDoorMeta(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ) { NIBBLETYPE Meta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ); - if ((Meta & 0x8) != 0) + if ((Meta & 0x08) != 0) { - NIBBLETYPE DownMeta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY - 1, a_BlockZ); - return (DownMeta & 0x7) | 0x8 | (((Meta & 0x1) != 0) ? 16 : 0); + // The coords are pointing at the top part of the door + if (a_BlockX > 0) + { + NIBBLETYPE DownMeta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY - 1, a_BlockZ); + return (DownMeta & 0x07) | 0x08 | (Meta << 4); + } + // This is the top part of the door at the bottommost layer of the world, there's no bottom: + return 0x08 | (Meta << 4); } else { - NIBBLETYPE UpMeta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY + 1, a_BlockZ); - return (Meta & 0x7) | (((UpMeta & 0x1) != 0) ? 16 : 0); + // The coords are pointing at the bottom part of the door + if (a_BlockY < cChunkDef::Height - 1) + { + NIBBLETYPE UpMeta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY + 1, a_BlockZ); + return Meta | (UpMeta << 4); + } + // This is the bottom part of the door at the topmost layer of the world, there's no top: + return Meta; } } + /** Sets the door to the specified state. If the door is already in that state, does nothing. */ static void SetOpen(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ, bool a_Open) { BLOCKTYPE Block = a_ChunkInterface.GetBlock(a_BlockX, a_BlockY, a_BlockZ); @@ -168,22 +184,27 @@ public: return; } - NIBBLETYPE Meta = GetTrueDoorMeta(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ); - bool Opened = (Meta & 0x4) != 0; - if (Opened == a_Open) + NIBBLETYPE Meta = GetCompleteDoorMeta(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ); + bool IsOpened = ((Meta & 0x04) != 0); + if (IsOpened == a_Open) { return; } // Change the door - NIBBLETYPE NewMeta = (Meta & 0x7) ^ 0x4; - if ((Meta & 0x8) == 0) + NIBBLETYPE NewMeta = (Meta & 0x07) ^ 0x04; // Flip the "IsOpen" bit (0x04) + if ((Meta & 0x08) == 0) { + // The block is the bottom part of the door a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, NewMeta); } else { - a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY - 1, a_BlockZ, NewMeta); + // The block is the top part of the door, set the meta to the corresponding top part + if (a_BlockY > 0) + { + a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY - 1, a_BlockZ, NewMeta); + } } } -- cgit v1.2.3 From bead36f5ed9ec9501ff9fa67bbaa8d734a7a168a Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 9 Jun 2014 23:38:50 +0200 Subject: Added cRidgedMultiNoise, fixed cPerlinNoise. --- src/Noise.cpp | 170 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++- src/Noise.h | 64 ++++++++++++++++++++++ 2 files changed, 233 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/Noise.cpp b/src/Noise.cpp index 89115d992..9c7042b02 100644 --- a/src/Noise.cpp +++ b/src/Noise.cpp @@ -854,7 +854,7 @@ void cPerlinNoise::Generate2D( NOISE_DATATYPE Amplitude = FirstOctave.m_Amplitude; for (int i = 0; i < ArrayCount; i++) { - a_Array[i] *= Amplitude; + a_Array[i] = a_Workspace[i] * Amplitude; } // Add each octave: @@ -949,3 +949,171 @@ void cPerlinNoise::Generate3D( + +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// cRidgedMultiNoise: + +cRidgedMultiNoise::cRidgedMultiNoise(void) : + m_Seed(0) +{ +} + + + + + +cRidgedMultiNoise::cRidgedMultiNoise(int a_Seed) : + m_Seed(a_Seed) +{ +} + + + + + +void cRidgedMultiNoise::SetSeed(int a_Seed) +{ + m_Seed = a_Seed; +} + + + + + +void cRidgedMultiNoise::AddOctave(float a_Frequency, float a_Amplitude) +{ + m_Octaves.push_back(cOctave(m_Seed * ((int)m_Octaves.size() + 4) * 4 + 1024, a_Frequency, a_Amplitude)); +} + + + + + +void cRidgedMultiNoise::Generate2D( + NOISE_DATATYPE * a_Array, ///< Array to generate into [x + a_SizeX * y] + int a_SizeX, int a_SizeY, ///< Count of the array, in each direction + NOISE_DATATYPE a_StartX, NOISE_DATATYPE a_EndX, ///< Noise-space coords of the array in the X direction + NOISE_DATATYPE a_StartY, NOISE_DATATYPE a_EndY, ///< Noise-space coords of the array in the Y direction + NOISE_DATATYPE * a_Workspace ///< Workspace that this function can use and trash +) const +{ + if (m_Octaves.empty()) + { + // No work to be done + ASSERT(!"RidgedMulti: No octaves to generate!"); + return; + } + + bool ShouldFreeWorkspace = (a_Workspace == NULL); + int ArrayCount = a_SizeX * a_SizeY; + if (ShouldFreeWorkspace) + { + a_Workspace = new NOISE_DATATYPE[ArrayCount]; + } + + // Generate the first octave directly into array: + const cOctave & FirstOctave = m_Octaves.front(); + + FirstOctave.m_Noise.Generate2D( + a_Workspace, a_SizeX, a_SizeY, + a_StartX * FirstOctave.m_Frequency, a_EndX * FirstOctave.m_Frequency, + a_StartY * FirstOctave.m_Frequency, a_EndY * FirstOctave.m_Frequency + ); + NOISE_DATATYPE Amplitude = FirstOctave.m_Amplitude; + for (int i = 0; i < ArrayCount; i++) + { + a_Array[i] = std::abs(a_Workspace[i] * Amplitude); + } + + // Add each octave: + for (cOctaves::const_iterator itr = m_Octaves.begin() + 1, end = m_Octaves.end(); itr != end; ++itr) + { + // Generate cubic noise for the octave: + itr->m_Noise.Generate2D( + a_Workspace, a_SizeX, a_SizeY, + a_StartX * itr->m_Frequency, a_EndX * itr->m_Frequency, + a_StartY * itr->m_Frequency, a_EndY * itr->m_Frequency + ); + // Add the cubic noise into the output: + NOISE_DATATYPE Amplitude = itr->m_Amplitude; + for (int i = 0; i < ArrayCount; i++) + { + a_Array[i] += std::abs(a_Workspace[i] * Amplitude); + } + } + + if (ShouldFreeWorkspace) + { + delete[] a_Workspace; + } +} + + + + + +void cRidgedMultiNoise::Generate3D( + NOISE_DATATYPE * a_Array, ///< Array to generate into [x + a_SizeX * y + a_SizeX * a_SizeY * z] + int a_SizeX, int a_SizeY, int a_SizeZ, ///< Count of the array, in each direction + NOISE_DATATYPE a_StartX, NOISE_DATATYPE a_EndX, ///< Noise-space coords of the array in the X direction + NOISE_DATATYPE a_StartY, NOISE_DATATYPE a_EndY, ///< Noise-space coords of the array in the Y direction + NOISE_DATATYPE a_StartZ, NOISE_DATATYPE a_EndZ, ///< Noise-space coords of the array in the Z direction + NOISE_DATATYPE * a_Workspace ///< Workspace that this function can use and trash +) const +{ + if (m_Octaves.empty()) + { + // No work to be done + ASSERT(!"RidgedMulti: No octaves to generate!"); + return; + } + + bool ShouldFreeWorkspace = (a_Workspace == NULL); + int ArrayCount = a_SizeX * a_SizeY * a_SizeZ; + if (ShouldFreeWorkspace) + { + a_Workspace = new NOISE_DATATYPE[ArrayCount]; + } + + // Generate the first octave directly into array: + const cOctave & FirstOctave = m_Octaves.front(); + + FirstOctave.m_Noise.Generate3D( + a_Workspace, a_SizeX, a_SizeY, a_SizeZ, + a_StartX * FirstOctave.m_Frequency, a_EndX * FirstOctave.m_Frequency, + a_StartY * FirstOctave.m_Frequency, a_EndY * FirstOctave.m_Frequency, + a_StartZ * FirstOctave.m_Frequency, a_EndZ * FirstOctave.m_Frequency + ); + NOISE_DATATYPE Amplitude = FirstOctave.m_Amplitude; + for (int i = 0; i < ArrayCount; i++) + { + a_Array[i] = a_Workspace[i] * Amplitude; + } + + // Add each octave: + for (cOctaves::const_iterator itr = m_Octaves.begin() + 1, end = m_Octaves.end(); itr != end; ++itr) + { + // Generate cubic noise for the octave: + itr->m_Noise.Generate3D( + a_Workspace, a_SizeX, a_SizeY, a_SizeZ, + a_StartX * itr->m_Frequency, a_EndX * itr->m_Frequency, + a_StartY * itr->m_Frequency, a_EndY * itr->m_Frequency, + a_StartZ * itr->m_Frequency, a_EndZ * itr->m_Frequency + ); + // Add the cubic noise into the output: + NOISE_DATATYPE Amplitude = itr->m_Amplitude; + for (int i = 0; i < ArrayCount; i++) + { + a_Array[i] += a_Workspace[i] * Amplitude; + } + } + + if (ShouldFreeWorkspace) + { + delete[] a_Workspace; + } +} + + + + diff --git a/src/Noise.h b/src/Noise.h index e605051b5..83af0cf08 100644 --- a/src/Noise.h +++ b/src/Noise.h @@ -192,6 +192,70 @@ protected: +class cRidgedMultiNoise +{ +public: + cRidgedMultiNoise(void); + cRidgedMultiNoise(int a_Seed); + + + void SetSeed(int a_Seed); + + void AddOctave(NOISE_DATATYPE a_Frequency, NOISE_DATATYPE a_Amplitude); + + void Generate1D( + NOISE_DATATYPE * a_Array, ///< Array to generate into + int a_SizeX, ///< Count of the array + NOISE_DATATYPE a_StartX, NOISE_DATATYPE a_EndX, ///< Noise-space coords of the array + NOISE_DATATYPE * a_Workspace = NULL ///< Workspace that this function can use and trash + ) const; + + + void Generate2D( + NOISE_DATATYPE * a_Array, ///< Array to generate into [x + a_SizeX * y] + int a_SizeX, int a_SizeY, ///< Count of the array, in each direction + NOISE_DATATYPE a_StartX, NOISE_DATATYPE a_EndX, ///< Noise-space coords of the array in the X direction + NOISE_DATATYPE a_StartY, NOISE_DATATYPE a_EndY, ///< Noise-space coords of the array in the Y direction + NOISE_DATATYPE * a_Workspace = NULL ///< Workspace that this function can use and trash + ) const; + + + void Generate3D( + NOISE_DATATYPE * a_Array, ///< Array to generate into [x + a_SizeX * y + a_SizeX * a_SizeY * z] + int a_SizeX, int a_SizeY, int a_SizeZ, ///< Count of the array, in each direction + NOISE_DATATYPE a_StartX, NOISE_DATATYPE a_EndX, ///< Noise-space coords of the array in the X direction + NOISE_DATATYPE a_StartY, NOISE_DATATYPE a_EndY, ///< Noise-space coords of the array in the Y direction + NOISE_DATATYPE a_StartZ, NOISE_DATATYPE a_EndZ, ///< Noise-space coords of the array in the Z direction + NOISE_DATATYPE * a_Workspace = NULL ///< Workspace that this function can use and trash + ) const; + +protected: + class cOctave + { + public: + cCubicNoise m_Noise; + + NOISE_DATATYPE m_Frequency; // Coord multiplier + NOISE_DATATYPE m_Amplitude; // Value multiplier + + cOctave(int a_Seed, NOISE_DATATYPE a_Frequency, NOISE_DATATYPE a_Amplitude) : + m_Noise(a_Seed), + m_Frequency(a_Frequency), + m_Amplitude(a_Amplitude) + { + } + } ; + + typedef std::vector cOctaves; + + int m_Seed; + cOctaves m_Octaves; +} ; + + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Inline function definitions: // These need to be in the header, otherwise linker error occur in MSVC -- cgit v1.2.3 From 9ff0ef87d4bca688b7fab8c7f4c9f9fcf683c06f Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 9 Jun 2014 23:40:51 +0200 Subject: Added an experimental height generator, Mountains. --- src/Generating/HeiGen.cpp | 66 +++++++++++++++++++++++++++++++++++++++++++++++ src/Generating/HeiGen.h | 21 +++++++++++++++ 2 files changed, 87 insertions(+) (limited to 'src') diff --git a/src/Generating/HeiGen.cpp b/src/Generating/HeiGen.cpp index 3621421c2..25ac912fd 100644 --- a/src/Generating/HeiGen.cpp +++ b/src/Generating/HeiGen.cpp @@ -47,6 +47,10 @@ cTerrainHeightGen * cTerrainHeightGen::CreateHeightGen(cIniFile &a_IniFile, cBio { res = new cEndGen(a_Seed); } + else if (NoCaseCompare(HeightGenName, "Mountains") == 0) + { + res = new cHeiGenMountains(a_Seed); + } else if (NoCaseCompare(HeightGenName, "Noise3D") == 0) { res = new cNoise3DComposable(a_Seed); @@ -300,6 +304,68 @@ void cHeiGenClassic::InitializeHeightGen(cIniFile & a_IniFile) +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// cHeiGenMountains: + +cHeiGenMountains::cHeiGenMountains(int a_Seed) : + m_Seed(a_Seed), + m_Noise(a_Seed) +{ +} + + + + + +void cHeiGenMountains::GenHeightMap(int a_ChunkX, int a_ChunkZ, cChunkDef::HeightMap & a_HeightMap) +{ + NOISE_DATATYPE StartX = (NOISE_DATATYPE)(a_ChunkX * cChunkDef::Width); + NOISE_DATATYPE EndX = (NOISE_DATATYPE)(a_ChunkX * cChunkDef::Width + cChunkDef::Width - 1); + NOISE_DATATYPE StartZ = (NOISE_DATATYPE)(a_ChunkZ * cChunkDef::Width); + NOISE_DATATYPE EndZ = (NOISE_DATATYPE)(a_ChunkZ * cChunkDef::Width + cChunkDef::Width - 1); + NOISE_DATATYPE Workspace[16 * 16]; + NOISE_DATATYPE Noise[16 * 16]; + NOISE_DATATYPE PerlinNoise[16 * 16]; + m_Noise.Generate2D(Noise, 16, 16, StartX, EndX, StartZ, EndZ, Workspace); + m_Perlin.Generate2D(PerlinNoise, 16, 16, StartX, EndX, StartZ, EndZ, Workspace); + for (int z = 0; z < cChunkDef::Width; z++) + { + int IdxZ = z * cChunkDef::Width; + for (int x = 0; x < cChunkDef::Width; x++) + { + int idx = IdxZ + x; + int hei = 100 - (int)((Noise[idx] + PerlinNoise[idx]) * 15); + if (hei < 10) + { + hei = 10; + } + if (hei > 250) + { + hei = 250; + } + cChunkDef::SetHeight(a_HeightMap, x , z, hei); + } // for x + } // for z +} + + + + + +void cHeiGenMountains::InitializeHeightGen(cIniFile & a_IniFile) +{ + // TODO: Read the params from an INI file + m_Noise.AddOctave(0.1f, 0.1f); + m_Noise.AddOctave(0.05f, 0.5f); + m_Noise.AddOctave(0.02f, 1.5f); + + m_Perlin.AddOctave(0.01f, 1.5f); +} + + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // cHeiGenBiomal: diff --git a/src/Generating/HeiGen.h b/src/Generating/HeiGen.h index 1376f2a25..5c106c7d9 100644 --- a/src/Generating/HeiGen.h +++ b/src/Generating/HeiGen.h @@ -106,6 +106,27 @@ protected: +class cHeiGenMountains : + public cTerrainHeightGen +{ +public: + cHeiGenMountains(int a_Seed); + +protected: + + int m_Seed; + cRidgedMultiNoise m_Noise; + cPerlinNoise m_Perlin; + + // cTerrainHeightGen overrides: + virtual void GenHeightMap(int a_ChunkX, int a_ChunkZ, cChunkDef::HeightMap & a_HeightMap) override; + virtual void InitializeHeightGen(cIniFile & a_IniFile) override; +} ; + + + + + class cHeiGenBiomal : public cTerrainHeightGen { -- cgit v1.2.3 From 6c43799cc558a435a03d82218738a9ff57fb6702 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 10 Jun 2014 09:20:32 +0200 Subject: Fixed gcc compilation. --- src/Noise.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/Noise.cpp b/src/Noise.cpp index 9c7042b02..e2e54efdf 100644 --- a/src/Noise.cpp +++ b/src/Noise.cpp @@ -1022,7 +1022,7 @@ void cRidgedMultiNoise::Generate2D( NOISE_DATATYPE Amplitude = FirstOctave.m_Amplitude; for (int i = 0; i < ArrayCount; i++) { - a_Array[i] = std::abs(a_Workspace[i] * Amplitude); + a_Array[i] = abs(a_Workspace[i] * Amplitude); } // Add each octave: @@ -1038,7 +1038,7 @@ void cRidgedMultiNoise::Generate2D( NOISE_DATATYPE Amplitude = itr->m_Amplitude; for (int i = 0; i < ArrayCount; i++) { - a_Array[i] += std::abs(a_Workspace[i] * Amplitude); + a_Array[i] += abs(a_Workspace[i] * Amplitude); } } -- cgit v1.2.3 From 366ecf9dfd38d612c0685f3fbf8b3a95b9900697 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 10 Jun 2014 18:25:53 +0200 Subject: Fixed a race condition when adding a player to a world. --- src/ChunkMap.cpp | 24 ++++++++++++++++++++++++ src/ChunkMap.h | 4 ++++ src/World.cpp | 5 +---- 3 files changed, 29 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/ChunkMap.cpp b/src/ChunkMap.cpp index 0a8164b47..dba6f3f41 100644 --- a/src/ChunkMap.cpp +++ b/src/ChunkMap.cpp @@ -1665,6 +1665,30 @@ void cChunkMap::AddEntity(cEntity * a_Entity) +void cChunkMap::AddEntityIfNotPresent(cEntity * a_Entity) +{ + cCSLock Lock(m_CSLayers); + cChunkPtr Chunk = GetChunkNoGen(a_Entity->GetChunkX(), ZERO_CHUNK_Y, a_Entity->GetChunkZ()); + if ( + (Chunk == NULL) || // Chunk not present at all + (!Chunk->IsValid() && !a_Entity->IsPlayer()) // Chunk present, but no valid data; players need to spawn in such chunks (#953) + ) + { + LOGWARNING("Entity at %p (%s, ID %d) spawning in a non-existent chunk, the entity is lost.", + a_Entity, a_Entity->GetClass(), a_Entity->GetUniqueID() + ); + return; + } + if (!Chunk->HasEntity(a_Entity->GetUniqueID())) + { + Chunk->AddEntity(a_Entity); + } +} + + + + + bool cChunkMap::HasEntity(int a_UniqueID) { cCSLock Lock(m_CSLayers); diff --git a/src/ChunkMap.h b/src/ChunkMap.h index 8786d7016..7e85bb6f1 100644 --- a/src/ChunkMap.h +++ b/src/ChunkMap.h @@ -199,6 +199,10 @@ public: /** Adds the entity to its appropriate chunk, takes ownership of the entity pointer */ void AddEntity(cEntity * a_Entity); + /** Adds the entity to its appropriate chunk, if the entity is not already added. + Takes ownership of the entity pointer */ + void AddEntityIfNotPresent(cEntity * a_Entity); + /** Returns true if the entity with specified ID is present in the chunks */ bool HasEntity(int a_EntityID); diff --git a/src/World.cpp b/src/World.cpp index ebe6b53e6..6bcd1391a 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -3148,10 +3148,7 @@ void cWorld::AddQueuedPlayers(void) (*itr)->SetWorld(this); // Add to chunkmap, if not already there (Spawn vs MoveToWorld): - if (!m_ChunkMap->HasEntity((*itr)->GetUniqueID())) - { - m_ChunkMap->AddEntity(*itr); - } + m_ChunkMap->AddEntityIfNotPresent(*itr); } // for itr - PlayersToAdd[] } // Lock(m_CSPlayers) -- cgit v1.2.3 From c259dad7b8561c9712c8e2c5c55d6399e9d26325 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 10 Jun 2014 18:27:17 +0200 Subject: Fixed clang warnings about abs() in Noise.cpp. MSVC provides a float overload of abs(), clang does not. Using the proper fabs(). --- src/Noise.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/Noise.cpp b/src/Noise.cpp index e2e54efdf..040421106 100644 --- a/src/Noise.cpp +++ b/src/Noise.cpp @@ -1022,7 +1022,7 @@ void cRidgedMultiNoise::Generate2D( NOISE_DATATYPE Amplitude = FirstOctave.m_Amplitude; for (int i = 0; i < ArrayCount; i++) { - a_Array[i] = abs(a_Workspace[i] * Amplitude); + a_Array[i] = fabs(a_Workspace[i] * Amplitude); } // Add each octave: @@ -1038,7 +1038,7 @@ void cRidgedMultiNoise::Generate2D( NOISE_DATATYPE Amplitude = itr->m_Amplitude; for (int i = 0; i < ArrayCount; i++) { - a_Array[i] += abs(a_Workspace[i] * Amplitude); + a_Array[i] += fabs(a_Workspace[i] * Amplitude); } } -- cgit v1.2.3