From 77f1f58c0a7eb55001b375f1945690ed5c1e87a2 Mon Sep 17 00:00:00 2001 From: tycho Date: Tue, 19 May 2015 19:32:10 +0100 Subject: Make -Werror disabling file only Ad fix a load of warnings --- src/WorldStorage/CMakeLists.txt | 8 ++++++++ src/WorldStorage/EnchantmentSerializer.cpp | 6 +++--- src/WorldStorage/FastNBT.cpp | 6 +++--- src/WorldStorage/FireworksSerializer.cpp | 2 +- src/WorldStorage/MapSerializer.cpp | 12 ++++++------ 5 files changed, 21 insertions(+), 13 deletions(-) (limited to 'src/WorldStorage') diff --git a/src/WorldStorage/CMakeLists.txt b/src/WorldStorage/CMakeLists.txt index 59193db2a..b511fc412 100644 --- a/src/WorldStorage/CMakeLists.txt +++ b/src/WorldStorage/CMakeLists.txt @@ -28,6 +28,14 @@ SET (HDRS WSSAnvil.h WorldStorage.h) +if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + set_source_files_properties(FastNBT.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=sign-conversion") + 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 -Wno-error=sign-conversion -Wno-error=conversion") + set_source_files_properties(SchematicFileSerializer.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=shadow -Wno-error=conversion") + set_source_files_properties(WSSAnvil.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=sign-conversion -Wno-error=shorten-64-to-32 -Wno-error=switch -Wno-error=switch-enum -Wno-error=conversion") +endif() + if(NOT MSVC) add_library(WorldStorage ${SRCS} ${HDRS}) diff --git a/src/WorldStorage/EnchantmentSerializer.cpp b/src/WorldStorage/EnchantmentSerializer.cpp index a6e562956..b28e16b1d 100644 --- a/src/WorldStorage/EnchantmentSerializer.cpp +++ b/src/WorldStorage/EnchantmentSerializer.cpp @@ -14,8 +14,8 @@ void EnchantmentSerializer::WriteToNBTCompound(const cEnchantments & a_Enchantme for (cEnchantments::cMap::const_iterator itr = a_Enchantments.m_Enchantments.begin(), end = a_Enchantments.m_Enchantments.end(); itr != end; ++itr) { a_Writer.BeginCompound(""); - a_Writer.AddShort("id", itr->first); - a_Writer.AddShort("lvl", itr->second); + a_Writer.AddShort("id", static_cast(itr->first)); + a_Writer.AddShort("lvl", static_cast(itr->second)); a_Writer.EndCompound(); } // for itr - m_Enchantments[] a_Writer.EndList(); @@ -82,7 +82,7 @@ void EnchantmentSerializer::ParseFromNBT(cEnchantments & a_Enchantments, const c } // Store the enchantment: - a_Enchantments.m_Enchantments[id] = lvl; + a_Enchantments.m_Enchantments[id] = static_cast(lvl); } // for tag - children of the ench list tag } diff --git a/src/WorldStorage/FastNBT.cpp b/src/WorldStorage/FastNBT.cpp index 033a07601..f77197914 100644 --- a/src/WorldStorage/FastNBT.cpp +++ b/src/WorldStorage/FastNBT.cpp @@ -257,7 +257,7 @@ bool cParsedNBT::ReadTag(void) return true; } - default: + case TAG_Min: { ASSERT(!"Unhandled NBT tag type"); return false; @@ -503,7 +503,7 @@ void cFastNBTWriter::AddString(const AString & a_Name, const AString & a_Value) void cFastNBTWriter::AddByteArray(const AString & a_Name, const char * a_Value, size_t a_NumElements) { TagCommon(a_Name, TAG_ByteArray); - u_long len = htonl(static_cast(a_NumElements)); + u_int len = htonl(static_cast(a_NumElements)); m_Result.append(reinterpret_cast(&len), 4); m_Result.append(a_Value, a_NumElements); } @@ -515,7 +515,7 @@ void cFastNBTWriter::AddByteArray(const AString & a_Name, const char * a_Value, void cFastNBTWriter::AddIntArray(const AString & a_Name, const int * a_Value, size_t a_NumElements) { TagCommon(a_Name, TAG_IntArray); - u_long len = htonl(static_cast(a_NumElements)); + u_int len = htonl(static_cast(a_NumElements)); size_t cap = m_Result.capacity(); size_t size = m_Result.length(); if ((cap - size) < (4 + a_NumElements * 4)) diff --git a/src/WorldStorage/FireworksSerializer.cpp b/src/WorldStorage/FireworksSerializer.cpp index 91a5b8b63..0398f4da8 100644 --- a/src/WorldStorage/FireworksSerializer.cpp +++ b/src/WorldStorage/FireworksSerializer.cpp @@ -14,7 +14,7 @@ void cFireworkItem::WriteToNBTCompound(const cFireworkItem & a_FireworkItem, cFa case E_ITEM_FIREWORK_ROCKET: { a_Writer.BeginCompound("Fireworks"); - a_Writer.AddByte("Flight", a_FireworkItem.m_FlightTimeInTicks / 20); + a_Writer.AddByte("Flight", static_cast(a_FireworkItem.m_FlightTimeInTicks / 20)); a_Writer.BeginList("Explosions", TAG_Compound); a_Writer.BeginCompound(""); a_Writer.AddByte("Flicker", a_FireworkItem.m_HasFlicker); diff --git a/src/WorldStorage/MapSerializer.cpp b/src/WorldStorage/MapSerializer.cpp index da7b9d929..d4925dcab 100644 --- a/src/WorldStorage/MapSerializer.cpp +++ b/src/WorldStorage/MapSerializer.cpp @@ -102,11 +102,11 @@ void cMapSerializer::SaveMapToNBT(cFastNBTWriter & a_Writer) { a_Writer.BeginCompound("data"); - a_Writer.AddByte("scale", m_Map->GetScale()); - a_Writer.AddByte("dimension", (int) m_Map->GetDimension()); + a_Writer.AddByte("scale", static_cast(m_Map->GetScale())); + a_Writer.AddByte("dimension", static_cast(m_Map->GetDimension())); - a_Writer.AddShort("width", m_Map->GetWidth()); - a_Writer.AddShort("height", m_Map->GetHeight()); + a_Writer.AddShort("width", static_cast(m_Map->GetWidth())); + a_Writer.AddShort("height", static_cast(m_Map->GetHeight())); a_Writer.AddInt("xCenter", m_Map->GetCenterX()); a_Writer.AddInt("zCenter", m_Map->GetCenterZ()); @@ -235,7 +235,7 @@ bool cIDCountSerializer::Load(void) int CurrLine = NBT.FindChildByName(0, "map"); if (CurrLine >= 0) { - m_MapCount = (int)NBT.GetShort(CurrLine) + 1; + m_MapCount = static_cast(NBT.GetShort(CurrLine) + 1); } else { @@ -255,7 +255,7 @@ bool cIDCountSerializer::Save(void) if (m_MapCount > 0) { - Writer.AddShort("map", m_MapCount - 1); + Writer.AddShort("map", static_cast(m_MapCount - 1)); } Writer.Finish(); -- cgit v1.2.3