summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2016-08-25 09:04:17 +0200
committerGitHub <noreply@github.com>2016-08-25 09:04:17 +0200
commitd52afadad491474f63e8184cb5a08c0ca21ab48c (patch)
treed5afab6035ca6bb0b58fd03ad5cfe3b3f8e1da55 /src
parentMerge pull request #3342 from cuberite/FixEmptyHeader (diff)
parentFixed type-casting-related warnings. (diff)
downloadcuberite-d52afadad491474f63e8184cb5a08c0ca21ab48c.tar
cuberite-d52afadad491474f63e8184cb5a08c0ca21ab48c.tar.gz
cuberite-d52afadad491474f63e8184cb5a08c0ca21ab48c.tar.bz2
cuberite-d52afadad491474f63e8184cb5a08c0ca21ab48c.tar.lz
cuberite-d52afadad491474f63e8184cb5a08c0ca21ab48c.tar.xz
cuberite-d52afadad491474f63e8184cb5a08c0ca21ab48c.tar.zst
cuberite-d52afadad491474f63e8184cb5a08c0ca21ab48c.zip
Diffstat (limited to '')
-rw-r--r--src/BlockArea.cpp6
-rw-r--r--src/BlockEntities/CMakeLists.txt3
-rw-r--r--src/CMakeLists.txt24
-rw-r--r--src/Generating/CMakeLists.txt10
-rw-r--r--src/Generating/RoughRavines.cpp6
-rw-r--r--src/HTTP/CMakeLists.txt1
-rw-r--r--src/Items/CMakeLists.txt2
-rw-r--r--src/Mobs/CMakeLists.txt2
-rw-r--r--src/Mobs/Rabbit.h1
-rw-r--r--src/PolarSSL++/CMakeLists.txt4
-rw-r--r--src/PolarSSL++/RsaPrivateKey.cpp10
-rw-r--r--src/Protocol/CMakeLists.txt4
-rw-r--r--src/Protocol/Protocol18x.cpp2
-rw-r--r--src/Protocol/Protocol19x.cpp40
-rw-r--r--src/Protocol/Protocol19x.h2
-rw-r--r--src/Simulator/CMakeLists.txt11
-rw-r--r--src/Simulator/FluidSimulator.cpp12
-rw-r--r--src/StringCompression.cpp4
-rw-r--r--src/StringUtils.cpp4
-rw-r--r--src/UI/CMakeLists.txt4
-rw-r--r--src/WorldStorage/CMakeLists.txt7
-rw-r--r--src/WorldStorage/FastNBT.cpp12
-rw-r--r--src/WorldStorage/NBTChunkSerializer.cpp4
-rwxr-xr-xsrc/WorldStorage/WSSAnvil.cpp16
24 files changed, 79 insertions, 112 deletions
diff --git a/src/BlockArea.cpp b/src/BlockArea.cpp
index 438d958b9..b54f6b2e7 100644
--- a/src/BlockArea.cpp
+++ b/src/BlockArea.cpp
@@ -632,9 +632,9 @@ void cBlockArea::DumpToRawFile(const AString & a_FileName)
LOGWARNING("cBlockArea: Cannot open file \"%s\" for raw dump", a_FileName.c_str());
return;
}
- UInt32 SizeX = ntohl(m_Size.x);
- UInt32 SizeY = ntohl(m_Size.y);
- UInt32 SizeZ = ntohl(m_Size.z);
+ UInt32 SizeX = ntohl(static_cast<UInt32>(m_Size.x));
+ UInt32 SizeY = ntohl(static_cast<UInt32>(m_Size.y));
+ UInt32 SizeZ = ntohl(static_cast<UInt32>(m_Size.z));
f.Write(&SizeX, 4);
f.Write(&SizeY, 4);
f.Write(&SizeZ, 4);
diff --git a/src/BlockEntities/CMakeLists.txt b/src/BlockEntities/CMakeLists.txt
index 8e57c172f..96dfa8d85 100644
--- a/src/BlockEntities/CMakeLists.txt
+++ b/src/BlockEntities/CMakeLists.txt
@@ -44,8 +44,7 @@ SET (HDRS
)
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
- set_source_files_properties(BeaconEntity.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=conversion -Wno-error=switch-enum")
- set_source_files_properties(NoteEntity.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=conversion -Wno-error=sign-conversion")
+ set_source_files_properties(BeaconEntity.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=switch-enum")
endif()
if(NOT MSVC)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 11e2f8376..ac1c8138b 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -163,29 +163,13 @@ configure_file("BuildInfo.h.cmake" "${CMAKE_CURRENT_SOURCE_DIR}/BuildInfo.h")
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set_source_files_properties(BiomeDef.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=switch-enum")
- set_source_files_properties(BlockArea.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=sign-conversion")
set_source_files_properties(BlockID.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=global-constructors")
- set_source_files_properties(BoundingBox.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=global-constructors -Wno-error=float-equal")
- set_source_files_properties(ByteBuffer.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=sign-conversion -Wno-error=global-constructors")
- set_source_files_properties(ChunkData.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=sign-conversion ")
- set_source_files_properties(ChunkMap.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=shadow -Wno-error=sign-conversion ")
- set_source_files_properties(ClientHandle.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=conversion -Wno-error=sign-conversion -Wno-error=global-constructors ")
- set_source_files_properties(CompositeChat.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=global-constructors -Wno-error=missing-variable-declarations")
- set_source_files_properties(IniFile.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=sign-conversion ")
- set_source_files_properties(Inventory.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=conversion")
- set_source_files_properties(Item.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=conversion ")
- set_source_files_properties(ItemGrid.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=conversion")
- set_source_files_properties(LightingThread.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=conversion -Wno-error=sign-conversion")
- set_source_files_properties(Map.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=conversion -Wno-error=old-style-cast")
- set_source_files_properties(MobProximityCounter.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=float-equal")
+ set_source_files_properties(BoundingBox.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=global-constructors")
+ set_source_files_properties(ByteBuffer.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=global-constructors")
+ set_source_files_properties(ClientHandle.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=global-constructors ")
+ set_source_files_properties(CompositeChat.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=global-constructors")
set_source_files_properties(MobSpawner.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=switch-enum")
- set_source_files_properties(RCONServer.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=sign-conversion")
- set_source_files_properties(Root.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=sign-conversion -Wno-error=shadow -Wno-error=old-style-cast")
set_source_files_properties(Statistics.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=global-constructors")
- set_source_files_properties(StringUtils.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=conversion ")
- set_source_files_properties(Tracer.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=sign-conversion")
- set_source_files_properties(World.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=sign-conversion ")
- set_source_files_properties(main.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=missing-variable-declarations -Wno-error=missing-prototypes")
endif()
if (NOT MSVC)
diff --git a/src/Generating/CMakeLists.txt b/src/Generating/CMakeLists.txt
index 8b0577129..2cd923a99 100644
--- a/src/Generating/CMakeLists.txt
+++ b/src/Generating/CMakeLists.txt
@@ -71,17 +71,11 @@ SET (HDRS
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set_source_files_properties(BioGen.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=switch-enum")
set_source_files_properties(CompoGenBiomal.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=global-constructors ")
- set_source_files_properties(ComposableGenerator.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=switch-enum -Wno-error=old-style-cast")
- set_source_files_properties(DistortedHeightmap.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=old-style-cast")
- set_source_files_properties(EndGen.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=old-style-cast")
+ set_source_files_properties(ComposableGenerator.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=switch-enum")
set_source_files_properties(FinishGen.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=switch-enum -Wno-error=switch")
- set_source_files_properties(HeiGen.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=old-style-cast")
- set_source_files_properties(Noise3DGenerator.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=old-style-cast")
set_source_files_properties(PieceGenerator.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=global-constructors")
set_source_files_properties(Prefab.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=global-constructors")
- set_source_files_properties(Ravines.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=old-style-cast")
- set_source_files_properties(RoughRavines.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=float-equal -Wno-error=old-style-cast")
- set_source_files_properties(StructGen.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=switch-enum -Wno-error=switch -Wno-error=old-style-cast")
+ set_source_files_properties(StructGen.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=switch-enum -Wno-error=switch")
set_source_files_properties(VillageGen.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=global-constructors -Wno-error=switch-enum")
endif()
diff --git a/src/Generating/RoughRavines.cpp b/src/Generating/RoughRavines.cpp
index c8e4fc9dd..f6f984ab4 100644
--- a/src/Generating/RoughRavines.cpp
+++ b/src/Generating/RoughRavines.cpp
@@ -181,7 +181,7 @@ protected:
{
#ifdef _DEBUG
// DEBUG: Make the roughravine shapepoints visible on a single layer (so that we can see with Minutor what's going on)
- if ((DifX + x == 0) && (DifZ + z == 0))
+ if ((FloorC(DifX + x) == 0) && (FloorC(DifZ + z) == 0))
{
a_ChunkDesc.SetBlockType(x, 4, z, E_BLOCK_LAPIS_ORE);
}
@@ -194,8 +194,8 @@ protected:
continue;
}
- int Top = std::min(static_cast<int>(ceilf(itr->m_Top)), +cChunkDef::Height);
- for (int y = std::max(static_cast<int>(floorf(itr->m_Bottom)), 1); y <= Top; y++)
+ int Top = std::min(CeilC(itr->m_Top), +cChunkDef::Height);
+ for (int y = std::max(FloorC(itr->m_Bottom), 1); y <= Top; y++)
{
if ((itr->m_Radius + m_PerHeightRadius[y]) * (itr->m_Radius + m_PerHeightRadius[y]) < DistSq)
{
diff --git a/src/HTTP/CMakeLists.txt b/src/HTTP/CMakeLists.txt
index 3a2001e67..1e7b0672b 100644
--- a/src/HTTP/CMakeLists.txt
+++ b/src/HTTP/CMakeLists.txt
@@ -35,7 +35,6 @@ SET (HDRS
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set_source_files_properties(HTTPServer.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=global-constructors ")
set_source_files_properties(HTTPServerConnection.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=switch-enum")
- set_source_files_properties(HTTPMessage.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=tautological-compare")
endif()
if(NOT MSVC)
diff --git a/src/Items/CMakeLists.txt b/src/Items/CMakeLists.txt
index f7341bb53..eacc1e53f 100644
--- a/src/Items/CMakeLists.txt
+++ b/src/Items/CMakeLists.txt
@@ -58,7 +58,7 @@ SET (HDRS
)
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
- set_source_files_properties(ItemHandler.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=sign-conversion -Wno-error=conversion -Wno-error=switch-enum")
+ set_source_files_properties(ItemHandler.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=switch-enum")
endif()
if(NOT MSVC)
diff --git a/src/Mobs/CMakeLists.txt b/src/Mobs/CMakeLists.txt
index 85fdb4b1b..44c664b6e 100644
--- a/src/Mobs/CMakeLists.txt
+++ b/src/Mobs/CMakeLists.txt
@@ -81,7 +81,7 @@ SET (HDRS
ZombiePigman.h)
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
- set_source_files_properties(Monster.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=sign-conversion -Wno-error=conversion -Wno-error=switch -Wno-error=switch-enum -Wno-error=float-equal ")
+ set_source_files_properties(Monster.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=switch -Wno-error=switch-enum")
endif()
if(NOT MSVC)
diff --git a/src/Mobs/Rabbit.h b/src/Mobs/Rabbit.h
index aafd979d1..289ff0282 100644
--- a/src/Mobs/Rabbit.h
+++ b/src/Mobs/Rabbit.h
@@ -42,7 +42,6 @@ public:
}
eRabbitType GetRabbitType() const { return m_Type; }
- UInt8 GetRabbitTypeAsNumber() const { return static_cast<UInt8>(GetRabbitType()); }
int GetMoreCarrotTicks() const { return m_MoreCarrotTicks; }
private:
diff --git a/src/PolarSSL++/CMakeLists.txt b/src/PolarSSL++/CMakeLists.txt
index 375e6f51e..3d77e15d1 100644
--- a/src/PolarSSL++/CMakeLists.txt
+++ b/src/PolarSSL++/CMakeLists.txt
@@ -32,10 +32,6 @@ set(HDRS
X509Cert.h
)
-if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
- set_source_files_properties(RsaPrivateKey.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=old-style-cast")
-endif()
-
if(NOT MSVC)
add_library(PolarSSL++ ${SRCS} ${HDRS})
diff --git a/src/PolarSSL++/RsaPrivateKey.cpp b/src/PolarSSL++/RsaPrivateKey.cpp
index 17cede05f..50620ecd4 100644
--- a/src/PolarSSL++/RsaPrivateKey.cpp
+++ b/src/PolarSSL++/RsaPrivateKey.cpp
@@ -3,8 +3,8 @@
#include "Globals.h"
#include "RsaPrivateKey.h"
+#include <polarssl/pk.h>
#include "CtrDrbgContext.h"
-#include "polarssl/pk.h"
@@ -112,7 +112,7 @@ int cRsaPrivateKey::Decrypt(const Byte * a_EncryptedData, size_t a_EncryptedLeng
if (a_EncryptedLength < m_Rsa.len)
{
LOGD("%s: Invalid a_EncryptedLength: got %u, exp at least %u",
- __FUNCTION__, (unsigned)a_EncryptedLength, (unsigned)(m_Rsa.len)
+ __FUNCTION__, static_cast<unsigned>(a_EncryptedLength), static_cast<unsigned>(m_Rsa.len)
);
ASSERT(!"Invalid a_DecryptedMaxLength!");
return -1;
@@ -120,7 +120,7 @@ int cRsaPrivateKey::Decrypt(const Byte * a_EncryptedData, size_t a_EncryptedLeng
if (a_DecryptedMaxLength < m_Rsa.len)
{
LOGD("%s: Invalid a_DecryptedMaxLength: got %u, exp at least %u",
- __FUNCTION__, (unsigned)a_EncryptedLength, (unsigned)(m_Rsa.len)
+ __FUNCTION__, static_cast<unsigned>(a_EncryptedLength), static_cast<unsigned>(m_Rsa.len)
);
ASSERT(!"Invalid a_DecryptedMaxLength!");
return -1;
@@ -146,7 +146,7 @@ int cRsaPrivateKey::Encrypt(const Byte * a_PlainData, size_t a_PlainLength, Byte
if (a_EncryptedMaxLength < m_Rsa.len)
{
LOGD("%s: Invalid a_EncryptedMaxLength: got %u, exp at least %u",
- __FUNCTION__, (unsigned)a_EncryptedMaxLength, (unsigned)(m_Rsa.len)
+ __FUNCTION__, static_cast<unsigned>(a_EncryptedMaxLength), static_cast<unsigned>(m_Rsa.len)
);
ASSERT(!"Invalid a_DecryptedMaxLength!");
return -1;
@@ -154,7 +154,7 @@ int cRsaPrivateKey::Encrypt(const Byte * a_PlainData, size_t a_PlainLength, Byte
if (a_PlainLength < m_Rsa.len)
{
LOGD("%s: Invalid a_PlainLength: got %u, exp at least %u",
- __FUNCTION__, (unsigned)a_PlainLength, (unsigned)(m_Rsa.len)
+ __FUNCTION__, static_cast<unsigned>(a_PlainLength), static_cast<unsigned>(m_Rsa.len)
);
ASSERT(!"Invalid a_PlainLength!");
return -1;
diff --git a/src/Protocol/CMakeLists.txt b/src/Protocol/CMakeLists.txt
index 220449fa3..f3282c93f 100644
--- a/src/Protocol/CMakeLists.txt
+++ b/src/Protocol/CMakeLists.txt
@@ -24,8 +24,8 @@ SET (HDRS
)
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
- set_source_files_properties(Protocol19x.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=old-style-cast -Wno-error=sign-conversion -Wno-error=conversion -Wno-error=switch-enum -Wno-error=switch")
- set_source_files_properties(Protocol18x.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=old-style-cast -Wno-error=sign-conversion -Wno-error=conversion -Wno-error=switch-enum -Wno-error=switch")
+ set_source_files_properties(Protocol19x.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=switch-enum -Wno-error=switch")
+ set_source_files_properties(Protocol18x.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=switch-enum -Wno-error=switch")
endif()
if (NOT MSVC)
diff --git a/src/Protocol/Protocol18x.cpp b/src/Protocol/Protocol18x.cpp
index b158dee4d..88a0757f2 100644
--- a/src/Protocol/Protocol18x.cpp
+++ b/src/Protocol/Protocol18x.cpp
@@ -3471,7 +3471,7 @@ void cProtocol180::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mob)
{
auto & Rabbit = reinterpret_cast<const cRabbit &>(a_Mob);
a_Pkt.WriteBEUInt8(0x12);
- a_Pkt.WriteBEUInt8(Rabbit.GetRabbitTypeAsNumber());
+ a_Pkt.WriteBEUInt8(static_cast<UInt8>(Rabbit.GetRabbitType()));
a_Pkt.WriteBEUInt8(0x0c);
a_Pkt.WriteBEInt8(Rabbit.IsBaby() ? -1 : (Rabbit.IsInLoveCooldown() ? 1 : 0));
break;
diff --git a/src/Protocol/Protocol19x.cpp b/src/Protocol/Protocol19x.cpp
index b0e458691..d8c86cf6b 100644
--- a/src/Protocol/Protocol19x.cpp
+++ b/src/Protocol/Protocol19x.cpp
@@ -402,7 +402,7 @@ void cProtocol190::SendEntityEquipment(const cEntity & a_Entity, short a_SlotNum
{
a_SlotNum++;
}
- Pkt.WriteVarInt32(a_SlotNum);
+ Pkt.WriteVarInt32(static_cast<UInt32>(a_SlotNum));
WriteItem(Pkt, a_Item);
}
@@ -3137,7 +3137,7 @@ void cProtocol190::StartEncryption(const Byte * a_Key)
-eBlockFace cProtocol190::FaceIntToBlockFace(UInt32 a_BlockFace)
+eBlockFace cProtocol190::FaceIntToBlockFace(Int32 a_BlockFace)
{
// Normalize the blockface values returned from the protocol
// Anything known gets mapped 1:1, everything else returns BLOCK_FACE_NONE
@@ -3543,14 +3543,10 @@ void cProtocol190::WriteEntityMetadata(cPacketizer & a_Pkt, const cEntity & a_En
a_Pkt.WriteBEUInt8(METADATA_TYPE_VARINT);
// The following expression makes Minecarts shake more with less health or higher damage taken
- // It gets half the maximum health, and takes it away from the current health minus the half health:
- /*
- Health: 5 | 3 - (5 - 3) = 1 (shake power)
- Health: 3 | 3 - (3 - 3) = 3
- Health: 1 | 3 - (1 - 3) = 5
- */
auto & Minecart = reinterpret_cast<const cMinecart &>(a_Entity);
- a_Pkt.WriteVarInt32((((a_Entity.GetMaxHealth() / 2) - (a_Entity.GetHealth() - (a_Entity.GetMaxHealth() / 2))) * Minecart.LastDamage()) * 4);
+ auto maxHealth = a_Entity.GetMaxHealth();
+ auto curHealth = a_Entity.GetHealth();
+ a_Pkt.WriteVarInt32(static_cast<UInt32>((maxHealth - curHealth) * Minecart.LastDamage() * 4));
a_Pkt.WriteBEUInt8(6); // Index 6: Shaking direction (doesn't seem to effect anything)
a_Pkt.WriteBEUInt8(METADATA_TYPE_VARINT);
@@ -3570,11 +3566,11 @@ void cProtocol190::WriteEntityMetadata(cPacketizer & a_Pkt, const cEntity & a_En
a_Pkt.WriteBEUInt8(METADATA_TYPE_VARINT);
int Content = MinecartContent.m_ItemType;
Content |= MinecartContent.m_ItemDamage << 8;
- a_Pkt.WriteVarInt32(Content);
+ a_Pkt.WriteVarInt32(static_cast<UInt32>(Content));
a_Pkt.WriteBEUInt8(9); // Index 9: Block ID and damage
a_Pkt.WriteBEUInt8(METADATA_TYPE_VARINT);
- a_Pkt.WriteVarInt32(RideableMinecart.GetBlockHeight());
+ a_Pkt.WriteVarInt32(static_cast<UInt32>(RideableMinecart.GetBlockHeight()));
a_Pkt.WriteBEUInt8(10); // Index 10: Show block
a_Pkt.WriteBEUInt8(METADATA_TYPE_BOOL);
@@ -3718,7 +3714,7 @@ void cProtocol190::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mob)
auto & Creeper = reinterpret_cast<const cCreeper &>(a_Mob);
a_Pkt.WriteBEUInt8(11); // Index 11: State (idle or "blowing")
a_Pkt.WriteBEUInt8(METADATA_TYPE_VARINT);
- a_Pkt.WriteVarInt32(Creeper.IsBlowing() ? 1 : -1);
+ a_Pkt.WriteVarInt32(Creeper.IsBlowing() ? 1 : 0xffffffff);
a_Pkt.WriteBEUInt8(12); // Index 12: Is charged
a_Pkt.WriteBEUInt8(METADATA_TYPE_BOOL);
@@ -3736,7 +3732,7 @@ void cProtocol190::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mob)
a_Pkt.WriteBEUInt8(11); // Index 11: Carried block
a_Pkt.WriteBEUInt8(METADATA_TYPE_BLOCKID);
UInt32 Carried = 0;
- Carried |= Enderman.GetCarriedBlock() << 4;
+ Carried |= static_cast<UInt32>(Enderman.GetCarriedBlock() << 4);
Carried |= Enderman.GetCarriedMeta();
a_Pkt.WriteVarInt32(Carried);
@@ -3789,18 +3785,18 @@ void cProtocol190::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mob)
a_Pkt.WriteBEUInt8(13); // Index 13: Variant / type
a_Pkt.WriteBEUInt8(METADATA_TYPE_VARINT);
- a_Pkt.WriteVarInt32(Horse.GetHorseType());
+ a_Pkt.WriteVarInt32(static_cast<UInt32>(Horse.GetHorseType()));
a_Pkt.WriteBEUInt8(14); // Index 14: Color / style
a_Pkt.WriteBEUInt8(METADATA_TYPE_VARINT);
int Appearance = 0;
Appearance = Horse.GetHorseColor();
Appearance |= Horse.GetHorseStyle() << 8;
- a_Pkt.WriteVarInt32(Appearance);
+ a_Pkt.WriteVarInt32(static_cast<UInt32>(Appearance));
a_Pkt.WriteBEUInt8(16); // Index 16: Armor
a_Pkt.WriteBEUInt8(METADATA_TYPE_VARINT);
- a_Pkt.WriteVarInt32(Horse.GetHorseArmour());
+ a_Pkt.WriteVarInt32(static_cast<UInt32>(Horse.GetHorseArmour()));
a_Pkt.WriteBEUInt8(11); // Index 11: Is baby
a_Pkt.WriteBEUInt8(METADATA_TYPE_BOOL);
@@ -3813,7 +3809,7 @@ void cProtocol190::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mob)
auto & MagmaCube = reinterpret_cast<const cMagmaCube &>(a_Mob);
a_Pkt.WriteBEUInt8(11); // Index 11: Size
a_Pkt.WriteBEUInt8(METADATA_TYPE_VARINT);
- a_Pkt.WriteVarInt32(MagmaCube.GetSize());
+ a_Pkt.WriteVarInt32(static_cast<UInt32>(MagmaCube.GetSize()));
break;
} // case mtMagmaCube
@@ -3873,7 +3869,7 @@ void cProtocol190::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mob)
a_Pkt.WriteBEUInt8(12); // Index 12: sheared, color
a_Pkt.WriteBEUInt8(METADATA_TYPE_BYTE);
Int8 SheepMetadata = 0;
- SheepMetadata = static_cast<Byte>(Sheep.GetFurColor());
+ SheepMetadata = static_cast<Int8>(Sheep.GetFurColor());
if (Sheep.IsSheared())
{
SheepMetadata |= 0x10;
@@ -3891,7 +3887,7 @@ void cProtocol190::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mob)
a_Pkt.WriteBEUInt8(12); // Index 12: Type
a_Pkt.WriteBEUInt8(METADATA_TYPE_VARINT);
- a_Pkt.WriteVarInt32(Rabbit.GetRabbitTypeAsNumber());
+ a_Pkt.WriteVarInt32(static_cast<UInt32>(Rabbit.GetRabbitType()));
break;
} // case mtRabbit
@@ -3909,7 +3905,7 @@ void cProtocol190::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mob)
auto & Slime = reinterpret_cast<const cSlime &>(a_Mob);
a_Pkt.WriteBEUInt8(11); // Index 11: Size
a_Pkt.WriteBEUInt8(METADATA_TYPE_VARINT);
- a_Pkt.WriteVarInt32(Slime.GetSize());
+ a_Pkt.WriteVarInt32(static_cast<UInt32>(Slime.GetSize()));
break;
} // case mtSlime
@@ -3922,7 +3918,7 @@ void cProtocol190::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mob)
a_Pkt.WriteBEUInt8(12); // Index 12: Type
a_Pkt.WriteBEUInt8(METADATA_TYPE_VARINT);
- a_Pkt.WriteVarInt32(Villager.GetVilType());
+ a_Pkt.WriteVarInt32(static_cast<UInt32>(Villager.GetVilType()));
break;
} // case mtVillager
@@ -3980,7 +3976,7 @@ void cProtocol190::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mob)
a_Pkt.WriteBEUInt8(16); // Index 16: Collar color
a_Pkt.WriteBEUInt8(METADATA_TYPE_VARINT);
- a_Pkt.WriteVarInt32(Wolf.GetCollarColor());
+ a_Pkt.WriteVarInt32(static_cast<UInt32>(Wolf.GetCollarColor()));
break;
} // case mtWolf
diff --git a/src/Protocol/Protocol19x.h b/src/Protocol/Protocol19x.h
index d23653702..2bf8df4f5 100644
--- a/src/Protocol/Protocol19x.h
+++ b/src/Protocol/Protocol19x.h
@@ -258,7 +258,7 @@ protected:
/** Converts the BlockFace received by the protocol into eBlockFace constants.
If the received value doesn't match any of our eBlockFace constants, BLOCK_FACE_NONE is returned. */
- eBlockFace FaceIntToBlockFace(UInt32 a_FaceInt);
+ eBlockFace FaceIntToBlockFace(Int32 a_FaceInt);
/** Writes the item data into a packet. */
void WriteItem(cPacketizer & a_Pkt, const cItem & a_Item);
diff --git a/src/Simulator/CMakeLists.txt b/src/Simulator/CMakeLists.txt
index dcd099890..45972a6ef 100644
--- a/src/Simulator/CMakeLists.txt
+++ b/src/Simulator/CMakeLists.txt
@@ -11,7 +11,8 @@ SET (SRCS
Simulator.cpp
SimulatorManager.cpp
VanillaFluidSimulator.cpp
- VaporizeFluidSimulator.cpp)
+ VaporizeFluidSimulator.cpp
+)
SET (HDRS
DelayedFluidSimulator.h
@@ -25,14 +26,10 @@ SET (HDRS
Simulator.h
SimulatorManager.h
VanillaFluidSimulator.h
- VaporizeFluidSimulator.h)
+ VaporizeFluidSimulator.h
+)
-if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
- set_source_files_properties(FireSimulator.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=sign-conversion")
- set_source_files_properties(FluidSimulator.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=sign-conversion -Wno-error=shadow")
-endif()
-
if(NOT MSVC)
add_library(Simulator ${SRCS} ${HDRS})
endif()
diff --git a/src/Simulator/FluidSimulator.cpp b/src/Simulator/FluidSimulator.cpp
index 10e4fee21..fce5e64b9 100644
--- a/src/Simulator/FluidSimulator.cpp
+++ b/src/Simulator/FluidSimulator.cpp
@@ -120,7 +120,7 @@ bool cFluidSimulator::IsHigherMeta(NIBBLETYPE a_Meta1, NIBBLETYPE a_Meta2)
// TODO Not working very well yet :s
Direction cFluidSimulator::GetFlowingDirection(int a_X, int a_Y, int a_Z, bool a_Over)
{
- if ((a_Y < 0) || (a_Y >= cChunkDef::Height))
+ if (!cChunkDef::IsValidHeight(a_Y))
{
return NONE;
}
@@ -157,11 +157,11 @@ Direction cFluidSimulator::GetFlowingDirection(int a_X, int a_Y, int a_Z, bool a
Points.push_back(new Vector3i(a_X, a_Y, a_Z + 1));
Points.push_back(new Vector3i(a_X, a_Y, a_Z - 1));
- for (std::vector<Vector3i *>::iterator it = Points.begin(); it < Points.end(); ++it)
+ for (auto itr = Points.cbegin(), end = Points.cend(); itr != end; ++itr)
{
- Vector3i *Pos = (*it);
- BLOCKTYPE BlockID = m_World.GetBlock(Pos->x, Pos->y, Pos->z);
- if (IsAllowedBlock(BlockID))
+ Vector3i * Pos = (*itr);
+ auto PosBlockID = m_World.GetBlock(Pos->x, Pos->y, Pos->z);
+ if (IsAllowedBlock(PosBlockID))
{
NIBBLETYPE Meta = m_World.GetBlockMeta(Pos->x, Pos->y, Pos->z);
@@ -172,7 +172,7 @@ Direction cFluidSimulator::GetFlowingDirection(int a_X, int a_Y, int a_Z, bool a
Z = Pos->z;
}
}
- else if (BlockID == E_BLOCK_AIR)
+ else if (PosBlockID == E_BLOCK_AIR)
{
LowestPoint = 9; // This always dominates
X = Pos->x;
diff --git a/src/StringCompression.cpp b/src/StringCompression.cpp
index 8be6d0026..ff434bbb1 100644
--- a/src/StringCompression.cpp
+++ b/src/StringCompression.cpp
@@ -16,7 +16,7 @@ int CompressString(const char * a_Data, size_t a_Length, AString & a_Compressed,
// HACK: We're assuming that AString returns its internal buffer in its data() call and we're overwriting that buffer!
// It saves us one allocation and one memcpy of the entire compressed data
- // It may not work on some STL implementations! (Confirmed working on MSVC 2008 & 2010)
+ // It may not work on some STL implementations! (Confirmed working on all currently used MSVC, GCC and Clang versions)
a_Compressed.resize(CompressedSize);
int errorcode = compress2(reinterpret_cast<Bytef *>(const_cast<char *>(a_Compressed.data())), &CompressedSize, reinterpret_cast<const Bytef *>(a_Data), static_cast<uLong>(a_Length), a_Factor);
if (errorcode != Z_OK)
@@ -35,7 +35,7 @@ int UncompressString(const char * a_Data, size_t a_Length, AString & a_Uncompres
{
// HACK: We're assuming that AString returns its internal buffer in its data() call and we're overwriting that buffer!
// It saves us one allocation and one memcpy of the entire compressed data
- // It may not work on some STL implementations! (Confirmed working on MSVC 2008 & 2010)
+ // It may not work on some STL implementations! (Confirmed working on all currently used MSVC, GCC and Clang versions)
a_Uncompressed.resize(a_UncompressedSize);
uLongf UncompressedSize = static_cast<uLongf>(a_UncompressedSize); // On some architectures the uLongf is different in size to int, that may be the cause of the -5 error
int errorcode = uncompress(reinterpret_cast<Bytef *>(const_cast<char *>(a_Uncompressed.data())), &UncompressedSize, reinterpret_cast<const Bytef *>(a_Data), static_cast<uLong>(a_Length));
diff --git a/src/StringUtils.cpp b/src/StringUtils.cpp
index 8ea94ecd7..521aa79f4 100644
--- a/src/StringUtils.cpp
+++ b/src/StringUtils.cpp
@@ -558,8 +558,8 @@ std::u16string UTF8ToRawBEUTF16(const AString & a_UTF8)
{
// target is a character in range 0xFFFF - 0x10FFFF.
ch -= halfBase;
- unsigned short v1 = htons((ch >> halfShift) + UNI_SUR_HIGH_START);
- unsigned short v2 = htons((ch & halfMask) + UNI_SUR_LOW_START);
+ auto v1 = htons(static_cast<uint16_t>((ch >> halfShift) + UNI_SUR_HIGH_START));
+ auto v2 = htons(static_cast<uint16_t>((ch & halfMask) + UNI_SUR_LOW_START));
UTF16.push_back(static_cast<char16_t>(v1));
UTF16.push_back(static_cast<char16_t>(v2));
}
diff --git a/src/UI/CMakeLists.txt b/src/UI/CMakeLists.txt
index e1e82c88d..d71e08ade 100644
--- a/src/UI/CMakeLists.txt
+++ b/src/UI/CMakeLists.txt
@@ -35,8 +35,8 @@ SET (HDRS
WindowOwner.h)
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
- set_source_files_properties(SlotArea.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=conversion -Wno-error=switch-enum -Wno-error=sign-conversion ")
- set_source_files_properties(Window.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=conversion -Wno-error=switch-enum -Wno-error=sign-conversion ")
+ set_source_files_properties(SlotArea.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=switch-enum ")
+ set_source_files_properties(Window.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=switch-enum ")
endif()
if(NOT MSVC)
diff --git a/src/WorldStorage/CMakeLists.txt b/src/WorldStorage/CMakeLists.txt
index b16e03160..c351420f4 100644
--- a/src/WorldStorage/CMakeLists.txt
+++ b/src/WorldStorage/CMakeLists.txt
@@ -29,11 +29,10 @@ SET (HDRS
)
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 -Wno-error=global-constructors")
- 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 ")
+ 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)
diff --git a/src/WorldStorage/FastNBT.cpp b/src/WorldStorage/FastNBT.cpp
index 608269aad..7d99b927a 100644
--- a/src/WorldStorage/FastNBT.cpp
+++ b/src/WorldStorage/FastNBT.cpp
@@ -439,7 +439,7 @@ void cFastNBTWriter::AddByte(const AString & a_Name, unsigned char a_Value)
void cFastNBTWriter::AddShort(const AString & a_Name, Int16 a_Value)
{
TagCommon(a_Name, TAG_Short);
- UInt16 Value = htons(a_Value);
+ UInt16 Value = htons(static_cast<UInt16>(a_Value));
m_Result.append(reinterpret_cast<const char *>(&Value), 2);
}
@@ -450,7 +450,7 @@ void cFastNBTWriter::AddShort(const AString & a_Name, Int16 a_Value)
void cFastNBTWriter::AddInt(const AString & a_Name, Int32 a_Value)
{
TagCommon(a_Name, TAG_Int);
- UInt32 Value = htonl(a_Value);
+ UInt32 Value = htonl(static_cast<UInt32>(a_Value));
m_Result.append(reinterpret_cast<const char *>(&Value), 4);
}
@@ -494,7 +494,7 @@ void cFastNBTWriter::AddDouble(const AString & a_Name, double a_Value)
void cFastNBTWriter::AddString(const AString & a_Name, const AString & a_Value)
{
TagCommon(a_Name, TAG_String);
- UInt16 len = htons(static_cast<short>(a_Value.size()));
+ UInt16 len = htons(static_cast<UInt16>(a_Value.size()));
m_Result.append(reinterpret_cast<const char *>(&len), 2);
m_Result.append(a_Value.c_str(), a_Value.size());
}
@@ -506,7 +506,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_int len = htonl(static_cast<u_int>(a_NumElements));
+ UInt32 len = htonl(static_cast<UInt32>(a_NumElements));
m_Result.append(reinterpret_cast<const char *>(&len), 4);
m_Result.append(a_Value, a_NumElements);
}
@@ -518,7 +518,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_int len = htonl(static_cast<u_int>(a_NumElements));
+ UInt32 len = htonl(static_cast<UInt32>(a_NumElements));
size_t cap = m_Result.capacity();
size_t size = m_Result.length();
if ((cap - size) < (4 + a_NumElements * 4))
@@ -528,7 +528,7 @@ void cFastNBTWriter::AddIntArray(const AString & a_Name, const int * a_Value, si
m_Result.append(reinterpret_cast<const char *>(&len), 4);
for (size_t i = 0; i < a_NumElements; i++)
{
- UInt32 Element = htonl(a_Value[i]);
+ UInt32 Element = htonl(static_cast<UInt32>(a_Value[i]));
m_Result.append(reinterpret_cast<const char *>(&Element), 4);
}
}
diff --git a/src/WorldStorage/NBTChunkSerializer.cpp b/src/WorldStorage/NBTChunkSerializer.cpp
index 86ad10af2..a825e4785 100644
--- a/src/WorldStorage/NBTChunkSerializer.cpp
+++ b/src/WorldStorage/NBTChunkSerializer.cpp
@@ -665,8 +665,8 @@ void cNBTChunkSerializer::AddMonsterEntity(cMonster * a_Monster)
}
case mtRabbit:
{
- const cRabbit *Rabbit = reinterpret_cast<const cRabbit *>(a_Monster);
- m_Writer.AddInt("RabbitType", Rabbit->GetRabbitTypeAsNumber());
+ 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;
diff --git a/src/WorldStorage/WSSAnvil.cpp b/src/WorldStorage/WSSAnvil.cpp
index 4fc855589..3fd104004 100755
--- a/src/WorldStorage/WSSAnvil.cpp
+++ b/src/WorldStorage/WSSAnvil.cpp
@@ -2882,8 +2882,7 @@ void cWSSAnvil::LoadWolfFromNBT(cEntityList & a_Entities, const cParsedNBT & a_N
case TAG_Byte:
{
// Vanilla uses this
- unsigned char CollarColor = a_NBT.GetByte(CollarColorIdx);
- Monster->SetCollarColor(CollarColor);
+ Monster->SetCollarColor(a_NBT.GetByte(CollarColorIdx));
break;
}
case TAG_Int:
@@ -2892,6 +2891,11 @@ void cWSSAnvil::LoadWolfFromNBT(cEntityList & a_Entities, const cParsedNBT & a_N
Monster->SetCollarColor(a_NBT.GetInt(CollarColorIdx));
break;
}
+ default:
+ {
+ // No other values are interpreted
+ break;
+ }
}
}
@@ -3381,7 +3385,7 @@ bool cWSSAnvil::cMCAFile::SetChunkData(const cChunkCoords & a_Chunk, const AStri
// Store the chunk data:
m_File.Seek(static_cast<int>(ChunkSector * 4096));
- u_long ChunkSize = htonl(static_cast<u_long>(a_Data.size()) + 1);
+ UInt32 ChunkSize = htonl(static_cast<UInt32>(a_Data.size() + 1));
if (m_File.Write(&ChunkSize, 4) != 4)
{
LOGWARNING("Cannot save chunk [%d, %d], writing(1) data to file \"%s\" failed", a_Chunk.m_ChunkX, a_Chunk.m_ChunkZ, GetFileName().c_str());
@@ -3408,7 +3412,7 @@ bool cWSSAnvil::cMCAFile::SetChunkData(const cChunkCoords & a_Chunk, const AStri
}
// Store the header:
- ChunkSize = (static_cast<u_long>(a_Data.size()) + MCA_CHUNK_HEADER_LENGTH + 4095) / 4096; // Round data size up to nearest 4KB sector, make it a sector number
+ ChunkSize = (static_cast<UInt32>(a_Data.size()) + MCA_CHUNK_HEADER_LENGTH + 4095) / 4096; // Round data size up to nearest 4KB sector, make it a sector number
if (ChunkSize > 255)
{
LOGWARNING("Cannot save chunk [%d, %d], the data is too large (%u KiB, maximum is 1024 KiB). Remove some entities and retry.",
@@ -3418,10 +3422,10 @@ bool cWSSAnvil::cMCAFile::SetChunkData(const cChunkCoords & a_Chunk, const AStri
}
// Store the header info in the table
- m_Header[LocalX + 32 * LocalZ] = htonl((ChunkSector << 8) | ChunkSize);
+ m_Header[LocalX + 32 * LocalZ] = htonl(static_cast<UInt32>((ChunkSector << 8) | ChunkSize));
// Set the modification time
- m_TimeStamps[LocalX + 32 * LocalZ] = htonl(static_cast<u_long>(time(nullptr)));
+ m_TimeStamps[LocalX + 32 * LocalZ] = htonl(static_cast<UInt32>(time(nullptr)));
if (m_File.Seek(0) < 0)
{