diff options
-rw-r--r-- | CONTRIBUTORS | 2 | ||||
-rw-r--r-- | Server/Plugins/DumpInfo/Init.lua | 4 | ||||
-rw-r--r-- | src/BlockEntities/BannerEntity.cpp | 37 | ||||
-rw-r--r-- | src/BlockEntities/BannerEntity.h | 12 | ||||
-rw-r--r-- | src/ClientHandle.cpp | 1 | ||||
-rw-r--r-- | src/Globals.h | 1 | ||||
-rw-r--r-- | src/Items/ItemBanner.h | 4 | ||||
-rw-r--r-- | src/OSSupport/ServerHandleImpl.cpp | 3 | ||||
-rw-r--r-- | src/Protocol/Protocol_1_13.cpp | 6 | ||||
-rw-r--r-- | src/Protocol/Protocol_1_14.cpp | 7 | ||||
-rw-r--r-- | src/WorldStorage/MapSerializer.cpp | 2 | ||||
-rw-r--r-- | src/WorldStorage/NBTChunkSerializer.cpp | 4 | ||||
-rw-r--r-- | src/WorldStorage/WSSAnvil.cpp | 16 |
13 files changed, 55 insertions, 44 deletions
diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 660746445..0a599bd30 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -59,6 +59,7 @@ mcfadyeni MeMuXin mgueydan MikeHunsinger +mjagdis (Mike Jagdis) Morritz (TJ) morsmordere (Anzhelika Iugai) mtilden @@ -79,6 +80,7 @@ Schwertspize Seadragon91 (Lukas Pioch) sleirsgoevy (Sergey Lisov) Sofapriester +solvictor Spekdrum (Pablo Beltran) SphinxC0re Spongecade (Updated wiki links) diff --git a/Server/Plugins/DumpInfo/Init.lua b/Server/Plugins/DumpInfo/Init.lua index 723ab3d94..6f51aa4a6 100644 --- a/Server/Plugins/DumpInfo/Init.lua +++ b/Server/Plugins/DumpInfo/Init.lua @@ -23,7 +23,7 @@ function HandleDumpPluginRequest(a_Request) -- Check if it already was requested to dump a plugin. if (a_Request.PostParams["DumpInfo"] ~= nil) then local F = loadfile("Plugins/InfoDump.lua") - F("Plugins/" .. a_Request.PostParams["DumpInfo"]) + F("Plugins/" .. cPluginManager:Get():GetPluginFolderName(a_Request.PostParams["DumpInfo"])) end Content = Content .. [[ @@ -36,7 +36,7 @@ function HandleDumpPluginRequest(a_Request) cPluginManager:Get():ForEachPlugin( function(a_Plugin) -- Check if there is a file called 'Info.lua' - if (cFile:IsFile("Plugins/" .. a_Plugin:GetName() .. "/Info.lua")) then + if (cFile:IsFile(a_Plugin:GetLocalFolder() .. "/Info.lua")) then Content = Content .. "\n<tr>\n" Content = Content .. "\t<td>" .. a_Plugin:GetName() .. "</td>\n" Content = Content .. "\t<td><form method='POST'> <input type='hidden' value='" .. a_Plugin:GetName() .. "' name='DumpInfo'> <input type='submit' value='DumpInfo'></form></td>\n" diff --git a/src/BlockEntities/BannerEntity.cpp b/src/BlockEntities/BannerEntity.cpp index f39263ac4..10f185bfd 100644 --- a/src/BlockEntities/BannerEntity.cpp +++ b/src/BlockEntities/BannerEntity.cpp @@ -13,18 +13,10 @@ -cBannerEntity::cBannerEntity(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos, cWorld * a_World) : - cBannerEntity(a_BlockType, a_BlockMeta, a_Pos, a_World, 1) -{ -} - - - - - -cBannerEntity::cBannerEntity(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos, cWorld * a_World, unsigned char a_BaseColor): +cBannerEntity::cBannerEntity(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos, cWorld * a_World, unsigned char a_BaseColor, AString a_CustomName): Super(a_BlockType, a_BlockMeta, a_Pos, a_World), - m_BaseColor(a_BaseColor) + m_BaseColor(a_BaseColor), + m_CustomName(std::move(a_CustomName)) { ASSERT((a_BlockType == E_BLOCK_WALL_BANNER) || (a_BlockType == E_BLOCK_STANDING_BANNER)); } @@ -33,27 +25,11 @@ cBannerEntity::cBannerEntity(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vect -unsigned char cBannerEntity::GetBaseColor() const -{ - return m_BaseColor; -} - - - - - -void cBannerEntity::SetBaseColor(const unsigned char a_Color) -{ - m_BaseColor = a_Color; -} - - - - - cItems cBannerEntity::ConvertToPickups() const { - return cItem(E_ITEM_BANNER, 1, static_cast<NIBBLETYPE>(GetBaseColor())); + cItem Item(E_ITEM_BANNER, 1, static_cast<NIBBLETYPE>(GetBaseColor())); + Item.m_CustomName = m_CustomName; + return Item; } @@ -65,6 +41,7 @@ void cBannerEntity::CopyFrom(const cBlockEntity & a_Src) Super::CopyFrom(a_Src); auto & src = static_cast<const cBannerEntity &>(a_Src); m_BaseColor = src.m_BaseColor; + m_CustomName = src.m_CustomName; } diff --git a/src/BlockEntities/BannerEntity.h b/src/BlockEntities/BannerEntity.h index b6d27f53b..91ef87e8c 100644 --- a/src/BlockEntities/BannerEntity.h +++ b/src/BlockEntities/BannerEntity.h @@ -25,16 +25,20 @@ class cBannerEntity : public: - cBannerEntity(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos, cWorld * a_World); - cBannerEntity(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos, cWorld * a_World, unsigned char a_BaseColor); + cBannerEntity(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos, cWorld * a_World, unsigned char a_BaseColor = 1, AString a_CustomName = ""); - unsigned char GetBaseColor() const; - void SetBaseColor(unsigned char a_Color); + unsigned char GetBaseColor() const { return m_BaseColor; } + void SetBaseColor(unsigned char a_Color) { m_BaseColor = a_Color; } + + const AString & GetCustomName() const { return m_CustomName; } + void SetCustomName(const AString & a_CustomName) { m_CustomName = a_CustomName; } private: unsigned char m_BaseColor; + AString m_CustomName; + // cBlockEntity overrides: virtual cItems ConvertToPickups() const override; virtual void CopyFrom(const cBlockEntity & a_Src) override; diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index b726e5c6f..01c95095a 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -74,6 +74,7 @@ cClientHandle::cClientHandle(const AString & a_IPString, int a_ViewDistance) : m_IPString(a_IPString), m_Player(nullptr), m_CachedSentChunk(std::numeric_limits<decltype(m_CachedSentChunk.m_ChunkX)>::max(), std::numeric_limits<decltype(m_CachedSentChunk.m_ChunkZ)>::max()), + m_ProxyConnection(false), m_HasSentDC(false), m_LastStreamedChunkX(std::numeric_limits<decltype(m_LastStreamedChunkX)>::max()), // bogus chunk coords to force streaming upon login m_LastStreamedChunkZ(std::numeric_limits<decltype(m_LastStreamedChunkZ)>::max()), diff --git a/src/Globals.h b/src/Globals.h index 0b6ff8ac5..7c2af3d11 100644 --- a/src/Globals.h +++ b/src/Globals.h @@ -98,6 +98,7 @@ #include <arpa/inet.h> #include <netinet/in.h> + #include <netinet/tcp.h> #include <sys/socket.h> #include <unistd.h> #endif diff --git a/src/Items/ItemBanner.h b/src/Items/ItemBanner.h index a404af336..551c41429 100644 --- a/src/Items/ItemBanner.h +++ b/src/Items/ItemBanner.h @@ -40,7 +40,9 @@ private: { ASSERT((a_BlockEntity.GetBlockType() == E_BLOCK_STANDING_BANNER) || (a_BlockEntity.GetBlockType() == E_BLOCK_WALL_BANNER)); - static_cast<cBannerEntity &>(a_BlockEntity).SetBaseColor(static_cast<NIBBLETYPE>(a_HeldItem.m_ItemDamage)); + cBannerEntity & BannerEntity = static_cast<cBannerEntity &>(a_BlockEntity); + BannerEntity.SetBaseColor(static_cast<NIBBLETYPE>(a_HeldItem.m_ItemDamage)); + BannerEntity.SetCustomName(a_HeldItem.m_CustomName); return false; }); diff --git a/src/OSSupport/ServerHandleImpl.cpp b/src/OSSupport/ServerHandleImpl.cpp index e68f82757..669a0f83f 100644 --- a/src/OSSupport/ServerHandleImpl.cpp +++ b/src/OSSupport/ServerHandleImpl.cpp @@ -328,6 +328,9 @@ void cServerHandleImpl::Callback(evconnlistener * a_Listener, evutil_socket_t a_ return; } + const int one = 1; + setsockopt(a_Socket, IPPROTO_TCP, TCP_NODELAY, reinterpret_cast<const char *>(&one), sizeof(one)); + // Create a new cTCPLink for the incoming connection: cTCPLinkImplPtr Link = std::make_shared<cTCPLinkImpl>(a_Socket, LinkCallbacks, Self->m_SelfPtr, a_Addr, static_cast<socklen_t>(a_Len)); { diff --git a/src/Protocol/Protocol_1_13.cpp b/src/Protocol/Protocol_1_13.cpp index eb452ec79..8bffe0f85 100644 --- a/src/Protocol/Protocol_1_13.cpp +++ b/src/Protocol/Protocol_1_13.cpp @@ -900,7 +900,11 @@ void cProtocol_1_13::WriteEntityMetadata(cPacketizer & a_Pkt, const cEntity & a_ case cEntity::etItemFrame: { - // TODO + const auto & Frame = static_cast<const cItemFrame &>(a_Entity); + WriteEntityMetadata(a_Pkt, EntityMetadata::ItemFrameItem, EntityMetadataType::Item); + WriteItem(a_Pkt, Frame.GetItem()); + WriteEntityMetadata(a_Pkt, EntityMetadata::ItemFrameRotation, EntityMetadataType::VarInt); + a_Pkt.WriteVarInt32(Frame.GetItemRotation()); break; } // case etItemFrame diff --git a/src/Protocol/Protocol_1_14.cpp b/src/Protocol/Protocol_1_14.cpp index 4b306a2c3..beb929ce3 100644 --- a/src/Protocol/Protocol_1_14.cpp +++ b/src/Protocol/Protocol_1_14.cpp @@ -19,6 +19,7 @@ Implements the 1.14 protocol classes: #include "../BlockEntities/BlockEntity.h" #include "../Entities/ArrowEntity.h" +#include "../Entities/ItemFrame.h" #include "../Mobs/Bat.h" #include "../Entities/Boat.h" #include "../Mobs/Chicken.h" @@ -1213,7 +1214,11 @@ void cProtocol_1_14::WriteEntityMetadata(cPacketizer & a_Pkt, const cEntity & a_ case cEntity::etItemFrame: { - // TODO + const auto & Frame = static_cast<const cItemFrame &>(a_Entity); + WriteEntityMetadata(a_Pkt, EntityMetadata::ItemFrameItem, EntityMetadataType::Item); + WriteItem(a_Pkt, Frame.GetItem()); + WriteEntityMetadata(a_Pkt, EntityMetadata::ItemFrameRotation, EntityMetadataType::VarInt); + a_Pkt.WriteVarInt32(Frame.GetItemRotation()); break; } // case etItemFrame diff --git a/src/WorldStorage/MapSerializer.cpp b/src/WorldStorage/MapSerializer.cpp index e68ad00e6..3e50740b3 100644 --- a/src/WorldStorage/MapSerializer.cpp +++ b/src/WorldStorage/MapSerializer.cpp @@ -18,7 +18,7 @@ cMapSerializer::cMapSerializer(const AString & a_WorldName, cMap * a_Map): m_Map(a_Map) { auto DataPath = fmt::format(FMT_STRING("{}{}data"), a_WorldName, cFile::PathSeparator()); - m_Path = fmt::format(FMT_STRING("{}{}map_%i.dat"), DataPath, cFile::PathSeparator(), a_Map->GetID()); + m_Path = fmt::format(FMT_STRING("{}{}map_{}.dat"), DataPath, cFile::PathSeparator(), a_Map->GetID()); cFile::CreateFolder(DataPath); } diff --git a/src/WorldStorage/NBTChunkSerializer.cpp b/src/WorldStorage/NBTChunkSerializer.cpp index fb6459c88..c61e6d185 100644 --- a/src/WorldStorage/NBTChunkSerializer.cpp +++ b/src/WorldStorage/NBTChunkSerializer.cpp @@ -376,6 +376,10 @@ public: mWriter.BeginCompound(""); AddBasicTileEntity(a_Entity,"Banner"); mWriter.AddInt("Base", static_cast<int>(a_Entity->GetBaseColor())); + if (!a_Entity->GetCustomName().empty()) + { + mWriter.AddString("CustomName", a_Entity->GetCustomName()); + } mWriter.EndCompound(); } diff --git a/src/WorldStorage/WSSAnvil.cpp b/src/WorldStorage/WSSAnvil.cpp index dec05f351..6b425c4dc 100644 --- a/src/WorldStorage/WSSAnvil.cpp +++ b/src/WorldStorage/WSSAnvil.cpp @@ -890,15 +890,23 @@ OwnedBlockEntity cWSSAnvil::LoadBannerFromNBT(const cParsedNBT & a_NBT, int a_Ta return nullptr; } + unsigned char Color = 15; + AString CustomName; + // Reads base color from NBT int CurrentLine = a_NBT.FindChildByName(a_TagIdx, "Base"); if (CurrentLine >= 0) { - const auto Color = static_cast<unsigned char>(a_NBT.GetInt(CurrentLine)); - return std::make_unique<cBannerEntity>(a_BlockType, a_BlockMeta, a_Pos, m_World, Color); + Color = static_cast<unsigned char>(a_NBT.GetInt(CurrentLine)); } - return nullptr; + CurrentLine = a_NBT.FindChildByName(a_TagIdx, "CustomName"); + if ((CurrentLine >= 0) && (a_NBT.GetType(CurrentLine) == TAG_String)) + { + CustomName = a_NBT.GetString(CurrentLine); + } + + return std::make_unique<cBannerEntity>(a_BlockType, a_BlockMeta, a_Pos, m_World, Color, CustomName); } @@ -3640,7 +3648,7 @@ bool cWSSAnvil::LoadEntityBaseFromNBT(cEntity & a_Entity, const cParsedNBT & a_N Rotation[1] = 0; } a_Entity.SetYaw(Rotation[0]); - a_Entity.SetRoll(Rotation[1]); + a_Entity.SetPitch(Rotation[1]); // Depending on the Minecraft version, the entity's health is // stored either as a float Health tag (HealF prior to 1.9) or |