diff options
author | Samuel Barney <samjbarney@gmail.com> | 2015-07-29 17:04:03 +0200 |
---|---|---|
committer | Samuel Barney <samjbarney@gmail.com> | 2015-07-29 17:49:30 +0200 |
commit | 804805d35a87c2acc9425d1762ad26b1ba2ec9ac (patch) | |
tree | 13b603c8bbf8177da92ce87f5413fb646d204f3f /src/Bindings | |
parent | Merge pull request #2376 from mjhanninen/fix-freebsd-build (diff) | |
download | cuberite-804805d35a87c2acc9425d1762ad26b1ba2ec9ac.tar cuberite-804805d35a87c2acc9425d1762ad26b1ba2ec9ac.tar.gz cuberite-804805d35a87c2acc9425d1762ad26b1ba2ec9ac.tar.bz2 cuberite-804805d35a87c2acc9425d1762ad26b1ba2ec9ac.tar.lz cuberite-804805d35a87c2acc9425d1762ad26b1ba2ec9ac.tar.xz cuberite-804805d35a87c2acc9425d1762ad26b1ba2ec9ac.tar.zst cuberite-804805d35a87c2acc9425d1762ad26b1ba2ec9ac.zip |
Diffstat (limited to 'src/Bindings')
-rw-r--r-- | src/Bindings/CMakeLists.txt | 6 | ||||
-rw-r--r-- | src/Bindings/DeprecatedBindings.cpp | 70 | ||||
-rw-r--r-- | src/Bindings/LuaState.cpp | 36 | ||||
-rw-r--r-- | src/Bindings/LuaState.h | 1 | ||||
-rw-r--r-- | src/Bindings/ManualBindings.cpp | 116 | ||||
-rw-r--r-- | src/Bindings/ManualBindings_World.cpp | 8 | ||||
-rw-r--r-- | src/Bindings/Plugin.h | 2 | ||||
-rw-r--r-- | src/Bindings/PluginLua.cpp | 164 | ||||
-rw-r--r-- | src/Bindings/PluginLua.h | 2 | ||||
-rw-r--r-- | src/Bindings/PluginManager.cpp | 2 | ||||
-rw-r--r-- | src/Bindings/PluginManager.h | 2 |
11 files changed, 208 insertions, 201 deletions
diff --git a/src/Bindings/CMakeLists.txt b/src/Bindings/CMakeLists.txt index 0a069ad85..edcda273e 100644 --- a/src/Bindings/CMakeLists.txt +++ b/src/Bindings/CMakeLists.txt @@ -146,16 +146,10 @@ set_source_files_properties(${BINDING_OUTPUTS} PROPERTIES GENERATED TRUE) set_source_files_properties(${CMAKE_SOURCE_DIR}/src/Bindings/Bindings.cpp PROPERTIES COMPILE_FLAGS -Wno-error) if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - set_source_files_properties(DeprecatedBindings.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=old-style-cast") - set_source_files_properties(LuaState.cpp COMPILE_FLAGS "-Wno-error=old-style-cast") set_source_files_properties(LuaWindow.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=switch-enum") - set_source_files_properties(ManualBindings.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=old-style-cast") - set_source_files_properties(ManualBindings_World.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=old-style-cast") - set_source_files_properties(PluginLua.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=old-style-cast") endif() if(NOT MSVC) add_library(Bindings ${SRCS} ${HDRS}) - target_link_libraries(Bindings lua sqlite tolualib mbedtls) endif() diff --git a/src/Bindings/DeprecatedBindings.cpp b/src/Bindings/DeprecatedBindings.cpp index 6dd6a4e59..574a017a6 100644 --- a/src/Bindings/DeprecatedBindings.cpp +++ b/src/Bindings/DeprecatedBindings.cpp @@ -19,7 +19,7 @@ #ifndef TOLUA_DISABLE_tolua_get_AllToLua_g_BlockLightValue static int tolua_get_AllToLua_g_BlockLightValue(lua_State* tolua_S) { - int BlockType; + BLOCKTYPE BlockType; #ifndef TOLUA_RELEASE { tolua_Error tolua_err; @@ -29,12 +29,12 @@ static int tolua_get_AllToLua_g_BlockLightValue(lua_State* tolua_S) } } #endif - BlockType = (int)tolua_tonumber(tolua_S, 2, 0); + BlockType = static_cast<BLOCKTYPE>(tolua_tonumber(tolua_S, 2, 0)); if ((BlockType < 0) || (BlockType > E_BLOCK_MAX_TYPE_ID)) { tolua_error(tolua_S, "array indexing out of range.", nullptr); } - tolua_pushnumber(tolua_S, (lua_Number)cBlockInfo::GetLightValue((BLOCKTYPE)BlockType)); + tolua_pushnumber(tolua_S, static_cast<lua_Number>(cBlockInfo::GetLightValue(BlockType))); return 1; } #endif // #ifndef TOLUA_DISABLE @@ -47,7 +47,7 @@ static int tolua_get_AllToLua_g_BlockLightValue(lua_State* tolua_S) #ifndef TOLUA_DISABLE_tolua_get_AllToLua_g_BlockSpreadLightFalloff static int tolua_get_AllToLua_g_BlockSpreadLightFalloff(lua_State* tolua_S) { - int BlockType; + BLOCKTYPE BlockType; #ifndef TOLUA_RELEASE { tolua_Error tolua_err; @@ -57,12 +57,12 @@ static int tolua_get_AllToLua_g_BlockSpreadLightFalloff(lua_State* tolua_S) } } #endif - BlockType = (int)tolua_tonumber(tolua_S, 2, 0); + BlockType = static_cast<BLOCKTYPE>(tolua_tonumber(tolua_S, 2, 0)); if ((BlockType < 0) || (BlockType > E_BLOCK_MAX_TYPE_ID)) { tolua_error(tolua_S, "array indexing out of range.", nullptr); } - tolua_pushnumber(tolua_S, (lua_Number)cBlockInfo::GetSpreadLightFalloff((BLOCKTYPE)BlockType)); + tolua_pushnumber(tolua_S, static_cast<lua_Number>(cBlockInfo::GetSpreadLightFalloff(BlockType))); return 1; } #endif // #ifndef TOLUA_DISABLE @@ -75,7 +75,7 @@ static int tolua_get_AllToLua_g_BlockSpreadLightFalloff(lua_State* tolua_S) #ifndef TOLUA_DISABLE_tolua_get_AllToLua_g_BlockTransparent static int tolua_get_AllToLua_g_BlockTransparent(lua_State* tolua_S) { - int BlockType; + BLOCKTYPE BlockType; #ifndef TOLUA_RELEASE { tolua_Error tolua_err; @@ -85,12 +85,12 @@ static int tolua_get_AllToLua_g_BlockTransparent(lua_State* tolua_S) } } #endif - BlockType = (int)tolua_tonumber(tolua_S, 2, 0); + BlockType = static_cast<BLOCKTYPE>(tolua_tonumber(tolua_S, 2, 0)); if ((BlockType < 0) || (BlockType > E_BLOCK_MAX_TYPE_ID)) { tolua_error(tolua_S, "array indexing out of range.", nullptr); } - tolua_pushboolean(tolua_S, cBlockInfo::IsTransparent((BLOCKTYPE)BlockType)); + tolua_pushboolean(tolua_S, cBlockInfo::IsTransparent(BlockType)); return 1; } #endif // #ifndef TOLUA_DISABLE @@ -103,7 +103,7 @@ static int tolua_get_AllToLua_g_BlockTransparent(lua_State* tolua_S) #ifndef TOLUA_DISABLE_tolua_get_AllToLua_g_BlockOneHitDig static int tolua_get_AllToLua_g_BlockOneHitDig(lua_State* tolua_S) { - int BlockType; + BLOCKTYPE BlockType; #ifndef TOLUA_RELEASE { tolua_Error tolua_err; @@ -113,12 +113,12 @@ static int tolua_get_AllToLua_g_BlockOneHitDig(lua_State* tolua_S) } } #endif - BlockType = (int)tolua_tonumber(tolua_S, 2, 0); + BlockType = static_cast<BLOCKTYPE>(tolua_tonumber(tolua_S, 2, 0)); if ((BlockType < 0) || (BlockType > E_BLOCK_MAX_TYPE_ID)) { tolua_error(tolua_S, "array indexing out of range.", nullptr); } - tolua_pushboolean(tolua_S, cBlockInfo::IsOneHitDig((BLOCKTYPE)BlockType)); + tolua_pushboolean(tolua_S, cBlockInfo::IsOneHitDig(BlockType)); return 1; } #endif // #ifndef TOLUA_DISABLE @@ -131,7 +131,7 @@ static int tolua_get_AllToLua_g_BlockOneHitDig(lua_State* tolua_S) #ifndef TOLUA_DISABLE_tolua_get_AllToLua_g_BlockPistonBreakable static int tolua_get_AllToLua_g_BlockPistonBreakable(lua_State* tolua_S) { - int BlockType; + BLOCKTYPE BlockType; #ifndef TOLUA_RELEASE { tolua_Error tolua_err; @@ -141,12 +141,12 @@ static int tolua_get_AllToLua_g_BlockPistonBreakable(lua_State* tolua_S) } } #endif - BlockType = (int)tolua_tonumber(tolua_S, 2, 0); + BlockType = static_cast<BLOCKTYPE>(tolua_tonumber(tolua_S, 2, 0)); if ((BlockType < 0) || (BlockType > E_BLOCK_MAX_TYPE_ID)) { tolua_error(tolua_S, "array indexing out of range.", nullptr); } - tolua_pushboolean(tolua_S, cBlockInfo::IsPistonBreakable((BLOCKTYPE)BlockType)); + tolua_pushboolean(tolua_S, cBlockInfo::IsPistonBreakable(BlockType)); return 1; } #endif // #ifndef TOLUA_DISABLE @@ -159,7 +159,7 @@ static int tolua_get_AllToLua_g_BlockPistonBreakable(lua_State* tolua_S) #ifndef TOLUA_DISABLE_tolua_get_AllToLua_g_BlockIsSnowable static int tolua_get_AllToLua_g_BlockIsSnowable(lua_State* tolua_S) { - int BlockType; + BLOCKTYPE BlockType; #ifndef TOLUA_RELEASE { tolua_Error tolua_err; @@ -169,12 +169,12 @@ static int tolua_get_AllToLua_g_BlockIsSnowable(lua_State* tolua_S) } } #endif - BlockType = (int)tolua_tonumber(tolua_S, 2, 0); + BlockType = static_cast<BLOCKTYPE>(tolua_tonumber(tolua_S, 2, 0)); if ((BlockType < 0) || (BlockType > E_BLOCK_MAX_TYPE_ID)) { tolua_error(tolua_S, "array indexing out of range.", nullptr); } - tolua_pushboolean(tolua_S, cBlockInfo::IsSnowable((BLOCKTYPE)BlockType)); + tolua_pushboolean(tolua_S, cBlockInfo::IsSnowable(BlockType)); return 1; } #endif // #ifndef TOLUA_DISABLE @@ -187,7 +187,7 @@ static int tolua_get_AllToLua_g_BlockIsSnowable(lua_State* tolua_S) #ifndef TOLUA_DISABLE_tolua_get_AllToLua_g_BlockIsSolid static int tolua_get_AllToLua_g_BlockIsSolid(lua_State* tolua_S) { - int BlockType; + BLOCKTYPE BlockType; #ifndef TOLUA_RELEASE { tolua_Error tolua_err; @@ -197,12 +197,12 @@ static int tolua_get_AllToLua_g_BlockIsSolid(lua_State* tolua_S) } } #endif - BlockType = (int)tolua_tonumber(tolua_S, 2, 0); + BlockType = static_cast<BLOCKTYPE>(tolua_tonumber(tolua_S, 2, 0)); if ((BlockType < 0) || (BlockType > E_BLOCK_MAX_TYPE_ID)) { tolua_error(tolua_S, "array indexing out of range.", nullptr); } - tolua_pushboolean(tolua_S, (bool)cBlockInfo::IsSolid((BLOCKTYPE)BlockType)); + tolua_pushboolean(tolua_S, static_cast<bool>(cBlockInfo::IsSolid(BlockType))); return 1; } #endif // #ifndef TOLUA_DISABLE @@ -215,7 +215,7 @@ static int tolua_get_AllToLua_g_BlockIsSolid(lua_State* tolua_S) #ifndef TOLUA_DISABLE_tolua_get_AllToLua_g_BlockFullyOccupiesVoxel static int tolua_get_AllToLua_g_BlockFullyOccupiesVoxel(lua_State* tolua_S) { - int BlockType; + BLOCKTYPE BlockType; #ifndef TOLUA_RELEASE { tolua_Error tolua_err; @@ -225,12 +225,12 @@ static int tolua_get_AllToLua_g_BlockFullyOccupiesVoxel(lua_State* tolua_S) } } #endif - BlockType = (int)tolua_tonumber(tolua_S, 2, 0); + BlockType = static_cast<BLOCKTYPE>(tolua_tonumber(tolua_S, 2, 0)); if ((BlockType < 0) || (BlockType > E_BLOCK_MAX_TYPE_ID)) { tolua_error(tolua_S, "array indexing out of range.", nullptr); } - tolua_pushboolean(tolua_S, (bool)cBlockInfo::FullyOccupiesVoxel((BLOCKTYPE)BlockType)); + tolua_pushboolean(tolua_S, static_cast<bool>(cBlockInfo::FullyOccupiesVoxel(BlockType))); return 1; } #endif // #ifndef TOLUA_DISABLE @@ -256,8 +256,8 @@ static int tolua_AllToLua_StringToMobType00(lua_State* tolua_S) { const AString a_MobString = tolua_tocppstring(LuaState, 1, 0); eMonsterType MobType = cMonster::StringToMobType(a_MobString); - tolua_pushnumber(LuaState, (lua_Number) MobType); - tolua_pushcppstring(LuaState, (const char *) a_MobString); + tolua_pushnumber(LuaState, static_cast<lua_Number>(MobType)); + tolua_pushcppstring(LuaState, a_MobString); } LOGWARNING("Warning in function call 'StringToMobType': StringToMobType() is deprecated. Please use cMonster:StringToMobType()"); @@ -298,15 +298,15 @@ static int tolua_cWorld_SetSignLines(lua_State * tolua_S) else #endif { - cWorld * self = (cWorld *) tolua_tousertype (LuaState, 1, nullptr); - int BlockX = (int) tolua_tonumber (LuaState, 2, 0); - int BlockY = (int) tolua_tonumber (LuaState, 3, 0); - int BlockZ = (int) tolua_tonumber (LuaState, 4, 0); - const AString Line1 = tolua_tocppstring(LuaState, 5, 0); - const AString Line2 = tolua_tocppstring(LuaState, 6, 0); - const AString Line3 = tolua_tocppstring(LuaState, 7, 0); - const AString Line4 = tolua_tocppstring(LuaState, 8, 0); - cPlayer * Player = (cPlayer *)tolua_tousertype (LuaState, 9, nullptr); + cWorld * self = reinterpret_cast<cWorld *>(tolua_tousertype (LuaState, 1, nullptr)); + cPlayer * Player = reinterpret_cast<cPlayer*>(tolua_tousertype (LuaState, 9, nullptr)); + int BlockX = static_cast<int>(tolua_tonumber(LuaState, 2, 0)); + int BlockY = static_cast<int>(tolua_tonumber(LuaState, 3, 0)); + int BlockZ = static_cast<int>(tolua_tonumber(LuaState, 4, 0)); + const AString Line1 = tolua_tocppstring(LuaState, 5, 0); + const AString Line2 = tolua_tocppstring(LuaState, 6, 0); + const AString Line3 = tolua_tocppstring(LuaState, 7, 0); + const AString Line4 = tolua_tocppstring(LuaState, 8, 0); #ifndef TOLUA_RELEASE if (self == nullptr) { diff --git a/src/Bindings/LuaState.cpp b/src/Bindings/LuaState.cpp index a0fdecb8b..7c0d2a121 100644 --- a/src/Bindings/LuaState.cpp +++ b/src/Bindings/LuaState.cpp @@ -379,7 +379,7 @@ void cLuaState::Push(const AStringVector & a_Vector) { ASSERT(IsValid()); - lua_createtable(m_LuaState, (int)a_Vector.size(), 0); + lua_createtable(m_LuaState, static_cast<int>(a_Vector.size()), 0); int newTable = lua_gettop(m_LuaState); int index = 1; for (AStringVector::const_iterator itr = a_Vector.begin(), end = a_Vector.end(); itr != end; ++itr, ++index) @@ -398,7 +398,7 @@ void cLuaState::Push(const cCraftingGrid * a_Grid) { ASSERT(IsValid()); - tolua_pushusertype(m_LuaState, (void *)a_Grid, "cCraftingGrid"); + tolua_pushusertype(m_LuaState, reinterpret_cast<void *>(const_cast<cCraftingGrid *>(a_Grid)), "cCraftingGrid"); m_NumCurrentFunctionArgs += 1; } @@ -410,7 +410,7 @@ void cLuaState::Push(const cCraftingRecipe * a_Recipe) { ASSERT(IsValid()); - tolua_pushusertype(m_LuaState, (void *)a_Recipe, "cCraftingRecipe"); + tolua_pushusertype(m_LuaState, reinterpret_cast<void *>(const_cast<cCraftingRecipe *>(a_Recipe)), "cCraftingRecipe"); m_NumCurrentFunctionArgs += 1; } @@ -434,7 +434,7 @@ void cLuaState::Push(const cItems & a_Items) { ASSERT(IsValid()); - tolua_pushusertype(m_LuaState, (void *)&a_Items, "cItems"); + tolua_pushusertype(m_LuaState, reinterpret_cast<void *>(const_cast<cItems *>(&a_Items)), "cItems"); m_NumCurrentFunctionArgs += 1; } @@ -446,7 +446,7 @@ void cLuaState::Push(const cPlayer * a_Player) { ASSERT(IsValid()); - tolua_pushusertype(m_LuaState, (void *)a_Player, "cPlayer"); + tolua_pushusertype(m_LuaState, reinterpret_cast<void *>(const_cast<cPlayer *>(a_Player)), "cPlayer"); m_NumCurrentFunctionArgs += 1; } @@ -470,7 +470,7 @@ void cLuaState::Push(const HTTPRequest * a_Request) { ASSERT(IsValid()); - tolua_pushusertype(m_LuaState, (void *)a_Request, "HTTPRequest"); + tolua_pushusertype(m_LuaState, reinterpret_cast<void *>(const_cast<HTTPRequest *>(a_Request)), "HTTPRequest"); m_NumCurrentFunctionArgs += 1; } @@ -482,7 +482,7 @@ void cLuaState::Push(const HTTPTemplateRequest * a_Request) { ASSERT(IsValid()); - tolua_pushusertype(m_LuaState, (void *)a_Request, "HTTPTemplateRequest"); + tolua_pushusertype(m_LuaState, reinterpret_cast<void *>(const_cast<HTTPTemplateRequest *>(a_Request)), "HTTPTemplateRequest"); m_NumCurrentFunctionArgs += 1; } @@ -494,7 +494,7 @@ void cLuaState::Push(const Vector3d & a_Vector) { ASSERT(IsValid()); - tolua_pushusertype(m_LuaState, (void *)&a_Vector, "Vector3<double>"); + tolua_pushusertype(m_LuaState, reinterpret_cast<void *>(const_cast<Vector3d *>(&a_Vector)), "Vector3<double>"); m_NumCurrentFunctionArgs += 1; } @@ -506,7 +506,7 @@ void cLuaState::Push(const Vector3d * a_Vector) { ASSERT(IsValid()); - tolua_pushusertype(m_LuaState, (void *)a_Vector, "Vector3<double>"); + tolua_pushusertype(m_LuaState, reinterpret_cast<void *>(const_cast<Vector3d *>(a_Vector)), "Vector3<double>"); m_NumCurrentFunctionArgs += 1; } @@ -518,7 +518,7 @@ void cLuaState::Push(const Vector3i & a_Vector) { ASSERT(IsValid()); - tolua_pushusertype(m_LuaState, (void *)&a_Vector, "Vector3<int>"); + tolua_pushusertype(m_LuaState, reinterpret_cast<void *>(const_cast<Vector3i *>(&a_Vector)), "Vector3<int>"); m_NumCurrentFunctionArgs += 1; } @@ -530,7 +530,7 @@ void cLuaState::Push(const Vector3i * a_Vector) { ASSERT(IsValid()); - tolua_pushusertype(m_LuaState, (void *)a_Vector, "Vector3<int>"); + tolua_pushusertype(m_LuaState, reinterpret_cast<void *>(const_cast<Vector3i *>(a_Vector)), "Vector3<int>"); m_NumCurrentFunctionArgs += 1; } @@ -676,6 +676,18 @@ void cLuaState::Push(int a_Value) +void cLuaState::Push(UInt32 a_Value) +{ + ASSERT(IsValid()); + + tolua_pushnumber(m_LuaState, a_Value); + m_NumCurrentFunctionArgs += 1; +} + + + + + void cLuaState::Push(void * a_Ptr) { UNUSED(a_Ptr); @@ -1406,7 +1418,7 @@ void cLuaState::LogStack(lua_State * a_LuaState, const char * a_Header) { case LUA_TBOOLEAN: Value.assign((lua_toboolean(a_LuaState, i) != 0) ? "true" : "false"); break; case LUA_TLIGHTUSERDATA: Printf(Value, "%p", lua_touserdata(a_LuaState, i)); break; - case LUA_TNUMBER: Printf(Value, "%f", (double)lua_tonumber(a_LuaState, i)); break; + case LUA_TNUMBER: Printf(Value, "%f", static_cast<double>(lua_tonumber(a_LuaState, i))); break; case LUA_TSTRING: Printf(Value, "%s", lua_tostring(a_LuaState, i)); break; case LUA_TTABLE: Printf(Value, "%p", lua_topointer(a_LuaState, i)); break; default: break; diff --git a/src/Bindings/LuaState.h b/src/Bindings/LuaState.h index cc8214646..759fdc54f 100644 --- a/src/Bindings/LuaState.h +++ b/src/Bindings/LuaState.h @@ -248,6 +248,7 @@ public: void Push(cLuaUDPEndpoint * a_UDPEndpoint); void Push(double a_Value); void Push(int a_Value); + void Push(const UInt32 a_Value); void Push(void * a_Ptr); void Push(std::chrono::milliseconds a_time); diff --git a/src/Bindings/ManualBindings.cpp b/src/Bindings/ManualBindings.cpp index 7655d8c83..e4420c39a 100644 --- a/src/Bindings/ManualBindings.cpp +++ b/src/Bindings/ManualBindings.cpp @@ -319,7 +319,7 @@ static AString GetLogMessage(lua_State * tolua_S) tolua_Error err; if (tolua_isusertype(tolua_S, 1, "cCompositeChat", false, &err)) { - return ((cCompositeChat *)tolua_tousertype(tolua_S, 1, nullptr))->ExtractText(); + return reinterpret_cast<cCompositeChat *>(tolua_tousertype(tolua_S, 1, nullptr))->ExtractText(); } else { @@ -352,7 +352,7 @@ static int tolua_LOG(lua_State * tolua_S) tolua_Error err; if (tolua_isusertype(tolua_S, 1, "cCompositeChat", false, &err)) { - LogLevel = cCompositeChat::MessageTypeToLogLevel(((cCompositeChat *)tolua_tousertype(tolua_S, 1, nullptr))->GetMessageType()); + LogLevel = cCompositeChat::MessageTypeToLogLevel(reinterpret_cast<cCompositeChat *>(tolua_tousertype(tolua_S, 1, nullptr))->GetMessageType()); } // Log the message: @@ -472,7 +472,7 @@ cPluginLua * cManualBindings::GetLuaPlugin(lua_State * L) lua_pop(L, 1); return nullptr; } - cPluginLua * Plugin = (cPluginLua *)lua_topointer(L, -1); + cPluginLua * Plugin = reinterpret_cast<cPluginLua *>(const_cast<void*>(lua_topointer(L, -1))); lua_pop(L, 1); return Plugin; @@ -602,7 +602,7 @@ static int tolua_cPluginManager_AddHook_FnRef(cPluginManager * a_PluginManager, } // Retrieve and check the hook type - int HookType = (int)tolua_tonumber(S, a_ParamIdx, -1); + int HookType = static_cast<int>(tolua_tonumber(S, a_ParamIdx, -1)); if (!a_PluginManager->IsValidHookType(HookType)) { LOGWARNING("cPluginManager.AddHook(): Invalid HOOK_TYPE parameter: %d", HookType); @@ -634,7 +634,7 @@ static int tolua_cPluginManager_AddHook_DefFn(cPluginManager * a_PluginManager, // The arg types have already been checked // Retrieve and check the cPlugin parameter - cPluginLua * Plugin = (cPluginLua *)tolua_tousertype(S, a_ParamIdx, nullptr); + cPluginLua * Plugin = reinterpret_cast<cPluginLua *>(tolua_tousertype(S, a_ParamIdx, nullptr)); if (Plugin == nullptr) { LOGWARNING("cPluginManager.AddHook(): Invalid Plugin parameter, expected a valid cPlugin object. Hook not added"); @@ -650,7 +650,7 @@ static int tolua_cPluginManager_AddHook_DefFn(cPluginManager * a_PluginManager, } // Retrieve and check the hook type - int HookType = (int)tolua_tonumber(S, a_ParamIdx + 1, -1); + int HookType = static_cast<int>(tolua_tonumber(S, a_ParamIdx + 1, -1)); if (!a_PluginManager->IsValidHookType(HookType)) { LOGWARNING("cPluginManager.AddHook(): Invalid HOOK_TYPE parameter: %d", HookType); @@ -707,7 +707,7 @@ static int tolua_cPluginManager_AddHook(lua_State * tolua_S) if (tolua_isusertype(S, 1, "cPluginManager", 0, &err)) { // Style 2 or 3, retrieve the PlgMgr instance - PlgMgr = (cPluginManager *)tolua_tousertype(S, 1, nullptr); + PlgMgr = reinterpret_cast<cPluginManager *>(tolua_tousertype(S, 1, nullptr)); if (PlgMgr == nullptr) { LOGWARNING("Malformed plugin, use cPluginManager.AddHook(HOOK_TYPE, CallbackFunction). Fixing the call for you."); @@ -1148,7 +1148,7 @@ static int tolua_cPlayer_GetPermissions(lua_State * tolua_S) } // Get the params: - cPlayer * self = (cPlayer *)tolua_tousertype(tolua_S, 1, nullptr); + cPlayer * self = reinterpret_cast<cPlayer *>(tolua_tousertype(tolua_S, 1, nullptr)); if (self == nullptr) { LOGWARNING("%s: invalid self (%p)", __FUNCTION__, self); @@ -1179,7 +1179,7 @@ static int tolua_cPlayer_GetRestrictions(lua_State * tolua_S) } // Get the params: - cPlayer * self = (cPlayer *)tolua_tousertype(tolua_S, 1, nullptr); + cPlayer * self = reinterpret_cast<cPlayer *>(tolua_tousertype(tolua_S, 1, nullptr)); if (self == nullptr) { LOGWARNING("%s: invalid self (%p)", __FUNCTION__, self); @@ -1207,8 +1207,8 @@ static int tolua_cPlayer_OpenWindow(lua_State * tolua_S) } // Get the parameters: - cPlayer * self = (cPlayer *)tolua_tousertype(tolua_S, 1, nullptr); - cWindow * wnd = (cWindow *)tolua_tousertype(tolua_S, 2, nullptr); + cPlayer * self = reinterpret_cast<cPlayer *>(tolua_tousertype(tolua_S, 1, nullptr)); + cWindow * wnd = reinterpret_cast<cWindow *>(tolua_tousertype(tolua_S, 2, nullptr)); if ((self == nullptr) || (wnd == nullptr)) { LOGWARNING("%s: invalid self (%p) or wnd (%p)", __FUNCTION__, self, wnd); @@ -1219,7 +1219,7 @@ static int tolua_cPlayer_OpenWindow(lua_State * tolua_S) tolua_Error err; if (tolua_isusertype(tolua_S, 2, "cLuaWindow", 0, &err)) { - cLuaWindow * LuaWnd = (cLuaWindow *)wnd; + cLuaWindow * LuaWnd = reinterpret_cast<cLuaWindow *>(wnd); // Only if not already referenced if (!LuaWnd->IsLuaReferenced()) { @@ -1289,7 +1289,7 @@ static int tolua_SetObjectCallback(lua_State * tolua_S) } // Get the parameters - self and the function reference: - OBJTYPE * self = (OBJTYPE *)tolua_tousertype(tolua_S, 1, nullptr); + OBJTYPE * self = reinterpret_cast<OBJTYPE *>(tolua_tousertype(tolua_S, 1, nullptr)); if (self == nullptr) { LOGWARNING("%s: invalid self (%p)", __FUNCTION__, self); @@ -1313,7 +1313,7 @@ static int tolua_SetObjectCallback(lua_State * tolua_S) static int tolua_cPluginLua_AddWebTab(lua_State * tolua_S) { - cPluginLua * self = (cPluginLua *)tolua_tousertype(tolua_S, 1, nullptr); + cPluginLua * self = reinterpret_cast<cPluginLua *>(tolua_tousertype(tolua_S, 1, nullptr)); tolua_Error tolua_err; tolua_err.array = 0; @@ -1329,7 +1329,7 @@ static int tolua_cPluginLua_AddWebTab(lua_State * tolua_S) ) { Reference = luaL_ref(tolua_S, LUA_REGISTRYINDEX); - Title = ((std::string)tolua_tocppstring(tolua_S, 2, 0)); + Title = (static_cast<std::string>(tolua_tocppstring(tolua_S, 2, 0))); } else { @@ -1400,13 +1400,13 @@ static int tolua_md5(lua_State * tolua_S) // Calculate the raw md5 checksum byte array: unsigned char Output[16]; size_t len = 0; - const unsigned char * SourceString = (const unsigned char *)lua_tolstring(tolua_S, 1, &len); + const unsigned char * SourceString = reinterpret_cast<const unsigned char *>(lua_tolstring(tolua_S, 1, &len)); if (SourceString == nullptr) { return 0; } md5(SourceString, len, Output); - lua_pushlstring(tolua_S, (const char *)Output, ARRAYCOUNT(Output)); + lua_pushlstring(tolua_S, reinterpret_cast<const char *>(Output), ARRAYCOUNT(Output)); return 1; } @@ -1431,7 +1431,7 @@ static int tolua_md5HexString(lua_State * tolua_S) // Calculate the raw md5 checksum byte array: unsigned char md5Output[16]; size_t len = 0; - const unsigned char * SourceString = (const unsigned char *)lua_tolstring(tolua_S, 1, &len); + const unsigned char * SourceString = reinterpret_cast<const unsigned char *>(lua_tolstring(tolua_S, 1, &len)); if (SourceString == nullptr) { return 0; @@ -1458,13 +1458,13 @@ static int tolua_sha1(lua_State * tolua_S) // Calculate the raw SHA1 checksum byte array from the input string: unsigned char Output[20]; size_t len = 0; - const unsigned char * SourceString = (const unsigned char *)lua_tolstring(tolua_S, 1, &len); + const unsigned char * SourceString = reinterpret_cast<const unsigned char *>(lua_tolstring(tolua_S, 1, &len)); if (SourceString == nullptr) { return 0; } sha1(SourceString, len, Output); - lua_pushlstring(tolua_S, (const char *)Output, ARRAYCOUNT(Output)); + lua_pushlstring(tolua_S, reinterpret_cast<const char *>(Output), ARRAYCOUNT(Output)); return 1; } @@ -1477,7 +1477,7 @@ static int tolua_sha1HexString(lua_State * tolua_S) // Calculate the raw SHA1 checksum byte array from the input string: unsigned char sha1Output[20]; size_t len = 0; - const unsigned char * SourceString = (const unsigned char *)lua_tolstring(tolua_S, 1, &len); + const unsigned char * SourceString = reinterpret_cast<const unsigned char *>(lua_tolstring(tolua_S, 1, &len)); if (SourceString == nullptr) { return 0; @@ -1565,18 +1565,18 @@ static int tolua_get_HTTPRequest_FormData(lua_State* tolua_S) static int tolua_cWebAdmin_GetPlugins(lua_State * tolua_S) { - cWebAdmin * self = (cWebAdmin *)tolua_tousertype(tolua_S, 1, nullptr); + cWebAdmin * self = reinterpret_cast<cWebAdmin *>(tolua_tousertype(tolua_S, 1, nullptr)); const cWebAdmin::PluginList & AllPlugins = self->GetPlugins(); - lua_createtable(tolua_S, (int)AllPlugins.size(), 0); + lua_createtable(tolua_S, static_cast<int>(AllPlugins.size()), 0); int newTable = lua_gettop(tolua_S); int index = 1; cWebAdmin::PluginList::const_iterator iter = AllPlugins.begin(); while (iter != AllPlugins.end()) { const cWebPlugin * Plugin = *iter; - tolua_pushusertype(tolua_S, (void *)Plugin, "const cWebPlugin"); + tolua_pushusertype(tolua_S, reinterpret_cast<void *>(const_cast<cWebPlugin*>(Plugin)), "const cWebPlugin"); lua_rawseti(tolua_S, newTable, index); ++iter; ++index; @@ -1676,7 +1676,7 @@ static int tolua_cClientHandle_SendPluginMessage(lua_State * L) { return 0; } - cClientHandle * Client = (cClientHandle *)tolua_tousertype(L, 1, nullptr); + cClientHandle * Client = reinterpret_cast<cClientHandle *>(tolua_tousertype(L, 1, nullptr)); if (Client == nullptr) { LOGWARNING("ClientHandle is nil in cClientHandle:SendPluginMessage()"); @@ -1922,8 +1922,8 @@ static int Lua_ItemGrid_GetSlotCoords(lua_State * L) } { - const cItemGrid * self = (const cItemGrid *)tolua_tousertype(L, 1, nullptr); - int SlotNum = (int)tolua_tonumber(L, 2, 0); + const cItemGrid * self = reinterpret_cast<const cItemGrid *>(tolua_tousertype(L, 1, nullptr)); + int SlotNum = static_cast<int>(tolua_tonumber(L, 2, 0)); if (self == nullptr) { tolua_error(L, "invalid 'self' in function 'cItemGrid:GetSlotCoords'", nullptr); @@ -1931,8 +1931,8 @@ static int Lua_ItemGrid_GetSlotCoords(lua_State * L) } int X, Y; self->GetSlotCoords(SlotNum, X, Y); - tolua_pushnumber(L, (lua_Number)X); - tolua_pushnumber(L, (lua_Number)Y); + tolua_pushnumber(L, static_cast<lua_Number>(X)); + tolua_pushnumber(L, static_cast<lua_Number>(Y)); return 2; } @@ -2063,7 +2063,7 @@ static int tolua_cLineBlockTracer_Trace(lua_State * tolua_S) } // Trace: - cWorld * World = (cWorld *)tolua_tousertype(L, idx, nullptr); + cWorld * World = reinterpret_cast<cWorld *>(tolua_tousertype(L, idx, nullptr)); cLuaBlockTracerCallbacks Callbacks(L, idx + 1); double StartX = tolua_tonumber(L, idx + 2, 0); double StartY = tolua_tonumber(L, idx + 3, 0); @@ -2179,22 +2179,22 @@ static int tolua_cHopperEntity_GetOutputBlockPos(lua_State * tolua_S) { return 0; } - cHopperEntity * self = (cHopperEntity *)tolua_tousertype(tolua_S, 1, nullptr); + cHopperEntity * self = reinterpret_cast<cHopperEntity *>(tolua_tousertype(tolua_S, 1, nullptr)); if (self == nullptr) { tolua_error(tolua_S, "invalid 'self' in function 'cHopperEntity::GetOutputBlockPos()'", nullptr); return 0; } - NIBBLETYPE a_BlockMeta = ((NIBBLETYPE)tolua_tonumber(tolua_S, 2, 0)); + NIBBLETYPE a_BlockMeta = static_cast<NIBBLETYPE>(tolua_tonumber(tolua_S, 2, 0)); int a_OutputX, a_OutputY, a_OutputZ; bool res = self->GetOutputBlockPos(a_BlockMeta, a_OutputX, a_OutputY, a_OutputZ); tolua_pushboolean(tolua_S, res); if (res) { - tolua_pushnumber(tolua_S, (lua_Number)a_OutputX); - tolua_pushnumber(tolua_S, (lua_Number)a_OutputY); - tolua_pushnumber(tolua_S, (lua_Number)a_OutputZ); + tolua_pushnumber(tolua_S, static_cast<lua_Number>(a_OutputX)); + tolua_pushnumber(tolua_S, static_cast<lua_Number>(a_OutputY)); + tolua_pushnumber(tolua_S, static_cast<lua_Number>(a_OutputZ)); return 4; } return 1; @@ -2219,15 +2219,15 @@ static int tolua_cBlockArea_GetBlockTypeMeta(lua_State * tolua_S) return 0; } - cBlockArea * self = (cBlockArea *)tolua_tousertype(tolua_S, 1, nullptr); + cBlockArea * self = reinterpret_cast<cBlockArea *>(tolua_tousertype(tolua_S, 1, nullptr)); if (self == nullptr) { tolua_error(tolua_S, "invalid 'self' in function 'cBlockArea:GetRelBlockTypeMeta'", nullptr); return 0; } - int BlockX = (int)tolua_tonumber(tolua_S, 2, 0); - int BlockY = (int)tolua_tonumber(tolua_S, 3, 0); - int BlockZ = (int)tolua_tonumber(tolua_S, 4, 0); + int BlockX = static_cast<int>(tolua_tonumber(tolua_S, 2, 0)); + int BlockY = static_cast<int>(tolua_tonumber(tolua_S, 3, 0)); + int BlockZ = static_cast<int>(tolua_tonumber(tolua_S, 4, 0)); BLOCKTYPE BlockType; NIBBLETYPE BlockMeta; self->GetBlockTypeMeta(BlockX, BlockY, BlockZ, BlockType, BlockMeta); @@ -2253,7 +2253,7 @@ static int tolua_cBlockArea_GetOrigin(lua_State * tolua_S) return 0; } - cBlockArea * self = (cBlockArea *)tolua_tousertype(tolua_S, 1, nullptr); + cBlockArea * self = reinterpret_cast<cBlockArea *>(tolua_tousertype(tolua_S, 1, nullptr)); if (self == nullptr) { tolua_error(tolua_S, "invalid 'self' in function 'cBlockArea:GetOrigin'", nullptr); @@ -2323,15 +2323,15 @@ static int tolua_cBlockArea_GetRelBlockTypeMeta(lua_State * tolua_S) return 0; } - cBlockArea * self = (cBlockArea *)tolua_tousertype(tolua_S, 1, nullptr); + cBlockArea * self = reinterpret_cast<cBlockArea *>(tolua_tousertype(tolua_S, 1, nullptr)); if (self == nullptr) { tolua_error(tolua_S, "invalid 'self' in function 'cBlockArea:GetRelBlockTypeMeta'", nullptr); return 0; } - int BlockX = (int)tolua_tonumber(tolua_S, 2, 0); - int BlockY = (int)tolua_tonumber(tolua_S, 3, 0); - int BlockZ = (int)tolua_tonumber(tolua_S, 4, 0); + int BlockX = static_cast<int>(tolua_tonumber(tolua_S, 2, 0)); + int BlockY = static_cast<int>(tolua_tonumber(tolua_S, 3, 0)); + int BlockZ = static_cast<int>(tolua_tonumber(tolua_S, 4, 0)); BLOCKTYPE BlockType; NIBBLETYPE BlockMeta; self->GetRelBlockTypeMeta(BlockX, BlockY, BlockZ, BlockType, BlockMeta); @@ -2357,7 +2357,7 @@ static int tolua_cBlockArea_GetSize(lua_State * tolua_S) return 0; } - cBlockArea * self = (cBlockArea *)tolua_tousertype(tolua_S, 1, nullptr); + cBlockArea * self = reinterpret_cast<cBlockArea *>(tolua_tousertype(tolua_S, 1, nullptr)); if (self == nullptr) { tolua_error(tolua_S, "invalid 'self' in function 'cBlockArea:GetSize'", nullptr); @@ -2388,7 +2388,7 @@ static int tolua_cBlockArea_GetCoordRange(lua_State * tolua_S) return 0; } - cBlockArea * self = (cBlockArea *)tolua_tousertype(tolua_S, 1, nullptr); + cBlockArea * self = reinterpret_cast<cBlockArea *>(tolua_tousertype(tolua_S, 1, nullptr)); if (self == nullptr) { tolua_error(tolua_S, "invalid 'self' in function 'cBlockArea:GetSize'", nullptr); @@ -2419,7 +2419,7 @@ static int tolua_cBlockArea_LoadFromSchematicFile(lua_State * tolua_S) { return 0; } - cBlockArea * self = (cBlockArea *)tolua_tousertype(tolua_S, 1, nullptr); + cBlockArea * self = reinterpret_cast<cBlockArea *>(tolua_tousertype(tolua_S, 1, nullptr)); if (self == nullptr) { tolua_error(tolua_S, "invalid 'self' in function 'cBlockArea::LoadFromSchematicFile'", nullptr); @@ -2449,7 +2449,7 @@ static int tolua_cBlockArea_LoadFromSchematicString(lua_State * tolua_S) { return 0; } - cBlockArea * self = (cBlockArea *)tolua_tousertype(tolua_S, 1, nullptr); + cBlockArea * self = reinterpret_cast<cBlockArea *>(tolua_tousertype(tolua_S, 1, nullptr)); if (self == nullptr) { tolua_error(tolua_S, "invalid 'self' in function 'cBlockArea::LoadFromSchematicFile'", nullptr); @@ -2480,7 +2480,7 @@ static int tolua_cBlockArea_SaveToSchematicFile(lua_State * tolua_S) { return 0; } - cBlockArea * self = (cBlockArea *)tolua_tousertype(tolua_S, 1, nullptr); + cBlockArea * self = reinterpret_cast<cBlockArea *>(tolua_tousertype(tolua_S, 1, nullptr)); if (self == nullptr) { tolua_error(tolua_S, "invalid 'self' in function 'cBlockArea::SaveToSchematicFile'", nullptr); @@ -2508,7 +2508,7 @@ static int tolua_cBlockArea_SaveToSchematicString(lua_State * tolua_S) { return 0; } - cBlockArea * self = (cBlockArea *)tolua_tousertype(tolua_S, 1, nullptr); + cBlockArea * self = reinterpret_cast<cBlockArea *>(tolua_tousertype(tolua_S, 1, nullptr)); if (self == nullptr) { tolua_error(tolua_S, "invalid 'self' in function 'cBlockArea::SaveToSchematicFile'", nullptr); @@ -2542,7 +2542,7 @@ static int tolua_cCompositeChat_AddRunCommandPart(lua_State * tolua_S) { return 0; } - cCompositeChat * self = (cCompositeChat *)tolua_tousertype(tolua_S, 1, nullptr); + cCompositeChat * self = reinterpret_cast<cCompositeChat *>(tolua_tousertype(tolua_S, 1, nullptr)); if (self == nullptr) { tolua_error(tolua_S, "invalid 'self' in function 'cCompositeChat:AddRunCommandPart'", nullptr); @@ -2579,7 +2579,7 @@ static int tolua_cCompositeChat_AddSuggestCommandPart(lua_State * tolua_S) { return 0; } - cCompositeChat * self = (cCompositeChat *)tolua_tousertype(tolua_S, 1, nullptr); + cCompositeChat * self = reinterpret_cast<cCompositeChat *>(tolua_tousertype(tolua_S, 1, nullptr)); if (self == nullptr) { tolua_error(tolua_S, "invalid 'self' in function 'cCompositeChat:AddSuggestCommandPart'", nullptr); @@ -2616,7 +2616,7 @@ static int tolua_cCompositeChat_AddTextPart(lua_State * tolua_S) { return 0; } - cCompositeChat * self = (cCompositeChat *)tolua_tousertype(tolua_S, 1, nullptr); + cCompositeChat * self = reinterpret_cast<cCompositeChat *>(tolua_tousertype(tolua_S, 1, nullptr)); if (self == nullptr) { tolua_error(tolua_S, "invalid 'self' in function 'cCompositeChat:AddTextPart'", nullptr); @@ -2652,7 +2652,7 @@ static int tolua_cCompositeChat_AddUrlPart(lua_State * tolua_S) { return 0; } - cCompositeChat * self = (cCompositeChat *)tolua_tousertype(tolua_S, 1, nullptr); + cCompositeChat * self = reinterpret_cast<cCompositeChat *>(tolua_tousertype(tolua_S, 1, nullptr)); if (self == nullptr) { tolua_error(tolua_S, "invalid 'self' in function 'cCompositeChat:AddUrlPart'", nullptr); @@ -2689,7 +2689,7 @@ static int tolua_cCompositeChat_ParseText(lua_State * tolua_S) { return 0; } - cCompositeChat * self = (cCompositeChat *)tolua_tousertype(tolua_S, 1, nullptr); + cCompositeChat * self = reinterpret_cast<cCompositeChat *>(tolua_tousertype(tolua_S, 1, nullptr)); if (self == nullptr) { tolua_error(tolua_S, "invalid 'self' in function 'cCompositeChat:ParseText'", nullptr); @@ -2724,7 +2724,7 @@ static int tolua_cCompositeChat_SetMessageType(lua_State * tolua_S) { return 0; } - cCompositeChat * self = (cCompositeChat *)tolua_tousertype(tolua_S, 1, nullptr); + cCompositeChat * self = reinterpret_cast<cCompositeChat *>(tolua_tousertype(tolua_S, 1, nullptr)); if (self == nullptr) { tolua_error(tolua_S, "invalid 'self' in function 'cCompositeChat:SetMessageType'", nullptr); @@ -2734,7 +2734,7 @@ static int tolua_cCompositeChat_SetMessageType(lua_State * tolua_S) // Set the type: int MessageType = mtCustom; L.GetStackValue(2, MessageType); - self->SetMessageType((eMessageType)MessageType); + self->SetMessageType(static_cast<eMessageType>(MessageType)); // Cut away everything from the stack except for the cCompositeChat instance; return that: lua_settop(L, 1); @@ -2756,7 +2756,7 @@ static int tolua_cCompositeChat_UnderlineUrls(lua_State * tolua_S) { return 0; } - cCompositeChat * self = (cCompositeChat *)tolua_tousertype(tolua_S, 1, nullptr); + cCompositeChat * self = reinterpret_cast<cCompositeChat *>(tolua_tousertype(tolua_S, 1, nullptr)); if (self == nullptr) { tolua_error(tolua_S, "invalid 'self' in function 'cCompositeChat:UnderlineUrls'", nullptr); diff --git a/src/Bindings/ManualBindings_World.cpp b/src/Bindings/ManualBindings_World.cpp index d9590de33..59dde9a93 100644 --- a/src/Bindings/ManualBindings_World.cpp +++ b/src/Bindings/ManualBindings_World.cpp @@ -86,7 +86,7 @@ static int tolua_cWorld_ChunkStay(lua_State * tolua_S) } // Read the params: - cWorld * World = (cWorld *)tolua_tousertype(tolua_S, 1, nullptr); + cWorld * World = reinterpret_cast<cWorld *>(tolua_tousertype(tolua_S, 1, nullptr)); if (World == nullptr) { LOGWARNING("World:ChunkStay(): invalid world parameter"); @@ -356,7 +356,7 @@ static int tolua_cWorld_QueueTask(lua_State * tolua_S) } // Retrieve the args: - cWorld * self = (cWorld *)tolua_tousertype(tolua_S, 1, nullptr); + cWorld * self = reinterpret_cast<cWorld *>(tolua_tousertype(tolua_S, 1, nullptr)); if (self == nullptr) { return cManualBindings::lua_do_error(tolua_S, "Error in function call '#funcname#': Not called on an object instance"); @@ -473,7 +473,7 @@ static int tolua_cWorld_ScheduleTask(lua_State * tolua_S) { return 0; } - cWorld * World = (cWorld *)tolua_tousertype(tolua_S, 1, nullptr); + cWorld * World = reinterpret_cast<cWorld *>(tolua_tousertype(tolua_S, 1, nullptr)); if (World == nullptr) { return cManualBindings::lua_do_error(tolua_S, "Error in function call '#funcname#': Not called on an object instance"); @@ -486,7 +486,7 @@ static int tolua_cWorld_ScheduleTask(lua_State * tolua_S) return cManualBindings::lua_do_error(tolua_S, "Error in function call '#funcname#': Could not get function reference of parameter #1"); } - int DelayTicks = (int)tolua_tonumber(tolua_S, 2, 0); + int DelayTicks = static_cast<int>(tolua_tonumber(tolua_S, 2, 0)); auto task = std::make_shared<cLuaScheduledWorldTask>(*Plugin, FnRef); Plugin->AddResettable(task); diff --git a/src/Bindings/Plugin.h b/src/Bindings/Plugin.h index 2fdf73a65..48ba6a77c 100644 --- a/src/Bindings/Plugin.h +++ b/src/Bindings/Plugin.h @@ -66,7 +66,7 @@ public: virtual bool OnHopperPushingItem (cWorld & a_World, cHopperEntity & a_Hopper, int a_SrcSlotNum, cBlockEntityWithItems & a_DstEntity, int a_DstSlotNum) = 0; virtual bool OnKilled (cEntity & a_Victim, TakeDamageInfo & a_TDI, AString & a_DeathMessage) = 0; virtual bool OnKilling (cEntity & a_Victim, cEntity * a_Killer, TakeDamageInfo & a_TDI) = 0; - virtual bool OnLogin (cClientHandle & a_Client, int a_ProtocolVersion, const AString & a_Username) = 0; + virtual bool OnLogin (cClientHandle & a_Client, UInt32 a_ProtocolVersion, const AString & a_Username) = 0; virtual bool OnPlayerAnimation (cPlayer & a_Player, int a_Animation) = 0; virtual bool OnPlayerBreakingBlock (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) = 0; virtual bool OnPlayerBrokenBlock (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) = 0; diff --git a/src/Bindings/PluginLua.cpp b/src/Bindings/PluginLua.cpp index 9be4e0eb4..50a0a387b 100644 --- a/src/Bindings/PluginLua.cpp +++ b/src/Bindings/PluginLua.cpp @@ -238,7 +238,7 @@ void cPluginLua::Tick(float a_Dt) cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_TICK]; for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr) { - m_LuaState.Call((int)(**itr), a_Dt); + m_LuaState.Call(static_cast<int>(**itr), a_Dt); } } @@ -257,7 +257,7 @@ bool cPluginLua::OnBlockSpread(cWorld & a_World, int a_BlockX, int a_BlockY, int cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_BLOCK_SPREAD]; for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr) { - m_LuaState.Call((int)(**itr), &a_World, a_BlockX, a_BlockY, a_BlockZ, a_Source, cLuaState::Return, res); + m_LuaState.Call(static_cast<int>(**itr), &a_World, a_BlockX, a_BlockY, a_BlockZ, a_Source, cLuaState::Return, res); if (res) { return true; @@ -281,7 +281,7 @@ bool cPluginLua::OnBlockToPickups(cWorld & a_World, cEntity * a_Digger, int a_Bl cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_BLOCK_TO_PICKUPS]; for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr) { - m_LuaState.Call((int)(**itr), &a_World, a_Digger, a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta, &a_Pickups, cLuaState::Return, res); + m_LuaState.Call(static_cast<int>(**itr), &a_World, a_Digger, a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta, &a_Pickups, cLuaState::Return, res); if (res) { return true; @@ -305,7 +305,7 @@ bool cPluginLua::OnChat(cPlayer & a_Player, AString & a_Message) cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_CHAT]; for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr) { - m_LuaState.Call((int)(**itr), &a_Player, a_Message, cLuaState::Return, res, a_Message); + m_LuaState.Call(static_cast<int>(**itr), &a_Player, a_Message, cLuaState::Return, res, a_Message); if (res) { return true; @@ -329,7 +329,7 @@ bool cPluginLua::OnChunkAvailable(cWorld & a_World, int a_ChunkX, int a_ChunkZ) cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_CHUNK_AVAILABLE]; for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr) { - m_LuaState.Call((int)(**itr), &a_World, a_ChunkX, a_ChunkZ, cLuaState::Return, res); + m_LuaState.Call(static_cast<int>(**itr), &a_World, a_ChunkX, a_ChunkZ, cLuaState::Return, res); if (res) { return true; @@ -353,7 +353,7 @@ bool cPluginLua::OnChunkGenerated(cWorld & a_World, int a_ChunkX, int a_ChunkZ, cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_CHUNK_GENERATED]; for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr) { - m_LuaState.Call((int)(**itr), &a_World, a_ChunkX, a_ChunkZ, a_ChunkDesc, cLuaState::Return, res); + m_LuaState.Call(static_cast<int>(**itr), &a_World, a_ChunkX, a_ChunkZ, a_ChunkDesc, cLuaState::Return, res); if (res) { return true; @@ -377,7 +377,7 @@ bool cPluginLua::OnChunkGenerating(cWorld & a_World, int a_ChunkX, int a_ChunkZ, cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_CHUNK_GENERATING]; for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr) { - m_LuaState.Call((int)(**itr), &a_World, a_ChunkX, a_ChunkZ, a_ChunkDesc, cLuaState::Return, res); + m_LuaState.Call(static_cast<int>(**itr), &a_World, a_ChunkX, a_ChunkZ, a_ChunkDesc, cLuaState::Return, res); if (res) { return true; @@ -401,7 +401,7 @@ bool cPluginLua::OnChunkUnloaded(cWorld & a_World, int a_ChunkX, int a_ChunkZ) cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_CHUNK_UNLOADED]; for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr) { - m_LuaState.Call((int)(**itr), &a_World, a_ChunkX, a_ChunkZ, cLuaState::Return, res); + m_LuaState.Call(static_cast<int>(**itr), &a_World, a_ChunkX, a_ChunkZ, cLuaState::Return, res); if (res) { return true; @@ -425,7 +425,7 @@ bool cPluginLua::OnChunkUnloading(cWorld & a_World, int a_ChunkX, int a_ChunkZ) cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_CHUNK_UNLOADING]; for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr) { - m_LuaState.Call((int)(**itr), &a_World, a_ChunkX, a_ChunkZ, cLuaState::Return, res); + m_LuaState.Call(static_cast<int>(**itr), &a_World, a_ChunkX, a_ChunkZ, cLuaState::Return, res); if (res) { return true; @@ -449,7 +449,7 @@ bool cPluginLua::OnCollectingPickup(cPlayer & a_Player, cPickup & a_Pickup) cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_COLLECTING_PICKUP]; for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr) { - m_LuaState.Call((int)(**itr), &a_Player, &a_Pickup, cLuaState::Return, res); + m_LuaState.Call(static_cast<int>(**itr), &a_Player, &a_Pickup, cLuaState::Return, res); if (res) { return true; @@ -473,7 +473,7 @@ bool cPluginLua::OnCraftingNoRecipe(cPlayer & a_Player, cCraftingGrid & a_Grid, cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_CRAFTING_NO_RECIPE]; for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr) { - m_LuaState.Call((int)(**itr), &a_Player, &a_Grid, &a_Recipe, cLuaState::Return, res); + m_LuaState.Call(static_cast<int>(**itr), &a_Player, &a_Grid, &a_Recipe, cLuaState::Return, res); if (res) { return true; @@ -497,7 +497,7 @@ bool cPluginLua::OnDisconnect(cClientHandle & a_Client, const AString & a_Reason cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_DISCONNECT]; for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr) { - m_LuaState.Call((int)(**itr), &a_Client, a_Reason, cLuaState::Return, res); + m_LuaState.Call(static_cast<int>(**itr), &a_Client, a_Reason, cLuaState::Return, res); if (res) { return true; @@ -521,7 +521,7 @@ bool cPluginLua::OnEntityAddEffect(cEntity & a_Entity, int a_EffectType, int a_E cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_ENTITY_ADD_EFFECT]; for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr) { - m_LuaState.Call((int)(**itr), &a_Entity, a_EffectType, a_EffectDurationTicks, a_EffectIntensity, a_DistanceModifier, cLuaState::Return, res); + m_LuaState.Call(static_cast<int>(**itr), &a_Entity, a_EffectType, a_EffectDurationTicks, a_EffectIntensity, a_DistanceModifier, cLuaState::Return, res); if (res) { return true; @@ -545,7 +545,7 @@ bool cPluginLua::OnEntityChangingWorld(cEntity & a_Entity, cWorld & a_World) cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_ENTITY_CHANGING_WORLD]; for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr) { - m_LuaState.Call((int)(**itr), &a_Entity, &a_World, cLuaState::Return, res); + m_LuaState.Call(static_cast<int>(**itr), &a_Entity, &a_World, cLuaState::Return, res); if (res) { return true; @@ -569,7 +569,7 @@ bool cPluginLua::OnEntityChangedWorld(cEntity & a_Entity, cWorld & a_World) cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_ENTITY_CHANGED_WORLD]; for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr) { - m_LuaState.Call((int)(**itr), &a_Entity, &a_World, res); + m_LuaState.Call(static_cast<int>(**itr), &a_Entity, &a_World, res); if (res) { return true; @@ -593,7 +593,7 @@ bool cPluginLua::OnExecuteCommand(cPlayer * a_Player, const AStringVector & a_Sp cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_EXECUTE_COMMAND]; for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr) { - m_LuaState.Call((int)(**itr), a_Player, a_Split, a_EntireCommand, cLuaState::Return, res, a_Result); + m_LuaState.Call(static_cast<int>(**itr), a_Player, a_Split, a_EntireCommand, cLuaState::Return, res, a_Result); if (res) { return true; @@ -619,16 +619,16 @@ bool cPluginLua::OnExploded(cWorld & a_World, double a_ExplosionSize, bool a_Can { switch (a_Source) { - case esOther: m_LuaState.Call((int)(**itr), &a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, a_SourceData, cLuaState::Return, res); break; - case esPrimedTNT: m_LuaState.Call((int)(**itr), &a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, (cTNTEntity *)a_SourceData, cLuaState::Return, res); break; - case esMonster: m_LuaState.Call((int)(**itr), &a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, (cMonster *)a_SourceData, cLuaState::Return, res); break; - case esBed: m_LuaState.Call((int)(**itr), &a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, (Vector3i *)a_SourceData, cLuaState::Return, res); break; - case esEnderCrystal: m_LuaState.Call((int)(**itr), &a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, (Vector3i *)a_SourceData, cLuaState::Return, res); break; - case esGhastFireball: m_LuaState.Call((int)(**itr), &a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, a_SourceData, cLuaState::Return, res); break; + case esOther: m_LuaState.Call(static_cast<int>(**itr), &a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, a_SourceData, cLuaState::Return, res); break; + case esPrimedTNT: m_LuaState.Call(static_cast<int>(**itr), &a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, reinterpret_cast<cTNTEntity *>(a_SourceData), cLuaState::Return, res); break; + case esMonster: m_LuaState.Call(static_cast<int>(**itr), &a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, reinterpret_cast<cMonster *>(a_SourceData), cLuaState::Return, res); break; + case esBed: m_LuaState.Call(static_cast<int>(**itr), &a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, reinterpret_cast<Vector3i *>(a_SourceData), cLuaState::Return, res); break; + case esEnderCrystal: m_LuaState.Call(static_cast<int>(**itr), &a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, reinterpret_cast<Vector3i *>(a_SourceData), cLuaState::Return, res); break; + case esGhastFireball: m_LuaState.Call(static_cast<int>(**itr), &a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, a_SourceData, cLuaState::Return, res); break; case esWitherSkullBlack: - case esWitherSkullBlue: m_LuaState.Call((int)(**itr), &a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, a_SourceData, cLuaState::Return, res); break; - case esWitherBirth: m_LuaState.Call((int)(**itr), &a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, a_SourceData, cLuaState::Return, res); break; - case esPlugin: m_LuaState.Call((int)(**itr), &a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, a_SourceData, cLuaState::Return, res); break; + case esWitherSkullBlue: m_LuaState.Call(static_cast<int>(**itr), &a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, a_SourceData, cLuaState::Return, res); break; + case esWitherBirth: m_LuaState.Call(static_cast<int>(**itr), &a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, a_SourceData, cLuaState::Return, res); break; + case esPlugin: m_LuaState.Call(static_cast<int>(**itr), &a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, a_SourceData, cLuaState::Return, res); break; } if (res) { @@ -655,16 +655,16 @@ bool cPluginLua::OnExploding(cWorld & a_World, double & a_ExplosionSize, bool & { switch (a_Source) { - case esOther: m_LuaState.Call((int)(**itr), &a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, a_SourceData, cLuaState::Return, res, a_CanCauseFire, a_ExplosionSize); break; - case esPrimedTNT: m_LuaState.Call((int)(**itr), &a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, (cTNTEntity *)a_SourceData, cLuaState::Return, res, a_CanCauseFire, a_ExplosionSize); break; - case esMonster: m_LuaState.Call((int)(**itr), &a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, (cMonster *)a_SourceData, cLuaState::Return, res, a_CanCauseFire, a_ExplosionSize); break; - case esBed: m_LuaState.Call((int)(**itr), &a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, (Vector3i *)a_SourceData, cLuaState::Return, res, a_CanCauseFire, a_ExplosionSize); break; - case esEnderCrystal: m_LuaState.Call((int)(**itr), &a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, (Vector3i *)a_SourceData, cLuaState::Return, res, a_CanCauseFire, a_ExplosionSize); break; - case esGhastFireball: m_LuaState.Call((int)(**itr), &a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, a_SourceData, cLuaState::Return, res, a_CanCauseFire, a_ExplosionSize); break; + case esOther: m_LuaState.Call(static_cast<int>(**itr), &a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, a_SourceData, cLuaState::Return, res, a_CanCauseFire, a_ExplosionSize); break; + case esPrimedTNT: m_LuaState.Call(static_cast<int>(**itr), &a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, reinterpret_cast<cTNTEntity *>(a_SourceData), cLuaState::Return, res, a_CanCauseFire, a_ExplosionSize); break; + case esMonster: m_LuaState.Call(static_cast<int>(**itr), &a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, reinterpret_cast<cMonster *>(a_SourceData), cLuaState::Return, res, a_CanCauseFire, a_ExplosionSize); break; + case esBed: m_LuaState.Call(static_cast<int>(**itr), &a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, reinterpret_cast<Vector3i *>(a_SourceData), cLuaState::Return, res, a_CanCauseFire, a_ExplosionSize); break; + case esEnderCrystal: m_LuaState.Call(static_cast<int>(**itr), &a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, reinterpret_cast<Vector3i *>(a_SourceData), cLuaState::Return, res, a_CanCauseFire, a_ExplosionSize); break; + case esGhastFireball: m_LuaState.Call(static_cast<int>(**itr), &a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, a_SourceData, cLuaState::Return, res, a_CanCauseFire, a_ExplosionSize); break; case esWitherSkullBlack: - case esWitherSkullBlue: m_LuaState.Call((int)(**itr), &a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, a_SourceData, cLuaState::Return, res, a_CanCauseFire, a_ExplosionSize); break; - case esWitherBirth: m_LuaState.Call((int)(**itr), &a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, a_SourceData, cLuaState::Return, res, a_CanCauseFire, a_ExplosionSize); break; - case esPlugin: m_LuaState.Call((int)(**itr), &a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, a_SourceData, cLuaState::Return, res, a_CanCauseFire, a_ExplosionSize); break; + case esWitherSkullBlue: m_LuaState.Call(static_cast<int>(**itr), &a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, a_SourceData, cLuaState::Return, res, a_CanCauseFire, a_ExplosionSize); break; + case esWitherBirth: m_LuaState.Call(static_cast<int>(**itr), &a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, a_SourceData, cLuaState::Return, res, a_CanCauseFire, a_ExplosionSize); break; + case esPlugin: m_LuaState.Call(static_cast<int>(**itr), &a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, a_SourceData, cLuaState::Return, res, a_CanCauseFire, a_ExplosionSize); break; } if (res) { @@ -689,7 +689,7 @@ bool cPluginLua::OnHandshake(cClientHandle & a_Client, const AString & a_Usernam cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_HANDSHAKE]; for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr) { - m_LuaState.Call((int)(**itr), &a_Client, a_Username, cLuaState::Return, res); + m_LuaState.Call(static_cast<int>(**itr), &a_Client, a_Username, cLuaState::Return, res); if (res) { return true; @@ -713,7 +713,7 @@ bool cPluginLua::OnHopperPullingItem(cWorld & a_World, cHopperEntity & a_Hopper, cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_HOPPER_PULLING_ITEM]; for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr) { - m_LuaState.Call((int)(**itr), &a_World, &a_Hopper, a_DstSlotNum, &a_SrcEntity, a_SrcSlotNum, cLuaState::Return, res); + m_LuaState.Call(static_cast<int>(**itr), &a_World, &a_Hopper, a_DstSlotNum, &a_SrcEntity, a_SrcSlotNum, cLuaState::Return, res); if (res) { return true; @@ -737,7 +737,7 @@ bool cPluginLua::OnHopperPushingItem(cWorld & a_World, cHopperEntity & a_Hopper, cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_HOPPER_PUSHING_ITEM]; for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr) { - m_LuaState.Call((int)(**itr), &a_World, &a_Hopper, a_SrcSlotNum, &a_DstEntity, a_DstSlotNum, cLuaState::Return, res); + m_LuaState.Call(static_cast<int>(**itr), &a_World, &a_Hopper, a_SrcSlotNum, &a_DstEntity, a_DstSlotNum, cLuaState::Return, res); if (res) { return true; @@ -761,7 +761,7 @@ bool cPluginLua::OnKilled(cEntity & a_Victim, TakeDamageInfo & a_TDI, AString & cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_KILLED]; for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr) { - m_LuaState.Call((int)(**itr), &a_Victim, &a_TDI, a_DeathMessage, cLuaState::Return, res, a_DeathMessage); + m_LuaState.Call(static_cast<int>(**itr), &a_Victim, &a_TDI, a_DeathMessage, cLuaState::Return, res, a_DeathMessage); if (res) { return true; @@ -785,7 +785,7 @@ bool cPluginLua::OnKilling(cEntity & a_Victim, cEntity * a_Killer, TakeDamageInf cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_KILLING]; for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr) { - m_LuaState.Call((int)(**itr), &a_Victim, a_Killer, &a_TDI, cLuaState::Return, res); + m_LuaState.Call(static_cast<int>(**itr), &a_Victim, a_Killer, &a_TDI, cLuaState::Return, res); if (res) { return true; @@ -798,7 +798,7 @@ bool cPluginLua::OnKilling(cEntity & a_Victim, cEntity * a_Killer, TakeDamageInf -bool cPluginLua::OnLogin(cClientHandle & a_Client, int a_ProtocolVersion, const AString & a_Username) +bool cPluginLua::OnLogin(cClientHandle & a_Client, UInt32 a_ProtocolVersion, const AString & a_Username) { cCSLock Lock(m_CriticalSection); if (!m_LuaState.IsValid()) @@ -809,7 +809,7 @@ bool cPluginLua::OnLogin(cClientHandle & a_Client, int a_ProtocolVersion, const cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_LOGIN]; for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr) { - m_LuaState.Call((int)(**itr), &a_Client, a_ProtocolVersion, a_Username, cLuaState::Return, res); + m_LuaState.Call(static_cast<int>(**itr), &a_Client, a_ProtocolVersion, a_Username, cLuaState::Return, res); if (res) { return true; @@ -833,7 +833,7 @@ bool cPluginLua::OnPlayerAnimation(cPlayer & a_Player, int a_Animation) cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_PLAYER_ANIMATION]; for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr) { - m_LuaState.Call((int)(**itr), &a_Player, a_Animation, cLuaState::Return, res); + m_LuaState.Call(static_cast<int>(**itr), &a_Player, a_Animation, cLuaState::Return, res); if (res) { return true; @@ -857,7 +857,7 @@ bool cPluginLua::OnPlayerBreakingBlock(cPlayer & a_Player, int a_BlockX, int a_B cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_PLAYER_BREAKING_BLOCK]; for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr) { - m_LuaState.Call((int)(**itr), &a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_BlockType, a_BlockMeta, cLuaState::Return, res); + m_LuaState.Call(static_cast<int>(**itr), &a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_BlockType, a_BlockMeta, cLuaState::Return, res); if (res) { return true; @@ -881,7 +881,7 @@ bool cPluginLua::OnPlayerBrokenBlock(cPlayer & a_Player, int a_BlockX, int a_Blo cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_PLAYER_BROKEN_BLOCK]; for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr) { - m_LuaState.Call((int)(**itr), &a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_BlockType, a_BlockMeta, cLuaState::Return, res); + m_LuaState.Call(static_cast<int>(**itr), &a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_BlockType, a_BlockMeta, cLuaState::Return, res); if (res) { return true; @@ -905,7 +905,7 @@ bool cPluginLua::OnPlayerDestroyed(cPlayer & a_Player) cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_PLAYER_DESTROYED]; for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr) { - m_LuaState.Call((int)(**itr), &a_Player, cLuaState::Return, res); + m_LuaState.Call(static_cast<int>(**itr), &a_Player, cLuaState::Return, res); if (res) { return true; @@ -929,7 +929,7 @@ bool cPluginLua::OnPlayerEating(cPlayer & a_Player) cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_PLAYER_EATING]; for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr) { - m_LuaState.Call((int)(**itr), &a_Player, cLuaState::Return, res); + m_LuaState.Call(static_cast<int>(**itr), &a_Player, cLuaState::Return, res); if (res) { return true; @@ -953,7 +953,7 @@ bool cPluginLua::OnPlayerFoodLevelChange(cPlayer & a_Player, int a_NewFoodLevel) cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_PLAYER_FOOD_LEVEL_CHANGE]; for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr) { - m_LuaState.Call((int)(**itr), &a_Player, a_NewFoodLevel, cLuaState::Return, res); + m_LuaState.Call(static_cast<int>(**itr), &a_Player, a_NewFoodLevel, cLuaState::Return, res); if (res) { return true; @@ -977,7 +977,7 @@ bool cPluginLua::OnPlayerFished(cPlayer & a_Player, const cItems & a_Reward) cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_PLAYER_FISHED]; for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr) { - m_LuaState.Call((int)(**itr), &a_Player, a_Reward, cLuaState::Return, res); + m_LuaState.Call(static_cast<int>(**itr), &a_Player, a_Reward, cLuaState::Return, res); if (res) { return true; @@ -1001,7 +1001,7 @@ bool cPluginLua::OnPlayerFishing(cPlayer & a_Player, cItems & a_Reward) cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_PLAYER_FISHING]; for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr) { - m_LuaState.Call((int)(**itr), &a_Player, &a_Reward, cLuaState::Return, res); + m_LuaState.Call(static_cast<int>(**itr), &a_Player, &a_Reward, cLuaState::Return, res); if (res) { return true; @@ -1025,7 +1025,7 @@ bool cPluginLua::OnPlayerJoined(cPlayer & a_Player) cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_PLAYER_JOINED]; for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr) { - m_LuaState.Call((int)(**itr), &a_Player, cLuaState::Return, res); + m_LuaState.Call(static_cast<int>(**itr), &a_Player, cLuaState::Return, res); if (res) { return true; @@ -1049,7 +1049,7 @@ bool cPluginLua::OnPlayerLeftClick(cPlayer & a_Player, int a_BlockX, int a_Block cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_PLAYER_LEFT_CLICK]; for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr) { - m_LuaState.Call((int)(**itr), &a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_Status, cLuaState::Return, res); + m_LuaState.Call(static_cast<int>(**itr), &a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_Status, cLuaState::Return, res); if (res) { return true; @@ -1073,7 +1073,7 @@ bool cPluginLua::OnPlayerMoving(cPlayer & a_Player, const Vector3d & a_OldPositi cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_PLAYER_MOVING]; for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr) { - m_LuaState.Call((int)(**itr), &a_Player, a_OldPosition, a_NewPosition, cLuaState::Return, res); + m_LuaState.Call(static_cast<int>(**itr), &a_Player, a_OldPosition, a_NewPosition, cLuaState::Return, res); if (res) { return true; @@ -1097,7 +1097,7 @@ bool cPluginLua::OnEntityTeleport(cEntity & a_Entity, const Vector3d & a_OldPosi cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_ENTITY_TELEPORT]; for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr) { - m_LuaState.Call((int)(**itr), &a_Entity, a_OldPosition, a_NewPosition, cLuaState::Return, res); + m_LuaState.Call(static_cast<int>(**itr), &a_Entity, a_OldPosition, a_NewPosition, cLuaState::Return, res); if (res) { return true; @@ -1121,7 +1121,7 @@ bool cPluginLua::OnPlayerPlacedBlock(cPlayer & a_Player, const sSetBlock & a_Blo cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_PLAYER_PLACED_BLOCK]; for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr) { - m_LuaState.Call((int)(**itr), &a_Player, + m_LuaState.Call(static_cast<int>(**itr), &a_Player, a_BlockChange.GetX(), a_BlockChange.GetY(), a_BlockChange.GetZ(), a_BlockChange.m_BlockType, a_BlockChange.m_BlockMeta, cLuaState::Return, @@ -1150,7 +1150,7 @@ bool cPluginLua::OnPlayerPlacingBlock(cPlayer & a_Player, const sSetBlock & a_Bl cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_PLAYER_PLACING_BLOCK]; for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr) { - m_LuaState.Call((int)(**itr), &a_Player, + m_LuaState.Call(static_cast<int>(**itr), &a_Player, a_BlockChange.GetX(), a_BlockChange.GetY(), a_BlockChange.GetZ(), a_BlockChange.m_BlockType, a_BlockChange.m_BlockMeta, cLuaState::Return, @@ -1179,7 +1179,7 @@ bool cPluginLua::OnPlayerRightClick(cPlayer & a_Player, int a_BlockX, int a_Bloc cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_PLAYER_RIGHT_CLICK]; for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr) { - m_LuaState.Call((int)(**itr), &a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, cLuaState::Return, res); + m_LuaState.Call(static_cast<int>(**itr), &a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, cLuaState::Return, res); if (res) { return true; @@ -1203,7 +1203,7 @@ bool cPluginLua::OnPlayerRightClickingEntity(cPlayer & a_Player, cEntity & a_Ent cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_PLAYER_RIGHT_CLICKING_ENTITY]; for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr) { - m_LuaState.Call((int)(**itr), &a_Player, &a_Entity, cLuaState::Return, res); + m_LuaState.Call(static_cast<int>(**itr), &a_Player, &a_Entity, cLuaState::Return, res); if (res) { return true; @@ -1227,7 +1227,7 @@ bool cPluginLua::OnPlayerShooting(cPlayer & a_Player) cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_PLAYER_SHOOTING]; for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr) { - m_LuaState.Call((int)(**itr), &a_Player, cLuaState::Return, res); + m_LuaState.Call(static_cast<int>(**itr), &a_Player, cLuaState::Return, res); if (res) { return true; @@ -1251,7 +1251,7 @@ bool cPluginLua::OnPlayerSpawned(cPlayer & a_Player) cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_PLAYER_SPAWNED]; for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr) { - m_LuaState.Call((int)(**itr), &a_Player, cLuaState::Return, res); + m_LuaState.Call(static_cast<int>(**itr), &a_Player, cLuaState::Return, res); if (res) { return true; @@ -1275,7 +1275,7 @@ bool cPluginLua::OnPlayerTossingItem(cPlayer & a_Player) cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_PLAYER_TOSSING_ITEM]; for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr) { - m_LuaState.Call((int)(**itr), &a_Player, cLuaState::Return, res); + m_LuaState.Call(static_cast<int>(**itr), &a_Player, cLuaState::Return, res); if (res) { return true; @@ -1299,7 +1299,7 @@ bool cPluginLua::OnPlayerUsedBlock(cPlayer & a_Player, int a_BlockX, int a_Block cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_PLAYER_USED_BLOCK]; for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr) { - m_LuaState.Call((int)(**itr), &a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, a_BlockType, a_BlockMeta, cLuaState::Return, res); + m_LuaState.Call(static_cast<int>(**itr), &a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, a_BlockType, a_BlockMeta, cLuaState::Return, res); if (res) { return true; @@ -1323,7 +1323,7 @@ bool cPluginLua::OnPlayerUsedItem(cPlayer & a_Player, int a_BlockX, int a_BlockY cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_PLAYER_USED_ITEM]; for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr) { - m_LuaState.Call((int)(**itr), &a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, cLuaState::Return, res); + m_LuaState.Call(static_cast<int>(**itr), &a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, cLuaState::Return, res); if (res) { return true; @@ -1347,7 +1347,7 @@ bool cPluginLua::OnPlayerUsingBlock(cPlayer & a_Player, int a_BlockX, int a_Bloc cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_PLAYER_USING_BLOCK]; for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr) { - m_LuaState.Call((int)(**itr), &a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, a_BlockType, a_BlockMeta, cLuaState::Return, res); + m_LuaState.Call(static_cast<int>(**itr), &a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, a_BlockType, a_BlockMeta, cLuaState::Return, res); if (res) { return true; @@ -1371,7 +1371,7 @@ bool cPluginLua::OnPlayerUsingItem(cPlayer & a_Player, int a_BlockX, int a_Block cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_PLAYER_USING_ITEM]; for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr) { - m_LuaState.Call((int)(**itr), &a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, cLuaState::Return, res); + m_LuaState.Call(static_cast<int>(**itr), &a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, cLuaState::Return, res); if (res) { return true; @@ -1395,7 +1395,7 @@ bool cPluginLua::OnPluginMessage(cClientHandle & a_Client, const AString & a_Cha cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_PLUGIN_MESSAGE]; for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr) { - m_LuaState.Call((int)(**itr), &a_Client, a_Channel, a_Message, cLuaState::Return, res); + m_LuaState.Call(static_cast<int>(**itr), &a_Client, a_Channel, a_Message, cLuaState::Return, res); if (res) { return true; @@ -1420,7 +1420,7 @@ bool cPluginLua::OnPluginsLoaded(void) for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr) { bool ret = false; - m_LuaState.Call((int)(**itr), cLuaState::Return, ret); + m_LuaState.Call(static_cast<int>(**itr), cLuaState::Return, ret); res = res || ret; } return res; @@ -1441,7 +1441,7 @@ bool cPluginLua::OnPostCrafting(cPlayer & a_Player, cCraftingGrid & a_Grid, cCra cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_POST_CRAFTING]; for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr) { - m_LuaState.Call((int)(**itr), &a_Player, &a_Grid, &a_Recipe, cLuaState::Return, res); + m_LuaState.Call(static_cast<int>(**itr), &a_Player, &a_Grid, &a_Recipe, cLuaState::Return, res); if (res) { return true; @@ -1465,7 +1465,7 @@ bool cPluginLua::OnPreCrafting(cPlayer & a_Player, cCraftingGrid & a_Grid, cCraf cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_PRE_CRAFTING]; for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr) { - m_LuaState.Call((int)(**itr), &a_Player, &a_Grid, &a_Recipe, cLuaState::Return, res); + m_LuaState.Call(static_cast<int>(**itr), &a_Player, &a_Grid, &a_Recipe, cLuaState::Return, res); if (res) { return true; @@ -1489,7 +1489,7 @@ bool cPluginLua::OnProjectileHitBlock(cProjectileEntity & a_Projectile, int a_Bl cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_PROJECTILE_HIT_BLOCK]; for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr) { - m_LuaState.Call((int)(**itr), &a_Projectile, a_BlockX, a_BlockY, a_BlockZ, a_Face, a_BlockHitPos, cLuaState::Return, res); + m_LuaState.Call(static_cast<int>(**itr), &a_Projectile, a_BlockX, a_BlockY, a_BlockZ, a_Face, a_BlockHitPos, cLuaState::Return, res); if (res) { return true; @@ -1513,7 +1513,7 @@ bool cPluginLua::OnProjectileHitEntity(cProjectileEntity & a_Projectile, cEntity cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_PROJECTILE_HIT_ENTITY]; for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr) { - m_LuaState.Call((int)(**itr), &a_Projectile, &a_HitEntity, cLuaState::Return, res); + m_LuaState.Call(static_cast<int>(**itr), &a_Projectile, &a_HitEntity, cLuaState::Return, res); if (res) { return true; @@ -1537,7 +1537,7 @@ bool cPluginLua::OnServerPing(cClientHandle & a_ClientHandle, AString & a_Server cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_SERVER_PING]; for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr) { - m_LuaState.Call((int)(**itr), &a_ClientHandle, a_ServerDescription, a_OnlinePlayersCount, a_MaxPlayersCount, a_Favicon, cLuaState::Return, res, a_ServerDescription, a_OnlinePlayersCount, a_MaxPlayersCount, a_Favicon); + m_LuaState.Call(static_cast<int>(**itr), &a_ClientHandle, a_ServerDescription, a_OnlinePlayersCount, a_MaxPlayersCount, a_Favicon, cLuaState::Return, res, a_ServerDescription, a_OnlinePlayersCount, a_MaxPlayersCount, a_Favicon); if (res) { return true; @@ -1561,7 +1561,7 @@ bool cPluginLua::OnSpawnedEntity(cWorld & a_World, cEntity & a_Entity) cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_SPAWNED_ENTITY]; for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr) { - m_LuaState.Call((int)(**itr), &a_World, &a_Entity, cLuaState::Return, res); + m_LuaState.Call(static_cast<int>(**itr), &a_World, &a_Entity, cLuaState::Return, res); if (res) { return true; @@ -1585,7 +1585,7 @@ bool cPluginLua::OnSpawnedMonster(cWorld & a_World, cMonster & a_Monster) cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_SPAWNED_MONSTER]; for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr) { - m_LuaState.Call((int)(**itr), &a_World, &a_Monster, cLuaState::Return, res); + m_LuaState.Call(static_cast<int>(**itr), &a_World, &a_Monster, cLuaState::Return, res); if (res) { return true; @@ -1609,7 +1609,7 @@ bool cPluginLua::OnSpawningEntity(cWorld & a_World, cEntity & a_Entity) cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_SPAWNING_ENTITY]; for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr) { - m_LuaState.Call((int)(**itr), &a_World, &a_Entity, cLuaState::Return, res); + m_LuaState.Call(static_cast<int>(**itr), &a_World, &a_Entity, cLuaState::Return, res); if (res) { return true; @@ -1633,7 +1633,7 @@ bool cPluginLua::OnSpawningMonster(cWorld & a_World, cMonster & a_Monster) cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_SPAWNING_MONSTER]; for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr) { - m_LuaState.Call((int)(**itr), &a_World, &a_Monster, cLuaState::Return, res); + m_LuaState.Call(static_cast<int>(**itr), &a_World, &a_Monster, cLuaState::Return, res); if (res) { return true; @@ -1657,7 +1657,7 @@ bool cPluginLua::OnTakeDamage(cEntity & a_Receiver, TakeDamageInfo & a_TDI) cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_TAKE_DAMAGE]; for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr) { - m_LuaState.Call((int)(**itr), &a_Receiver, &a_TDI, cLuaState::Return, res); + m_LuaState.Call(static_cast<int>(**itr), &a_Receiver, &a_TDI, cLuaState::Return, res); if (res) { return true; @@ -1686,7 +1686,7 @@ bool cPluginLua::OnUpdatedSign( cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_UPDATED_SIGN]; for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr) { - m_LuaState.Call((int)(**itr), &a_World, a_BlockX, a_BlockY, a_BlockZ, a_Line1, a_Line2, a_Line3, a_Line4, a_Player, cLuaState::Return, res); + m_LuaState.Call(static_cast<int>(**itr), &a_World, a_BlockX, a_BlockY, a_BlockZ, a_Line1, a_Line2, a_Line3, a_Line4, a_Player, cLuaState::Return, res); if (res) { return true; @@ -1715,7 +1715,7 @@ bool cPluginLua::OnUpdatingSign( cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_UPDATING_SIGN]; for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr) { - m_LuaState.Call((int)(**itr), &a_World, a_BlockX, a_BlockY, a_BlockZ, a_Line1, a_Line2, a_Line3, a_Line4, a_Player, cLuaState::Return, res, a_Line1, a_Line2, a_Line3, a_Line4); + m_LuaState.Call(static_cast<int>(**itr), &a_World, a_BlockX, a_BlockY, a_BlockZ, a_Line1, a_Line2, a_Line3, a_Line4, a_Player, cLuaState::Return, res, a_Line1, a_Line2, a_Line3, a_Line4); if (res) { return true; @@ -1739,7 +1739,7 @@ bool cPluginLua::OnWeatherChanged(cWorld & a_World) cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_WEATHER_CHANGED]; for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr) { - m_LuaState.Call((int)(**itr), &a_World, cLuaState::Return, res); + m_LuaState.Call(static_cast<int>(**itr), &a_World, cLuaState::Return, res); if (res) { return true; @@ -1763,7 +1763,7 @@ bool cPluginLua::OnWeatherChanging(cWorld & a_World, eWeather & a_NewWeather) cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_WEATHER_CHANGING]; for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr) { - m_LuaState.Call((int)(**itr), &a_World, a_NewWeather, cLuaState::Return, res, a_NewWeather); + m_LuaState.Call(static_cast<int>(**itr), &a_World, a_NewWeather, cLuaState::Return, res, a_NewWeather); if (res) { return true; @@ -1786,7 +1786,7 @@ bool cPluginLua::OnWorldStarted(cWorld & a_World) cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_WORLD_STARTED]; for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr) { - m_LuaState.Call((int)(**itr), &a_World); + m_LuaState.Call(static_cast<int>(**itr), &a_World); } return false; } @@ -1805,7 +1805,7 @@ bool cPluginLua::OnWorldTick(cWorld & a_World, std::chrono::milliseconds a_Dt, s cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_WORLD_TICK]; for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr) { - m_LuaState.Call((int)(**itr), &a_World, a_Dt, a_LastTickDurationMSec); + m_LuaState.Call(static_cast<int>(**itr), &a_World, a_Dt, a_LastTickDurationMSec); } return false; } diff --git a/src/Bindings/PluginLua.h b/src/Bindings/PluginLua.h index 7de70ef1f..4344b36ac 100644 --- a/src/Bindings/PluginLua.h +++ b/src/Bindings/PluginLua.h @@ -125,7 +125,7 @@ public: virtual bool OnHopperPushingItem (cWorld & a_World, cHopperEntity & a_Hopper, int a_SrcSlotNum, cBlockEntityWithItems & a_DstEntity, int a_DstSlotNum) override; virtual bool OnKilled (cEntity & a_Victim, TakeDamageInfo & a_TDI, AString & a_DeathMessage) override; virtual bool OnKilling (cEntity & a_Victim, cEntity * a_Killer, TakeDamageInfo & a_TDI) override; - virtual bool OnLogin (cClientHandle & a_Client, int a_ProtocolVersion, const AString & a_Username) override; + virtual bool OnLogin (cClientHandle & a_Client, UInt32 a_ProtocolVersion, const AString & a_Username) override; virtual bool OnPlayerAnimation (cPlayer & a_Player, int a_Animation) override; virtual bool OnPlayerBreakingBlock (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) override; virtual bool OnPlayerBrokenBlock (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) override; diff --git a/src/Bindings/PluginManager.cpp b/src/Bindings/PluginManager.cpp index 712c385c7..026865f5b 100644 --- a/src/Bindings/PluginManager.cpp +++ b/src/Bindings/PluginManager.cpp @@ -713,7 +713,7 @@ bool cPluginManager::CallHookKilling(cEntity & a_Victim, cEntity * a_Killer, Tak -bool cPluginManager::CallHookLogin(cClientHandle & a_Client, int a_ProtocolVersion, const AString & a_Username) +bool cPluginManager::CallHookLogin(cClientHandle & a_Client, UInt32 a_ProtocolVersion, const AString & a_Username) { FIND_HOOK(HOOK_LOGIN); VERIFY_HOOK; diff --git a/src/Bindings/PluginManager.h b/src/Bindings/PluginManager.h index 153f4996d..d7e3b8dfe 100644 --- a/src/Bindings/PluginManager.h +++ b/src/Bindings/PluginManager.h @@ -214,7 +214,7 @@ public: bool CallHookHopperPushingItem (cWorld & a_World, cHopperEntity & a_Hopper, int a_SrcSlotNum, cBlockEntityWithItems & a_DstEntity, int a_DstSlotNum); bool CallHookKilled (cEntity & a_Victim, TakeDamageInfo & a_TDI, AString & a_DeathMessage); bool CallHookKilling (cEntity & a_Victim, cEntity * a_Killer, TakeDamageInfo & a_TDI); - bool CallHookLogin (cClientHandle & a_Client, int a_ProtocolVersion, const AString & a_Username); + bool CallHookLogin (cClientHandle & a_Client, UInt32 a_ProtocolVersion, const AString & a_Username); bool CallHookPlayerAnimation (cPlayer & a_Player, int a_Animation); bool CallHookPlayerBreakingBlock (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta); bool CallHookPlayerBrokenBlock (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta); |