summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSamuel Barney <samjbarney@gmail.com>2015-07-29 17:04:03 +0200
committerSamuel Barney <samjbarney@gmail.com>2015-07-29 17:49:30 +0200
commit804805d35a87c2acc9425d1762ad26b1ba2ec9ac (patch)
tree13b603c8bbf8177da92ce87f5413fb646d204f3f
parentMerge pull request #2376 from mjhanninen/fix-freebsd-build (diff)
downloadcuberite-804805d35a87c2acc9425d1762ad26b1ba2ec9ac.tar
cuberite-804805d35a87c2acc9425d1762ad26b1ba2ec9ac.tar.gz
cuberite-804805d35a87c2acc9425d1762ad26b1ba2ec9ac.tar.bz2
cuberite-804805d35a87c2acc9425d1762ad26b1ba2ec9ac.tar.lz
cuberite-804805d35a87c2acc9425d1762ad26b1ba2ec9ac.tar.xz
cuberite-804805d35a87c2acc9425d1762ad26b1ba2ec9ac.tar.zst
cuberite-804805d35a87c2acc9425d1762ad26b1ba2ec9ac.zip
-rw-r--r--src/Bindings/CMakeLists.txt6
-rw-r--r--src/Bindings/DeprecatedBindings.cpp70
-rw-r--r--src/Bindings/LuaState.cpp36
-rw-r--r--src/Bindings/LuaState.h1
-rw-r--r--src/Bindings/ManualBindings.cpp116
-rw-r--r--src/Bindings/ManualBindings_World.cpp8
-rw-r--r--src/Bindings/Plugin.h2
-rw-r--r--src/Bindings/PluginLua.cpp164
-rw-r--r--src/Bindings/PluginLua.h2
-rw-r--r--src/Bindings/PluginManager.cpp2
-rw-r--r--src/Bindings/PluginManager.h2
-rw-r--r--src/BlockEntities/BeaconEntity.cpp4
-rw-r--r--src/BlockEntities/NoteEntity.cpp4
-rw-r--r--src/Blocks/BlockAnvil.h4
-rw-r--r--src/Blocks/BlockCocoaPod.h2
-rw-r--r--src/Blocks/BlockCrops.h6
-rw-r--r--src/Blocks/BlockGlowstone.h2
-rw-r--r--src/Blocks/BlockLeaves.h4
-rw-r--r--src/Blocks/BlockLever.h2
-rw-r--r--src/Blocks/BlockMelon.h2
-rw-r--r--src/Blocks/BlockMobHead.h2
-rw-r--r--src/Blocks/BlockMobSpawner.h2
-rw-r--r--src/Blocks/BlockNetherWart.h2
-rw-r--r--src/Blocks/BlockOre.h4
-rw-r--r--src/Blocks/BlockPiston.cpp4
-rw-r--r--src/Blocks/BlockPlanks.h2
-rw-r--r--src/Blocks/BlockQuartz.h2
-rw-r--r--src/Blocks/BlockSeaLantern.h2
-rw-r--r--src/Blocks/BlockSideways.h2
-rw-r--r--src/Blocks/BlockSignPost.h2
-rw-r--r--src/Blocks/BlockTrapdoor.h2
-rw-r--r--src/Blocks/BlockVine.h4
-rw-r--r--src/Blocks/CMakeLists.txt5
-rw-r--r--src/ByteBuffer.cpp14
-rw-r--r--src/CMakeLists.txt21
-rw-r--r--src/Chunk.cpp50
-rw-r--r--src/ChunkData.cpp30
-rw-r--r--src/ChunkData.h2
-rw-r--r--src/ChunkMap.cpp38
-rw-r--r--src/ClientHandle.cpp46
-rw-r--r--src/ClientHandle.h2
-rw-r--r--src/Color.h4
-rw-r--r--src/Entities/ArrowEntity.cpp10
-rw-r--r--src/Entities/CMakeLists.txt10
-rw-r--r--src/Entities/Entity.cpp98
-rw-r--r--src/Entities/EntityEffect.cpp42
-rw-r--r--src/Entities/Floater.cpp19
-rw-r--r--src/Entities/Floater.h10
-rw-r--r--src/Entities/Minecart.h2
-rw-r--r--src/Entities/Player.cpp44
-rw-r--r--src/Entities/Player.h6
-rw-r--r--src/Generating/CMakeLists.txt8
-rw-r--r--src/Generating/Caves.cpp16
-rw-r--r--src/Generating/ChunkGenerator.cpp6
-rw-r--r--src/Generating/CompoGen.cpp16
-rw-r--r--src/Generating/CompoGenBiomal.cpp18
-rw-r--r--src/HTTPServer/CMakeLists.txt2
-rw-r--r--src/HTTPServer/HTTPServer.cpp4
-rw-r--r--src/IniFile.cpp92
-rw-r--r--src/Inventory.cpp6
-rw-r--r--src/Item.cpp30
-rw-r--r--src/ItemGrid.cpp6
-rw-r--r--src/Items/CMakeLists.txt2
-rw-r--r--src/Items/ItemEmptyMap.h2
-rw-r--r--src/Items/ItemFishingRod.h18
-rw-r--r--src/Items/ItemHandler.cpp5
-rw-r--r--src/Items/ItemLighter.h4
-rw-r--r--src/Items/ItemMap.h2
-rw-r--r--src/Items/ItemMinecart.h6
-rw-r--r--src/Items/ItemSlab.h2
-rw-r--r--src/Items/ItemSword.h5
-rw-r--r--src/LightingThread.cpp24
-rw-r--r--src/LightingThread.h8
-rw-r--r--src/LinearInterpolation.cpp16
-rw-r--r--src/Matrix4.h4
-rw-r--r--src/MobProximityCounter.cpp4
-rw-r--r--src/Mobs/CMakeLists.txt4
-rw-r--r--src/Mobs/Monster.cpp26
-rw-r--r--src/Mobs/SnowGolem.cpp8
-rw-r--r--src/Mobs/Villager.cpp16
-rw-r--r--src/Noise/CMakeLists.txt5
-rw-r--r--src/Noise/InterpolNoise.h22
-rw-r--r--src/Noise/Noise.cpp16
-rw-r--r--src/OSSupport/CMakeLists.txt2
-rw-r--r--src/OSSupport/File.cpp10
-rw-r--r--src/OSSupport/GZipFile.cpp4
-rw-r--r--src/Protocol/CMakeLists.txt6
-rw-r--r--src/Protocol/ChunkDataSerializer.cpp10
-rw-r--r--src/Protocol/MojangAPI.cpp6
-rw-r--r--src/Protocol/Protocol.h2
-rw-r--r--src/Protocol/Protocol17x.cpp57
-rw-r--r--src/Protocol/Protocol17x.h2
-rw-r--r--src/Protocol/Protocol18x.cpp179
-rw-r--r--src/Protocol/Protocol18x.h2
-rw-r--r--src/Protocol/ProtocolRecognizer.cpp12
-rw-r--r--src/Protocol/ProtocolRecognizer.h2
-rw-r--r--src/RCONServer.cpp2
-rw-r--r--src/Root.cpp10
-rw-r--r--src/Simulator/CMakeLists.txt2
-rw-r--r--src/Simulator/FireSimulator.cpp10
-rw-r--r--src/Simulator/FluidSimulator.cpp4
-rw-r--r--src/Simulator/IncrementalRedstoneSimulator.cpp28
-rw-r--r--src/StringCompression.cpp32
-rw-r--r--src/StringUtils.cpp46
-rw-r--r--src/Tracer.cpp4
-rw-r--r--src/UI/CMakeLists.txt5
-rw-r--r--src/UI/ChestWindow.cpp6
-rw-r--r--src/UI/SlotArea.cpp56
-rw-r--r--src/UI/SlotArea.h2
-rw-r--r--src/UI/Window.cpp16
-rw-r--r--src/World.cpp54
-rw-r--r--src/WorldStorage/CMakeLists.txt14
-rw-r--r--src/WorldStorage/FastNBT.cpp20
-rw-r--r--src/WorldStorage/MapSerializer.cpp10
-rw-r--r--src/WorldStorage/NBTChunkSerializer.cpp150
-rw-r--r--src/WorldStorage/SchematicFileSerializer.cpp10
-rwxr-xr-xsrc/WorldStorage/WSSAnvil.cpp122
117 files changed, 1103 insertions, 1119 deletions
diff --git a/src/Bindings/CMakeLists.txt b/src/Bindings/CMakeLists.txt
index 0a069ad85..edcda273e 100644
--- a/src/Bindings/CMakeLists.txt
+++ b/src/Bindings/CMakeLists.txt
@@ -146,16 +146,10 @@ set_source_files_properties(${BINDING_OUTPUTS} PROPERTIES GENERATED TRUE)
set_source_files_properties(${CMAKE_SOURCE_DIR}/src/Bindings/Bindings.cpp PROPERTIES COMPILE_FLAGS -Wno-error)
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
- set_source_files_properties(DeprecatedBindings.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=old-style-cast")
- set_source_files_properties(LuaState.cpp COMPILE_FLAGS "-Wno-error=old-style-cast")
set_source_files_properties(LuaWindow.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=switch-enum")
- set_source_files_properties(ManualBindings.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=old-style-cast")
- set_source_files_properties(ManualBindings_World.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=old-style-cast")
- set_source_files_properties(PluginLua.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=old-style-cast")
endif()
if(NOT MSVC)
add_library(Bindings ${SRCS} ${HDRS})
-
target_link_libraries(Bindings lua sqlite tolualib mbedtls)
endif()
diff --git a/src/Bindings/DeprecatedBindings.cpp b/src/Bindings/DeprecatedBindings.cpp
index 6dd6a4e59..574a017a6 100644
--- a/src/Bindings/DeprecatedBindings.cpp
+++ b/src/Bindings/DeprecatedBindings.cpp
@@ -19,7 +19,7 @@
#ifndef TOLUA_DISABLE_tolua_get_AllToLua_g_BlockLightValue
static int tolua_get_AllToLua_g_BlockLightValue(lua_State* tolua_S)
{
- int BlockType;
+ BLOCKTYPE BlockType;
#ifndef TOLUA_RELEASE
{
tolua_Error tolua_err;
@@ -29,12 +29,12 @@ static int tolua_get_AllToLua_g_BlockLightValue(lua_State* tolua_S)
}
}
#endif
- BlockType = (int)tolua_tonumber(tolua_S, 2, 0);
+ BlockType = static_cast<BLOCKTYPE>(tolua_tonumber(tolua_S, 2, 0));
if ((BlockType < 0) || (BlockType > E_BLOCK_MAX_TYPE_ID))
{
tolua_error(tolua_S, "array indexing out of range.", nullptr);
}
- tolua_pushnumber(tolua_S, (lua_Number)cBlockInfo::GetLightValue((BLOCKTYPE)BlockType));
+ tolua_pushnumber(tolua_S, static_cast<lua_Number>(cBlockInfo::GetLightValue(BlockType)));
return 1;
}
#endif // #ifndef TOLUA_DISABLE
@@ -47,7 +47,7 @@ static int tolua_get_AllToLua_g_BlockLightValue(lua_State* tolua_S)
#ifndef TOLUA_DISABLE_tolua_get_AllToLua_g_BlockSpreadLightFalloff
static int tolua_get_AllToLua_g_BlockSpreadLightFalloff(lua_State* tolua_S)
{
- int BlockType;
+ BLOCKTYPE BlockType;
#ifndef TOLUA_RELEASE
{
tolua_Error tolua_err;
@@ -57,12 +57,12 @@ static int tolua_get_AllToLua_g_BlockSpreadLightFalloff(lua_State* tolua_S)
}
}
#endif
- BlockType = (int)tolua_tonumber(tolua_S, 2, 0);
+ BlockType = static_cast<BLOCKTYPE>(tolua_tonumber(tolua_S, 2, 0));
if ((BlockType < 0) || (BlockType > E_BLOCK_MAX_TYPE_ID))
{
tolua_error(tolua_S, "array indexing out of range.", nullptr);
}
- tolua_pushnumber(tolua_S, (lua_Number)cBlockInfo::GetSpreadLightFalloff((BLOCKTYPE)BlockType));
+ tolua_pushnumber(tolua_S, static_cast<lua_Number>(cBlockInfo::GetSpreadLightFalloff(BlockType)));
return 1;
}
#endif // #ifndef TOLUA_DISABLE
@@ -75,7 +75,7 @@ static int tolua_get_AllToLua_g_BlockSpreadLightFalloff(lua_State* tolua_S)
#ifndef TOLUA_DISABLE_tolua_get_AllToLua_g_BlockTransparent
static int tolua_get_AllToLua_g_BlockTransparent(lua_State* tolua_S)
{
- int BlockType;
+ BLOCKTYPE BlockType;
#ifndef TOLUA_RELEASE
{
tolua_Error tolua_err;
@@ -85,12 +85,12 @@ static int tolua_get_AllToLua_g_BlockTransparent(lua_State* tolua_S)
}
}
#endif
- BlockType = (int)tolua_tonumber(tolua_S, 2, 0);
+ BlockType = static_cast<BLOCKTYPE>(tolua_tonumber(tolua_S, 2, 0));
if ((BlockType < 0) || (BlockType > E_BLOCK_MAX_TYPE_ID))
{
tolua_error(tolua_S, "array indexing out of range.", nullptr);
}
- tolua_pushboolean(tolua_S, cBlockInfo::IsTransparent((BLOCKTYPE)BlockType));
+ tolua_pushboolean(tolua_S, cBlockInfo::IsTransparent(BlockType));
return 1;
}
#endif // #ifndef TOLUA_DISABLE
@@ -103,7 +103,7 @@ static int tolua_get_AllToLua_g_BlockTransparent(lua_State* tolua_S)
#ifndef TOLUA_DISABLE_tolua_get_AllToLua_g_BlockOneHitDig
static int tolua_get_AllToLua_g_BlockOneHitDig(lua_State* tolua_S)
{
- int BlockType;
+ BLOCKTYPE BlockType;
#ifndef TOLUA_RELEASE
{
tolua_Error tolua_err;
@@ -113,12 +113,12 @@ static int tolua_get_AllToLua_g_BlockOneHitDig(lua_State* tolua_S)
}
}
#endif
- BlockType = (int)tolua_tonumber(tolua_S, 2, 0);
+ BlockType = static_cast<BLOCKTYPE>(tolua_tonumber(tolua_S, 2, 0));
if ((BlockType < 0) || (BlockType > E_BLOCK_MAX_TYPE_ID))
{
tolua_error(tolua_S, "array indexing out of range.", nullptr);
}
- tolua_pushboolean(tolua_S, cBlockInfo::IsOneHitDig((BLOCKTYPE)BlockType));
+ tolua_pushboolean(tolua_S, cBlockInfo::IsOneHitDig(BlockType));
return 1;
}
#endif // #ifndef TOLUA_DISABLE
@@ -131,7 +131,7 @@ static int tolua_get_AllToLua_g_BlockOneHitDig(lua_State* tolua_S)
#ifndef TOLUA_DISABLE_tolua_get_AllToLua_g_BlockPistonBreakable
static int tolua_get_AllToLua_g_BlockPistonBreakable(lua_State* tolua_S)
{
- int BlockType;
+ BLOCKTYPE BlockType;
#ifndef TOLUA_RELEASE
{
tolua_Error tolua_err;
@@ -141,12 +141,12 @@ static int tolua_get_AllToLua_g_BlockPistonBreakable(lua_State* tolua_S)
}
}
#endif
- BlockType = (int)tolua_tonumber(tolua_S, 2, 0);
+ BlockType = static_cast<BLOCKTYPE>(tolua_tonumber(tolua_S, 2, 0));
if ((BlockType < 0) || (BlockType > E_BLOCK_MAX_TYPE_ID))
{
tolua_error(tolua_S, "array indexing out of range.", nullptr);
}
- tolua_pushboolean(tolua_S, cBlockInfo::IsPistonBreakable((BLOCKTYPE)BlockType));
+ tolua_pushboolean(tolua_S, cBlockInfo::IsPistonBreakable(BlockType));
return 1;
}
#endif // #ifndef TOLUA_DISABLE
@@ -159,7 +159,7 @@ static int tolua_get_AllToLua_g_BlockPistonBreakable(lua_State* tolua_S)
#ifndef TOLUA_DISABLE_tolua_get_AllToLua_g_BlockIsSnowable
static int tolua_get_AllToLua_g_BlockIsSnowable(lua_State* tolua_S)
{
- int BlockType;
+ BLOCKTYPE BlockType;
#ifndef TOLUA_RELEASE
{
tolua_Error tolua_err;
@@ -169,12 +169,12 @@ static int tolua_get_AllToLua_g_BlockIsSnowable(lua_State* tolua_S)
}
}
#endif
- BlockType = (int)tolua_tonumber(tolua_S, 2, 0);
+ BlockType = static_cast<BLOCKTYPE>(tolua_tonumber(tolua_S, 2, 0));
if ((BlockType < 0) || (BlockType > E_BLOCK_MAX_TYPE_ID))
{
tolua_error(tolua_S, "array indexing out of range.", nullptr);
}
- tolua_pushboolean(tolua_S, cBlockInfo::IsSnowable((BLOCKTYPE)BlockType));
+ tolua_pushboolean(tolua_S, cBlockInfo::IsSnowable(BlockType));
return 1;
}
#endif // #ifndef TOLUA_DISABLE
@@ -187,7 +187,7 @@ static int tolua_get_AllToLua_g_BlockIsSnowable(lua_State* tolua_S)
#ifndef TOLUA_DISABLE_tolua_get_AllToLua_g_BlockIsSolid
static int tolua_get_AllToLua_g_BlockIsSolid(lua_State* tolua_S)
{
- int BlockType;
+ BLOCKTYPE BlockType;
#ifndef TOLUA_RELEASE
{
tolua_Error tolua_err;
@@ -197,12 +197,12 @@ static int tolua_get_AllToLua_g_BlockIsSolid(lua_State* tolua_S)
}
}
#endif
- BlockType = (int)tolua_tonumber(tolua_S, 2, 0);
+ BlockType = static_cast<BLOCKTYPE>(tolua_tonumber(tolua_S, 2, 0));
if ((BlockType < 0) || (BlockType > E_BLOCK_MAX_TYPE_ID))
{
tolua_error(tolua_S, "array indexing out of range.", nullptr);
}
- tolua_pushboolean(tolua_S, (bool)cBlockInfo::IsSolid((BLOCKTYPE)BlockType));
+ tolua_pushboolean(tolua_S, static_cast<bool>(cBlockInfo::IsSolid(BlockType)));
return 1;
}
#endif // #ifndef TOLUA_DISABLE
@@ -215,7 +215,7 @@ static int tolua_get_AllToLua_g_BlockIsSolid(lua_State* tolua_S)
#ifndef TOLUA_DISABLE_tolua_get_AllToLua_g_BlockFullyOccupiesVoxel
static int tolua_get_AllToLua_g_BlockFullyOccupiesVoxel(lua_State* tolua_S)
{
- int BlockType;
+ BLOCKTYPE BlockType;
#ifndef TOLUA_RELEASE
{
tolua_Error tolua_err;
@@ -225,12 +225,12 @@ static int tolua_get_AllToLua_g_BlockFullyOccupiesVoxel(lua_State* tolua_S)
}
}
#endif
- BlockType = (int)tolua_tonumber(tolua_S, 2, 0);
+ BlockType = static_cast<BLOCKTYPE>(tolua_tonumber(tolua_S, 2, 0));
if ((BlockType < 0) || (BlockType > E_BLOCK_MAX_TYPE_ID))
{
tolua_error(tolua_S, "array indexing out of range.", nullptr);
}
- tolua_pushboolean(tolua_S, (bool)cBlockInfo::FullyOccupiesVoxel((BLOCKTYPE)BlockType));
+ tolua_pushboolean(tolua_S, static_cast<bool>(cBlockInfo::FullyOccupiesVoxel(BlockType)));
return 1;
}
#endif // #ifndef TOLUA_DISABLE
@@ -256,8 +256,8 @@ static int tolua_AllToLua_StringToMobType00(lua_State* tolua_S)
{
const AString a_MobString = tolua_tocppstring(LuaState, 1, 0);
eMonsterType MobType = cMonster::StringToMobType(a_MobString);
- tolua_pushnumber(LuaState, (lua_Number) MobType);
- tolua_pushcppstring(LuaState, (const char *) a_MobString);
+ tolua_pushnumber(LuaState, static_cast<lua_Number>(MobType));
+ tolua_pushcppstring(LuaState, a_MobString);
}
LOGWARNING("Warning in function call 'StringToMobType': StringToMobType() is deprecated. Please use cMonster:StringToMobType()");
@@ -298,15 +298,15 @@ static int tolua_cWorld_SetSignLines(lua_State * tolua_S)
else
#endif
{
- cWorld * self = (cWorld *) tolua_tousertype (LuaState, 1, nullptr);
- int BlockX = (int) tolua_tonumber (LuaState, 2, 0);
- int BlockY = (int) tolua_tonumber (LuaState, 3, 0);
- int BlockZ = (int) tolua_tonumber (LuaState, 4, 0);
- const AString Line1 = tolua_tocppstring(LuaState, 5, 0);
- const AString Line2 = tolua_tocppstring(LuaState, 6, 0);
- const AString Line3 = tolua_tocppstring(LuaState, 7, 0);
- const AString Line4 = tolua_tocppstring(LuaState, 8, 0);
- cPlayer * Player = (cPlayer *)tolua_tousertype (LuaState, 9, nullptr);
+ cWorld * self = reinterpret_cast<cWorld *>(tolua_tousertype (LuaState, 1, nullptr));
+ cPlayer * Player = reinterpret_cast<cPlayer*>(tolua_tousertype (LuaState, 9, nullptr));
+ int BlockX = static_cast<int>(tolua_tonumber(LuaState, 2, 0));
+ int BlockY = static_cast<int>(tolua_tonumber(LuaState, 3, 0));
+ int BlockZ = static_cast<int>(tolua_tonumber(LuaState, 4, 0));
+ const AString Line1 = tolua_tocppstring(LuaState, 5, 0);
+ const AString Line2 = tolua_tocppstring(LuaState, 6, 0);
+ const AString Line3 = tolua_tocppstring(LuaState, 7, 0);
+ const AString Line4 = tolua_tocppstring(LuaState, 8, 0);
#ifndef TOLUA_RELEASE
if (self == nullptr)
{
diff --git a/src/Bindings/LuaState.cpp b/src/Bindings/LuaState.cpp
index a0fdecb8b..7c0d2a121 100644
--- a/src/Bindings/LuaState.cpp
+++ b/src/Bindings/LuaState.cpp
@@ -379,7 +379,7 @@ void cLuaState::Push(const AStringVector & a_Vector)
{
ASSERT(IsValid());
- lua_createtable(m_LuaState, (int)a_Vector.size(), 0);
+ lua_createtable(m_LuaState, static_cast<int>(a_Vector.size()), 0);
int newTable = lua_gettop(m_LuaState);
int index = 1;
for (AStringVector::const_iterator itr = a_Vector.begin(), end = a_Vector.end(); itr != end; ++itr, ++index)
@@ -398,7 +398,7 @@ void cLuaState::Push(const cCraftingGrid * a_Grid)
{
ASSERT(IsValid());
- tolua_pushusertype(m_LuaState, (void *)a_Grid, "cCraftingGrid");
+ tolua_pushusertype(m_LuaState, reinterpret_cast<void *>(const_cast<cCraftingGrid *>(a_Grid)), "cCraftingGrid");
m_NumCurrentFunctionArgs += 1;
}
@@ -410,7 +410,7 @@ void cLuaState::Push(const cCraftingRecipe * a_Recipe)
{
ASSERT(IsValid());
- tolua_pushusertype(m_LuaState, (void *)a_Recipe, "cCraftingRecipe");
+ tolua_pushusertype(m_LuaState, reinterpret_cast<void *>(const_cast<cCraftingRecipe *>(a_Recipe)), "cCraftingRecipe");
m_NumCurrentFunctionArgs += 1;
}
@@ -434,7 +434,7 @@ void cLuaState::Push(const cItems & a_Items)
{
ASSERT(IsValid());
- tolua_pushusertype(m_LuaState, (void *)&a_Items, "cItems");
+ tolua_pushusertype(m_LuaState, reinterpret_cast<void *>(const_cast<cItems *>(&a_Items)), "cItems");
m_NumCurrentFunctionArgs += 1;
}
@@ -446,7 +446,7 @@ void cLuaState::Push(const cPlayer * a_Player)
{
ASSERT(IsValid());
- tolua_pushusertype(m_LuaState, (void *)a_Player, "cPlayer");
+ tolua_pushusertype(m_LuaState, reinterpret_cast<void *>(const_cast<cPlayer *>(a_Player)), "cPlayer");
m_NumCurrentFunctionArgs += 1;
}
@@ -470,7 +470,7 @@ void cLuaState::Push(const HTTPRequest * a_Request)
{
ASSERT(IsValid());
- tolua_pushusertype(m_LuaState, (void *)a_Request, "HTTPRequest");
+ tolua_pushusertype(m_LuaState, reinterpret_cast<void *>(const_cast<HTTPRequest *>(a_Request)), "HTTPRequest");
m_NumCurrentFunctionArgs += 1;
}
@@ -482,7 +482,7 @@ void cLuaState::Push(const HTTPTemplateRequest * a_Request)
{
ASSERT(IsValid());
- tolua_pushusertype(m_LuaState, (void *)a_Request, "HTTPTemplateRequest");
+ tolua_pushusertype(m_LuaState, reinterpret_cast<void *>(const_cast<HTTPTemplateRequest *>(a_Request)), "HTTPTemplateRequest");
m_NumCurrentFunctionArgs += 1;
}
@@ -494,7 +494,7 @@ void cLuaState::Push(const Vector3d & a_Vector)
{
ASSERT(IsValid());
- tolua_pushusertype(m_LuaState, (void *)&a_Vector, "Vector3<double>");
+ tolua_pushusertype(m_LuaState, reinterpret_cast<void *>(const_cast<Vector3d *>(&a_Vector)), "Vector3<double>");
m_NumCurrentFunctionArgs += 1;
}
@@ -506,7 +506,7 @@ void cLuaState::Push(const Vector3d * a_Vector)
{
ASSERT(IsValid());
- tolua_pushusertype(m_LuaState, (void *)a_Vector, "Vector3<double>");
+ tolua_pushusertype(m_LuaState, reinterpret_cast<void *>(const_cast<Vector3d *>(a_Vector)), "Vector3<double>");
m_NumCurrentFunctionArgs += 1;
}
@@ -518,7 +518,7 @@ void cLuaState::Push(const Vector3i & a_Vector)
{
ASSERT(IsValid());
- tolua_pushusertype(m_LuaState, (void *)&a_Vector, "Vector3<int>");
+ tolua_pushusertype(m_LuaState, reinterpret_cast<void *>(const_cast<Vector3i *>(&a_Vector)), "Vector3<int>");
m_NumCurrentFunctionArgs += 1;
}
@@ -530,7 +530,7 @@ void cLuaState::Push(const Vector3i * a_Vector)
{
ASSERT(IsValid());
- tolua_pushusertype(m_LuaState, (void *)a_Vector, "Vector3<int>");
+ tolua_pushusertype(m_LuaState, reinterpret_cast<void *>(const_cast<Vector3i *>(a_Vector)), "Vector3<int>");
m_NumCurrentFunctionArgs += 1;
}
@@ -676,6 +676,18 @@ void cLuaState::Push(int a_Value)
+void cLuaState::Push(UInt32 a_Value)
+{
+ ASSERT(IsValid());
+
+ tolua_pushnumber(m_LuaState, a_Value);
+ m_NumCurrentFunctionArgs += 1;
+}
+
+
+
+
+
void cLuaState::Push(void * a_Ptr)
{
UNUSED(a_Ptr);
@@ -1406,7 +1418,7 @@ void cLuaState::LogStack(lua_State * a_LuaState, const char * a_Header)
{
case LUA_TBOOLEAN: Value.assign((lua_toboolean(a_LuaState, i) != 0) ? "true" : "false"); break;
case LUA_TLIGHTUSERDATA: Printf(Value, "%p", lua_touserdata(a_LuaState, i)); break;
- case LUA_TNUMBER: Printf(Value, "%f", (double)lua_tonumber(a_LuaState, i)); break;
+ case LUA_TNUMBER: Printf(Value, "%f", static_cast<double>(lua_tonumber(a_LuaState, i))); break;
case LUA_TSTRING: Printf(Value, "%s", lua_tostring(a_LuaState, i)); break;
case LUA_TTABLE: Printf(Value, "%p", lua_topointer(a_LuaState, i)); break;
default: break;
diff --git a/src/Bindings/LuaState.h b/src/Bindings/LuaState.h
index cc8214646..759fdc54f 100644
--- a/src/Bindings/LuaState.h
+++ b/src/Bindings/LuaState.h
@@ -248,6 +248,7 @@ public:
void Push(cLuaUDPEndpoint * a_UDPEndpoint);
void Push(double a_Value);
void Push(int a_Value);
+ void Push(const UInt32 a_Value);
void Push(void * a_Ptr);
void Push(std::chrono::milliseconds a_time);
diff --git a/src/Bindings/ManualBindings.cpp b/src/Bindings/ManualBindings.cpp
index 7655d8c83..e4420c39a 100644
--- a/src/Bindings/ManualBindings.cpp
+++ b/src/Bindings/ManualBindings.cpp
@@ -319,7 +319,7 @@ static AString GetLogMessage(lua_State * tolua_S)
tolua_Error err;
if (tolua_isusertype(tolua_S, 1, "cCompositeChat", false, &err))
{
- return ((cCompositeChat *)tolua_tousertype(tolua_S, 1, nullptr))->ExtractText();
+ return reinterpret_cast<cCompositeChat *>(tolua_tousertype(tolua_S, 1, nullptr))->ExtractText();
}
else
{
@@ -352,7 +352,7 @@ static int tolua_LOG(lua_State * tolua_S)
tolua_Error err;
if (tolua_isusertype(tolua_S, 1, "cCompositeChat", false, &err))
{
- LogLevel = cCompositeChat::MessageTypeToLogLevel(((cCompositeChat *)tolua_tousertype(tolua_S, 1, nullptr))->GetMessageType());
+ LogLevel = cCompositeChat::MessageTypeToLogLevel(reinterpret_cast<cCompositeChat *>(tolua_tousertype(tolua_S, 1, nullptr))->GetMessageType());
}
// Log the message:
@@ -472,7 +472,7 @@ cPluginLua * cManualBindings::GetLuaPlugin(lua_State * L)
lua_pop(L, 1);
return nullptr;
}
- cPluginLua * Plugin = (cPluginLua *)lua_topointer(L, -1);
+ cPluginLua * Plugin = reinterpret_cast<cPluginLua *>(const_cast<void*>(lua_topointer(L, -1)));
lua_pop(L, 1);
return Plugin;
@@ -602,7 +602,7 @@ static int tolua_cPluginManager_AddHook_FnRef(cPluginManager * a_PluginManager,
}
// Retrieve and check the hook type
- int HookType = (int)tolua_tonumber(S, a_ParamIdx, -1);
+ int HookType = static_cast<int>(tolua_tonumber(S, a_ParamIdx, -1));
if (!a_PluginManager->IsValidHookType(HookType))
{
LOGWARNING("cPluginManager.AddHook(): Invalid HOOK_TYPE parameter: %d", HookType);
@@ -634,7 +634,7 @@ static int tolua_cPluginManager_AddHook_DefFn(cPluginManager * a_PluginManager,
// The arg types have already been checked
// Retrieve and check the cPlugin parameter
- cPluginLua * Plugin = (cPluginLua *)tolua_tousertype(S, a_ParamIdx, nullptr);
+ cPluginLua * Plugin = reinterpret_cast<cPluginLua *>(tolua_tousertype(S, a_ParamIdx, nullptr));
if (Plugin == nullptr)
{
LOGWARNING("cPluginManager.AddHook(): Invalid Plugin parameter, expected a valid cPlugin object. Hook not added");
@@ -650,7 +650,7 @@ static int tolua_cPluginManager_AddHook_DefFn(cPluginManager * a_PluginManager,
}
// Retrieve and check the hook type
- int HookType = (int)tolua_tonumber(S, a_ParamIdx + 1, -1);
+ int HookType = static_cast<int>(tolua_tonumber(S, a_ParamIdx + 1, -1));
if (!a_PluginManager->IsValidHookType(HookType))
{
LOGWARNING("cPluginManager.AddHook(): Invalid HOOK_TYPE parameter: %d", HookType);
@@ -707,7 +707,7 @@ static int tolua_cPluginManager_AddHook(lua_State * tolua_S)
if (tolua_isusertype(S, 1, "cPluginManager", 0, &err))
{
// Style 2 or 3, retrieve the PlgMgr instance
- PlgMgr = (cPluginManager *)tolua_tousertype(S, 1, nullptr);
+ PlgMgr = reinterpret_cast<cPluginManager *>(tolua_tousertype(S, 1, nullptr));
if (PlgMgr == nullptr)
{
LOGWARNING("Malformed plugin, use cPluginManager.AddHook(HOOK_TYPE, CallbackFunction). Fixing the call for you.");
@@ -1148,7 +1148,7 @@ static int tolua_cPlayer_GetPermissions(lua_State * tolua_S)
}
// Get the params:
- cPlayer * self = (cPlayer *)tolua_tousertype(tolua_S, 1, nullptr);
+ cPlayer * self = reinterpret_cast<cPlayer *>(tolua_tousertype(tolua_S, 1, nullptr));
if (self == nullptr)
{
LOGWARNING("%s: invalid self (%p)", __FUNCTION__, self);
@@ -1179,7 +1179,7 @@ static int tolua_cPlayer_GetRestrictions(lua_State * tolua_S)
}
// Get the params:
- cPlayer * self = (cPlayer *)tolua_tousertype(tolua_S, 1, nullptr);
+ cPlayer * self = reinterpret_cast<cPlayer *>(tolua_tousertype(tolua_S, 1, nullptr));
if (self == nullptr)
{
LOGWARNING("%s: invalid self (%p)", __FUNCTION__, self);
@@ -1207,8 +1207,8 @@ static int tolua_cPlayer_OpenWindow(lua_State * tolua_S)
}
// Get the parameters:
- cPlayer * self = (cPlayer *)tolua_tousertype(tolua_S, 1, nullptr);
- cWindow * wnd = (cWindow *)tolua_tousertype(tolua_S, 2, nullptr);
+ cPlayer * self = reinterpret_cast<cPlayer *>(tolua_tousertype(tolua_S, 1, nullptr));
+ cWindow * wnd = reinterpret_cast<cWindow *>(tolua_tousertype(tolua_S, 2, nullptr));
if ((self == nullptr) || (wnd == nullptr))
{
LOGWARNING("%s: invalid self (%p) or wnd (%p)", __FUNCTION__, self, wnd);
@@ -1219,7 +1219,7 @@ static int tolua_cPlayer_OpenWindow(lua_State * tolua_S)
tolua_Error err;
if (tolua_isusertype(tolua_S, 2, "cLuaWindow", 0, &err))
{
- cLuaWindow * LuaWnd = (cLuaWindow *)wnd;
+ cLuaWindow * LuaWnd = reinterpret_cast<cLuaWindow *>(wnd);
// Only if not already referenced
if (!LuaWnd->IsLuaReferenced())
{
@@ -1289,7 +1289,7 @@ static int tolua_SetObjectCallback(lua_State * tolua_S)
}
// Get the parameters - self and the function reference:
- OBJTYPE * self = (OBJTYPE *)tolua_tousertype(tolua_S, 1, nullptr);
+ OBJTYPE * self = reinterpret_cast<OBJTYPE *>(tolua_tousertype(tolua_S, 1, nullptr));
if (self == nullptr)
{
LOGWARNING("%s: invalid self (%p)", __FUNCTION__, self);
@@ -1313,7 +1313,7 @@ static int tolua_SetObjectCallback(lua_State * tolua_S)
static int tolua_cPluginLua_AddWebTab(lua_State * tolua_S)
{
- cPluginLua * self = (cPluginLua *)tolua_tousertype(tolua_S, 1, nullptr);
+ cPluginLua * self = reinterpret_cast<cPluginLua *>(tolua_tousertype(tolua_S, 1, nullptr));
tolua_Error tolua_err;
tolua_err.array = 0;
@@ -1329,7 +1329,7 @@ static int tolua_cPluginLua_AddWebTab(lua_State * tolua_S)
)
{
Reference = luaL_ref(tolua_S, LUA_REGISTRYINDEX);
- Title = ((std::string)tolua_tocppstring(tolua_S, 2, 0));
+ Title = (static_cast<std::string>(tolua_tocppstring(tolua_S, 2, 0)));
}
else
{
@@ -1400,13 +1400,13 @@ static int tolua_md5(lua_State * tolua_S)
// Calculate the raw md5 checksum byte array:
unsigned char Output[16];
size_t len = 0;
- const unsigned char * SourceString = (const unsigned char *)lua_tolstring(tolua_S, 1, &len);
+ const unsigned char * SourceString = reinterpret_cast<const unsigned char *>(lua_tolstring(tolua_S, 1, &len));
if (SourceString == nullptr)
{
return 0;
}
md5(SourceString, len, Output);
- lua_pushlstring(tolua_S, (const char *)Output, ARRAYCOUNT(Output));
+ lua_pushlstring(tolua_S, reinterpret_cast<const char *>(Output), ARRAYCOUNT(Output));
return 1;
}
@@ -1431,7 +1431,7 @@ static int tolua_md5HexString(lua_State * tolua_S)
// Calculate the raw md5 checksum byte array:
unsigned char md5Output[16];
size_t len = 0;
- const unsigned char * SourceString = (const unsigned char *)lua_tolstring(tolua_S, 1, &len);
+ const unsigned char * SourceString = reinterpret_cast<const unsigned char *>(lua_tolstring(tolua_S, 1, &len));
if (SourceString == nullptr)
{
return 0;
@@ -1458,13 +1458,13 @@ static int tolua_sha1(lua_State * tolua_S)
// Calculate the raw SHA1 checksum byte array from the input string:
unsigned char Output[20];
size_t len = 0;
- const unsigned char * SourceString = (const unsigned char *)lua_tolstring(tolua_S, 1, &len);
+ const unsigned char * SourceString = reinterpret_cast<const unsigned char *>(lua_tolstring(tolua_S, 1, &len));
if (SourceString == nullptr)
{
return 0;
}
sha1(SourceString, len, Output);
- lua_pushlstring(tolua_S, (const char *)Output, ARRAYCOUNT(Output));
+ lua_pushlstring(tolua_S, reinterpret_cast<const char *>(Output), ARRAYCOUNT(Output));
return 1;
}
@@ -1477,7 +1477,7 @@ static int tolua_sha1HexString(lua_State * tolua_S)
// Calculate the raw SHA1 checksum byte array from the input string:
unsigned char sha1Output[20];
size_t len = 0;
- const unsigned char * SourceString = (const unsigned char *)lua_tolstring(tolua_S, 1, &len);
+ const unsigned char * SourceString = reinterpret_cast<const unsigned char *>(lua_tolstring(tolua_S, 1, &len));
if (SourceString == nullptr)
{
return 0;
@@ -1565,18 +1565,18 @@ static int tolua_get_HTTPRequest_FormData(lua_State* tolua_S)
static int tolua_cWebAdmin_GetPlugins(lua_State * tolua_S)
{
- cWebAdmin * self = (cWebAdmin *)tolua_tousertype(tolua_S, 1, nullptr);
+ cWebAdmin * self = reinterpret_cast<cWebAdmin *>(tolua_tousertype(tolua_S, 1, nullptr));
const cWebAdmin::PluginList & AllPlugins = self->GetPlugins();
- lua_createtable(tolua_S, (int)AllPlugins.size(), 0);
+ lua_createtable(tolua_S, static_cast<int>(AllPlugins.size()), 0);
int newTable = lua_gettop(tolua_S);
int index = 1;
cWebAdmin::PluginList::const_iterator iter = AllPlugins.begin();
while (iter != AllPlugins.end())
{
const cWebPlugin * Plugin = *iter;
- tolua_pushusertype(tolua_S, (void *)Plugin, "const cWebPlugin");
+ tolua_pushusertype(tolua_S, reinterpret_cast<void *>(const_cast<cWebPlugin*>(Plugin)), "const cWebPlugin");
lua_rawseti(tolua_S, newTable, index);
++iter;
++index;
@@ -1676,7 +1676,7 @@ static int tolua_cClientHandle_SendPluginMessage(lua_State * L)
{
return 0;
}
- cClientHandle * Client = (cClientHandle *)tolua_tousertype(L, 1, nullptr);
+ cClientHandle * Client = reinterpret_cast<cClientHandle *>(tolua_tousertype(L, 1, nullptr));
if (Client == nullptr)
{
LOGWARNING("ClientHandle is nil in cClientHandle:SendPluginMessage()");
@@ -1922,8 +1922,8 @@ static int Lua_ItemGrid_GetSlotCoords(lua_State * L)
}
{
- const cItemGrid * self = (const cItemGrid *)tolua_tousertype(L, 1, nullptr);
- int SlotNum = (int)tolua_tonumber(L, 2, 0);
+ const cItemGrid * self = reinterpret_cast<const cItemGrid *>(tolua_tousertype(L, 1, nullptr));
+ int SlotNum = static_cast<int>(tolua_tonumber(L, 2, 0));
if (self == nullptr)
{
tolua_error(L, "invalid 'self' in function 'cItemGrid:GetSlotCoords'", nullptr);
@@ -1931,8 +1931,8 @@ static int Lua_ItemGrid_GetSlotCoords(lua_State * L)
}
int X, Y;
self->GetSlotCoords(SlotNum, X, Y);
- tolua_pushnumber(L, (lua_Number)X);
- tolua_pushnumber(L, (lua_Number)Y);
+ tolua_pushnumber(L, static_cast<lua_Number>(X));
+ tolua_pushnumber(L, static_cast<lua_Number>(Y));
return 2;
}
@@ -2063,7 +2063,7 @@ static int tolua_cLineBlockTracer_Trace(lua_State * tolua_S)
}
// Trace:
- cWorld * World = (cWorld *)tolua_tousertype(L, idx, nullptr);
+ cWorld * World = reinterpret_cast<cWorld *>(tolua_tousertype(L, idx, nullptr));
cLuaBlockTracerCallbacks Callbacks(L, idx + 1);
double StartX = tolua_tonumber(L, idx + 2, 0);
double StartY = tolua_tonumber(L, idx + 3, 0);
@@ -2179,22 +2179,22 @@ static int tolua_cHopperEntity_GetOutputBlockPos(lua_State * tolua_S)
{
return 0;
}
- cHopperEntity * self = (cHopperEntity *)tolua_tousertype(tolua_S, 1, nullptr);
+ cHopperEntity * self = reinterpret_cast<cHopperEntity *>(tolua_tousertype(tolua_S, 1, nullptr));
if (self == nullptr)
{
tolua_error(tolua_S, "invalid 'self' in function 'cHopperEntity::GetOutputBlockPos()'", nullptr);
return 0;
}
- NIBBLETYPE a_BlockMeta = ((NIBBLETYPE)tolua_tonumber(tolua_S, 2, 0));
+ NIBBLETYPE a_BlockMeta = static_cast<NIBBLETYPE>(tolua_tonumber(tolua_S, 2, 0));
int a_OutputX, a_OutputY, a_OutputZ;
bool res = self->GetOutputBlockPos(a_BlockMeta, a_OutputX, a_OutputY, a_OutputZ);
tolua_pushboolean(tolua_S, res);
if (res)
{
- tolua_pushnumber(tolua_S, (lua_Number)a_OutputX);
- tolua_pushnumber(tolua_S, (lua_Number)a_OutputY);
- tolua_pushnumber(tolua_S, (lua_Number)a_OutputZ);
+ tolua_pushnumber(tolua_S, static_cast<lua_Number>(a_OutputX));
+ tolua_pushnumber(tolua_S, static_cast<lua_Number>(a_OutputY));
+ tolua_pushnumber(tolua_S, static_cast<lua_Number>(a_OutputZ));
return 4;
}
return 1;
@@ -2219,15 +2219,15 @@ static int tolua_cBlockArea_GetBlockTypeMeta(lua_State * tolua_S)
return 0;
}
- cBlockArea * self = (cBlockArea *)tolua_tousertype(tolua_S, 1, nullptr);
+ cBlockArea * self = reinterpret_cast<cBlockArea *>(tolua_tousertype(tolua_S, 1, nullptr));
if (self == nullptr)
{
tolua_error(tolua_S, "invalid 'self' in function 'cBlockArea:GetRelBlockTypeMeta'", nullptr);
return 0;
}
- int BlockX = (int)tolua_tonumber(tolua_S, 2, 0);
- int BlockY = (int)tolua_tonumber(tolua_S, 3, 0);
- int BlockZ = (int)tolua_tonumber(tolua_S, 4, 0);
+ int BlockX = static_cast<int>(tolua_tonumber(tolua_S, 2, 0));
+ int BlockY = static_cast<int>(tolua_tonumber(tolua_S, 3, 0));
+ int BlockZ = static_cast<int>(tolua_tonumber(tolua_S, 4, 0));
BLOCKTYPE BlockType;
NIBBLETYPE BlockMeta;
self->GetBlockTypeMeta(BlockX, BlockY, BlockZ, BlockType, BlockMeta);
@@ -2253,7 +2253,7 @@ static int tolua_cBlockArea_GetOrigin(lua_State * tolua_S)
return 0;
}
- cBlockArea * self = (cBlockArea *)tolua_tousertype(tolua_S, 1, nullptr);
+ cBlockArea * self = reinterpret_cast<cBlockArea *>(tolua_tousertype(tolua_S, 1, nullptr));
if (self == nullptr)
{
tolua_error(tolua_S, "invalid 'self' in function 'cBlockArea:GetOrigin'", nullptr);
@@ -2323,15 +2323,15 @@ static int tolua_cBlockArea_GetRelBlockTypeMeta(lua_State * tolua_S)
return 0;
}
- cBlockArea * self = (cBlockArea *)tolua_tousertype(tolua_S, 1, nullptr);
+ cBlockArea * self = reinterpret_cast<cBlockArea *>(tolua_tousertype(tolua_S, 1, nullptr));
if (self == nullptr)
{
tolua_error(tolua_S, "invalid 'self' in function 'cBlockArea:GetRelBlockTypeMeta'", nullptr);
return 0;
}
- int BlockX = (int)tolua_tonumber(tolua_S, 2, 0);
- int BlockY = (int)tolua_tonumber(tolua_S, 3, 0);
- int BlockZ = (int)tolua_tonumber(tolua_S, 4, 0);
+ int BlockX = static_cast<int>(tolua_tonumber(tolua_S, 2, 0));
+ int BlockY = static_cast<int>(tolua_tonumber(tolua_S, 3, 0));
+ int BlockZ = static_cast<int>(tolua_tonumber(tolua_S, 4, 0));
BLOCKTYPE BlockType;
NIBBLETYPE BlockMeta;
self->GetRelBlockTypeMeta(BlockX, BlockY, BlockZ, BlockType, BlockMeta);
@@ -2357,7 +2357,7 @@ static int tolua_cBlockArea_GetSize(lua_State * tolua_S)
return 0;
}
- cBlockArea * self = (cBlockArea *)tolua_tousertype(tolua_S, 1, nullptr);
+ cBlockArea * self = reinterpret_cast<cBlockArea *>(tolua_tousertype(tolua_S, 1, nullptr));
if (self == nullptr)
{
tolua_error(tolua_S, "invalid 'self' in function 'cBlockArea:GetSize'", nullptr);
@@ -2388,7 +2388,7 @@ static int tolua_cBlockArea_GetCoordRange(lua_State * tolua_S)
return 0;
}
- cBlockArea * self = (cBlockArea *)tolua_tousertype(tolua_S, 1, nullptr);
+ cBlockArea * self = reinterpret_cast<cBlockArea *>(tolua_tousertype(tolua_S, 1, nullptr));
if (self == nullptr)
{
tolua_error(tolua_S, "invalid 'self' in function 'cBlockArea:GetSize'", nullptr);
@@ -2419,7 +2419,7 @@ static int tolua_cBlockArea_LoadFromSchematicFile(lua_State * tolua_S)
{
return 0;
}
- cBlockArea * self = (cBlockArea *)tolua_tousertype(tolua_S, 1, nullptr);
+ cBlockArea * self = reinterpret_cast<cBlockArea *>(tolua_tousertype(tolua_S, 1, nullptr));
if (self == nullptr)
{
tolua_error(tolua_S, "invalid 'self' in function 'cBlockArea::LoadFromSchematicFile'", nullptr);
@@ -2449,7 +2449,7 @@ static int tolua_cBlockArea_LoadFromSchematicString(lua_State * tolua_S)
{
return 0;
}
- cBlockArea * self = (cBlockArea *)tolua_tousertype(tolua_S, 1, nullptr);
+ cBlockArea * self = reinterpret_cast<cBlockArea *>(tolua_tousertype(tolua_S, 1, nullptr));
if (self == nullptr)
{
tolua_error(tolua_S, "invalid 'self' in function 'cBlockArea::LoadFromSchematicFile'", nullptr);
@@ -2480,7 +2480,7 @@ static int tolua_cBlockArea_SaveToSchematicFile(lua_State * tolua_S)
{
return 0;
}
- cBlockArea * self = (cBlockArea *)tolua_tousertype(tolua_S, 1, nullptr);
+ cBlockArea * self = reinterpret_cast<cBlockArea *>(tolua_tousertype(tolua_S, 1, nullptr));
if (self == nullptr)
{
tolua_error(tolua_S, "invalid 'self' in function 'cBlockArea::SaveToSchematicFile'", nullptr);
@@ -2508,7 +2508,7 @@ static int tolua_cBlockArea_SaveToSchematicString(lua_State * tolua_S)
{
return 0;
}
- cBlockArea * self = (cBlockArea *)tolua_tousertype(tolua_S, 1, nullptr);
+ cBlockArea * self = reinterpret_cast<cBlockArea *>(tolua_tousertype(tolua_S, 1, nullptr));
if (self == nullptr)
{
tolua_error(tolua_S, "invalid 'self' in function 'cBlockArea::SaveToSchematicFile'", nullptr);
@@ -2542,7 +2542,7 @@ static int tolua_cCompositeChat_AddRunCommandPart(lua_State * tolua_S)
{
return 0;
}
- cCompositeChat * self = (cCompositeChat *)tolua_tousertype(tolua_S, 1, nullptr);
+ cCompositeChat * self = reinterpret_cast<cCompositeChat *>(tolua_tousertype(tolua_S, 1, nullptr));
if (self == nullptr)
{
tolua_error(tolua_S, "invalid 'self' in function 'cCompositeChat:AddRunCommandPart'", nullptr);
@@ -2579,7 +2579,7 @@ static int tolua_cCompositeChat_AddSuggestCommandPart(lua_State * tolua_S)
{
return 0;
}
- cCompositeChat * self = (cCompositeChat *)tolua_tousertype(tolua_S, 1, nullptr);
+ cCompositeChat * self = reinterpret_cast<cCompositeChat *>(tolua_tousertype(tolua_S, 1, nullptr));
if (self == nullptr)
{
tolua_error(tolua_S, "invalid 'self' in function 'cCompositeChat:AddSuggestCommandPart'", nullptr);
@@ -2616,7 +2616,7 @@ static int tolua_cCompositeChat_AddTextPart(lua_State * tolua_S)
{
return 0;
}
- cCompositeChat * self = (cCompositeChat *)tolua_tousertype(tolua_S, 1, nullptr);
+ cCompositeChat * self = reinterpret_cast<cCompositeChat *>(tolua_tousertype(tolua_S, 1, nullptr));
if (self == nullptr)
{
tolua_error(tolua_S, "invalid 'self' in function 'cCompositeChat:AddTextPart'", nullptr);
@@ -2652,7 +2652,7 @@ static int tolua_cCompositeChat_AddUrlPart(lua_State * tolua_S)
{
return 0;
}
- cCompositeChat * self = (cCompositeChat *)tolua_tousertype(tolua_S, 1, nullptr);
+ cCompositeChat * self = reinterpret_cast<cCompositeChat *>(tolua_tousertype(tolua_S, 1, nullptr));
if (self == nullptr)
{
tolua_error(tolua_S, "invalid 'self' in function 'cCompositeChat:AddUrlPart'", nullptr);
@@ -2689,7 +2689,7 @@ static int tolua_cCompositeChat_ParseText(lua_State * tolua_S)
{
return 0;
}
- cCompositeChat * self = (cCompositeChat *)tolua_tousertype(tolua_S, 1, nullptr);
+ cCompositeChat * self = reinterpret_cast<cCompositeChat *>(tolua_tousertype(tolua_S, 1, nullptr));
if (self == nullptr)
{
tolua_error(tolua_S, "invalid 'self' in function 'cCompositeChat:ParseText'", nullptr);
@@ -2724,7 +2724,7 @@ static int tolua_cCompositeChat_SetMessageType(lua_State * tolua_S)
{
return 0;
}
- cCompositeChat * self = (cCompositeChat *)tolua_tousertype(tolua_S, 1, nullptr);
+ cCompositeChat * self = reinterpret_cast<cCompositeChat *>(tolua_tousertype(tolua_S, 1, nullptr));
if (self == nullptr)
{
tolua_error(tolua_S, "invalid 'self' in function 'cCompositeChat:SetMessageType'", nullptr);
@@ -2734,7 +2734,7 @@ static int tolua_cCompositeChat_SetMessageType(lua_State * tolua_S)
// Set the type:
int MessageType = mtCustom;
L.GetStackValue(2, MessageType);
- self->SetMessageType((eMessageType)MessageType);
+ self->SetMessageType(static_cast<eMessageType>(MessageType));
// Cut away everything from the stack except for the cCompositeChat instance; return that:
lua_settop(L, 1);
@@ -2756,7 +2756,7 @@ static int tolua_cCompositeChat_UnderlineUrls(lua_State * tolua_S)
{
return 0;
}
- cCompositeChat * self = (cCompositeChat *)tolua_tousertype(tolua_S, 1, nullptr);
+ cCompositeChat * self = reinterpret_cast<cCompositeChat *>(tolua_tousertype(tolua_S, 1, nullptr));
if (self == nullptr)
{
tolua_error(tolua_S, "invalid 'self' in function 'cCompositeChat:UnderlineUrls'", nullptr);
diff --git a/src/Bindings/ManualBindings_World.cpp b/src/Bindings/ManualBindings_World.cpp
index d9590de33..59dde9a93 100644
--- a/src/Bindings/ManualBindings_World.cpp
+++ b/src/Bindings/ManualBindings_World.cpp
@@ -86,7 +86,7 @@ static int tolua_cWorld_ChunkStay(lua_State * tolua_S)
}
// Read the params:
- cWorld * World = (cWorld *)tolua_tousertype(tolua_S, 1, nullptr);
+ cWorld * World = reinterpret_cast<cWorld *>(tolua_tousertype(tolua_S, 1, nullptr));
if (World == nullptr)
{
LOGWARNING("World:ChunkStay(): invalid world parameter");
@@ -356,7 +356,7 @@ static int tolua_cWorld_QueueTask(lua_State * tolua_S)
}
// Retrieve the args:
- cWorld * self = (cWorld *)tolua_tousertype(tolua_S, 1, nullptr);
+ cWorld * self = reinterpret_cast<cWorld *>(tolua_tousertype(tolua_S, 1, nullptr));
if (self == nullptr)
{
return cManualBindings::lua_do_error(tolua_S, "Error in function call '#funcname#': Not called on an object instance");
@@ -473,7 +473,7 @@ static int tolua_cWorld_ScheduleTask(lua_State * tolua_S)
{
return 0;
}
- cWorld * World = (cWorld *)tolua_tousertype(tolua_S, 1, nullptr);
+ cWorld * World = reinterpret_cast<cWorld *>(tolua_tousertype(tolua_S, 1, nullptr));
if (World == nullptr)
{
return cManualBindings::lua_do_error(tolua_S, "Error in function call '#funcname#': Not called on an object instance");
@@ -486,7 +486,7 @@ static int tolua_cWorld_ScheduleTask(lua_State * tolua_S)
return cManualBindings::lua_do_error(tolua_S, "Error in function call '#funcname#': Could not get function reference of parameter #1");
}
- int DelayTicks = (int)tolua_tonumber(tolua_S, 2, 0);
+ int DelayTicks = static_cast<int>(tolua_tonumber(tolua_S, 2, 0));
auto task = std::make_shared<cLuaScheduledWorldTask>(*Plugin, FnRef);
Plugin->AddResettable(task);
diff --git a/src/Bindings/Plugin.h b/src/Bindings/Plugin.h
index 2fdf73a65..48ba6a77c 100644
--- a/src/Bindings/Plugin.h
+++ b/src/Bindings/Plugin.h
@@ -66,7 +66,7 @@ public:
virtual bool OnHopperPushingItem (cWorld & a_World, cHopperEntity & a_Hopper, int a_SrcSlotNum, cBlockEntityWithItems & a_DstEntity, int a_DstSlotNum) = 0;
virtual bool OnKilled (cEntity & a_Victim, TakeDamageInfo & a_TDI, AString & a_DeathMessage) = 0;
virtual bool OnKilling (cEntity & a_Victim, cEntity * a_Killer, TakeDamageInfo & a_TDI) = 0;
- virtual bool OnLogin (cClientHandle & a_Client, int a_ProtocolVersion, const AString & a_Username) = 0;
+ virtual bool OnLogin (cClientHandle & a_Client, UInt32 a_ProtocolVersion, const AString & a_Username) = 0;
virtual bool OnPlayerAnimation (cPlayer & a_Player, int a_Animation) = 0;
virtual bool OnPlayerBreakingBlock (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) = 0;
virtual bool OnPlayerBrokenBlock (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) = 0;
diff --git a/src/Bindings/PluginLua.cpp b/src/Bindings/PluginLua.cpp
index 9be4e0eb4..50a0a387b 100644
--- a/src/Bindings/PluginLua.cpp
+++ b/src/Bindings/PluginLua.cpp
@@ -238,7 +238,7 @@ void cPluginLua::Tick(float a_Dt)
cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_TICK];
for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr)
{
- m_LuaState.Call((int)(**itr), a_Dt);
+ m_LuaState.Call(static_cast<int>(**itr), a_Dt);
}
}
@@ -257,7 +257,7 @@ bool cPluginLua::OnBlockSpread(cWorld & a_World, int a_BlockX, int a_BlockY, int
cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_BLOCK_SPREAD];
for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr)
{
- m_LuaState.Call((int)(**itr), &a_World, a_BlockX, a_BlockY, a_BlockZ, a_Source, cLuaState::Return, res);
+ m_LuaState.Call(static_cast<int>(**itr), &a_World, a_BlockX, a_BlockY, a_BlockZ, a_Source, cLuaState::Return, res);
if (res)
{
return true;
@@ -281,7 +281,7 @@ bool cPluginLua::OnBlockToPickups(cWorld & a_World, cEntity * a_Digger, int a_Bl
cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_BLOCK_TO_PICKUPS];
for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr)
{
- m_LuaState.Call((int)(**itr), &a_World, a_Digger, a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta, &a_Pickups, cLuaState::Return, res);
+ m_LuaState.Call(static_cast<int>(**itr), &a_World, a_Digger, a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta, &a_Pickups, cLuaState::Return, res);
if (res)
{
return true;
@@ -305,7 +305,7 @@ bool cPluginLua::OnChat(cPlayer & a_Player, AString & a_Message)
cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_CHAT];
for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr)
{
- m_LuaState.Call((int)(**itr), &a_Player, a_Message, cLuaState::Return, res, a_Message);
+ m_LuaState.Call(static_cast<int>(**itr), &a_Player, a_Message, cLuaState::Return, res, a_Message);
if (res)
{
return true;
@@ -329,7 +329,7 @@ bool cPluginLua::OnChunkAvailable(cWorld & a_World, int a_ChunkX, int a_ChunkZ)
cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_CHUNK_AVAILABLE];
for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr)
{
- m_LuaState.Call((int)(**itr), &a_World, a_ChunkX, a_ChunkZ, cLuaState::Return, res);
+ m_LuaState.Call(static_cast<int>(**itr), &a_World, a_ChunkX, a_ChunkZ, cLuaState::Return, res);
if (res)
{
return true;
@@ -353,7 +353,7 @@ bool cPluginLua::OnChunkGenerated(cWorld & a_World, int a_ChunkX, int a_ChunkZ,
cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_CHUNK_GENERATED];
for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr)
{
- m_LuaState.Call((int)(**itr), &a_World, a_ChunkX, a_ChunkZ, a_ChunkDesc, cLuaState::Return, res);
+ m_LuaState.Call(static_cast<int>(**itr), &a_World, a_ChunkX, a_ChunkZ, a_ChunkDesc, cLuaState::Return, res);
if (res)
{
return true;
@@ -377,7 +377,7 @@ bool cPluginLua::OnChunkGenerating(cWorld & a_World, int a_ChunkX, int a_ChunkZ,
cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_CHUNK_GENERATING];
for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr)
{
- m_LuaState.Call((int)(**itr), &a_World, a_ChunkX, a_ChunkZ, a_ChunkDesc, cLuaState::Return, res);
+ m_LuaState.Call(static_cast<int>(**itr), &a_World, a_ChunkX, a_ChunkZ, a_ChunkDesc, cLuaState::Return, res);
if (res)
{
return true;
@@ -401,7 +401,7 @@ bool cPluginLua::OnChunkUnloaded(cWorld & a_World, int a_ChunkX, int a_ChunkZ)
cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_CHUNK_UNLOADED];
for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr)
{
- m_LuaState.Call((int)(**itr), &a_World, a_ChunkX, a_ChunkZ, cLuaState::Return, res);
+ m_LuaState.Call(static_cast<int>(**itr), &a_World, a_ChunkX, a_ChunkZ, cLuaState::Return, res);
if (res)
{
return true;
@@ -425,7 +425,7 @@ bool cPluginLua::OnChunkUnloading(cWorld & a_World, int a_ChunkX, int a_ChunkZ)
cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_CHUNK_UNLOADING];
for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr)
{
- m_LuaState.Call((int)(**itr), &a_World, a_ChunkX, a_ChunkZ, cLuaState::Return, res);
+ m_LuaState.Call(static_cast<int>(**itr), &a_World, a_ChunkX, a_ChunkZ, cLuaState::Return, res);
if (res)
{
return true;
@@ -449,7 +449,7 @@ bool cPluginLua::OnCollectingPickup(cPlayer & a_Player, cPickup & a_Pickup)
cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_COLLECTING_PICKUP];
for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr)
{
- m_LuaState.Call((int)(**itr), &a_Player, &a_Pickup, cLuaState::Return, res);
+ m_LuaState.Call(static_cast<int>(**itr), &a_Player, &a_Pickup, cLuaState::Return, res);
if (res)
{
return true;
@@ -473,7 +473,7 @@ bool cPluginLua::OnCraftingNoRecipe(cPlayer & a_Player, cCraftingGrid & a_Grid,
cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_CRAFTING_NO_RECIPE];
for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr)
{
- m_LuaState.Call((int)(**itr), &a_Player, &a_Grid, &a_Recipe, cLuaState::Return, res);
+ m_LuaState.Call(static_cast<int>(**itr), &a_Player, &a_Grid, &a_Recipe, cLuaState::Return, res);
if (res)
{
return true;
@@ -497,7 +497,7 @@ bool cPluginLua::OnDisconnect(cClientHandle & a_Client, const AString & a_Reason
cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_DISCONNECT];
for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr)
{
- m_LuaState.Call((int)(**itr), &a_Client, a_Reason, cLuaState::Return, res);
+ m_LuaState.Call(static_cast<int>(**itr), &a_Client, a_Reason, cLuaState::Return, res);
if (res)
{
return true;
@@ -521,7 +521,7 @@ bool cPluginLua::OnEntityAddEffect(cEntity & a_Entity, int a_EffectType, int a_E
cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_ENTITY_ADD_EFFECT];
for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr)
{
- m_LuaState.Call((int)(**itr), &a_Entity, a_EffectType, a_EffectDurationTicks, a_EffectIntensity, a_DistanceModifier, cLuaState::Return, res);
+ m_LuaState.Call(static_cast<int>(**itr), &a_Entity, a_EffectType, a_EffectDurationTicks, a_EffectIntensity, a_DistanceModifier, cLuaState::Return, res);
if (res)
{
return true;
@@ -545,7 +545,7 @@ bool cPluginLua::OnEntityChangingWorld(cEntity & a_Entity, cWorld & a_World)
cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_ENTITY_CHANGING_WORLD];
for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr)
{
- m_LuaState.Call((int)(**itr), &a_Entity, &a_World, cLuaState::Return, res);
+ m_LuaState.Call(static_cast<int>(**itr), &a_Entity, &a_World, cLuaState::Return, res);
if (res)
{
return true;
@@ -569,7 +569,7 @@ bool cPluginLua::OnEntityChangedWorld(cEntity & a_Entity, cWorld & a_World)
cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_ENTITY_CHANGED_WORLD];
for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr)
{
- m_LuaState.Call((int)(**itr), &a_Entity, &a_World, res);
+ m_LuaState.Call(static_cast<int>(**itr), &a_Entity, &a_World, res);
if (res)
{
return true;
@@ -593,7 +593,7 @@ bool cPluginLua::OnExecuteCommand(cPlayer * a_Player, const AStringVector & a_Sp
cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_EXECUTE_COMMAND];
for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr)
{
- m_LuaState.Call((int)(**itr), a_Player, a_Split, a_EntireCommand, cLuaState::Return, res, a_Result);
+ m_LuaState.Call(static_cast<int>(**itr), a_Player, a_Split, a_EntireCommand, cLuaState::Return, res, a_Result);
if (res)
{
return true;
@@ -619,16 +619,16 @@ bool cPluginLua::OnExploded(cWorld & a_World, double a_ExplosionSize, bool a_Can
{
switch (a_Source)
{
- case esOther: m_LuaState.Call((int)(**itr), &a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, a_SourceData, cLuaState::Return, res); break;
- case esPrimedTNT: m_LuaState.Call((int)(**itr), &a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, (cTNTEntity *)a_SourceData, cLuaState::Return, res); break;
- case esMonster: m_LuaState.Call((int)(**itr), &a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, (cMonster *)a_SourceData, cLuaState::Return, res); break;
- case esBed: m_LuaState.Call((int)(**itr), &a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, (Vector3i *)a_SourceData, cLuaState::Return, res); break;
- case esEnderCrystal: m_LuaState.Call((int)(**itr), &a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, (Vector3i *)a_SourceData, cLuaState::Return, res); break;
- case esGhastFireball: m_LuaState.Call((int)(**itr), &a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, a_SourceData, cLuaState::Return, res); break;
+ case esOther: m_LuaState.Call(static_cast<int>(**itr), &a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, a_SourceData, cLuaState::Return, res); break;
+ case esPrimedTNT: m_LuaState.Call(static_cast<int>(**itr), &a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, reinterpret_cast<cTNTEntity *>(a_SourceData), cLuaState::Return, res); break;
+ case esMonster: m_LuaState.Call(static_cast<int>(**itr), &a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, reinterpret_cast<cMonster *>(a_SourceData), cLuaState::Return, res); break;
+ case esBed: m_LuaState.Call(static_cast<int>(**itr), &a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, reinterpret_cast<Vector3i *>(a_SourceData), cLuaState::Return, res); break;
+ case esEnderCrystal: m_LuaState.Call(static_cast<int>(**itr), &a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, reinterpret_cast<Vector3i *>(a_SourceData), cLuaState::Return, res); break;
+ case esGhastFireball: m_LuaState.Call(static_cast<int>(**itr), &a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, a_SourceData, cLuaState::Return, res); break;
case esWitherSkullBlack:
- case esWitherSkullBlue: m_LuaState.Call((int)(**itr), &a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, a_SourceData, cLuaState::Return, res); break;
- case esWitherBirth: m_LuaState.Call((int)(**itr), &a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, a_SourceData, cLuaState::Return, res); break;
- case esPlugin: m_LuaState.Call((int)(**itr), &a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, a_SourceData, cLuaState::Return, res); break;
+ case esWitherSkullBlue: m_LuaState.Call(static_cast<int>(**itr), &a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, a_SourceData, cLuaState::Return, res); break;
+ case esWitherBirth: m_LuaState.Call(static_cast<int>(**itr), &a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, a_SourceData, cLuaState::Return, res); break;
+ case esPlugin: m_LuaState.Call(static_cast<int>(**itr), &a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, a_SourceData, cLuaState::Return, res); break;
}
if (res)
{
@@ -655,16 +655,16 @@ bool cPluginLua::OnExploding(cWorld & a_World, double & a_ExplosionSize, bool &
{
switch (a_Source)
{
- case esOther: m_LuaState.Call((int)(**itr), &a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, a_SourceData, cLuaState::Return, res, a_CanCauseFire, a_ExplosionSize); break;
- case esPrimedTNT: m_LuaState.Call((int)(**itr), &a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, (cTNTEntity *)a_SourceData, cLuaState::Return, res, a_CanCauseFire, a_ExplosionSize); break;
- case esMonster: m_LuaState.Call((int)(**itr), &a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, (cMonster *)a_SourceData, cLuaState::Return, res, a_CanCauseFire, a_ExplosionSize); break;
- case esBed: m_LuaState.Call((int)(**itr), &a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, (Vector3i *)a_SourceData, cLuaState::Return, res, a_CanCauseFire, a_ExplosionSize); break;
- case esEnderCrystal: m_LuaState.Call((int)(**itr), &a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, (Vector3i *)a_SourceData, cLuaState::Return, res, a_CanCauseFire, a_ExplosionSize); break;
- case esGhastFireball: m_LuaState.Call((int)(**itr), &a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, a_SourceData, cLuaState::Return, res, a_CanCauseFire, a_ExplosionSize); break;
+ case esOther: m_LuaState.Call(static_cast<int>(**itr), &a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, a_SourceData, cLuaState::Return, res, a_CanCauseFire, a_ExplosionSize); break;
+ case esPrimedTNT: m_LuaState.Call(static_cast<int>(**itr), &a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, reinterpret_cast<cTNTEntity *>(a_SourceData), cLuaState::Return, res, a_CanCauseFire, a_ExplosionSize); break;
+ case esMonster: m_LuaState.Call(static_cast<int>(**itr), &a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, reinterpret_cast<cMonster *>(a_SourceData), cLuaState::Return, res, a_CanCauseFire, a_ExplosionSize); break;
+ case esBed: m_LuaState.Call(static_cast<int>(**itr), &a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, reinterpret_cast<Vector3i *>(a_SourceData), cLuaState::Return, res, a_CanCauseFire, a_ExplosionSize); break;
+ case esEnderCrystal: m_LuaState.Call(static_cast<int>(**itr), &a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, reinterpret_cast<Vector3i *>(a_SourceData), cLuaState::Return, res, a_CanCauseFire, a_ExplosionSize); break;
+ case esGhastFireball: m_LuaState.Call(static_cast<int>(**itr), &a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, a_SourceData, cLuaState::Return, res, a_CanCauseFire, a_ExplosionSize); break;
case esWitherSkullBlack:
- case esWitherSkullBlue: m_LuaState.Call((int)(**itr), &a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, a_SourceData, cLuaState::Return, res, a_CanCauseFire, a_ExplosionSize); break;
- case esWitherBirth: m_LuaState.Call((int)(**itr), &a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, a_SourceData, cLuaState::Return, res, a_CanCauseFire, a_ExplosionSize); break;
- case esPlugin: m_LuaState.Call((int)(**itr), &a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, a_SourceData, cLuaState::Return, res, a_CanCauseFire, a_ExplosionSize); break;
+ case esWitherSkullBlue: m_LuaState.Call(static_cast<int>(**itr), &a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, a_SourceData, cLuaState::Return, res, a_CanCauseFire, a_ExplosionSize); break;
+ case esWitherBirth: m_LuaState.Call(static_cast<int>(**itr), &a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, a_SourceData, cLuaState::Return, res, a_CanCauseFire, a_ExplosionSize); break;
+ case esPlugin: m_LuaState.Call(static_cast<int>(**itr), &a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, a_SourceData, cLuaState::Return, res, a_CanCauseFire, a_ExplosionSize); break;
}
if (res)
{
@@ -689,7 +689,7 @@ bool cPluginLua::OnHandshake(cClientHandle & a_Client, const AString & a_Usernam
cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_HANDSHAKE];
for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr)
{
- m_LuaState.Call((int)(**itr), &a_Client, a_Username, cLuaState::Return, res);
+ m_LuaState.Call(static_cast<int>(**itr), &a_Client, a_Username, cLuaState::Return, res);
if (res)
{
return true;
@@ -713,7 +713,7 @@ bool cPluginLua::OnHopperPullingItem(cWorld & a_World, cHopperEntity & a_Hopper,
cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_HOPPER_PULLING_ITEM];
for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr)
{
- m_LuaState.Call((int)(**itr), &a_World, &a_Hopper, a_DstSlotNum, &a_SrcEntity, a_SrcSlotNum, cLuaState::Return, res);
+ m_LuaState.Call(static_cast<int>(**itr), &a_World, &a_Hopper, a_DstSlotNum, &a_SrcEntity, a_SrcSlotNum, cLuaState::Return, res);
if (res)
{
return true;
@@ -737,7 +737,7 @@ bool cPluginLua::OnHopperPushingItem(cWorld & a_World, cHopperEntity & a_Hopper,
cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_HOPPER_PUSHING_ITEM];
for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr)
{
- m_LuaState.Call((int)(**itr), &a_World, &a_Hopper, a_SrcSlotNum, &a_DstEntity, a_DstSlotNum, cLuaState::Return, res);
+ m_LuaState.Call(static_cast<int>(**itr), &a_World, &a_Hopper, a_SrcSlotNum, &a_DstEntity, a_DstSlotNum, cLuaState::Return, res);
if (res)
{
return true;
@@ -761,7 +761,7 @@ bool cPluginLua::OnKilled(cEntity & a_Victim, TakeDamageInfo & a_TDI, AString &
cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_KILLED];
for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr)
{
- m_LuaState.Call((int)(**itr), &a_Victim, &a_TDI, a_DeathMessage, cLuaState::Return, res, a_DeathMessage);
+ m_LuaState.Call(static_cast<int>(**itr), &a_Victim, &a_TDI, a_DeathMessage, cLuaState::Return, res, a_DeathMessage);
if (res)
{
return true;
@@ -785,7 +785,7 @@ bool cPluginLua::OnKilling(cEntity & a_Victim, cEntity * a_Killer, TakeDamageInf
cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_KILLING];
for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr)
{
- m_LuaState.Call((int)(**itr), &a_Victim, a_Killer, &a_TDI, cLuaState::Return, res);
+ m_LuaState.Call(static_cast<int>(**itr), &a_Victim, a_Killer, &a_TDI, cLuaState::Return, res);
if (res)
{
return true;
@@ -798,7 +798,7 @@ bool cPluginLua::OnKilling(cEntity & a_Victim, cEntity * a_Killer, TakeDamageInf
-bool cPluginLua::OnLogin(cClientHandle & a_Client, int a_ProtocolVersion, const AString & a_Username)
+bool cPluginLua::OnLogin(cClientHandle & a_Client, UInt32 a_ProtocolVersion, const AString & a_Username)
{
cCSLock Lock(m_CriticalSection);
if (!m_LuaState.IsValid())
@@ -809,7 +809,7 @@ bool cPluginLua::OnLogin(cClientHandle & a_Client, int a_ProtocolVersion, const
cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_LOGIN];
for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr)
{
- m_LuaState.Call((int)(**itr), &a_Client, a_ProtocolVersion, a_Username, cLuaState::Return, res);
+ m_LuaState.Call(static_cast<int>(**itr), &a_Client, a_ProtocolVersion, a_Username, cLuaState::Return, res);
if (res)
{
return true;
@@ -833,7 +833,7 @@ bool cPluginLua::OnPlayerAnimation(cPlayer & a_Player, int a_Animation)
cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_PLAYER_ANIMATION];
for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr)
{
- m_LuaState.Call((int)(**itr), &a_Player, a_Animation, cLuaState::Return, res);
+ m_LuaState.Call(static_cast<int>(**itr), &a_Player, a_Animation, cLuaState::Return, res);
if (res)
{
return true;
@@ -857,7 +857,7 @@ bool cPluginLua::OnPlayerBreakingBlock(cPlayer & a_Player, int a_BlockX, int a_B
cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_PLAYER_BREAKING_BLOCK];
for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr)
{
- m_LuaState.Call((int)(**itr), &a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_BlockType, a_BlockMeta, cLuaState::Return, res);
+ m_LuaState.Call(static_cast<int>(**itr), &a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_BlockType, a_BlockMeta, cLuaState::Return, res);
if (res)
{
return true;
@@ -881,7 +881,7 @@ bool cPluginLua::OnPlayerBrokenBlock(cPlayer & a_Player, int a_BlockX, int a_Blo
cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_PLAYER_BROKEN_BLOCK];
for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr)
{
- m_LuaState.Call((int)(**itr), &a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_BlockType, a_BlockMeta, cLuaState::Return, res);
+ m_LuaState.Call(static_cast<int>(**itr), &a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_BlockType, a_BlockMeta, cLuaState::Return, res);
if (res)
{
return true;
@@ -905,7 +905,7 @@ bool cPluginLua::OnPlayerDestroyed(cPlayer & a_Player)
cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_PLAYER_DESTROYED];
for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr)
{
- m_LuaState.Call((int)(**itr), &a_Player, cLuaState::Return, res);
+ m_LuaState.Call(static_cast<int>(**itr), &a_Player, cLuaState::Return, res);
if (res)
{
return true;
@@ -929,7 +929,7 @@ bool cPluginLua::OnPlayerEating(cPlayer & a_Player)
cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_PLAYER_EATING];
for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr)
{
- m_LuaState.Call((int)(**itr), &a_Player, cLuaState::Return, res);
+ m_LuaState.Call(static_cast<int>(**itr), &a_Player, cLuaState::Return, res);
if (res)
{
return true;
@@ -953,7 +953,7 @@ bool cPluginLua::OnPlayerFoodLevelChange(cPlayer & a_Player, int a_NewFoodLevel)
cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_PLAYER_FOOD_LEVEL_CHANGE];
for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr)
{
- m_LuaState.Call((int)(**itr), &a_Player, a_NewFoodLevel, cLuaState::Return, res);
+ m_LuaState.Call(static_cast<int>(**itr), &a_Player, a_NewFoodLevel, cLuaState::Return, res);
if (res)
{
return true;
@@ -977,7 +977,7 @@ bool cPluginLua::OnPlayerFished(cPlayer & a_Player, const cItems & a_Reward)
cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_PLAYER_FISHED];
for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr)
{
- m_LuaState.Call((int)(**itr), &a_Player, a_Reward, cLuaState::Return, res);
+ m_LuaState.Call(static_cast<int>(**itr), &a_Player, a_Reward, cLuaState::Return, res);
if (res)
{
return true;
@@ -1001,7 +1001,7 @@ bool cPluginLua::OnPlayerFishing(cPlayer & a_Player, cItems & a_Reward)
cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_PLAYER_FISHING];
for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr)
{
- m_LuaState.Call((int)(**itr), &a_Player, &a_Reward, cLuaState::Return, res);
+ m_LuaState.Call(static_cast<int>(**itr), &a_Player, &a_Reward, cLuaState::Return, res);
if (res)
{
return true;
@@ -1025,7 +1025,7 @@ bool cPluginLua::OnPlayerJoined(cPlayer & a_Player)
cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_PLAYER_JOINED];
for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr)
{
- m_LuaState.Call((int)(**itr), &a_Player, cLuaState::Return, res);
+ m_LuaState.Call(static_cast<int>(**itr), &a_Player, cLuaState::Return, res);
if (res)
{
return true;
@@ -1049,7 +1049,7 @@ bool cPluginLua::OnPlayerLeftClick(cPlayer & a_Player, int a_BlockX, int a_Block
cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_PLAYER_LEFT_CLICK];
for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr)
{
- m_LuaState.Call((int)(**itr), &a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_Status, cLuaState::Return, res);
+ m_LuaState.Call(static_cast<int>(**itr), &a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_Status, cLuaState::Return, res);
if (res)
{
return true;
@@ -1073,7 +1073,7 @@ bool cPluginLua::OnPlayerMoving(cPlayer & a_Player, const Vector3d & a_OldPositi
cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_PLAYER_MOVING];
for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr)
{
- m_LuaState.Call((int)(**itr), &a_Player, a_OldPosition, a_NewPosition, cLuaState::Return, res);
+ m_LuaState.Call(static_cast<int>(**itr), &a_Player, a_OldPosition, a_NewPosition, cLuaState::Return, res);
if (res)
{
return true;
@@ -1097,7 +1097,7 @@ bool cPluginLua::OnEntityTeleport(cEntity & a_Entity, const Vector3d & a_OldPosi
cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_ENTITY_TELEPORT];
for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr)
{
- m_LuaState.Call((int)(**itr), &a_Entity, a_OldPosition, a_NewPosition, cLuaState::Return, res);
+ m_LuaState.Call(static_cast<int>(**itr), &a_Entity, a_OldPosition, a_NewPosition, cLuaState::Return, res);
if (res)
{
return true;
@@ -1121,7 +1121,7 @@ bool cPluginLua::OnPlayerPlacedBlock(cPlayer & a_Player, const sSetBlock & a_Blo
cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_PLAYER_PLACED_BLOCK];
for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr)
{
- m_LuaState.Call((int)(**itr), &a_Player,
+ m_LuaState.Call(static_cast<int>(**itr), &a_Player,
a_BlockChange.GetX(), a_BlockChange.GetY(), a_BlockChange.GetZ(),
a_BlockChange.m_BlockType, a_BlockChange.m_BlockMeta,
cLuaState::Return,
@@ -1150,7 +1150,7 @@ bool cPluginLua::OnPlayerPlacingBlock(cPlayer & a_Player, const sSetBlock & a_Bl
cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_PLAYER_PLACING_BLOCK];
for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr)
{
- m_LuaState.Call((int)(**itr), &a_Player,
+ m_LuaState.Call(static_cast<int>(**itr), &a_Player,
a_BlockChange.GetX(), a_BlockChange.GetY(), a_BlockChange.GetZ(),
a_BlockChange.m_BlockType, a_BlockChange.m_BlockMeta,
cLuaState::Return,
@@ -1179,7 +1179,7 @@ bool cPluginLua::OnPlayerRightClick(cPlayer & a_Player, int a_BlockX, int a_Bloc
cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_PLAYER_RIGHT_CLICK];
for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr)
{
- m_LuaState.Call((int)(**itr), &a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, cLuaState::Return, res);
+ m_LuaState.Call(static_cast<int>(**itr), &a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, cLuaState::Return, res);
if (res)
{
return true;
@@ -1203,7 +1203,7 @@ bool cPluginLua::OnPlayerRightClickingEntity(cPlayer & a_Player, cEntity & a_Ent
cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_PLAYER_RIGHT_CLICKING_ENTITY];
for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr)
{
- m_LuaState.Call((int)(**itr), &a_Player, &a_Entity, cLuaState::Return, res);
+ m_LuaState.Call(static_cast<int>(**itr), &a_Player, &a_Entity, cLuaState::Return, res);
if (res)
{
return true;
@@ -1227,7 +1227,7 @@ bool cPluginLua::OnPlayerShooting(cPlayer & a_Player)
cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_PLAYER_SHOOTING];
for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr)
{
- m_LuaState.Call((int)(**itr), &a_Player, cLuaState::Return, res);
+ m_LuaState.Call(static_cast<int>(**itr), &a_Player, cLuaState::Return, res);
if (res)
{
return true;
@@ -1251,7 +1251,7 @@ bool cPluginLua::OnPlayerSpawned(cPlayer & a_Player)
cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_PLAYER_SPAWNED];
for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr)
{
- m_LuaState.Call((int)(**itr), &a_Player, cLuaState::Return, res);
+ m_LuaState.Call(static_cast<int>(**itr), &a_Player, cLuaState::Return, res);
if (res)
{
return true;
@@ -1275,7 +1275,7 @@ bool cPluginLua::OnPlayerTossingItem(cPlayer & a_Player)
cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_PLAYER_TOSSING_ITEM];
for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr)
{
- m_LuaState.Call((int)(**itr), &a_Player, cLuaState::Return, res);
+ m_LuaState.Call(static_cast<int>(**itr), &a_Player, cLuaState::Return, res);
if (res)
{
return true;
@@ -1299,7 +1299,7 @@ bool cPluginLua::OnPlayerUsedBlock(cPlayer & a_Player, int a_BlockX, int a_Block
cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_PLAYER_USED_BLOCK];
for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr)
{
- m_LuaState.Call((int)(**itr), &a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, a_BlockType, a_BlockMeta, cLuaState::Return, res);
+ m_LuaState.Call(static_cast<int>(**itr), &a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, a_BlockType, a_BlockMeta, cLuaState::Return, res);
if (res)
{
return true;
@@ -1323,7 +1323,7 @@ bool cPluginLua::OnPlayerUsedItem(cPlayer & a_Player, int a_BlockX, int a_BlockY
cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_PLAYER_USED_ITEM];
for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr)
{
- m_LuaState.Call((int)(**itr), &a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, cLuaState::Return, res);
+ m_LuaState.Call(static_cast<int>(**itr), &a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, cLuaState::Return, res);
if (res)
{
return true;
@@ -1347,7 +1347,7 @@ bool cPluginLua::OnPlayerUsingBlock(cPlayer & a_Player, int a_BlockX, int a_Bloc
cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_PLAYER_USING_BLOCK];
for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr)
{
- m_LuaState.Call((int)(**itr), &a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, a_BlockType, a_BlockMeta, cLuaState::Return, res);
+ m_LuaState.Call(static_cast<int>(**itr), &a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, a_BlockType, a_BlockMeta, cLuaState::Return, res);
if (res)
{
return true;
@@ -1371,7 +1371,7 @@ bool cPluginLua::OnPlayerUsingItem(cPlayer & a_Player, int a_BlockX, int a_Block
cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_PLAYER_USING_ITEM];
for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr)
{
- m_LuaState.Call((int)(**itr), &a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, cLuaState::Return, res);
+ m_LuaState.Call(static_cast<int>(**itr), &a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, cLuaState::Return, res);
if (res)
{
return true;
@@ -1395,7 +1395,7 @@ bool cPluginLua::OnPluginMessage(cClientHandle & a_Client, const AString & a_Cha
cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_PLUGIN_MESSAGE];
for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr)
{
- m_LuaState.Call((int)(**itr), &a_Client, a_Channel, a_Message, cLuaState::Return, res);
+ m_LuaState.Call(static_cast<int>(**itr), &a_Client, a_Channel, a_Message, cLuaState::Return, res);
if (res)
{
return true;
@@ -1420,7 +1420,7 @@ bool cPluginLua::OnPluginsLoaded(void)
for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr)
{
bool ret = false;
- m_LuaState.Call((int)(**itr), cLuaState::Return, ret);
+ m_LuaState.Call(static_cast<int>(**itr), cLuaState::Return, ret);
res = res || ret;
}
return res;
@@ -1441,7 +1441,7 @@ bool cPluginLua::OnPostCrafting(cPlayer & a_Player, cCraftingGrid & a_Grid, cCra
cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_POST_CRAFTING];
for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr)
{
- m_LuaState.Call((int)(**itr), &a_Player, &a_Grid, &a_Recipe, cLuaState::Return, res);
+ m_LuaState.Call(static_cast<int>(**itr), &a_Player, &a_Grid, &a_Recipe, cLuaState::Return, res);
if (res)
{
return true;
@@ -1465,7 +1465,7 @@ bool cPluginLua::OnPreCrafting(cPlayer & a_Player, cCraftingGrid & a_Grid, cCraf
cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_PRE_CRAFTING];
for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr)
{
- m_LuaState.Call((int)(**itr), &a_Player, &a_Grid, &a_Recipe, cLuaState::Return, res);
+ m_LuaState.Call(static_cast<int>(**itr), &a_Player, &a_Grid, &a_Recipe, cLuaState::Return, res);
if (res)
{
return true;
@@ -1489,7 +1489,7 @@ bool cPluginLua::OnProjectileHitBlock(cProjectileEntity & a_Projectile, int a_Bl
cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_PROJECTILE_HIT_BLOCK];
for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr)
{
- m_LuaState.Call((int)(**itr), &a_Projectile, a_BlockX, a_BlockY, a_BlockZ, a_Face, a_BlockHitPos, cLuaState::Return, res);
+ m_LuaState.Call(static_cast<int>(**itr), &a_Projectile, a_BlockX, a_BlockY, a_BlockZ, a_Face, a_BlockHitPos, cLuaState::Return, res);
if (res)
{
return true;
@@ -1513,7 +1513,7 @@ bool cPluginLua::OnProjectileHitEntity(cProjectileEntity & a_Projectile, cEntity
cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_PROJECTILE_HIT_ENTITY];
for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr)
{
- m_LuaState.Call((int)(**itr), &a_Projectile, &a_HitEntity, cLuaState::Return, res);
+ m_LuaState.Call(static_cast<int>(**itr), &a_Projectile, &a_HitEntity, cLuaState::Return, res);
if (res)
{
return true;
@@ -1537,7 +1537,7 @@ bool cPluginLua::OnServerPing(cClientHandle & a_ClientHandle, AString & a_Server
cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_SERVER_PING];
for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr)
{
- m_LuaState.Call((int)(**itr), &a_ClientHandle, a_ServerDescription, a_OnlinePlayersCount, a_MaxPlayersCount, a_Favicon, cLuaState::Return, res, a_ServerDescription, a_OnlinePlayersCount, a_MaxPlayersCount, a_Favicon);
+ m_LuaState.Call(static_cast<int>(**itr), &a_ClientHandle, a_ServerDescription, a_OnlinePlayersCount, a_MaxPlayersCount, a_Favicon, cLuaState::Return, res, a_ServerDescription, a_OnlinePlayersCount, a_MaxPlayersCount, a_Favicon);
if (res)
{
return true;
@@ -1561,7 +1561,7 @@ bool cPluginLua::OnSpawnedEntity(cWorld & a_World, cEntity & a_Entity)
cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_SPAWNED_ENTITY];
for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr)
{
- m_LuaState.Call((int)(**itr), &a_World, &a_Entity, cLuaState::Return, res);
+ m_LuaState.Call(static_cast<int>(**itr), &a_World, &a_Entity, cLuaState::Return, res);
if (res)
{
return true;
@@ -1585,7 +1585,7 @@ bool cPluginLua::OnSpawnedMonster(cWorld & a_World, cMonster & a_Monster)
cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_SPAWNED_MONSTER];
for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr)
{
- m_LuaState.Call((int)(**itr), &a_World, &a_Monster, cLuaState::Return, res);
+ m_LuaState.Call(static_cast<int>(**itr), &a_World, &a_Monster, cLuaState::Return, res);
if (res)
{
return true;
@@ -1609,7 +1609,7 @@ bool cPluginLua::OnSpawningEntity(cWorld & a_World, cEntity & a_Entity)
cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_SPAWNING_ENTITY];
for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr)
{
- m_LuaState.Call((int)(**itr), &a_World, &a_Entity, cLuaState::Return, res);
+ m_LuaState.Call(static_cast<int>(**itr), &a_World, &a_Entity, cLuaState::Return, res);
if (res)
{
return true;
@@ -1633,7 +1633,7 @@ bool cPluginLua::OnSpawningMonster(cWorld & a_World, cMonster & a_Monster)
cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_SPAWNING_MONSTER];
for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr)
{
- m_LuaState.Call((int)(**itr), &a_World, &a_Monster, cLuaState::Return, res);
+ m_LuaState.Call(static_cast<int>(**itr), &a_World, &a_Monster, cLuaState::Return, res);
if (res)
{
return true;
@@ -1657,7 +1657,7 @@ bool cPluginLua::OnTakeDamage(cEntity & a_Receiver, TakeDamageInfo & a_TDI)
cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_TAKE_DAMAGE];
for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr)
{
- m_LuaState.Call((int)(**itr), &a_Receiver, &a_TDI, cLuaState::Return, res);
+ m_LuaState.Call(static_cast<int>(**itr), &a_Receiver, &a_TDI, cLuaState::Return, res);
if (res)
{
return true;
@@ -1686,7 +1686,7 @@ bool cPluginLua::OnUpdatedSign(
cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_UPDATED_SIGN];
for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr)
{
- m_LuaState.Call((int)(**itr), &a_World, a_BlockX, a_BlockY, a_BlockZ, a_Line1, a_Line2, a_Line3, a_Line4, a_Player, cLuaState::Return, res);
+ m_LuaState.Call(static_cast<int>(**itr), &a_World, a_BlockX, a_BlockY, a_BlockZ, a_Line1, a_Line2, a_Line3, a_Line4, a_Player, cLuaState::Return, res);
if (res)
{
return true;
@@ -1715,7 +1715,7 @@ bool cPluginLua::OnUpdatingSign(
cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_UPDATING_SIGN];
for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr)
{
- m_LuaState.Call((int)(**itr), &a_World, a_BlockX, a_BlockY, a_BlockZ, a_Line1, a_Line2, a_Line3, a_Line4, a_Player, cLuaState::Return, res, a_Line1, a_Line2, a_Line3, a_Line4);
+ m_LuaState.Call(static_cast<int>(**itr), &a_World, a_BlockX, a_BlockY, a_BlockZ, a_Line1, a_Line2, a_Line3, a_Line4, a_Player, cLuaState::Return, res, a_Line1, a_Line2, a_Line3, a_Line4);
if (res)
{
return true;
@@ -1739,7 +1739,7 @@ bool cPluginLua::OnWeatherChanged(cWorld & a_World)
cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_WEATHER_CHANGED];
for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr)
{
- m_LuaState.Call((int)(**itr), &a_World, cLuaState::Return, res);
+ m_LuaState.Call(static_cast<int>(**itr), &a_World, cLuaState::Return, res);
if (res)
{
return true;
@@ -1763,7 +1763,7 @@ bool cPluginLua::OnWeatherChanging(cWorld & a_World, eWeather & a_NewWeather)
cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_WEATHER_CHANGING];
for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr)
{
- m_LuaState.Call((int)(**itr), &a_World, a_NewWeather, cLuaState::Return, res, a_NewWeather);
+ m_LuaState.Call(static_cast<int>(**itr), &a_World, a_NewWeather, cLuaState::Return, res, a_NewWeather);
if (res)
{
return true;
@@ -1786,7 +1786,7 @@ bool cPluginLua::OnWorldStarted(cWorld & a_World)
cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_WORLD_STARTED];
for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr)
{
- m_LuaState.Call((int)(**itr), &a_World);
+ m_LuaState.Call(static_cast<int>(**itr), &a_World);
}
return false;
}
@@ -1805,7 +1805,7 @@ bool cPluginLua::OnWorldTick(cWorld & a_World, std::chrono::milliseconds a_Dt, s
cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_WORLD_TICK];
for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr)
{
- m_LuaState.Call((int)(**itr), &a_World, a_Dt, a_LastTickDurationMSec);
+ m_LuaState.Call(static_cast<int>(**itr), &a_World, a_Dt, a_LastTickDurationMSec);
}
return false;
}
diff --git a/src/Bindings/PluginLua.h b/src/Bindings/PluginLua.h
index 7de70ef1f..4344b36ac 100644
--- a/src/Bindings/PluginLua.h
+++ b/src/Bindings/PluginLua.h
@@ -125,7 +125,7 @@ public:
virtual bool OnHopperPushingItem (cWorld & a_World, cHopperEntity & a_Hopper, int a_SrcSlotNum, cBlockEntityWithItems & a_DstEntity, int a_DstSlotNum) override;
virtual bool OnKilled (cEntity & a_Victim, TakeDamageInfo & a_TDI, AString & a_DeathMessage) override;
virtual bool OnKilling (cEntity & a_Victim, cEntity * a_Killer, TakeDamageInfo & a_TDI) override;
- virtual bool OnLogin (cClientHandle & a_Client, int a_ProtocolVersion, const AString & a_Username) override;
+ virtual bool OnLogin (cClientHandle & a_Client, UInt32 a_ProtocolVersion, const AString & a_Username) override;
virtual bool OnPlayerAnimation (cPlayer & a_Player, int a_Animation) override;
virtual bool OnPlayerBreakingBlock (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) override;
virtual bool OnPlayerBrokenBlock (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) override;
diff --git a/src/Bindings/PluginManager.cpp b/src/Bindings/PluginManager.cpp
index 712c385c7..026865f5b 100644
--- a/src/Bindings/PluginManager.cpp
+++ b/src/Bindings/PluginManager.cpp
@@ -713,7 +713,7 @@ bool cPluginManager::CallHookKilling(cEntity & a_Victim, cEntity * a_Killer, Tak
-bool cPluginManager::CallHookLogin(cClientHandle & a_Client, int a_ProtocolVersion, const AString & a_Username)
+bool cPluginManager::CallHookLogin(cClientHandle & a_Client, UInt32 a_ProtocolVersion, const AString & a_Username)
{
FIND_HOOK(HOOK_LOGIN);
VERIFY_HOOK;
diff --git a/src/Bindings/PluginManager.h b/src/Bindings/PluginManager.h
index 153f4996d..d7e3b8dfe 100644
--- a/src/Bindings/PluginManager.h
+++ b/src/Bindings/PluginManager.h
@@ -214,7 +214,7 @@ public:
bool CallHookHopperPushingItem (cWorld & a_World, cHopperEntity & a_Hopper, int a_SrcSlotNum, cBlockEntityWithItems & a_DstEntity, int a_DstSlotNum);
bool CallHookKilled (cEntity & a_Victim, TakeDamageInfo & a_TDI, AString & a_DeathMessage);
bool CallHookKilling (cEntity & a_Victim, cEntity * a_Killer, TakeDamageInfo & a_TDI);
- bool CallHookLogin (cClientHandle & a_Client, int a_ProtocolVersion, const AString & a_Username);
+ bool CallHookLogin (cClientHandle & a_Client, UInt32 a_ProtocolVersion, const AString & a_Username);
bool CallHookPlayerAnimation (cPlayer & a_Player, int a_Animation);
bool CallHookPlayerBreakingBlock (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta);
bool CallHookPlayerBrokenBlock (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta);
diff --git a/src/BlockEntities/BeaconEntity.cpp b/src/BlockEntities/BeaconEntity.cpp
index a945c6ea9..a0de281ba 100644
--- a/src/BlockEntities/BeaconEntity.cpp
+++ b/src/BlockEntities/BeaconEntity.cpp
@@ -49,14 +49,14 @@ char cBeaconEntity::CalculatePyramidLevel(void)
{
if (!IsMineralBlock(Area.GetRelBlockType(X, Y, Z)))
{
- return (Layer - 1);
+ return static_cast<char>(Layer - 1);
}
}
}
Layer++;
}
- return (Layer - 1);
+ return static_cast<char>(Layer - 1);
}
diff --git a/src/BlockEntities/NoteEntity.cpp b/src/BlockEntities/NoteEntity.cpp
index 29839bae1..53685233b 100644
--- a/src/BlockEntities/NoteEntity.cpp
+++ b/src/BlockEntities/NoteEntity.cpp
@@ -87,10 +87,10 @@ void cNoteEntity::MakeSound(void)
}
}
- m_World->BroadcastBlockAction(m_PosX, m_PosY, m_PosZ, instrument, m_Pitch, E_BLOCK_NOTE_BLOCK);
+ m_World->BroadcastBlockAction(m_PosX, m_PosY, m_PosZ, static_cast<Byte>(instrument), static_cast<Byte>(m_Pitch), E_BLOCK_NOTE_BLOCK);
// TODO: instead of calculating the power function over and over, make a precalculated table - there's only 24 pitches after all
- float calcPitch = pow(2.0f, static_cast<float>(m_Pitch - 12.0f) / 12.0f);
+ float calcPitch = static_cast<float>(pow(2.0f, static_cast<float>(m_Pitch - 12.0f) / 12.0f));
m_World->BroadcastSoundEffect(
sampleName,
static_cast<double>(m_PosX),
diff --git a/src/Blocks/BlockAnvil.h b/src/Blocks/BlockAnvil.h
index a2a7c0cf4..ebfe472c5 100644
--- a/src/Blocks/BlockAnvil.h
+++ b/src/Blocks/BlockAnvil.h
@@ -38,8 +38,8 @@ public:
) override
{
a_BlockType = m_BlockType;
- NIBBLETYPE Meta = (NIBBLETYPE)a_Player->GetEquippedItem().m_ItemDamage;
- int Direction = (int)floor(a_Player->GetYaw() * 4.0 / 360.0 + 1.5) & 0x3;
+ NIBBLETYPE Meta = static_cast<NIBBLETYPE>(a_Player->GetEquippedItem().m_ItemDamage);
+ int Direction = static_cast<int>(floor(a_Player->GetYaw() * 4.0 / 360.0 + 1.5)) & 0x3;
switch (Direction)
{
diff --git a/src/Blocks/BlockCocoaPod.h b/src/Blocks/BlockCocoaPod.h
index d061fbdd5..a48bfdfc2 100644
--- a/src/Blocks/BlockCocoaPod.h
+++ b/src/Blocks/BlockCocoaPod.h
@@ -41,7 +41,7 @@ public:
if (GrowState < 2)
{
++GrowState;
- a_Chunk.SetMeta(a_RelX, a_RelY, a_RelZ, (NIBBLETYPE) (GrowState << 2 | TypeMeta));
+ a_Chunk.SetMeta(a_RelX, a_RelY, a_RelZ, static_cast<NIBBLETYPE>(GrowState << 2 | TypeMeta));
}
}
}
diff --git a/src/Blocks/BlockCrops.h b/src/Blocks/BlockCrops.h
index e510d5f8d..c54625561 100644
--- a/src/Blocks/BlockCrops.h
+++ b/src/Blocks/BlockCrops.h
@@ -30,17 +30,17 @@ public:
case E_BLOCK_CROPS:
{
a_Pickups.push_back(cItem(E_ITEM_WHEAT, 1, 0));
- a_Pickups.push_back(cItem(E_ITEM_SEEDS, (char)(1 + (rand.NextInt(3) + rand.NextInt(3)) / 2), 0)); // [1 .. 3] with high preference of 2
+ a_Pickups.push_back(cItem(E_ITEM_SEEDS, static_cast<char>(1 + (rand.NextInt(3) + rand.NextInt(3)) / 2), 0)); // [1 .. 3] with high preference of 2
break;
}
case E_BLOCK_CARROTS:
{
- a_Pickups.push_back(cItem(E_ITEM_CARROT, (char)(1 + (rand.NextInt(3) + rand.NextInt(3)) / 2), 0)); // [1 .. 3] with high preference of 2
+ a_Pickups.push_back(cItem(E_ITEM_CARROT, static_cast<char>(1 + (rand.NextInt(3) + rand.NextInt(3)) / 2), 0)); // [1 .. 3] with high preference of 2
break;
}
case E_BLOCK_POTATOES:
{
- a_Pickups.push_back(cItem(E_ITEM_POTATO, (char)(1 + (rand.NextInt(3) + rand.NextInt(3)) / 2), 0)); // [1 .. 3] with high preference of 2
+ a_Pickups.push_back(cItem(E_ITEM_POTATO, static_cast<char>(1 + (rand.NextInt(3) + rand.NextInt(3)) / 2), 0)); // [1 .. 3] with high preference of 2
if (rand.NextInt(21) == 0)
{
// With a 5% chance, drop a poisonous potato as well
diff --git a/src/Blocks/BlockGlowstone.h b/src/Blocks/BlockGlowstone.h
index 2781a7206..cb36b9a73 100644
--- a/src/Blocks/BlockGlowstone.h
+++ b/src/Blocks/BlockGlowstone.h
@@ -21,7 +21,7 @@ public:
cFastRandom Random;
// Add more than one dust
- a_Pickups.push_back(cItem(E_ITEM_GLOWSTONE_DUST, (char)(2 + Random.NextInt(3)), 0));
+ a_Pickups.push_back(cItem(E_ITEM_GLOWSTONE_DUST, static_cast<char>(2 + Random.NextInt(3)), 0));
}
virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
diff --git a/src/Blocks/BlockLeaves.h b/src/Blocks/BlockLeaves.h
index 06c41369d..2017c391b 100644
--- a/src/Blocks/BlockLeaves.h
+++ b/src/Blocks/BlockLeaves.h
@@ -14,9 +14,9 @@
#define PROCESS_NEIGHBOR(x, y, z) \
switch (a_Area.GetBlockType(x, y, z)) \
{ \
- case E_BLOCK_LEAVES: a_Area.SetBlockType(x, y, z, (BLOCKTYPE)(E_BLOCK_SPONGE + i + 1)); break; \
+ case E_BLOCK_LEAVES: a_Area.SetBlockType(x, y, z, static_cast<BLOCKTYPE>(E_BLOCK_SPONGE + i + 1)); break; \
case E_BLOCK_LOG: return true; \
- case E_BLOCK_NEW_LEAVES: a_Area.SetBlockType(x, y, z, (BLOCKTYPE)(E_BLOCK_SPONGE + i + 1)); break; \
+ case E_BLOCK_NEW_LEAVES: a_Area.SetBlockType(x, y, z, static_cast<BLOCKTYPE>(E_BLOCK_SPONGE + i + 1)); break; \
case E_BLOCK_NEW_LOG: return true; \
}
diff --git a/src/Blocks/BlockLever.h b/src/Blocks/BlockLever.h
index 840a61e60..698b74ec8 100644
--- a/src/Blocks/BlockLever.h
+++ b/src/Blocks/BlockLever.h
@@ -24,7 +24,7 @@ public:
a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, Meta);
a_WorldInterface.WakeUpSimulators(a_BlockX, a_BlockY, a_BlockZ);
- a_WorldInterface.GetBroadcastManager().BroadcastSoundEffect("random.click", (double)a_BlockX, (double)a_BlockY, (double)a_BlockZ, 0.5f, (Meta & 0x08) ? 0.6f : 0.5f);
+ a_WorldInterface.GetBroadcastManager().BroadcastSoundEffect("random.click", static_cast<double>(a_BlockX), static_cast<double>(a_BlockY), static_cast<double>(a_BlockZ), 0.5f, (Meta & 0x08) ? 0.6f : 0.5f);
}
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
diff --git a/src/Blocks/BlockMelon.h b/src/Blocks/BlockMelon.h
index e97df723d..4743e5c98 100644
--- a/src/Blocks/BlockMelon.h
+++ b/src/Blocks/BlockMelon.h
@@ -19,7 +19,7 @@ public:
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
{
cFastRandom Random;
- a_Pickups.push_back(cItem(E_ITEM_MELON_SLICE, (char)(3 + Random.NextInt(5)), 0));
+ a_Pickups.push_back(cItem(E_ITEM_MELON_SLICE, static_cast<char>(3 + Random.NextInt(5)), 0));
}
virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
diff --git a/src/Blocks/BlockMobHead.h b/src/Blocks/BlockMobHead.h
index 639b83a03..72face3a2 100644
--- a/src/Blocks/BlockMobHead.h
+++ b/src/Blocks/BlockMobHead.h
@@ -41,7 +41,7 @@ public:
cMobHeadEntity * MobHeadEntity = static_cast<cMobHeadEntity*>(a_BlockEntity);
cItems Pickups;
- Pickups.Add(E_ITEM_HEAD, 1, (short) MobHeadEntity->GetType());
+ Pickups.Add(E_ITEM_HEAD, 1, static_cast<short>(MobHeadEntity->GetType()));
MTRand r1;
// Mid-block position first
diff --git a/src/Blocks/BlockMobSpawner.h b/src/Blocks/BlockMobSpawner.h
index d5e7c273f..4f389c397 100644
--- a/src/Blocks/BlockMobSpawner.h
+++ b/src/Blocks/BlockMobSpawner.h
@@ -47,6 +47,6 @@ public:
cFastRandom Random;
int Reward = 15 + Random.NextInt(15) + Random.NextInt(15);
- a_WorldInterface.SpawnExperienceOrb((double)a_BlockX, (double)a_BlockY + 1, (double)a_BlockZ, Reward);
+ a_WorldInterface.SpawnExperienceOrb(static_cast<double>(a_BlockX), static_cast<double>(a_BlockY + 1), static_cast<double>(a_BlockZ), Reward);
}
} ;
diff --git a/src/Blocks/BlockNetherWart.h b/src/Blocks/BlockNetherWart.h
index 424730796..6a76e0828 100644
--- a/src/Blocks/BlockNetherWart.h
+++ b/src/Blocks/BlockNetherWart.h
@@ -25,7 +25,7 @@ public:
if (a_Meta == 0x7)
{
// Fully grown, drop the entire produce:
- a_Pickups.push_back(cItem(E_ITEM_NETHER_WART, (char)(1 + (rand.NextInt(3) + rand.NextInt(3))) / 2, 0));
+ a_Pickups.push_back(cItem(E_ITEM_NETHER_WART, static_cast<char>(1 + (rand.NextInt(3) + rand.NextInt(3))) / 2, 0));
}
else
{
diff --git a/src/Blocks/BlockOre.h b/src/Blocks/BlockOre.h
index 7e67e3450..70d599843 100644
--- a/src/Blocks/BlockOre.h
+++ b/src/Blocks/BlockOre.h
@@ -26,13 +26,13 @@ public:
{
case E_BLOCK_LAPIS_ORE:
{
- a_Pickups.push_back(cItem(E_ITEM_DYE, (char)(4 + Random.NextInt(5)), 4));
+ a_Pickups.push_back(cItem(E_ITEM_DYE, static_cast<char>(4 + Random.NextInt(5)), 4));
break;
}
case E_BLOCK_REDSTONE_ORE:
case E_BLOCK_REDSTONE_ORE_GLOWING:
{
- a_Pickups.push_back(cItem(E_ITEM_REDSTONE_DUST, (char)(4 + Random.NextInt(2)), 0));
+ a_Pickups.push_back(cItem(E_ITEM_REDSTONE_DUST, static_cast<char>(4 + Random.NextInt(2)), 0));
break;
}
case E_BLOCK_DIAMOND_ORE:
diff --git a/src/Blocks/BlockPiston.cpp b/src/Blocks/BlockPiston.cpp
index 75f8621a7..4e4814242 100644
--- a/src/Blocks/BlockPiston.cpp
+++ b/src/Blocks/BlockPiston.cpp
@@ -135,7 +135,7 @@ void cBlockPistonHandler::ExtendPiston(int a_BlockX, int a_BlockY, int a_BlockZ,
}
a_World->BroadcastBlockAction(a_BlockX, a_BlockY, a_BlockZ, 0, pistonMeta, pistonBlock);
- a_World->BroadcastSoundEffect("tile.piston.out", (double)a_BlockX, (double)a_BlockY, (double)a_BlockZ, 0.5f, 0.7f);
+ a_World->BroadcastSoundEffect("tile.piston.out", static_cast<double>(a_BlockX), static_cast<double>(a_BlockY), static_cast<double>(a_BlockZ), 0.5f, 0.7f);
// Drop the breakable block in the line, if appropriate:
AddPistonDir(a_BlockX, a_BlockY, a_BlockZ, pistonMeta, dist + 1); // "a_Block" now at the breakable / empty block
@@ -209,7 +209,7 @@ void cBlockPistonHandler::RetractPiston(int a_BlockX, int a_BlockY, int a_BlockZ
AddPistonDir(a_BlockX, a_BlockY, a_BlockZ, pistonMeta, -1);
a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, pistonBlock, pistonMeta & ~(8));
a_World->BroadcastBlockAction(a_BlockX, a_BlockY, a_BlockZ, 1, pistonMeta & ~(8), pistonBlock);
- a_World->BroadcastSoundEffect("tile.piston.in", (double)a_BlockX, (double)a_BlockY, (double)a_BlockZ, 0.5f, 0.7f);
+ a_World->BroadcastSoundEffect("tile.piston.in", static_cast<double>(a_BlockX), static_cast<double>(a_BlockY), static_cast<double>(a_BlockZ), 0.5f, 0.7f);
AddPistonDir(a_BlockX, a_BlockY, a_BlockZ, pistonMeta, 1);
// Retract the extension, pull block if appropriate
diff --git a/src/Blocks/BlockPlanks.h b/src/Blocks/BlockPlanks.h
index e913db5f6..52e8c34dc 100644
--- a/src/Blocks/BlockPlanks.h
+++ b/src/Blocks/BlockPlanks.h
@@ -23,7 +23,7 @@ public:
) override
{
a_BlockType = m_BlockType;
- a_BlockMeta = (NIBBLETYPE)(a_Player->GetEquippedItem().m_ItemDamage);
+ a_BlockMeta = static_cast<NIBBLETYPE>(a_Player->GetEquippedItem().m_ItemDamage);
return true;
}
diff --git a/src/Blocks/BlockQuartz.h b/src/Blocks/BlockQuartz.h
index 878a12b25..b987723e8 100644
--- a/src/Blocks/BlockQuartz.h
+++ b/src/Blocks/BlockQuartz.h
@@ -23,7 +23,7 @@ public:
) override
{
a_BlockType = m_BlockType;
- NIBBLETYPE Meta = (NIBBLETYPE)(a_Player->GetEquippedItem().m_ItemDamage);
+ NIBBLETYPE Meta = static_cast<NIBBLETYPE>(a_Player->GetEquippedItem().m_ItemDamage);
if (Meta != E_META_QUARTZ_PILLAR) // Check if the block is a pillar block.
{
diff --git a/src/Blocks/BlockSeaLantern.h b/src/Blocks/BlockSeaLantern.h
index a9259d1d6..3454259b5 100644
--- a/src/Blocks/BlockSeaLantern.h
+++ b/src/Blocks/BlockSeaLantern.h
@@ -21,7 +21,7 @@ public:
{
// Reset meta to 0
cFastRandom Random;
- a_Pickups.push_back(cItem(E_ITEM_PRISMARINE_CRYSTALS, (char)(2 + Random.NextInt(2)), 0));
+ a_Pickups.push_back(cItem(E_ITEM_PRISMARINE_CRYSTALS, static_cast<char>(2 + Random.NextInt(2)), 0));
}
} ;
diff --git a/src/Blocks/BlockSideways.h b/src/Blocks/BlockSideways.h
index e52fbaa2f..c3fa5b3da 100644
--- a/src/Blocks/BlockSideways.h
+++ b/src/Blocks/BlockSideways.h
@@ -24,7 +24,7 @@ public:
) override
{
a_BlockType = m_BlockType;
- NIBBLETYPE Meta = (NIBBLETYPE)(a_Player->GetEquippedItem().m_ItemDamage);
+ NIBBLETYPE Meta = static_cast<NIBBLETYPE>(a_Player->GetEquippedItem().m_ItemDamage);
a_BlockMeta = BlockFaceToMetaData(a_BlockFace, Meta);
return true;
}
diff --git a/src/Blocks/BlockSignPost.h b/src/Blocks/BlockSignPost.h
index 5ae285bf0..0b122af98 100644
--- a/src/Blocks/BlockSignPost.h
+++ b/src/Blocks/BlockSignPost.h
@@ -46,7 +46,7 @@ public:
a_Rotation = (a_Rotation / 360) * 16;
- return ((char)a_Rotation) % 16;
+ return (static_cast<char>(a_Rotation)) % 16;
}
virtual NIBBLETYPE MetaRotateCW(NIBBLETYPE a_Meta) override
diff --git a/src/Blocks/BlockTrapdoor.h b/src/Blocks/BlockTrapdoor.h
index 13783c16f..f7f83a61d 100644
--- a/src/Blocks/BlockTrapdoor.h
+++ b/src/Blocks/BlockTrapdoor.h
@@ -39,7 +39,7 @@ public:
NIBBLETYPE Meta = (a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ) ^ 0x04);
a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, Meta);
- cWorld * World = (cWorld *) &a_WorldInterface;
+ cWorld * World = static_cast<cWorld *>(&a_WorldInterface);
World->BroadcastSoundParticleEffect(1003, a_BlockX, a_BlockY, a_BlockZ, 0, a_Player->GetClientHandle());
}
diff --git a/src/Blocks/BlockVine.h b/src/Blocks/BlockVine.h
index cc354c374..575273cde 100644
--- a/src/Blocks/BlockVine.h
+++ b/src/Blocks/BlockVine.h
@@ -203,13 +203,13 @@ public:
virtual NIBBLETYPE MetaMirrorXY(NIBBLETYPE a_Meta) override
{
// Bits 2 and 4 stay, bits 1 and 3 swap
- return (NIBBLETYPE)((a_Meta & 0x0a) | ((a_Meta & 0x01) << 2) | ((a_Meta & 0x04) >> 2));
+ return static_cast<NIBBLETYPE>((a_Meta & 0x0a) | ((a_Meta & 0x01) << 2) | ((a_Meta & 0x04) >> 2));
}
virtual NIBBLETYPE MetaMirrorYZ(NIBBLETYPE a_Meta) override
{
// Bits 1 and 3 stay, bits 2 and 4 swap
- return (NIBBLETYPE)((a_Meta & 0x05) | ((a_Meta & 0x02) << 2) | ((a_Meta & 0x08) >> 2));
+ return static_cast<NIBBLETYPE>((a_Meta & 0x05) | ((a_Meta & 0x02) << 2) | ((a_Meta & 0x08) >> 2));
}
virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
diff --git a/src/Blocks/CMakeLists.txt b/src/Blocks/CMakeLists.txt
index d8affd9cf..ed3e321d4 100644
--- a/src/Blocks/CMakeLists.txt
+++ b/src/Blocks/CMakeLists.txt
@@ -95,11 +95,6 @@ SET (HDRS
MetaRotator.h
WorldInterface.h)
-if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
- set_source_files_properties(BlockHandler.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=old-style-cast")
- set_source_files_properties(BlockPiston.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=old-style-cast")
-endif()
-
if(NOT MSVC)
add_library(Blocks ${SRCS} ${HDRS})
endif()
diff --git a/src/ByteBuffer.cpp b/src/ByteBuffer.cpp
index f50e3845b..7557a80db 100644
--- a/src/ByteBuffer.cpp
+++ b/src/ByteBuffer.cpp
@@ -210,7 +210,7 @@ bool cByteBuffer::Write(const void * a_Bytes, size_t a_Count)
}
ASSERT(m_BufferSize >= m_WritePos);
size_t TillEnd = m_BufferSize - m_WritePos;
- const char * Bytes = (const char *)a_Bytes;
+ const char * Bytes = reinterpret_cast<const char *>(a_Bytes);
if (TillEnd <= a_Count)
{
// Need to wrap around the ringbuffer end
@@ -548,7 +548,7 @@ bool cByteBuffer::ReadVarUTF8String(AString & a_Value)
{
LOGWARNING("%s: String too large: %u (%u KiB)", __FUNCTION__, Size, Size / 1024);
}
- return ReadString(a_Value, (size_t)Size);
+ return ReadString(a_Value, static_cast<size_t>(Size));
}
@@ -589,9 +589,9 @@ bool cByteBuffer::ReadPosition64(int & a_BlockX, int & a_BlockY, int & a_BlockZ)
UInt32 BlockZRaw = (Value & 0x03ffffff); // Bottom 26 bits
// If the highest bit in the number's range is set, convert the number into negative:
- a_BlockX = ((BlockXRaw & 0x02000000) == 0) ? BlockXRaw : -(0x04000000 - (int)BlockXRaw);
- a_BlockY = ((BlockYRaw & 0x0800) == 0) ? BlockYRaw : -(0x0800 - (int)BlockYRaw);
- a_BlockZ = ((BlockZRaw & 0x02000000) == 0) ? BlockZRaw : -(0x04000000 - (int)BlockZRaw);
+ a_BlockX = ((BlockXRaw & 0x02000000) == 0) ? static_cast<int>(BlockXRaw) : -(0x04000000 - static_cast<int>(BlockXRaw));
+ a_BlockY = ((BlockYRaw & 0x0800) == 0) ? static_cast<int>(BlockYRaw) : -(0x0800 - static_cast<int>(BlockYRaw));
+ a_BlockZ = ((BlockZRaw & 0x02000000) == 0) ? static_cast<int>(BlockZRaw) : -(0x04000000 - static_cast<int>(BlockZRaw));
return true;
}
@@ -839,7 +839,7 @@ bool cByteBuffer::ReadBuf(void * a_Buffer, size_t a_Count)
CHECK_THREAD
CheckValid();
NEEDBYTES(a_Count);
- char * Dst = (char *)a_Buffer; // So that we can do byte math
+ char * Dst = reinterpret_cast<char *>(a_Buffer); // So that we can do byte math
ASSERT(m_BufferSize >= m_ReadPos);
size_t BytesToEndOfBuffer = m_BufferSize - m_ReadPos;
if (BytesToEndOfBuffer <= a_Count)
@@ -872,7 +872,7 @@ bool cByteBuffer::WriteBuf(const void * a_Buffer, size_t a_Count)
CHECK_THREAD
CheckValid();
PUTBYTES(a_Count);
- char * Src = (char *)a_Buffer; // So that we can do byte math
+ char * Src = reinterpret_cast<char *>(const_cast<void*>(a_Buffer)); // So that we can do byte math
ASSERT(m_BufferSize >= m_ReadPos);
size_t BytesToEndOfBuffer = m_BufferSize - m_WritePos;
if (BytesToEndOfBuffer <= a_Count)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index d941b7d4c..03dfc76db 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -164,30 +164,25 @@ if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
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=old-style-cast -Wno-error=global-constructors")
- set_source_files_properties(Chunk.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=old-style-cast")
- set_source_files_properties(ChunkData.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=sign-conversion -Wno-error=old-style-cast")
- set_source_files_properties(ChunkMap.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=shadow -Wno-error=sign-conversion -Wno-error=old-style-cast")
- set_source_files_properties(ClientHandle.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=conversion -Wno-error=sign-conversion -Wno-error=global-constructors -Wno-error=old-style-cast")
+ 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(Enchantments.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=old-style-cast")
- set_source_files_properties(IniFile.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=sign-conversion -Wno-error=old-style-cast")
+ 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 -Wno-error=old-style-cast")
+ 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(LinearInterpolation.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=old-style-cast")
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(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(Server.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=old-style-cast")
set_source_files_properties(Statistics.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=global-constructors")
- set_source_files_properties(StringCompression.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=old-style-cast")
- set_source_files_properties(StringUtils.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=conversion -Wno-error=old-style-cast")
+ 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 -Wno-error=old-style-cast")
+ 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()
diff --git a/src/Chunk.cpp b/src/Chunk.cpp
index b6ec39294..e6d1d665e 100644
--- a/src/Chunk.cpp
+++ b/src/Chunk.cpp
@@ -1441,7 +1441,7 @@ void cChunk::CalculateHeightmap(const BLOCKTYPE * a_BlockTypes)
int index = MakeIndex( x, y, z);
if (a_BlockTypes[index] != E_BLOCK_AIR)
{
- m_HeightMap[x + z * Width] = (HEIGHTTYPE)y;
+ m_HeightMap[x + z * Width] = static_cast<HEIGHTTYPE>(y);
break;
}
} // for y
@@ -1615,7 +1615,7 @@ void cChunk::FastSetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockT
{
if (a_BlockType != E_BLOCK_AIR)
{
- m_HeightMap[a_RelX + a_RelZ * Width] = (HEIGHTTYPE)a_RelY;
+ m_HeightMap[a_RelX + a_RelZ * Width] = static_cast<HEIGHTTYPE>(a_RelY);
}
else
{
@@ -1623,7 +1623,7 @@ void cChunk::FastSetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockT
{
if (GetBlock(a_RelX, y, a_RelZ) != E_BLOCK_AIR)
{
- m_HeightMap[a_RelX + a_RelZ * Width] = (HEIGHTTYPE)y;
+ m_HeightMap[a_RelX + a_RelZ * Width] = static_cast<HEIGHTTYPE>(y);
break;
}
} // for y - column in m_BlockData
@@ -1781,9 +1781,9 @@ void cChunk::CollectPickupsByPlayer(cPlayer & a_Player)
{
continue; // Only pickups and projectiles can be picked up
}
- float DiffX = (float)((*itr)->GetPosX() - PosX);
- float DiffY = (float)((*itr)->GetPosY() - PosY);
- float DiffZ = (float)((*itr)->GetPosZ() - PosZ);
+ float DiffX = static_cast<float>((*itr)->GetPosX() - PosX);
+ float DiffY = static_cast<float>((*itr)->GetPosY() - PosY);
+ float DiffZ = static_cast<float>((*itr)->GetPosZ() - PosZ);
float SqrDist = DiffX * DiffX + DiffY * DiffY + DiffZ * DiffZ;
if (SqrDist < 1.5f * 1.5f) // 1.5 block
{
@@ -2079,7 +2079,7 @@ bool cChunk::ForEachChest(cChestCallback & a_Callback)
{
continue;
}
- if (a_Callback.Item((cChestEntity *)*itr))
+ if (a_Callback.Item(reinterpret_cast<cChestEntity *>(*itr)))
{
return false;
}
@@ -2101,7 +2101,7 @@ bool cChunk::ForEachDispenser(cDispenserCallback & a_Callback)
{
continue;
}
- if (a_Callback.Item((cDispenserEntity *)*itr))
+ if (a_Callback.Item(reinterpret_cast<cDispenserEntity *>(*itr)))
{
return false;
}
@@ -2123,7 +2123,7 @@ bool cChunk::ForEachDropper(cDropperCallback & a_Callback)
{
continue;
}
- if (a_Callback.Item((cDropperEntity *)*itr))
+ if (a_Callback.Item(reinterpret_cast<cDropperEntity *>(*itr)))
{
return false;
}
@@ -2145,7 +2145,7 @@ bool cChunk::ForEachDropSpenser(cDropSpenserCallback & a_Callback)
{
continue;
}
- if (a_Callback.Item((cDropSpenserEntity *)*itr))
+ if (a_Callback.Item(reinterpret_cast<cDropSpenserEntity *>(*itr)))
{
return false;
}
@@ -2175,7 +2175,7 @@ bool cChunk::ForEachFurnace(cFurnaceCallback & a_Callback)
continue;
}
}
- if (a_Callback.Item((cFurnaceEntity *)*itr))
+ if (a_Callback.Item(reinterpret_cast<cFurnaceEntity *>(*itr)))
{
return false;
}
@@ -2269,7 +2269,7 @@ bool cChunk::DoWithBeaconAt(int a_BlockX, int a_BlockY, int a_BlockZ, cBeaconCal
}
// The correct block entity is here
- if (a_Callback.Item((cBeaconEntity *)*itr))
+ if (a_Callback.Item(reinterpret_cast<cBeaconEntity *>(*itr)))
{
return false;
}
@@ -2301,7 +2301,7 @@ bool cChunk::DoWithChestAt(int a_BlockX, int a_BlockY, int a_BlockZ, cChestCallb
}
// The correct block entity is here
- if (a_Callback.Item((cChestEntity *)*itr))
+ if (a_Callback.Item(reinterpret_cast<cChestEntity *>(*itr)))
{
return false;
}
@@ -2333,7 +2333,7 @@ bool cChunk::DoWithDispenserAt(int a_BlockX, int a_BlockY, int a_BlockZ, cDispen
}
// The correct block entity is here
- if (a_Callback.Item((cDispenserEntity *)*itr))
+ if (a_Callback.Item(reinterpret_cast<cDispenserEntity *>(*itr)))
{
return false;
}
@@ -2365,7 +2365,7 @@ bool cChunk::DoWithDropperAt(int a_BlockX, int a_BlockY, int a_BlockZ, cDropperC
}
// The correct block entity is here
- if (a_Callback.Item((cDropperEntity *)*itr))
+ if (a_Callback.Item(reinterpret_cast<cDropperEntity *>(*itr)))
{
return false;
}
@@ -2397,7 +2397,7 @@ bool cChunk::DoWithDropSpenserAt(int a_BlockX, int a_BlockY, int a_BlockZ, cDrop
}
// The correct block entity is here
- if (a_Callback.Item((cDropSpenserEntity *)*itr))
+ if (a_Callback.Item(reinterpret_cast<cDropSpenserEntity *>(*itr)))
{
return false;
}
@@ -2437,7 +2437,7 @@ bool cChunk::DoWithFurnaceAt(int a_BlockX, int a_BlockY, int a_BlockZ, cFurnaceC
} // switch (BlockType)
// The correct block entity is here,
- if (a_Callback.Item((cFurnaceEntity *)*itr))
+ if (a_Callback.Item(reinterpret_cast<cFurnaceEntity *>(*itr)))
{
return false;
}
@@ -2469,7 +2469,7 @@ bool cChunk::DoWithNoteBlockAt(int a_BlockX, int a_BlockY, int a_BlockZ, cNoteBl
}
// The correct block entity is here
- if (a_Callback.Item((cNoteEntity *)*itr))
+ if (a_Callback.Item(reinterpret_cast<cNoteEntity *>(*itr)))
{
return false;
}
@@ -2501,7 +2501,7 @@ bool cChunk::DoWithCommandBlockAt(int a_BlockX, int a_BlockY, int a_BlockZ, cCom
}
// The correct block entity is here,
- if (a_Callback.Item((cCommandBlockEntity *)*itr))
+ if (a_Callback.Item(reinterpret_cast<cCommandBlockEntity *>(*itr)))
{
return false;
}
@@ -2533,7 +2533,7 @@ bool cChunk::DoWithMobHeadAt(int a_BlockX, int a_BlockY, int a_BlockZ, cMobHeadC
}
// The correct block entity is here,
- if (a_Callback.Item((cMobHeadEntity *)*itr))
+ if (a_Callback.Item(reinterpret_cast<cMobHeadEntity *>(*itr)))
{
return false;
}
@@ -2565,7 +2565,7 @@ bool cChunk::DoWithFlowerPotAt(int a_BlockX, int a_BlockY, int a_BlockZ, cFlower
}
// The correct block entity is here
- if (a_Callback.Item((cFlowerPotEntity *)*itr))
+ if (a_Callback.Item(reinterpret_cast<cFlowerPotEntity *>(*itr)))
{
return false;
}
@@ -2594,10 +2594,10 @@ bool cChunk::GetSignLines(int a_BlockX, int a_BlockY, int a_BlockZ, AString & a_
case E_BLOCK_WALLSIGN:
case E_BLOCK_SIGN_POST:
{
- a_Line1 = ((cSignEntity *)*itr)->GetLine(0);
- a_Line2 = ((cSignEntity *)*itr)->GetLine(1);
- a_Line3 = ((cSignEntity *)*itr)->GetLine(2);
- a_Line4 = ((cSignEntity *)*itr)->GetLine(3);
+ a_Line1 = reinterpret_cast<cSignEntity *>(*itr)->GetLine(0);
+ a_Line2 = reinterpret_cast<cSignEntity *>(*itr)->GetLine(1);
+ a_Line3 = reinterpret_cast<cSignEntity *>(*itr)->GetLine(2);
+ a_Line4 = reinterpret_cast<cSignEntity *>(*itr)->GetLine(3);
return true;
}
} // switch (BlockType)
diff --git a/src/ChunkData.cpp b/src/ChunkData.cpp
index 80f40d39e..ca11602a6 100644
--- a/src/ChunkData.cpp
+++ b/src/ChunkData.cpp
@@ -156,7 +156,7 @@ BLOCKTYPE cChunkData::GetBlock(int a_X, int a_Y, int a_Z) const
int Section = a_Y / SectionHeight;
if (m_Sections[Section] != nullptr)
{
- int Index = cChunkDef::MakeIndexNoCheck(a_X, a_Y - (Section * SectionHeight), a_Z);
+ int Index = cChunkDef::MakeIndexNoCheck(a_X, static_cast<int>(static_cast<UInt32>(a_Y) - (static_cast<UInt32>(Section) * SectionHeight)), a_Z);
return m_Sections[Section]->m_BlockTypes[Index];
}
else
@@ -181,7 +181,7 @@ void cChunkData::SetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_Block)
return;
}
- int Section = a_RelY / SectionHeight;
+ int Section = static_cast<int>(static_cast<UInt32>(a_RelY) / SectionHeight);
if (m_Sections[Section] == nullptr)
{
if (a_Block == 0x00)
@@ -196,7 +196,7 @@ void cChunkData::SetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_Block)
}
ZeroSection(m_Sections[Section]);
}
- int Index = cChunkDef::MakeIndexNoCheck(a_RelX, a_RelY - (Section * SectionHeight), a_RelZ);
+ int Index = cChunkDef::MakeIndexNoCheck(a_RelX, static_cast<int>(static_cast<UInt32>(a_RelY) - (static_cast<UInt32>(Section) * SectionHeight)), a_RelZ);
m_Sections[Section]->m_BlockTypes[Index] = a_Block;
}
@@ -211,10 +211,10 @@ NIBBLETYPE cChunkData::GetMeta(int a_RelX, int a_RelY, int a_RelZ) const
(a_RelY < cChunkDef::Height) && (a_RelY > -1) &&
(a_RelZ < cChunkDef::Width) && (a_RelZ > -1))
{
- int Section = a_RelY / SectionHeight;
+ int Section = static_cast<int>(static_cast<UInt32>(a_RelY) / SectionHeight);
if (m_Sections[Section] != nullptr)
{
- int Index = cChunkDef::MakeIndexNoCheck(a_RelX, a_RelY - (Section * SectionHeight), a_RelZ);
+ int Index = cChunkDef::MakeIndexNoCheck(a_RelX, static_cast<int>(static_cast<UInt32>(a_RelY) - (static_cast<UInt32>(Section) * SectionHeight)), a_RelZ);
return (m_Sections[Section]->m_BlockMetas[Index / 2] >> ((Index & 1) * 4)) & 0x0f;
}
else
@@ -242,7 +242,7 @@ bool cChunkData::SetMeta(int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_Nibble
return false;
}
- int Section = a_RelY / SectionHeight;
+ int Section = static_cast<int>(static_cast<UInt32>(a_RelY) / SectionHeight);
if (m_Sections[Section] == nullptr)
{
if ((a_Nibble & 0xf) == 0x00)
@@ -257,7 +257,7 @@ bool cChunkData::SetMeta(int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_Nibble
}
ZeroSection(m_Sections[Section]);
}
- int Index = cChunkDef::MakeIndexNoCheck(a_RelX, a_RelY - (Section * SectionHeight), a_RelZ);
+ int Index = cChunkDef::MakeIndexNoCheck(a_RelX, static_cast<int>(static_cast<UInt32>(a_RelY) - (static_cast<UInt32>(Section) * SectionHeight)), a_RelZ);
NIBBLETYPE oldval = m_Sections[Section]->m_BlockMetas[Index / 2] >> ((Index & 1) * 4) & 0xf;
m_Sections[Section]->m_BlockMetas[Index / 2] = static_cast<NIBBLETYPE>(
(m_Sections[Section]->m_BlockMetas[Index / 2] & (0xf0 >> ((Index & 1) * 4))) | // The untouched nibble
@@ -278,10 +278,10 @@ NIBBLETYPE cChunkData::GetBlockLight(int a_RelX, int a_RelY, int a_RelZ) const
(a_RelZ < cChunkDef::Width) && (a_RelZ > -1)
)
{
- int Section = a_RelY / SectionHeight;
+ int Section = static_cast<int>(static_cast<UInt32>(a_RelY) / SectionHeight);
if (m_Sections[Section] != nullptr)
{
- int Index = cChunkDef::MakeIndexNoCheck(a_RelX, a_RelY - (Section * SectionHeight), a_RelZ);
+ int Index = cChunkDef::MakeIndexNoCheck(a_RelX, static_cast<int>(static_cast<UInt32>(a_RelY) - (static_cast<UInt32>(Section) * SectionHeight)), a_RelZ);
return (m_Sections[Section]->m_BlockLight[Index / 2] >> ((Index & 1) * 4)) & 0x0f;
}
else
@@ -301,10 +301,10 @@ NIBBLETYPE cChunkData::GetSkyLight(int a_RelX, int a_RelY, int a_RelZ) const
{
if ((a_RelX < cChunkDef::Width) && (a_RelX > -1) && (a_RelY < cChunkDef::Height) && (a_RelY > -1) && (a_RelZ < cChunkDef::Width) && (a_RelZ > -1))
{
- int Section = a_RelY / SectionHeight;
+ int Section = static_cast<int>(static_cast<UInt32>(a_RelY) / SectionHeight);
if (m_Sections[Section] != nullptr)
{
- int Index = cChunkDef::MakeIndexNoCheck(a_RelX, a_RelY - (Section * SectionHeight), a_RelZ);
+ int Index = cChunkDef::MakeIndexNoCheck(a_RelX, static_cast<int>(static_cast<UInt32>(a_RelY) - (static_cast<UInt32>(Section) * SectionHeight)), a_RelZ);
return (m_Sections[Section]->m_BlockSkyLight[Index / 2] >> ((Index & 1) * 4)) & 0x0f;
}
else
@@ -442,7 +442,7 @@ void cChunkData::SetBlockTypes(const BLOCKTYPE * a_Src)
}
// The section doesn't exist, find out if it is needed:
- if (IsAllValue(a_Src + i * SectionBlockCount, SectionBlockCount, (const BLOCKTYPE)0))
+ if (IsAllValue(a_Src + i * SectionBlockCount, SectionBlockCount, static_cast<BLOCKTYPE>(0)))
{
// No need for the section, the data is all-air
continue;
@@ -474,7 +474,7 @@ void cChunkData::SetMetas(const NIBBLETYPE * a_Src)
}
// The section doesn't exist, find out if it is needed:
- if (IsAllValue(a_Src + i * SectionBlockCount / 2, SectionBlockCount / 2, (NIBBLETYPE)0))
+ if (IsAllValue(a_Src + i * SectionBlockCount / 2, SectionBlockCount / 2, static_cast<NIBBLETYPE>(0)))
{
// No need for the section, the data is all zeroes
continue;
@@ -510,7 +510,7 @@ void cChunkData::SetBlockLight(const NIBBLETYPE * a_Src)
}
// The section doesn't exist, find out if it is needed:
- if (IsAllValue(a_Src + i * SectionBlockCount / 2, SectionBlockCount / 2, (NIBBLETYPE)0))
+ if (IsAllValue(a_Src + i * SectionBlockCount / 2, SectionBlockCount / 2, static_cast<NIBBLETYPE>(0)))
{
// No need for the section, the data is all zeroes
continue;
@@ -545,7 +545,7 @@ void cChunkData::SetSkyLight(const NIBBLETYPE * a_Src)
}
// The section doesn't exist, find out if it is needed:
- if (IsAllValue(a_Src + i * SectionBlockCount / 2, SectionBlockCount / 2, (NIBBLETYPE)0xff))
+ if (IsAllValue(a_Src + i * SectionBlockCount / 2, SectionBlockCount / 2, static_cast<NIBBLETYPE>(0xff)))
{
// No need for the section, the data is all zeroes
continue;
diff --git a/src/ChunkData.h b/src/ChunkData.h
index 2ab629b29..60eeca816 100644
--- a/src/ChunkData.h
+++ b/src/ChunkData.h
@@ -29,7 +29,7 @@ class cChunkData
{
private:
- static const size_t SectionHeight = 16;
+ static const int SectionHeight = 16;
static const size_t NumSections = (cChunkDef::Height / SectionHeight);
static const size_t SectionBlockCount = SectionHeight * cChunkDef::Width * cChunkDef::Width;
diff --git a/src/ChunkMap.cpp b/src/ChunkMap.cpp
index 4db73971c..7f253ef6f 100644
--- a/src/ChunkMap.cpp
+++ b/src/ChunkMap.cpp
@@ -606,7 +606,7 @@ void cChunkMap::BroadcastParticleEffect(const AString & a_ParticleName, float a_
cCSLock Lock(m_CSLayers);
int ChunkX, ChunkZ;
- cChunkDef::BlockToChunk((int) a_SrcX, (int) a_SrcZ, ChunkX, ChunkZ);
+ cChunkDef::BlockToChunk(FloorC(a_SrcX), FloorC(a_SrcZ), ChunkX, ChunkZ);
cChunkPtr Chunk = GetChunkNoGen(ChunkX, ChunkZ);
if (Chunk == nullptr)
{
@@ -642,7 +642,7 @@ void cChunkMap::BroadcastSoundEffect(const AString & a_SoundName, double a_X, do
cCSLock Lock(m_CSLayers);
int ChunkX, ChunkZ;
- cChunkDef::BlockToChunk((int)std::floor(a_X), (int)std::floor(a_Z), ChunkX, ChunkZ);
+ cChunkDef::BlockToChunk(FloorC(std::floor(a_X)), FloorC(std::floor(a_Z)), ChunkX, ChunkZ);
cChunkPtr Chunk = GetChunkNoGen(ChunkX, ChunkZ);
if (Chunk == nullptr)
{
@@ -1182,9 +1182,9 @@ void cChunkMap::SetBlocks(const sSetBlockVector & a_Blocks)
void cChunkMap::CollectPickupsByPlayer(cPlayer & a_Player)
{
- int BlockX = (int)(a_Player.GetPosX()); // Truncating doesn't matter much; we're scanning entire chunks anyway
- int BlockY = (int)(a_Player.GetPosY());
- int BlockZ = (int)(a_Player.GetPosZ());
+ int BlockX = static_cast<int>(a_Player.GetPosX()); // Truncating doesn't matter much; we're scanning entire chunks anyway
+ int BlockY = static_cast<int>(a_Player.GetPosY());
+ int BlockZ = static_cast<int>(a_Player.GetPosZ());
int ChunkX = 0, ChunkZ = 0;
cChunkDef::AbsoluteToRelative(BlockX, BlockY, BlockZ, ChunkX, ChunkZ);
int OtherChunkX = ChunkX + ((BlockX > 8) ? 1 : -1);
@@ -1828,10 +1828,10 @@ bool cChunkMap::ForEachEntityInChunk(int a_ChunkX, int a_ChunkZ, cEntityCallback
bool cChunkMap::ForEachEntityInBox(const cBoundingBox & a_Box, cEntityCallback & a_Callback)
{
// Calculate the chunk range for the box:
- int MinChunkX = (int)floor(a_Box.GetMinX() / cChunkDef::Width);
- int MinChunkZ = (int)floor(a_Box.GetMinZ() / cChunkDef::Width);
- int MaxChunkX = (int)floor((a_Box.GetMaxX() + cChunkDef::Width) / cChunkDef::Width);
- int MaxChunkZ = (int)floor((a_Box.GetMaxZ() + cChunkDef::Width) / cChunkDef::Width);
+ int MinChunkX = FloorC(a_Box.GetMinX() / cChunkDef::Width);
+ int MinChunkZ = FloorC(a_Box.GetMinZ() / cChunkDef::Width);
+ int MaxChunkX = FloorC((a_Box.GetMaxX() + cChunkDef::Width) / cChunkDef::Width);
+ int MaxChunkZ = FloorC((a_Box.GetMaxZ() + cChunkDef::Width) / cChunkDef::Width);
// Iterate over each chunk in the range:
cCSLock Lock(m_CSLayers);
@@ -1868,26 +1868,26 @@ void cChunkMap::DoExplosionAt(double a_ExplosionSize, double a_BlockX, double a_
bool ShouldDestroyBlocks = true;
// Don't explode if the explosion center is inside a liquid block:
- if (IsBlockLiquid(m_World->GetBlock((int)floor(a_BlockX), (int)floor(a_BlockY), (int)floor(a_BlockZ))))
+ if (IsBlockLiquid(m_World->GetBlock(FloorC(a_BlockX), FloorC(a_BlockY), FloorC(a_BlockZ))))
{
ShouldDestroyBlocks = false;
}
- int ExplosionSizeInt = (int)ceil(a_ExplosionSize);
+ int ExplosionSizeInt = CeilC(a_ExplosionSize);
int ExplosionSizeSq = ExplosionSizeInt * ExplosionSizeInt;
- int bx = (int)floor(a_BlockX);
- int by = (int)floor(a_BlockY);
- int bz = (int)floor(a_BlockZ);
+ int bx = FloorC(a_BlockX);
+ int by = FloorC(a_BlockY);
+ int bz = FloorC(a_BlockZ);
- int MinY = std::max((int)floor(a_BlockY - ExplosionSizeInt), 0);
- int MaxY = std::min((int)ceil(a_BlockY + ExplosionSizeInt), cChunkDef::Height - 1);
+ int MinY = std::max(FloorC(a_BlockY - ExplosionSizeInt), 0);
+ int MaxY = std::min(CeilC(a_BlockY + ExplosionSizeInt), cChunkDef::Height - 1);
if (ShouldDestroyBlocks)
{
cBlockArea area;
- a_BlocksAffected.reserve(8 * ExplosionSizeInt * ExplosionSizeInt * ExplosionSizeInt);
- if (!area.Read(m_World, bx - ExplosionSizeInt, (int)ceil(a_BlockX + ExplosionSizeInt), MinY, MaxY, bz - ExplosionSizeInt, (int)ceil(a_BlockZ + ExplosionSizeInt)))
+ a_BlocksAffected.reserve(8 * static_cast<size_t>(ExplosionSizeInt * ExplosionSizeInt * ExplosionSizeInt));
+ if (!area.Read(m_World, bx - ExplosionSizeInt, static_cast<int>(ceil(a_BlockX + ExplosionSizeInt)), MinY, MaxY, bz - ExplosionSizeInt, static_cast<int>(ceil(a_BlockZ + ExplosionSizeInt))))
{
return;
}
@@ -2017,7 +2017,7 @@ void cChunkMap::DoExplosionAt(double a_ExplosionSize, double a_BlockX, double a_
}
// Ensure that the damage dealt is inversely proportional to the distance to the TNT centre - the closer a player is, the harder they are hit
- a_Entity->TakeDamage(dtExplosion, nullptr, (int)((1 / DistanceFromExplosion.Length()) * 6 * m_ExplosionSize), 0);
+ a_Entity->TakeDamage(dtExplosion, nullptr, static_cast<int>((1 / DistanceFromExplosion.Length()) * 6 * m_ExplosionSize), 0);
}
// Apply force to entities around the explosion - code modified from World.cpp DoExplosionAt()
diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp
index 566b814b9..ec440d51c 100644
--- a/src/ClientHandle.cpp
+++ b/src/ClientHandle.cpp
@@ -255,7 +255,7 @@ AString cClientHandle::GenerateOfflineUUID(const AString & a_Username)
// Generate an md5 checksum, and use it as base for the ID:
unsigned char MD5[16];
- md5((const unsigned char *)lcUsername.c_str(), lcUsername.length(), MD5);
+ md5(reinterpret_cast<const unsigned char *>(lcUsername.c_str()), lcUsername.length(), MD5);
MD5[6] &= 0x0f; // Need to trim to 4 bits only...
MD5[8] &= 0x0f; // ... otherwise %01x overflows into two chars
return Printf("%02x%02x%02x%02x%02x%02x3%01x%02x8%01x%02x%02x%02x%02x%02x%02x%02x",
@@ -520,8 +520,8 @@ bool cClientHandle::StreamNextChunk(void)
void cClientHandle::UnloadOutOfRangeChunks(void)
{
- int ChunkPosX = FAST_FLOOR_DIV((int)m_Player->GetPosX(), cChunkDef::Width);
- int ChunkPosZ = FAST_FLOOR_DIV((int)m_Player->GetPosZ(), cChunkDef::Width);
+ int ChunkPosX = FAST_FLOOR_DIV(static_cast<int>(m_Player->GetPosX()), cChunkDef::Width);
+ int ChunkPosZ = FAST_FLOOR_DIV(static_cast<int>(m_Player->GetPosZ()), cChunkDef::Width);
cChunkCoordsList ChunksToRemove;
{
@@ -650,7 +650,7 @@ void cClientHandle::HandlePing(void)
-bool cClientHandle::HandleLogin(int a_ProtocolVersion, const AString & a_Username)
+bool cClientHandle::HandleLogin(UInt32 a_ProtocolVersion, const AString & a_Username)
{
// If the protocol version hasn't been set yet, set it now:
if (m_ProtocolVersion == 0)
@@ -892,7 +892,7 @@ void cClientHandle::HandleBeaconSelection(int a_PrimaryEffect, int a_SecondaryEf
{
return;
}
- cBeaconWindow * BeaconWindow = (cBeaconWindow *) Window;
+ cBeaconWindow * BeaconWindow = reinterpret_cast<cBeaconWindow *>(Window);
if (Window->GetSlot(*m_Player, 0)->IsEmpty())
{
@@ -900,14 +900,14 @@ void cClientHandle::HandleBeaconSelection(int a_PrimaryEffect, int a_SecondaryEf
}
cEntityEffect::eType PrimaryEffect = cEntityEffect::effNoEffect;
- if ((a_PrimaryEffect >= 0) && (a_PrimaryEffect <= (int)cEntityEffect::effSaturation))
+ if ((a_PrimaryEffect >= 0) && (a_PrimaryEffect <= static_cast<int>(cEntityEffect::effSaturation)))
{
- PrimaryEffect = (cEntityEffect::eType)a_PrimaryEffect;
+ PrimaryEffect = static_cast<cEntityEffect::eType>(a_PrimaryEffect);
}
cEntityEffect::eType SecondaryEffect = cEntityEffect::effNoEffect;
- if ((a_SecondaryEffect >= 0) && (a_SecondaryEffect <= (int)cEntityEffect::effSaturation))
+ if ((a_SecondaryEffect >= 0) && (a_SecondaryEffect <= static_cast<int>(cEntityEffect::effSaturation)))
{
- SecondaryEffect = (cEntityEffect::eType)a_SecondaryEffect;
+ SecondaryEffect = static_cast<cEntityEffect::eType>(a_SecondaryEffect);
}
Window->SetSlot(*m_Player, 0, cItem());
@@ -971,7 +971,7 @@ void cClientHandle::HandleAnvilItemName(const AString & a_ItemName)
if (a_ItemName.length() <= 30)
{
- ((cAnvilWindow *)m_Player->GetWindow())->SetRepairedItemName(a_ItemName, m_Player);
+ reinterpret_cast<cAnvilWindow *>(m_Player->GetWindow())->SetRepairedItemName(a_ItemName, m_Player);
}
}
@@ -1021,9 +1021,9 @@ void cClientHandle::HandleLeftClick(int a_BlockX, int a_BlockY, int a_BlockZ, eB
}
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))
+ ((Diff(m_Player->GetPosX(), static_cast<double>(a_BlockX)) > 6) ||
+ (Diff(m_Player->GetPosY(), static_cast<double>(a_BlockY)) > 6) ||
+ (Diff(m_Player->GetPosZ(), static_cast<double>(a_BlockZ)) > 6))
)
{
m_Player->GetWorld()->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, m_Player);
@@ -1032,7 +1032,7 @@ void cClientHandle::HandleLeftClick(int a_BlockX, int a_BlockY, int a_BlockZ, eB
}
cPluginManager * PlgMgr = cRoot::Get()->GetPluginManager();
- if (PlgMgr->CallHookPlayerLeftClick(*m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_Status))
+ if (PlgMgr->CallHookPlayerLeftClick(*m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, static_cast<char>(a_Status)))
{
// A plugin doesn't agree with the action, replace the block on the client and quit:
m_Player->GetWorld()->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, m_Player);
@@ -1145,9 +1145,9 @@ void cClientHandle::HandleBlockDigStarted(int a_BlockX, int a_BlockY, int a_Bloc
}
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)
+ (Diff(m_Player->GetPosX(), static_cast<double>(a_BlockX)) > 6) ||
+ (Diff(m_Player->GetPosY(), static_cast<double>(a_BlockY)) > 6) ||
+ (Diff(m_Player->GetPosZ(), static_cast<double>(a_BlockZ)) > 6)
)
{
m_Player->GetWorld()->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, m_Player);
@@ -1177,7 +1177,7 @@ void cClientHandle::HandleBlockDigStarted(int a_BlockX, int a_BlockY, int a_Bloc
m_BlockDigAnimY = a_BlockY;
m_BlockDigAnimZ = a_BlockZ;
m_BlockDigAnimStage = 0;
- m_Player->GetWorld()->BroadcastBlockBreakAnimation(m_UniqueID, m_BlockDigAnimX, m_BlockDigAnimY, m_BlockDigAnimZ, 0, this);
+ m_Player->GetWorld()->BroadcastBlockBreakAnimation(static_cast<UInt32>(m_UniqueID), m_BlockDigAnimX, m_BlockDigAnimY, m_BlockDigAnimZ, 0, this);
cWorld * World = m_Player->GetWorld();
cChunkInterface ChunkInterface(World->GetChunkMap());
@@ -1269,7 +1269,7 @@ void cClientHandle::FinishDigAnimation()
// End dig animation
m_BlockDigAnimStage = -1;
// It seems that 10 ends block animation
- m_Player->GetWorld()->BroadcastBlockBreakAnimation(m_UniqueID, m_LastDigBlockX, m_LastDigBlockY, m_LastDigBlockZ, 10, this);
+ m_Player->GetWorld()->BroadcastBlockBreakAnimation(static_cast<UInt32>(m_UniqueID), m_LastDigBlockX, m_LastDigBlockY, m_LastDigBlockZ, 10, this);
}
m_BlockDigAnimX = -1;
@@ -1517,7 +1517,7 @@ void cClientHandle::HandleAnimation(int a_Animation)
return;
}
- m_Player->GetWorld()->BroadcastEntityAnimation(*m_Player, a_Animation, this);
+ m_Player->GetWorld()->BroadcastEntityAnimation(*m_Player, static_cast<char>(a_Animation), this);
}
@@ -1545,7 +1545,7 @@ void cClientHandle::HandleSteerVehicle(float a_Forward, float a_Sideways)
void cClientHandle::HandleWindowClose(UInt8 a_WindowID)
{
- m_Player->CloseWindowIfID(a_WindowID);
+ m_Player->CloseWindowIfID(static_cast<char>(a_WindowID));
}
@@ -1952,14 +1952,14 @@ void cClientHandle::Tick(float a_Dt)
if (m_BlockDigAnimStage > -1)
{
int lastAnimVal = m_BlockDigAnimStage;
- m_BlockDigAnimStage += (int)(m_BlockDigAnimSpeed * a_Dt);
+ m_BlockDigAnimStage += static_cast<int>(m_BlockDigAnimSpeed * a_Dt);
if (m_BlockDigAnimStage > 9000)
{
m_BlockDigAnimStage = 9000;
}
if (m_BlockDigAnimStage / 1000 != lastAnimVal / 1000)
{
- m_Player->GetWorld()->BroadcastBlockBreakAnimation(m_UniqueID, m_BlockDigAnimX, m_BlockDigAnimY, m_BlockDigAnimZ, (char)(m_BlockDigAnimStage / 1000), this);
+ m_Player->GetWorld()->BroadcastBlockBreakAnimation(static_cast<UInt32>(m_UniqueID), m_BlockDigAnimX, m_BlockDigAnimY, m_BlockDigAnimZ, static_cast<char>(m_BlockDigAnimStage / 1000), this);
}
}
diff --git a/src/ClientHandle.h b/src/ClientHandle.h
index 7401537b9..92c075131 100644
--- a/src/ClientHandle.h
+++ b/src/ClientHandle.h
@@ -341,7 +341,7 @@ public: // tolua_export
/** Called when the protocol has finished logging the user in.
Return true to allow the user in; false to kick them.
*/
- bool HandleLogin(int a_ProtocolVersion, const AString & a_Username);
+ bool HandleLogin(UInt32 a_ProtocolVersion, const AString & a_Username);
void SendData(const char * a_Data, size_t a_Size);
diff --git a/src/Color.h b/src/Color.h
index a90e8372b..69e6a3f60 100644
--- a/src/Color.h
+++ b/src/Color.h
@@ -22,7 +22,7 @@ public:
COLOR_LIMIT = 256,
COLOR_NONE = 0xFFFFFFFF,
};
- cColor() { m_Color = COLOR_NONE;}
+ cColor() { m_Color = static_cast<unsigned int>(COLOR_NONE);}
cColor(unsigned char a_Red, unsigned char a_Green, unsigned char a_Blue) { SetColor(a_Red, a_Green, a_Blue); }
/// Returns whether the color is a valid color
@@ -50,7 +50,7 @@ public:
unsigned char GetBlue() const;
/// Resets the color
- void Clear() { m_Color = COLOR_NONE; }
+ void Clear() { m_Color = static_cast<unsigned int>(COLOR_NONE); }
// tolua_end
unsigned int m_Color;
diff --git a/src/Entities/ArrowEntity.cpp b/src/Entities/ArrowEntity.cpp
index 492cf2a56..76b4c9758 100644
--- a/src/Entities/ArrowEntity.cpp
+++ b/src/Entities/ArrowEntity.cpp
@@ -86,7 +86,7 @@ void cArrowEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFa
m_HitBlockPos = Vector3i(X, Y, Z);
// Broadcast arrow hit sound
- m_World->BroadcastSoundEffect("random.bowhit", (double)X, (double)Y, (double)Z, 0.5f, (float)(0.75 + ((float)((GetUniqueID() * 23) % 32)) / 64));
+ m_World->BroadcastSoundEffect("random.bowhit", static_cast<double>(X), static_cast<double>(Y), static_cast<double>(Z), 0.5f, static_cast<float>(0.75 + (static_cast<float>((GetUniqueID() * 23) % 32)) / 64));
if ((m_World->GetBlock(Hit) == E_BLOCK_TNT) && IsOnFire())
{
@@ -102,7 +102,7 @@ void cArrowEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFa
void cArrowEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos)
{
- int Damage = (int)(GetSpeed().Length() / 20 * m_DamageCoeff + 0.5);
+ int Damage = static_cast<int>(GetSpeed().Length() / 20 * m_DamageCoeff + 0.5);
if (m_IsCritical)
{
Damage += m_World->GetTickRandomNumber(Damage / 2 + 2);
@@ -111,7 +111,7 @@ void cArrowEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos)
unsigned int PowerLevel = m_CreatorData.m_Enchantments.GetLevel(cEnchantments::enchPower);
if (PowerLevel > 0)
{
- int ExtraDamage = (int)ceil(0.25 * (PowerLevel + 1));
+ int ExtraDamage = static_cast<int>(ceil(0.25 * (PowerLevel + 1)));
Damage += ExtraDamage;
}
@@ -139,7 +139,7 @@ void cArrowEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos)
}
// Broadcast successful hit sound
- GetWorld()->BroadcastSoundEffect("random.successful_hit", GetPosX(), GetPosY(), GetPosZ(), 0.5, (float)(0.75 + ((float)((GetUniqueID() * 23) % 32)) / 64));
+ GetWorld()->BroadcastSoundEffect("random.successful_hit", GetPosX(), GetPosY(), GetPosZ(), 0.5, static_cast<float>(0.75 + (static_cast<float>((GetUniqueID() * 23) % 32)) / 64));
Destroy();
}
@@ -164,7 +164,7 @@ void cArrowEntity::CollectedBy(cPlayer & a_Dest)
}
GetWorld()->BroadcastCollectEntity(*this, a_Dest);
- GetWorld()->BroadcastSoundEffect("random.pop", GetPosX(), GetPosY(), GetPosZ(), 0.5, (float)(0.75 + ((float)((GetUniqueID() * 23) % 32)) / 64));
+ GetWorld()->BroadcastSoundEffect("random.pop", GetPosX(), GetPosY(), GetPosZ(), 0.5, static_cast<float>(0.75 + (static_cast<float>((GetUniqueID() * 23) % 32)) / 64));
m_bIsCollected = true;
}
}
diff --git a/src/Entities/CMakeLists.txt b/src/Entities/CMakeLists.txt
index 7261e85c0..54cca9c90 100644
--- a/src/Entities/CMakeLists.txt
+++ b/src/Entities/CMakeLists.txt
@@ -61,15 +61,13 @@ SET (HDRS
WitherSkullEntity.h)
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
- set_source_files_properties(ArrowEntity.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=old-style-cast")
- set_source_files_properties(Entity.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=sign-conversion -Wno-error=global-constructors -Wno-error=switch-enum -Wno-error=old-style-cast")
- set_source_files_properties(EntityEffect.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=switch-enum -Wno-error=old-style-cast")
- set_source_files_properties(Floater.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=sign-conversion -Wno-error=old-style-cast")
- set_source_files_properties(Player.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=sign-conversion -Wno-error=switch-enum -Wno-error=conversion -Wno-error=old-style-cast")
+ set_source_files_properties(Entity.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=sign-conversion -Wno-error=global-constructors -Wno-error=switch-enum ")
+ set_source_files_properties(EntityEffect.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=switch-enum ")
+ set_source_files_properties(Floater.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=sign-conversion ")
+ set_source_files_properties(Player.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=sign-conversion -Wno-error=switch-enum -Wno-error=conversion ")
endif()
if(NOT MSVC)
add_library(Entities ${SRCS} ${HDRS})
-
target_link_libraries(Entities WorldStorage)
endif()
diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp
index bb9d3c44b..23cc487f6 100644
--- a/src/Entities/Entity.cpp
+++ b/src/Entities/Entity.cpp
@@ -313,7 +313,7 @@ bool cEntity::DoTakeDamage(TakeDamageInfo & a_TDI)
if ((a_TDI.Attacker != nullptr) && (a_TDI.Attacker->IsPlayer()))
{
- cPlayer * Player = (cPlayer *)a_TDI.Attacker;
+ cPlayer * Player = reinterpret_cast<cPlayer *>(a_TDI.Attacker);
Player->GetEquippedItem().GetHandler()->OnEntityAttack(Player, this);
@@ -321,19 +321,19 @@ bool cEntity::DoTakeDamage(TakeDamageInfo & a_TDI)
// TODO: Better damage increase, and check for enchantments (and use magic critical instead of plain)
const cEnchantments & Enchantments = Player->GetEquippedItem().m_Enchantments;
- int SharpnessLevel = Enchantments.GetLevel(cEnchantments::enchSharpness);
- int SmiteLevel = Enchantments.GetLevel(cEnchantments::enchSmite);
- int BaneOfArthropodsLevel = Enchantments.GetLevel(cEnchantments::enchBaneOfArthropods);
+ int SharpnessLevel = static_cast<int>(Enchantments.GetLevel(cEnchantments::enchSharpness));
+ int SmiteLevel = static_cast<int>(Enchantments.GetLevel(cEnchantments::enchSmite));
+ int BaneOfArthropodsLevel = static_cast<int>(Enchantments.GetLevel(cEnchantments::enchBaneOfArthropods));
if (SharpnessLevel > 0)
{
- a_TDI.FinalDamage += (int)ceil(1.25 * SharpnessLevel);
+ a_TDI.FinalDamage += static_cast<int>(ceil(1.25 * SharpnessLevel));
}
else if (SmiteLevel > 0)
{
if (IsMob())
{
- cMonster * Monster = (cMonster *)this;
+ cMonster * Monster = reinterpret_cast<cMonster *>(this);
switch (Monster->GetMobType())
{
case mtSkeleton:
@@ -341,7 +341,7 @@ bool cEntity::DoTakeDamage(TakeDamageInfo & a_TDI)
case mtWither:
case mtZombiePigman:
{
- a_TDI.FinalDamage += (int)ceil(2.5 * SmiteLevel);
+ a_TDI.FinalDamage += static_cast<int>(ceil(2.5 * SmiteLevel));
break;
}
default: break;
@@ -352,14 +352,14 @@ bool cEntity::DoTakeDamage(TakeDamageInfo & a_TDI)
{
if (IsMob())
{
- cMonster * Monster = (cMonster *)this;
+ cMonster * Monster = reinterpret_cast<cMonster *>(this);
switch (Monster->GetMobType())
{
case mtSpider:
case mtCaveSpider:
case mtSilverfish:
{
- a_TDI.RawDamage += (int)ceil(2.5 * BaneOfArthropodsLevel);
+ a_TDI.RawDamage += static_cast<int>(ceil(2.5 * BaneOfArthropodsLevel));
// TODO: Add slowness effect
break;
@@ -369,7 +369,7 @@ bool cEntity::DoTakeDamage(TakeDamageInfo & a_TDI)
}
}
- int FireAspectLevel = Enchantments.GetLevel(cEnchantments::enchFireAspect);
+ int FireAspectLevel = static_cast<int>(Enchantments.GetLevel(cEnchantments::enchFireAspect));
if (FireAspectLevel > 0)
{
int BurnTicks = 3;
@@ -384,7 +384,7 @@ bool cEntity::DoTakeDamage(TakeDamageInfo & a_TDI)
}
else if (IsMob() && !IsSubmerged() && !IsSwimming())
{
- cMonster * Monster = (cMonster *)this;
+ cMonster * Monster = reinterpret_cast<cMonster *>(this);
switch (Monster->GetMobType())
{
case mtGhast:
@@ -408,7 +408,7 @@ bool cEntity::DoTakeDamage(TakeDamageInfo & a_TDI)
if (ThornsLevel > 0)
{
- int Chance = ThornsLevel * 15;
+ int Chance = static_cast<int>(ThornsLevel * 15);
cFastRandom Random;
int RandomValue = Random.GenerateRandomInteger(0, 100);
@@ -428,7 +428,7 @@ bool cEntity::DoTakeDamage(TakeDamageInfo & a_TDI)
}
}
- Player->GetStatManager().AddValue(statDamageDealt, (StatValue)floor(a_TDI.FinalDamage * 10 + 0.5));
+ Player->GetStatManager().AddValue(statDamageDealt, static_cast<StatValue>(floor(a_TDI.FinalDamage * 10 + 0.5)));
}
if (IsPlayer())
@@ -444,31 +444,31 @@ bool cEntity::DoTakeDamage(TakeDamageInfo & a_TDI)
for (size_t i = 0; i < ARRAYCOUNT(ArmorItems); i++)
{
const cItem & Item = ArmorItems[i];
- int Level = Item.m_Enchantments.GetLevel(cEnchantments::enchProtection);
+ int Level = static_cast<int>(Item.m_Enchantments.GetLevel(cEnchantments::enchProtection));
if (Level > 0)
{
EPFProtection += (6 + Level * Level) * 0.75 / 3;
}
- Level = Item.m_Enchantments.GetLevel(cEnchantments::enchFireProtection);
+ Level = static_cast<int>(Item.m_Enchantments.GetLevel(cEnchantments::enchFireProtection));
if (Level > 0)
{
EPFFireProtection += (6 + Level * Level) * 1.25 / 3;
}
- Level = Item.m_Enchantments.GetLevel(cEnchantments::enchFeatherFalling);
+ Level = static_cast<int>(Item.m_Enchantments.GetLevel(cEnchantments::enchFeatherFalling));
if (Level > 0)
{
EPFFeatherFalling += (6 + Level * Level) * 2.5 / 3;
}
- Level = Item.m_Enchantments.GetLevel(cEnchantments::enchBlastProtection);
+ Level = static_cast<int>(Item.m_Enchantments.GetLevel(cEnchantments::enchBlastProtection));
if (Level > 0)
{
EPFBlastProtection += (6 + Level * Level) * 1.5 / 3;
}
- Level = Item.m_Enchantments.GetLevel(cEnchantments::enchProjectileProtection);
+ Level = static_cast<int>(Item.m_Enchantments.GetLevel(cEnchantments::enchProjectileProtection));
if (Level > 0)
{
EPFProjectileProtection += (6 + Level * Level) * 1.5 / 3;
@@ -509,27 +509,27 @@ bool cEntity::DoTakeDamage(TakeDamageInfo & a_TDI)
if ((a_TDI.DamageType != dtInVoid) && (a_TDI.DamageType != dtAdmin))
{
- RemovedDamage += (int)ceil(EPFProtection * 0.04 * a_TDI.FinalDamage);
+ RemovedDamage += CeilC(EPFProtection * 0.04 * a_TDI.FinalDamage);
}
if ((a_TDI.DamageType == dtFalling) || (a_TDI.DamageType == dtFall) || (a_TDI.DamageType == dtEnderPearl))
{
- RemovedDamage += (int)ceil(EPFFeatherFalling * 0.04 * a_TDI.FinalDamage);
+ RemovedDamage += CeilC(EPFFeatherFalling * 0.04 * a_TDI.FinalDamage);
}
if (a_TDI.DamageType == dtBurning)
{
- RemovedDamage += (int)ceil(EPFFireProtection * 0.04 * a_TDI.FinalDamage);
+ RemovedDamage += CeilC(EPFFireProtection * 0.04 * a_TDI.FinalDamage);
}
if (a_TDI.DamageType == dtExplosion)
{
- RemovedDamage += (int)ceil(EPFBlastProtection * 0.04 * a_TDI.FinalDamage);
+ RemovedDamage += CeilC(EPFBlastProtection * 0.04 * a_TDI.FinalDamage);
}
if (a_TDI.DamageType == dtProjectile)
{
- RemovedDamage += (int)ceil(EPFBlastProtection * 0.04 * a_TDI.FinalDamage);
+ RemovedDamage += CeilC(EPFBlastProtection * 0.04 * a_TDI.FinalDamage);
}
if (a_TDI.FinalDamage < RemovedDamage)
@@ -540,7 +540,7 @@ bool cEntity::DoTakeDamage(TakeDamageInfo & a_TDI)
a_TDI.FinalDamage -= RemovedDamage;
}
- m_Health -= (short)a_TDI.FinalDamage;
+ m_Health -= static_cast<short>(a_TDI.FinalDamage);
// TODO: Apply damage to armor
@@ -549,11 +549,11 @@ bool cEntity::DoTakeDamage(TakeDamageInfo & a_TDI)
// Add knockback:
if ((IsMob() || IsPlayer()) && (a_TDI.Attacker != nullptr))
{
- int KnockbackLevel = a_TDI.Attacker->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchKnockback); // More common enchantment
+ int KnockbackLevel = static_cast<int>(a_TDI.Attacker->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchKnockback)); // More common enchantment
if (KnockbackLevel < 1)
{
// We support punch on swords and vice versa! :)
- KnockbackLevel = a_TDI.Attacker->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchPunch);
+ KnockbackLevel = static_cast<int>(a_TDI.Attacker->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchPunch));
}
Vector3d AdditionalSpeed(0, 0, 0);
@@ -800,7 +800,7 @@ void cEntity::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
if (IsPlayer())
{
- cPlayer * Player = (cPlayer *)this;
+ cPlayer * Player = reinterpret_cast<cPlayer *>(this);
Player->UpdateMovementStats(DeltaPos);
}
}
@@ -1013,7 +1013,7 @@ void cEntity::HandlePhysics(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
cTracer Tracer(GetWorld());
// Distance traced is an integer, so we round up from the distance we should go (Speed * Delta), else we will encounter collision detection failurse
- int DistanceToTrace = (int)(ceil((NextSpeed * DtSec.count()).SqrLength()) * 2);
+ int DistanceToTrace = CeilC((NextSpeed * DtSec.count()).SqrLength()) * 2;
bool HasHit = Tracer.Trace(NextPos, NextSpeed, DistanceToTrace);
if (HasHit)
@@ -1123,12 +1123,12 @@ void cEntity::TickBurning(cChunk & a_Chunk)
}
// Update the burning times, based on surroundings:
- int MinRelX = (int)floor(GetPosX() - m_Width / 2) - a_Chunk.GetPosX() * cChunkDef::Width;
- int MaxRelX = (int)floor(GetPosX() + m_Width / 2) - a_Chunk.GetPosX() * cChunkDef::Width;
- int MinRelZ = (int)floor(GetPosZ() - m_Width / 2) - a_Chunk.GetPosZ() * cChunkDef::Width;
- int MaxRelZ = (int)floor(GetPosZ() + m_Width / 2) - a_Chunk.GetPosZ() * cChunkDef::Width;
- int MinY = std::max(0, std::min(cChunkDef::Height - 1, POSY_TOINT));
- int MaxY = std::max(0, std::min(cChunkDef::Height - 1, (int)ceil (GetPosY() + m_Height)));
+ int MinRelX = FloorC(GetPosX() - m_Width / 2) - a_Chunk.GetPosX() * cChunkDef::Width;
+ int MaxRelX = FloorC(GetPosX() + m_Width / 2) - a_Chunk.GetPosX() * cChunkDef::Width;
+ int MinRelZ = FloorC(GetPosZ() - m_Width / 2) - a_Chunk.GetPosZ() * cChunkDef::Width;
+ int MaxRelZ = FloorC(GetPosZ() + m_Width / 2) - a_Chunk.GetPosZ() * cChunkDef::Width;
+ int MinY = Clamp(POSY_TOINT, 0, cChunkDef::Height - 1);
+ int MaxY = Clamp(CeilC(GetPosY() + m_Height), 0, cChunkDef::Height - 1);
bool HasWater = false;
bool HasLava = false;
bool HasFire = false;
@@ -1325,7 +1325,7 @@ bool cEntity::DetectPortal()
return false;
}
- if (IsPlayer() && !((cPlayer *)this)->IsGameModeCreative() && (m_PortalCooldownData.m_TicksDelayed != 80))
+ if (IsPlayer() && !(reinterpret_cast<cPlayer *>(this))->IsGameModeCreative() && (m_PortalCooldownData.m_TicksDelayed != 80))
{
// Delay teleportation for four seconds if the entity is a non-creative player
m_PortalCooldownData.m_TicksDelayed++;
@@ -1345,7 +1345,7 @@ bool cEntity::DetectPortal()
if (IsPlayer())
{
// Send a respawn packet before world is loaded / generated so the client isn't left in limbo
- ((cPlayer *)this)->GetClientHandle()->SendRespawn(dimOverworld);
+ (reinterpret_cast<cPlayer *>(this))->GetClientHandle()->SendRespawn(dimOverworld);
}
Vector3d TargetPos = GetPosition();
@@ -1368,8 +1368,8 @@ bool cEntity::DetectPortal()
if (IsPlayer())
{
- ((cPlayer *)this)->AwardAchievement(achEnterPortal);
- ((cPlayer *)this)->GetClientHandle()->SendRespawn(dimNether);
+ reinterpret_cast<cPlayer *>(this)->AwardAchievement(achEnterPortal);
+ reinterpret_cast<cPlayer *>(this)->GetClientHandle()->SendRespawn(dimNether);
}
Vector3d TargetPos = GetPosition();
@@ -1401,7 +1401,7 @@ bool cEntity::DetectPortal()
if (IsPlayer())
{
- cPlayer * Player = (cPlayer *)this;
+ cPlayer * Player = reinterpret_cast<cPlayer *>(this);
Player->TeleportToCoords(Player->GetLastBedPos().x, Player->GetLastBedPos().y, Player->GetLastBedPos().z);
Player->GetClientHandle()->SendRespawn(dimOverworld);
}
@@ -1419,8 +1419,8 @@ bool cEntity::DetectPortal()
if (IsPlayer())
{
- ((cPlayer *)this)->AwardAchievement(achEnterTheEnd);
- ((cPlayer *)this)->GetClientHandle()->SendRespawn(dimEnd);
+ reinterpret_cast<cPlayer *>(this)->AwardAchievement(achEnterTheEnd);
+ reinterpret_cast<cPlayer *>(this)->GetClientHandle()->SendRespawn(dimEnd);
}
return MoveToWorld(cRoot::Get()->CreateAndInitializeWorld(GetWorld()->GetLinkedEndWorldName(), dimEnd, GetWorld()->GetName()), false);
@@ -1498,7 +1498,7 @@ bool cEntity::MoveToWorld(const AString & a_WorldName, bool a_ShouldSendRespawn)
void cEntity::SetSwimState(cChunk & a_Chunk)
{
- int RelY = (int)floor(GetPosY() + 0.1);
+ int RelY = FloorC(GetPosY() + 0.1);
if ((RelY < 0) || (RelY >= cChunkDef::Height - 1))
{
m_IsSwimming = false;
@@ -1550,7 +1550,7 @@ void cEntity::HandleAir(void)
// See if the entity is /submerged/ water (block above is water)
// Get the type of block the entity is standing in:
- int RespirationLevel = GetEquippedHelmet().m_Enchantments.GetLevel(cEnchantments::enchRespiration);
+ int RespirationLevel = static_cast<int>(GetEquippedHelmet().m_Enchantments.GetLevel(cEnchantments::enchRespiration));
if (IsSubmerged())
{
@@ -1561,7 +1561,7 @@ void cEntity::HandleAir(void)
if (RespirationLevel > 0)
{
- ((cPawn *)this)->AddEntityEffect(cEntityEffect::effNightVision, 200, 5, 0);
+ reinterpret_cast<cPawn *>(this)->AddEntityEffect(cEntityEffect::effNightVision, 200, 5, 0);
}
if (m_AirLevel <= 0)
@@ -1733,9 +1733,9 @@ void cEntity::BroadcastMovementUpdate(const cClientHandle * a_Exclude)
}
// TODO: Pickups move disgracefully if relative move packets are sent as opposed to just velocity. Have a system to send relmove only when SetPosXXX() is called with a large difference in position
- int DiffX = (int)(floor(GetPosX() * 32.0) - floor(m_LastPos.x * 32.0));
- int DiffY = (int)(floor(GetPosY() * 32.0) - floor(m_LastPos.y * 32.0));
- int DiffZ = (int)(floor(GetPosZ() * 32.0) - floor(m_LastPos.z * 32.0));
+ int DiffX = FloorC(GetPosX() * 32.0) - FloorC(m_LastPos.x * 32.0);
+ int DiffY = FloorC(GetPosY() * 32.0) - FloorC(m_LastPos.y * 32.0);
+ int DiffZ = FloorC(GetPosZ() * 32.0) - FloorC(m_LastPos.z * 32.0);
if ((DiffX != 0) || (DiffY != 0) || (DiffZ != 0)) // Have we moved?
{
@@ -1744,12 +1744,12 @@ void cEntity::BroadcastMovementUpdate(const cClientHandle * a_Exclude)
// Difference within Byte limitations, use a relative move packet
if (m_bDirtyOrientation)
{
- m_World->BroadcastEntityRelMoveLook(*this, (char)DiffX, (char)DiffY, (char)DiffZ, a_Exclude);
+ m_World->BroadcastEntityRelMoveLook(*this, static_cast<char>(DiffX), static_cast<char>(DiffY), static_cast<char>(DiffZ), a_Exclude);
m_bDirtyOrientation = false;
}
else
{
- m_World->BroadcastEntityRelMove(*this, (char)DiffX, (char)DiffY, (char)DiffZ, a_Exclude);
+ m_World->BroadcastEntityRelMove(*this, static_cast<char>(DiffX), static_cast<char>(DiffY), static_cast<char>(DiffZ), a_Exclude);
}
// Clients seem to store two positions, one for the velocity packet and one for the teleport / relmove packet
// The latter is only changed with a relmove / teleport, and m_LastPos stores this position
diff --git a/src/Entities/EntityEffect.cpp b/src/Entities/EntityEffect.cpp
index c8be414d4..214cbcc2b 100644
--- a/src/Entities/EntityEffect.cpp
+++ b/src/Entities/EntityEffect.cpp
@@ -114,7 +114,7 @@ int cEntityEffect::GetPotionEffectDuration(short a_ItemDamage)
// http://minecraft.gamepedia.com/Data_values#.22Extended_duration.22_bit
// http://minecraft.gamepedia.com/Data_values#.22Splash_potion.22_bit
- return (int)(base * TierCoeff * ExtCoeff * SplashCoeff);
+ return static_cast<int>(base * TierCoeff * ExtCoeff * SplashCoeff);
}
@@ -240,12 +240,12 @@ void cEntityEffectSpeed::OnActivate(cPawn & a_Target)
{
if (a_Target.IsMob())
{
- cMonster * Mob = (cMonster*) &a_Target;
+ cMonster * Mob = reinterpret_cast<cMonster*>(&a_Target);
Mob->SetRelativeWalkSpeed(Mob->GetRelativeWalkSpeed() + 0.2 * m_Intensity);
}
else if (a_Target.IsPlayer())
{
- cPlayer * Player = (cPlayer*) &a_Target;
+ cPlayer * Player = reinterpret_cast<cPlayer*>(&a_Target);
Player->SetNormalMaxSpeed(Player->GetNormalMaxSpeed() + 0.2 * m_Intensity);
Player->SetSprintingMaxSpeed(Player->GetSprintingMaxSpeed() + 0.26 * m_Intensity);
Player->SetFlyingMaxSpeed(Player->GetFlyingMaxSpeed() + 0.2 * m_Intensity);
@@ -260,12 +260,12 @@ void cEntityEffectSpeed::OnDeactivate(cPawn & a_Target)
{
if (a_Target.IsMob())
{
- cMonster * Mob = (cMonster*) &a_Target;
+ cMonster * Mob = reinterpret_cast<cMonster*>(&a_Target);
Mob->SetRelativeWalkSpeed(Mob->GetRelativeWalkSpeed() - 0.2 * m_Intensity);
}
else if (a_Target.IsPlayer())
{
- cPlayer * Player = (cPlayer*) &a_Target;
+ cPlayer * Player = reinterpret_cast<cPlayer*>(&a_Target);
Player->SetNormalMaxSpeed(Player->GetNormalMaxSpeed() - 0.2 * m_Intensity);
Player->SetSprintingMaxSpeed(Player->GetSprintingMaxSpeed() - 0.26 * m_Intensity);
Player->SetFlyingMaxSpeed(Player->GetFlyingMaxSpeed() - 0.2 * m_Intensity);
@@ -283,12 +283,12 @@ void cEntityEffectSlowness::OnActivate(cPawn & a_Target)
{
if (a_Target.IsMob())
{
- cMonster * Mob = (cMonster*) &a_Target;
+ cMonster * Mob = static_cast<cMonster*>(&a_Target);
Mob->SetRelativeWalkSpeed(Mob->GetRelativeWalkSpeed() - 0.15 * m_Intensity);
}
else if (a_Target.IsPlayer())
{
- cPlayer * Player = (cPlayer*) &a_Target;
+ cPlayer * Player = static_cast<cPlayer*>(&a_Target);
Player->SetNormalMaxSpeed(Player->GetNormalMaxSpeed() - 0.15 * m_Intensity);
Player->SetSprintingMaxSpeed(Player->GetSprintingMaxSpeed() - 0.195 * m_Intensity);
Player->SetFlyingMaxSpeed(Player->GetFlyingMaxSpeed() - 0.15 * m_Intensity);
@@ -303,12 +303,12 @@ void cEntityEffectSlowness::OnDeactivate(cPawn & a_Target)
{
if (a_Target.IsMob())
{
- cMonster * Mob = (cMonster*) &a_Target;
+ cMonster * Mob = static_cast<cMonster*>(&a_Target);
Mob->SetRelativeWalkSpeed(Mob->GetRelativeWalkSpeed() + 0.15 * m_Intensity);
}
else if (a_Target.IsPlayer())
{
- cPlayer * Player = (cPlayer*) &a_Target;
+ cPlayer * Player = static_cast<cPlayer*>(&a_Target);
Player->SetNormalMaxSpeed(Player->GetNormalMaxSpeed() + 0.15 * m_Intensity);
Player->SetSprintingMaxSpeed(Player->GetSprintingMaxSpeed() + 0.195 * m_Intensity);
Player->SetFlyingMaxSpeed(Player->GetFlyingMaxSpeed() + 0.15 * m_Intensity);
@@ -325,9 +325,9 @@ void cEntityEffectSlowness::OnDeactivate(cPawn & a_Target)
void cEntityEffectInstantHealth::OnActivate(cPawn & a_Target)
{
// Base amount = 6, doubles for every increase in intensity
- int amount = (int)(6 * (1 << m_Intensity) * m_DistanceModifier);
+ int amount = static_cast<int>(6 * (1 << m_Intensity) * m_DistanceModifier);
- if (a_Target.IsMob() && ((cMonster &) a_Target).IsUndead())
+ if (a_Target.IsMob() && reinterpret_cast<cMonster &>(a_Target).IsUndead())
{
a_Target.TakeDamage(dtPotionOfHarming, nullptr, amount, 0); // TODO: Store attacker in a pointer-safe way, pass to TakeDamage
return;
@@ -345,9 +345,9 @@ void cEntityEffectInstantHealth::OnActivate(cPawn & a_Target)
void cEntityEffectInstantDamage::OnActivate(cPawn & a_Target)
{
// Base amount = 6, doubles for every increase in intensity
- int amount = (int)(6 * (1 << m_Intensity) * m_DistanceModifier);
+ int amount = static_cast<int>(6 * (1 << m_Intensity) * m_DistanceModifier);
- if (a_Target.IsMob() && ((cMonster &) a_Target).IsUndead())
+ if (a_Target.IsMob() && reinterpret_cast<cMonster &>(a_Target).IsUndead())
{
a_Target.Heal(amount);
return;
@@ -366,13 +366,13 @@ void cEntityEffectRegeneration::OnTick(cPawn & a_Target)
{
super::OnTick(a_Target);
- if (a_Target.IsMob() && ((cMonster &) a_Target).IsUndead())
+ if (a_Target.IsMob() && reinterpret_cast<cMonster &>(a_Target).IsUndead())
{
return;
}
// Regen frequency = 50 ticks, divided by potion level (Regen II = 25 ticks)
- int frequency = (int) std::floor(50.0 / (double)(m_Intensity + 1));
+ int frequency = FloorC(50.0 / static_cast<double>(m_Intensity + 1));
if ((m_Ticks % frequency) != 0)
{
@@ -395,8 +395,8 @@ void cEntityEffectHunger::OnTick(cPawn & a_Target)
if (a_Target.IsPlayer())
{
- cPlayer & Target = (cPlayer &) a_Target;
- Target.AddFoodExhaustion(0.025 * ((double)GetIntensity() + 1.0)); // 0.5 per second = 0.025 per tick
+ cPlayer & Target = reinterpret_cast<cPlayer &>(a_Target);
+ Target.AddFoodExhaustion(0.025 * (static_cast<double>(GetIntensity()) + 1.0)); // 0.5 per second = 0.025 per tick
}
}
@@ -431,7 +431,7 @@ void cEntityEffectPoison::OnTick(cPawn & a_Target)
if (a_Target.IsMob())
{
- cMonster & Target = (cMonster &) a_Target;
+ cMonster & Target = reinterpret_cast<cMonster &>(a_Target);
// Doesn't effect undead mobs, spiders
if (
@@ -445,7 +445,7 @@ void cEntityEffectPoison::OnTick(cPawn & a_Target)
}
// Poison frequency = 25 ticks, divided by potion level (Poison II = 12 ticks)
- int frequency = (int) std::floor(25.0 / (double)(m_Intensity + 1));
+ int frequency = FloorC(25.0 / static_cast<double>(m_Intensity + 1));
if ((m_Ticks % frequency) == 0)
{
@@ -469,7 +469,7 @@ void cEntityEffectWither::OnTick(cPawn & a_Target)
super::OnTick(a_Target);
// Damage frequency = 40 ticks, divided by effect level (Wither II = 20 ticks)
- int frequency = (int) std::floor(25.0 / (double)(m_Intensity + 1));
+ int frequency = FloorC(25.0 / static_cast<double>(m_Intensity + 1));
if ((m_Ticks % frequency) == 0)
{
@@ -488,7 +488,7 @@ void cEntityEffectSaturation::OnTick(cPawn & a_Target)
{
if (a_Target.IsPlayer())
{
- cPlayer & Target = (cPlayer &) a_Target;
+ cPlayer & Target = reinterpret_cast<cPlayer &>(a_Target);
Target.SetFoodSaturationLevel(Target.GetFoodSaturationLevel() + (1 + m_Intensity)); // Increase saturation 1 per tick, adds 1 for every increase in level
}
}
diff --git a/src/Entities/Floater.cpp b/src/Entities/Floater.cpp
index 0c868270d..c9e8167ee 100644
--- a/src/Entities/Floater.cpp
+++ b/src/Entities/Floater.cpp
@@ -101,13 +101,13 @@ protected:
-cFloater::cFloater(double a_X, double a_Y, double a_Z, Vector3d a_Speed, int a_PlayerID, int a_CountDownTime) :
+cFloater::cFloater(double a_X, double a_Y, double a_Z, Vector3d a_Speed, UInt32 a_PlayerID, int a_CountDownTime) :
cEntity(etFloater, a_X, a_Y, a_Z, 0.2, 0.2),
m_CanPickupItem(false),
m_PickupCountDown(0),
m_CountDownTime(a_CountDownTime),
m_PlayerID(a_PlayerID),
- m_AttachedMobID(-1)
+ m_AttachedMobID(cEntity::INVALID_ID)
{
SetSpeed(a_Speed);
}
@@ -118,7 +118,7 @@ cFloater::cFloater(double a_X, double a_Y, double a_Z, Vector3d a_Speed, int a_P
void cFloater::SpawnOn(cClientHandle & a_Client)
{
- a_Client.SendSpawnObject(*this, 90, m_PlayerID, 0, 0);
+ a_Client.SendSpawnObject(*this, 90, static_cast<int>(m_PlayerID), 0, 0);
}
@@ -128,9 +128,10 @@ void cFloater::SpawnOn(cClientHandle & a_Client)
void cFloater::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
HandlePhysics(a_Dt, a_Chunk);
- if (IsBlockWater(m_World->GetBlock((int) GetPosX(), (int) GetPosY(), (int) GetPosZ())) && m_World->GetBlockMeta((int) GetPosX(), (int) GetPosY(), (int) GetPosZ()) == 0)
+ if (IsBlockWater(m_World->GetBlock(POSX_TOINT, POSY_TOINT, POSZ_TOINT))
+ && (m_World->GetBlockMeta(POSX_TOINT, POSY_TOINT, POSX_TOINT) == 0))
{
- if ((!m_CanPickupItem) && (m_AttachedMobID == -1)) // Check if you can't already pickup a fish and if the floater isn't attached to a mob.
+ if ((!m_CanPickupItem) && (m_AttachedMobID == cEntity::INVALID_ID)) // Check if you can't already pickup a fish and if the floater isn't attached to a mob.
{
if (m_CountDownTime <= 0)
{
@@ -154,7 +155,7 @@ void cFloater::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
}
m_CountDownTime--;
- if (m_World->GetHeight((int) GetPosX(), (int) GetPosZ()) == (int) GetPosY())
+ if (m_World->GetHeight(POSX_TOINT, POSY_TOINT) == POSZ_TOINT)
{
if (m_World->IsWeatherWet() && m_World->GetTickRandomNumber(3) == 0) // 25% chance of an extra countdown when being rained on.
{
@@ -182,7 +183,7 @@ void cFloater::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
}
}
- if ((GetSpeed().Length() > 4) && (m_AttachedMobID == -1))
+ if ((GetSpeed().Length() > 4) && (m_AttachedMobID == cEntity::INVALID_ID))
{
cFloaterEntityCollisionCallback Callback(this, GetPosition(), GetPosition() + GetSpeed() / 20);
@@ -202,12 +203,12 @@ void cFloater::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
Destroy(true);
}
- if (m_AttachedMobID != -1)
+ if (m_AttachedMobID != cEntity::INVALID_ID)
{
m_World->DoWithEntityByID(m_AttachedMobID, EntityCallback); // The mob the floater was attached to doesn't exist anymore.
if (!EntityCallback.DoesExist())
{
- m_AttachedMobID = -1;
+ m_AttachedMobID = cEntity::INVALID_ID;
}
}
diff --git a/src/Entities/Floater.h b/src/Entities/Floater.h
index d5715f89e..e7818c915 100644
--- a/src/Entities/Floater.h
+++ b/src/Entities/Floater.h
@@ -18,15 +18,15 @@ public:
CLASS_PROTODEF(cFloater)
- cFloater(double a_X, double a_Y, double a_Z, Vector3d a_Speed, int a_PlayerID, int a_CountDownTime);
+ cFloater(double a_X, double a_Y, double a_Z, Vector3d a_Speed, UInt32 a_PlayerID, int a_CountDownTime);
virtual void SpawnOn(cClientHandle & a_Client) override;
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
// tolua_begin
bool CanPickup(void) const { return m_CanPickupItem; }
- int GetOwnerID(void) const { return m_PlayerID; }
- int GetAttachedMobID(void) const { return m_AttachedMobID; }
+ UInt32 GetOwnerID(void) const { return m_PlayerID; }
+ UInt32 GetAttachedMobID(void) const { return m_AttachedMobID; }
// tolua_end
protected:
@@ -41,6 +41,6 @@ protected:
int m_CountDownTime;
// Entity IDs
- int m_PlayerID;
- int m_AttachedMobID;
+ UInt32 m_PlayerID;
+ UInt32 m_AttachedMobID;
} ; // tolua_export
diff --git a/src/Entities/Minecart.h b/src/Entities/Minecart.h
index 05eaf16e9..1ae4e1359 100644
--- a/src/Entities/Minecart.h
+++ b/src/Entities/Minecart.h
@@ -127,7 +127,7 @@ public:
};
const cItem & GetSlot(int a_Idx) const { return m_Contents.GetSlot(a_Idx); }
- void SetSlot(size_t a_Idx, const cItem & a_Item) { m_Contents.SetSlot(static_cast<int>(a_Idx), a_Item); }
+ void SetSlot(int a_Idx, const cItem & a_Item) { m_Contents.SetSlot(a_Idx, a_Item); }
protected:
cItemGrid m_Contents;
diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp
index 3a9360d1e..40754f6d9 100644
--- a/src/Entities/Player.cpp
+++ b/src/Entities/Player.cpp
@@ -82,7 +82,7 @@ cPlayer::cPlayer(cClientHandlePtr a_Client, const AString & a_PlayerName) :
m_bDirtyExperience(false),
m_IsChargingBow(false),
m_BowCharge(0),
- m_FloaterID(-1),
+ m_FloaterID(cEntity::INVALID_ID),
m_Team(nullptr),
m_TicksUntilNextSave(PLAYER_INVENTORY_SAVE_INTERVAL),
m_bIsTeleporting(false),
@@ -508,7 +508,7 @@ void cPlayer::SetTouchGround(bool a_bTouchGround)
if (Dist >= 2.0) // At least two blocks - TODO: Use m_LastJumpHeight instead of m_LastGroundHeight above
{
// Increment statistic
- m_Stats.AddValue(statDistFallen, (StatValue)floor(Dist * 100 + 0.5));
+ m_Stats.AddValue(statDistFallen, FloorC<StatValue>(Dist * 100 + 0.5));
}
int Damage = static_cast<int>(Dist - 3.f);
@@ -878,7 +878,7 @@ bool cPlayer::DoTakeDamage(TakeDamageInfo & a_TDI)
if ((a_TDI.Attacker != nullptr) && (a_TDI.Attacker->IsPlayer()))
{
- cPlayer * Attacker = (cPlayer *)a_TDI.Attacker;
+ cPlayer * Attacker = reinterpret_cast<cPlayer *>(a_TDI.Attacker);
if ((m_Team != nullptr) && (m_Team == Attacker->m_Team))
{
@@ -896,7 +896,7 @@ bool cPlayer::DoTakeDamage(TakeDamageInfo & a_TDI)
AddFoodExhaustion(0.3f);
SendHealth();
- m_Stats.AddValue(statDamageTaken, (StatValue)floor(a_TDI.FinalDamage * 10 + 0.5));
+ m_Stats.AddValue(statDamageTaken, FloorC<StatValue>(a_TDI.FinalDamage * 10 + 0.5));
return true;
}
return false;
@@ -926,7 +926,7 @@ void cPlayer::KilledBy(TakeDamageInfo & a_TDI)
{
Pickups.Add(cItem(E_ITEM_RED_APPLE));
}
- m_Stats.AddValue(statItemsDropped, (StatValue)Pickups.Size());
+ m_Stats.AddValue(statItemsDropped, static_cast<StatValue>(Pickups.Size()));
m_World->SpawnItemPickups(Pickups, GetPosX(), GetPosY(), GetPosZ(), 10);
SaveToDisk(); // Save it, yeah the world is a tough place !
@@ -969,7 +969,7 @@ void cPlayer::KilledBy(TakeDamageInfo & a_TDI)
}
else if (a_TDI.Attacker->IsPlayer())
{
- cPlayer * Killer = (cPlayer *)a_TDI.Attacker;
+ cPlayer * Killer = reinterpret_cast<cPlayer *>(a_TDI.Attacker);
AString DeathMessage = Printf("%s was killed by %s", GetName().c_str(), Killer->GetName().c_str());
PluginManager->CallHookKilled(*this, a_TDI, DeathMessage);
if (DeathMessage != AString(""))
@@ -1010,7 +1010,7 @@ void cPlayer::Killed(cEntity * a_Victim)
}
else if (a_Victim->IsMob())
{
- if (((cMonster *)a_Victim)->GetMobFamily() == cMonster::mfHostile)
+ if (reinterpret_cast<cMonster *>(a_Victim)->GetMobFamily() == cMonster::mfHostile)
{
AwardAchievement(achKillMonster);
}
@@ -1293,7 +1293,7 @@ unsigned int cPlayer::AwardAchievement(const eStatistic a_Ach)
if (Old > 0)
{
- return m_Stats.AddValue(a_Ach);
+ return static_cast<unsigned int>(m_Stats.AddValue(a_Ach));
}
else
{
@@ -1311,7 +1311,7 @@ unsigned int cPlayer::AwardAchievement(const eStatistic a_Ach)
// Achievement Get!
m_ClientHandle->SendStatistics(m_Stats);
- return New;
+ return static_cast<unsigned int>(New);
}
}
@@ -1630,7 +1630,7 @@ void cPlayer::TossItems(const cItems & a_Items)
return;
}
- m_Stats.AddValue(statItemsDropped, (StatValue)a_Items.Size());
+ m_Stats.AddValue(statItemsDropped, static_cast<StatValue>(a_Items.Size()));
double vX = 0, vY = 0, vZ = 0;
EulerToVector(-GetYaw(), GetPitch(), vZ, vX, vY);
@@ -1781,18 +1781,18 @@ bool cPlayer::LoadFromFile(const AString & a_FileName, cWorldPtr & a_World)
Json::Value & JSON_PlayerPosition = root["position"];
if (JSON_PlayerPosition.size() == 3)
{
- SetPosX(JSON_PlayerPosition[(unsigned)0].asDouble());
- SetPosY(JSON_PlayerPosition[(unsigned)1].asDouble());
- SetPosZ(JSON_PlayerPosition[(unsigned)2].asDouble());
+ SetPosX(JSON_PlayerPosition[0].asDouble());
+ SetPosY(JSON_PlayerPosition[1].asDouble());
+ SetPosZ(JSON_PlayerPosition[2].asDouble());
m_LastPos = GetPosition();
}
Json::Value & JSON_PlayerRotation = root["rotation"];
if (JSON_PlayerRotation.size() == 3)
{
- SetYaw (static_cast<float>(JSON_PlayerRotation[(unsigned)0].asDouble()));
- SetPitch (static_cast<float>(JSON_PlayerRotation[(unsigned)1].asDouble()));
- SetRoll (static_cast<float>(JSON_PlayerRotation[(unsigned)2].asDouble()));
+ SetYaw (static_cast<float>(JSON_PlayerRotation[0].asDouble()));
+ SetPitch (static_cast<float>(JSON_PlayerRotation[1].asDouble()));
+ SetRoll (static_cast<float>(JSON_PlayerRotation[2].asDouble()));
}
m_Health = root.get("health", 0).asInt();
@@ -1805,7 +1805,7 @@ bool cPlayer::LoadFromFile(const AString & a_FileName, cWorldPtr & a_World)
m_CurrentXp = root.get("xpCurrent", 0).asInt();
m_IsFlying = root.get("isflying", 0).asBool();
- m_GameMode = (eGameMode) root.get("gamemode", eGameMode_NotSet).asInt();
+ m_GameMode = static_cast<eGameMode>(root.get("gamemode", eGameMode_NotSet).asInt());
if (m_GameMode == eGameMode_Creative)
{
@@ -1948,7 +1948,7 @@ void cPlayer::UseEquippedItem(int a_Amount)
// If the item has an unbreaking enchantment, give it a random chance of not breaking:
cItem Item = GetEquippedItem();
- int UnbreakingLevel = Item.m_Enchantments.GetLevel(cEnchantments::enchUnbreaking);
+ int UnbreakingLevel = static_cast<int>(Item.m_Enchantments.GetLevel(cEnchantments::enchUnbreaking));
if (UnbreakingLevel > 0)
{
int chance;
@@ -1968,7 +1968,7 @@ void cPlayer::UseEquippedItem(int a_Amount)
}
}
- if (GetInventory().DamageEquippedItem(a_Amount))
+ if (GetInventory().DamageEquippedItem(static_cast<Int16>(a_Amount)))
{
m_World->BroadcastSoundEffect("random.break", GetPosX(), GetPosY(), GetPosZ(), 0.5f, static_cast<float>(0.75 + (static_cast<float>((GetUniqueID() * 23) % 32)) / 64));
}
@@ -2104,7 +2104,7 @@ bool cPlayer::IsClimbing(void) const
void cPlayer::UpdateMovementStats(const Vector3d & a_DeltaPos)
{
- StatValue Value = (StatValue)floor(a_DeltaPos.Length() * 100 + 0.5);
+ StatValue Value = FloorC<StatValue>(a_DeltaPos.Length() * 100 + 0.5);
if (m_AttachedTo == nullptr)
{
@@ -2112,7 +2112,7 @@ void cPlayer::UpdateMovementStats(const Vector3d & a_DeltaPos)
{
if (a_DeltaPos.y > 0.0) // Going up
{
- m_Stats.AddValue(statDistClimbed, (StatValue)floor(a_DeltaPos.y * 100 + 0.5));
+ m_Stats.AddValue(statDistClimbed, FloorC<StatValue>(a_DeltaPos.y * 100 + 0.5));
}
}
else if (IsSubmerged())
@@ -2146,7 +2146,7 @@ void cPlayer::UpdateMovementStats(const Vector3d & a_DeltaPos)
case cEntity::etBoat: m_Stats.AddValue(statDistBoat, Value); break;
case cEntity::etMonster:
{
- cMonster * Monster = (cMonster *)m_AttachedTo;
+ cMonster * Monster = reinterpret_cast<cMonster *>(m_AttachedTo);
switch (Monster->GetMobType())
{
case mtPig: m_Stats.AddValue(statDistPig, Value); break;
diff --git a/src/Entities/Player.h b/src/Entities/Player.h
index dffb61677..0fee6ef8a 100644
--- a/src/Entities/Player.h
+++ b/src/Entities/Player.h
@@ -319,9 +319,9 @@ public:
/** returns true if the player has thrown out a floater. */
bool IsFishing(void) const { return m_IsFishing; }
- void SetIsFishing(bool a_IsFishing, int a_FloaterID = -1) { m_IsFishing = a_IsFishing; m_FloaterID = a_FloaterID; }
+ void SetIsFishing(bool a_IsFishing, UInt32 a_FloaterID = cEntity::INVALID_ID) { m_IsFishing = a_IsFishing; m_FloaterID = a_FloaterID; }
- int GetFloaterID(void) const { return m_FloaterID; }
+ UInt32 GetFloaterID(void) const { return m_FloaterID; }
// tolua_end
@@ -619,7 +619,7 @@ protected:
bool m_IsChargingBow;
int m_BowCharge;
- int m_FloaterID;
+ UInt32 m_FloaterID;
cTeam * m_Team;
diff --git a/src/Generating/CMakeLists.txt b/src/Generating/CMakeLists.txt
index de74f8734..ecec0ea3f 100644
--- a/src/Generating/CMakeLists.txt
+++ b/src/Generating/CMakeLists.txt
@@ -74,10 +74,7 @@ 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(Caves.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=old-style-cast")
- set_source_files_properties(ChunkGenerator.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=old-style-cast")
- set_source_files_properties(CompoGen.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=old-style-cast")
- set_source_files_properties(CompoGenBiomal.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=global-constructors -Wno-error=old-style-cast")
+ 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")
@@ -91,15 +88,12 @@ if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
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(ShapeGen.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=old-style-cast")
set_source_files_properties(TestRailsGen.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=global-constructors")
- set_source_files_properties(TwoHeights.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=old-style-cast")
set_source_files_properties(UnderwaterBaseGen.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=global-constructors -Wno-error=switch-enum")
set_source_files_properties(VillageGen.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=global-constructors -Wno-error=switch-enum")
endif()
if(NOT MSVC)
add_library(Generating ${SRCS} ${HDRS})
-
target_link_libraries(Generating OSSupport Blocks Bindings)
endif()
diff --git a/src/Generating/Caves.cpp b/src/Generating/Caves.cpp
index 0a3673711..05f95464c 100644
--- a/src/Generating/Caves.cpp
+++ b/src/Generating/Caves.cpp
@@ -206,7 +206,7 @@ void cCaveTunnel::Randomize(cNoise & a_Noise)
int len = (PrevX - itr->m_BlockX) * (PrevX - itr->m_BlockX);
len += (PrevY - itr->m_BlockY) * (PrevY - itr->m_BlockY);
len += (PrevZ - itr->m_BlockZ) * (PrevZ - itr->m_BlockZ);
- len = 3 * (int)sqrt((double)len) / 4;
+ len = 3 * static_cast<int>(sqrt(static_cast<double>(len))) / 4;
int Rad = std::min(MAX_RADIUS, std::max(MIN_RADIUS, (PrevR + itr->m_Radius) / 2 + (Random % 3) - 1));
Random /= 4;
int x = (itr->m_BlockX + PrevX) / 2 + (Random % (len + 1) - len / 2);
@@ -493,7 +493,7 @@ void cCaveTunnel::ProcessChunk(
int DifY = itr->m_BlockY;
int DifZ = itr->m_BlockZ - BlockStartZ; // substitution for faster calc
int Bottom = std::max(itr->m_BlockY - 3 * itr->m_Radius / 7, 1);
- int Top = std::min(itr->m_BlockY + 3 * itr->m_Radius / 7, (int)(cChunkDef::Height));
+ int Top = std::min(itr->m_BlockY + 3 * itr->m_Radius / 7, static_cast<int>(cChunkDef::Height));
int SqRad = itr->m_Radius * itr->m_Radius;
for (int z = 0; z < cChunkDef::Width; z++) for (int x = 0; x < cChunkDef::Width; x++)
{
@@ -732,10 +732,10 @@ void cStructGenMarbleCaves::GenFinish(cChunkDesc & a_ChunkDesc)
cNoise Noise(m_Seed);
for (int z = 0; z < cChunkDef::Width; z++)
{
- const float zz = (float)(a_ChunkDesc.GetChunkZ() * cChunkDef::Width + z);
+ const float zz = static_cast<float>(a_ChunkDesc.GetChunkZ() * cChunkDef::Width + z);
for (int x = 0; x < cChunkDef::Width; x++)
{
- const float xx = (float)(a_ChunkDesc.GetChunkX() * cChunkDef::Width + x);
+ const float xx = static_cast<float>(a_ChunkDesc.GetChunkX() * cChunkDef::Width + x);
int Top = a_ChunkDesc.GetHeight(x, z);
for (int y = 1; y < Top; ++y)
@@ -745,7 +745,7 @@ void cStructGenMarbleCaves::GenFinish(cChunkDesc & a_ChunkDesc)
continue;
}
- const float yy = (float)y;
+ const float yy = static_cast<float>(y);
const float WaveNoise = 1;
if (cosf(GetMarbleNoise(xx, yy * 0.5f, zz, Noise)) * fabs(cosf(yy * 0.2f + WaveNoise * 2) * 0.75f + WaveNoise) > 0.0005f)
{
@@ -767,15 +767,15 @@ void cStructGenDualRidgeCaves::GenFinish(cChunkDesc & a_ChunkDesc)
{
for (int z = 0; z < cChunkDef::Width; z++)
{
- const float zz = (float)(a_ChunkDesc.GetChunkZ() * cChunkDef::Width + z) / 10;
+ const float zz = static_cast<float>(a_ChunkDesc.GetChunkZ() * cChunkDef::Width + z) / 10;
for (int x = 0; x < cChunkDef::Width; x++)
{
- const float xx = (float)(a_ChunkDesc.GetChunkX() * cChunkDef::Width + x) / 10;
+ const float xx = static_cast<float>(a_ChunkDesc.GetChunkX() * cChunkDef::Width + x) / 10;
int Top = a_ChunkDesc.GetHeight(x, z);
for (int y = 1; y <= Top; ++y)
{
- const float yy = (float)y / 10;
+ const float yy = static_cast<float>(y / 10);
float n1 = m_Noise1.CubicNoise3D(xx, yy, zz);
float n2 = m_Noise2.CubicNoise3D(xx, yy, zz);
float n3 = m_Noise1.CubicNoise3D(xx * 4, yy * 4, zz * 4) / 4;
diff --git a/src/Generating/ChunkGenerator.cpp b/src/Generating/ChunkGenerator.cpp
index 72d8f5258..f312d371d 100644
--- a/src/Generating/ChunkGenerator.cpp
+++ b/src/Generating/ChunkGenerator.cpp
@@ -161,7 +161,7 @@ void cChunkGenerator::WaitForQueueEmpty(void)
int cChunkGenerator::GetQueueLength(void)
{
cCSLock Lock(m_CS);
- return (int)m_Queue.size();
+ return static_cast<int>(m_Queue.size());
}
@@ -210,7 +210,7 @@ void cChunkGenerator::Execute(void)
if ((NumChunksGenerated > 16) && (clock() - LastReportTick > CLOCKS_PER_SEC))
{
LOG("Chunk generator performance: %.2f ch / sec (%d ch total)",
- (double)NumChunksGenerated * CLOCKS_PER_SEC/ (clock() - GenerationStart),
+ static_cast<double>(NumChunksGenerated) * CLOCKS_PER_SEC/ (clock() - GenerationStart),
NumChunksGenerated
);
}
@@ -242,7 +242,7 @@ void cChunkGenerator::Execute(void)
if ((NumChunksGenerated > 16) && (clock() - LastReportTick > 2 * CLOCKS_PER_SEC))
{
LOG("Chunk generator performance: %.2f ch / sec (%d ch total)",
- (double)NumChunksGenerated * CLOCKS_PER_SEC / (clock() - GenerationStart),
+ static_cast<double>(NumChunksGenerated) * CLOCKS_PER_SEC / (clock() - GenerationStart),
NumChunksGenerated
);
LastReportTick = clock();
diff --git a/src/Generating/CompoGen.cpp b/src/Generating/CompoGen.cpp
index 7cadc881a..f55228b80 100644
--- a/src/Generating/CompoGen.cpp
+++ b/src/Generating/CompoGen.cpp
@@ -53,7 +53,7 @@ void cCompoGenSameBlock::ComposeTerrain(cChunkDesc & a_ChunkDesc, const cChunkDe
void cCompoGenSameBlock::InitializeCompoGen(cIniFile & a_IniFile)
{
- m_BlockType = (BLOCKTYPE)(GetIniItemSet(a_IniFile, "Generator", "SameBlockType", "stone").m_ItemType);
+ m_BlockType = static_cast<BLOCKTYPE>(GetIniItemSet(a_IniFile, "Generator", "SameBlockType", "stone").m_ItemType);
m_IsBedrocked = (a_IniFile.GetValueSetI("Generator", "SameBlockBedrocked", 1) != 0);
}
@@ -200,12 +200,12 @@ void cCompoGenClassic::InitializeCompoGen(cIniFile & a_IniFile)
m_SeaLevel = a_IniFile.GetValueSetI("Generator", "SeaLevel", m_SeaLevel);
m_BeachHeight = a_IniFile.GetValueSetI("Generator", "ClassicBeachHeight", m_BeachHeight);
m_BeachDepth = a_IniFile.GetValueSetI("Generator", "ClassicBeachDepth", m_BeachDepth);
- m_BlockTop = (BLOCKTYPE)(GetIniItemSet(a_IniFile, "Generator", "ClassicBlockTop", "grass").m_ItemType);
- m_BlockMiddle = (BLOCKTYPE)(GetIniItemSet(a_IniFile, "Generator", "ClassicBlockMiddle", "dirt").m_ItemType);
- m_BlockBottom = (BLOCKTYPE)(GetIniItemSet(a_IniFile, "Generator", "ClassicBlockBottom", "stone").m_ItemType);
- m_BlockBeach = (BLOCKTYPE)(GetIniItemSet(a_IniFile, "Generator", "ClassicBlockBeach", "sand").m_ItemType);
- m_BlockBeachBottom = (BLOCKTYPE)(GetIniItemSet(a_IniFile, "Generator", "ClassicBlockBeachBottom", "sandstone").m_ItemType);
- m_BlockSea = (BLOCKTYPE)(GetIniItemSet(a_IniFile, "Generator", "ClassicBlockSea", "stationarywater").m_ItemType);
+ m_BlockTop = static_cast<BLOCKTYPE>(GetIniItemSet(a_IniFile, "Generator", "ClassicBlockTop", "grass").m_ItemType);
+ m_BlockMiddle = static_cast<BLOCKTYPE>(GetIniItemSet(a_IniFile, "Generator", "ClassicBlockMiddle", "dirt").m_ItemType);
+ m_BlockBottom = static_cast<BLOCKTYPE>(GetIniItemSet(a_IniFile, "Generator", "ClassicBlockBottom", "stone").m_ItemType);
+ m_BlockBeach = static_cast<BLOCKTYPE>(GetIniItemSet(a_IniFile, "Generator", "ClassicBlockBeach", "sand").m_ItemType);
+ m_BlockBeachBottom = static_cast<BLOCKTYPE>(GetIniItemSet(a_IniFile, "Generator", "ClassicBlockBeachBottom", "sandstone").m_ItemType);
+ m_BlockSea = static_cast<BLOCKTYPE>(GetIniItemSet(a_IniFile, "Generator", "ClassicBlockSea", "stationarywater").m_ItemType);
}
@@ -307,7 +307,7 @@ void cCompoGenNether::ComposeTerrain(cChunkDesc & a_ChunkDesc, const cChunkDesc:
int Height = a_ChunkDesc.GetHeight(x, z);
a_ChunkDesc.SetBlockType(x, Height, z, E_BLOCK_BEDROCK);
- NOISE_DATATYPE CeilingDisguise = (m_Noise1.CubicNoise2D((float)(a_ChunkDesc.GetChunkX() * cChunkDef::Width + x) / 10, (float)(a_ChunkDesc.GetChunkZ() * cChunkDef::Width + z) / 10));
+ NOISE_DATATYPE CeilingDisguise = (m_Noise1.CubicNoise2D(static_cast<float>(a_ChunkDesc.GetChunkX() * cChunkDef::Width + x) / 10, static_cast<float>(a_ChunkDesc.GetChunkZ() * cChunkDef::Width + z) / 10));
if (CeilingDisguise < 0)
{
CeilingDisguise = -CeilingDisguise;
diff --git a/src/Generating/CompoGenBiomal.cpp b/src/Generating/CompoGenBiomal.cpp
index 60f7e7520..43e98387f 100644
--- a/src/Generating/CompoGenBiomal.cpp
+++ b/src/Generating/CompoGenBiomal.cpp
@@ -365,8 +365,8 @@ protected:
case biMegaSpruceTaigaHills:
{
// Select the pattern to use - podzol, grass or grassless dirt:
- NOISE_DATATYPE NoiseX = ((NOISE_DATATYPE)(a_ChunkDesc.GetChunkX() * cChunkDef::Width + a_RelX)) / FrequencyX;
- NOISE_DATATYPE NoiseY = ((NOISE_DATATYPE)(a_ChunkDesc.GetChunkZ() * cChunkDef::Width + a_RelZ)) / FrequencyZ;
+ NOISE_DATATYPE NoiseX = (static_cast<NOISE_DATATYPE>(a_ChunkDesc.GetChunkX() * cChunkDef::Width + a_RelX)) / FrequencyX;
+ NOISE_DATATYPE NoiseY = (static_cast<NOISE_DATATYPE>(a_ChunkDesc.GetChunkZ() * cChunkDef::Width + a_RelZ)) / FrequencyZ;
NOISE_DATATYPE Val = m_OceanFloorSelect.CubicNoise2D(NoiseX, NoiseY);
const cPattern::BlockInfo * Pattern = (Val < -0.9) ? patGrassLess.Get() : ((Val > 0) ? patPodzol.Get() : patGrass.Get());
FillColumnPattern(a_ChunkDesc, a_RelX, a_RelZ, Pattern, a_ShapeColumn);
@@ -407,8 +407,8 @@ protected:
case biExtremeHillsM:
{
// Select the pattern to use - gravel, stone or grass:
- NOISE_DATATYPE NoiseX = ((NOISE_DATATYPE)(a_ChunkDesc.GetChunkX() * cChunkDef::Width + a_RelX)) / FrequencyX;
- NOISE_DATATYPE NoiseY = ((NOISE_DATATYPE)(a_ChunkDesc.GetChunkZ() * cChunkDef::Width + a_RelZ)) / FrequencyZ;
+ NOISE_DATATYPE NoiseX = (static_cast<NOISE_DATATYPE>(a_ChunkDesc.GetChunkX() * cChunkDef::Width + a_RelX)) / FrequencyX;
+ NOISE_DATATYPE NoiseY = (static_cast<NOISE_DATATYPE>(a_ChunkDesc.GetChunkZ() * cChunkDef::Width + a_RelZ)) / FrequencyZ;
NOISE_DATATYPE Val = m_OceanFloorSelect.CubicNoise2D(NoiseX, NoiseY);
const cPattern::BlockInfo * Pattern = (Val < 0.0) ? patStone.Get() : patGrass.Get();
FillColumnPattern(a_ChunkDesc, a_RelX, a_RelZ, Pattern, a_ShapeColumn);
@@ -493,9 +493,9 @@ protected:
return;
}
- NOISE_DATATYPE NoiseX = ((NOISE_DATATYPE)(a_ChunkDesc.GetChunkX() * cChunkDef::Width + a_RelX)) / FrequencyX;
- NOISE_DATATYPE NoiseY = ((NOISE_DATATYPE)(a_ChunkDesc.GetChunkZ() * cChunkDef::Width + a_RelZ)) / FrequencyZ;
- int ClayFloor = m_SeaLevel - 6 + (int)(4.f * m_MesaFloor.CubicNoise2D(NoiseX, NoiseY));
+ NOISE_DATATYPE NoiseX = (static_cast<NOISE_DATATYPE>(a_ChunkDesc.GetChunkX() * cChunkDef::Width + a_RelX)) / FrequencyX;
+ NOISE_DATATYPE NoiseY = (static_cast<NOISE_DATATYPE>(a_ChunkDesc.GetChunkZ() * cChunkDef::Width + a_RelZ)) / FrequencyZ;
+ int ClayFloor = m_SeaLevel - 6 + static_cast<int>(4.f * m_MesaFloor.CubicNoise2D(NoiseX, NoiseY));
if (ClayFloor >= Top)
{
ClayFloor = Top - 1;
@@ -577,8 +577,8 @@ protected:
const NOISE_DATATYPE FrequencyZ = 3;
// Select the ocean-floor pattern to use:
- NOISE_DATATYPE NoiseX = ((NOISE_DATATYPE)(a_ChunkX * cChunkDef::Width + a_RelX)) / FrequencyX;
- NOISE_DATATYPE NoiseY = ((NOISE_DATATYPE)(a_ChunkZ * cChunkDef::Width + a_RelZ)) / FrequencyZ;
+ NOISE_DATATYPE NoiseX = (static_cast<NOISE_DATATYPE>(a_ChunkX * cChunkDef::Width + a_RelX)) / FrequencyX;
+ NOISE_DATATYPE NoiseY = (static_cast<NOISE_DATATYPE>(a_ChunkZ * cChunkDef::Width + a_RelZ)) / FrequencyZ;
NOISE_DATATYPE Val = m_OceanFloorSelect.CubicNoise2D(NoiseX, NoiseY);
if (Val < -0.95)
{
diff --git a/src/HTTPServer/CMakeLists.txt b/src/HTTPServer/CMakeLists.txt
index e25628f7f..6788d50bf 100644
--- a/src/HTTPServer/CMakeLists.txt
+++ b/src/HTTPServer/CMakeLists.txt
@@ -25,7 +25,7 @@ SET (HDRS
SslHTTPConnection.h)
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
- set_source_files_properties(HTTPServer.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=global-constructors -Wno-error=old-style-cast")
+ set_source_files_properties(HTTPServer.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=global-constructors ")
set_source_files_properties(HTTPConnection.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=switch-enum")
set_source_files_properties(HTTPMessage.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=tautological-compare")
endif()
diff --git a/src/HTTPServer/HTTPServer.cpp b/src/HTTPServer/HTTPServer.cpp
index 2eb8bf1ff..7a6303b1f 100644
--- a/src/HTTPServer/HTTPServer.cpp
+++ b/src/HTTPServer/HTTPServer.cpp
@@ -43,7 +43,7 @@ class cDebugCallbacks :
{
UNUSED(a_Connection);
- cHTTPFormParser * FormParser = (cHTTPFormParser *)(a_Request.GetUserData());
+ cHTTPFormParser * FormParser = reinterpret_cast<cHTTPFormParser *>(a_Request.GetUserData());
if (FormParser != nullptr)
{
FormParser->Parse(a_Data, a_Size);
@@ -53,7 +53,7 @@ class cDebugCallbacks :
virtual void OnRequestFinished(cHTTPConnection & a_Connection, cHTTPRequest & a_Request) override
{
- cHTTPFormParser * FormParser = (cHTTPFormParser *)(a_Request.GetUserData());
+ cHTTPFormParser * FormParser = reinterpret_cast<cHTTPFormParser *>(a_Request.GetUserData());
if (FormParser != nullptr)
{
if (FormParser->Finish())
diff --git a/src/IniFile.cpp b/src/IniFile.cpp
index 635af740d..2efa9064b 100644
--- a/src/IniFile.cpp
+++ b/src/IniFile.cpp
@@ -255,15 +255,15 @@ int cIniFile::FindKey(const AString & a_KeyName) const
int cIniFile::FindValue(const int keyID, const AString & a_ValueName) const
{
- if (!keys.size() || (keyID >= (int)keys.size()))
+ if (!keys.size() || (keyID >= static_cast<int>(keys.size())))
{
return noID;
}
AString CaseValueName = CheckCase(a_ValueName);
- for (size_t valueID = 0; valueID < keys[keyID].names.size(); ++valueID)
+ for (size_t valueID = 0; valueID < keys[static_cast<size_t>(keyID)].names.size(); ++valueID)
{
- if (CheckCase(keys[keyID].names[valueID]) == CaseValueName)
+ if (CheckCase(keys[static_cast<size_t>(keyID)].names[valueID]) == CaseValueName)
{
return int(valueID);
}
@@ -279,7 +279,7 @@ int cIniFile::AddKeyName(const AString & keyname)
{
names.resize(names.size() + 1, keyname);
keys.resize(keys.size() + 1);
- return (int)names.size() - 1;
+ return static_cast<int>(names.size()) - 1;
}
@@ -288,9 +288,9 @@ int cIniFile::AddKeyName(const AString & keyname)
AString cIniFile::GetKeyName(const int keyID) const
{
- if (keyID < (int)names.size())
+ if (keyID < static_cast<int>(names.size()))
{
- return names[keyID];
+ return names[static_cast<size_t>(keyID)];
}
else
{
@@ -304,9 +304,9 @@ AString cIniFile::GetKeyName(const int keyID) const
int cIniFile::GetNumValues(const int keyID) const
{
- if (keyID < (int)keys.size())
+ if (keyID < static_cast<int>(keys.size()))
{
- return (int)keys[keyID].names.size();
+ return static_cast<int>(keys[static_cast<size_t>(keyID)].names.size());
}
return 0;
}
@@ -322,7 +322,7 @@ int cIniFile::GetNumValues(const AString & keyname) const
{
return 0;
}
- return (int)keys[keyID].names.size();
+ return static_cast<int>(keys[static_cast<size_t>(keyID)].names.size());
}
@@ -331,9 +331,9 @@ int cIniFile::GetNumValues(const AString & keyname) const
AString cIniFile::GetValueName(const int keyID, const int valueID) const
{
- if ((keyID < (int)keys.size()) && (valueID < (int)keys[keyID].names.size()))
+ if ((keyID < static_cast<int>(keys.size())) && (valueID < static_cast<int>(keys[static_cast<size_t>(keyID)].names.size())))
{
- return keys[keyID].names[valueID];
+ return keys[static_cast<size_t>(keyID)].names[static_cast<size_t>(valueID)];
}
return "";
}
@@ -364,8 +364,8 @@ void cIniFile::AddValue(const AString & a_KeyName, const AString & a_ValueName,
keyID = int(AddKeyName(a_KeyName));
}
- keys[keyID].names.push_back(a_ValueName);
- keys[keyID].values.push_back(a_Value);
+ keys[static_cast<size_t>(keyID)].names.push_back(a_ValueName);
+ keys[static_cast<size_t>(keyID)].values.push_back(a_Value);
}
@@ -392,11 +392,11 @@ void cIniFile::AddValueF(const AString & a_KeyName, const AString & a_ValueName,
bool cIniFile::SetValue(const int keyID, const int valueID, const AString & value)
{
- if (((size_t)keyID >= keys.size()) || ((size_t)valueID >= keys[keyID].names.size()))
+ if ((static_cast<size_t>(keyID) >= keys.size()) || (static_cast<size_t>(valueID) >= keys[static_cast<size_t>(keyID)].names.size()))
{
return false;
}
- keys[keyID].values[valueID] = value;
+ keys[static_cast<size_t>(keyID)].values[static_cast<size_t>(valueID)] = value;
return true;
}
@@ -423,12 +423,12 @@ bool cIniFile::SetValue(const AString & a_KeyName, const AString & a_ValueName,
{
return false;
}
- keys[keyID].names.push_back(a_ValueName);
- keys[keyID].values.push_back(a_Value);
+ keys[static_cast<size_t>(keyID)].names.push_back(a_ValueName);
+ keys[static_cast<size_t>(keyID)].values.push_back(a_Value);
}
else
{
- keys[keyID].values[valueID] = a_Value;
+ keys[static_cast<size_t>(keyID)].values[static_cast<size_t>(valueID)] = a_Value;
}
return true;
@@ -467,9 +467,9 @@ bool cIniFile::SetValueF(const AString & a_KeyName, const AString & a_ValueName,
AString cIniFile::GetValue(const int keyID, const int valueID, const AString & defValue) const
{
- if ((keyID < (int)keys.size()) && (valueID < (int)keys[keyID].names.size()))
+ if ((keyID < static_cast<int>(keys.size())) && (valueID < static_cast<int>(keys[static_cast<size_t>(keyID)].names.size())))
{
- return keys[keyID].values[valueID];
+ return keys[static_cast<size_t>(keyID)].values[static_cast<size_t>(valueID)];
}
return defValue;
}
@@ -492,7 +492,7 @@ AString cIniFile::GetValue(const AString & keyname, const AString & valuename, c
return defValue;
}
- return keys[keyID].values[valueID];
+ return keys[static_cast<size_t>(keyID)].values[static_cast<size_t>(valueID)];
}
@@ -537,7 +537,7 @@ AString cIniFile::GetValueSet(const AString & keyname, const AString & valuename
return defValue;
}
- return keys[keyID].values[valueID];
+ return keys[static_cast<size_t>(keyID)].values[static_cast<size_t>(valueID)];
}
@@ -586,13 +586,13 @@ Int64 cIniFile::GetValueSetI(const AString & keyname, const AString & valuename,
bool cIniFile::DeleteValueByID(const int keyID, const int valueID)
{
- if ((keyID < (int)keys.size()) && (valueID < (int)keys[keyID].names.size()))
+ if ((keyID < static_cast<int>(keys.size())) && (valueID < static_cast<int>(keys[static_cast<size_t>(keyID)].names.size())))
{
// This looks strange, but is neccessary.
- vector<AString>::iterator npos = keys[keyID].names.begin() + valueID;
- vector<AString>::iterator vpos = keys[keyID].values.begin() + valueID;
- keys[keyID].names.erase(npos, npos + 1);
- keys[keyID].values.erase(vpos, vpos + 1);
+ vector<AString>::iterator npos = keys[static_cast<size_t>(keyID)].names.begin() + valueID;
+ vector<AString>::iterator vpos = keys[static_cast<size_t>(keyID)].values.begin() + valueID;
+ keys[static_cast<size_t>(keyID)].names.erase(npos, npos + 1);
+ keys[static_cast<size_t>(keyID)].values.erase(vpos, vpos + 1);
return true;
}
return false;
@@ -684,9 +684,9 @@ void cIniFile::AddHeaderComment(const AString & comment)
AString cIniFile::GetHeaderComment(const int commentID) const
{
- if (commentID < (int)comments.size())
+ if (commentID < static_cast<int>(comments.size()))
{
- return comments[commentID];
+ return comments[static_cast<size_t>(commentID)];
}
return "";
}
@@ -697,7 +697,7 @@ AString cIniFile::GetHeaderComment(const int commentID) const
bool cIniFile::DeleteHeaderComment(int commentID)
{
- if (commentID < (int)comments.size())
+ if (commentID < static_cast<int>(comments.size()))
{
vector<AString>::iterator cpos = comments.begin() + commentID;
comments.erase(cpos, cpos + 1);
@@ -712,9 +712,9 @@ bool cIniFile::DeleteHeaderComment(int commentID)
int cIniFile::GetNumKeyComments(const int keyID) const
{
- if (keyID < (int)keys.size())
+ if (keyID < static_cast<int>(keys.size()))
{
- return (int)keys[keyID].comments.size();
+ return static_cast<int>(keys[static_cast<size_t>(keyID)].comments.size());
}
return 0;
}
@@ -730,7 +730,7 @@ int cIniFile::GetNumKeyComments(const AString & keyname) const
{
return 0;
}
- return (int)keys[keyID].comments.size();
+ return static_cast<int>(keys[static_cast<size_t>(keyID)].comments.size());
}
@@ -739,9 +739,9 @@ int cIniFile::GetNumKeyComments(const AString & keyname) const
bool cIniFile::AddKeyComment(const int keyID, const AString & comment)
{
- if (keyID < (int)keys.size())
+ if (keyID < static_cast<int>(keys.size()))
{
- keys[keyID].comments.resize(keys[keyID].comments.size() + 1, comment);
+ keys[static_cast<size_t>(keyID)].comments.resize(keys[static_cast<size_t>(keyID)].comments.size() + 1, comment);
return true;
}
return false;
@@ -767,9 +767,9 @@ bool cIniFile::AddKeyComment(const AString & keyname, const AString & comment)
AString cIniFile::GetKeyComment(const int keyID, const int commentID) const
{
- if ((keyID < (int)keys.size()) && (commentID < (int)keys[keyID].comments.size()))
+ if ((keyID < static_cast<int>(keys.size())) && (commentID < static_cast<int>(keys[static_cast<size_t>(keyID)].comments.size())))
{
- return keys[keyID].comments[commentID];
+ return keys[static_cast<size_t>(keyID)].comments[static_cast<size_t>(commentID)];
}
return "";
}
@@ -794,10 +794,10 @@ AString cIniFile::GetKeyComment(const AString & keyname, const int commentID) co
bool cIniFile::DeleteKeyComment(const int keyID, const int commentID)
{
- if ((keyID < (int)keys.size()) && (commentID < (int)keys[keyID].comments.size()))
+ if ((keyID < static_cast<int>(keys.size())) && (commentID < static_cast<int>(keys[static_cast<size_t>(keyID)].comments.size())))
{
- vector<AString>::iterator cpos = keys[keyID].comments.begin() + commentID;
- keys[keyID].comments.erase(cpos, cpos + 1);
+ vector<AString>::iterator cpos = keys[static_cast<size_t>(keyID)].comments.begin() + commentID;
+ keys[static_cast<size_t>(keyID)].comments.erase(cpos, cpos + 1);
return true;
}
return false;
@@ -823,9 +823,9 @@ bool cIniFile::DeleteKeyComment(const AString & keyname, const int commentID)
bool cIniFile::DeleteKeyComments(const int keyID)
{
- if (keyID < (int)keys.size())
+ if (keyID < static_cast<int>(keys.size()))
{
- keys[keyID].comments.clear();
+ keys[static_cast<size_t>(keyID)].comments.clear();
return true;
}
return false;
@@ -842,7 +842,7 @@ bool cIniFile::DeleteKeyComments(const AString & keyname)
{
return false;
}
- return DeleteKeyComments(int(keyID));
+ return DeleteKeyComments(static_cast<int>(keyID));
}
@@ -877,7 +877,7 @@ void cIniFile::RemoveBom(AString & a_line) const
const AString ref = a_line.substr(0, 3);
// If any of the first three chars do not match, return and do nothing.
- for (int i = 0; i < 3; ++i)
+ for (size_t i = 0; i < 3; ++i)
{
if (static_cast<unsigned char>(ref[i]) != BOM[i])
{
@@ -910,9 +910,9 @@ std::vector<std::pair<AString, AString>> cIniFile::GetValues(AString a_keyName)
{
return ret;
}
- for (size_t valueID = 0; valueID < keys[keyID].names.size(); ++valueID)
+ for (size_t valueID = 0; valueID < keys[static_cast<size_t>(keyID)].names.size(); ++valueID)
{
- ret.emplace_back(keys[keyID].names[valueID], keys[keyID].values[valueID]);
+ ret.emplace_back(keys[static_cast<size_t>(keyID)].names[valueID], keys[static_cast<size_t>(keyID)].values[valueID]);
}
return ret;
}
diff --git a/src/Inventory.cpp b/src/Inventory.cpp
index 455a4bbe5..14b7202c7 100644
--- a/src/Inventory.cpp
+++ b/src/Inventory.cpp
@@ -138,7 +138,7 @@ int cInventory::AddItem(const cItem & a_Item, bool a_AllowNewStacks)
}
res += m_HotbarSlots.AddItem(ToAdd, a_AllowNewStacks);
- ToAdd.m_ItemCount = a_Item.m_ItemCount - res;
+ ToAdd.m_ItemCount = static_cast<char>(a_Item.m_ItemCount - res);
if (ToAdd.m_ItemCount == 0)
{
return res;
@@ -459,7 +459,7 @@ void cInventory::SendSlot(int a_SlotNum)
// Sanitize items that are not completely empty (ie. count == 0, but type != empty)
Item.Empty();
}
- m_Owner.GetClientHandle()->SendInventorySlot(0, a_SlotNum + 5, Item); // Slots in the client are numbered "+ 5" because of crafting grid and result
+ m_Owner.GetClientHandle()->SendInventorySlot(0, static_cast<short>(a_SlotNum + 5), Item); // Slots in the client are numbered "+ 5" because of crafting grid and result
}
@@ -724,7 +724,7 @@ void cInventory::OnSlotChanged(cItemGrid * a_ItemGrid, int a_SlotNum)
if ((a_ItemGrid == &m_ArmorSlots) && (World != nullptr))
{
World->BroadcastEntityEquipment(
- m_Owner, ArmorSlotNumToEntityEquipmentID(a_SlotNum),
+ m_Owner, static_cast<short>(ArmorSlotNumToEntityEquipmentID(a_SlotNum)),
m_ArmorSlots.GetSlot(a_SlotNum), m_Owner.GetClientHandle()
);
}
diff --git a/src/Item.cpp b/src/Item.cpp
index 7bd344ae8..2a4accb58 100644
--- a/src/Item.cpp
+++ b/src/Item.cpp
@@ -169,11 +169,11 @@ void cItem::GetJson(Json::Value & a_OutValue) const
void cItem::FromJson(const Json::Value & a_Value)
{
- m_ItemType = (ENUM_ITEM_ID)a_Value.get("ID", -1).asInt();
+ m_ItemType = static_cast<ENUM_ITEM_ID>(a_Value.get("ID", -1).asInt());
if (m_ItemType > 0)
{
- m_ItemCount = (char)a_Value.get("Count", -1).asInt();
- m_ItemDamage = (short)a_Value.get("Health", -1).asInt();
+ m_ItemCount = static_cast<char>(a_Value.get("Count", -1).asInt());
+ m_ItemDamage = static_cast<short>(a_Value.get("Health", -1).asInt());
m_Enchantments.Clear();
m_Enchantments.AddFromString(a_Value.get("ench", "").asString());
m_CustomName = a_Value.get("Name", "").asString();
@@ -195,8 +195,8 @@ void cItem::FromJson(const Json::Value & a_Value)
{
m_FireworkItem.m_HasFlicker = a_Value.get("Flicker", false).asBool();
m_FireworkItem.m_HasTrail = a_Value.get("Trail", false).asBool();
- m_FireworkItem.m_Type = (NIBBLETYPE)a_Value.get("Type", 0).asInt();
- m_FireworkItem.m_FlightTimeInTicks = (short)a_Value.get("FlightTimeInTicks", 0).asInt();
+ m_FireworkItem.m_Type = static_cast<NIBBLETYPE>(a_Value.get("Type", 0).asInt());
+ m_FireworkItem.m_FlightTimeInTicks = static_cast<short>(a_Value.get("FlightTimeInTicks", 0).asInt());
m_FireworkItem.ColoursFromString(a_Value.get("Colours", "").asString(), m_FireworkItem);
m_FireworkItem.FadeColoursFromString(a_Value.get("FadeColours", "").asString(), m_FireworkItem);
}
@@ -334,9 +334,9 @@ bool cItem::EnchantByXPLevels(int a_NumXPLevels)
}
cFastRandom Random;
- int ModifiedEnchantmentLevel = a_NumXPLevels + (int)Random.NextFloat((float)Enchantability / 4) + (int)Random.NextFloat((float)Enchantability / 4) + 1;
+ int ModifiedEnchantmentLevel = a_NumXPLevels + static_cast<int>(Random.NextFloat(static_cast<float>(Enchantability / 4))) + static_cast<int>(Random.NextFloat(static_cast<float>(Enchantability / 4))) + 1;
float RandomBonus = 1.0F + (Random.NextFloat(1) + Random.NextFloat(1) - 1.0F) * 0.15F;
- int FinalEnchantmentLevel = (int)(ModifiedEnchantmentLevel * RandomBonus + 0.5F);
+ int FinalEnchantmentLevel = static_cast<int>(ModifiedEnchantmentLevel * RandomBonus + 0.5F);
cWeightedEnchantments Enchantments;
cEnchantments::AddItemEnchantmentWeights(Enchantments, m_ItemType, FinalEnchantmentLevel);
@@ -353,7 +353,7 @@ bool cItem::EnchantByXPLevels(int a_NumXPLevels)
// Checking for conflicting enchantments
cEnchantments::CheckEnchantmentConflictsFromVector(Enchantments, Enchantment1);
- float NewEnchantmentLevel = (float)a_NumXPLevels;
+ float NewEnchantmentLevel = static_cast<float>(a_NumXPLevels);
// Next Enchantment (Second)
NewEnchantmentLevel = NewEnchantmentLevel / 2;
@@ -407,12 +407,12 @@ bool cItem::EnchantByXPLevels(int a_NumXPLevels)
cItem * cItems::Get(int a_Idx)
{
- if ((a_Idx < 0) || (a_Idx >= (int)size()))
+ if ((a_Idx < 0) || (a_Idx >= static_cast<int>(size())))
{
LOGWARNING("cItems: Attempt to get an out-of-bounds item at index %d; there are currently " SIZE_T_FMT " items. Returning a nil.", a_Idx, size());
return nullptr;
}
- return &at(a_Idx);
+ return &at(static_cast<size_t>(a_Idx));
}
@@ -421,12 +421,12 @@ cItem * cItems::Get(int a_Idx)
void cItems::Set(int a_Idx, const cItem & a_Item)
{
- if ((a_Idx < 0) || (a_Idx >= (int)size()))
+ if ((a_Idx < 0) || (a_Idx >= static_cast<int>(size())))
{
LOGWARNING("cItems: Attempt to set an item at an out-of-bounds index %d; there are currently " SIZE_T_FMT " items. Not setting.", a_Idx, size());
return;
}
- at(a_Idx) = a_Item;
+ at(static_cast<size_t>(a_Idx)) = a_Item;
}
@@ -435,7 +435,7 @@ void cItems::Set(int a_Idx, const cItem & a_Item)
void cItems::Delete(int a_Idx)
{
- if ((a_Idx < 0) || (a_Idx >= (int)size()))
+ if ((a_Idx < 0) || (a_Idx >= static_cast<int>(size())))
{
LOGWARNING("cItems: Attempt to delete an item at an out-of-bounds index %d; there are currently " SIZE_T_FMT " items. Ignoring.", a_Idx, size());
return;
@@ -449,12 +449,12 @@ void cItems::Delete(int a_Idx)
void cItems::Set(int a_Idx, short a_ItemType, char a_ItemCount, short a_ItemDamage)
{
- if ((a_Idx < 0) || (a_Idx >= (int)size()))
+ if ((a_Idx < 0) || (a_Idx >= static_cast<int>(size())))
{
LOGWARNING("cItems: Attempt to set an item at an out-of-bounds index %d; there are currently " SIZE_T_FMT " items. Not setting.", a_Idx, size());
return;
}
- at(a_Idx) = cItem(a_ItemType, a_ItemCount, a_ItemDamage);
+ at(static_cast<size_t>(a_Idx)) = cItem(a_ItemType, a_ItemCount, a_ItemDamage);
}
diff --git a/src/ItemGrid.cpp b/src/ItemGrid.cpp
index 8433598f7..9585ace8f 100644
--- a/src/ItemGrid.cpp
+++ b/src/ItemGrid.cpp
@@ -256,7 +256,7 @@ int cItemGrid::AddItemToSlot(const cItem & a_ItemStack, int a_Slot, int a_Num, i
{
PrevCount = m_Slots[a_Slot].m_ItemCount;
}
- m_Slots[a_Slot].m_ItemCount = std::min(a_MaxStack, PrevCount + a_Num);
+ m_Slots[a_Slot].m_ItemCount = static_cast<char>(std::min(a_MaxStack, PrevCount + a_Num));
int toReturn = m_Slots[a_Slot].m_ItemCount - PrevCount;
TriggerListeners(a_Slot);
return toReturn;
@@ -660,11 +660,11 @@ void cItemGrid::GenerateRandomLootWithBooks(const cLootProbab * a_LootProbabs, s
CurrentLoot = a_LootProbabs[j].m_Item;
if ((a_LootProbabs[j].m_MaxAmount - a_LootProbabs[j].m_MinAmount) > 0)
{
- CurrentLoot.m_ItemCount = a_LootProbabs[j].m_MinAmount + (Rnd % (a_LootProbabs[j].m_MaxAmount - a_LootProbabs[j].m_MinAmount));
+ CurrentLoot.m_ItemCount = static_cast<char>(a_LootProbabs[j].m_MinAmount + (Rnd % (a_LootProbabs[j].m_MaxAmount - a_LootProbabs[j].m_MinAmount)));
}
else
{
- CurrentLoot.m_ItemCount = a_LootProbabs[j].m_MinAmount;
+ CurrentLoot.m_ItemCount = static_cast<char>(a_LootProbabs[j].m_MinAmount);
}
Rnd >>= 8;
break;
diff --git a/src/Items/CMakeLists.txt b/src/Items/CMakeLists.txt
index 71f2d9ceb..46ff3b4a0 100644
--- a/src/Items/CMakeLists.txt
+++ b/src/Items/CMakeLists.txt
@@ -57,7 +57,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=old-style-cast -Wno-error=switch-enum")
+ set_source_files_properties(ItemHandler.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=sign-conversion -Wno-error=conversion -Wno-error=switch-enum")
endif()
if(NOT MSVC)
diff --git a/src/Items/ItemEmptyMap.h b/src/Items/ItemEmptyMap.h
index 98352bd2d..f26f915c4 100644
--- a/src/Items/ItemEmptyMap.h
+++ b/src/Items/ItemEmptyMap.h
@@ -60,7 +60,7 @@ public:
return true;
}
- a_Player->GetInventory().AddItem(cItem(E_ITEM_MAP, 1, (short)(NewMap->GetID() & 0x7fff)));
+ a_Player->GetInventory().AddItem(cItem(E_ITEM_MAP, 1, static_cast<short>(NewMap->GetID() & 0x7fff)));
return true;
}
diff --git a/src/Items/ItemFishingRod.h b/src/Items/ItemFishingRod.h
index 5bf4b29b7..355ff2eae 100644
--- a/src/Items/ItemFishingRod.h
+++ b/src/Items/ItemFishingRod.h
@@ -27,27 +27,27 @@ class cFloaterCallback :
public:
cFloaterCallback(void) :
m_CanPickup(false),
- m_AttachedMobID(-1)
+ m_AttachedMobID(cEntity::INVALID_ID)
{
}
virtual bool Item(cEntity * a_Entity) override
{
- m_CanPickup = ((cFloater *)a_Entity)->CanPickup();
+ m_CanPickup = reinterpret_cast<cFloater *>(a_Entity)->CanPickup();
m_Pos = Vector3d(a_Entity->GetPosX(), a_Entity->GetPosY(), a_Entity->GetPosZ());
- m_AttachedMobID = ((cFloater *)a_Entity)->GetAttachedMobID();
+ m_AttachedMobID = reinterpret_cast<cFloater *>(a_Entity)->GetAttachedMobID();
a_Entity->Destroy(true);
return true;
}
bool CanPickup(void) const { return m_CanPickup; }
- bool IsAttached(void) const { return (m_AttachedMobID != -1); }
- int GetAttachedMobID(void) const { return m_AttachedMobID; }
+ bool IsAttached(void) const { return (m_AttachedMobID != cEntity::INVALID_ID); }
+ UInt32 GetAttachedMobID(void) const { return m_AttachedMobID; }
Vector3d GetPos(void) const { return m_Pos; }
protected:
bool m_CanPickup;
- int m_AttachedMobID;
+ UInt32 m_AttachedMobID;
Vector3d m_Pos;
} ;
@@ -137,7 +137,7 @@ public:
}
case 2:
{
- Drops.Add(cItem(E_ITEM_FISHING_ROD, 1, (short)a_World->GetTickRandomNumber(50))); // Fishing rod with durability. TODO: Enchantments on it
+ Drops.Add(cItem(E_ITEM_FISHING_ROD, 1, static_cast<short>(a_World->GetTickRandomNumber(50)))); // Fishing rod with durability. TODO: Enchantments on it
break;
}
case 3:
@@ -168,7 +168,7 @@ public:
}
else if (Junk <= 4)
{
- Drops.Add(cItem(E_ITEM_BOW, 1, (short)a_World->GetTickRandomNumber(64)));
+ Drops.Add(cItem(E_ITEM_BOW, 1, static_cast<short>(a_World->GetTickRandomNumber(64))));
}
else if (Junk <= 9)
{
@@ -244,7 +244,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));
+ cFloater * Floater = new cFloater(a_Player->GetPosX(), a_Player->GetStance(), a_Player->GetPosZ(), a_Player->GetLookVector() * 15, a_Player->GetUniqueID(), static_cast<int>(100 + static_cast<unsigned int>(a_World->GetTickRandomNumber(800)) - (a_Player->GetEquippedItem().m_Enchantments.GetLevel(cEnchantments::enchLure) * 100)));
Floater->Initialize(*a_World);
a_Player->SetIsFishing(true, Floater->GetUniqueID());
}
diff --git a/src/Items/ItemHandler.cpp b/src/Items/ItemHandler.cpp
index aa5f6109b..580a0b7ee 100644
--- a/src/Items/ItemHandler.cpp
+++ b/src/Items/ItemHandler.cpp
@@ -531,12 +531,15 @@ void cItemHandler::OnFoodEaten(cWorld * a_World, cPlayer * a_Player, cItem * a_I
short cItemHandler::GetDurabilityLossByAction(eDurabilityLostAction a_Action)
{
- switch ((int)a_Action)
+ switch (a_Action)
{
case dlaAttackEntity: return 2;
case dlaBreakBlock: return 1;
}
+
+ #ifndef __clang__
return 0;
+ #endif
}
diff --git a/src/Items/ItemLighter.h b/src/Items/ItemLighter.h
index 24641dce6..a1b4b871b 100644
--- a/src/Items/ItemLighter.h
+++ b/src/Items/ItemLighter.h
@@ -57,7 +57,7 @@ public:
case E_BLOCK_TNT:
{
// Activate the TNT:
- a_World->BroadcastSoundEffect("game.tnt.primed", (double)a_BlockX, (double)a_BlockY, (double)a_BlockZ, 1.0f, 1.0f);
+ a_World->BroadcastSoundEffect("game.tnt.primed", static_cast<double>(a_BlockX), static_cast<double>(a_BlockY), static_cast<double>(a_BlockZ), 1.0f, 1.0f);
a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_AIR, 0);
a_World->SpawnPrimedTNT(a_BlockX + 0.5, a_BlockY + 0.5, a_BlockZ + 0.5); // 80 ticks to boom
break;
@@ -73,7 +73,7 @@ public:
if (a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ) == E_BLOCK_AIR)
{
a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_FIRE, 0);
- a_World->BroadcastSoundEffect("fire.ignite", (double)a_BlockX, (double)a_BlockY, (double)a_BlockZ, 1.0F, 1.04F);
+ a_World->BroadcastSoundEffect("fire.ignite", static_cast<double>(a_BlockX), static_cast<double>(a_BlockY), static_cast<double>(a_BlockZ), 1.0F, 1.04F);
break;
}
}
diff --git a/src/Items/ItemMap.h b/src/Items/ItemMap.h
index a96183f41..19b974767 100644
--- a/src/Items/ItemMap.h
+++ b/src/Items/ItemMap.h
@@ -29,7 +29,7 @@ public:
virtual void OnUpdate(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item)
{
- cMap * Map = a_World->GetMapManager().GetMapData((unsigned)a_Item.m_ItemDamage);
+ cMap * Map = a_World->GetMapManager().GetMapData(static_cast<unsigned>(a_Item.m_ItemDamage));
if (Map == nullptr)
{
diff --git a/src/Items/ItemMinecart.h b/src/Items/ItemMinecart.h
index e7d2cf8cd..2cf42507b 100644
--- a/src/Items/ItemMinecart.h
+++ b/src/Items/ItemMinecart.h
@@ -56,9 +56,9 @@ public:
}
}
- double x = (double)a_BlockX + 0.5;
- double y = (double)a_BlockY + 0.5;
- double z = (double)a_BlockZ + 0.5;
+ double x = static_cast<double>(a_BlockX) + 0.5;
+ double y = static_cast<double>(a_BlockY) + 0.5;
+ double z = static_cast<double>(a_BlockZ) + 0.5;
cMinecart * Minecart = nullptr;
switch (m_ItemType)
{
diff --git a/src/Items/ItemSlab.h b/src/Items/ItemSlab.h
index 3a78cc016..21b53081a 100644
--- a/src/Items/ItemSlab.h
+++ b/src/Items/ItemSlab.h
@@ -40,7 +40,7 @@ public:
) override
{
// Prepare sound effect
- AString PlaceSound = cBlockInfo::GetPlaceSound(m_ItemType);
+ AString PlaceSound = cBlockInfo::GetPlaceSound(static_cast<BLOCKTYPE>(m_ItemType));
float Volume = 1.0f, Pitch = 0.8f;
// Special slab handling - placing a slab onto another slab produces a dblslab instead:
diff --git a/src/Items/ItemSword.h b/src/Items/ItemSword.h
index 2b2dbfc0d..3b0db7b21 100644
--- a/src/Items/ItemSword.h
+++ b/src/Items/ItemSword.h
@@ -46,12 +46,15 @@ public:
virtual short GetDurabilityLossByAction(eDurabilityLostAction a_Action) override
{
- switch ((int)a_Action)
+ switch (a_Action)
{
case dlaAttackEntity: return 1;
case dlaBreakBlock: return 2;
}
+
+ #ifndef __clang__
return 0;
+ #endif
}
} ;
diff --git a/src/LightingThread.cpp b/src/LightingThread.cpp
index 7f13a94fd..a2f44c284 100644
--- a/src/LightingThread.cpp
+++ b/src/LightingThread.cpp
@@ -28,7 +28,7 @@ class cReader :
{
for (int z = 0; z < cChunkDef::Width; z++)
{
- a_ChunkBuffer.CopyBlockTypes(OutputRows + OutputIdx * 16, InputIdx * 16, 16);
+ a_ChunkBuffer.CopyBlockTypes(OutputRows + OutputIdx * 16, static_cast<size_t>(InputIdx * 16), 16);
InputIdx++;
OutputIdx += 3;
} // for z
@@ -386,14 +386,14 @@ void cLightingThread::PrepareSkyLight(void)
{
int CurrentIdx = idx + Current * BlocksPerYLayer;
m_IsSeed1[CurrentIdx] = true;
- m_SeedIdx1[m_NumSeeds++] = CurrentIdx;
+ m_SeedIdx1[m_NumSeeds++] = static_cast<UInt32>(CurrentIdx);
}
// Add seed from Current up to the highest neighbor:
for (int y = Current + 1, Index = idx + y * BlocksPerYLayer; y < MaxNeighbor; y++, Index += BlocksPerYLayer)
{
m_IsSeed1[Index] = true;
- m_SeedIdx1[m_NumSeeds++] = Index;
+ m_SeedIdx1[m_NumSeeds++] = static_cast<UInt32>(Index);
}
}
}
@@ -426,7 +426,7 @@ void cLightingThread::PrepareBlockLight(void)
// Add current block as a seed:
m_IsSeed1[Index] = true;
- m_SeedIdx1[m_NumSeeds++] = Index;
+ m_SeedIdx1[m_NumSeeds++] = static_cast<UInt32>(Index);
// Light it up:
m_BlockLight[Index] = cBlockInfo::GetLightValue(m_BlockTypes[Index]);
@@ -470,7 +470,7 @@ void cLightingThread::PrepareBlockLight2(void)
// Add current block as a seed:
m_IsSeed1[idx] = true;
- m_SeedIdx1[m_NumSeeds++] = idx;
+ m_SeedIdx1[m_NumSeeds++] = static_cast<UInt32>(idx);
// Light it up:
m_BlockLight[idx] = cBlockInfo::GetLightValue(m_BlockTypes[idx]);
@@ -485,7 +485,7 @@ void cLightingThread::PrepareBlockLight2(void)
void cLightingThread::CalcLight(NIBBLETYPE * a_Light)
{
- int NumSeeds2 = 0;
+ size_t NumSeeds2 = 0;
while (m_NumSeeds > 0)
{
// Buffer 1 -> buffer 2
@@ -510,15 +510,15 @@ void cLightingThread::CalcLight(NIBBLETYPE * a_Light)
void cLightingThread::CalcLightStep(
NIBBLETYPE * a_Light,
- int a_NumSeedsIn, unsigned char * a_IsSeedIn, unsigned int * a_SeedIdxIn,
- int & a_NumSeedsOut, unsigned char * a_IsSeedOut, unsigned int * a_SeedIdxOut
+ size_t a_NumSeedsIn, unsigned char * a_IsSeedIn, unsigned int * a_SeedIdxIn,
+ size_t & a_NumSeedsOut, unsigned char * a_IsSeedOut, unsigned int * a_SeedIdxOut
)
{
UNUSED(a_IsSeedIn);
- int NumSeedsOut = 0;
- for (int i = 0; i < a_NumSeedsIn; i++)
+ size_t NumSeedsOut = 0;
+ for (size_t i = 0; i < a_NumSeedsIn; i++)
{
- int SeedIdx = a_SeedIdxIn[i];
+ UInt32 SeedIdx = static_cast<UInt32>(a_SeedIdxIn[i]);
int SeedX = SeedIdx % (cChunkDef::Width * 3);
int SeedZ = (SeedIdx / (cChunkDef::Width * 3)) % (cChunkDef::Width * 3);
int SeedY = SeedIdx / BlocksPerYLayer;
@@ -566,7 +566,7 @@ void cLightingThread::CompressLight(NIBBLETYPE * a_LightArray, NIBBLETYPE * a_Ch
{
for (int x = 0; x < cChunkDef::Width; x += 2)
{
- a_ChunkLight[OutIdx++] = (a_LightArray[InIdx + 1] << 4) | a_LightArray[InIdx];
+ a_ChunkLight[OutIdx++] = static_cast<NIBBLETYPE>(a_LightArray[InIdx + 1] << 4) | a_LightArray[InIdx];
InIdx += 2;
}
InIdx += cChunkDef::Width * 2;
diff --git a/src/LightingThread.h b/src/LightingThread.h
index da6be12c8..b18ac7799 100644
--- a/src/LightingThread.h
+++ b/src/LightingThread.h
@@ -132,7 +132,7 @@ protected:
unsigned int m_SeedIdx1[BlocksPerYLayer * cChunkDef::Height];
unsigned char m_IsSeed2 [BlocksPerYLayer * cChunkDef::Height];
unsigned int m_SeedIdx2[BlocksPerYLayer * cChunkDef::Height];
- int m_NumSeeds;
+ size_t m_NumSeeds;
virtual void Execute(void) override;
@@ -158,8 +158,8 @@ protected:
/** Does one step in the light calculation - one seed propagation and seed recalculation */
void CalcLightStep(
NIBBLETYPE * a_Light,
- int a_NumSeedsIn, unsigned char * a_IsSeedIn, unsigned int * a_SeedIdxIn,
- int & a_NumSeedsOut, unsigned char * a_IsSeedOut, unsigned int * a_SeedIdxOut
+ size_t a_NumSeedsIn, unsigned char * a_IsSeedIn, unsigned int * a_SeedIdxIn,
+ size_t & a_NumSeedsOut, unsigned char * a_IsSeedOut, unsigned int * a_SeedIdxOut
);
/** Compresses from 1-block-per-byte (faster calc) into 2-blocks-per-byte (MC storage): */
@@ -168,7 +168,7 @@ protected:
inline void PropagateLight(
NIBBLETYPE * a_Light,
unsigned int a_SrcIdx, unsigned int a_DstIdx,
- int & a_NumSeedsOut, unsigned char * a_IsSeedOut, unsigned int * a_SeedIdxOut
+ size_t & a_NumSeedsOut, unsigned char * a_IsSeedOut, unsigned int * a_SeedIdxOut
)
{
ASSERT(a_SrcIdx < ARRAYCOUNT(m_SkyLight));
diff --git a/src/LinearInterpolation.cpp b/src/LinearInterpolation.cpp
index 9455f3e4f..c7c690bd2 100644
--- a/src/LinearInterpolation.cpp
+++ b/src/LinearInterpolation.cpp
@@ -65,14 +65,14 @@ void LinearInterpolate1DArray(
a_Dst[0] = a_Src[0];
int DstSizeXm1 = a_DstSizeX - 1;
int SrcSizeXm1 = a_SrcSizeX - 1;
- float fDstSizeXm1 = (float)DstSizeXm1;
- float fSrcSizeXm1 = (float)SrcSizeXm1;
+ float fDstSizeXm1 = static_cast<float>(DstSizeXm1);
+ float fSrcSizeXm1 = static_cast<float>(SrcSizeXm1);
for (int x = 1; x < DstSizeXm1; x++)
{
int SrcIdx = x * SrcSizeXm1 / DstSizeXm1;
float ValLo = a_Src[SrcIdx];
float ValHi = a_Src[SrcIdx + 1];
- float Ratio = (float)x * fSrcSizeXm1 / fDstSizeXm1 - SrcIdx;
+ float Ratio = static_cast<float>(x) * fSrcSizeXm1 / fDstSizeXm1 - SrcIdx;
a_Dst[x] = ValLo + (ValHi - ValLo) * Ratio;
}
a_Dst[a_DstSizeX - 1] = a_Src[a_SrcSizeX - 1];
@@ -103,12 +103,12 @@ void LinearInterpolate2DArray(
for (int x = 1; x < a_DstSizeX; x++)
{
SrcIdxX[x] = x * (a_SrcSizeX - 1) / (a_DstSizeX - 1);
- RatioX[x] = ((float)(x * (a_SrcSizeX - 1)) / (a_DstSizeX - 1)) - SrcIdxX[x];
+ RatioX[x] = (static_cast<float>(x * (a_SrcSizeX - 1)) / (a_DstSizeX - 1)) - SrcIdxX[x];
}
for (int y = 1; y < a_DstSizeY; y++)
{
SrcIdxY[y] = y * (a_SrcSizeY - 1) / (a_DstSizeY - 1);
- RatioY[y] = ((float)(y * (a_SrcSizeY - 1)) / (a_DstSizeY - 1)) - SrcIdxY[y];
+ RatioY[y] = (static_cast<float>(y * (a_SrcSizeY - 1)) / (a_DstSizeY - 1)) - SrcIdxY[y];
}
// Special values at the ends. Notice especially the last indices being (size - 2) with ratio set to 1, to avoid index overflow:
@@ -176,17 +176,17 @@ void LinearInterpolate3DArray(
for (int x = 1; x < a_DstSizeX; x++)
{
SrcIdxX[x] = x * (a_SrcSizeX - 1) / (a_DstSizeX - 1);
- RatioX[x] = ((float)(x * (a_SrcSizeX - 1)) / (a_DstSizeX - 1)) - SrcIdxX[x];
+ RatioX[x] = (static_cast<float>(x * (a_SrcSizeX - 1)) / (a_DstSizeX - 1)) - SrcIdxX[x];
}
for (int y = 1; y < a_DstSizeY; y++)
{
SrcIdxY[y] = y * (a_SrcSizeY - 1) / (a_DstSizeY - 1);
- RatioY[y] = ((float)(y * (a_SrcSizeY - 1)) / (a_DstSizeY - 1)) - SrcIdxY[y];
+ RatioY[y] = (static_cast<float>(y * (a_SrcSizeY - 1)) / (a_DstSizeY - 1)) - SrcIdxY[y];
}
for (int z = 1; z < a_DstSizeZ; z++)
{
SrcIdxZ[z] = z * (a_SrcSizeZ - 1) / (a_DstSizeZ - 1);
- RatioZ[z] = ((float)(z * (a_SrcSizeZ - 1)) / (a_DstSizeZ - 1)) - SrcIdxZ[z];
+ RatioZ[z] = (static_cast<float>(z * (a_SrcSizeZ - 1)) / (a_DstSizeZ - 1)) - SrcIdxZ[z];
}
// Special values at the ends. Notice especially the last indices being (size - 2) with ratio set to 1, to avoid index overflow:
diff --git a/src/Matrix4.h b/src/Matrix4.h
index 0558fa5f3..a5d6017d0 100644
--- a/src/Matrix4.h
+++ b/src/Matrix4.h
@@ -98,8 +98,8 @@ public:
inline void RotateZ(T a_RZ)
{
- T sz = (T) sin(a_RZ * M_PI / 180);
- T cz = (T) cos(a_RZ * M_PI / 180);
+ T sz = static_cast<T>(sin(a_RZ * M_PI / 180));
+ T cz = static_cast<T>(cos(a_RZ * M_PI / 180));
Identity();
diff --git a/src/MobProximityCounter.cpp b/src/MobProximityCounter.cpp
index 1bdac2f88..47d585954 100644
--- a/src/MobProximityCounter.cpp
+++ b/src/MobProximityCounter.cpp
@@ -63,7 +63,7 @@ cMobProximityCounter::sIterablePair cMobProximityCounter::getMobWithinThosesDist
{
if (toReturn.m_Begin == m_DistanceToMonster.end())
{
- if ((a_DistanceMin == 1) || (itr->first > a_DistanceMin))
+ if ((a_DistanceMin == 1.0) || (itr->first > a_DistanceMin))
{
toReturn.m_Begin = itr; // This is the first one with distance > a_DistanceMin;
}
@@ -71,7 +71,7 @@ cMobProximityCounter::sIterablePair cMobProximityCounter::getMobWithinThosesDist
if (toReturn.m_Begin != m_DistanceToMonster.end())
{
- if ((a_DistanceMax != 1) && (itr->first > a_DistanceMax))
+ if ((a_DistanceMax != 1.0) && (itr->first > a_DistanceMax))
{
toReturn.m_End = itr; // This is just after the last one with distance < a_DistanceMax
// Note : if we are not going through this, it's ok, toReturn.m_End will be end();
diff --git a/src/Mobs/CMakeLists.txt b/src/Mobs/CMakeLists.txt
index e99494508..5c374f9ee 100644
--- a/src/Mobs/CMakeLists.txt
+++ b/src/Mobs/CMakeLists.txt
@@ -81,9 +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 -Wno-error=old-style-cast")
- set_source_files_properties(SnowGolem.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=old-style-cast")
- set_source_files_properties(Villager.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=old-style-cast")
+ 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 ")
endif()
if(NOT MSVC)
diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp
index 4befe307d..d97999e0f 100644
--- a/src/Mobs/Monster.cpp
+++ b/src/Mobs/Monster.cpp
@@ -238,7 +238,7 @@ void cMonster::MoveToWayPoint(cChunk & a_Chunk)
if (DoesPosYRequireJump(FloorC(m_NextWayPointPosition.y)))
{
if (
- (IsOnGround() && (GetSpeedX() == 0) && (GetSpeedY() == 0)) ||
+ (IsOnGround() && (GetSpeedX() == 0.0f) && (GetSpeedY() == 0.0f)) ||
(IsSwimming() && (m_GiveUpCounter < 15))
)
{
@@ -257,7 +257,7 @@ void cMonster::MoveToWayPoint(cChunk & a_Chunk)
}
Vector3d Distance = m_NextWayPointPosition - GetPosition();
- if ((Distance.x != 0) || (Distance.z != 0))
+ if ((Distance.x != 0.0f) || (Distance.z != 0.0f))
{
Distance.y = 0;
Distance.Normalize();
@@ -581,9 +581,9 @@ int cMonster::FindFirstNonAirBlockPosition(double a_PosX, double a_PosZ)
int PosY = POSY_TOINT;
PosY = Clamp(PosY, 0, cChunkDef::Height);
- if (!cBlockInfo::IsSolid(m_World->GetBlock((int)floor(a_PosX), PosY, (int)floor(a_PosZ))))
+ if (!cBlockInfo::IsSolid(m_World->GetBlock(FloorC(a_PosX), PosY, FloorC(a_PosZ))))
{
- while (!cBlockInfo::IsSolid(m_World->GetBlock((int)floor(a_PosX), PosY, (int)floor(a_PosZ))) && (PosY > 0))
+ while (!cBlockInfo::IsSolid(m_World->GetBlock(FloorC(a_PosX), PosY, FloorC(a_PosZ))) && (PosY > 0))
{
PosY--;
}
@@ -592,7 +592,7 @@ int cMonster::FindFirstNonAirBlockPosition(double a_PosX, double a_PosZ)
}
else
{
- while ((PosY < cChunkDef::Height) && cBlockInfo::IsSolid(m_World->GetBlock((int)floor(a_PosX), PosY, (int)floor(a_PosZ))))
+ while ((PosY < cChunkDef::Height) && cBlockInfo::IsSolid(m_World->GetBlock(static_cast<int>(floor(a_PosX)), PosY, static_cast<int>(floor(a_PosZ)))))
{
PosY++;
}
@@ -732,7 +732,7 @@ void cMonster::OnRightClicked(cPlayer & a_Player)
void cMonster::CheckEventSeePlayer(void)
{
// TODO: Rewrite this to use cWorld's DoWithPlayers()
- cPlayer * Closest = m_World->FindClosestPlayer(GetPosition(), (float)m_SightDistance, false);
+ cPlayer * Closest = m_World->FindClosestPlayer(GetPosition(), static_cast<float>(m_SightDistance), false);
if (Closest != nullptr)
{
@@ -800,8 +800,8 @@ void cMonster::InStateIdle(std::chrono::milliseconds a_Dt)
m_IdleInterval -= std::chrono::seconds(1); // So nothing gets dropped when the server hangs for a few seconds
Vector3d Dist;
- Dist.x = (double)m_World->GetTickRandomNumber(10) - 5;
- Dist.z = (double)m_World->GetTickRandomNumber(10) - 5;
+ Dist.x = static_cast<double>(m_World->GetTickRandomNumber(10)) - 5.0;
+ Dist.z = static_cast<double>(m_World->GetTickRandomNumber(10)) - 5.0;
if ((Dist.SqrLength() > 2) && (rem >= 3))
{
@@ -1068,7 +1068,7 @@ cMonster * cMonster::NewMonsterFromType(eMonsterType a_MobType)
VillagerType = 0;
}
- toReturn = new cVillager((cVillager::eVillagerType)VillagerType);
+ toReturn = new cVillager(static_cast<cVillager::eVillagerType>(VillagerType));
break;
}
case mtHorse:
@@ -1130,10 +1130,10 @@ cMonster * cMonster::NewMonsterFromType(eMonsterType a_MobType)
void cMonster::AddRandomDropItem(cItems & a_Drops, unsigned int a_Min, unsigned int a_Max, short a_Item, short a_ItemHealth)
{
MTRand r1;
- int Count = r1.randInt() % (a_Max + 1 - a_Min) + a_Min;
+ int Count = static_cast<int>(static_cast<unsigned int>(r1.randInt()) % (a_Max + 1 - a_Min) + a_Min);
if (Count > 0)
{
- a_Drops.push_back(cItem(a_Item, Count, a_ItemHealth));
+ a_Drops.push_back(cItem(a_Item, static_cast<char>(Count), a_ItemHealth));
}
}
@@ -1158,10 +1158,10 @@ void cMonster::AddRandomUncommonDropItem(cItems & a_Drops, float a_Chance, short
void cMonster::AddRandomRareDropItem(cItems & a_Drops, cItems & a_Items, unsigned int a_LootingLevel)
{
MTRand r1;
- unsigned int Count = r1.randInt() % 200;
+ unsigned int Count = static_cast<unsigned int>(static_cast<unsigned long>(r1.randInt()) % 200);
if (Count < (5 + a_LootingLevel))
{
- int Rare = r1.randInt() % a_Items.Size();
+ size_t Rare = static_cast<size_t>(r1.randInt()) % a_Items.Size();
a_Drops.push_back(a_Items.at(Rare));
}
}
diff --git a/src/Mobs/SnowGolem.cpp b/src/Mobs/SnowGolem.cpp
index e1510b203..6afe3fda0 100644
--- a/src/Mobs/SnowGolem.cpp
+++ b/src/Mobs/SnowGolem.cpp
@@ -30,17 +30,17 @@ void cSnowGolem::GetDrops(cItems & a_Drops, cEntity * a_Killer)
void cSnowGolem::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
super::Tick(a_Dt, a_Chunk);
- if (IsBiomeNoDownfall(m_World->GetBiomeAt((int) floor(GetPosX()), (int) floor(GetPosZ()))))
+ if (IsBiomeNoDownfall(m_World->GetBiomeAt(POSX_TOINT, POSZ_TOINT)))
{
TakeDamage(*this);
}
else
{
- BLOCKTYPE BlockBelow = m_World->GetBlock((int) floor(GetPosX()), (int) floor(GetPosY()) - 1, (int) floor(GetPosZ()));
- BLOCKTYPE Block = m_World->GetBlock((int) floor(GetPosX()), (int) floor(GetPosY()), (int) floor(GetPosZ()));
+ BLOCKTYPE BlockBelow = m_World->GetBlock(POSX_TOINT, POSY_TOINT - 1, POSZ_TOINT);
+ BLOCKTYPE Block = m_World->GetBlock(POSX_TOINT, POSY_TOINT, POSZ_TOINT);
if ((Block == E_BLOCK_AIR) && cBlockInfo::IsSolid(BlockBelow))
{
- m_World->SetBlock((int) floor(GetPosX()), (int) floor(GetPosY()), (int) floor(GetPosZ()), E_BLOCK_SNOW, 0);
+ m_World->SetBlock(POSX_TOINT, POSY_TOINT, POSZ_TOINT, E_BLOCK_SNOW, 0);
}
}
}
diff --git a/src/Mobs/Villager.cpp b/src/Mobs/Villager.cpp
index 9239575d0..7a1a6e448 100644
--- a/src/Mobs/Villager.cpp
+++ b/src/Mobs/Villager.cpp
@@ -115,12 +115,12 @@ void cVillager::HandleFarmerPrepareFarmCrops()
/// Read a 11x7x11 area.
Surrounding.Read(
m_World,
- (int) GetPosX() - 5,
- (int) GetPosX() + 6,
- (int) GetPosY() - 3,
- (int) GetPosY() + 4,
- (int) GetPosZ() - 5,
- (int) GetPosZ() + 6
+ static_cast<int>(GetPosX()) - 5,
+ static_cast<int>(GetPosX()) + 6,
+ static_cast<int>(GetPosY()) - 3,
+ static_cast<int>(GetPosY()) + 4,
+ static_cast<int>(GetPosZ()) - 5,
+ static_cast<int>(GetPosZ()) + 6
);
for (int I = 0; I < 5; I++)
@@ -142,8 +142,8 @@ void cVillager::HandleFarmerPrepareFarmCrops()
}
m_VillagerAction = true;
- m_CropsPos = Vector3i((int) GetPosX() + X - 5, (int) GetPosY() + Y - 3, (int) GetPosZ() + Z - 5);
- MoveToPosition(Vector3f((float) (m_CropsPos.x + 0.5), (float) m_CropsPos.y, (float) (m_CropsPos.z + 0.5)));
+ m_CropsPos = Vector3i(static_cast<int>(GetPosX()) + X - 5, static_cast<int>(GetPosY()) + Y - 3, static_cast<int>(GetPosZ()) + Z - 5);
+ MoveToPosition(Vector3f(static_cast<float>(m_CropsPos.x + 0.5), static_cast<float>(m_CropsPos.y), static_cast<float>(m_CropsPos.z + 0.5)));
return;
} // for Y loop.
} // Repeat the procces 5 times.
diff --git a/src/Noise/CMakeLists.txt b/src/Noise/CMakeLists.txt
index ab4cf031b..39f3bc975 100644
--- a/src/Noise/CMakeLists.txt
+++ b/src/Noise/CMakeLists.txt
@@ -14,12 +14,7 @@ SET (HDRS
RidgedNoise.h
)
-if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
- set_source_files_properties(Noise.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=old-style-cast")
-endif()
-
if(NOT MSVC)
add_library(Noise ${SRCS} ${HDRS})
-
target_link_libraries(Noise OSSupport)
endif()
diff --git a/src/Noise/InterpolNoise.h b/src/Noise/InterpolNoise.h
index 683b54563..afc7cff49 100644
--- a/src/Noise/InterpolNoise.h
+++ b/src/Noise/InterpolNoise.h
@@ -11,7 +11,7 @@
#include "Noise.h"
-#define FAST_FLOOR(x) (((x) < 0) ? (((int)x) - 1) : ((int)x))
+#define FAST_FLOOR(x) (((x) < 0) ? ((static_cast<int>(x)) - 1) : (static_cast<int>(x)))
@@ -104,7 +104,7 @@ public:
}
else
{
- (*m_WorkRnds)[x][y] = (NOISE_DATATYPE)m_Noise.IntNoise2D(cx, cy);
+ (*m_WorkRnds)[x][y] = static_cast<NOISE_DATATYPE>(m_Noise.IntNoise2D(cx, cy));
}
}
}
@@ -221,14 +221,14 @@ public:
m_CurFloorX = a_FloorX;
m_CurFloorY = a_FloorY;
m_CurFloorZ = a_FloorZ;
- (*m_WorkRnds)[0][0][0] = (NOISE_DATATYPE)m_Noise.IntNoise3D(m_CurFloorX, m_CurFloorY, m_CurFloorZ);
- (*m_WorkRnds)[0][0][1] = (NOISE_DATATYPE)m_Noise.IntNoise3D(m_CurFloorX, m_CurFloorY, m_CurFloorZ + 1);
- (*m_WorkRnds)[0][1][0] = (NOISE_DATATYPE)m_Noise.IntNoise3D(m_CurFloorX, m_CurFloorY + 1, m_CurFloorZ);
- (*m_WorkRnds)[0][1][1] = (NOISE_DATATYPE)m_Noise.IntNoise3D(m_CurFloorX, m_CurFloorY + 1, m_CurFloorZ + 1);
- (*m_WorkRnds)[1][0][0] = (NOISE_DATATYPE)m_Noise.IntNoise3D(m_CurFloorX + 1, m_CurFloorY, m_CurFloorZ);
- (*m_WorkRnds)[1][0][1] = (NOISE_DATATYPE)m_Noise.IntNoise3D(m_CurFloorX + 1, m_CurFloorY, m_CurFloorZ + 1);
- (*m_WorkRnds)[1][1][0] = (NOISE_DATATYPE)m_Noise.IntNoise3D(m_CurFloorX + 1, m_CurFloorY + 1, m_CurFloorZ);
- (*m_WorkRnds)[1][1][1] = (NOISE_DATATYPE)m_Noise.IntNoise3D(m_CurFloorX + 1, m_CurFloorY + 1, m_CurFloorZ + 1);
+ (*m_WorkRnds)[0][0][0] = static_cast<NOISE_DATATYPE>(m_Noise.IntNoise3D(m_CurFloorX, m_CurFloorY, m_CurFloorZ));
+ (*m_WorkRnds)[0][0][1] = static_cast<NOISE_DATATYPE>(m_Noise.IntNoise3D(m_CurFloorX, m_CurFloorY, m_CurFloorZ + 1));
+ (*m_WorkRnds)[0][1][0] = static_cast<NOISE_DATATYPE>(m_Noise.IntNoise3D(m_CurFloorX, m_CurFloorY + 1, m_CurFloorZ));
+ (*m_WorkRnds)[0][1][1] = static_cast<NOISE_DATATYPE>(m_Noise.IntNoise3D(m_CurFloorX, m_CurFloorY + 1, m_CurFloorZ + 1));
+ (*m_WorkRnds)[1][0][0] = static_cast<NOISE_DATATYPE>(m_Noise.IntNoise3D(m_CurFloorX + 1, m_CurFloorY, m_CurFloorZ));
+ (*m_WorkRnds)[1][0][1] = static_cast<NOISE_DATATYPE>(m_Noise.IntNoise3D(m_CurFloorX + 1, m_CurFloorY, m_CurFloorZ + 1));
+ (*m_WorkRnds)[1][1][0] = static_cast<NOISE_DATATYPE>(m_Noise.IntNoise3D(m_CurFloorX + 1, m_CurFloorY + 1, m_CurFloorZ));
+ (*m_WorkRnds)[1][1][1] = static_cast<NOISE_DATATYPE>(m_Noise.IntNoise3D(m_CurFloorX + 1, m_CurFloorY + 1, m_CurFloorZ + 1));
}
@@ -265,7 +265,7 @@ public:
}
else
{
- (*m_WorkRnds)[x][y][z] = (NOISE_DATATYPE)m_Noise.IntNoise3D(cx, cy, cz);
+ (*m_WorkRnds)[x][y][z] = static_cast<NOISE_DATATYPE>(m_Noise.IntNoise3D(cx, cy, cz));
}
} // for z
} // for y
diff --git a/src/Noise/Noise.cpp b/src/Noise/Noise.cpp
index 703ec3d30..d8cde6e3d 100644
--- a/src/Noise/Noise.cpp
+++ b/src/Noise/Noise.cpp
@@ -3,7 +3,7 @@
#include "Noise.h"
-#define FAST_FLOOR(x) (((x) < 0) ? (((int)x) - 1) : ((int)x))
+#define FAST_FLOOR(x) (((x) < 0) ? ((static_cast<int>(x)) - 1) : (static_cast<int>(x)))
@@ -129,7 +129,7 @@ void Debug3DNoise(const NOISE_DATATYPE * a_Noise, size_t a_SizeX, size_t a_SizeY
unsigned char buf[BUF_SIZE];
for (size_t x = 0; x < a_SizeX; x++)
{
- buf[x] = static_cast<unsigned char>(Clamp((int)(128 + a_Coeff * a_Noise[idx++]), 0, 255));
+ buf[x] = static_cast<unsigned char>(Clamp(static_cast<int>(128 + a_Coeff * a_Noise[idx++]), 0, 255));
}
f1.Write(buf, a_SizeX);
} // for y
@@ -150,7 +150,7 @@ void Debug3DNoise(const NOISE_DATATYPE * a_Noise, size_t a_SizeX, size_t a_SizeY
unsigned char buf[BUF_SIZE];
for (size_t x = 0; x < a_SizeX; x++)
{
- buf[x] = static_cast<unsigned char>(Clamp((int)(128 + a_Coeff * a_Noise[idx++]), 0, 255));
+ buf[x] = static_cast<unsigned char>(Clamp(static_cast<int>(128 + a_Coeff * a_Noise[idx++]), 0, 255));
}
f2.Write(buf, a_SizeX);
} // for z
@@ -179,7 +179,7 @@ void Debug2DNoise(const NOISE_DATATYPE * a_Noise, size_t a_SizeX, size_t a_SizeY
unsigned char buf[BUF_SIZE];
for (size_t x = 0; x < a_SizeX; x++)
{
- buf[x] = static_cast<unsigned char>(Clamp((int)(128 + a_Coeff * a_Noise[idx++]), 0, 255));
+ buf[x] = static_cast<unsigned char>(Clamp(static_cast<int>(128 + a_Coeff * a_Noise[idx++]), 0, 255));
}
f1.Write(buf, a_SizeX);
} // for y
@@ -295,7 +295,7 @@ void cCubicCell2D::InitWorkRnds(int a_FloorX, int a_FloorY)
for (int y = 0; y < 4; y++)
{
int cy = a_FloorY + y - 1;
- (*m_WorkRnds)[x][y] = (NOISE_DATATYPE)m_Noise.IntNoise2D(cx, cy);
+ (*m_WorkRnds)[x][y] = static_cast<NOISE_DATATYPE>(m_Noise.IntNoise2D(cx, cy));
}
}
}
@@ -329,7 +329,7 @@ void cCubicCell2D::Move(int a_NewFloorX, int a_NewFloorY)
}
else
{
- (*m_WorkRnds)[x][y] = (NOISE_DATATYPE)m_Noise.IntNoise2D(cx, cy);
+ (*m_WorkRnds)[x][y] = static_cast<NOISE_DATATYPE>(m_Noise.IntNoise2D(cx, cy));
}
}
}
@@ -472,7 +472,7 @@ void cCubicCell3D::InitWorkRnds(int a_FloorX, int a_FloorY, int a_FloorZ)
for (int z = 0; z < 4; z++)
{
int cz = a_FloorZ + z - 1;
- (*m_WorkRnds)[x][y][z] = (NOISE_DATATYPE)m_Noise.IntNoise3D(cx, cy, cz);
+ (*m_WorkRnds)[x][y][z] = static_cast<NOISE_DATATYPE>(m_Noise.IntNoise3D(cx, cy, cz));
}
}
}
@@ -513,7 +513,7 @@ void cCubicCell3D::Move(int a_NewFloorX, int a_NewFloorY, int a_NewFloorZ)
}
else
{
- (*m_WorkRnds)[x][y][z] = (NOISE_DATATYPE)m_Noise.IntNoise3D(cx, cy, cz);
+ (*m_WorkRnds)[x][y][z] = static_cast<NOISE_DATATYPE>(m_Noise.IntNoise3D(cx, cy, cz));
}
} // for z
} // for y
diff --git a/src/OSSupport/CMakeLists.txt b/src/OSSupport/CMakeLists.txt
index df47394ae..ce1d5c530 100644
--- a/src/OSSupport/CMakeLists.txt
+++ b/src/OSSupport/CMakeLists.txt
@@ -40,7 +40,7 @@ SET (HDRS
)
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
- add_flags_cxx("-Wno-error=global-constructors -Wno-error=old-style-cast")
+ add_flags_cxx("-Wno-error=global-constructors ")
endif()
if(NOT MSVC)
diff --git a/src/OSSupport/File.cpp b/src/OSSupport/File.cpp
index 6327b3505..03cddc408 100644
--- a/src/OSSupport/File.cpp
+++ b/src/OSSupport/File.cpp
@@ -156,7 +156,7 @@ int cFile::Read (void * iBuffer, size_t iNumBytes)
return -1;
}
- return (int)fread(iBuffer, 1, (size_t)iNumBytes, m_File); // fread() returns the portion of Count parameter actually read, so we need to send iNumBytes as Count
+ return static_cast<int>(fread(iBuffer, 1, static_cast<size_t>(iNumBytes), m_File)); // fread() returns the portion of Count parameter actually read, so we need to send iNumBytes as Count
}
@@ -172,7 +172,7 @@ int cFile::Write(const void * iBuffer, size_t iNumBytes)
return -1;
}
- int res = (int)fwrite(iBuffer, 1, (size_t)iNumBytes, m_File); // fwrite() returns the portion of Count parameter actually written, so we need to send iNumBytes as Count
+ int res = static_cast<int>(fwrite(iBuffer, 1, static_cast<size_t>(iNumBytes), m_File)); // fwrite() returns the portion of Count parameter actually written, so we need to send iNumBytes as Count
return res;
}
@@ -236,7 +236,7 @@ long cFile::GetSize(void) const
return -1;
}
long res = Tell();
- if (fseek(m_File, (long)CurPos, SEEK_SET) != 0)
+ if (fseek(m_File, static_cast<long>(CurPos), SEEK_SET) != 0)
{
return -1;
}
@@ -272,7 +272,7 @@ int cFile::ReadRestOfFile(AString & a_Contents)
// HACK: This depends on the internal knowledge that AString's data() function returns the internal buffer directly
a_Contents.assign(DataSize, '\0');
- return Read((void *)a_Contents.data(), DataSize);
+ return Read(reinterpret_cast<void *>(const_cast<char *>(a_Contents.data())), DataSize);
}
@@ -366,7 +366,7 @@ long cFile::GetSize(const AString & a_FileName)
struct stat st;
if (stat(a_FileName.c_str(), &st) == 0)
{
- return (int)st.st_size;
+ return static_cast<int>(st.st_size);
}
return -1;
}
diff --git a/src/OSSupport/GZipFile.cpp b/src/OSSupport/GZipFile.cpp
index 32d84a0d5..2ddc260e5 100644
--- a/src/OSSupport/GZipFile.cpp
+++ b/src/OSSupport/GZipFile.cpp
@@ -78,7 +78,7 @@ int cGZipFile::ReadRestOfFile(AString & a_Contents)
while ((NumBytesRead = gzread(m_File, Buffer, sizeof(Buffer))) > 0)
{
TotalBytes += NumBytesRead;
- a_Contents.append(Buffer, (size_t)NumBytesRead);
+ a_Contents.append(Buffer, static_cast<size_t>(NumBytesRead));
}
// NumBytesRead is < 0 on error
return (NumBytesRead >= 0) ? TotalBytes : NumBytesRead;
@@ -102,7 +102,7 @@ bool cGZipFile::Write(const char * a_Contents, int a_Size)
return false;
}
- return (gzwrite(m_File, a_Contents, (unsigned int)a_Size) != 0);
+ return (gzwrite(m_File, a_Contents, static_cast<unsigned int>(a_Size)) != 0);
}
diff --git a/src/Protocol/CMakeLists.txt b/src/Protocol/CMakeLists.txt
index 42a7d5a9d..58a69efbf 100644
--- a/src/Protocol/CMakeLists.txt
+++ b/src/Protocol/CMakeLists.txt
@@ -26,12 +26,8 @@ SET (HDRS
)
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
- set_source_files_properties(ChunkDataSerializer.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=old-style-cast")
- set_source_files_properties(MojangAPI.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=old-style-cast")
- set_source_files_properties(Packetizer.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=old-style-cast")
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(Protocol17x.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=switch-enum -Wno-error=old-style-cast")
- set_source_files_properties(ProtocolRecognizer.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=old-style-cast")
+ set_source_files_properties(Protocol17x.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=switch-enum ")
endif()
if (NOT MSVC)
diff --git a/src/Protocol/ChunkDataSerializer.cpp b/src/Protocol/ChunkDataSerializer.cpp
index 37fbae0e5..8c5569cc7 100644
--- a/src/Protocol/ChunkDataSerializer.cpp
+++ b/src/Protocol/ChunkDataSerializer.cpp
@@ -95,7 +95,7 @@ void cChunkDataSerializer::Serialize39(AString & a_Data)
// Run-time check that our compile-time guess about CompressedMaxSize was enough:
ASSERT(CompressedSize <= CompressedMaxSize);
- compress2((Bytef*)CompressedBlockData, &CompressedSize, (const Bytef*)AllData, sizeof(AllData), Z_DEFAULT_COMPRESSION);
+ compress2(reinterpret_cast<Bytef*>(CompressedBlockData), &CompressedSize, reinterpret_cast<const Bytef*>(AllData), sizeof(AllData), Z_DEFAULT_COMPRESSION);
// Now put all those data into a_Data:
@@ -106,11 +106,11 @@ void cChunkDataSerializer::Serialize39(AString & a_Data)
// Also, no endian flipping is needed because of the const values
unsigned short BitMap1 = 0xffff;
unsigned short BitMap2 = 0;
- a_Data.append((const char *)&BitMap1, sizeof(short));
- a_Data.append((const char *)&BitMap2, sizeof(short));
+ a_Data.append(reinterpret_cast<const char *>(&BitMap1), sizeof(short));
+ a_Data.append(reinterpret_cast<const char *>(&BitMap2), sizeof(short));
- UInt32 CompressedSizeBE = htonl((UInt32)CompressedSize);
- a_Data.append((const char *)&CompressedSizeBE, sizeof(CompressedSizeBE));
+ UInt32 CompressedSizeBE = htonl(static_cast<UInt32>(CompressedSize));
+ a_Data.append(reinterpret_cast<const char *>(&CompressedSizeBE), sizeof(CompressedSizeBE));
// Unlike 29, 39 doesn't have the "unused" int
diff --git a/src/Protocol/MojangAPI.cpp b/src/Protocol/MojangAPI.cpp
index 110590359..f3f9baf25 100644
--- a/src/Protocol/MojangAPI.cpp
+++ b/src/Protocol/MojangAPI.cpp
@@ -456,7 +456,7 @@ bool cMojangAPI::SecureRequest(const AString & a_ServerName, const AString & a_R
break;
}
- a_Response.append((const char *)buf, (size_t)ret);
+ a_Response.append(reinterpret_cast<const char *>(buf), static_cast<size_t>(ret));
}
return true;
@@ -919,7 +919,7 @@ void cMojangAPI::Update(void)
}
if (!PlayerNames.empty())
{
- LOG("cMojangAPI: Updating name-to-uuid cache for %u names", (unsigned)PlayerNames.size());
+ LOG("cMojangAPI: Updating name-to-uuid cache for %u names", static_cast<unsigned>(PlayerNames.size()));
QueryNamesToUUIDs(PlayerNames);
}
@@ -937,7 +937,7 @@ void cMojangAPI::Update(void)
}
if (!ProfileUUIDs.empty())
{
- LOG("cMojangAPI: Updating uuid-to-profile cache for %u uuids", (unsigned)ProfileUUIDs.size());
+ LOG("cMojangAPI: Updating uuid-to-profile cache for %u uuids", static_cast<unsigned>(ProfileUUIDs.size()));
for (AStringVector::const_iterator itr = ProfileUUIDs.begin(), end = ProfileUUIDs.end(); itr != end; ++itr)
{
QueryUUIDToProfile(*itr);
diff --git a/src/Protocol/Protocol.h b/src/Protocol/Protocol.h
index 9e80f7bd5..43c92989a 100644
--- a/src/Protocol/Protocol.h
+++ b/src/Protocol/Protocol.h
@@ -96,7 +96,7 @@ public:
virtual void SendHealth (void) = 0;
virtual void SendHideTitle (void) = 0;
virtual void SendInventorySlot (char a_WindowID, short a_SlotNum, const cItem & a_Item) = 0;
- virtual void SendKeepAlive (int a_PingID) = 0;
+ virtual void SendKeepAlive (UInt32 a_PingID) = 0;
virtual void SendLogin (const cPlayer & a_Player, const cWorld & a_World) = 0;
virtual void SendLoginSuccess (void) = 0;
virtual void SendMapData (const cMap & a_Map, int a_DataStartX, int a_DataStartY) = 0;
diff --git a/src/Protocol/Protocol17x.cpp b/src/Protocol/Protocol17x.cpp
index 098c62a90..003530c67 100644
--- a/src/Protocol/Protocol17x.cpp
+++ b/src/Protocol/Protocol17x.cpp
@@ -127,7 +127,7 @@ cProtocol172::cProtocol172(cClientHandle * a_Client, const AString & a_ServerAdd
{
static int sCounter = 0;
cFile::CreateFolder("CommLogs");
- AString FileName = Printf("CommLogs/%x_%d__%s.log", (unsigned)time(nullptr), sCounter++, a_Client->GetIPString().c_str());
+ AString FileName = Printf("CommLogs/%x_%d__%s.log", static_cast<unsigned>(time(nullptr)), sCounter++, a_Client->GetIPString().c_str());
m_CommLogFile.Open(FileName, cFile::fmWrite);
}
}
@@ -144,8 +144,8 @@ void cProtocol172::DataReceived(const char * a_Data, size_t a_Size)
while (a_Size > 0)
{
size_t NumBytes = (a_Size > sizeof(Decrypted)) ? sizeof(Decrypted) : a_Size;
- m_Decryptor.ProcessData(Decrypted, (Byte *)a_Data, NumBytes);
- AddReceivedData((const char *)Decrypted, NumBytes);
+ m_Decryptor.ProcessData(Decrypted, reinterpret_cast<const Byte *>(a_Data), NumBytes);
+ AddReceivedData(reinterpret_cast<const char *>(Decrypted), NumBytes);
a_Size -= NumBytes;
a_Data += NumBytes;
}
@@ -642,7 +642,7 @@ void cProtocol172::SendInventorySlot(char a_WindowID, short a_SlotNum, const cIt
-void cProtocol172::SendKeepAlive(int a_PingID)
+void cProtocol172::SendKeepAlive(UInt32 a_PingID)
{
// Drop the packet if the protocol is not in the Game state yet (caused a client crash):
if (m_State != 3)
@@ -652,7 +652,7 @@ void cProtocol172::SendKeepAlive(int a_PingID)
}
cPacketizer Pkt(*this, 0x00); // Keep Alive packet
- Pkt.WriteBEInt32(a_PingID);
+ Pkt.WriteBEInt32(static_cast<Int32>(a_PingID));
}
@@ -1078,9 +1078,9 @@ void cProtocol172::SendRespawn(eDimension a_Dimension, bool a_ShouldIgnoreDimens
cPacketizer Pkt(*this, 0x07); // Respawn packet
cPlayer * Player = m_Client->GetPlayer();
- Pkt.WriteBEInt32((int)a_Dimension);
+ Pkt.WriteBEInt32(static_cast<int>(a_Dimension));
Pkt.WriteBEUInt8(2); // TODO: Difficulty (set to Normal)
- Pkt.WriteBEUInt8((Byte)Player->GetEffectiveGameMode());
+ Pkt.WriteBEUInt8(static_cast<Byte>(Player->GetEffectiveGameMode()));
Pkt.WriteString("default");
m_LastSentDimension = a_Dimension;
}
@@ -1146,7 +1146,7 @@ void cProtocol172::SendScoreUpdate(const AString & a_Objective, const AString &
if (a_Mode != 1)
{
Pkt.WriteString(a_Objective);
- Pkt.WriteBEInt32((int) a_Score);
+ Pkt.WriteBEInt32(static_cast<int>(a_Score));
}
}
@@ -1266,7 +1266,7 @@ void cProtocol172::SendSpawnMob(const cMonster & a_Mob)
cPacketizer Pkt(*this, 0x0f); // Spawn Mob packet
Pkt.WriteVarInt32(a_Mob.GetUniqueID());
- Pkt.WriteBEUInt8((Byte)a_Mob.GetMobType());
+ Pkt.WriteBEUInt8(static_cast<Byte>(a_Mob.GetMobType()));
Pkt.WriteFPInt(a_Mob.GetPosX());
Pkt.WriteFPInt(a_Mob.GetPosY());
Pkt.WriteFPInt(a_Mob.GetPosZ());
@@ -1341,10 +1341,11 @@ void cProtocol172::SendStatistics(const cStatManager & a_Manager)
cPacketizer Pkt(*this, 0x37);
Pkt.WriteVarInt32(statCount); // TODO 2014-05-11 xdot: Optimization: Send "dirty" statistics only
- for (size_t i = 0; i < (size_t)statCount; ++i)
+ size_t Count = static_cast<size_t>(statCount);
+ for (size_t i = 0; i < Count; ++i)
{
- StatValue Value = a_Manager.GetValue((eStatistic) i);
- const AString & StatName = cStatInfo::GetName((eStatistic) i);
+ StatValue Value = a_Manager.GetValue(static_cast<eStatistic>(i));
+ const AString & StatName = cStatInfo::GetName(static_cast<eStatistic>(i));
Pkt.WriteString(StatName);
Pkt.WriteVarInt32(static_cast<UInt32>(Value));
@@ -1621,8 +1622,8 @@ void cProtocol172::AddReceivedData(const char * a_Data, size_t a_Size)
}
AString Hex;
CreateHexDump(Hex, a_Data, a_Size, 16);
- m_CommLogFile.Printf("Incoming data: %d (0x%x) bytes: \n%s\n",
- (unsigned)a_Size, (unsigned)a_Size, Hex.c_str()
+ m_CommLogFile.Printf("Incoming data: %u (0x%x) bytes: \n%s\n",
+ static_cast<unsigned>(a_Size), static_cast<unsigned>(a_Size), Hex.c_str()
);
m_CommLogFile.Flush();
}
@@ -2495,8 +2496,8 @@ void cProtocol172::SendData(const char * a_Data, size_t a_Size)
while (a_Size > 0)
{
size_t NumBytes = (a_Size > sizeof(Encrypted)) ? sizeof(Encrypted) : a_Size;
- m_Encryptor.ProcessData(Encrypted, (Byte *)a_Data, NumBytes);
- m_Client->SendData((const char *)Encrypted, NumBytes);
+ m_Encryptor.ProcessData(Encrypted, reinterpret_cast<const Byte *>(a_Data), NumBytes);
+ m_Client->SendData(reinterpret_cast<const char *>(Encrypted), NumBytes);
a_Size -= NumBytes;
a_Data += NumBytes;
}
@@ -2645,7 +2646,7 @@ void cProtocol172::ParseItemMetadata(cItem & a_Item, const AString & a_Metadata)
}
else if ((TagName == "Fireworks") || (TagName == "Explosion"))
{
- cFireworkItem::ParseFromNBT(a_Item.m_FireworkItem, NBT, tag, (ENUM_ITEM_ID)a_Item.m_ItemType);
+ cFireworkItem::ParseFromNBT(a_Item.m_FireworkItem, NBT, tag, static_cast<ENUM_ITEM_ID>(a_Item.m_ItemType));
}
break;
}
@@ -2675,9 +2676,9 @@ void cProtocol172::StartEncryption(const Byte * a_Key)
cSha1Checksum Checksum;
cServer * Server = cRoot::Get()->GetServer();
const AString & ServerID = Server->GetServerID();
- Checksum.Update((const Byte *)ServerID.c_str(), ServerID.length());
+ Checksum.Update(reinterpret_cast<const Byte *>(ServerID.c_str()), ServerID.length());
Checksum.Update(a_Key, 16);
- Checksum.Update((const Byte *)Server->GetPublicKeyDER().data(), Server->GetPublicKeyDER().size());
+ Checksum.Update(reinterpret_cast<const Byte *>(Server->GetPublicKeyDER().data()), Server->GetPublicKeyDER().size());
Byte Digest[20];
Checksum.Finalize(Digest);
cSha1Checksum::DigestToJava(Digest, m_AuthServerID);
@@ -2778,7 +2779,7 @@ void cProtocol172::WriteItem(cPacketizer & a_Pkt, const cItem & a_Item)
}
if ((a_Item.m_ItemType == E_ITEM_FIREWORK_ROCKET) || (a_Item.m_ItemType == E_ITEM_FIREWORK_STAR))
{
- cFireworkItem::WriteToNBTCompound(a_Item.m_FireworkItem, Writer, (ENUM_ITEM_ID)a_Item.m_ItemType);
+ cFireworkItem::WriteToNBTCompound(a_Item.m_FireworkItem, Writer, static_cast<ENUM_ITEM_ID>(a_Item.m_ItemType));
}
Writer.Finish();
@@ -2851,8 +2852,8 @@ void cProtocol172::WriteBlockEntity(cPacketizer & a_Pkt, const cBlockEntity & a_
Writer.AddInt("x", FlowerPotEntity.GetPosX());
Writer.AddInt("y", FlowerPotEntity.GetPosY());
Writer.AddInt("z", FlowerPotEntity.GetPosZ());
- Writer.AddInt("Item", (Int32) FlowerPotEntity.GetItem().m_ItemType);
- Writer.AddInt("Data", (Int32) FlowerPotEntity.GetItem().m_ItemDamage);
+ Writer.AddInt("Item", static_cast<Int32>(FlowerPotEntity.GetItem().m_ItemType));
+ Writer.AddInt("Data", static_cast<Int32>(FlowerPotEntity.GetItem().m_ItemDamage));
Writer.AddString("id", "FlowerPot"); // "Tile Entity ID" - MC wiki; vanilla server always seems to send this though
break;
}
@@ -3027,7 +3028,7 @@ void cProtocol172::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mob)
}
a_Pkt.WriteBEUInt8(0x66);
- a_Pkt.WriteBEFloat(a_Mob.GetHealth());
+ a_Pkt.WriteBEFloat(static_cast<float>(a_Mob.GetHealth()));
switch (a_Mob.GetMobType())
{
@@ -3051,9 +3052,9 @@ void cProtocol172::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mob)
{
auto & Enderman = reinterpret_cast<const cEnderman &>(a_Mob);
a_Pkt.WriteBEUInt8(0x10);
- a_Pkt.WriteBEUInt8((Byte)(Enderman.GetCarriedBlock()));
+ a_Pkt.WriteBEUInt8(static_cast<UInt8>(Enderman.GetCarriedBlock()));
a_Pkt.WriteBEUInt8(0x11);
- a_Pkt.WriteBEUInt8((Byte)(Enderman.GetCarriedMeta()));
+ a_Pkt.WriteBEUInt8(static_cast<UInt8>(Enderman.GetCarriedMeta()));
a_Pkt.WriteBEUInt8(0x12);
a_Pkt.WriteBEUInt8(Enderman.IsScreaming() ? 1 : 0);
break;
@@ -3280,9 +3281,9 @@ void cProtocol176::SendPlayerSpawn(const cPlayer & a_Player)
for (Json::Value::iterator itr = Properties.begin(), end = Properties.end(); itr != end; ++itr)
{
- Pkt.WriteString(((Json::Value)*itr).get("name", "").asString());
- Pkt.WriteString(((Json::Value)*itr).get("value", "").asString());
- Pkt.WriteString(((Json::Value)*itr).get("signature", "").asString());
+ Pkt.WriteString(itr->get("name", "").asString());
+ Pkt.WriteString(itr->get("value", "").asString());
+ Pkt.WriteString(itr->get("signature", "").asString());
}
Pkt.WriteFPInt(a_Player.GetPosX());
diff --git a/src/Protocol/Protocol17x.h b/src/Protocol/Protocol17x.h
index c5625dd62..9d2d108dc 100644
--- a/src/Protocol/Protocol17x.h
+++ b/src/Protocol/Protocol17x.h
@@ -98,7 +98,7 @@ public:
virtual void SendHealth (void) override;
virtual void SendHideTitle (void) override;
virtual void SendInventorySlot (char a_WindowID, short a_SlotNum, const cItem & a_Item) override;
- virtual void SendKeepAlive (int a_PingID) override;
+ virtual void SendKeepAlive (UInt32 a_PingID) override;
virtual void SendLogin (const cPlayer & a_Player, const cWorld & a_World) override;
virtual void SendLoginSuccess (void) override;
virtual void SendMapData (const cMap & a_Map, int a_DataStartX, int a_DataStartY) override;
diff --git a/src/Protocol/Protocol18x.cpp b/src/Protocol/Protocol18x.cpp
index e8acf8bd4..bd38d25d8 100644
--- a/src/Protocol/Protocol18x.cpp
+++ b/src/Protocol/Protocol18x.cpp
@@ -140,8 +140,8 @@ void cProtocol180::DataReceived(const char * a_Data, size_t a_Size)
while (a_Size > 0)
{
size_t NumBytes = (a_Size > sizeof(Decrypted)) ? sizeof(Decrypted) : a_Size;
- m_Decryptor.ProcessData(Decrypted, (Byte *)a_Data, NumBytes);
- AddReceivedData((const char *)Decrypted, NumBytes);
+ m_Decryptor.ProcessData(Decrypted, reinterpret_cast<const Byte *>(a_Data), NumBytes);
+ AddReceivedData(reinterpret_cast<const char *>(Decrypted), NumBytes);
a_Size -= NumBytes;
a_Data += NumBytes;
}
@@ -205,7 +205,7 @@ void cProtocol180::SendBlockChange(int a_BlockX, int a_BlockY, int a_BlockZ, BLO
cPacketizer Pkt(*this, 0x23); // Block Change packet
Pkt.WritePosition64(a_BlockX, a_BlockY, a_BlockZ);
- Pkt.WriteVarInt32(((UInt32)a_BlockType << 4) | ((UInt32)a_BlockMeta & 15));
+ Pkt.WriteVarInt32((static_cast<UInt32>(a_BlockType) << 4) | (static_cast<UInt32>(a_BlockMeta) & 15));
}
@@ -219,12 +219,12 @@ void cProtocol180::SendBlockChanges(int a_ChunkX, int a_ChunkZ, const sSetBlockV
cPacketizer Pkt(*this, 0x22); // Multi Block Change packet
Pkt.WriteBEInt32(a_ChunkX);
Pkt.WriteBEInt32(a_ChunkZ);
- Pkt.WriteVarInt32((UInt32)a_Changes.size());
+ Pkt.WriteVarInt32(static_cast<UInt32>(a_Changes.size()));
for (sSetBlockVector::const_iterator itr = a_Changes.begin(), end = a_Changes.end(); itr != end; ++itr)
{
Int16 Coords = static_cast<Int16>(itr->m_RelY | (itr->m_RelZ << 8) | (itr->m_RelX << 12));
Pkt.WriteBEInt16(Coords);
- Pkt.WriteVarInt32((itr->m_BlockType & 0xFFF) << 4 | (itr->m_BlockMeta & 0xF));
+ Pkt.WriteVarInt32(static_cast<UInt32>(itr->m_BlockType & 0xFFF) << 4 | (itr->m_BlockMeta & 0xF));
} // for itr - a_Changes[]
}
@@ -403,7 +403,7 @@ void cProtocol180::SendEntityEffect(const cEntity & a_Entity, int a_EffectID, in
Pkt.WriteVarInt32(a_Entity.GetUniqueID());
Pkt.WriteBEUInt8(static_cast<UInt8>(a_EffectID));
Pkt.WriteBEUInt8(static_cast<UInt8>(a_Amplifier));
- Pkt.WriteVarInt32((UInt32)a_Duration);
+ Pkt.WriteVarInt32(static_cast<UInt32>(a_Duration));
Pkt.WriteBool(false); // Hide particles
}
@@ -534,9 +534,9 @@ void cProtocol180::SendEntityVelocity(const cEntity & a_Entity)
cPacketizer Pkt(*this, 0x12); // Entity Velocity packet
Pkt.WriteVarInt32(a_Entity.GetUniqueID());
// 400 = 8000 / 20 ... Conversion from our speed in m / s to 8000 m / tick
- Pkt.WriteBEInt16((short)(a_Entity.GetSpeedX() * 400));
- Pkt.WriteBEInt16((short)(a_Entity.GetSpeedY() * 400));
- Pkt.WriteBEInt16((short)(a_Entity.GetSpeedZ() * 400));
+ Pkt.WriteBEInt16(static_cast<Int16>(a_Entity.GetSpeedX() * 400));
+ Pkt.WriteBEInt16(static_cast<Int16>(a_Entity.GetSpeedY() * 400));
+ Pkt.WriteBEInt16(static_cast<Int16>(a_Entity.GetSpeedZ() * 400));
}
@@ -588,7 +588,7 @@ void cProtocol180::SendHealth(void)
cPacketizer Pkt(*this, 0x06); // Update Health packet
cPlayer * Player = m_Client->GetPlayer();
Pkt.WriteBEFloat(static_cast<float>(Player->GetHealth()));
- Pkt.WriteVarInt32((UInt32)Player->GetFoodLevel());
+ Pkt.WriteVarInt32(static_cast<UInt32>(Player->GetFoodLevel()));
Pkt.WriteBEFloat(static_cast<float>(Player->GetFoodSaturationLevel()));
}
@@ -622,7 +622,7 @@ void cProtocol180::SendInventorySlot(char a_WindowID, short a_SlotNum, const cIt
-void cProtocol180::SendKeepAlive(int a_PingID)
+void cProtocol180::SendKeepAlive(UInt32 a_PingID)
{
// Drop the packet if the protocol is not in the Game state yet (caused a client crash):
if (m_State != 3)
@@ -646,10 +646,10 @@ void cProtocol180::SendLogin(const cPlayer & a_Player, const cWorld & a_World)
cServer * Server = cRoot::Get()->GetServer();
cPacketizer Pkt(*this, 0x01); // Join Game packet
Pkt.WriteBEUInt32(a_Player.GetUniqueID());
- Pkt.WriteBEUInt8((Byte)a_Player.GetEffectiveGameMode() | (Server->IsHardcore() ? 0x08 : 0)); // Hardcore flag bit 4
- Pkt.WriteBEInt8((char)a_World.GetDimension());
+ Pkt.WriteBEUInt8(static_cast<UInt8>(a_Player.GetEffectiveGameMode()) | (Server->IsHardcore() ? 0x08 : 0)); // Hardcore flag bit 4
+ Pkt.WriteBEInt8(static_cast<Int8>(a_World.GetDimension()));
Pkt.WriteBEUInt8(2); // TODO: Difficulty (set to Normal)
- Pkt.WriteBEUInt8(Server->GetMaxPlayers());
+ Pkt.WriteBEUInt8(Clamp<UInt8>(Server->GetMaxPlayers(), 0, 255));
Pkt.WriteString("default"); // Level type - wtf?
Pkt.WriteBool(false); // Reduced Debug Info - wtf?
}
@@ -658,7 +658,7 @@ void cProtocol180::SendLogin(const cPlayer & a_Player, const cWorld & a_World)
// Send the spawn position:
{
cPacketizer Pkt(*this, 0x05); // Spawn Position packet
- Pkt.WritePosition64((int)a_World.GetSpawnX(), (int)a_World.GetSpawnY(), (int)a_World.GetSpawnZ());
+ Pkt.WritePosition64(FloorC(a_World.GetSpawnX()), FloorC(a_World.GetSpawnY()), FloorC(a_World.GetSpawnZ()));
}
// Send the server difficulty:
@@ -707,8 +707,8 @@ void cProtocol180::SendPaintingSpawn(const cPainting & a_Painting)
cPacketizer Pkt(*this, 0x10); // Spawn Painting packet
Pkt.WriteVarInt32(a_Painting.GetUniqueID());
Pkt.WriteString(a_Painting.GetName().c_str());
- Pkt.WritePosition64((int)PosX, (int)PosY, (int)PosZ);
- Pkt.WriteBEInt8(a_Painting.GetProtocolFacing());
+ Pkt.WritePosition64(static_cast<Int32>(PosX), static_cast<Int32>(PosY), static_cast<Int32>(PosZ));
+ Pkt.WriteBEInt8(static_cast<Int8>(a_Painting.GetProtocolFacing()));
}
@@ -721,20 +721,20 @@ void cProtocol180::SendMapData(const cMap & a_Map, int a_DataStartX, int a_DataS
cPacketizer Pkt(*this, 0x34);
Pkt.WriteVarInt32(a_Map.GetID());
- Pkt.WriteBEUInt8(a_Map.GetScale());
+ Pkt.WriteBEUInt8(static_cast<UInt8>(a_Map.GetScale()));
Pkt.WriteVarInt32(static_cast<UInt32>(a_Map.GetDecorators().size()));
for (const auto Decorator : a_Map.GetDecorators())
{
- Pkt.WriteBEUInt8(static_cast<Byte>((static_cast<int>(Decorator.GetType()) << 4) | (Decorator.GetRot() & 0xF)));
- Pkt.WriteBEUInt8(Decorator.GetPixelX());
- Pkt.WriteBEUInt8(Decorator.GetPixelZ());
+ Pkt.WriteBEUInt8(static_cast<Byte>((static_cast<Int32>(Decorator.GetType()) << 4) | (Decorator.GetRot() & 0xF)));
+ Pkt.WriteBEUInt8(static_cast<UInt8>(Decorator.GetPixelX()));
+ Pkt.WriteBEUInt8(static_cast<UInt8>(Decorator.GetPixelZ()));
}
Pkt.WriteBEUInt8(128);
Pkt.WriteBEUInt8(128);
- Pkt.WriteBEUInt8(a_DataStartX);
- Pkt.WriteBEUInt8(a_DataStartY);
+ Pkt.WriteBEUInt8(static_cast<UInt8>(a_DataStartX));
+ Pkt.WriteBEUInt8(static_cast<UInt8>(a_DataStartY));
Pkt.WriteVarInt32(static_cast<UInt32>(a_Map.GetData().size()));
for (auto itr = a_Map.GetData().cbegin(); itr != a_Map.GetData().cend(); ++itr)
{
@@ -897,9 +897,9 @@ void cProtocol180::SendPlayerListAddPlayer(const cPlayer & a_Player)
Pkt.WriteVarInt32(Properties.size());
for (Json::Value::iterator itr = Properties.begin(), end = Properties.end(); itr != end; ++itr)
{
- Pkt.WriteString(((Json::Value)*itr).get("name", "").asString());
- Pkt.WriteString(((Json::Value)*itr).get("value", "").asString());
- AString Signature = ((Json::Value)*itr).get("signature", "").asString();
+ Pkt.WriteString(static_cast<Json::Value>(*itr).get("name", "").asString());
+ Pkt.WriteString(static_cast<Json::Value>(*itr).get("value", "").asString());
+ AString Signature = static_cast<Json::Value>(*itr).get("signature", "").asString();
if (Signature.empty())
{
Pkt.WriteBool(false);
@@ -911,8 +911,8 @@ void cProtocol180::SendPlayerListAddPlayer(const cPlayer & a_Player)
}
}
- Pkt.WriteVarInt32((UInt32)a_Player.GetGameMode());
- Pkt.WriteVarInt32((UInt32)a_Player.GetClientHandle()->GetPing());
+ Pkt.WriteVarInt32(static_cast<UInt32>(a_Player.GetGameMode()));
+ Pkt.WriteVarInt32(static_cast<UInt32>(a_Player.GetClientHandle()->GetPing()));
Pkt.WriteBool(false);
}
@@ -942,7 +942,7 @@ void cProtocol180::SendPlayerListUpdateGameMode(const cPlayer & a_Player)
Pkt.WriteVarInt32(1);
Pkt.WriteVarInt32(1);
Pkt.WriteUUID(a_Player.GetUUID());
- Pkt.WriteVarInt32((UInt32)a_Player.GetGameMode());
+ Pkt.WriteVarInt32(static_cast<UInt32>(a_Player.GetGameMode()));
}
@@ -1095,7 +1095,7 @@ void cProtocol180::SendRemoveEntityEffect(const cEntity & a_Entity, int a_Effect
cPacketizer Pkt(*this, 0x1e);
Pkt.WriteVarInt32(a_Entity.GetUniqueID());
- Pkt.WriteBEUInt8(a_EffectID);
+ Pkt.WriteBEUInt8(static_cast<UInt8>(a_EffectID));
}
@@ -1124,9 +1124,9 @@ void cProtocol180::SendRespawn(eDimension a_Dimension, bool a_ShouldIgnoreDimens
cPacketizer Pkt(*this, 0x07); // Respawn packet
cPlayer * Player = m_Client->GetPlayer();
- Pkt.WriteBEInt32((int)a_Dimension);
+ Pkt.WriteBEInt32(static_cast<Int32>(a_Dimension));
Pkt.WriteBEUInt8(2); // TODO: Difficulty (set to Normal)
- Pkt.WriteBEUInt8((Byte)Player->GetEffectiveGameMode());
+ Pkt.WriteBEUInt8(static_cast<Byte>(Player->GetEffectiveGameMode()));
Pkt.WriteString("default");
m_LastSentDimension = a_Dimension;
}
@@ -1142,8 +1142,8 @@ void cProtocol180::SendExperience(void)
cPacketizer Pkt(*this, 0x1f); // Experience Packet
cPlayer * Player = m_Client->GetPlayer();
Pkt.WriteBEFloat(Player->GetXpPercentage());
- Pkt.WriteVarInt32((UInt32)Player->GetXpLevel());
- Pkt.WriteVarInt32((UInt32)Player->GetCurrentXp());
+ Pkt.WriteVarInt32(static_cast<UInt32>(Player->GetXpLevel()));
+ Pkt.WriteVarInt32(static_cast<UInt32>(Player->GetCurrentXp()));
}
@@ -1159,7 +1159,7 @@ void cProtocol180::SendExperienceOrb(const cExpOrb & a_ExpOrb)
Pkt.WriteFPInt(a_ExpOrb.GetPosX());
Pkt.WriteFPInt(a_ExpOrb.GetPosY());
Pkt.WriteFPInt(a_ExpOrb.GetPosZ());
- Pkt.WriteBEInt16(a_ExpOrb.GetReward());
+ Pkt.WriteBEInt16(static_cast<Int16>(a_ExpOrb.GetReward()));
}
@@ -1195,7 +1195,7 @@ void cProtocol180::SendScoreUpdate(const AString & a_Objective, const AString &
if (a_Mode != 1)
{
- Pkt.WriteVarInt32((UInt32) a_Score);
+ Pkt.WriteVarInt32(static_cast<UInt32>(a_Score));
}
}
@@ -1208,7 +1208,7 @@ void cProtocol180::SendDisplayObjective(const AString & a_Objective, cScoreboard
ASSERT(m_State == 3); // In game mode?
cPacketizer Pkt(*this, 0x3d);
- Pkt.WriteBEUInt8((int) a_Display);
+ Pkt.WriteBEUInt8(static_cast<UInt8>(a_Display));
Pkt.WriteString(a_Objective);
}
@@ -1268,11 +1268,11 @@ void cProtocol180::SendSoundEffect(const AString & a_SoundName, double a_X, doub
cPacketizer Pkt(*this, 0x29); // Sound Effect packet
Pkt.WriteString(a_SoundName);
- Pkt.WriteBEInt32((int)(a_X * 8.0));
- Pkt.WriteBEInt32((int)(a_Y * 8.0));
- Pkt.WriteBEInt32((int)(a_Z * 8.0));
+ Pkt.WriteBEInt32(static_cast<Int32>(a_X * 8.0));
+ Pkt.WriteBEInt32(static_cast<Int32>(a_Y * 8.0));
+ Pkt.WriteBEInt32(static_cast<Int32>(a_Z * 8.0));
Pkt.WriteBEFloat(a_Volume);
- Pkt.WriteBEUInt8((Byte)(a_Pitch * 63));
+ Pkt.WriteBEUInt8(static_cast<Byte>(a_Pitch * 63));
}
@@ -1306,10 +1306,10 @@ void cProtocol180::SendSpawnFallingBlock(const cFallingBlock & a_FallingBlock)
Pkt.WriteFPInt(a_FallingBlock.GetPosZ());
Pkt.WriteByteAngle(a_FallingBlock.GetYaw());
Pkt.WriteByteAngle(a_FallingBlock.GetPitch());
- Pkt.WriteBEInt32(((int)a_FallingBlock.GetBlockType()) | (((int)a_FallingBlock.GetBlockMeta()) << 12));
- Pkt.WriteBEInt16((short)(a_FallingBlock.GetSpeedX() * 400));
- Pkt.WriteBEInt16((short)(a_FallingBlock.GetSpeedY() * 400));
- Pkt.WriteBEInt16((short)(a_FallingBlock.GetSpeedZ() * 400));
+ Pkt.WriteBEInt32(static_cast<Int32>(a_FallingBlock.GetBlockType()) | (static_cast<Int32>(a_FallingBlock.GetBlockMeta()) << 12));
+ Pkt.WriteBEInt16(static_cast<Int16>(a_FallingBlock.GetSpeedX() * 400));
+ Pkt.WriteBEInt16(static_cast<Int16>(a_FallingBlock.GetSpeedY() * 400));
+ Pkt.WriteBEInt16(static_cast<Int16>(a_FallingBlock.GetSpeedZ() * 400));
}
@@ -1322,16 +1322,16 @@ void cProtocol180::SendSpawnMob(const cMonster & a_Mob)
cPacketizer Pkt(*this, 0x0f); // Spawn Mob packet
Pkt.WriteVarInt32(a_Mob.GetUniqueID());
- Pkt.WriteBEUInt8((Byte)a_Mob.GetMobType());
+ Pkt.WriteBEUInt8(static_cast<Byte>(a_Mob.GetMobType()));
Pkt.WriteFPInt(a_Mob.GetPosX());
Pkt.WriteFPInt(a_Mob.GetPosY());
Pkt.WriteFPInt(a_Mob.GetPosZ());
Pkt.WriteByteAngle(a_Mob.GetPitch());
Pkt.WriteByteAngle(a_Mob.GetHeadYaw());
Pkt.WriteByteAngle(a_Mob.GetYaw());
- Pkt.WriteBEInt16((short)(a_Mob.GetSpeedX() * 400));
- Pkt.WriteBEInt16((short)(a_Mob.GetSpeedY() * 400));
- Pkt.WriteBEInt16((short)(a_Mob.GetSpeedZ() * 400));
+ Pkt.WriteBEInt16(static_cast<Int16>(a_Mob.GetSpeedX() * 400));
+ Pkt.WriteBEInt16(static_cast<Int16>(a_Mob.GetSpeedY() * 400));
+ Pkt.WriteBEInt16(static_cast<Int16>(a_Mob.GetSpeedZ() * 400));
WriteEntityMetadata(Pkt, a_Mob);
Pkt.WriteBEUInt8(0x7f); // Metadata terminator
}
@@ -1353,7 +1353,7 @@ void cProtocol180::SendSpawnObject(const cEntity & a_Entity, char a_ObjectType,
cPacketizer Pkt(*this, 0xe); // Spawn Object packet
Pkt.WriteVarInt32(a_Entity.GetUniqueID());
- Pkt.WriteBEUInt8(a_ObjectType);
+ Pkt.WriteBEUInt8(static_cast<UInt8>(a_ObjectType));
Pkt.WriteFPInt(PosX);
Pkt.WriteFPInt(a_Entity.GetPosY());
Pkt.WriteFPInt(PosZ);
@@ -1362,9 +1362,9 @@ void cProtocol180::SendSpawnObject(const cEntity & a_Entity, char a_ObjectType,
Pkt.WriteBEInt32(a_ObjectData);
if (a_ObjectData != 0)
{
- Pkt.WriteBEInt16((short)(a_Entity.GetSpeedX() * 400));
- Pkt.WriteBEInt16((short)(a_Entity.GetSpeedY() * 400));
- Pkt.WriteBEInt16((short)(a_Entity.GetSpeedZ() * 400));
+ Pkt.WriteBEInt16(static_cast<Int16>(a_Entity.GetSpeedX() * 400));
+ Pkt.WriteBEInt16(static_cast<Int16>(a_Entity.GetSpeedY() * 400));
+ Pkt.WriteBEInt16(static_cast<Int16>(a_Entity.GetSpeedZ() * 400));
}
}
@@ -1378,7 +1378,7 @@ void cProtocol180::SendSpawnVehicle(const cEntity & a_Vehicle, char a_VehicleTyp
cPacketizer Pkt(*this, 0xe); // Spawn Object packet
Pkt.WriteVarInt32(a_Vehicle.GetUniqueID());
- Pkt.WriteBEUInt8(a_VehicleType);
+ Pkt.WriteBEUInt8(static_cast<UInt8>(a_VehicleType));
Pkt.WriteFPInt(a_Vehicle.GetPosX());
Pkt.WriteFPInt(a_Vehicle.GetPosY());
Pkt.WriteFPInt(a_Vehicle.GetPosZ());
@@ -1387,9 +1387,9 @@ void cProtocol180::SendSpawnVehicle(const cEntity & a_Vehicle, char a_VehicleTyp
Pkt.WriteBEInt32(a_VehicleSubType);
if (a_VehicleSubType != 0)
{
- Pkt.WriteBEInt16((short)(a_Vehicle.GetSpeedX() * 400));
- Pkt.WriteBEInt16((short)(a_Vehicle.GetSpeedY() * 400));
- Pkt.WriteBEInt16((short)(a_Vehicle.GetSpeedZ() * 400));
+ Pkt.WriteBEInt16(static_cast<Int16>(a_Vehicle.GetSpeedX() * 400));
+ Pkt.WriteBEInt16(static_cast<Int16>(a_Vehicle.GetSpeedY() * 400));
+ Pkt.WriteBEInt16(static_cast<Int16>(a_Vehicle.GetSpeedZ() * 400));
}
}
@@ -1404,13 +1404,14 @@ void cProtocol180::SendStatistics(const cStatManager & a_Manager)
cPacketizer Pkt(*this, 0x37);
Pkt.WriteVarInt32(statCount); // TODO 2014-05-11 xdot: Optimization: Send "dirty" statistics only
- for (size_t i = 0; i < (size_t)statCount; ++i)
+ size_t Count = static_cast<size_t>(statCount);
+ for (size_t i = 0; i < Count; ++i)
{
- StatValue Value = a_Manager.GetValue((eStatistic) i);
- const AString & StatName = cStatInfo::GetName((eStatistic) i);
+ StatValue Value = a_Manager.GetValue(static_cast<eStatistic>(i));
+ const AString & StatName = cStatInfo::GetName(static_cast<eStatistic>(i));
Pkt.WriteString(StatName);
- Pkt.WriteVarInt32(Value);
+ Pkt.WriteVarInt32(static_cast<UInt32>(Value));
}
}
@@ -1423,7 +1424,7 @@ void cProtocol180::SendTabCompletionResults(const AStringVector & a_Results)
ASSERT(m_State == 3); // In game mode?
cPacketizer Pkt(*this, 0x3a); // Tab-Complete packet
- Pkt.WriteVarInt32((int)a_Results.size());
+ Pkt.WriteVarInt32(static_cast<UInt32>(a_Results.size()));
for (AStringVector::const_iterator itr = a_Results.begin(), end = a_Results.end(); itr != end; ++itr)
{
@@ -1601,7 +1602,7 @@ void cProtocol180::SendWholeInventory(const cWindow & a_Window)
cPacketizer Pkt(*this, 0x30); // Window Items packet
Pkt.WriteBEInt8(a_Window.GetWindowID());
- Pkt.WriteBEInt16(a_Window.GetNumSlots());
+ Pkt.WriteBEInt16(static_cast<Int16>(a_Window.GetNumSlots()));
cItems Slots;
a_Window.GetSlots(*(m_Client->GetPlayer()), Slots);
for (cItems::const_iterator itr = Slots.begin(), end = Slots.end(); itr != end; ++itr)
@@ -1652,7 +1653,7 @@ void cProtocol180::SendWindowOpen(const cWindow & a_Window)
}
default:
{
- Pkt.WriteBEInt8(a_Window.GetNumNonInventorySlots());
+ Pkt.WriteBEInt8(static_cast<Int8>(a_Window.GetNumNonInventorySlots()));
break;
}
}
@@ -1846,8 +1847,8 @@ void cProtocol180::AddReceivedData(const char * a_Data, size_t a_Size)
}
AString Hex;
CreateHexDump(Hex, a_Data, a_Size, 16);
- m_CommLogFile.Printf("Incoming data: %d (0x%x) bytes: \n%s\n",
- (unsigned)a_Size, (unsigned)a_Size, Hex.c_str()
+ m_CommLogFile.Printf("Incoming data: %u (0x%x) bytes: \n%s\n",
+ static_cast<unsigned>(a_Size), static_cast<unsigned>(a_Size), Hex.c_str()
);
m_CommLogFile.Flush();
}
@@ -1912,7 +1913,7 @@ void cProtocol180::AddReceivedData(const char * a_Data, size_t a_Size)
if (CompressedSize == 0)
{
// No compression was used, move directly
- VERIFY(m_ReceivedData.ReadToByteBuffer(bb, (int)PacketLen));
+ VERIFY(m_ReceivedData.ReadToByteBuffer(bb, static_cast<size_t>(PacketLen)));
}
else
{
@@ -2189,14 +2190,14 @@ void cProtocol180::HandlePacketLoginEncryptionResponse(cByteBuffer & a_ByteBuffe
// Decrypt EncNonce using privkey
cRsaPrivateKey & rsaDecryptor = cRoot::Get()->GetServer()->GetPrivateKey();
Int32 DecryptedNonce[MAX_ENC_LEN / sizeof(Int32)];
- int res = rsaDecryptor.Decrypt((const Byte *)EncNonce.data(), EncNonce.size(), (Byte *)DecryptedNonce, sizeof(DecryptedNonce));
+ int res = rsaDecryptor.Decrypt(reinterpret_cast<const Byte *>(EncNonce.data()), EncNonce.size(), reinterpret_cast<Byte *>(DecryptedNonce), sizeof(DecryptedNonce));
if (res != 4)
{
LOGD("Bad nonce length: got %d, exp %d", res, 4);
m_Client->Kick("Hacked client");
return;
}
- if (ntohl(DecryptedNonce[0]) != (unsigned)(uintptr_t)this)
+ if (ntohl(DecryptedNonce[0]) != (unsigned)(uintptr_t)this) // Cannot convert to c++ casts
{
LOGD("Bad nonce value");
m_Client->Kick("Hacked client");
@@ -2205,7 +2206,7 @@ void cProtocol180::HandlePacketLoginEncryptionResponse(cByteBuffer & a_ByteBuffe
// Decrypt the symmetric encryption key using privkey:
Byte DecryptedKey[MAX_ENC_LEN];
- res = rsaDecryptor.Decrypt((const Byte *)EncKey.data(), EncKey.size(), DecryptedKey, sizeof(DecryptedKey));
+ res = rsaDecryptor.Decrypt(reinterpret_cast<const Byte *>(EncKey.data()), EncKey.size(), DecryptedKey, sizeof(DecryptedKey));
if (res != 16)
{
LOGD("Bad key length");
@@ -2243,10 +2244,10 @@ void cProtocol180::HandlePacketLoginStart(cByteBuffer & a_ByteBuffer)
cPacketizer Pkt(*this, 0x01);
Pkt.WriteString(Server->GetServerID());
const AString & PubKeyDer = Server->GetPublicKeyDER();
- Pkt.WriteVarInt32((short)PubKeyDer.size());
+ Pkt.WriteVarInt32(static_cast<UInt32>(PubKeyDer.size()));
Pkt.WriteBuf(PubKeyDer.data(), PubKeyDer.size());
Pkt.WriteVarInt32(4);
- Pkt.WriteBEInt32((int)(intptr_t)this); // Using 'this' as the cryptographic nonce, so that we don't have to generate one each time :)
+ Pkt.WriteBEInt32((int)(intptr_t)this); // Using 'this' as the cryptographic nonce, so that we don't have to generate one each time :) Cannot convert to c++ casts
m_Client->SetUsername(Username);
return;
}
@@ -2405,7 +2406,7 @@ void cProtocol180::HandlePacketEntityAction(cByteBuffer & a_ByteBuffer)
void cProtocol180::HandlePacketKeepAlive(cByteBuffer & a_ByteBuffer)
{
HANDLE_READ(a_ByteBuffer, ReadVarInt, UInt32, KeepAliveID);
- m_Client->HandleKeepAlive(static_cast<int>(KeepAliveID));
+ m_Client->HandleKeepAlive(static_cast<Int32>(KeepAliveID));
}
@@ -2771,8 +2772,8 @@ void cProtocol180::SendData(const char * a_Data, size_t a_Size)
while (a_Size > 0)
{
size_t NumBytes = (a_Size > sizeof(Encrypted)) ? sizeof(Encrypted) : a_Size;
- m_Encryptor.ProcessData(Encrypted, (Byte *)a_Data, NumBytes);
- m_Client->SendData((const char *)Encrypted, NumBytes);
+ m_Encryptor.ProcessData(Encrypted, reinterpret_cast<Byte *>(const_cast<char*>(a_Data)), NumBytes);
+ m_Client->SendData(reinterpret_cast<const char *>(Encrypted), NumBytes);
a_Size -= NumBytes;
a_Data += NumBytes;
}
@@ -2877,7 +2878,7 @@ void cProtocol180::ParseItemMetadata(cItem & a_Item, const AString & a_Metadata)
}
else if ((TagName == "Fireworks") || (TagName == "Explosion"))
{
- cFireworkItem::ParseFromNBT(a_Item.m_FireworkItem, NBT, tag, (ENUM_ITEM_ID)a_Item.m_ItemType);
+ cFireworkItem::ParseFromNBT(a_Item.m_FireworkItem, NBT, tag, static_cast<ENUM_ITEM_ID>(a_Item.m_ItemType));
}
break;
}
@@ -2907,9 +2908,9 @@ void cProtocol180::StartEncryption(const Byte * a_Key)
cSha1Checksum Checksum;
cServer * Server = cRoot::Get()->GetServer();
const AString & ServerID = Server->GetServerID();
- Checksum.Update((const Byte *)ServerID.c_str(), ServerID.length());
+ Checksum.Update(reinterpret_cast<const Byte *>(ServerID.c_str()), ServerID.length());
Checksum.Update(a_Key, 16);
- Checksum.Update((const Byte *)Server->GetPublicKeyDER().data(), Server->GetPublicKeyDER().size());
+ Checksum.Update(reinterpret_cast<const Byte *>(Server->GetPublicKeyDER().data()), Server->GetPublicKeyDER().size());
Byte Digest[20];
Checksum.Finalize(Digest);
cSha1Checksum::DigestToJava(Digest, m_AuthServerID);
@@ -3045,7 +3046,7 @@ void cProtocol180::WriteItem(cPacketizer & a_Pkt, const cItem & a_Item)
Writer.BeginCompound("display");
if (a_Item.m_ItemColor.IsValid())
{
- Writer.AddInt("color", static_cast<int>(a_Item.m_ItemColor.m_Color));
+ Writer.AddInt("color", static_cast<Int32>(a_Item.m_ItemColor.m_Color));
}
if (!a_Item.IsCustomNameEmpty())
@@ -3149,8 +3150,8 @@ void cProtocol180::WriteBlockEntity(cPacketizer & a_Pkt, const cBlockEntity & a_
Writer.AddInt("x", FlowerPotEntity.GetPosX());
Writer.AddInt("y", FlowerPotEntity.GetPosY());
Writer.AddInt("z", FlowerPotEntity.GetPosZ());
- Writer.AddInt("Item", (Int32) FlowerPotEntity.GetItem().m_ItemType);
- Writer.AddInt("Data", (Int32) FlowerPotEntity.GetItem().m_ItemDamage);
+ Writer.AddInt("Item", static_cast<Int32>(FlowerPotEntity.GetItem().m_ItemType));
+ Writer.AddInt("Data", static_cast<Int32>(FlowerPotEntity.GetItem().m_ItemDamage));
Writer.AddString("id", "FlowerPot"); // "Tile Entity ID" - MC wiki; vanilla server always seems to send this though
break;
}
@@ -3324,7 +3325,7 @@ void cProtocol180::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mob)
}
a_Pkt.WriteBEUInt8(0x66);
- a_Pkt.WriteBEFloat(a_Mob.GetHealth());
+ a_Pkt.WriteBEFloat(static_cast<float>(a_Mob.GetHealth()));
switch (a_Mob.GetMobType())
{
@@ -3340,7 +3341,7 @@ void cProtocol180::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mob)
{
auto & Creeper = reinterpret_cast<const cCreeper &>(a_Mob);
a_Pkt.WriteBEUInt8(0x10);
- a_Pkt.WriteBEUInt8(Creeper.IsBlowing() ? 1 : -1);
+ a_Pkt.WriteBEUInt8(Creeper.IsBlowing() ? 1 : 0);
a_Pkt.WriteBEUInt8(0x11);
a_Pkt.WriteBEUInt8(Creeper.IsCharged() ? 1 : 0);
break;
@@ -3397,7 +3398,7 @@ void cProtocol180::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mob)
a_Pkt.WriteBEUInt8(0x50); // Int at index 16
a_Pkt.WriteBEInt32(Flags);
a_Pkt.WriteBEUInt8(0x13); // Byte at index 19
- a_Pkt.WriteBEUInt8(Horse.GetHorseType());
+ a_Pkt.WriteBEUInt8(static_cast<UInt8>(Horse.GetHorseType()));
a_Pkt.WriteBEUInt8(0x54); // Int at index 20
int Appearance = 0;
Appearance = Horse.GetHorseColor();
@@ -3415,7 +3416,7 @@ void cProtocol180::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mob)
{
auto & MagmaCube = reinterpret_cast<const cMagmaCube &>(a_Mob);
a_Pkt.WriteBEUInt8(0x10);
- a_Pkt.WriteBEUInt8(MagmaCube.GetSize());
+ a_Pkt.WriteBEUInt8(static_cast<UInt8>(MagmaCube.GetSize()));
break;
} // case mtMagmaCube
@@ -3445,7 +3446,7 @@ void cProtocol180::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mob)
a_Pkt.WriteBEUInt8(0x10);
Byte SheepMetadata = 0;
- SheepMetadata = Sheep.GetFurColor();
+ SheepMetadata = static_cast<Byte>(Sheep.GetFurColor());
if (Sheep.IsSheared())
{
SheepMetadata |= 0x10;
@@ -3477,7 +3478,7 @@ void cProtocol180::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mob)
{
auto & Slime = reinterpret_cast<const cSlime &>(a_Mob);
a_Pkt.WriteBEUInt8(0x10);
- a_Pkt.WriteBEUInt8(Slime.GetSize());
+ a_Pkt.WriteBEUInt8(static_cast<UInt8>(Slime.GetSize()));
break;
} // case mtSlime
@@ -3503,7 +3504,7 @@ void cProtocol180::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mob)
{
auto & Wither = reinterpret_cast<const cWither &>(a_Mob);
a_Pkt.WriteBEUInt8(0x54); // Int at index 20
- a_Pkt.WriteBEInt32(Wither.GetWitherInvulnerableTicks());
+ a_Pkt.WriteBEInt32(static_cast<Int32>(Wither.GetWitherInvulnerableTicks()));
a_Pkt.WriteBEUInt8(0x66); // Float at index 6
a_Pkt.WriteBEFloat(static_cast<float>(a_Mob.GetHealth()));
break;
@@ -3533,7 +3534,7 @@ void cProtocol180::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mob)
a_Pkt.WriteBEUInt8(0x13);
a_Pkt.WriteBEUInt8(Wolf.IsBegging() ? 1 : 0);
a_Pkt.WriteBEUInt8(0x14);
- a_Pkt.WriteBEUInt8(Wolf.GetCollarColor());
+ a_Pkt.WriteBEUInt8(static_cast<UInt8>(Wolf.GetCollarColor()));
a_Pkt.WriteBEUInt8(0x0c);
a_Pkt.WriteBEInt8(Wolf.GetAge());
diff --git a/src/Protocol/Protocol18x.h b/src/Protocol/Protocol18x.h
index 99774d242..02add5528 100644
--- a/src/Protocol/Protocol18x.h
+++ b/src/Protocol/Protocol18x.h
@@ -93,7 +93,7 @@ public:
virtual void SendHealth (void) override;
virtual void SendHideTitle (void) override;
virtual void SendInventorySlot (char a_WindowID, short a_SlotNum, const cItem & a_Item) override;
- virtual void SendKeepAlive (int a_PingID) override;
+ virtual void SendKeepAlive (UInt32 a_PingID) override;
virtual void SendLogin (const cPlayer & a_Player, const cWorld & a_World) override;
virtual void SendLoginSuccess (void) override;
virtual void SendMapData (const cMap & a_Map, int a_DataStartX, int a_DataStartY) override;
diff --git a/src/Protocol/ProtocolRecognizer.cpp b/src/Protocol/ProtocolRecognizer.cpp
index 574875831..42c2eee0a 100644
--- a/src/Protocol/ProtocolRecognizer.cpp
+++ b/src/Protocol/ProtocolRecognizer.cpp
@@ -258,11 +258,11 @@ void cProtocolRecognizer::SendDisconnect(const AString & a_Reason)
{
// This is used when the client sends a server-ping, respond with the default packet:
static const int Packet = 0xff; // PACKET_DISCONNECT
- SendData((const char *)&Packet, 1); // WriteByte()
+ SendData(reinterpret_cast<const char *>(&Packet), 1); // WriteByte()
AString UTF16 = UTF8ToRawBEUTF16(a_Reason.c_str(), a_Reason.length());
- static const u_short Size = htons((u_short)(UTF16.size() / 2));
- SendData((const char *)&Size, 2); // WriteShort()
+ static const u_short Size = htons(static_cast<u_short>(UTF16.size() / 2));
+ SendData(reinterpret_cast<const char *>(&Size), 2); // WriteShort()
SendData(UTF16.data(), UTF16.size()); // WriteString()
}
}
@@ -440,7 +440,7 @@ void cProtocolRecognizer::SendInventorySlot(char a_WindowID, short a_SlotNum, co
-void cProtocolRecognizer::SendKeepAlive(int a_PingID)
+void cProtocolRecognizer::SendKeepAlive(UInt32 a_PingID)
{
ASSERT(m_Protocol != nullptr);
m_Protocol->SendKeepAlive(a_PingID);
@@ -986,13 +986,13 @@ bool cProtocolRecognizer::TryRecognizeProtocol(void)
// Lengthed protocol, try if it has the entire initial handshake packet:
UInt32 PacketLen;
- UInt32 ReadSoFar = (UInt32)m_Buffer.GetReadableSpace();
+ UInt32 ReadSoFar = static_cast<UInt32>(m_Buffer.GetReadableSpace());
if (!m_Buffer.ReadVarInt(PacketLen))
{
// Not enough bytes for the packet length, keep waiting
return false;
}
- ReadSoFar -= (UInt32)m_Buffer.GetReadableSpace();
+ ReadSoFar -= static_cast<UInt32>(m_Buffer.GetReadableSpace());
if (!m_Buffer.CanReadBytes(PacketLen))
{
// Not enough bytes for the packet, keep waiting
diff --git a/src/Protocol/ProtocolRecognizer.h b/src/Protocol/ProtocolRecognizer.h
index 491645cff..090e36799 100644
--- a/src/Protocol/ProtocolRecognizer.h
+++ b/src/Protocol/ProtocolRecognizer.h
@@ -81,7 +81,7 @@ public:
virtual void SendHealth (void) override;
virtual void SendHideTitle (void) override;
virtual void SendInventorySlot (char a_WindowID, short a_SlotNum, const cItem & a_Item) override;
- virtual void SendKeepAlive (int a_PingID) override;
+ virtual void SendKeepAlive (UInt32 a_PingID) override;
virtual void SendLogin (const cPlayer & a_Player, const cWorld & a_World) override;
virtual void SendLoginSuccess (void) override;
virtual void SendMapData (const cMap & a_Map, int a_DataStartX, int a_DataStartY) override;
diff --git a/src/RCONServer.cpp b/src/RCONServer.cpp
index c5dc9b69b..7b1c2dcf6 100644
--- a/src/RCONServer.cpp
+++ b/src/RCONServer.cpp
@@ -317,7 +317,7 @@ bool cRCONServer::cConnection::ProcessPacket(UInt32 a_RequestID, UInt32 a_Packet
UInt32 cRCONServer::cConnection::UIntFromBuffer(const char * a_Buffer)
{
const Byte * Buffer = reinterpret_cast<const Byte *>(a_Buffer);
- return (Buffer[3] << 24) | (Buffer[2] << 16) | (Buffer[1] << 8) | Buffer[0];
+ return static_cast<UInt32>((Buffer[3] << 24) | (Buffer[2] << 16) | (Buffer[1] << 8) | Buffer[0]);
}
diff --git a/src/Root.cpp b/src/Root.cpp
index 3ba391b7f..cfd609c39 100644
--- a/src/Root.cpp
+++ b/src/Root.cpp
@@ -760,7 +760,7 @@ int cRoot::GetVirtualRAMUsage(void)
&t_info_count
))
{
- return (int)(t_info.virtual_size / 1024);
+ return static_cast<int>(t_info.virtual_size / 1024);
}
return -1;
#else
@@ -812,7 +812,7 @@ int cRoot::GetPhysicalRAMUsage(void)
&t_info_count
))
{
- return (int)(t_info.resident_size / 1024);
+ return static_cast<int>(t_info.resident_size / 1024);
}
return -1;
#else
@@ -836,8 +836,8 @@ void cRoot::LogChunkStats(cCommandOutputCallback & a_Output)
{
cWorld * World = itr->second;
int NumInGenerator = World->GetGeneratorQueueLength();
- int NumInSaveQueue = (int)World->GetStorageSaveQueueLength();
- int NumInLoadQueue = (int)World->GetStorageLoadQueueLength();
+ int NumInSaveQueue = static_cast<int>(World->GetStorageSaveQueueLength());
+ int NumInLoadQueue = static_cast<int>(World->GetStorageLoadQueueLength());
int NumValid = 0;
int NumDirty = 0;
int NumInLighting = 0;
@@ -849,7 +849,7 @@ void cRoot::LogChunkStats(cCommandOutputCallback & a_Output)
a_Output.Out(" Num chunks in generator queue: %d", NumInGenerator);
a_Output.Out(" Num chunks in storage load queue: %d", NumInLoadQueue);
a_Output.Out(" Num chunks in storage save queue: %d", NumInSaveQueue);
- int Mem = NumValid * sizeof(cChunk);
+ int Mem = NumValid * static_cast<int>(sizeof(cChunk));
a_Output.Out(" Memory used by chunks: %d KiB (%d MiB)", (Mem + 1023) / 1024, (Mem + 1024 * 1024 - 1) / (1024 * 1024));
a_Output.Out(" Per-chunk memory size breakdown:");
a_Output.Out(" block types: " SIZE_T_FMT_PRECISION(6) " bytes (" SIZE_T_FMT_PRECISION(3) " KiB)", sizeof(cChunkDef::BlockTypes), (sizeof(cChunkDef::BlockTypes) + 1023) / 1024);
diff --git a/src/Simulator/CMakeLists.txt b/src/Simulator/CMakeLists.txt
index 5ac39bb0f..966acd264 100644
--- a/src/Simulator/CMakeLists.txt
+++ b/src/Simulator/CMakeLists.txt
@@ -35,7 +35,7 @@ SET (HDRS
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")
- set_source_files_properties(IncrementalRedstoneSimulator.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=conversion -Wno-error=old-style-cast")
+ set_source_files_properties(IncrementalRedstoneSimulator.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=conversion ")
endif()
if(NOT MSVC)
diff --git a/src/Simulator/FireSimulator.cpp b/src/Simulator/FireSimulator.cpp
index e447437d4..b1d36d526 100644
--- a/src/Simulator/FireSimulator.cpp
+++ b/src/Simulator/FireSimulator.cpp
@@ -70,8 +70,8 @@ cFireSimulator::cFireSimulator(cWorld & a_World, cIniFile & a_IniFile) :
cSimulator(a_World)
{
// Read params from the ini file:
- m_BurnStepTimeFuel = a_IniFile.GetValueSetI("FireSimulator", "BurnStepTimeFuel", 500);
- m_BurnStepTimeNonfuel = a_IniFile.GetValueSetI("FireSimulator", "BurnStepTimeNonfuel", 100);
+ m_BurnStepTimeFuel = static_cast<unsigned>(a_IniFile.GetValueSetI("FireSimulator", "BurnStepTimeFuel", 500));
+ m_BurnStepTimeNonfuel = static_cast<unsigned>(a_IniFile.GetValueSetI("FireSimulator", "BurnStepTimeNonfuel", 100));
m_Flammability = a_IniFile.GetValueSetI("FireSimulator", "Flammability", 50);
m_ReplaceFuelChance = a_IniFile.GetValueSetI("FireSimulator", "ReplaceFuelChance", 50000);
}
@@ -265,7 +265,7 @@ int cFireSimulator::GetBurnStepTime(cChunk * a_Chunk, int a_RelX, int a_RelY, in
}
if (IsFuel(BlockBelow))
{
- return m_BurnStepTimeFuel;
+ return static_cast<int>(m_BurnStepTimeFuel);
}
IsBlockBelowSolid = cBlockInfo::IsSolid(BlockBelow);
}
@@ -278,7 +278,7 @@ int cFireSimulator::GetBurnStepTime(cChunk * a_Chunk, int a_RelX, int a_RelY, in
{
if (IsFuel(BlockType))
{
- return m_BurnStepTimeFuel;
+ return static_cast<int>(m_BurnStepTimeFuel);
}
}
} // for i - gCrossCoords[]
@@ -291,7 +291,7 @@ int cFireSimulator::GetBurnStepTime(cChunk * a_Chunk, int a_RelX, int a_RelY, in
a_Chunk->SetBlock(a_RelX, a_RelY, a_RelZ, E_BLOCK_AIR, 0);
return 0;
}
- return m_BurnStepTimeNonfuel;
+ return static_cast<int>(m_BurnStepTimeNonfuel);
}
diff --git a/src/Simulator/FluidSimulator.cpp b/src/Simulator/FluidSimulator.cpp
index ecd74ee52..d2ca22775 100644
--- a/src/Simulator/FluidSimulator.cpp
+++ b/src/Simulator/FluidSimulator.cpp
@@ -160,10 +160,10 @@ Direction cFluidSimulator::GetFlowingDirection(int a_X, int a_Y, int a_Z, bool a
for (std::vector<Vector3i *>::iterator it = Points.begin(); it < Points.end(); ++it)
{
Vector3i *Pos = (*it);
- char BlockID = m_World.GetBlock(Pos->x, Pos->y, Pos->z);
+ BLOCKTYPE BlockID = m_World.GetBlock(Pos->x, Pos->y, Pos->z);
if (IsAllowedBlock(BlockID))
{
- char Meta = m_World.GetBlockMeta(Pos->x, Pos->y, Pos->z);
+ NIBBLETYPE Meta = m_World.GetBlockMeta(Pos->x, Pos->y, Pos->z);
if (Meta > LowestPoint)
{
diff --git a/src/Simulator/IncrementalRedstoneSimulator.cpp b/src/Simulator/IncrementalRedstoneSimulator.cpp
index 74aa069a1..a23ee8ec2 100644
--- a/src/Simulator/IncrementalRedstoneSimulator.cpp
+++ b/src/Simulator/IncrementalRedstoneSimulator.cpp
@@ -948,7 +948,7 @@ void cIncrementalRedstoneSimulator::HandleTNT(int a_RelBlockX, int a_RelBlockY,
if (AreCoordsPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ))
{
- m_Chunk->BroadcastSoundEffect("game.tnt.primed", (double)BlockX, (double)a_RelBlockY, (double)BlockZ, 0.5f, 0.6f);
+ m_Chunk->BroadcastSoundEffect("game.tnt.primed", static_cast<double>(BlockX), static_cast<double>(a_RelBlockY), static_cast<double>(BlockZ), 0.5f, 0.6f);
m_Chunk->SetBlock(a_RelBlockX, a_RelBlockY, a_RelBlockZ, E_BLOCK_AIR, 0);
this->m_World.SpawnPrimedTNT(BlockX + 0.5, a_RelBlockY + 0.5, BlockZ + 0.5); // 80 ticks to boom
}
@@ -1159,7 +1159,7 @@ void cIncrementalRedstoneSimulator::HandlePressurePlate(int a_RelBlockX, int a_R
case E_BLOCK_STONE_PRESSURE_PLATE:
{
// MCS feature - stone pressure plates can only be triggered by players :D
- cPlayer * a_Player = this->m_World.FindClosestPlayer(Vector3f(BlockX + 0.5f, (float)a_RelBlockY, BlockZ + 0.5f), 0.5f, false);
+ cPlayer * a_Player = this->m_World.FindClosestPlayer(Vector3f(BlockX + 0.5f, static_cast<float>(a_RelBlockY), BlockZ + 0.5f), 0.5f, false);
if (a_Player != nullptr)
{
@@ -1191,7 +1191,7 @@ void cIncrementalRedstoneSimulator::HandlePressurePlate(int a_RelBlockX, int a_R
virtual bool Item(cEntity * a_Entity) override
{
Vector3f EntityPos = a_Entity->GetPosition();
- Vector3f BlockPos(m_X + 0.5f, (float)m_Y, m_Z + 0.5f);
+ Vector3f BlockPos(m_X + 0.5f, static_cast<float>(m_Y), m_Z + 0.5f);
double Distance = (EntityPos - BlockPos).Length();
if (Distance <= 0.5)
@@ -1203,7 +1203,7 @@ void cIncrementalRedstoneSimulator::HandlePressurePlate(int a_RelBlockX, int a_R
bool GetPowerLevel(unsigned char & a_PowerLevel) const
{
- a_PowerLevel = std::min(m_NumberOfEntities, MAX_POWER_LEVEL);
+ a_PowerLevel = static_cast<unsigned char>(std::min(m_NumberOfEntities, MAX_POWER_LEVEL));
return (a_PowerLevel > 0);
}
@@ -1224,7 +1224,7 @@ void cIncrementalRedstoneSimulator::HandlePressurePlate(int a_RelBlockX, int a_R
{
if (Meta == E_META_PRESSURE_PLATE_RAISED)
{
- m_Chunk->BroadcastSoundEffect("random.click", (double)BlockX + 0.5, (double)a_RelBlockY + 0.1, (double)BlockZ + 0.5, 0.3F, 0.5F);
+ m_Chunk->BroadcastSoundEffect("random.click", static_cast<double>(BlockX) + 0.5, static_cast<double>(a_RelBlockY) + 0.1, static_cast<double>(BlockZ) + 0.5, 0.3F, 0.5F);
}
m_Chunk->SetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ, E_META_PRESSURE_PLATE_DEPRESSED);
SetAllDirsAsPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, Power);
@@ -1234,7 +1234,7 @@ void cIncrementalRedstoneSimulator::HandlePressurePlate(int a_RelBlockX, int a_R
{
if (Meta == E_META_PRESSURE_PLATE_DEPRESSED)
{
- m_Chunk->BroadcastSoundEffect("random.click", (double)BlockX + 0.5, (double)a_RelBlockY + 0.1, (double)BlockZ + 0.5, 0.3F, 0.6F);
+ m_Chunk->BroadcastSoundEffect("random.click", static_cast<double>(BlockX) + 0.5, static_cast<double>(a_RelBlockY) + 0.1, static_cast<double>(BlockZ) + 0.5, 0.3F, 0.6F);
}
m_Chunk->SetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ, E_META_PRESSURE_PLATE_RAISED);
SetSourceUnpowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, m_Chunk);
@@ -1259,7 +1259,7 @@ void cIncrementalRedstoneSimulator::HandlePressurePlate(int a_RelBlockX, int a_R
virtual bool Item(cEntity * a_Entity) override
{
Vector3f EntityPos = a_Entity->GetPosition();
- Vector3f BlockPos(m_X + 0.5f, (float)m_Y, m_Z + 0.5f);
+ Vector3f BlockPos(m_X + 0.5f, static_cast<float>(m_Y), m_Z + 0.5f);
double Distance = (EntityPos - BlockPos).Length();
if (Distance <= 0.5)
@@ -1271,7 +1271,7 @@ void cIncrementalRedstoneSimulator::HandlePressurePlate(int a_RelBlockX, int a_R
bool GetPowerLevel(unsigned char & a_PowerLevel) const
{
- a_PowerLevel = std::min((int)ceil(m_NumberOfEntities / 10.f), MAX_POWER_LEVEL);
+ a_PowerLevel = static_cast<Byte>(std::min(static_cast<int>(ceil(m_NumberOfEntities / 10.f)), MAX_POWER_LEVEL));
return (a_PowerLevel > 0);
}
@@ -1292,7 +1292,7 @@ void cIncrementalRedstoneSimulator::HandlePressurePlate(int a_RelBlockX, int a_R
{
if (Meta == E_META_PRESSURE_PLATE_RAISED)
{
- m_Chunk->BroadcastSoundEffect("random.click", (double)BlockX + 0.5, (double)a_RelBlockY + 0.1, (double)BlockZ + 0.5, 0.3F, 0.5F);
+ m_Chunk->BroadcastSoundEffect("random.click", static_cast<double>(BlockX) + 0.5, static_cast<double>(a_RelBlockY) + 0.1, static_cast<double>(BlockZ) + 0.5, 0.3F, 0.5F);
}
m_Chunk->SetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ, E_META_PRESSURE_PLATE_DEPRESSED);
SetAllDirsAsPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, Power);
@@ -1302,7 +1302,7 @@ void cIncrementalRedstoneSimulator::HandlePressurePlate(int a_RelBlockX, int a_R
{
if (Meta == E_META_PRESSURE_PLATE_DEPRESSED)
{
- m_Chunk->BroadcastSoundEffect("random.click", (double)BlockX + 0.5, (double)a_RelBlockY + 0.1, (double)BlockZ + 0.5, 0.3F, 0.6F);
+ m_Chunk->BroadcastSoundEffect("random.click", static_cast<double>(BlockX) + 0.5, static_cast<double>(a_RelBlockY) + 0.1, static_cast<double>(BlockZ) + 0.5, 0.3F, 0.6F);
}
m_Chunk->SetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ, E_META_PRESSURE_PLATE_RAISED);
SetSourceUnpowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, m_Chunk);
@@ -1327,7 +1327,7 @@ void cIncrementalRedstoneSimulator::HandlePressurePlate(int a_RelBlockX, int a_R
virtual bool Item(cEntity * a_Entity) override
{
Vector3f EntityPos = a_Entity->GetPosition();
- Vector3f BlockPos(m_X + 0.5f, (float)m_Y, m_Z + 0.5f);
+ Vector3f BlockPos(m_X + 0.5f, static_cast<float>(m_Y), m_Z + 0.5f);
double Distance = (EntityPos - BlockPos).Length();
if (Distance <= 0.5)
@@ -1359,7 +1359,7 @@ void cIncrementalRedstoneSimulator::HandlePressurePlate(int a_RelBlockX, int a_R
{
if (Meta == E_META_PRESSURE_PLATE_RAISED)
{
- m_Chunk->BroadcastSoundEffect("random.click", (double)BlockX + 0.5, (double)a_RelBlockY + 0.1, (double)BlockZ + 0.5, 0.3F, 0.5F);
+ m_Chunk->BroadcastSoundEffect("random.click", static_cast<double>(BlockX) + 0.5, static_cast<double>(a_RelBlockY) + 0.1, static_cast<double>(BlockZ) + 0.5, 0.3F, 0.5F);
}
m_Chunk->SetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ, E_META_PRESSURE_PLATE_DEPRESSED);
SetAllDirsAsPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ);
@@ -1369,7 +1369,7 @@ void cIncrementalRedstoneSimulator::HandlePressurePlate(int a_RelBlockX, int a_R
{
if (Meta == E_META_PRESSURE_PLATE_DEPRESSED)
{
- m_Chunk->BroadcastSoundEffect("random.click", (double)BlockX + 0.5, (double)a_RelBlockY + 0.1, (double)BlockZ + 0.5, 0.3F, 0.6F);
+ m_Chunk->BroadcastSoundEffect("random.click", static_cast<double>(BlockX) + 0.5, static_cast<double>(a_RelBlockY) + 0.1, static_cast<double>(BlockZ) + 0.5, 0.3F, 0.6F);
}
m_Chunk->SetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ, E_META_PRESSURE_PLATE_RAISED);
SetSourceUnpowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, m_Chunk);
@@ -1475,7 +1475,7 @@ void cIncrementalRedstoneSimulator::HandleTrappedChest(int a_RelBlockX, int a_Re
unsigned char GetPowerLevel(void) const
{
- return std::min(m_NumberOfPlayers, MAX_POWER_LEVEL);
+ return static_cast<unsigned char>(std::min(m_NumberOfPlayers, MAX_POWER_LEVEL));
}
private:
diff --git a/src/StringCompression.cpp b/src/StringCompression.cpp
index af9f1687f..dd22dd4d4 100644
--- a/src/StringCompression.cpp
+++ b/src/StringCompression.cpp
@@ -13,13 +13,13 @@
/// Compresses a_Data into a_Compressed; returns Z_XXX error constants same as zlib's compress2()
int CompressString(const char * a_Data, size_t a_Length, AString & a_Compressed, int a_Factor)
{
- uLongf CompressedSize = compressBound((uLong)a_Length);
+ uLongf CompressedSize = compressBound(static_cast<uLong>(a_Length));
// 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)
a_Compressed.resize(CompressedSize);
- int errorcode = compress2((Bytef*)a_Compressed.data(), &CompressedSize, (const Bytef *)a_Data, (uLong)a_Length, a_Factor);
+ 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)
{
return errorcode;
@@ -39,8 +39,8 @@ int UncompressString(const char * a_Data, size_t a_Length, AString & a_Uncompres
// 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)
a_Uncompressed.resize(a_UncompressedSize);
- uLongf UncompressedSize = (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((Bytef*)a_Uncompressed.data(), &UncompressedSize, (const Bytef*)a_Data, (uLong)a_Length);
+ 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));
if (errorcode != Z_OK)
{
return errorcode;
@@ -62,9 +62,9 @@ int CompressStringGZIP(const char * a_Data, size_t a_Length, AString & a_Compres
char Buffer[64 KiB];
z_stream strm;
memset(&strm, 0, sizeof(strm));
- strm.next_in = (Bytef *)a_Data;
- strm.avail_in = (uInt)a_Length;
- strm.next_out = (Bytef *)Buffer;
+ strm.next_in = reinterpret_cast<Bytef *>(const_cast<char *>(a_Data));
+ strm.avail_in = static_cast<uInt>(a_Length);
+ strm.next_out = reinterpret_cast<Bytef *>(Buffer);
strm.avail_out = sizeof(Buffer);
int res = deflateInit2(&strm, 9, Z_DEFLATED, 31, 9, Z_DEFAULT_STRATEGY);
@@ -83,7 +83,7 @@ int CompressStringGZIP(const char * a_Data, size_t a_Length, AString & a_Compres
{
// Some data has been compressed. Consume the buffer and continue compressing
a_Compressed.append(Buffer, sizeof(Buffer) - strm.avail_out);
- strm.next_out = (Bytef *)Buffer;
+ strm.next_out = reinterpret_cast<Bytef *>(Buffer);
strm.avail_out = sizeof(Buffer);
if (strm.avail_in == 0)
{
@@ -126,9 +126,9 @@ extern int UncompressStringGZIP(const char * a_Data, size_t a_Length, AString &
char Buffer[64 KiB];
z_stream strm;
memset(&strm, 0, sizeof(strm));
- strm.next_in = (Bytef *)a_Data;
- strm.avail_in = (uInt)a_Length;
- strm.next_out = (Bytef *)Buffer;
+ strm.next_in = reinterpret_cast<Bytef *>(const_cast<char *>(a_Data));
+ strm.avail_in = static_cast<uInt>(a_Length);
+ strm.next_out = reinterpret_cast<Bytef *>(Buffer);
strm.avail_out = sizeof(Buffer);
int res = inflateInit2(&strm, 31); // Force GZIP decoding
@@ -147,7 +147,7 @@ extern int UncompressStringGZIP(const char * a_Data, size_t a_Length, AString &
{
// Some data has been uncompressed. Consume the buffer and continue uncompressing
a_Uncompressed.append(Buffer, sizeof(Buffer) - strm.avail_out);
- strm.next_out = (Bytef *)Buffer;
+ strm.next_out = reinterpret_cast<Bytef *>(Buffer);
strm.avail_out = sizeof(Buffer);
if (strm.avail_in == 0)
{
@@ -188,9 +188,9 @@ extern int InflateString(const char * a_Data, size_t a_Length, AString & a_Uncom
char Buffer[64 KiB];
z_stream strm;
memset(&strm, 0, sizeof(strm));
- strm.next_in = (Bytef *)a_Data;
- strm.avail_in = (uInt)a_Length;
- strm.next_out = (Bytef *)Buffer;
+ strm.next_in = reinterpret_cast<Bytef *>(const_cast<char *>(a_Data));
+ strm.avail_in = static_cast<uInt>(a_Length);
+ strm.next_out = reinterpret_cast<Bytef *>(Buffer);
strm.avail_out = sizeof(Buffer);
int res = inflateInit(&strm); // Force GZIP decoding
@@ -209,7 +209,7 @@ extern int InflateString(const char * a_Data, size_t a_Length, AString & a_Uncom
{
// Some data has been uncompressed. Consume the buffer and continue uncompressing
a_Uncompressed.append(Buffer, sizeof(Buffer) - strm.avail_out);
- strm.next_out = (Bytef *)Buffer;
+ strm.next_out = reinterpret_cast<Bytef *>(Buffer);
strm.avail_out = sizeof(Buffer);
if (strm.avail_in == 0)
{
diff --git a/src/StringUtils.cpp b/src/StringUtils.cpp
index 12bd3ada1..34e25f379 100644
--- a/src/StringUtils.cpp
+++ b/src/StringUtils.cpp
@@ -320,8 +320,8 @@ size_t RateCompareString(const AString & s1, const AString & s2)
for (size_t i = 0; i < s1Length; i++)
{
- char c1 = (char)toupper(s1[i]);
- char c2 = (char)toupper(s2[i]);
+ char c1 = static_cast<char>(toupper(s1[i]));
+ char c2 = static_cast<char>(toupper(s2[i]));
if (c1 == c2)
{
++MatchedLetters;
@@ -360,12 +360,12 @@ AString & RawBEToUTF8(const char * a_RawData, size_t a_NumShorts, AString & a_UT
int c = GetBEShort(&a_RawData[i * 2]);
if (c < 0x80)
{
- a_UTF8.push_back((char)c);
+ a_UTF8.push_back(static_cast<char>(c));
}
else if (c < 0x800)
{
- a_UTF8.push_back((char)(192 + c / 64));
- a_UTF8.push_back((char)(128 + c % 64));
+ a_UTF8.push_back(static_cast<char>(192 + c / 64));
+ a_UTF8.push_back(static_cast<char>(128 + c % 64));
}
else if (c - 0xd800 < 0x800)
{
@@ -505,7 +505,7 @@ AString UTF8ToRawBEUTF16(const char * a_UTF8, size_t a_UTF8Length)
AString UTF16;
UTF16.reserve(a_UTF8Length * 3);
- const unsigned char * source = (const unsigned char *)a_UTF8;
+ const unsigned char * source = reinterpret_cast<const unsigned char *>(a_UTF8);
const unsigned char * sourceEnd = source + a_UTF8Length;
const int halfShift = 10; // used for shifting by 10 bits
const unsigned int halfBase = 0x0010000UL;
@@ -545,14 +545,14 @@ AString UTF8ToRawBEUTF16(const char * a_UTF8, size_t a_UTF8Length)
// UTF-16 surrogate values are illegal in UTF-32
ch = ' ';
}
- unsigned short v = htons((unsigned short)ch);
- UTF16.append((const char *)&v, 2);
+ unsigned short v = htons(static_cast<unsigned short>(ch));
+ UTF16.append(reinterpret_cast<const char *>(&v), 2);
}
else if (ch > UNI_MAX_UTF16)
{
// Invalid value, replace with a space
unsigned short v = htons(' ');
- UTF16.append((const char *)&v, 2);
+ UTF16.append(reinterpret_cast<const char *>(&v), 2);
}
else
{
@@ -560,8 +560,8 @@ AString UTF8ToRawBEUTF16(const char * a_UTF8, size_t a_UTF8Length)
ch -= halfBase;
unsigned short v1 = htons((ch >> halfShift) + UNI_SUR_HIGH_START);
unsigned short v2 = htons((ch & halfMask) + UNI_SUR_LOW_START);
- UTF16.append((const char *)&v1, 2);
- UTF16.append((const char *)&v2, 2);
+ UTF16.append(reinterpret_cast<const char *>(&v1), 2);
+ UTF16.append(reinterpret_cast<const char *>(&v2), 2);
}
}
return UTF16;
@@ -620,9 +620,9 @@ AString & CreateHexDump(AString & a_Out, const void * a_Data, size_t a_Size, siz
}
#ifdef _MSC_VER
// MSVC provides a "secure" version of sprintf()
- int Count = sprintf_s(line, sizeof(line), "%08x:", (unsigned)i);
+ int Count = sprintf_s(line, sizeof(line), "%08x:", static_cast<unsigned>(i));
#else
- int Count = sprintf(line, "%08x:", (unsigned)i);
+ int Count = sprintf(line, "%08x:", static_cast<unsigned>(i));
#endif
// Remove the terminating nullptr / leftover garbage in line, after the sprintf-ed value
memset(line + Count, 32, sizeof(line) - static_cast<size_t>(Count));
@@ -870,24 +870,24 @@ AString Base64Encode(const AString & a_Input)
for (size_t i = 0; i < size_full24; i += 3)
{
- output[output_index++] = BASE64[(unsigned char)a_Input[i] >> 2];
- output[output_index++] = BASE64[((unsigned char)a_Input[i] << 4 | (unsigned char)a_Input[i + 1] >> 4) & 63];
- output[output_index++] = BASE64[((unsigned char)a_Input[i + 1] << 2 | (unsigned char)a_Input[i + 2] >> 6) & 63];
- output[output_index++] = BASE64[(unsigned char)a_Input[i + 2] & 63];
+ output[output_index++] = BASE64[static_cast<unsigned char>(a_Input[i]) >> 2];
+ output[output_index++] = BASE64[(static_cast<unsigned char>(a_Input[i]) << 4 | static_cast<unsigned char>(a_Input[i + 1]) >> 4) & 63];
+ output[output_index++] = BASE64[(static_cast<unsigned char>(a_Input[i + 1]) << 2 | static_cast<unsigned char>(a_Input[i + 2]) >> 6) & 63];
+ output[output_index++] = BASE64[static_cast<unsigned char>(a_Input[i + 2]) & 63];
}
if (size_full24 < a_Input.size())
{
- output[output_index++] = BASE64[(unsigned char)a_Input[size_full24] >> 2];
+ output[output_index++] = BASE64[static_cast<unsigned char>(a_Input[size_full24]) >> 2];
if (size_full24 + 1 == a_Input.size())
{
- output[output_index++] = BASE64[((unsigned char)a_Input[size_full24] << 4) & 63];
+ output[output_index++] = BASE64[(static_cast<unsigned char>(a_Input[size_full24]) << 4) & 63];
output[output_index++] = '=';
}
else
{
- output[output_index++] = BASE64[((unsigned char)a_Input[size_full24] << 4 | (unsigned char)a_Input[size_full24 + 1] >> 4) & 63];
- output[output_index++] = BASE64[((unsigned char)a_Input[size_full24 + 1] << 2) & 63];
+ output[output_index++] = BASE64[(static_cast<unsigned char>(a_Input[size_full24]) << 4 | static_cast<unsigned char>(a_Input[size_full24 + 1]) >> 4) & 63];
+ output[output_index++] = BASE64[(static_cast<unsigned char>(a_Input[size_full24 + 1]) << 2) & 63];
}
output[output_index++] = '=';
@@ -903,7 +903,7 @@ AString Base64Encode(const AString & a_Input)
short GetBEShort(const char * a_Mem)
{
- const Byte * Bytes = (const Byte *)a_Mem;
+ const Byte * Bytes = reinterpret_cast<const Byte *>(a_Mem);
return static_cast<short>((Bytes[0] << 8) | Bytes[1]);
}
@@ -913,7 +913,7 @@ short GetBEShort(const char * a_Mem)
int GetBEInt(const char * a_Mem)
{
- const Byte * Bytes = (const Byte *)a_Mem;
+ const Byte * Bytes = reinterpret_cast<const Byte *>(a_Mem);
return (Bytes[0] << 24) | (Bytes[1] << 16) | (Bytes[2] << 8) | Bytes[3];
}
diff --git a/src/Tracer.cpp b/src/Tracer.cpp
index b54a50798..17f1bdfbc 100644
--- a/src/Tracer.cpp
+++ b/src/Tracer.cpp
@@ -264,7 +264,7 @@ bool cTracer::Trace(const Vector3f & a_Start, const Vector3f & a_Direction, int
int Normal = GetHitNormal(a_Start, End, pos);
if (Normal > 0)
{
- HitNormal = m_NormalTable()[Normal - 1];
+ HitNormal = m_NormalTable()[static_cast<size_t>(Normal - 1)];
}
return true;
}
@@ -349,7 +349,7 @@ int cTracer::intersect3D_SegmentPlane(const Vector3f & a_Origin, const Vector3f
int cTracer::GetHitNormal(const Vector3f & start, const Vector3f & end, const Vector3i & a_BlockPos)
{
Vector3i SmallBlockPos = a_BlockPos;
- char BlockID = m_World->GetBlock(a_BlockPos.x, a_BlockPos.y, a_BlockPos.z);
+ BLOCKTYPE BlockID = static_cast<BLOCKTYPE>(m_World->GetBlock(a_BlockPos.x, a_BlockPos.y, a_BlockPos.z));
if ((BlockID == E_BLOCK_AIR) || IsBlockWater(BlockID))
{
diff --git a/src/UI/CMakeLists.txt b/src/UI/CMakeLists.txt
index 178498479..b907919c8 100644
--- a/src/UI/CMakeLists.txt
+++ b/src/UI/CMakeLists.txt
@@ -35,9 +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 -Wno-error=old-style-cast")
- set_source_files_properties(Window.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=conversion -Wno-error=switch-enum -Wno-error=sign-conversion -Wno-error=old-style-cast")
- set_source_files_properties(ChestWindow.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=old-style-cast")
+ 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 ")
endif()
if(NOT MSVC)
diff --git a/src/UI/ChestWindow.cpp b/src/UI/ChestWindow.cpp
index 3766b132d..44992453e 100644
--- a/src/UI/ChestWindow.cpp
+++ b/src/UI/ChestWindow.cpp
@@ -26,7 +26,7 @@ cChestWindow::cChestWindow(cChestEntity * a_Chest) :
m_SlotAreas.push_back(new cSlotAreaHotBar(*this));
// Play the opening sound:
- m_World->BroadcastSoundEffect("random.chestopen", (double)m_BlockX, (double)m_BlockY, (double)m_BlockZ, 1, 1);
+ m_World->BroadcastSoundEffect("random.chestopen", static_cast<double>(m_BlockX), static_cast<double>(m_BlockY), static_cast<double>(m_BlockZ), 1, 1);
// Send out the chest-open packet:
m_World->BroadcastBlockAction(m_BlockX, m_BlockY, m_BlockZ, 1, 1, a_Chest->GetBlockType());
@@ -50,7 +50,7 @@ cChestWindow::cChestWindow(cChestEntity * a_PrimaryChest, cChestEntity * a_Secon
m_SlotAreas.push_back(new cSlotAreaHotBar(*this));
// Play the opening sound:
- m_World->BroadcastSoundEffect("random.chestopen", (double)m_BlockX, (double)m_BlockY, (double)m_BlockZ, 1, 1);
+ m_World->BroadcastSoundEffect("random.chestopen", static_cast<double>(m_BlockX), static_cast<double>(m_BlockY), static_cast<double>(m_BlockZ), 1, 1);
// Send out the chest-open packet:
m_World->BroadcastBlockAction(m_BlockX, m_BlockY, m_BlockZ, 1, 1, a_PrimaryChest->GetBlockType());
@@ -65,7 +65,7 @@ cChestWindow::~cChestWindow()
// Send out the chest-close packet:
m_World->BroadcastBlockAction(m_BlockX, m_BlockY, m_BlockZ, 1, 0, m_PrimaryChest->GetBlockType());
- m_World->BroadcastSoundEffect("random.chestclosed", (double)m_BlockX, (double)m_BlockY, (double)m_BlockZ, 1, 1);
+ m_World->BroadcastSoundEffect("random.chestclosed", static_cast<double>(m_BlockX), static_cast<double>(m_BlockY), static_cast<double>(m_BlockZ), 1, 1);
}
diff --git a/src/UI/SlotArea.cpp b/src/UI/SlotArea.cpp
index 5b58b18b6..478c004fb 100644
--- a/src/UI/SlotArea.cpp
+++ b/src/UI/SlotArea.cpp
@@ -116,7 +116,7 @@ void cSlotArea::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickA
{
DraggingItem = Slot.CopyOne(); // Obtain copy of slot to preserve lore, enchantments, etc.
- DraggingItem.m_ItemCount = (char)(((float)Slot.m_ItemCount) / 2.f + 0.5f);
+ DraggingItem.m_ItemCount = static_cast<char>(static_cast<float>(Slot.m_ItemCount) / 2.f + 0.5f);
Slot.m_ItemCount -= DraggingItem.m_ItemCount;
if (Slot.m_ItemCount <= 0)
@@ -173,10 +173,10 @@ void cSlotArea::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickA
ASSERT(!"Bad item stack size - where did we get more items in a slot than allowed?");
FreeSlots = 0;
}
- int Filling = (FreeSlots > DraggingItem.m_ItemCount) ? DraggingItem.m_ItemCount : FreeSlots;
+ char Filling = static_cast<char>((FreeSlots > DraggingItem.m_ItemCount) ? DraggingItem.m_ItemCount : FreeSlots);
- Slot.m_ItemCount += (char)Filling;
- DraggingItem.m_ItemCount -= (char)Filling;
+ Slot.m_ItemCount += Filling;
+ DraggingItem.m_ItemCount -= Filling;
if (DraggingItem.m_ItemCount <= 0)
{
DraggingItem.Empty();
@@ -306,7 +306,7 @@ void cSlotArea::NumberClicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_
return;
}
- int HotbarSlot = (int)a_ClickAction - (int)caNumber1;
+ int HotbarSlot = static_cast<int>(a_ClickAction - caNumber1);
cItem ItemInHotbar(a_Player.GetInventory().GetHotbarSlot(HotbarSlot));
cItem ItemInSlot(*GetSlot(a_SlotNum, a_Player));
@@ -980,13 +980,13 @@ void cSlotAreaAnvil::OnTakeResult(cPlayer & a_Player)
{
SetSlot(1, a_Player, cItem());
}
- m_ParentWindow.SetProperty(0, m_MaximumCost, a_Player);
+ m_ParentWindow.SetProperty(0, static_cast<short>(m_MaximumCost), a_Player);
m_MaximumCost = 0;
- ((cAnvilWindow*)&m_ParentWindow)->SetRepairedItemName("", nullptr);
+ reinterpret_cast<cAnvilWindow &>(m_ParentWindow).SetRepairedItemName("", nullptr);
int PosX, PosY, PosZ;
- ((cAnvilWindow*)&m_ParentWindow)->GetBlockPos(PosX, PosY, PosZ);
+ reinterpret_cast<cAnvilWindow &>(m_ParentWindow).GetBlockPos(PosX, PosY, PosZ);
BLOCKTYPE Block;
NIBBLETYPE BlockMeta;
@@ -1002,13 +1002,13 @@ void cSlotAreaAnvil::OnTakeResult(cPlayer & a_Player)
if (AnvilDamage > 2)
{
// Anvil will break
- a_Player.GetWorld()->SetBlock(PosX, PosY, PosZ, E_BLOCK_AIR, (NIBBLETYPE)0);
+ a_Player.GetWorld()->SetBlock(PosX, PosY, PosZ, E_BLOCK_AIR, 0);
a_Player.GetWorld()->BroadcastSoundParticleEffect(1020, PosX, PosY, PosZ, 0);
a_Player.CloseWindow(false);
}
else
{
- a_Player.GetWorld()->SetBlockMeta(PosX, PosY, PosZ, Orientation | (AnvilDamage << 2));
+ a_Player.GetWorld()->SetBlockMeta(PosX, PosY, PosZ, static_cast<NIBBLETYPE>(Orientation | (AnvilDamage << 2)));
a_Player.GetWorld()->BroadcastSoundParticleEffect(1021, PosX, PosY, PosZ, 0);
}
}
@@ -1075,7 +1075,7 @@ void cSlotAreaAnvil::UpdateResult(cPlayer & a_Player)
if (Input.IsDamageable() && cItemHandler::GetItemHandler(Input)->CanRepairWithRawMaterial(SecondInput.m_ItemType))
{
// Tool and armor repair with special item (iron / gold / diamond / ...)
- int DamageDiff = std::min((int)Input.m_ItemDamage, (int)Input.GetMaxDamage() / 4);
+ int DamageDiff = std::min(static_cast<int>(Input.m_ItemDamage), static_cast<int>(Input.GetMaxDamage()) / 4);
if (DamageDiff <= 0)
{
// No enchantment
@@ -1089,12 +1089,12 @@ void cSlotAreaAnvil::UpdateResult(cPlayer & a_Player)
while ((DamageDiff > 0) && (x < SecondInput.m_ItemCount))
{
Input.m_ItemDamage -= DamageDiff;
- NeedExp += std::max(1, DamageDiff / 100) + (int)Input.m_Enchantments.Count();
- DamageDiff = std::min((int)Input.m_ItemDamage, (int)Input.GetMaxDamage() / 4);
+ NeedExp += std::max(1, DamageDiff / 100) + static_cast<int>(Input.m_Enchantments.Count());
+ DamageDiff = std::min(static_cast<int>(Input.m_ItemDamage), static_cast<int>(Input.GetMaxDamage()) / 4);
++x;
}
- m_StackSizeToBeUsedInRepair = x;
+ m_StackSizeToBeUsedInRepair = static_cast<char>(x);
}
else
{
@@ -1122,7 +1122,7 @@ void cSlotAreaAnvil::UpdateResult(cPlayer & a_Player)
if (NewItemDamage < Input.m_ItemDamage)
{
- Input.m_ItemDamage = NewItemDamage;
+ Input.m_ItemDamage = static_cast<short>(NewItemDamage);
NeedExp += std::max(1, Damage / 100);
}
}
@@ -1132,7 +1132,7 @@ void cSlotAreaAnvil::UpdateResult(cPlayer & a_Player)
}
int NameChangeExp = 0;
- const AString & RepairedItemName = ((cAnvilWindow*)&m_ParentWindow)->GetRepairedItemName();
+ const AString & RepairedItemName = reinterpret_cast<cAnvilWindow*>(&m_ParentWindow)->GetRepairedItemName();
if (RepairedItemName.empty())
{
// Remove custom name
@@ -1188,7 +1188,7 @@ void cSlotAreaAnvil::UpdateResult(cPlayer & a_Player)
}
SetSlot(2, a_Player, Input);
- m_ParentWindow.SetProperty(0, m_MaximumCost, a_Player);
+ m_ParentWindow.SetProperty(0, static_cast<Int16>(m_MaximumCost), a_Player);
}
@@ -1569,14 +1569,14 @@ void cSlotAreaEnchanting::UpdateResult(cPlayer & a_Player)
int Bookshelves = std::min(GetBookshelvesCount(a_Player.GetWorld()), 15);
cFastRandom Random;
- int Base = (Random.GenerateRandomInteger(1, 8) + (int)floor((float)Bookshelves / 2) + Random.GenerateRandomInteger(0, Bookshelves));
+ int Base = (Random.GenerateRandomInteger(1, 8) + static_cast<int>(floor(static_cast<float>(Bookshelves / 2)) + Random.GenerateRandomInteger(0, Bookshelves)));
int TopSlot = std::max(Base / 3, 1);
int MiddleSlot = (Base * 2) / 3 + 1;
int BottomSlot = std::max(Base, Bookshelves * 2);
- m_ParentWindow.SetProperty(0, TopSlot, a_Player);
- m_ParentWindow.SetProperty(1, MiddleSlot, a_Player);
- m_ParentWindow.SetProperty(2, BottomSlot, a_Player);
+ m_ParentWindow.SetProperty(0, static_cast<short>(TopSlot), a_Player);
+ m_ParentWindow.SetProperty(1, static_cast<short>(MiddleSlot), a_Player);
+ m_ParentWindow.SetProperty(2, static_cast<short>(BottomSlot), a_Player);
}
else
{
@@ -1803,7 +1803,7 @@ void cSlotAreaFurnace::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a
case caRightClick:
{
DraggingItem = Slot.CopyOne();
- DraggingItem.m_ItemCount = (char)(((float)Slot.m_ItemCount) / 2.f + 0.5f);
+ DraggingItem.m_ItemCount = static_cast<char>(static_cast<float>(Slot.m_ItemCount) / 2.f + 0.5f);
Slot.m_ItemCount -= DraggingItem.m_ItemCount;
if (Slot.m_ItemCount <= 0)
@@ -2241,14 +2241,14 @@ const cItem * cSlotAreaTemporary::GetSlot(int a_SlotNum, cPlayer & a_Player) con
return nullptr;
}
- if (a_SlotNum >= (int)(itr->second.size()))
+ if (a_SlotNum >= static_cast<int>(itr->second.size()))
{
LOGERROR("cSlotAreaTemporary: asking for more slots than actually stored!");
ASSERT(!"cSlotAreaTemporary: asking for more slots than actually stored!");
return nullptr;
}
- return &(itr->second[a_SlotNum]);
+ return &(itr->second[static_cast<size_t>(a_SlotNum)]);
}
@@ -2265,13 +2265,13 @@ void cSlotAreaTemporary::SetSlot(int a_SlotNum, cPlayer & a_Player, const cItem
return;
}
- if (a_SlotNum >= (int)(itr->second.size()))
+ if (a_SlotNum >= static_cast<int>(itr->second.size()))
{
LOGERROR("cSlotAreaTemporary: asking for more slots than actually stored!");
return;
}
- itr->second[a_SlotNum] = a_Item;
+ itr->second[static_cast<size_t>(a_SlotNum)] = a_Item;
}
@@ -2281,7 +2281,7 @@ void cSlotAreaTemporary::SetSlot(int a_SlotNum, cPlayer & a_Player, const cItem
void cSlotAreaTemporary::OnPlayerAdded(cPlayer & a_Player)
{
ASSERT(m_Items.find(a_Player.GetUniqueID()) == m_Items.end()); // The player shouldn't be in the itemmap, otherwise we probably have a leak
- m_Items[a_Player.GetUniqueID()].resize(m_NumSlots); // Make the vector the specified size of empty items
+ m_Items[a_Player.GetUniqueID()].resize(static_cast<size_t>(m_NumSlots)); // Make the vector the specified size of empty items
}
@@ -2311,7 +2311,7 @@ void cSlotAreaTemporary::TossItems(cPlayer & a_Player, int a_Begin, int a_End)
cItems Drops;
for (int i = a_Begin; i < a_End; i++)
{
- cItem & Item = itr->second[i];
+ cItem & Item = itr->second[static_cast<size_t>(i)];
if (!Item.IsEmpty())
{
Drops.push_back(Item);
diff --git a/src/UI/SlotArea.h b/src/UI/SlotArea.h
index 664c6502c..cd340408a 100644
--- a/src/UI/SlotArea.h
+++ b/src/UI/SlotArea.h
@@ -216,7 +216,7 @@ public:
void TossItems(cPlayer & a_Player, int a_Begin, int a_End);
protected:
- typedef std::map<int, std::vector<cItem> > cItemMap; // Maps EntityID -> items
+ typedef std::map<UInt32, std::vector<cItem> > cItemMap; // Maps EntityID -> items
cItemMap m_Items;
diff --git a/src/UI/Window.cpp b/src/UI/Window.cpp
index dbdcbeaa8..d0b963e13 100644
--- a/src/UI/Window.cpp
+++ b/src/UI/Window.cpp
@@ -173,7 +173,7 @@ bool cWindow::IsSlotInPlayerInventory(int a_SlotNum) const
void cWindow::GetSlots(cPlayer & a_Player, cItems & a_Slots) const
{
a_Slots.clear();
- a_Slots.reserve(GetNumSlots());
+ a_Slots.reserve(static_cast<size_t>(GetNumSlots()));
for (cSlotAreas::const_iterator itr = m_SlotAreas.begin(), end = m_SlotAreas.end(); itr != end; ++itr)
{
int NumSlots = (*itr)->GetNumSlots();
@@ -482,7 +482,7 @@ void cWindow::SendSlot(cPlayer & a_Player, cSlotArea * a_SlotArea, int a_Relativ
}
a_Player.GetClientHandle()->SendInventorySlot(
- m_WindowID, a_RelativeSlotNum + SlotBase, *(a_SlotArea->GetSlot(a_RelativeSlotNum, a_Player))
+ m_WindowID, static_cast<short>(a_RelativeSlotNum + SlotBase), *(a_SlotArea->GetSlot(a_RelativeSlotNum, a_Player))
);
}
@@ -593,7 +593,7 @@ void cWindow::OnLeftPaintEnd(cPlayer & a_Player)
const cSlotNums & SlotNums = a_Player.GetInventoryPaintSlots();
cItem ToDistribute(a_Player.GetDraggingItem());
- int ToEachSlot = (int)ToDistribute.m_ItemCount / (int)SlotNums.size();
+ int ToEachSlot = static_cast<int>(ToDistribute.m_ItemCount) / static_cast<int>(SlotNums.size());
int NumDistributed = DistributeItemToSlots(a_Player, ToDistribute, ToEachSlot, SlotNums);
@@ -645,9 +645,9 @@ void cWindow::OnRightPaintEnd(cPlayer & a_Player)
int cWindow::DistributeItemToSlots(cPlayer & a_Player, const cItem & a_Item, int a_NumToEachSlot, const cSlotNums & a_SlotNums)
{
- if ((size_t)(a_Item.m_ItemCount) < a_SlotNums.size())
+ if (static_cast<size_t>(a_Item.m_ItemCount) < a_SlotNums.size())
{
- LOGWARNING("%s: Distributing less items (%d) than slots (" SIZE_T_FMT ")", __FUNCTION__, (int)a_Item.m_ItemCount, a_SlotNums.size());
+ LOGWARNING("%s: Distributing less items (%d) than slots (" SIZE_T_FMT ")", __FUNCTION__, static_cast<int>(a_Item.m_ItemCount), a_SlotNums.size());
// This doesn't seem to happen with the 1.5.1 client, so we don't worry about it for now
return 0;
}
@@ -671,14 +671,14 @@ int cWindow::DistributeItemToSlots(cPlayer & a_Player, const cItem & a_Item, int
{
// Empty, just move all of it there:
cItem ToStore(a_Item);
- ToStore.m_ItemCount = std::min(a_NumToEachSlot, (int)MaxStack);
+ ToStore.m_ItemCount = static_cast<char>(std::min(a_NumToEachSlot, static_cast<int>(MaxStack)));
Area->SetSlot(LocalSlotNum, a_Player, ToStore);
NumDistributed += ToStore.m_ItemCount;
}
else if (AtSlot.IsEqual(a_Item))
{
// Occupied, add and cap at MaxStack:
- int CanStore = std::min(a_NumToEachSlot, (int)MaxStack - AtSlot.m_ItemCount);
+ int CanStore = std::min(a_NumToEachSlot, static_cast<int>(MaxStack) - AtSlot.m_ItemCount);
AtSlot.m_ItemCount += CanStore;
Area->SetSlot(LocalSlotNum, a_Player, AtSlot);
NumDistributed += CanStore;
@@ -717,7 +717,7 @@ void cWindow::BroadcastSlot(cSlotArea * a_Area, int a_LocalSlotNum)
cCSLock Lock(m_CS);
for (cPlayerList::iterator itr = m_OpenedBy.begin(); itr != m_OpenedBy.end(); ++itr)
{
- (*itr)->GetClientHandle()->SendInventorySlot(m_WindowID, SlotNum, *a_Area->GetSlot(a_LocalSlotNum, **itr));
+ (*itr)->GetClientHandle()->SendInventorySlot(m_WindowID, static_cast<short>(SlotNum), *a_Area->GetSlot(a_LocalSlotNum, **itr));
} // for itr - m_OpenedBy[]
}
diff --git a/src/World.cpp b/src/World.cpp
index b152d119a..890d74166 100644
--- a/src/World.cpp
+++ b/src/World.cpp
@@ -326,7 +326,7 @@ void cWorld::InitializeSpawn(void)
}
int ChunkX = 0, ChunkZ = 0;
- cChunkDef::BlockToChunk((int)m_SpawnX, (int)m_SpawnZ, ChunkX, ChunkZ);
+ cChunkDef::BlockToChunk(FloorC(m_SpawnX), FloorC(m_SpawnZ), ChunkX, ChunkZ);
// For the debugging builds, don't make the server build too much world upon start:
#if defined(_DEBUG) || defined(ANDROID_NDK)
@@ -462,7 +462,7 @@ void cWorld::Start(void)
m_IsSugarcaneBonemealable = IniFile.GetValueSetB("Plants", "IsSugarcaneBonemealable", false);
m_IsDeepSnowEnabled = IniFile.GetValueSetB("Physics", "DeepSnow", true);
m_ShouldLavaSpawnFire = IniFile.GetValueSetB("Physics", "ShouldLavaSpawnFire", true);
- int TNTShrapnelLevel = IniFile.GetValueSetI("Physics", "TNTShrapnelLevel", (int)slAll);
+ int TNTShrapnelLevel = IniFile.GetValueSetI("Physics", "TNTShrapnelLevel", static_cast<int>(slAll));
m_bCommandBlocksEnabled = IniFile.GetValueSetB("Mechanics", "CommandBlocksEnabled", false);
m_bEnabledPVP = IniFile.GetValueSetB("Mechanics", "PVPEnabled", true);
m_bUseChatPrefixes = IniFile.GetValueSetB("Mechanics", "UseChatPrefixes", true);
@@ -472,8 +472,8 @@ void cWorld::Start(void)
m_MaxNetherPortalHeight = IniFile.GetValueSetI("Mechanics", "MaxNetherPortalHeight", 21);
m_VillagersShouldHarvestCrops = IniFile.GetValueSetB("Monsters", "VillagersShouldHarvestCrops", true);
m_IsDaylightCycleEnabled = IniFile.GetValueSetB("General", "IsDaylightCycleEnabled", true);
- int GameMode = IniFile.GetValueSetI("General", "Gamemode", (int)m_GameMode);
- int Weather = IniFile.GetValueSetI("General", "Weather", (int)m_Weather);
+ int GameMode = IniFile.GetValueSetI("General", "Gamemode", static_cast<int>(m_GameMode));
+ int Weather = IniFile.GetValueSetI("General", "Weather", static_cast<int>(m_Weather));
if (GetDimension() == dimOverworld)
{
@@ -486,9 +486,9 @@ void cWorld::Start(void)
}
// Adjust the enum-backed variables into their respective bounds:
- m_GameMode = (eGameMode) Clamp(GameMode, (int)gmSurvival, (int)gmSpectator);
- m_TNTShrapnelLevel = (eShrapnelLevel)Clamp(TNTShrapnelLevel, (int)slNone, (int)slAll);
- m_Weather = (eWeather) Clamp(Weather, (int)wSunny, (int)wStorm);
+ m_GameMode = static_cast<eGameMode> (Clamp<int>(GameMode, gmSurvival, gmSpectator));
+ m_TNTShrapnelLevel = static_cast<eShrapnelLevel>(Clamp<int>(TNTShrapnelLevel, slNone, slAll));
+ m_Weather = static_cast<eWeather> (Clamp<int>(Weather, wSunny, wStorm));
InitialiseGeneratorDefaults(IniFile);
InitialiseAndLoadMobSpawningValues(IniFile);
@@ -541,17 +541,19 @@ void cWorld::GenerateRandomSpawn(void)
{
LOGD("Generating random spawnpoint...");
bool foundSpawnPoint = false;
+ int SpawnX = FloorC(m_SpawnX);
+ int SpawnZ = FloorC(m_SpawnZ);
// Look for a spawn point at most 100 chunks away from map center:
for (int i = 0; i < 100; i++)
{
- EMCSBiome biome = GetBiomeAt((int)m_SpawnX, (int)m_SpawnZ);
+ EMCSBiome biome = GetBiomeAt(SpawnX, SpawnZ);
if (
(biome != biOcean) && (biome != biFrozenOcean) && // The biome is acceptable (don't want a small ocean island)
- !IsBlockWaterOrIce(GetBlock((int)m_SpawnX, GetHeight((int)m_SpawnX, (int)m_SpawnZ), (int)m_SpawnZ)) // The terrain is acceptable (don't want to spawn inside a lake / river)
+ !IsBlockWaterOrIce(GetBlock(SpawnX, GetHeight(SpawnX, SpawnZ), SpawnZ)) // The terrain is acceptable (don't want to spawn inside a lake / river)
)
{
- if (CheckPlayerSpawnPoint((int)m_SpawnX, GetHeight((int)m_SpawnX, (int)m_SpawnZ), (int)m_SpawnZ))
+ if (CheckPlayerSpawnPoint(SpawnX, GetHeight(SpawnX, SpawnZ), SpawnZ))
{
// A good spawnpoint was found
foundSpawnPoint = true;
@@ -569,14 +571,14 @@ void cWorld::GenerateRandomSpawn(void)
}
} // for i - 100*
- m_SpawnY = (double)GetHeight((int)m_SpawnX, (int)m_SpawnZ) + 1.6f; // 1.6f to accomodate player height
+ m_SpawnY = static_cast<double>(GetHeight(SpawnX, SpawnZ) + 1.6f); // 1.6f to accomodate player height
if (foundSpawnPoint)
{
- LOGINFO("Generated random spawnpoint position at {%i, %i, %i}", (int)m_SpawnX, (int)m_SpawnY, (int)m_SpawnZ);
+ LOGINFO("Generated random spawnpoint position at {%i, %i, %i}", SpawnX, static_cast<int>(m_SpawnY), SpawnZ);
}
else
{
- LOGINFO("Did not find an acceptable spawnpoint. Generated a random spawnpoint position at {%i, %i, %i}", (int)m_SpawnX, (int)m_SpawnY, (int)m_SpawnZ);
+ LOGINFO("Did not find an acceptable spawnpoint. Generated a random spawnpoint position at {%i, %i, %i}", SpawnX, static_cast<int>(m_SpawnY), SpawnZ);
} // Maybe widen the search instead?
}
@@ -1181,7 +1183,7 @@ void cWorld::DoExplosionAt(double a_ExplosionSize, double a_BlockX, double a_Blo
Vector3d explosion_pos = Vector3d(a_BlockX, a_BlockY, a_BlockZ);
cVector3iArray BlocksAffected;
m_ChunkMap->DoExplosionAt(a_ExplosionSize, a_BlockX, a_BlockY, a_BlockZ, BlocksAffected);
- BroadcastSoundEffect("random.explode", (double)a_BlockX, (double)a_BlockY, (double)a_BlockZ, 1.0f, 0.6f);
+ BroadcastSoundEffect("random.explode", static_cast<double>(a_BlockX), static_cast<double>(a_BlockY), static_cast<double>(a_BlockZ), 1.0f, 0.6f);
{
cCSLock Lock(m_CSPlayers);
@@ -1204,7 +1206,7 @@ void cWorld::DoExplosionAt(double a_ExplosionSize, double a_BlockX, double a_Blo
}
distance_explosion.Normalize();
distance_explosion *= power;
- ch->SendExplosion(a_BlockX, a_BlockY, a_BlockZ, (float)a_ExplosionSize, BlocksAffected, distance_explosion);
+ ch->SendExplosion(a_BlockX, a_BlockY, a_BlockZ, static_cast<float>(a_ExplosionSize), BlocksAffected, distance_explosion);
}
}
}
@@ -1388,7 +1390,7 @@ void cWorld::GrowTreeFromSapling(int a_X, int a_Y, int a_Z, NIBBLETYPE a_Sapling
{
cNoise Noise(m_Generator.GetSeed());
sSetBlockVector Logs, Other;
- auto WorldAge = (int)(std::chrono::duration_cast<cTickTimeLong>(m_WorldAge).count() & 0xffffffff);
+ auto WorldAge = static_cast<int>(std::chrono::duration_cast<cTickTimeLong>(m_WorldAge).count() & 0xffffffff);
switch (a_SaplingMeta & 0x07)
{
case E_META_SAPLING_APPLE: GetAppleTreeImage (a_X, a_Y, a_Z, Noise, WorldAge, Logs, Other); break;
@@ -1425,7 +1427,7 @@ void cWorld::GrowTreeByBiome(int a_X, int a_Y, int a_Z)
{
cNoise Noise(m_Generator.GetSeed());
sSetBlockVector Logs, Other;
- GetTreeImageByBiome(a_X, a_Y, a_Z, Noise, (int)(std::chrono::duration_cast<cTickTimeLong>(m_WorldAge).count() & 0xffffffff), GetBiomeAt(a_X, a_Z), Logs, Other);
+ GetTreeImageByBiome(a_X, a_Y, a_Z, Noise, static_cast<int>(std::chrono::duration_cast<cTickTimeLong>(m_WorldAge).count() & 0xffffffff), GetBiomeAt(a_X, a_Z), Logs, Other);
Other.insert(Other.begin(), Logs.begin(), Logs.end());
Logs.clear();
GrowTreeImage(Other);
@@ -1518,7 +1520,7 @@ bool cWorld::GrowRipePlant(int a_BlockX, int a_BlockY, int a_BlockZ, bool a_IsBy
if (GrowState < 2)
{
GrowState++;
- FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, BlockType, (NIBBLETYPE) (GrowState << 2 | TypeMeta));
+ FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, BlockType, static_cast<NIBBLETYPE>(GrowState << 2 | TypeMeta));
BroadcastSoundParticleEffect(2005, a_BlockX, a_BlockY, a_BlockZ, 0);
}
return GrowState == 2;
@@ -1839,7 +1841,7 @@ NIBBLETYPE cWorld::GetBlockBlockLight(int a_BlockX, int a_BlockY, int a_BlockZ)
bool cWorld::GetBlockTypeMeta(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta)
{
- return m_ChunkMap->GetBlockTypeMeta(a_BlockX, a_BlockY, a_BlockZ, (BLOCKTYPE &)a_BlockType, (NIBBLETYPE &)a_BlockMeta);
+ return m_ChunkMap->GetBlockTypeMeta(a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta);
}
@@ -1875,9 +1877,9 @@ void cWorld::SpawnItemPickups(const cItems & a_Pickups, double a_BlockX, double
continue;
}
- float SpeedX = (float)(a_FlyAwaySpeed * (GetTickRandomNumber(10) - 5));
- float SpeedY = (float)(a_FlyAwaySpeed * GetTickRandomNumber(50));
- float SpeedZ = (float)(a_FlyAwaySpeed * (GetTickRandomNumber(10) - 5));
+ float SpeedX = static_cast<float>(a_FlyAwaySpeed * (GetTickRandomNumber(10) - 5));
+ float SpeedY = static_cast<float>(a_FlyAwaySpeed * GetTickRandomNumber(50));
+ float SpeedZ = static_cast<float>(a_FlyAwaySpeed * (GetTickRandomNumber(10) - 5));
cPickup * Pickup = new cPickup(
a_BlockX, a_BlockY, a_BlockZ,
@@ -1902,7 +1904,7 @@ void cWorld::SpawnItemPickups(const cItems & a_Pickups, double a_BlockX, double
cPickup * Pickup = new cPickup(
a_BlockX, a_BlockY, a_BlockZ,
- *itr, IsPlayerCreated, (float)a_SpeedX, (float)a_SpeedY, (float)a_SpeedZ
+ *itr, IsPlayerCreated, static_cast<float>(a_SpeedX), static_cast<float>(a_SpeedY), static_cast<float>(a_SpeedZ)
);
Pickup->Initialize(*this);
}
@@ -2056,7 +2058,7 @@ void cWorld::BroadcastAttachEntity(const cEntity & a_Entity, const cEntity * a_V
void cWorld::BroadcastBlockAction(int a_BlockX, int a_BlockY, int a_BlockZ, Byte a_Byte1, Byte a_Byte2, BLOCKTYPE a_BlockType, const cClientHandle * a_Exclude)
{
- m_ChunkMap->BroadcastBlockAction(a_BlockX, a_BlockY, a_BlockZ, a_Byte1, a_Byte2, a_BlockType, a_Exclude);
+ m_ChunkMap->BroadcastBlockAction(a_BlockX, a_BlockY, a_BlockZ, static_cast<char>(a_Byte1), static_cast<char>(a_Byte2), a_BlockType, a_Exclude);
}
@@ -2831,7 +2833,7 @@ cPlayer * cWorld::FindClosestPlayer(const Vector3d & a_Pos, float a_SightLimit,
{
if (a_CheckLineOfSight)
{
- if (!LineOfSight.Trace(a_Pos, (Pos - a_Pos), (int)(Pos - a_Pos).Length()))
+ if (!LineOfSight.Trace(a_Pos, (Pos - a_Pos), static_cast<int>((Pos - a_Pos).Length())))
{
ClosestDistance = Distance;
ClosestPlayer = *itr;
@@ -3260,7 +3262,7 @@ int cWorld::GetNumChunks(void) const
void cWorld::GetChunkStats(int & a_NumValid, int & a_NumDirty, int & a_NumInLightingQueue)
{
m_ChunkMap->GetChunkStats(a_NumValid, a_NumDirty);
- a_NumInLightingQueue = (int) m_Lighting.GetQueueLength();
+ a_NumInLightingQueue = static_cast<int>(m_Lighting.GetQueueLength());
}
diff --git a/src/WorldStorage/CMakeLists.txt b/src/WorldStorage/CMakeLists.txt
index 017d85f27..2192564e8 100644
--- a/src/WorldStorage/CMakeLists.txt
+++ b/src/WorldStorage/CMakeLists.txt
@@ -31,15 +31,11 @@ SET (HDRS
)
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
- set_source_files_properties(EnchantmentSerializer.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=old-style-cast")
- set_source_files_properties(FastNBT.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=sign-conversion -Wno-error=old-style-cast")
- set_source_files_properties(FireworksSerializer.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=switch-enum -Wno-error=old-style-cast")
- set_source_files_properties(MapSerializer.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=old-style-cast")
- set_source_files_properties(NBTChunkSerializer.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=switch-enum -Wno-error=sign-conversion -Wno-error=conversion -Wno-error=old-style-cast")
- set_source_files_properties(SchematicFileSerializer.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=shadow -Wno-error=conversion -Wno-error=old-style-cast -Wno-error=global-constructors")
- set_source_files_properties(ScoreboardSerializer.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=old-style-cast")
- 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 -Wno-error=old-style-cast")
- set_source_files_properties(WorldStorage.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=old-style-cast")
+ 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 ")
endif()
if(NOT MSVC)
diff --git a/src/WorldStorage/FastNBT.cpp b/src/WorldStorage/FastNBT.cpp
index 860eb3a4a..35c3ace0b 100644
--- a/src/WorldStorage/FastNBT.cpp
+++ b/src/WorldStorage/FastNBT.cpp
@@ -36,7 +36,7 @@ static const int MAX_LIST_ITEMS = 10000;
// cParsedNBT:
#define NEEDBYTES(N) \
- if (m_Length - m_Pos < (size_t)N) \
+ if (m_Length - m_Pos < static_cast<size_t>(N)) \
{ \
return false; \
}
@@ -90,7 +90,7 @@ bool cParsedNBT::ReadString(size_t & a_StringStart, size_t & a_StringLen)
{
NEEDBYTES(2);
a_StringStart = m_Pos + 2;
- a_StringLen = (size_t)GetBEShort(m_Data + m_Pos);
+ a_StringLen = static_cast<size_t>(GetBEShort(m_Data + m_Pos));
if (a_StringLen > 0xffff)
{
// Suspicious string length
@@ -114,7 +114,7 @@ bool cParsedNBT::ReadCompound(void)
for (;;)
{
NEEDBYTES(1);
- eTagType TagType = (eTagType)(m_Data[m_Pos]);
+ eTagType TagType = static_cast<eTagType>(m_Data[m_Pos]);
m_Pos++;
if (TagType == TAG_End)
{
@@ -123,13 +123,13 @@ bool cParsedNBT::ReadCompound(void)
m_Tags.push_back(cFastNBTTag(TagType, static_cast<int>(ParentIdx), PrevSibling));
if (PrevSibling >= 0)
{
- m_Tags[static_cast<size_t>(PrevSibling)].m_NextSibling = (int)m_Tags.size() - 1;
+ m_Tags[static_cast<size_t>(PrevSibling)].m_NextSibling = static_cast<int>(m_Tags.size()) - 1;
}
else
{
- m_Tags[ParentIdx].m_FirstChild = (int)m_Tags.size() - 1;
+ m_Tags[ParentIdx].m_FirstChild = static_cast<int>(m_Tags.size()) - 1;
}
- PrevSibling = (int)m_Tags.size() - 1;
+ PrevSibling = static_cast<int>(m_Tags.size()) - 1;
RETURN_FALSE_IF_FALSE(ReadString(m_Tags.back().m_NameStart, m_Tags.back().m_NameLength));
RETURN_FALSE_IF_FALSE(ReadTag());
} // while (true)
@@ -349,7 +349,7 @@ cFastNBTWriter::cFastNBTWriter(const AString & a_RootTagName) :
m_Stack[0].m_Type = TAG_Compound;
m_Result.reserve(100 * 1024);
m_Result.push_back(TAG_Compound);
- WriteString(a_RootTagName.data(), (UInt16)a_RootTagName.size());
+ WriteString(a_RootTagName.data(), static_cast<UInt16>(a_RootTagName.size()));
}
@@ -397,12 +397,12 @@ void cFastNBTWriter::BeginList(const AString & a_Name, eTagType a_ChildrenType)
TagCommon(a_Name, TAG_List);
- m_Result.push_back((char)a_ChildrenType);
- m_Result.append(4, (char)0);
+ m_Result.push_back(static_cast<char>(a_ChildrenType));
+ m_Result.append(4, static_cast<char>(0));
++m_CurrentStack;
m_Stack[m_CurrentStack].m_Type = TAG_List;
- m_Stack[m_CurrentStack].m_Pos = (int)m_Result.size() - 4;
+ m_Stack[m_CurrentStack].m_Pos = static_cast<int>(m_Result.size()) - 4;
m_Stack[m_CurrentStack].m_Count = 0;
m_Stack[m_CurrentStack].m_ItemType = a_ChildrenType;
}
diff --git a/src/WorldStorage/MapSerializer.cpp b/src/WorldStorage/MapSerializer.cpp
index d4925dcab..8acfa4696 100644
--- a/src/WorldStorage/MapSerializer.cpp
+++ b/src/WorldStorage/MapSerializer.cpp
@@ -112,7 +112,7 @@ void cMapSerializer::SaveMapToNBT(cFastNBTWriter & a_Writer)
a_Writer.AddInt("zCenter", m_Map->GetCenterZ());
const cMap::cColorList & Data = m_Map->GetData();
- a_Writer.AddByteArray("colors", (char *)Data.data(), Data.size());
+ a_Writer.AddByteArray("colors", reinterpret_cast<const char *>(Data.data()), Data.size());
a_Writer.EndCompound();
}
@@ -132,14 +132,14 @@ bool cMapSerializer::LoadMapFromNBT(const cParsedNBT & a_NBT)
int CurrLine = a_NBT.FindChildByName(Data, "scale");
if ((CurrLine >= 0) && (a_NBT.GetType(CurrLine) == TAG_Byte))
{
- unsigned int Scale = (unsigned int)a_NBT.GetByte(CurrLine);
+ unsigned int Scale = static_cast<unsigned int>(a_NBT.GetByte(CurrLine));
m_Map->SetScale(Scale);
}
CurrLine = a_NBT.FindChildByName(Data, "dimension");
if ((CurrLine >= 0) && (a_NBT.GetType(CurrLine) == TAG_Byte))
{
- eDimension Dimension = (eDimension) a_NBT.GetByte(CurrLine);
+ eDimension Dimension = static_cast<eDimension>(a_NBT.GetByte(CurrLine));
if (Dimension != m_Map->m_World->GetDimension())
{
@@ -151,7 +151,7 @@ bool cMapSerializer::LoadMapFromNBT(const cParsedNBT & a_NBT)
CurrLine = a_NBT.FindChildByName(Data, "width");
if ((CurrLine >= 0) && (a_NBT.GetType(CurrLine) == TAG_Short))
{
- unsigned int Width = (unsigned int)a_NBT.GetShort(CurrLine);
+ unsigned int Width = static_cast<unsigned int>(a_NBT.GetShort(CurrLine));
if (Width != 128)
{
return false;
@@ -162,7 +162,7 @@ bool cMapSerializer::LoadMapFromNBT(const cParsedNBT & a_NBT)
CurrLine = a_NBT.FindChildByName(Data, "height");
if ((CurrLine >= 0) && (a_NBT.GetType(CurrLine) == TAG_Short))
{
- unsigned int Height = (unsigned int)a_NBT.GetShort(CurrLine);
+ unsigned int Height = static_cast<unsigned int>(a_NBT.GetShort(CurrLine));
if (Height >= 256)
{
return false;
diff --git a/src/WorldStorage/NBTChunkSerializer.cpp b/src/WorldStorage/NBTChunkSerializer.cpp
index cfbbcd0b4..f204ec52b 100644
--- a/src/WorldStorage/NBTChunkSerializer.cpp
+++ b/src/WorldStorage/NBTChunkSerializer.cpp
@@ -92,12 +92,12 @@ void cNBTChunkSerializer::Finish(void)
void cNBTChunkSerializer::AddItem(const cItem & a_Item, int a_Slot, const AString & a_CompoundName)
{
m_Writer.BeginCompound(a_CompoundName);
- m_Writer.AddShort("id", (short)(a_Item.m_ItemType));
- m_Writer.AddShort("Damage", a_Item.m_ItemDamage);
- m_Writer.AddByte ("Count", a_Item.m_ItemCount);
+ m_Writer.AddShort("id", static_cast<Int16>(a_Item.m_ItemType));
+ m_Writer.AddShort("Damage", static_cast<Int16>((a_Item.m_ItemDamage)));
+ m_Writer.AddByte ("Count", static_cast<Byte>(a_Item.m_ItemCount));
if (a_Slot >= 0)
{
- m_Writer.AddByte ("Slot", (unsigned char)a_Slot);
+ m_Writer.AddByte ("Slot", static_cast<unsigned char>(a_Slot));
}
// Write the tag compound (for enchantment, firework, custom name and repair cost):
@@ -131,7 +131,7 @@ void cNBTChunkSerializer::AddItem(const cItem & a_Item, int a_Slot, const AStrin
if ((a_Item.m_ItemType == E_ITEM_FIREWORK_ROCKET) || (a_Item.m_ItemType == E_ITEM_FIREWORK_STAR))
{
- cFireworkItem::WriteToNBTCompound(a_Item.m_FireworkItem, m_Writer, (ENUM_ITEM_ID)a_Item.m_ItemType);
+ cFireworkItem::WriteToNBTCompound(a_Item.m_FireworkItem, m_Writer, static_cast<ENUM_ITEM_ID>(a_Item.m_ItemType));
}
if (!a_Item.m_Enchantments.IsEmpty())
@@ -184,8 +184,8 @@ void cNBTChunkSerializer::AddBeaconEntity(cBeaconEntity * a_Entity)
m_Writer.BeginCompound("");
AddBasicTileEntity(a_Entity, "Beacon");
m_Writer.AddInt("Levels", a_Entity->GetBeaconLevel());
- m_Writer.AddInt("Primary", (int)a_Entity->GetPrimaryEffect());
- m_Writer.AddInt("Secondary", (int)a_Entity->GetSecondaryEffect());
+ m_Writer.AddInt("Primary", static_cast<int>(a_Entity->GetPrimaryEffect()));
+ m_Writer.AddInt("Secondary", static_cast<int>(a_Entity->GetSecondaryEffect()));
m_Writer.BeginList("Items", TAG_Compound);
AddItemGrid(a_Entity->GetContents());
m_Writer.EndList();
@@ -245,8 +245,8 @@ void cNBTChunkSerializer::AddFurnaceEntity(cFurnaceEntity * a_Furnace)
m_Writer.BeginList("Items", TAG_Compound);
AddItemGrid(a_Furnace->GetContents());
m_Writer.EndList();
- m_Writer.AddShort("BurnTime", a_Furnace->GetFuelBurnTimeLeft());
- m_Writer.AddShort("CookTime", a_Furnace->GetTimeCooked());
+ m_Writer.AddShort("BurnTime", static_cast<Int16>(a_Furnace->GetFuelBurnTimeLeft()));
+ m_Writer.AddShort("CookTime", static_cast<Int16>(a_Furnace->GetTimeCooked()));
m_Writer.EndCompound();
}
@@ -298,7 +298,7 @@ void cNBTChunkSerializer::AddNoteEntity(cNoteEntity * a_Note)
{
m_Writer.BeginCompound("");
AddBasicTileEntity(a_Note, "Music");
- m_Writer.AddByte("note", a_Note->GetPitch());
+ m_Writer.AddByte("note", static_cast<Byte>(a_Note->GetPitch()));
m_Writer.EndCompound();
}
@@ -354,8 +354,8 @@ void cNBTChunkSerializer::AddFlowerPotEntity(cFlowerPotEntity * a_FlowerPot)
{
m_Writer.BeginCompound("");
AddBasicTileEntity(a_FlowerPot, "FlowerPot");
- m_Writer.AddInt ("Item", (Int32) a_FlowerPot->GetItem().m_ItemType);
- m_Writer.AddInt ("Data", (Int32) a_FlowerPot->GetItem().m_ItemDamage);
+ m_Writer.AddInt ("Item", static_cast<Int32>(a_FlowerPot->GetItem().m_ItemType));
+ m_Writer.AddInt ("Data", static_cast<Int32>(a_FlowerPot->GetItem().m_ItemDamage));
m_Writer.EndCompound();
}
@@ -380,7 +380,7 @@ void cNBTChunkSerializer::AddBasicEntity(cEntity * a_Entity, const AString & a_C
m_Writer.AddDouble("", a_Entity->GetYaw());
m_Writer.AddDouble("", a_Entity->GetPitch());
m_Writer.EndList();
- m_Writer.AddShort("Health", a_Entity->GetHealth());
+ m_Writer.AddShort("Health", static_cast<Int16>(a_Entity->GetHealth()));
}
@@ -435,7 +435,7 @@ void cNBTChunkSerializer::AddMinecartEntity(cMinecart * a_Minecart)
{
AddBasicEntity(a_Minecart, "MinecartChest");
// Add chest contents into the Items tag:
- AddMinecartChestContents((cMinecartWithChest *)a_Minecart);
+ AddMinecartChestContents(reinterpret_cast<cMinecartWithChest *>(a_Minecart));
break;
}
case cMinecart::mpFurnace:
@@ -521,9 +521,9 @@ void cNBTChunkSerializer::AddMonsterEntity(cMonster * a_Monster)
m_Writer.AddFloat("", a_Monster->GetDropChanceLeggings());
m_Writer.AddFloat("", a_Monster->GetDropChanceBoots());
m_Writer.EndList();
- m_Writer.AddByte("CanPickUpLoot", (char)a_Monster->CanPickUpLoot());
+ m_Writer.AddByte("CanPickUpLoot", (a_Monster->CanPickUpLoot())? 1 : 0);
m_Writer.AddString("CustomName", a_Monster->GetCustomName());
- m_Writer.AddByte("CustomNameVisible", (char)a_Monster->IsCustomNameAlwaysVisible());
+ m_Writer.AddByte("CustomNameVisible", static_cast<Byte>(a_Monster->IsCustomNameAlwaysVisible()));
switch (a_Monster->GetMobType())
{
case mtBat:
@@ -541,22 +541,22 @@ void cNBTChunkSerializer::AddMonsterEntity(cMonster * a_Monster)
case mtEnderman:
{
const cEnderman *Enderman = reinterpret_cast<const cEnderman *>(a_Monster);
- m_Writer.AddShort("carried", (Int16) Enderman->GetCarriedBlock());
- m_Writer.AddShort("carriedData", (Int16) Enderman->GetCarriedMeta());
+ m_Writer.AddShort("carried", static_cast<Int16>(Enderman->GetCarriedBlock()));
+ m_Writer.AddShort("carriedData", static_cast<Int16>(Enderman->GetCarriedMeta()));
break;
}
case mtHorse:
{
const cHorse *Horse = reinterpret_cast<const cHorse *>(a_Monster);
- m_Writer.AddByte("ChestedHorse", Horse->IsChested());
- m_Writer.AddByte("EatingHaystack", Horse->IsEating());
- m_Writer.AddByte("Tame", Horse->IsTame());
+ m_Writer.AddByte("ChestedHorse", Horse->IsChested()? 1 : 0);
+ m_Writer.AddByte("EatingHaystack", Horse->IsEating()? 1 : 0);
+ m_Writer.AddByte("Tame", Horse->IsTame()? 1: 0);
m_Writer.AddInt ("Type", Horse->GetHorseType());
m_Writer.AddInt ("Color", Horse->GetHorseColor());
m_Writer.AddInt ("Style", Horse->GetHorseStyle());
m_Writer.AddInt ("ArmorType", Horse->GetHorseArmour());
- m_Writer.AddByte("Saddle", Horse->IsSaddled());
- m_Writer.AddByte("Age", Horse->GetAge());
+ m_Writer.AddByte("Saddle", Horse->IsSaddled()? 1 : 0);
+ m_Writer.AddByte("Age", static_cast<Byte>(Horse->GetAge()));
break;
}
case mtMagmaCube:
@@ -567,9 +567,9 @@ void cNBTChunkSerializer::AddMonsterEntity(cMonster * a_Monster)
case mtSheep:
{
const cSheep *Sheep = reinterpret_cast<const cSheep *>(a_Monster);
- m_Writer.AddByte("Sheared", Sheep->IsSheared());
- m_Writer.AddByte("Color", Sheep->GetFurColor());
- m_Writer.AddByte("Age", Sheep->GetAge());
+ m_Writer.AddByte("Sheared", Sheep->IsSheared()? 1 : 0);
+ m_Writer.AddByte("Color", static_cast<Byte>(Sheep->GetFurColor()));
+ m_Writer.AddByte("Age", static_cast<Byte>(Sheep->GetAge()));
break;
}
case mtSlime:
@@ -586,12 +586,12 @@ void cNBTChunkSerializer::AddMonsterEntity(cMonster * a_Monster)
{
const cVillager *Villager = reinterpret_cast<const cVillager *>(a_Monster);
m_Writer.AddInt("Profession", Villager->GetVilType());
- m_Writer.AddByte("Age", Villager->GetAge());
+ m_Writer.AddByte("Age", static_cast<Byte>(Villager->GetAge()));
break;
}
case mtWither:
{
- m_Writer.AddInt("Invul", reinterpret_cast<const cWither *>(a_Monster)->GetWitherInvulnerableTicks());
+ m_Writer.AddInt("Invul", static_cast<Int32>(reinterpret_cast<const cWither *>(a_Monster)->GetWitherInvulnerableTicks()));
break;
}
case mtWolf:
@@ -607,8 +607,8 @@ void cNBTChunkSerializer::AddMonsterEntity(cMonster * a_Monster)
}
m_Writer.AddByte("Sitting", Wolf->IsSitting() ? 1 : 0);
m_Writer.AddByte("Angry", Wolf->IsAngry() ? 1 : 0);
- m_Writer.AddByte("CollarColor", (unsigned char) Wolf->GetCollarColor());
- m_Writer.AddByte("Age", Wolf->GetAge());
+ m_Writer.AddByte("CollarColor", static_cast<Byte>(Wolf->GetCollarColor()));
+ m_Writer.AddByte("Age", static_cast<Byte>(Wolf->GetAge()));
break;
}
case mtZombie:
@@ -616,22 +616,22 @@ void cNBTChunkSerializer::AddMonsterEntity(cMonster * a_Monster)
const cZombie *Zombie = reinterpret_cast<const cZombie *>(a_Monster);
m_Writer.AddByte("IsVillager", Zombie->IsVillagerZombie() ? 1 : 0);
m_Writer.AddByte("IsConverting", Zombie->IsConverting() ? 1 : 0);
- m_Writer.AddByte("Age", Zombie->GetAge());
+ m_Writer.AddByte("Age", static_cast<Byte>(Zombie->GetAge()));
break;
}
case mtZombiePigman:
{
- m_Writer.AddByte("Age", reinterpret_cast<const cZombiePigman *>(a_Monster)->GetAge());
+ m_Writer.AddByte("Age", static_cast<Byte>(reinterpret_cast<const cZombiePigman *>(a_Monster)->GetAge()));
break;
}
case mtOcelot:
{
- m_Writer.AddByte("Age", reinterpret_cast<const cOcelot *>(a_Monster)->GetAge());
+ m_Writer.AddByte("Age", static_cast<Byte>(reinterpret_cast<const cOcelot *>(a_Monster)->GetAge()));
break;
}
case mtPig:
{
- m_Writer.AddByte("Age", reinterpret_cast<const cPig *>(a_Monster)->GetAge());
+ m_Writer.AddByte("Age", static_cast<Byte>(reinterpret_cast<const cPig *>(a_Monster)->GetAge()));
break;
}
case mtRabbit:
@@ -639,7 +639,7 @@ void cNBTChunkSerializer::AddMonsterEntity(cMonster * a_Monster)
const cRabbit *Rabbit = reinterpret_cast<const cRabbit *>(a_Monster);
m_Writer.AddInt("RabbitType", Rabbit->GetRabbitTypeAsNumber());
m_Writer.AddInt("MoreCarrotTicks", Rabbit->GetMoreCarrotTicks());
- m_Writer.AddByte("Age", Rabbit->GetAge());
+ m_Writer.AddByte("Age", static_cast<Byte>(Rabbit->GetAge()));
break;
}
case mtInvalidType:
@@ -675,7 +675,7 @@ void cNBTChunkSerializer::AddPickupEntity(cPickup * a_Pickup)
m_Writer.BeginCompound("");
AddBasicEntity(a_Pickup, "Item");
AddItem(a_Pickup->GetItem(), -1, "Item");
- m_Writer.AddShort("Age", (Int16)a_Pickup->GetAge());
+ m_Writer.AddShort("Age", static_cast<Int16>(a_Pickup->GetAge()));
m_Writer.EndCompound();
}
@@ -693,21 +693,21 @@ void cNBTChunkSerializer::AddProjectileEntity(cProjectileEntity * a_Projectile)
{
case cProjectileEntity::pkArrow:
{
- cArrowEntity * Arrow = (cArrowEntity *)a_Projectile;
+ cArrowEntity * Arrow = reinterpret_cast<cArrowEntity *>(a_Projectile);
- m_Writer.AddShort("xTile", (Int16)Arrow->GetBlockHit().x);
- m_Writer.AddShort("yTile", (Int16)Arrow->GetBlockHit().y);
- m_Writer.AddShort("zTile", (Int16)Arrow->GetBlockHit().z);
+ m_Writer.AddShort("xTile", static_cast<Int16>(Arrow->GetBlockHit().x));
+ m_Writer.AddShort("yTile", static_cast<Int16>(Arrow->GetBlockHit().y));
+ m_Writer.AddShort("zTile", static_cast<Int16>(Arrow->GetBlockHit().z));
m_Writer.AddByte("pickup", Arrow->GetPickupState());
m_Writer.AddDouble("damage", Arrow->GetDamageCoeff());
break;
}
case cProjectileEntity::pkSplashPotion:
{
- cSplashPotionEntity * Potion = (cSplashPotionEntity *)a_Projectile;
+ cSplashPotionEntity * Potion = reinterpret_cast<cSplashPotionEntity *>(a_Projectile);
- m_Writer.AddInt("EffectType", (Int16)Potion->GetEntityEffectType());
- m_Writer.AddInt("EffectDuration", (Int16)Potion->GetEntityEffect().GetDuration());
+ m_Writer.AddInt("EffectType", static_cast<Int16>(Potion->GetEntityEffectType()));
+ m_Writer.AddInt("EffectDuration", static_cast<Int16>(Potion->GetEntityEffect().GetDuration()));
m_Writer.AddShort("EffectIntensity", Potion->GetEntityEffect().GetIntensity());
m_Writer.AddDouble("EffectDistanceModifier", Potion->GetEntityEffect().GetDistanceModifier());
m_Writer.AddInt("PotionName", Potion->GetPotionColor());
@@ -757,7 +757,7 @@ void cNBTChunkSerializer::AddTNTEntity(cTNTEntity * a_TNT)
{
m_Writer.BeginCompound("");
AddBasicEntity(a_TNT, "PrimedTnt");
- m_Writer.AddByte("Fuse", (unsigned char)a_TNT->GetFuseTicks());
+ m_Writer.AddByte("Fuse", static_cast<unsigned char>(a_TNT->GetFuseTicks()));
m_Writer.EndCompound();
}
@@ -769,8 +769,8 @@ void cNBTChunkSerializer::AddExpOrbEntity(cExpOrb * a_ExpOrb)
{
m_Writer.BeginCompound("");
AddBasicEntity(a_ExpOrb, "XPOrb");
- m_Writer.AddShort("Age", (Int16)a_ExpOrb->GetAge());
- m_Writer.AddShort("Value", (Int16)a_ExpOrb->GetReward());
+ m_Writer.AddShort("Age", static_cast<Int16>(a_ExpOrb->GetAge()));
+ m_Writer.AddShort("Value", static_cast<Int16>(a_ExpOrb->GetReward()));
m_Writer.EndCompound();
}
@@ -784,7 +784,7 @@ void cNBTChunkSerializer::AddItemFrameEntity(cItemFrame * a_ItemFrame)
AddBasicEntity(a_ItemFrame, "ItemFrame");
AddHangingEntity(a_ItemFrame);
AddItem(a_ItemFrame->GetItem(), -1, "Item");
- m_Writer.AddByte("ItemRotation", (unsigned char)a_ItemFrame->GetItemRotation());
+ m_Writer.AddByte("ItemRotation", static_cast<Byte>(a_ItemFrame->GetItemRotation()));
m_Writer.AddFloat("ItemDropChance", 1.0F);
m_Writer.EndCompound();
}
@@ -858,7 +858,7 @@ void cNBTChunkSerializer::BiomeData(const cChunkDef::BiomeMap * a_BiomeMap)
if ((*a_BiomeMap)[i] < 255)
{
// Normal MC biome, copy as-is:
- m_VanillaBiomes[i] = (unsigned char)((*a_BiomeMap)[i]);
+ m_VanillaBiomes[i] = static_cast<Byte>((*a_BiomeMap)[i]);
}
else
{
@@ -894,17 +894,17 @@ void cNBTChunkSerializer::Entity(cEntity * a_Entity)
switch (a_Entity->GetEntityType())
{
- case cEntity::etBoat: AddBoatEntity ((cBoat *) a_Entity); break;
- case cEntity::etEnderCrystal: AddEnderCrystalEntity((cEnderCrystal *) a_Entity); break;
- case cEntity::etFallingBlock: AddFallingBlockEntity((cFallingBlock *) a_Entity); break;
- case cEntity::etMinecart: AddMinecartEntity ((cMinecart *) a_Entity); break;
- case cEntity::etMonster: AddMonsterEntity ((cMonster *) a_Entity); break;
- case cEntity::etPickup: AddPickupEntity ((cPickup *) a_Entity); break;
- case cEntity::etProjectile: AddProjectileEntity ((cProjectileEntity *)a_Entity); break;
- case cEntity::etTNT: AddTNTEntity ((cTNTEntity *) a_Entity); break;
- case cEntity::etExpOrb: AddExpOrbEntity ((cExpOrb *) a_Entity); break;
- case cEntity::etItemFrame: AddItemFrameEntity ((cItemFrame *) a_Entity); break;
- case cEntity::etPainting: AddPaintingEntity (reinterpret_cast<cPainting *>(a_Entity)); break;
+ case cEntity::etBoat: AddBoatEntity (reinterpret_cast<cBoat *> (a_Entity)); break;
+ case cEntity::etEnderCrystal: AddEnderCrystalEntity(reinterpret_cast<cEnderCrystal *> (a_Entity)); break;
+ case cEntity::etFallingBlock: AddFallingBlockEntity(reinterpret_cast<cFallingBlock *> (a_Entity)); break;
+ case cEntity::etMinecart: AddMinecartEntity (reinterpret_cast<cMinecart *> (a_Entity)); break;
+ case cEntity::etMonster: AddMonsterEntity (reinterpret_cast<cMonster *> (a_Entity)); break;
+ case cEntity::etPickup: AddPickupEntity (reinterpret_cast<cPickup *> (a_Entity)); break;
+ case cEntity::etProjectile: AddProjectileEntity (reinterpret_cast<cProjectileEntity *>(a_Entity)); break;
+ case cEntity::etTNT: AddTNTEntity (reinterpret_cast<cTNTEntity *> (a_Entity)); break;
+ case cEntity::etExpOrb: AddExpOrbEntity (reinterpret_cast<cExpOrb *> (a_Entity)); break;
+ case cEntity::etItemFrame: AddItemFrameEntity (reinterpret_cast<cItemFrame *> (a_Entity)); break;
+ case cEntity::etPainting: AddPaintingEntity (reinterpret_cast<cPainting *> (a_Entity)); break;
case cEntity::etPlayer: return; // Players aren't saved into the world
default:
{
@@ -937,23 +937,23 @@ void cNBTChunkSerializer::BlockEntity(cBlockEntity * a_Entity)
// Add tile-entity into NBT:
switch (a_Entity->GetBlockType())
{
- case E_BLOCK_BEACON: AddBeaconEntity ((cBeaconEntity *) a_Entity); break;
- case E_BLOCK_CHEST: AddChestEntity ((cChestEntity *) a_Entity, a_Entity->GetBlockType()); break;
- case E_BLOCK_COMMAND_BLOCK: AddCommandBlockEntity((cCommandBlockEntity *)a_Entity); break;
- case E_BLOCK_DISPENSER: AddDispenserEntity ((cDispenserEntity *) a_Entity); break;
- case E_BLOCK_DROPPER: AddDropperEntity ((cDropperEntity *) a_Entity); break;
+ case E_BLOCK_BEACON: AddBeaconEntity (reinterpret_cast<cBeaconEntity *> (a_Entity)); break;
+ case E_BLOCK_CHEST: AddChestEntity (reinterpret_cast<cChestEntity *> (a_Entity), a_Entity->GetBlockType()); break;
+ case E_BLOCK_COMMAND_BLOCK: AddCommandBlockEntity(reinterpret_cast<cCommandBlockEntity *>(a_Entity)); break;
+ case E_BLOCK_DISPENSER: AddDispenserEntity (reinterpret_cast<cDispenserEntity *> (a_Entity)); break;
+ case E_BLOCK_DROPPER: AddDropperEntity (reinterpret_cast<cDropperEntity *> (a_Entity)); break;
case E_BLOCK_ENDER_CHEST: /* No data to be saved */ break;
- case E_BLOCK_FLOWER_POT: AddFlowerPotEntity ((cFlowerPotEntity *) a_Entity); break;
- case E_BLOCK_FURNACE: AddFurnaceEntity ((cFurnaceEntity *) a_Entity); break;
- case E_BLOCK_HEAD: AddMobHeadEntity ((cMobHeadEntity *) a_Entity); break;
- case E_BLOCK_HOPPER: AddHopperEntity ((cHopperEntity *) a_Entity); break;
- case E_BLOCK_JUKEBOX: AddJukeboxEntity ((cJukeboxEntity *) a_Entity); break;
- case E_BLOCK_LIT_FURNACE: AddFurnaceEntity ((cFurnaceEntity *) a_Entity); break;
- case E_BLOCK_MOB_SPAWNER: AddMobSpawnerEntity ((cMobSpawnerEntity *) a_Entity); break;
- case E_BLOCK_NOTE_BLOCK: AddNoteEntity ((cNoteEntity *) a_Entity); break;
- case E_BLOCK_SIGN_POST: AddSignEntity ((cSignEntity *) a_Entity); break;
- case E_BLOCK_TRAPPED_CHEST: AddChestEntity ((cChestEntity *) a_Entity, a_Entity->GetBlockType()); break;
- case E_BLOCK_WALLSIGN: AddSignEntity ((cSignEntity *) a_Entity); break;
+ case E_BLOCK_FLOWER_POT: AddFlowerPotEntity (reinterpret_cast<cFlowerPotEntity *> (a_Entity)); break;
+ case E_BLOCK_FURNACE: AddFurnaceEntity (reinterpret_cast<cFurnaceEntity *> (a_Entity)); break;
+ case E_BLOCK_HEAD: AddMobHeadEntity (reinterpret_cast<cMobHeadEntity *> (a_Entity)); break;
+ case E_BLOCK_HOPPER: AddHopperEntity (reinterpret_cast<cHopperEntity *> (a_Entity)); break;
+ case E_BLOCK_JUKEBOX: AddJukeboxEntity (reinterpret_cast<cJukeboxEntity *> (a_Entity)); break;
+ case E_BLOCK_LIT_FURNACE: AddFurnaceEntity (reinterpret_cast<cFurnaceEntity *> (a_Entity)); break;
+ case E_BLOCK_MOB_SPAWNER: AddMobSpawnerEntity (reinterpret_cast<cMobSpawnerEntity *> (a_Entity)); break;
+ case E_BLOCK_NOTE_BLOCK: AddNoteEntity (reinterpret_cast<cNoteEntity *> (a_Entity)); break;
+ case E_BLOCK_SIGN_POST: AddSignEntity (reinterpret_cast<cSignEntity *> (a_Entity)); break;
+ case E_BLOCK_TRAPPED_CHEST: AddChestEntity (reinterpret_cast<cChestEntity *> (a_Entity), a_Entity->GetBlockType()); break;
+ case E_BLOCK_WALLSIGN: AddSignEntity (reinterpret_cast<cSignEntity *> (a_Entity)); break;
default:
{
diff --git a/src/WorldStorage/SchematicFileSerializer.cpp b/src/WorldStorage/SchematicFileSerializer.cpp
index 3e9ed5bef..6267668c5 100644
--- a/src/WorldStorage/SchematicFileSerializer.cpp
+++ b/src/WorldStorage/SchematicFileSerializer.cpp
@@ -271,13 +271,13 @@ bool cSchematicFileSerializer::LoadFromSchematicNBT(cBlockArea & a_BlockArea, cP
AString cSchematicFileSerializer::SaveToSchematicNBT(const cBlockArea & a_BlockArea)
{
cFastNBTWriter Writer("Schematic");
- Writer.AddShort("Width", a_BlockArea.m_Size.x);
- Writer.AddShort("Height", a_BlockArea.m_Size.y);
- Writer.AddShort("Length", a_BlockArea.m_Size.z);
+ Writer.AddShort("Width", static_cast<Int16>(a_BlockArea.m_Size.x));
+ Writer.AddShort("Height", static_cast<Int16>(a_BlockArea.m_Size.y));
+ Writer.AddShort("Length", static_cast<Int16>(a_BlockArea.m_Size.z));
Writer.AddString("Materials", "Alpha");
if (a_BlockArea.HasBlockTypes())
{
- Writer.AddByteArray("Blocks", (const char *)a_BlockArea.m_BlockTypes, a_BlockArea.GetBlockCount());
+ Writer.AddByteArray("Blocks", reinterpret_cast<const char *>(a_BlockArea.m_BlockTypes), a_BlockArea.GetBlockCount());
}
else
{
@@ -286,7 +286,7 @@ AString cSchematicFileSerializer::SaveToSchematicNBT(const cBlockArea & a_BlockA
}
if (a_BlockArea.HasBlockMetas())
{
- Writer.AddByteArray("Data", (const char *)a_BlockArea.m_BlockMetas, a_BlockArea.GetBlockCount());
+ Writer.AddByteArray("Data", reinterpret_cast<const char *>(a_BlockArea.m_BlockMetas), a_BlockArea.GetBlockCount());
}
else
{
diff --git a/src/WorldStorage/WSSAnvil.cpp b/src/WorldStorage/WSSAnvil.cpp
index 54071b9df..a4c9f4fbf 100755
--- a/src/WorldStorage/WSSAnvil.cpp
+++ b/src/WorldStorage/WSSAnvil.cpp
@@ -78,7 +78,7 @@ Since only the header is actually in the memory, this number can be high, but st
"Please add the reported file and this message to the issue report.", \
__FUNCTION__, __LINE__, CHX, CHZ, RegionX, RegionZ \
); \
- *((volatile int *)0) = 0; /* Crash intentionally */ \
+ *(reinterpret_cast<volatile int *>(0)) = 0; /* Crash intentionally */ \
}
@@ -107,13 +107,13 @@ cWSSAnvil::cWSSAnvil(cWorld * a_World, int a_CompressionFactor) :
Writer.AddByte("MapFeatures", 1);
Writer.AddByte("raining", a_World->IsWeatherRain() ? 1 : 0);
Writer.AddByte("thundering", a_World->IsWeatherStorm() ? 1 : 0);
- Writer.AddInt("GameType", (int)a_World->GetGameMode());
+ Writer.AddInt("GameType", static_cast<int>(a_World->GetGameMode()));
Writer.AddInt("generatorVersion", 1);
- Writer.AddInt("SpawnX", (int)a_World->GetSpawnX());
- Writer.AddInt("SpawnY", (int)a_World->GetSpawnY());
- Writer.AddInt("SpawnZ", (int)a_World->GetSpawnZ());
+ Writer.AddInt("SpawnX", static_cast<int>(a_World->GetSpawnX()));
+ Writer.AddInt("SpawnY", static_cast<int>(a_World->GetSpawnY()));
+ Writer.AddInt("SpawnZ", static_cast<int>(a_World->GetSpawnZ()));
Writer.AddInt("version", 19133);
- Writer.AddLong("DayTime", (Int64)a_World->GetTimeOfDay());
+ Writer.AddLong("DayTime", static_cast<Int64>(a_World->GetTimeOfDay()));
Writer.AddLong("Time", a_World->GetWorldAge());
Writer.AddLong("SizeOnDisk", 0);
Writer.AddString("generatorName", "default");
@@ -366,10 +366,10 @@ bool cWSSAnvil::LoadChunkFromNBT(const cChunkCoords & a_Chunk, const cParsedNBT
{
continue;
}
- CopyNBTData(a_NBT, Child, "Blocks", (char *)&(BlockTypes[y * 4096]), 4096);
- CopyNBTData(a_NBT, Child, "Data", (char *)&(MetaData[y * 2048]), 2048);
- CopyNBTData(a_NBT, Child, "SkyLight", (char *)&(SkyLight[y * 2048]), 2048);
- CopyNBTData(a_NBT, Child, "BlockLight", (char *)&(BlockLight[y * 2048]), 2048);
+ CopyNBTData(a_NBT, Child, "Blocks", reinterpret_cast<char *>(&(BlockTypes[y * 4096])), 4096);
+ CopyNBTData(a_NBT, Child, "Data", reinterpret_cast<char *>(&(MetaData[y * 2048])), 2048);
+ CopyNBTData(a_NBT, Child, "SkyLight", reinterpret_cast<char *>(&(SkyLight[y * 2048])), 2048);
+ CopyNBTData(a_NBT, Child, "BlockLight", reinterpret_cast<char *>(&(BlockLight[y * 2048])), 2048);
} // for itr - LevelSections[]
// Load the biomes from NBT, if present and valid. First try MCS-style, then Vanilla-style:
@@ -471,32 +471,32 @@ bool cWSSAnvil::SaveChunkToNBT(const cChunkCoords & a_Chunk, cFastNBTWriter & a_
// Save biomes, both MCS (IntArray) and MC-vanilla (ByteArray):
if (Serializer.m_BiomesAreValid)
{
- a_Writer.AddByteArray("Biomes", (const char *)(Serializer.m_VanillaBiomes), ARRAYCOUNT(Serializer.m_VanillaBiomes));
- a_Writer.AddIntArray ("MCSBiomes", (const int *)(Serializer.m_Biomes), ARRAYCOUNT(Serializer.m_Biomes));
+ a_Writer.AddByteArray("Biomes", reinterpret_cast<const char *>(Serializer.m_VanillaBiomes), ARRAYCOUNT(Serializer.m_VanillaBiomes));
+ a_Writer.AddIntArray ("MCSBiomes", reinterpret_cast<const int *>(Serializer.m_Biomes), ARRAYCOUNT(Serializer.m_Biomes));
}
// Save heightmap (Vanilla require this):
- a_Writer.AddIntArray("HeightMap", (const int *)Serializer.m_VanillaHeightMap, ARRAYCOUNT(Serializer.m_VanillaHeightMap));
+ a_Writer.AddIntArray("HeightMap", reinterpret_cast<const int *>(Serializer.m_VanillaHeightMap), ARRAYCOUNT(Serializer.m_VanillaHeightMap));
// Save blockdata:
a_Writer.BeginList("Sections", TAG_Compound);
size_t SliceSizeBlock = cChunkDef::Width * cChunkDef::Width * 16;
size_t SliceSizeNibble = SliceSizeBlock / 2;
- const char * BlockTypes = (const char *)(Serializer.m_BlockTypes);
- const char * BlockMetas = (const char *)(Serializer.m_BlockMetas);
+ const char * BlockTypes = reinterpret_cast<const char *>(Serializer.m_BlockTypes);
+ const char * BlockMetas = reinterpret_cast<const char *>(Serializer.m_BlockMetas);
#ifdef DEBUG_SKYLIGHT
- const char * BlockLight = (const char *)(Serializer.m_BlockSkyLight);
+ const char * BlockLight = reinterpret_cast<const char *>(Serializer.m_BlockSkyLight);
#else
- const char * BlockLight = (const char *)(Serializer.m_BlockLight);
+ const char * BlockLight = reinterpret_cast<const char *>(Serializer.m_BlockLight);
#endif
- const char * BlockSkyLight = (const char *)(Serializer.m_BlockSkyLight);
+ const char * BlockSkyLight = reinterpret_cast<const char *>(Serializer.m_BlockSkyLight);
for (int Y = 0; Y < 16; Y++)
{
a_Writer.BeginCompound("");
- a_Writer.AddByteArray("Blocks", BlockTypes + Y * SliceSizeBlock, SliceSizeBlock);
- a_Writer.AddByteArray("Data", BlockMetas + Y * SliceSizeNibble, SliceSizeNibble);
- a_Writer.AddByteArray("SkyLight", BlockSkyLight + Y * SliceSizeNibble, SliceSizeNibble);
- a_Writer.AddByteArray("BlockLight", BlockLight + Y * SliceSizeNibble, SliceSizeNibble);
+ a_Writer.AddByteArray("Blocks", BlockTypes + static_cast<unsigned int>(Y) * SliceSizeBlock, SliceSizeBlock);
+ a_Writer.AddByteArray("Data", BlockMetas + static_cast<unsigned int>(Y) * SliceSizeNibble, SliceSizeNibble);
+ a_Writer.AddByteArray("SkyLight", BlockSkyLight + static_cast<unsigned int>(Y) * SliceSizeNibble, SliceSizeNibble);
+ a_Writer.AddByteArray("BlockLight", BlockLight + static_cast<unsigned int>(Y) * SliceSizeNibble, SliceSizeNibble);
a_Writer.AddByte("Y", static_cast<unsigned char>(Y));
a_Writer.EndCompound();
}
@@ -534,7 +534,7 @@ cChunkDef::BiomeMap * cWSSAnvil::LoadVanillaBiomeMapFromNBT(cChunkDef::BiomeMap
// The biomes stored don't match in size
return nullptr;
}
- const unsigned char * VanillaBiomeData = (const unsigned char *)(a_NBT.GetData(a_TagIdx));
+ const unsigned char * VanillaBiomeData = reinterpret_cast<const unsigned char *>(a_NBT.GetData(a_TagIdx));
for (size_t i = 0; i < ARRAYCOUNT(*a_BiomeMap); i++)
{
if ((VanillaBiomeData)[i] == 0xff)
@@ -542,7 +542,7 @@ cChunkDef::BiomeMap * cWSSAnvil::LoadVanillaBiomeMapFromNBT(cChunkDef::BiomeMap
// Unassigned biomes
return nullptr;
}
- (*a_BiomeMap)[i] = (EMCSBiome)(VanillaBiomeData[i]);
+ (*a_BiomeMap)[i] = static_cast<EMCSBiome>(VanillaBiomeData[i]);
}
return a_BiomeMap;
}
@@ -565,7 +565,7 @@ cChunkDef::BiomeMap * cWSSAnvil::LoadBiomeMapFromNBT(cChunkDef::BiomeMap * a_Bio
const char * BiomeData = (a_NBT.GetData(a_TagIdx));
for (size_t i = 0; i < ARRAYCOUNT(*a_BiomeMap); i++)
{
- (*a_BiomeMap)[i] = (EMCSBiome)(GetBEInt(&BiomeData[i * 4]));
+ (*a_BiomeMap)[i] = static_cast<EMCSBiome>(GetBEInt(&BiomeData[i * 4]));
if ((*a_BiomeMap)[i] == 0xff)
{
// Unassigned biomes
@@ -682,7 +682,7 @@ cBlockEntity * cWSSAnvil::LoadBlockEntityFromNBT(const cParsedNBT & a_NBT, int a
AString TypeName("<unknown>");
if (TagID >= 0)
{
- TypeName.assign(a_NBT.GetData(TagID), (size_t)a_NBT.GetDataLength(TagID));
+ 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(),
@@ -736,7 +736,7 @@ bool cWSSAnvil::LoadItemFromNBT(cItem & a_Item, const cParsedNBT & a_NBT, int a_
int Count = a_NBT.FindChildByName(a_TagIdx, "Count");
if ((Count > 0) && (a_NBT.GetType(Count) == TAG_Byte))
{
- a_Item.m_ItemCount = a_NBT.GetByte(Count);
+ a_Item.m_ItemCount = static_cast<char>(a_NBT.GetByte(Count));
}
// Find the "tag" tag, used for enchantments and other extra data
@@ -782,7 +782,7 @@ bool cWSSAnvil::LoadItemFromNBT(cItem & a_Item, const cParsedNBT & a_NBT, int a_
int FireworksTag = a_NBT.FindChildByName(TagTag, ((a_Item.m_ItemType == E_ITEM_FIREWORK_STAR) ? "Fireworks" : "Explosion"));
if (EnchTag > 0)
{
- cFireworkItem::ParseFromNBT(a_Item.m_FireworkItem, a_NBT, FireworksTag, (ENUM_ITEM_ID)a_Item.m_ItemType);
+ cFireworkItem::ParseFromNBT(a_Item.m_FireworkItem, a_NBT, FireworksTag, static_cast<ENUM_ITEM_ID>(a_Item.m_ItemType));
}
return true;
@@ -802,7 +802,7 @@ void cWSSAnvil::LoadItemGridFromNBT(cItemGrid & a_ItemGrid, const cParsedNBT & a
{
continue;
}
- int SlotNum = (int)(a_NBT.GetByte(SlotTag)) - a_SlotOffset;
+ int SlotNum = static_cast<int>(a_NBT.GetByte(SlotTag)) - a_SlotOffset;
if ((SlotNum < 0) || (SlotNum >= NumSlots))
{
// SlotNum outside of the range
@@ -836,13 +836,13 @@ bool cWSSAnvil::CheckBlockEntityType(const cParsedNBT & a_NBT, int a_TagIdx, con
}
// Compare the value:
- if (strncmp(a_NBT.GetData(TagID), a_ExpectedType, (size_t)a_NBT.GetDataLength(TagID)) == 0)
+ if (strncmp(a_NBT.GetData(TagID), a_ExpectedType, static_cast<size_t>(a_NBT.GetDataLength(TagID))) == 0)
{
return true;
}
LOGWARNING("Block entity type mismatch: exp \"%s\", got \"%s\".",
a_ExpectedType,
- AString(a_NBT.GetData(TagID), (size_t)a_NBT.GetDataLength(TagID)).c_str()
+ AString(a_NBT.GetData(TagID), static_cast<size_t>(a_NBT.GetDataLength(TagID))).c_str()
);
return false;
}
@@ -864,19 +864,19 @@ cBlockEntity * cWSSAnvil::LoadBeaconFromNBT(const cParsedNBT & a_NBT, int a_TagI
int CurrentLine = a_NBT.FindChildByName(a_TagIdx, "Levels");
if (CurrentLine >= 0)
{
- Beacon->SetBeaconLevel((char)a_NBT.GetInt(CurrentLine));
+ Beacon->SetBeaconLevel(static_cast<char>(a_NBT.GetInt(CurrentLine)));
}
CurrentLine = a_NBT.FindChildByName(a_TagIdx, "Primary");
if (CurrentLine >= 0)
{
- Beacon->SetPrimaryEffect((cEntityEffect::eType)a_NBT.GetInt(CurrentLine));
+ Beacon->SetPrimaryEffect(static_cast<cEntityEffect::eType>(a_NBT.GetInt(CurrentLine)));
}
CurrentLine = a_NBT.FindChildByName(a_TagIdx, "Secondary");
if (CurrentLine >= 0)
{
- Beacon->SetSecondaryEffect((cEntityEffect::eType)a_NBT.GetInt(CurrentLine));
+ Beacon->SetSecondaryEffect(static_cast<cEntityEffect::eType>(a_NBT.GetInt(CurrentLine)));
}
// We are better than mojang, we load / save the beacon inventory!
@@ -937,7 +937,7 @@ cBlockEntity * cWSSAnvil::LoadCommandBlockFromNBT(const cParsedNBT & a_NBT, int
currentLine = a_NBT.FindChildByName(a_TagIdx, "SuccessCount");
if (currentLine >= 0)
{
- CmdBlock->SetResult(a_NBT.GetInt(currentLine));
+ CmdBlock->SetResult(static_cast<NIBBLETYPE>(a_NBT.GetInt(currentLine)));
}
currentLine = a_NBT.FindChildByName(a_TagIdx, "LastOutput");
@@ -1019,14 +1019,14 @@ cBlockEntity * cWSSAnvil::LoadFlowerPotFromNBT(const cParsedNBT & a_NBT, int a_T
}
else if (a_NBT.GetType(currentLine) == TAG_Int)
{
- Item.m_ItemType = (short) a_NBT.GetInt(currentLine);
+ Item.m_ItemType = static_cast<short>(a_NBT.GetInt(currentLine));
}
}
currentLine = a_NBT.FindChildByName(a_TagIdx, "Data");
if ((currentLine >= 0) && (a_NBT.GetType(currentLine) == TAG_Int))
{
- Item.m_ItemDamage = (short) a_NBT.GetInt(currentLine);
+ Item.m_ItemDamage = static_cast<short>(a_NBT.GetInt(currentLine));
}
FlowerPot->SetItem(Item);
@@ -1234,7 +1234,7 @@ cBlockEntity * cWSSAnvil::LoadNoteBlockFromNBT(const cParsedNBT & a_NBT, int a_T
int note = a_NBT.FindChildByName(a_TagIdx, "note");
if (note >= 0)
{
- NoteBlock->SetPitch(a_NBT.GetByte(note));
+ NoteBlock->SetPitch(static_cast<char>(a_NBT.GetByte(note)));
}
return NoteBlock.release();
}
@@ -1553,7 +1553,7 @@ void cWSSAnvil::LoadFallingBlockFromNBT(cEntityList & a_Entities, const cParsedN
}
int Type = a_NBT.GetInt(TypeIdx);
- NIBBLETYPE Meta = (NIBBLETYPE)a_NBT.GetByte(MetaIdx);
+ NIBBLETYPE Meta = static_cast<NIBBLETYPE>(a_NBT.GetByte(MetaIdx));
std::unique_ptr<cFallingBlock> FallingBlock = cpp14::make_unique<cFallingBlock>(Vector3i(0, 0, 0), Type, Meta);
if (!LoadEntityBaseFromNBT(*FallingBlock.get(), a_NBT, a_TagIdx))
@@ -1710,7 +1710,7 @@ void cWSSAnvil::LoadTNTFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NB
int FuseTicks = a_NBT.FindChildByName(a_TagIdx, "Fuse");
if (FuseTicks > 0)
{
- TNT->SetFuseTicks((int) a_NBT.GetByte(FuseTicks));
+ TNT->SetFuseTicks(static_cast<int>(a_NBT.GetByte(FuseTicks)));
}
a_Entities.push_back(TNT.release());
@@ -1804,7 +1804,7 @@ void cWSSAnvil::LoadItemFrameFromNBT(cEntityList & a_Entities, const cParsedNBT
int Rotation = a_NBT.FindChildByName(a_TagIdx, "ItemRotation");
if (Rotation > 0)
{
- ItemFrame->SetItemRotation((Byte)a_NBT.GetByte(Rotation));
+ ItemFrame->SetItemRotation(static_cast<Byte>(a_NBT.GetByte(Rotation)));
}
a_Entities.push_back(ItemFrame.release());
@@ -1849,7 +1849,7 @@ void cWSSAnvil::LoadArrowFromNBT(cEntityList & a_Entities, const cParsedNBT & a_
int PickupIdx = a_NBT.FindChildByName(a_TagIdx, "pickup");
if ((PickupIdx > 0) && (a_NBT.GetType(PickupIdx) == TAG_Byte))
{
- Arrow->SetPickupState((cArrowEntity::ePickupState)a_NBT.GetByte(PickupIdx));
+ Arrow->SetPickupState(static_cast<cArrowEntity::ePickupState>(a_NBT.GetByte(PickupIdx)));
}
else
{
@@ -1888,7 +1888,7 @@ void cWSSAnvil::LoadArrowFromNBT(cEntityList & a_Entities, const cParsedNBT & a_
case TAG_Short:
{
// Vanilla uses this
- Arrow->SetBlockHit(Vector3i((int)a_NBT.GetShort(InBlockXIdx), (int)a_NBT.GetShort(InBlockYIdx), (int)a_NBT.GetShort(InBlockZIdx)));
+ Arrow->SetBlockHit(Vector3i(static_cast<int>(a_NBT.GetShort(InBlockXIdx)), static_cast<int>(a_NBT.GetShort(InBlockYIdx)), static_cast<int>(a_NBT.GetShort(InBlockZIdx))));
break;
}
default:
@@ -1919,8 +1919,8 @@ void cWSSAnvil::LoadSplashPotionFromNBT(cEntityList & a_Entities, const cParsedN
int EffectIntensity = a_NBT.FindChildByName(a_TagIdx, "EffectIntensity");
int EffectDistanceModifier = a_NBT.FindChildByName(a_TagIdx, "EffectDistanceModifier");
- SplashPotion->SetEntityEffectType((cEntityEffect::eType) a_NBT.FindChildByName(a_TagIdx, "EffectType"));
- SplashPotion->SetEntityEffect(cEntityEffect(EffectDuration, EffectIntensity, EffectDistanceModifier));
+ SplashPotion->SetEntityEffectType(static_cast<cEntityEffect::eType>(a_NBT.FindChildByName(a_TagIdx, "EffectType")));
+ SplashPotion->SetEntityEffect(cEntityEffect(EffectDuration, static_cast<Int16>(EffectIntensity), EffectDistanceModifier));
SplashPotion->SetPotionColor(a_NBT.FindChildByName(a_TagIdx, "PotionName"));
// Store the new splash potion in the entities list:
@@ -2261,7 +2261,7 @@ void cWSSAnvil::LoadHorseFromNBT(cEntityList & a_Entities, const cParsedNBT & a_
if (AgeableIdx > 0)
{
Byte Age = a_NBT.GetByte(AgeableIdx);
- Monster->SetAge(Age);
+ Monster->SetAge(static_cast<char>(Age));
}
a_Entities.push_back(Monster.release());
@@ -2357,7 +2357,7 @@ void cWSSAnvil::LoadOcelotFromNBT(cEntityList & a_Entities, const cParsedNBT & a
if (AgeableIdx > 0)
{
Byte Age = a_NBT.GetByte(AgeableIdx);
- Monster->SetAge(Age);
+ Monster->SetAge(static_cast<char>(Age));
}
a_Entities.push_back(Monster.release());
@@ -2384,7 +2384,7 @@ void cWSSAnvil::LoadPigFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NB
if (AgeableIdx > 0)
{
Byte Age = a_NBT.GetByte(AgeableIdx);
- Monster->SetAge(Age);
+ Monster->SetAge(static_cast<char>(Age));
}
a_Entities.push_back(Monster.release());
@@ -2422,7 +2422,7 @@ void cWSSAnvil::LoadRabbitFromNBT(cEntityList & a_Entities, const cParsedNBT & a
if (AgeableIdx > 0)
{
Byte Age = a_NBT.GetByte(AgeableIdx);
- Monster->SetAge(Age);
+ Monster->SetAge(static_cast<char>(Age));
}
a_Entities.push_back(Monster.release());
@@ -2438,7 +2438,7 @@ void cWSSAnvil::LoadSheepFromNBT(cEntityList & a_Entities, const cParsedNBT & a_
int Color = -1;
if (ColorIdx > 0)
{
- Color = (int)a_NBT.GetByte(ColorIdx);
+ Color = static_cast<int>(a_NBT.GetByte(ColorIdx));
}
std::unique_ptr<cSheep> Monster = cpp14::make_unique<cSheep>(Color);
@@ -2462,7 +2462,7 @@ void cWSSAnvil::LoadSheepFromNBT(cEntityList & a_Entities, const cParsedNBT & a_
if (AgeableIdx > 0)
{
Byte Age = a_NBT.GetByte(AgeableIdx);
- Monster->SetAge(Age);
+ Monster->SetAge(static_cast<char>(Age));
}
a_Entities.push_back(Monster.release());
@@ -2634,7 +2634,7 @@ void cWSSAnvil::LoadVillagerFromNBT(cEntityList & a_Entities, const cParsedNBT &
if (AgeableIdx > 0)
{
Byte Age = a_NBT.GetByte(AgeableIdx);
- Monster->SetAge(Age);
+ Monster->SetAge(static_cast<char>(Age));
}
@@ -2681,7 +2681,7 @@ void cWSSAnvil::LoadWitherFromNBT(cEntityList & a_Entities, const cParsedNBT & a
int CurrLine = a_NBT.FindChildByName(a_TagIdx, "Invul");
if (CurrLine > 0)
{
- Monster->SetWitherInvulnerableTicks(a_NBT.GetInt(CurrLine));
+ Monster->SetWitherInvulnerableTicks(static_cast<unsigned int>(a_NBT.GetInt(CurrLine)));
}
a_Entities.push_back(Monster.release());
@@ -2742,7 +2742,7 @@ void cWSSAnvil::LoadWolfFromNBT(cEntityList & a_Entities, const cParsedNBT & a_N
if (AgeableIdx > 0)
{
Byte Age = a_NBT.GetByte(AgeableIdx);
- Monster->SetAge(Age);
+ Monster->SetAge(static_cast<char>(Age));
}
a_Entities.push_back(Monster.release());
@@ -2777,7 +2777,7 @@ void cWSSAnvil::LoadZombieFromNBT(cEntityList & a_Entities, const cParsedNBT & a
if (AgeableIdx > 0)
{
Byte Age = a_NBT.GetByte(AgeableIdx);
- Monster->SetAge(Age);
+ Monster->SetAge(static_cast<char>(Age));
}
a_Entities.push_back(Monster.release());
@@ -2804,7 +2804,7 @@ void cWSSAnvil::LoadPigZombieFromNBT(cEntityList & a_Entities, const cParsedNBT
if (AgeableIdx > 0)
{
Byte Age = a_NBT.GetByte(AgeableIdx);
- Monster->SetAge(Age);
+ Monster->SetAge(static_cast<char>(Age));
}
a_Entities.push_back(Monster.release());
@@ -3138,7 +3138,7 @@ bool cWSSAnvil::cMCAFile::GetChunkData(const cChunkCoords & a_Chunk, AString & a
return false;
}
- m_File.Seek((int)ChunkOffset * 4096);
+ m_File.Seek(static_cast<int>(ChunkOffset) * 4096);
int ChunkSize = 0;
if (m_File.Read(&ChunkSize, 4) != 4)
@@ -3162,8 +3162,8 @@ bool cWSSAnvil::cMCAFile::GetChunkData(const cChunkCoords & a_Chunk, AString & a
ChunkSize--;
// HACK: This depends on the internal knowledge that AString's data() function returns the internal buffer directly
- a_Data.assign(ChunkSize, '\0');
- if (m_File.Read((void *)a_Data.data(), ChunkSize) == ChunkSize)
+ a_Data.assign(static_cast<size_t>(ChunkSize), '\0');
+ if (static_cast<size_t>(m_File.Read(static_cast<void *>(const_cast<char*>(a_Data.data())), static_cast<size_t>(ChunkSize))) == static_cast<size_t>(ChunkSize))
{
return true;
}
@@ -3197,7 +3197,7 @@ bool cWSSAnvil::cMCAFile::SetChunkData(const cChunkCoords & a_Chunk, const AStri
unsigned ChunkSector = FindFreeLocation(LocalX, LocalZ, a_Data);
// Store the chunk data:
- m_File.Seek(ChunkSector * 4096);
+ m_File.Seek(static_cast<int>(ChunkSector * 4096));
u_long ChunkSize = htonl(static_cast<u_long>(a_Data.size()) + 1);
if (m_File.Write(&ChunkSize, 4) != 4)
{
@@ -3210,7 +3210,7 @@ bool cWSSAnvil::cMCAFile::SetChunkData(const cChunkCoords & a_Chunk, const AStri
LOGWARNING("Cannot save chunk [%d, %d], writing(2) data to file \"%s\" failed", a_Chunk.m_ChunkX, a_Chunk.m_ChunkZ, GetFileName().c_str());
return false;
}
- if (m_File.Write(a_Data.data(), a_Data.size()) != (int)(a_Data.size()))
+ if (m_File.Write(a_Data.data(), a_Data.size()) != static_cast<int>(a_Data.size()))
{
LOGWARNING("Cannot save chunk [%d, %d], writing(3) data to file \"%s\" failed", a_Chunk.m_ChunkX, a_Chunk.m_ChunkZ, GetFileName().c_str());
return false;