commit
735d590abf
@ -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()
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -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),
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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; \
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
} ;
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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:
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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.
|
||||
{
|
||||
|
@ -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));
|
||||
}
|
||||
} ;
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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());
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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()
|
||||
|
@ -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)
|
||||
|
@ -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()
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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()
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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()
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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()
|
||||
|
@ -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;
|
||||
|
@ -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();
|
||||
|
@ -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;
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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()
|
||||
|
@ -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())
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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()
|
||||
);
|
||||
}
|
||||
|
30
src/Item.cpp
30
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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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)
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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());
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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:
|
||||
|
@ -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
|
||||
}
|
||||
} ;
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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));
|
||||
|
@ -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:
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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();
|
||||
|
@ -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)
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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.
|
||||
|
@ -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()
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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());
|
||||
|
@ -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;
|
||||
|
@ -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());
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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]);
|
||||
}
|
||||
|
||||
|
||||
|
10
src/Root.cpp
10
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);
|
||||
|
@ -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)
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user