diff options
-rw-r--r-- | src/Bindings/DeprecatedBindings.cpp | 45 | ||||
-rw-r--r-- | src/Bindings/ManualBindings.cpp | 18 |
2 files changed, 29 insertions, 34 deletions
diff --git a/src/Bindings/DeprecatedBindings.cpp b/src/Bindings/DeprecatedBindings.cpp index 574a017a6..876ec7b20 100644 --- a/src/Bindings/DeprecatedBindings.cpp +++ b/src/Bindings/DeprecatedBindings.cpp @@ -281,32 +281,29 @@ static int tolua_cWorld_SetSignLines(lua_State * tolua_S) cLuaState LuaState(tolua_S); #ifndef TOLUA_RELEASE - tolua_Error tolua_err; if ( - !tolua_isusertype (LuaState, 1, "cWorld", 0, &tolua_err) || - !tolua_isnumber (LuaState, 2, 0, &tolua_err) || - !tolua_isnumber (LuaState, 3, 0, &tolua_err) || - !tolua_isnumber (LuaState, 4, 0, &tolua_err) || - !tolua_iscppstring(LuaState, 5, 0, &tolua_err) || - !tolua_iscppstring(LuaState, 6, 0, &tolua_err) || - !tolua_iscppstring(LuaState, 7, 0, &tolua_err) || - !tolua_iscppstring(LuaState, 8, 0, &tolua_err) || - !tolua_isusertype (LuaState, 9, "cPlayer", 1, &tolua_err) || - !tolua_isnoobj (LuaState, 10, &tolua_err) + !LuaState.CheckParamUserType(1, "cWorld") || + !LuaState.CheckParamNumber(2, 4) || + !LuaState.CheckParamString(5, 8) || + !LuaState.CheckParamUserType(9, "cPlayer") || + !LuaState.CheckParamEnd(10) ) - goto tolua_lerror; + return 0; else #endif { - 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); + cWorld * self = nullptr; + cPlayer * Player = nullptr; + int BlockX = 0; + int BlockY = 0; + int BlockZ = 0; + AString Line1; + AString Line2; + AString Line3; + AString Line4; + + LuaState.GetStackValues(1, self, BlockX, BlockY, BlockZ, Line1, Line2, Line3, Line4, Player); + #ifndef TOLUA_RELEASE if (self == nullptr) { @@ -321,12 +318,6 @@ static int tolua_cWorld_SetSignLines(lua_State * tolua_S) LOGWARNING("Warning in function call 'UpdateSign': UpdateSign() is deprecated. Please use SetSignLines()"); LuaState.LogStackTrace(0); return 1; - - #ifndef TOLUA_RELEASE -tolua_lerror: - tolua_error(LuaState, "#ferror in function 'UpdateSign'.", &tolua_err); - return 0; - #endif } diff --git a/src/Bindings/ManualBindings.cpp b/src/Bindings/ManualBindings.cpp index 4260d33c7..b4d5449b5 100644 --- a/src/Bindings/ManualBindings.cpp +++ b/src/Bindings/ManualBindings.cpp @@ -1313,23 +1313,27 @@ static int tolua_SetObjectCallback(lua_State * tolua_S) static int tolua_cPluginLua_AddWebTab(lua_State * tolua_S) { - cPluginLua * self = reinterpret_cast<cPluginLua *>(tolua_tousertype(tolua_S, 1, nullptr)); + cLuaState LuaState(tolua_S); + cPluginLua * self = nullptr; + if (!LuaState.GetStackValue(1, self)) + { + LOGWARNING("cPluginLua:AddWebTab: invalid self as first argument"); + return 0; + } + tolua_Error tolua_err; tolua_err.array = 0; tolua_err.index = 3; tolua_err.type = "function"; - std::string Title = ""; + std::string Title; int Reference = LUA_REFNIL; - if ( - tolua_isstring(tolua_S, 2, 0, &tolua_err) && - lua_isfunction(tolua_S, 3) - ) + if (LuaState.CheckParamString(2) && LuaState.CheckParamFunction(3)) { Reference = luaL_ref(tolua_S, LUA_REGISTRYINDEX); - Title = (static_cast<std::string>(tolua_tocppstring(tolua_S, 2, 0))); + LuaState.GetStackValue(2, Title); } else { |