diff options
Diffstat (limited to '')
-rw-r--r-- | src/WorldStorage/CMakeLists.txt | 7 | ||||
-rw-r--r-- | src/WorldStorage/NBTChunkSerializer.cpp | 64 | ||||
-rwxr-xr-x | src/WorldStorage/WSSAnvil.cpp | 35 |
3 files changed, 54 insertions, 52 deletions
diff --git a/src/WorldStorage/CMakeLists.txt b/src/WorldStorage/CMakeLists.txt index c351420f4..d9e066b32 100644 --- a/src/WorldStorage/CMakeLists.txt +++ b/src/WorldStorage/CMakeLists.txt @@ -28,13 +28,6 @@ SET (HDRS WorldStorage.h ) -if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - set_source_files_properties(FireworksSerializer.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=switch-enum ") - set_source_files_properties(NBTChunkSerializer.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=switch-enum ") - set_source_files_properties(SchematicFileSerializer.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=global-constructors") - set_source_files_properties(WSSAnvil.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=switch -Wno-error=switch-enum ") -endif() - if(NOT MSVC) add_library(WorldStorage ${SRCS} ${HDRS}) diff --git a/src/WorldStorage/NBTChunkSerializer.cpp b/src/WorldStorage/NBTChunkSerializer.cpp index 1e8543648..12f767abf 100644 --- a/src/WorldStorage/NBTChunkSerializer.cpp +++ b/src/WorldStorage/NBTChunkSerializer.cpp @@ -643,6 +643,35 @@ void cNBTChunkSerializer::AddMonsterEntity(cMonster * a_Monster) m_Writer.AddInt("Size", reinterpret_cast<const cMagmaCube *>(a_Monster)->GetSize()); break; } + case mtOcelot: + { + const auto *Ocelot = reinterpret_cast<const cOcelot *>(a_Monster); + if (!Ocelot->GetOwnerName().empty()) + { + m_Writer.AddString("Owner", Ocelot->GetOwnerName()); + } + if (!Ocelot->GetOwnerUUID().IsNil()) + { + m_Writer.AddString("OwnerUUID", Ocelot->GetOwnerUUID().ToShortString()); + } + m_Writer.AddByte("Sitting", Ocelot->IsSitting() ? 1 : 0); + m_Writer.AddInt("CatType", Ocelot->GetOcelotType()); + m_Writer.AddInt("Age", Ocelot->GetAge()); + break; + } + case mtPig: + { + m_Writer.AddInt("Age", reinterpret_cast<const cPig *>(a_Monster)->GetAge()); + break; + } + case mtRabbit: + { + const cRabbit * Rabbit = reinterpret_cast<const cRabbit *>(a_Monster); + m_Writer.AddInt("RabbitType", static_cast<Int32>(Rabbit->GetRabbitType())); + m_Writer.AddInt("MoreCarrotTicks", Rabbit->GetMoreCarrotTicks()); + m_Writer.AddInt("Age", Rabbit->GetAge()); + break; + } case mtSheep: { const cSheep *Sheep = reinterpret_cast<const cSheep *>(a_Monster); @@ -703,36 +732,6 @@ void cNBTChunkSerializer::AddMonsterEntity(cMonster * a_Monster) m_Writer.AddInt("Age", reinterpret_cast<const cZombiePigman *>(a_Monster)->GetAge()); break; } - case mtOcelot: - { - const auto *Ocelot = reinterpret_cast<const cOcelot *>(a_Monster); - if (!Ocelot->GetOwnerName().empty()) - { - m_Writer.AddString("Owner", Ocelot->GetOwnerName()); - } - if (!Ocelot->GetOwnerUUID().IsNil()) - { - m_Writer.AddString("OwnerUUID", Ocelot->GetOwnerUUID().ToShortString()); - } - m_Writer.AddByte("Sitting", Ocelot->IsSitting() ? 1 : 0); - m_Writer.AddInt ("CatType", Ocelot->GetOcelotType()); - m_Writer.AddInt ("Age", Ocelot->GetAge()); - break; - } - case mtPig: - { - m_Writer.AddInt("Age", reinterpret_cast<const cPig *>(a_Monster)->GetAge()); - break; - } - case mtRabbit: - { - const cRabbit * Rabbit = reinterpret_cast<const cRabbit *>(a_Monster); - m_Writer.AddInt("RabbitType", static_cast<Int32>(Rabbit->GetRabbitType())); - m_Writer.AddInt("MoreCarrotTicks", Rabbit->GetMoreCarrotTicks()); - m_Writer.AddInt("Age", Rabbit->GetAge()); - break; - } - case mtInvalidType: case mtBlaze: case mtCaveSpider: case mtChicken: @@ -752,6 +751,11 @@ void cNBTChunkSerializer::AddMonsterEntity(cMonster * a_Monster) // Other mobs have no special tags. break; } + case mtInvalidType: + { + ASSERT(!"cNBTChunkSerializer::AddMonsterEntity: Recieved mob of invalid type"); + break; + } } m_Writer.EndCompound(); } diff --git a/src/WorldStorage/WSSAnvil.cpp b/src/WorldStorage/WSSAnvil.cpp index 158f7a819..b47d3eddd 100755 --- a/src/WorldStorage/WSSAnvil.cpp +++ b/src/WorldStorage/WSSAnvil.cpp @@ -716,22 +716,25 @@ cBlockEntity * cWSSAnvil::LoadBlockEntityFromNBT(const cParsedNBT & a_NBT, int a // Blocktypes that have block entities but don't load their contents from disk: case E_BLOCK_ENDER_CHEST: return nullptr; - } - // All the other blocktypes should have no entities assigned to them. Report an error: - // Get the "id" tag: - int TagID = a_NBT.FindChildByName(a_Tag, "id"); - AString TypeName("<unknown>"); - if (TagID >= 0) - { - TypeName.assign(a_NBT.GetData(TagID), static_cast<size_t>(a_NBT.GetDataLength(TagID))); + default: + { + // All the other blocktypes should have no entities assigned to them. Report an error: + // Get the "id" tag: + int TagID = a_NBT.FindChildByName(a_Tag, "id"); + AString TypeName("<unknown>"); + if (TagID >= 0) + { + TypeName.assign(a_NBT.GetData(TagID), static_cast<size_t>(a_NBT.GetDataLength(TagID))); + } + LOGINFO("WorldLoader(%s): Block entity mismatch: block type %s (%d), type \"%s\", at {%d, %d, %d}; the entity will be lost.", + m_World->GetName().c_str(), + ItemTypeToString(a_BlockType).c_str(), a_BlockType, TypeName.c_str(), + a_BlockX, a_BlockY, a_BlockZ + ); + return nullptr; + } } - LOGINFO("WorldLoader(%s): Block entity mismatch: block type %s (%d), type \"%s\", at {%d, %d, %d}; the entity will be lost.", - m_World->GetName().c_str(), - ItemTypeToString(a_BlockType).c_str(), a_BlockType, TypeName.c_str(), - a_BlockX, a_BlockY, a_BlockZ - ); - return nullptr; } @@ -1645,13 +1648,15 @@ void cWSSAnvil::LoadOldMinecartFromNBT(cEntityList & a_Entities, const cParsedNB { return; } - switch (a_NBT.GetInt(TypeTag)) + int MinecartType = a_NBT.GetInt(TypeTag); + switch (MinecartType) { case 0: LoadMinecartRFromNBT(a_Entities, a_NBT, a_TagIdx); break; // Rideable minecart case 1: LoadMinecartCFromNBT(a_Entities, a_NBT, a_TagIdx); break; // Minecart with chest case 2: LoadMinecartFFromNBT(a_Entities, a_NBT, a_TagIdx); break; // Minecart with furnace case 3: LoadMinecartTFromNBT(a_Entities, a_NBT, a_TagIdx); break; // Minecart with TNT case 4: LoadMinecartHFromNBT(a_Entities, a_NBT, a_TagIdx); break; // Minecart with Hopper + default: LOGWARNING("cWSSAnvil::LoadOldMinecartFromNBT: Unhandled minecart type (%d)", MinecartType); break; } } |