diff options
author | Alexander Harkness <me@bearbin.net> | 2024-11-02 22:27:47 +0100 |
---|---|---|
committer | Alexander Harkness <me@bearbin.net> | 2024-11-02 22:27:47 +0100 |
commit | cb50ec10591c0e0e4b9915e642bc50d3d8d1fd0a (patch) | |
tree | f647b20e1823f1846af88e832cf82a4a02e96e69 /src/Bindings/ManualBindings.cpp | |
parent | Improve clang-format config file, remove automatically enforced code style from contrib guide. (diff) | |
download | cuberite-cb50ec10591c0e0e4b9915e642bc50d3d8d1fd0a.tar cuberite-cb50ec10591c0e0e4b9915e642bc50d3d8d1fd0a.tar.gz cuberite-cb50ec10591c0e0e4b9915e642bc50d3d8d1fd0a.tar.bz2 cuberite-cb50ec10591c0e0e4b9915e642bc50d3d8d1fd0a.tar.lz cuberite-cb50ec10591c0e0e4b9915e642bc50d3d8d1fd0a.tar.xz cuberite-cb50ec10591c0e0e4b9915e642bc50d3d8d1fd0a.tar.zst cuberite-cb50ec10591c0e0e4b9915e642bc50d3d8d1fd0a.zip |
Diffstat (limited to 'src/Bindings/ManualBindings.cpp')
-rw-r--r-- | src/Bindings/ManualBindings.cpp | 1365 |
1 files changed, 566 insertions, 799 deletions
diff --git a/src/Bindings/ManualBindings.cpp b/src/Bindings/ManualBindings.cpp index 93c94fdff..5c70b3033 100644 --- a/src/Bindings/ManualBindings.cpp +++ b/src/Bindings/ManualBindings.cpp @@ -44,7 +44,7 @@ // Hotpatching the Macro to prevent a Clang Warning (0 for pointer used) -#undef lua_tostring +#undef lua_tostring #define lua_tostring(L, i) lua_tolstring(L, (i), nullptr) @@ -55,11 +55,10 @@ // LuaCommandHandler: /** Defines a bridge between cPluginManager::cCommandHandler and cLuaState::cCallback. */ -class LuaCommandHandler: - public cPluginManager::cCommandHandler +class LuaCommandHandler : public cPluginManager::cCommandHandler { -public: - LuaCommandHandler(cLuaState::cCallbackPtr && a_Callback): + public: + LuaCommandHandler(cLuaState::cCallbackPtr && a_Callback) : m_Callback(std::move(a_Callback)) { } @@ -84,7 +83,7 @@ public: return res; } -protected: + protected: cLuaState::cCallbackPtr m_Callback; }; @@ -105,7 +104,7 @@ int cManualBindings::tolua_do_error(lua_State * L, const char * a_pMsg, tolua_Er // Insert function name into error msg AString msg(a_pMsg); - ReplaceString(msg, "#funcname#", entry.name?entry.name:"?"); + ReplaceString(msg, "#funcname#", entry.name ? entry.name : "?"); // Send the error to Lua tolua_error(L, msg.c_str(), a_pToLuaError); @@ -146,12 +145,19 @@ static int tolua_Clamp(lua_State * tolua_S) int NumArgs = lua_gettop(LuaState); if (NumArgs != 3) { - return cManualBindings::lua_do_error(LuaState, "Error in function call '#funcname#': Requires 3 arguments, got %i", NumArgs); + return cManualBindings::lua_do_error( + LuaState, + "Error in function call '#funcname#': Requires 3 arguments, got %i", + NumArgs + ); } if (!lua_isnumber(LuaState, 1) || !lua_isnumber(LuaState, 2) || !lua_isnumber(LuaState, 3)) { - return cManualBindings::lua_do_error(LuaState, "Error in function call '#funcname#': Expected a number for parameters #1, #2 and #3"); + return cManualBindings::lua_do_error( + LuaState, + "Error in function call '#funcname#': Expected a number for parameters #1, #2 and #3" + ); } lua_Number Number = tolua_tonumber(LuaState, 1, 0); @@ -170,13 +176,7 @@ static int tolua_Clamp(lua_State * tolua_S) static int tolua_CompressStringZLIB(lua_State * tolua_S) { cLuaState S(tolua_S); - if ( - !S.CheckParamString(1) || - ( - !S.CheckParamNumber(2) && - !S.CheckParamEnd(2) - ) - ) + if (!S.CheckParamString(1) || (!S.CheckParamNumber(2) && !S.CheckParamEnd(2))) { cLuaState::LogStackTrace(tolua_S); return 0; @@ -199,10 +199,7 @@ static int tolua_CompressStringZLIB(lua_State * tolua_S) static int tolua_UncompressStringZLIB(lua_State * tolua_S) { cLuaState S(tolua_S); - if ( - !S.CheckParamString(1) || - !S.CheckParamNumber(2) - ) + if (!S.CheckParamString(1) || !S.CheckParamNumber(2)) { cLuaState::LogStackTrace(tolua_S); return 0; @@ -234,10 +231,7 @@ static int tolua_UncompressStringZLIB(lua_State * tolua_S) static int tolua_CompressStringGZIP(lua_State * tolua_S) { cLuaState S(tolua_S); - if ( - !S.CheckParamString(1) || - !S.CheckParamEnd(2) - ) + if (!S.CheckParamString(1) || !S.CheckParamEnd(2)) { cLuaState::LogStackTrace(tolua_S); return 0; @@ -259,10 +253,7 @@ static int tolua_CompressStringGZIP(lua_State * tolua_S) static int tolua_InflateString(lua_State * tolua_S) { cLuaState S(tolua_S); - if ( - !S.CheckParamString(1) || - !S.CheckParamEnd(2) - ) + if (!S.CheckParamString(1) || !S.CheckParamEnd(2)) { cLuaState::LogStackTrace(tolua_S); return 0; @@ -328,10 +319,7 @@ static int tolua_StringSplitAndTrim(lua_State * tolua_S) { // Check params: cLuaState L(tolua_S); - if ( - !L.CheckParamString(1, 2) || - !L.CheckParamEnd(3) - ) + if (!L.CheckParamString(1, 2) || !L.CheckParamEnd(3)) { return 0; } @@ -347,7 +335,8 @@ static int tolua_StringSplitAndTrim(lua_State * tolua_S) -/** Prints the message to the console, optionally formatting it with a plugin name prefix if the second param on the Lua stack is true. */ +/** Prints the message to the console, optionally formatting it with a plugin name prefix if the second param on the Lua + * stack is true. */ static void LogFromLuaStack(lua_State * tolua_S, const std::string_view a_Message, const eLogLevel a_LogLevel) { if (lua_isboolean(tolua_S, 2) && (lua_toboolean(tolua_S, 2) == 1)) @@ -356,7 +345,10 @@ static void LogFromLuaStack(lua_State * tolua_S, const std::string_view a_Messag } else { - Logger::LogSimple(fmt::format("[{}] {}", cManualBindings::GetLuaPlugin(tolua_S)->GetName(), a_Message), a_LogLevel); + Logger::LogSimple( + fmt::format("[{}] {}", cManualBindings::GetLuaPlugin(tolua_S)->GetName(), a_Message), + a_LogLevel + ); } } @@ -364,7 +356,8 @@ static void LogFromLuaStack(lua_State * tolua_S, const std::string_view a_Messag -/** Retrieves a string log message from the first param on the Lua stack, optionally prefixes it with plugin name, and prints it to the console. */ +/** Retrieves a string log message from the first param on the Lua stack, optionally prefixes it with plugin name, and + * prints it to the console. */ static void LogFromLuaStack(lua_State * tolua_S, const eLogLevel a_LogLevel) { cLuaState L(tolua_S); @@ -393,7 +386,11 @@ static int tolua_LOG(lua_State * tolua_S) const auto CompositeChat = static_cast<cCompositeChat *>(tolua_tousertype(tolua_S, 1, nullptr)); if (CompositeChat != nullptr) // isusertype returns true for nil values { - LogFromLuaStack(tolua_S, CompositeChat->ExtractText(), cCompositeChat::MessageTypeToLogLevel(CompositeChat->GetMessageType())); + LogFromLuaStack( + tolua_S, + CompositeChat->ExtractText(), + cCompositeChat::MessageTypeToLogLevel(CompositeChat->GetMessageType()) + ); return 0; } } @@ -440,10 +437,7 @@ static int tolua_LOGERROR(lua_State * tolua_S) static int tolua_Base64Encode(lua_State * tolua_S) { cLuaState L(tolua_S); - if ( - !L.CheckParamString(1) || - !L.CheckParamEnd(2) - ) + if (!L.CheckParamString(1) || !L.CheckParamEnd(2)) { return 0; } @@ -462,10 +456,7 @@ static int tolua_Base64Encode(lua_State * tolua_S) static int tolua_Base64Decode(lua_State * tolua_S) { cLuaState L(tolua_S); - if ( - !L.CheckParamString(1) || - !L.CheckParamEnd(2) - ) + if (!L.CheckParamString(1) || !L.CheckParamEnd(2)) { return 0; } @@ -491,7 +482,7 @@ cPluginLua * cManualBindings::GetLuaPlugin(lua_State * L) lua_pop(L, 1); return nullptr; } - cPluginLua * Plugin = static_cast<cPluginLua *>(const_cast<void*>(lua_topointer(L, -1))); + cPluginLua * Plugin = static_cast<cPluginLua *>(const_cast<void *>(lua_topointer(L, -1))); lua_pop(L, 1); return Plugin; @@ -508,11 +499,7 @@ static int tolua_cFile_ChangeFileExt(lua_State * tolua_S) // Check params: cLuaState L(tolua_S); - if ( - !L.CheckParamUserTable(1, "cFile") || - !L.CheckParamString(2, 3) || - !L.CheckParamEnd(4) - ) + if (!L.CheckParamUserTable(1, "cFile") || !L.CheckParamString(2, 3) || !L.CheckParamEnd(4)) { return 0; } @@ -535,11 +522,7 @@ static int tolua_cFile_Copy(lua_State * tolua_S) // Check params: cLuaState L(tolua_S); - if ( - !L.CheckParamUserTable(1, "cFile") || - !L.CheckParamString(2, 3) || - !L.CheckParamEnd(4) - ) + if (!L.CheckParamUserTable(1, "cFile") || !L.CheckParamString(2, 3) || !L.CheckParamEnd(4)) { return 0; } @@ -562,11 +545,7 @@ static int tolua_cFile_CreateFolder(lua_State * tolua_S) // Check params: cLuaState L(tolua_S); - if ( - !L.CheckParamUserTable(1, "cFile") || - !L.CheckParamString(2) || - !L.CheckParamEnd(3) - ) + if (!L.CheckParamUserTable(1, "cFile") || !L.CheckParamString(2) || !L.CheckParamEnd(3)) { return 0; } @@ -589,11 +568,7 @@ static int tolua_cFile_CreateFolderRecursive(lua_State * tolua_S) // Check params: cLuaState L(tolua_S); - if ( - !L.CheckParamUserTable(1, "cFile") || - !L.CheckParamString(2) || - !L.CheckParamEnd(3) - ) + if (!L.CheckParamUserTable(1, "cFile") || !L.CheckParamString(2) || !L.CheckParamEnd(3)) { return 0; } @@ -616,11 +591,7 @@ static int tolua_cFile_Delete(lua_State * tolua_S) // Check params: cLuaState L(tolua_S); - if ( - !L.CheckParamUserTable(1, "cFile") || - !L.CheckParamString(2) || - !L.CheckParamEnd(3) - ) + if (!L.CheckParamUserTable(1, "cFile") || !L.CheckParamString(2) || !L.CheckParamEnd(3)) { return 0; } @@ -643,11 +614,7 @@ static int tolua_cFile_DeleteFile(lua_State * tolua_S) // Check params: cLuaState L(tolua_S); - if ( - !L.CheckParamUserTable(1, "cFile") || - !L.CheckParamString(2) || - !L.CheckParamEnd(3) - ) + if (!L.CheckParamUserTable(1, "cFile") || !L.CheckParamString(2) || !L.CheckParamEnd(3)) { return 0; } @@ -670,11 +637,7 @@ static int tolua_cFile_DeleteFolder(lua_State * tolua_S) // Check params: cLuaState L(tolua_S); - if ( - !L.CheckParamUserTable(1, "cFile") || - !L.CheckParamString(2) || - !L.CheckParamEnd(3) - ) + if (!L.CheckParamUserTable(1, "cFile") || !L.CheckParamString(2) || !L.CheckParamEnd(3)) { return 0; } @@ -697,11 +660,7 @@ static int tolua_cFile_DeleteFolderContents(lua_State * tolua_S) // Check params: cLuaState L(tolua_S); - if ( - !L.CheckParamUserTable(1, "cFile") || - !L.CheckParamString(2) || - !L.CheckParamEnd(3) - ) + if (!L.CheckParamUserTable(1, "cFile") || !L.CheckParamString(2) || !L.CheckParamEnd(3)) { return 0; } @@ -728,11 +687,7 @@ static int tolua_cFile_Exists(lua_State * tolua_S) L.LogStackTrace(); // Check params: - if ( - !L.CheckParamUserTable(1, "cFile") || - !L.CheckParamString(2) || - !L.CheckParamEnd(3) - ) + if (!L.CheckParamUserTable(1, "cFile") || !L.CheckParamString(2) || !L.CheckParamEnd(3)) { return 0; } @@ -755,11 +710,7 @@ static int tolua_cFile_GetFolderContents(lua_State * tolua_S) // Check params: cLuaState LuaState(tolua_S); - if ( - !LuaState.CheckParamUserTable(1, "cFile") || - !LuaState.CheckParamString (2) || - !LuaState.CheckParamEnd (3) - ) + if (!LuaState.CheckParamUserTable(1, "cFile") || !LuaState.CheckParamString(2) || !LuaState.CheckParamEnd(3)) { return 0; } @@ -784,11 +735,7 @@ static int tolua_cFile_GetLastModificationTime(lua_State * tolua_S) // Check params: cLuaState L(tolua_S); - if ( - !L.CheckParamUserTable(1, "cFile") || - !L.CheckParamString(2) || - !L.CheckParamEnd(3) - ) + if (!L.CheckParamUserTable(1, "cFile") || !L.CheckParamString(2) || !L.CheckParamEnd(3)) { return 0; } @@ -811,11 +758,7 @@ static int tolua_cFile_GetSize(lua_State * tolua_S) // Check params: cLuaState L(tolua_S); - if ( - !L.CheckParamUserTable(1, "cFile") || - !L.CheckParamString(2) || - !L.CheckParamEnd(3) - ) + if (!L.CheckParamUserTable(1, "cFile") || !L.CheckParamString(2) || !L.CheckParamEnd(3)) { return 0; } @@ -838,11 +781,7 @@ static int tolua_cFile_IsFile(lua_State * tolua_S) // Check params: cLuaState L(tolua_S); - if ( - !L.CheckParamUserTable(1, "cFile") || - !L.CheckParamString(2) || - !L.CheckParamEnd(3) - ) + if (!L.CheckParamUserTable(1, "cFile") || !L.CheckParamString(2) || !L.CheckParamEnd(3)) { return 0; } @@ -865,11 +804,7 @@ static int tolua_cFile_IsFolder(lua_State * tolua_S) // Check params: cLuaState L(tolua_S); - if ( - !L.CheckParamUserTable(1, "cFile") || - !L.CheckParamString(2) || - !L.CheckParamEnd(3) - ) + if (!L.CheckParamUserTable(1, "cFile") || !L.CheckParamString(2) || !L.CheckParamEnd(3)) { return 0; } @@ -892,11 +827,7 @@ static int tolua_cFile_ReadWholeFile(lua_State * tolua_S) // Check params: cLuaState LuaState(tolua_S); - if ( - !LuaState.CheckParamUserTable(1, "cFile") || - !LuaState.CheckParamString (2) || - !LuaState.CheckParamEnd (3) - ) + if (!LuaState.CheckParamUserTable(1, "cFile") || !LuaState.CheckParamString(2) || !LuaState.CheckParamEnd(3)) { return 0; } @@ -921,11 +852,7 @@ static int tolua_cFile_Rename(lua_State * tolua_S) // Check params: cLuaState L(tolua_S); - if ( - !L.CheckParamUserTable(1, "cFile") || - !L.CheckParamString(2, 3) || - !L.CheckParamEnd(4) - ) + if (!L.CheckParamUserTable(1, "cFile") || !L.CheckParamString(2, 3) || !L.CheckParamEnd(4)) { return 0; } @@ -975,7 +902,8 @@ static int tolua_cPluginManager_GetCurrentPlugin(lua_State * S) static int tolua_cPluginManager_GetPlugin(lua_State * tolua_S) { // API function no longer available: - LOGWARNING("cPluginManager:GetPlugin() is no longer available. Use cPluginManager:DoWithPlugin() or cPluginManager:CallPlugin() instead."); + LOGWARNING("cPluginManager:GetPlugin() is no longer available. Use cPluginManager:DoWithPlugin() or " + "cPluginManager:CallPlugin() instead."); cLuaState::LogStackTrace(tolua_S); return 0; } @@ -1057,14 +985,17 @@ static int tolua_cPluginManager_AddHook_DefFn(cPluginManager * a_PluginManager, cPluginLua * Plugin = static_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"); + LOGWARNING("cPluginManager.AddHook(): Invalid Plugin parameter, expected a valid cPlugin object. Hook not added" + ); S.LogStackTrace(); return 0; } if (Plugin != cManualBindings::GetLuaPlugin(S)) { // The plugin parameter passed to us is not our stored plugin. Disallow this! - LOGWARNING("cPluginManager.AddHook(): Invalid Plugin parameter, cannot add hook to foreign plugins. Hook not added."); + LOGWARNING( + "cPluginManager.AddHook(): Invalid Plugin parameter, cannot add hook to foreign plugins. Hook not added." + ); S.LogStackTrace(); return 0; } @@ -1115,8 +1046,9 @@ static int tolua_cPluginManager_AddHook(lua_State * tolua_S) cPluginManager:AddHook(HOOK_TYPE, CallbackFunction) -- (1) recommended cPluginManager.AddHook(HOOK_TYPE, CallbackFunction) -- (2) accepted silently (#401 deprecates this) cPluginManager:Get():AddHook(HOOK_TYPE, CallbackFunction) -- (3) accepted silently - cPluginManager:Get():AddHook(Plugin, HOOK_TYPE) -- (4) old style (#121), accepted but complained about in the console - cPluginManager.AddHook(Plugin, HOOK_TYPE) -- (5) old style (#121) mangled, accepted but complained about in the console + cPluginManager:Get():AddHook(Plugin, HOOK_TYPE) -- (4) old style (#121), accepted but complained about in + the console cPluginManager.AddHook(Plugin, HOOK_TYPE) -- (5) old style (#121) mangled, accepted but + complained about in the console */ cLuaState S(tolua_S); @@ -1131,7 +1063,9 @@ static int tolua_cPluginManager_AddHook(lua_State * tolua_S) PlgMgr = static_cast<cPluginManager *>(tolua_tousertype(S, 1, nullptr)); if (PlgMgr == nullptr) { - LOGWARNING("Malformed plugin, use cPluginManager.AddHook(HOOK_TYPE, CallbackFunction). Fixing the call for you."); + LOGWARNING( + "Malformed plugin, use cPluginManager.AddHook(HOOK_TYPE, CallbackFunction). Fixing the call for you." + ); S.LogStackTrace(); PlgMgr = cPluginManager::Get(); } @@ -1151,13 +1085,17 @@ static int tolua_cPluginManager_AddHook(lua_State * tolua_S) else if (tolua_isusertype(S, ParamIdx, "cPlugin", 0, &err) && lua_isnumber(S, ParamIdx + 1)) { // The next params are a cPlugin and a number, assume style 3 or 4 - LOGINFO("cPluginManager.AddHook(): Deprecated format used, use cPluginManager.AddHook(HOOK_TYPE, CallbackFunction) instead. Fixing the call for you."); + LOGINFO("cPluginManager.AddHook(): Deprecated format used, use cPluginManager.AddHook(HOOK_TYPE, " + "CallbackFunction) instead. Fixing the call for you."); S.LogStackTrace(); return tolua_cPluginManager_AddHook_DefFn(PlgMgr, S, ParamIdx); } auto ParamDesc = fmt::format(FMT_STRING("{}, {}, {}"), S.GetTypeText(1), S.GetTypeText(2), S.GetTypeText(3)); - LOGWARNING("cPluginManager:AddHook(): bad parameters. Expected HOOK_TYPE and CallbackFunction, got %s. Hook not added.", ParamDesc); + LOGWARNING( + "cPluginManager:AddHook(): bad parameters. Expected HOOK_TYPE and CallbackFunction, got %s. Hook not added.", + ParamDesc + ); S.LogStackTrace(); return 0; } @@ -1175,11 +1113,7 @@ static int tolua_cPluginManager_ForEachCommand(lua_State * tolua_S) // Check params: cLuaState L(tolua_S); - if ( - !L.CheckParamUserType(1, "cPluginManager") || - !L.CheckParamFunction(2) || - !L.CheckParamEnd(3) - ) + if (!L.CheckParamUserType(1, "cPluginManager") || !L.CheckParamFunction(2) || !L.CheckParamEnd(3)) { return 0; } @@ -1196,15 +1130,19 @@ static int tolua_cPluginManager_ForEachCommand(lua_State * tolua_S) // Callback for enumerating all commands: class cLuaCallback : public cPluginManager::cCommandEnumCallback { - public: - cLuaCallback(cLuaState & a_LuaState, cLuaState::cRef & a_FnRef): - m_LuaState(a_LuaState), - m_FnRef(a_FnRef) + public: + cLuaCallback(cLuaState & a_LuaState, cLuaState::cRef & a_FnRef) : + m_LuaState(a_LuaState), m_FnRef(a_FnRef) { } - private: - virtual bool Command(const AString & a_Command, const cPlugin * a_Plugin, const AString & a_Permission, const AString & a_HelpString) override + private: + virtual bool Command( + const AString & a_Command, + const cPlugin * a_Plugin, + const AString & a_Permission, + const AString & a_HelpString + ) override { UNUSED(a_Plugin); bool ret = false; @@ -1233,11 +1171,7 @@ static int tolua_cPluginManager_ForEachConsoleCommand(lua_State * tolua_S) // Check params: cLuaState L(tolua_S); - if ( - !L.CheckParamUserType(1, "cPluginManager") || - !L.CheckParamFunction(2) || - !L.CheckParamEnd(3) - ) + if (!L.CheckParamUserType(1, "cPluginManager") || !L.CheckParamFunction(2) || !L.CheckParamEnd(3)) { return 0; } @@ -1254,15 +1188,19 @@ static int tolua_cPluginManager_ForEachConsoleCommand(lua_State * tolua_S) // Callback for enumerating all commands: class cLuaCallback : public cPluginManager::cCommandEnumCallback { - public: - cLuaCallback(cLuaState & a_LuaState, cLuaState::cRef & a_FnRef): - m_LuaState(a_LuaState), - m_FnRef(a_FnRef) + public: + cLuaCallback(cLuaState & a_LuaState, cLuaState::cRef & a_FnRef) : + m_LuaState(a_LuaState), m_FnRef(a_FnRef) { } - private: - virtual bool Command(const AString & a_Command, const cPlugin * a_Plugin, const AString & a_Permission, const AString & a_HelpString) override + private: + virtual bool Command( + const AString & a_Command, + const cPlugin * a_Plugin, + const AString & a_Permission, + const AString & a_HelpString + ) override { UNUSED(a_Plugin); UNUSED(a_Permission); @@ -1300,19 +1238,13 @@ static int tolua_cPluginManager_BindCommand(lua_State * a_LuaState) // Read the arguments to this API call: tolua_Error tolua_err; int idx = 1; - if ( - tolua_isusertype (L, 1, "cPluginManager", 0, &tolua_err) || - tolua_isusertable(L, 1, "cPluginManager", 0, &tolua_err) - ) + if (tolua_isusertype(L, 1, "cPluginManager", 0, &tolua_err) || + tolua_isusertable(L, 1, "cPluginManager", 0, &tolua_err)) { idx++; } - if ( - !tolua_iscppstring(L, idx, 0, &tolua_err) || - !tolua_iscppstring(L, idx + 1, 0, &tolua_err) || - !tolua_iscppstring(L, idx + 3, 0, &tolua_err) || - !tolua_isnoobj (L, idx + 4, &tolua_err) - ) + if (!tolua_iscppstring(L, idx, 0, &tolua_err) || !tolua_iscppstring(L, idx + 1, 0, &tolua_err) || + !tolua_iscppstring(L, idx + 3, 0, &tolua_err) || !tolua_isnoobj(L, idx + 4, &tolua_err)) { tolua_error(L, "#ferror in function 'BindCommand'.", &tolua_err); return 0; @@ -1367,25 +1299,24 @@ static int tolua_cPluginManager_BindConsoleCommand(lua_State * a_LuaState) // Read the arguments to this API call: tolua_Error tolua_err; int idx = 1; - if ( - tolua_isusertype(L, 1, "cPluginManager", 0, &tolua_err) || - tolua_isusertable(L, 1, "cPluginManager", 0, &tolua_err) - ) + if (tolua_isusertype(L, 1, "cPluginManager", 0, &tolua_err) || + tolua_isusertable(L, 1, "cPluginManager", 0, &tolua_err)) { idx++; } - if ( - !tolua_iscppstring(L, idx, 0, &tolua_err) || // Command + if (!tolua_iscppstring(L, idx, 0, &tolua_err) || // Command !tolua_iscppstring(L, idx + 2, 0, &tolua_err) || // HelpString - !tolua_isnoobj (L, idx + 3, &tolua_err) - ) + !tolua_isnoobj(L, idx + 3, &tolua_err)) { tolua_error(L, "#ferror in function 'BindConsoleCommand'.", &tolua_err); return 0; } if (!lua_isfunction(L, idx + 1)) { - luaL_error(L, "\"BindConsoleCommand\" function expects a function as its 2nd parameter. Command-binding aborted."); + luaL_error( + L, + "\"BindConsoleCommand\" function expects a function as its 2nd parameter. Command-binding aborted." + ); return 0; } cPluginManager * self = cPluginManager::Get(); @@ -1394,7 +1325,10 @@ static int tolua_cPluginManager_BindConsoleCommand(lua_State * a_LuaState) L.GetStackValues(idx, Command, Handler, HelpString); if (!Handler->IsValid()) { - LOGERROR("\"BindConsoleCommand\": Cannot create a function reference. Console command \"%s\" not bound.", Command.c_str()); + LOGERROR( + "\"BindConsoleCommand\": Cannot create a function reference. Console command \"%s\" not bound.", + Command.c_str() + ); return 0; } @@ -1422,9 +1356,7 @@ static int tolua_cPluginManager_CallPlugin(lua_State * tolua_S) // Check the parameters: cLuaState L(tolua_S); - if ( - !L.CheckParamUserTable(1, "cPluginManager") || - !L.CheckParamString(2, 3)) + if (!L.CheckParamUserTable(1, "cPluginManager") || !L.CheckParamString(2, 3)) { return 0; } @@ -1456,16 +1388,15 @@ static int tolua_cPluginManager_CallPlugin(lua_State * tolua_S) // Call the destination plugin using a plugin callback: int NumReturns = 0; auto PluginCallback = [&](cPlugin & a_Plugin) + { + if (!a_Plugin.IsLoaded()) { - if (!a_Plugin.IsLoaded()) - { - return false; - } - NumReturns = static_cast<cPluginLua &>(a_Plugin).CallFunctionFromForeignState( - FunctionName, L, 4, lua_gettop(L) - ); - return true; - }; + return false; + } + NumReturns = + static_cast<cPluginLua &>(a_Plugin).CallFunctionFromForeignState(FunctionName, L, 4, lua_gettop(L)); + return true; + }; if (!cPluginManager::Get()->DoWithPlugin(PluginName, PluginCallback)) { @@ -1473,7 +1404,8 @@ static int tolua_cPluginManager_CallPlugin(lua_State * tolua_S) } if (NumReturns < 0) { - // The call has failed, there are zero return values. Do NOT return negative number (Lua considers that a "yield") + // The call has failed, there are zero return values. Do NOT return negative number (Lua considers that a + // "yield") return 0; } return NumReturns; @@ -1492,11 +1424,7 @@ static int tolua_cPluginManager_ExecuteConsoleCommand(lua_State * tolua_S) // Check params: cLuaState L(tolua_S); - if ( - !L.CheckParamUserTable(1, "cPluginManager") || - !L.CheckParamString(2) || - !L.CheckParamEnd(3) - ) + if (!L.CheckParamUserTable(1, "cPluginManager") || !L.CheckParamString(2) || !L.CheckParamEnd(3)) { return 0; } @@ -1538,10 +1466,7 @@ static int tolua_cPlayer_GetPermissions(lua_State * tolua_S) // Check the params: cLuaState L(tolua_S); - if ( - !L.CheckParamUserType(1, "cPlayer") || - !L.CheckParamEnd (2) - ) + if (!L.CheckParamUserType(1, "cPlayer") || !L.CheckParamEnd(2)) { return 0; } @@ -1569,10 +1494,7 @@ static int tolua_cPlayer_GetRestrictions(lua_State * tolua_S) // Check the params: cLuaState L(tolua_S); - if ( - !L.CheckParamUserType(1, "cPlayer") || - !L.CheckParamEnd (2) - ) + if (!L.CheckParamUserType(1, "cPlayer") || !L.CheckParamEnd(2)) { return 0; } @@ -1620,12 +1542,8 @@ static int tolua_cPlayer_PlaceBlock(lua_State * tolua_S) { // Check the params: cLuaState L(tolua_S); - if ( - !L.CheckParamSelf("cPlayer") || - !L.CheckParamUserType(2, "Vector3<int>") || - !L.CheckParamNumber(3, 4) || - !L.CheckParamEnd(5) - ) + if (!L.CheckParamSelf("cPlayer") || !L.CheckParamUserType(2, "Vector3<int>") || !L.CheckParamNumber(3, 4) || + !L.CheckParamEnd(5)) { return 0; } @@ -1657,11 +1575,7 @@ static int tolua_cPlayer_PermissionMatches(lua_State * tolua_S) // Check the params: cLuaState L(tolua_S); - if ( - !L.CheckParamUserTable(1, "cPlayer") || - !L.CheckParamString (2, 3) || - !L.CheckParamEnd (4) - ) + if (!L.CheckParamUserTable(1, "cPlayer") || !L.CheckParamString(2, 3) || !L.CheckParamEnd(4)) { return 0; } @@ -1679,10 +1593,7 @@ static int tolua_cPlayer_PermissionMatches(lua_State * tolua_S) -template < - class OBJTYPE, - void (OBJTYPE::*SetCallback)(cLuaState::cCallbackPtr && a_CallbackFn) -> +template <class OBJTYPE, void (OBJTYPE::*SetCallback)(cLuaState::cCallbackPtr && a_CallbackFn)> static int tolua_SetObjectCallback(lua_State * tolua_S) { // Function signature: OBJTYPE:SetWhateverCallback(CallbackFunction) @@ -1708,10 +1619,9 @@ static int tolua_SetObjectCallback(lua_State * tolua_S) // Callback class used for the WebTab: -class cWebTabCallback: - public cWebAdmin::cWebTabCallback +class cWebTabCallback : public cWebAdmin::cWebTabCallback { -public: + public: /** The Lua callback to call to generate the page contents. */ cLuaState::cCallback m_Callback; @@ -1723,7 +1633,8 @@ public: ) override { AString content, contentType; - return m_Callback.Call(const_cast<HTTPRequest *>(&a_Request), a_UrlPath, cLuaState::Return, a_Content, a_ContentType); + return m_Callback + .Call(const_cast<HTTPRequest *>(&a_Request), a_UrlPath, cLuaState::Return, a_Content, a_ContentType); } }; @@ -1747,12 +1658,9 @@ static int tolua_cPluginLua_AddWebTab(lua_State * tolua_S) { return 0; } - if ( - !LuaState.CheckParamString(2) || - !LuaState.CheckParamFunction(3) || + if (!LuaState.CheckParamString(2) || !LuaState.CheckParamFunction(3) || // Optional string as param 4 - !LuaState.CheckParamEnd(5) - ) + !LuaState.CheckParamEnd(5)) { return 0; } @@ -1867,7 +1775,8 @@ static int tolua_md5HexString(lua_State * tolua_S) Output << std::hex << std::setfill('0'); for (size_t i = 0; i < ARRAYCOUNT(md5Output); i++) { - Output << std::setw(2) << static_cast<unsigned short>(md5Output[i]); // Need to cast to a number, otherwise a char is output + Output << std::setw(2) + << static_cast<unsigned short>(md5Output[i]); // Need to cast to a number, otherwise a char is output } lua_pushlstring(tolua_S, Output.str().c_str(), Output.str().size()); return 1; @@ -1913,7 +1822,8 @@ static int tolua_sha1HexString(lua_State * tolua_S) Output << std::hex << std::setfill('0'); for (size_t i = 0; i < ARRAYCOUNT(sha1Output); i++) { - Output << std::setw(2) << static_cast<unsigned short>(sha1Output[i]); // Need to cast to a number, otherwise a char is output + Output << std::setw(2) + << static_cast<unsigned short>(sha1Output[i]); // Need to cast to a number, otherwise a char is output } lua_pushlstring(tolua_S, Output.str().c_str(), Output.str().size()); return 1; @@ -1959,7 +1869,7 @@ static int tolua_get_HTTPRequest_PostParams(lua_State * a_LuaState) -static int tolua_get_HTTPRequest_FormData(lua_State* a_LuaState) +static int tolua_get_HTTPRequest_FormData(lua_State * a_LuaState) { cLuaState L(a_LuaState); HTTPRequest * self; @@ -1977,7 +1887,8 @@ static int tolua_get_HTTPRequest_FormData(lua_State* a_LuaState) { lua_pushstring(a_LuaState, Data.first.c_str()); tolua_pushusertype(a_LuaState, &Data.second, "HTTPFormData"); - // lua_pushlstring(a_LuaState, Data.second.Value.c_str(), Data.second.Value.size()); // Might contain binary data + // lua_pushlstring(a_LuaState, Data.second.Value.c_str(), Data.second.Value.size()); // Might contain binary + // data lua_settable(a_LuaState, top); } @@ -1995,11 +1906,7 @@ static int tolua_cUrlParser_GetDefaultPort(lua_State * a_LuaState) // Check params: cLuaState L(a_LuaState); - if ( - !L.CheckParamUserTable(1, "cUrlParser") || - !L.CheckParamString(2) || - !L.CheckParamEnd(3) - ) + if (!L.CheckParamUserTable(1, "cUrlParser") || !L.CheckParamString(2) || !L.CheckParamEnd(3)) { return 0; } @@ -2024,11 +1931,7 @@ static int tolua_cUrlParser_IsKnownScheme(lua_State * a_LuaState) // Check params: cLuaState L(a_LuaState); - if ( - !L.CheckParamUserTable(1, "cUrlParser") || - !L.CheckParamString(2) || - !L.CheckParamEnd(3) - ) + if (!L.CheckParamUserTable(1, "cUrlParser") || !L.CheckParamString(2) || !L.CheckParamEnd(3)) { return 0; } @@ -2054,11 +1957,7 @@ static int tolua_cUrlParser_Parse(lua_State * a_LuaState) // Check params: cLuaState L(a_LuaState); - if ( - !L.CheckParamUserTable(1, "cUrlParser") || - !L.CheckParamString(2) || - !L.CheckParamEnd(3) - ) + if (!L.CheckParamUserTable(1, "cUrlParser") || !L.CheckParamString(2) || !L.CheckParamEnd(3)) { return 0; } @@ -2094,11 +1993,7 @@ static int tolua_cUrlParser_ParseAuthorityPart(lua_State * a_LuaState) // Check params: cLuaState L(a_LuaState); - if ( - !L.CheckParamUserTable(1, "cUrlParser") || - !L.CheckParamString(2) || - !L.CheckParamEnd(3) - ) + if (!L.CheckParamUserTable(1, "cUrlParser") || !L.CheckParamString(2) || !L.CheckParamEnd(3)) { return 0; } @@ -2237,7 +2132,7 @@ static int tolua_cWebAdmin_GetAllWebTabs(lua_State * tolua_S) int newTable = lua_gettop(tolua_S); int index = 1; cLuaState L(tolua_S); - for (const auto & wt: webTabs) + for (const auto & wt : webTabs) { lua_createtable(tolua_S, 0, 3); L.Push(wt->m_PluginName); @@ -2331,11 +2226,7 @@ static int tolua_cWebAdmin_GetURLEncodedString(lua_State * tolua_S) static int tolua_cClientHandle_SendPluginMessage(lua_State * L) { cLuaState S(L); - if ( - !S.CheckParamSelf("cClientHandle") || - !S.CheckParamString(2, 3) || - !S.CheckParamEnd(4) - ) + if (!S.CheckParamSelf("cClientHandle") || !S.CheckParamString(2, 3) || !S.CheckParamEnd(4)) { return 0; } @@ -2360,12 +2251,7 @@ static int tolua_cClientHandle_SendPluginMessage(lua_State * L) static int tolua_cClientHandle_SendTimeUpdate(lua_State * L) { cLuaState S(L); - if ( - !S.CheckParamSelf("cClientHandle") || - !S.CheckParamNumber(2, 3) || - !S.CheckParamBool(4) || - !S.CheckParamEnd(5) - ) + if (!S.CheckParamSelf("cClientHandle") || !S.CheckParamNumber(2, 3) || !S.CheckParamBool(4) || !S.CheckParamEnd(5)) { return 0; } @@ -2390,10 +2276,7 @@ static int tolua_cClientHandle_SendTimeUpdate(lua_State * L) static int tolua_cClientHandle_GetForgeMods(lua_State * L) { cLuaState S(L); - if ( - !S.CheckParamSelf("cClientHandle") || - !S.CheckParamEnd(2) - ) + if (!S.CheckParamSelf("cClientHandle") || !S.CheckParamEnd(2)) { return 0; } @@ -2412,10 +2295,7 @@ static int tolua_cClientHandle_GetUUID(lua_State * tolua_S) { // Check the params: cLuaState L(tolua_S); - if ( - !L.CheckParamSelf("cClientHandle") || - !L.CheckParamEnd(2) - ) + if (!L.CheckParamSelf("cClientHandle") || !L.CheckParamEnd(2)) { return 0; } @@ -2437,11 +2317,7 @@ static int tolua_cClientHandle_GenerateOfflineUUID(lua_State * tolua_S) { // Check the params: cLuaState L(tolua_S); - if ( - !L.CheckParamStaticSelf("cClientHandle") || - !L.CheckParamString(2) || - !L.CheckParamEnd(3) - ) + if (!L.CheckParamStaticSelf("cClientHandle") || !L.CheckParamString(2) || !L.CheckParamEnd(3)) { return 0; } @@ -2463,11 +2339,7 @@ static int tolua_cClientHandle_IsUUIDOnline(lua_State * tolua_S) { // Check the params: cLuaState L(tolua_S); - if ( - !L.CheckParamStaticSelf("cClientHandle") || - !L.CheckParamUUID(2) || - !L.CheckParamEnd(3) - ) + if (!L.CheckParamStaticSelf("cClientHandle") || !L.CheckParamUUID(2) || !L.CheckParamEnd(3)) { return 0; } @@ -2489,12 +2361,7 @@ static int tolua_cMobHeadEntity_SetOwner(lua_State * tolua_S) { // Check params: cLuaState L(tolua_S); - if ( - !L.CheckParamSelf("cMobHeadEntity") || - !L.CheckParamUUID(2) || - !L.CheckParamString(3, 5) || - !L.CheckParamEnd(6) - ) + if (!L.CheckParamSelf("cMobHeadEntity") || !L.CheckParamUUID(2) || !L.CheckParamString(3, 5) || !L.CheckParamEnd(6)) { return 0; } @@ -2519,10 +2386,7 @@ static int tolua_cMobHeadEntity_GetOwnerUUID(lua_State * tolua_S) { // Check params: cLuaState L(tolua_S); - if ( - !L.CheckParamSelf("cMobHeadEntity") || - !L.CheckParamEnd(2) - ) + if (!L.CheckParamSelf("cMobHeadEntity") || !L.CheckParamEnd(2)) { return 0; } @@ -2533,7 +2397,7 @@ static int tolua_cMobHeadEntity_GetOwnerUUID(lua_State * tolua_S) // Return the UUID as a string: cUUID Owner = Self->GetOwnerUUID(); - L.Push(Owner.IsNil() ? AString{} : Owner.ToShortString()); + L.Push(Owner.IsNil() ? AString {} : Owner.ToShortString()); return 1; } @@ -2544,12 +2408,7 @@ static int tolua_cMobHeadEntity_GetOwnerUUID(lua_State * tolua_S) static int tolua_cMojangAPI_AddPlayerNameToUUIDMapping(lua_State * L) { cLuaState S(L); - if ( - !S.CheckParamStaticSelf("cMojangAPI") || - !S.CheckParamString(2) || - !S.CheckParamUUID(3) || - !S.CheckParamEnd(4) - ) + if (!S.CheckParamStaticSelf("cMojangAPI") || !S.CheckParamString(2) || !S.CheckParamUUID(3) || !S.CheckParamEnd(4)) { return 0; } @@ -2571,11 +2430,7 @@ static int tolua_cMojangAPI_AddPlayerNameToUUIDMapping(lua_State * L) static int tolua_cMojangAPI_GetPlayerNameFromUUID(lua_State * L) { cLuaState S(L); - if ( - !S.CheckParamStaticSelf("cMojangAPI") || - !S.CheckParamUUID(2) || - !S.CheckParamEnd(4) - ) + if (!S.CheckParamStaticSelf("cMojangAPI") || !S.CheckParamUUID(2) || !S.CheckParamEnd(4)) { return 0; } @@ -2604,11 +2459,7 @@ static int tolua_cMojangAPI_GetPlayerNameFromUUID(lua_State * L) static int tolua_cMojangAPI_GetUUIDFromPlayerName(lua_State * L) { cLuaState S(L); - if ( - !S.CheckParamStaticSelf("cMojangAPI") || - !S.CheckParamString(2) || - !S.CheckParamEnd(4) - ) + if (!S.CheckParamStaticSelf("cMojangAPI") || !S.CheckParamString(2) || !S.CheckParamEnd(4)) { return 0; } @@ -2626,7 +2477,7 @@ static int tolua_cMojangAPI_GetUUIDFromPlayerName(lua_State * L) // Return the UUID as a string: cUUID UUID = cRoot::Get()->GetMojangAPI().GetUUIDFromPlayerName(PlayerName, ShouldUseCacheOnly); - S.Push(UUID.IsNil() ? AString{} : UUID.ToShortString()); + S.Push(UUID.IsNil() ? AString {} : UUID.ToShortString()); return 1; } @@ -2637,11 +2488,7 @@ static int tolua_cMojangAPI_GetUUIDFromPlayerName(lua_State * L) static int tolua_cMojangAPI_GetUUIDsFromPlayerNames(lua_State * L) { cLuaState S(L); - if ( - !S.CheckParamStaticSelf("cMojangAPI") || - !S.CheckParamTable(2) || - !S.CheckParamEnd(4) - ) + if (!S.CheckParamStaticSelf("cMojangAPI") || !S.CheckParamTable(2) || !S.CheckParamEnd(4)) { return 0; } @@ -2706,11 +2553,7 @@ static int tolua_cMojangAPI_MakeUUIDDashed(lua_State * L) // Check params: cLuaState S(L); - if ( - !S.CheckParamStaticSelf("cMojangAPI") || - !S.CheckParamUUID(2) || - !S.CheckParamEnd(3) - ) + if (!S.CheckParamStaticSelf("cMojangAPI") || !S.CheckParamUUID(2) || !S.CheckParamEnd(3)) { return 0; } @@ -2734,11 +2577,7 @@ static int tolua_cMojangAPI_MakeUUIDShort(lua_State * L) // Check params: cLuaState S(L); - if ( - !S.CheckParamUserTable(1, "cMojangAPI") || - !S.CheckParamUUID(2) || - !S.CheckParamEnd(3) - ) + if (!S.CheckParamUserTable(1, "cMojangAPI") || !S.CheckParamUUID(2) || !S.CheckParamEnd(3)) { return 0; } @@ -2782,10 +2621,7 @@ static int tolua_cItem_EnchantByXPLevels(lua_State * tolua_S) { // Check params: cLuaState L(tolua_S); - if ( - !L.CheckParamSelf("cItem") || - !L.CheckParamNumber(2) - ) + if (!L.CheckParamSelf("cItem") || !L.CheckParamNumber(2)) { return 0; } @@ -2809,10 +2645,7 @@ static int tolua_set_cItem_m_LoreTable(lua_State * tolua_S) { // Check params: cLuaState L(tolua_S); - if ( - !L.CheckParamSelf("cItem") || - !L.CheckParamTable(2) - ) + if (!L.CheckParamSelf("cItem") || !L.CheckParamTable(2)) { return 0; } @@ -2837,11 +2670,8 @@ static int tolua_set_cItem_m_LoreTable(lua_State * tolua_S) static int Lua_ItemGrid_GetSlotCoords(lua_State * L) { tolua_Error tolua_err; - if ( - !tolua_isusertype(L, 1, "const cItemGrid", 0, &tolua_err) || - !tolua_isnumber (L, 2, 0, &tolua_err) || - !tolua_isnoobj (L, 3, &tolua_err) - ) + if (!tolua_isusertype(L, 1, "const cItemGrid", 0, &tolua_err) || !tolua_isnumber(L, 2, 0, &tolua_err) || + !tolua_isnoobj(L, 3, &tolua_err)) { goto tolua_lerror; } @@ -2871,26 +2701,20 @@ tolua_lerror: /** Provides interface between a Lua table of callbacks and the cBlockTracer::cCallbacks */ -class cLuaBlockTracerCallbacks : - public cBlockTracer::cCallbacks +class cLuaBlockTracerCallbacks : public cBlockTracer::cCallbacks { -public: - cLuaBlockTracerCallbacks(cLuaState::cTableRefPtr && a_Callbacks): + public: + cLuaBlockTracerCallbacks(cLuaState::cTableRefPtr && a_Callbacks) : m_Callbacks(std::move(a_Callbacks)) { } - virtual bool OnNextBlock(Vector3i a_BlockPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, eBlockFace a_EntryFace) override + virtual bool OnNextBlock(Vector3i a_BlockPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, eBlockFace a_EntryFace) + override { bool res = false; - if (m_Callbacks->CallTableFn( - "OnNextBlock", - a_BlockPos, - a_BlockType, - a_BlockMeta, - a_EntryFace, - cLuaState::Return, res) - ) + if (m_Callbacks + ->CallTableFn("OnNextBlock", a_BlockPos, a_BlockType, a_BlockMeta, a_EntryFace, cLuaState::Return, res)) { return res; } @@ -2901,12 +2725,7 @@ public: virtual bool OnNextBlockNoData(Vector3i a_BlockPos, eBlockFace a_EntryFace) override { bool res = false; - if (m_Callbacks->CallTableFn( - "OnNextBlockNoData", - a_BlockPos, - a_EntryFace, - cLuaState::Return, res) - ) + if (m_Callbacks->CallTableFn("OnNextBlockNoData", a_BlockPos, a_EntryFace, cLuaState::Return, res)) { return res; } @@ -2917,11 +2736,7 @@ public: virtual bool OnOutOfWorld(Vector3d a_BlockPos) override { bool res = false; - if (m_Callbacks->CallTableFn( - "OnOutOfWorld", - a_BlockPos, - cLuaState::Return, res) - ) + if (m_Callbacks->CallTableFn("OnOutOfWorld", a_BlockPos, cLuaState::Return, res)) { return res; } @@ -2932,10 +2747,7 @@ public: virtual bool OnIntoWorld(Vector3d a_BlockPos) override { bool res = false; - if (m_Callbacks->CallTableFn("OnIntoWorld", - a_BlockPos, - cLuaState::Return, res) - ) + if (m_Callbacks->CallTableFn("OnIntoWorld", a_BlockPos, cLuaState::Return, res)) { return res; } @@ -2943,17 +2755,11 @@ public: return false; } - virtual void OnNoMoreHits(void) override - { - m_Callbacks->CallTableFn("OnNoMoreHits"); - } + virtual void OnNoMoreHits(void) override { m_Callbacks->CallTableFn("OnNoMoreHits"); } - virtual void OnNoChunk(void) override - { - m_Callbacks->CallTableFn("OnNoChunk"); - } + virtual void OnNoChunk(void) override { m_Callbacks->CallTableFn("OnNoChunk"); } -protected: + protected: cLuaState::cTableRefPtr m_Callbacks; }; @@ -2964,26 +2770,29 @@ protected: /** Provides interface between a Lua table of callbacks and the cBlockTracer::cCallbacks This is the deprecated version of cLuaBlockTracerCallback, used when the plugin calls the Trace function with number-based coords. */ -class cLuaBlockTracerCallbacksOld : - public cLuaBlockTracerCallbacks +class cLuaBlockTracerCallbacksOld : public cLuaBlockTracerCallbacks { -public: - cLuaBlockTracerCallbacksOld(cLuaState::cTableRefPtr && a_Callbacks): + public: + cLuaBlockTracerCallbacksOld(cLuaState::cTableRefPtr && a_Callbacks) : cLuaBlockTracerCallbacks(std::move(a_Callbacks)) { } - virtual bool OnNextBlock(Vector3i a_BlockPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, eBlockFace a_EntryFace) override + virtual bool OnNextBlock(Vector3i a_BlockPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, eBlockFace a_EntryFace) + override { bool res = false; if (m_Callbacks->CallTableFn( - "OnNextBlock", - a_BlockPos.x, a_BlockPos.y, a_BlockPos.z, - a_BlockType, - a_BlockMeta, - a_EntryFace, - cLuaState::Return, res) - ) + "OnNextBlock", + a_BlockPos.x, + a_BlockPos.y, + a_BlockPos.z, + a_BlockType, + a_BlockMeta, + a_EntryFace, + cLuaState::Return, + res + )) { return res; } @@ -2995,11 +2804,14 @@ public: { bool res = false; if (m_Callbacks->CallTableFn( - "OnNextBlockNoData", - a_BlockPos.x, a_BlockPos.y, a_BlockPos.z, - a_EntryFace, - cLuaState::Return, res) - ) + "OnNextBlockNoData", + a_BlockPos.x, + a_BlockPos.y, + a_BlockPos.z, + a_EntryFace, + cLuaState::Return, + res + )) { return res; } @@ -3010,11 +2822,7 @@ public: virtual bool OnOutOfWorld(Vector3d a_BlockPos) override { bool res = false; - if (m_Callbacks->CallTableFn( - "OnOutOfWorld", - a_BlockPos.x, a_BlockPos.y, a_BlockPos.z, - cLuaState::Return, res) - ) + if (m_Callbacks->CallTableFn("OnOutOfWorld", a_BlockPos.x, a_BlockPos.y, a_BlockPos.z, cLuaState::Return, res)) { return res; } @@ -3025,11 +2833,7 @@ public: virtual bool OnIntoWorld(Vector3d a_BlockPos) override { bool res = false; - if (m_Callbacks->CallTableFn( - "OnIntoWorld", - a_BlockPos.x, a_BlockPos.y, a_BlockPos.z, - cLuaState::Return, res) - ) + if (m_Callbacks->CallTableFn("OnIntoWorld", a_BlockPos.x, a_BlockPos.y, a_BlockPos.z, cLuaState::Return, res)) { return res; } @@ -3045,10 +2849,11 @@ public: static int tolua_cLineBlockTracer_FirstSolidHitTrace(lua_State * tolua_S) { /* Supported function signatures: - cLineBlockTracer:FirstSolidHitTrace(World, StartX, StartY, StartZ, EndX, EndY, EndZ) -> bool, [Vector3d, Vector3i, eBlockFace] // Canonical - cLineBlockTracer:FirstSolidHitTrace(World, Start, End) -> bool, [Vector3d, Vector3i, eBlockFace] // Canonical - cLineBlockTracer.FirstSolidHitTrace(World, StartX, StartY, StartZ, EndX, EndY, EndZ) -> bool, [Vector3d, Vector3i, eBlockFace] - cLineBlockTracer.FirstSolidHitTrace(World, Start, End) -> bool, [Vector3d, Vector3i, eBlockFace] + cLineBlockTracer:FirstSolidHitTrace(World, StartX, StartY, StartZ, EndX, EndY, EndZ) -> bool, [Vector3d, Vector3i, + eBlockFace] // Canonical cLineBlockTracer:FirstSolidHitTrace(World, Start, End) -> bool, [Vector3d, Vector3i, + eBlockFace] // Canonical cLineBlockTracer.FirstSolidHitTrace(World, StartX, StartY, + StartZ, EndX, EndY, EndZ) -> bool, [Vector3d, Vector3i, eBlockFace] cLineBlockTracer.FirstSolidHitTrace(World, + Start, End) -> bool, [Vector3d, Vector3i, eBlockFace] */ // If the first param is the cLineBlockTracer class, shift param index by one: @@ -3061,9 +2866,7 @@ static int tolua_cLineBlockTracer_FirstSolidHitTrace(lua_State * tolua_S) // Check params: cLuaState L(tolua_S); - if ( - !L.CheckParamUserType(idx, "cWorld") - ) + if (!L.CheckParamUserType(idx, "cWorld")) { return 0; } @@ -3071,10 +2874,7 @@ static int tolua_cLineBlockTracer_FirstSolidHitTrace(lua_State * tolua_S) if (L.IsParamNumber(idx + 1)) { // This is the number variant of the call: - if ( - !L.CheckParamNumber(idx + 1, idx + 6) || - !L.CheckParamEnd(idx + 7) - ) + if (!L.CheckParamNumber(idx + 1, idx + 6) || !L.CheckParamEnd(idx + 7)) { return 0; } @@ -3092,7 +2892,14 @@ static int tolua_cLineBlockTracer_FirstSolidHitTrace(lua_State * tolua_S) Vector3d hitCoords; Vector3i hitBlockCoords; eBlockFace hitBlockFace; - auto isHit = cLineBlockTracer::FirstSolidHitTrace(*world, Vector3d(startX, startY, startZ), Vector3d(endX, endY, endZ), hitCoords, hitBlockCoords, hitBlockFace); + auto isHit = cLineBlockTracer::FirstSolidHitTrace( + *world, + Vector3d(startX, startY, startZ), + Vector3d(endX, endY, endZ), + hitCoords, + hitBlockCoords, + hitBlockFace + ); L.Push(isHit); if (!isHit) { @@ -3107,10 +2914,7 @@ static int tolua_cLineBlockTracer_FirstSolidHitTrace(lua_State * tolua_S) if (L.IsParamVector3(idx + 1)) { // This is the Vector3-based variant of the call: - if ( - !L.CheckParamVector3(idx + 1, idx + 2) || - !L.CheckParamEnd(idx + 3) - ) + if (!L.CheckParamVector3(idx + 1, idx + 2) || !L.CheckParamEnd(idx + 3)) { return 0; } @@ -3140,7 +2944,11 @@ static int tolua_cLineBlockTracer_FirstSolidHitTrace(lua_State * tolua_S) return 4; } - tolua_error(L, "cLineBlockTracer:FirstSolidHitTrace(): Invalid parameters, expected either a set of coords, or two Vector3's", nullptr); + tolua_error( + L, + "cLineBlockTracer:FirstSolidHitTrace(): Invalid parameters, expected either a set of coords, or two Vector3's", + nullptr + ); return 0; } @@ -3167,9 +2975,7 @@ static int tolua_cLineBlockTracer_LineOfSightTrace(lua_State * tolua_S) // Check params: cLuaState L(tolua_S); - if ( - !L.CheckParamUserType(idx, "cWorld") - ) + if (!L.CheckParamUserType(idx, "cWorld")) { return 0; } @@ -3177,11 +2983,9 @@ static int tolua_cLineBlockTracer_LineOfSightTrace(lua_State * tolua_S) if (L.IsParamNumber(idx + 1)) { // This is the number variant of the call: - if ( - !L.CheckParamNumber(idx + 1, idx + 6) || + if (!L.CheckParamNumber(idx + 1, idx + 6) || // Optional param lineOfSight is not checked - !L.CheckParamEnd(idx + 8) - ) + !L.CheckParamEnd(idx + 8)) { return 0; } @@ -3198,18 +3002,21 @@ static int tolua_cLineBlockTracer_LineOfSightTrace(lua_State * tolua_S) } int lineOfSight = cLineBlockTracer::losAir | cLineBlockTracer::losWater; L.GetStackValue(idx + 7, lineOfSight); - L.Push(cLineBlockTracer::LineOfSightTrace(*world, Vector3d(startX, startY, startZ), Vector3d(endX, endY, endZ), lineOfSight)); + L.Push(cLineBlockTracer::LineOfSightTrace( + *world, + Vector3d(startX, startY, startZ), + Vector3d(endX, endY, endZ), + lineOfSight + )); return 1; } if (L.IsParamVector3(idx + 1)) { // This is the Vector3-based variant of the call: - if ( - !L.CheckParamVector3(idx + 1, idx + 2) || + if (!L.CheckParamVector3(idx + 1, idx + 2) || // Optional param lineOfSight is not checked - !L.CheckParamEnd(idx + 4) - ) + !L.CheckParamEnd(idx + 4)) { return 0; } @@ -3230,7 +3037,11 @@ static int tolua_cLineBlockTracer_LineOfSightTrace(lua_State * tolua_S) return 1; } - tolua_error(L, "cLineBlockTracer:LineOfSightTrace(): Invalid parameters, expected either a set of coords, or two Vector3's", nullptr); + tolua_error( + L, + "cLineBlockTracer:LineOfSightTrace(): Invalid parameters, expected either a set of coords, or two Vector3's", + nullptr + ); return 0; } @@ -3257,10 +3068,7 @@ static int tolua_cLineBlockTracer_Trace(lua_State * tolua_S) // Check params: cLuaState L(tolua_S); - if ( - !L.CheckParamUserType(idx, "cWorld") || - !L.CheckParamTable (idx + 1) - ) + if (!L.CheckParamUserType(idx, "cWorld") || !L.CheckParamTable(idx + 1)) { return 0; } @@ -3270,19 +3078,15 @@ static int tolua_cLineBlockTracer_Trace(lua_State * tolua_S) Vector3d start; Vector3d end; cLuaState::cTableRefPtr callbacks; - if ( - L.IsParamNumber (idx + 2) && - L.IsParamNumber (idx + 3) && - L.IsParamNumber (idx + 4) && - L.IsParamNumber (idx + 5) && - L.IsParamNumber (idx + 6) && - L.IsParamNumber (idx + 7) && - L.CheckParamEnd (idx + 8) - ) + if (L.IsParamNumber(idx + 2) && L.IsParamNumber(idx + 3) && L.IsParamNumber(idx + 4) && L.IsParamNumber(idx + 5) && + L.IsParamNumber(idx + 6) && L.IsParamNumber(idx + 7) && L.CheckParamEnd(idx + 8)) { if (!L.GetStackValues(idx, world, callbacks, start.x, start.y, start.z, end.x, end.y, end.z)) { - LOGWARNING("cLineBlockTracer:Trace(): Cannot read parameters (starting at idx %d), aborting the trace.", idx); + LOGWARNING( + "cLineBlockTracer:Trace(): Cannot read parameters (starting at idx %d), aborting the trace.", + idx + ); L.LogStackTrace(); L.LogStackValues("Values on the stack"); return 0; @@ -3295,15 +3099,14 @@ static int tolua_cLineBlockTracer_Trace(lua_State * tolua_S) tolua_pushboolean(L, res ? 1 : 0); return 1; } - else if ( - L.IsParamVector3(idx + 2) && - L.IsParamVector3(idx + 3) && - L.CheckParamEnd (idx + 4) - ) + else if (L.IsParamVector3(idx + 2) && L.IsParamVector3(idx + 3) && L.CheckParamEnd(idx + 4)) { if (!L.GetStackValues(idx, world, callbacks, start, end)) { - LOGWARNING("cLineBlockTracer:Trace(): Cannot read parameters (starting at idx %d), aborting the trace.", idx); + LOGWARNING( + "cLineBlockTracer:Trace(): Cannot read parameters (starting at idx %d), aborting the trace.", + idx + ); L.LogStackTrace(); L.LogStackValues("Values on the stack"); return 0; @@ -3328,12 +3131,8 @@ static int tolua_cLuaWindow_new(lua_State * tolua_S) // Check params: cLuaState L(tolua_S); - if ( - !L.CheckParamUserTable(1, "cLuaWindow") || - !L.CheckParamNumber(2, 4) || - !L.CheckParamString(5) || - !L.CheckParamEnd(6) - ) + if (!L.CheckParamUserTable(1, "cLuaWindow") || !L.CheckParamNumber(2, 4) || !L.CheckParamString(5) || + !L.CheckParamEnd(6)) { return 0; } @@ -3364,12 +3163,8 @@ static int tolua_cLuaWindow_new_local(lua_State * tolua_S) // Check params: cLuaState L(tolua_S); - if ( - !L.CheckParamUserTable(1, "cLuaWindow") || - !L.CheckParamNumber(2, 4) || - !L.CheckParamString(5) || - !L.CheckParamEnd(6) - ) + if (!L.CheckParamUserTable(1, "cLuaWindow") || !L.CheckParamNumber(2, 4) || !L.CheckParamString(5) || + !L.CheckParamEnd(6)) { return 0; } @@ -3398,12 +3193,7 @@ static int tolua_cRoot_DoWithPlayerByUUID(lua_State * tolua_S) { // Check params: cLuaState L(tolua_S); - if ( - !L.CheckParamSelf("cRoot") || - !L.CheckParamUUID(2) || - !L.CheckParamFunction(3) || - !L.CheckParamEnd(4) - ) + if (!L.CheckParamSelf("cRoot") || !L.CheckParamUUID(2) || !L.CheckParamFunction(3) || !L.CheckParamEnd(4)) { return 0; } @@ -3424,7 +3214,9 @@ static int tolua_cRoot_DoWithPlayerByUUID(lua_State * tolua_S) } // Call the function: - bool res = Self->DoWithPlayerByUUID(PlayerUUID, [&](cPlayer & a_Player) + bool res = Self->DoWithPlayerByUUID( + PlayerUUID, + [&](cPlayer & a_Player) { bool ret = false; L.Call(FnRef, &a_Player, cLuaState::Return, ret); @@ -3488,12 +3280,8 @@ static int tolua_cRoot_GetBuildSeriesName(lua_State * tolua_S) static int tolua_cRoot_GetBrewingRecipe(lua_State * tolua_S) { cLuaState L(tolua_S); - if ( - !L.CheckParamUserTable(1, "cRoot") || - !L.CheckParamUserType (2, "const cItem") || - !L.CheckParamUserType (3, "const cItem") || - !L.CheckParamEnd (4) - ) + if (!L.CheckParamUserTable(1, "cRoot") || !L.CheckParamUserType(2, "const cItem") || + !L.CheckParamUserType(3, "const cItem") || !L.CheckParamEnd(4)) { return 0; } @@ -3537,11 +3325,7 @@ static int tolua_cRoot_GetBrewingRecipe(lua_State * tolua_S) static int tolua_cRoot_GetFurnaceRecipe(lua_State * tolua_S) { cLuaState L(tolua_S); - if ( - !L.CheckParamUserTable(1, "cRoot") || - !L.CheckParamUserType (2, "const cItem") || - !L.CheckParamEnd (3) - ) + if (!L.CheckParamUserTable(1, "cRoot") || !L.CheckParamUserType(2, "const cItem") || !L.CheckParamEnd(3)) { return 0; } @@ -3576,12 +3360,7 @@ static int tolua_cRoot_GetFurnaceRecipe(lua_State * tolua_S) static int tolua_cServer_RegisterForgeMod(lua_State * a_LuaState) { cLuaState L(a_LuaState); - if ( - !L.CheckParamSelf("cServer") || - !L.CheckParamString(2, 3) || - !L.CheckParamNumber(4) || - !L.CheckParamEnd(5) - ) + if (!L.CheckParamSelf("cServer") || !L.CheckParamString(2, 3) || !L.CheckParamNumber(4) || !L.CheckParamEnd(5)) { return 0; } @@ -3611,11 +3390,7 @@ static int tolua_cServer_ScheduleTask(lua_State * a_LuaState) // Retrieve the args: cLuaState L(a_LuaState); - if ( - !L.CheckParamUserType(1, "cServer") || - !L.CheckParamNumber(2) || - !L.CheckParamFunction(3) - ) + if (!L.CheckParamUserType(1, "cServer") || !L.CheckParamNumber(2) || !L.CheckParamFunction(3)) { return 0; } @@ -3628,17 +3403,20 @@ static int tolua_cServer_ScheduleTask(lua_State * a_LuaState) } if (Server == nullptr) { - return cManualBindings::lua_do_error(a_LuaState, "Error in function call '#funcname#': Not called on an object instance"); + return cManualBindings::lua_do_error( + a_LuaState, + "Error in function call '#funcname#': Not called on an object instance" + ); } if (!Task->IsValid()) { - return cManualBindings::lua_do_error(a_LuaState, "Error in function call '#funcname#': Could not store the callback parameter"); + return cManualBindings::lua_do_error( + a_LuaState, + "Error in function call '#funcname#': Could not store the callback parameter" + ); } - Server->ScheduleTask(cTickTime(NumTicks), [Task](cServer & a_Server) - { - Task->Call(&a_Server); - }); + Server->ScheduleTask(cTickTime(NumTicks), [Task](cServer & a_Server) { Task->Call(&a_Server); }); return 0; } @@ -3649,10 +3427,7 @@ static int tolua_cServer_ScheduleTask(lua_State * a_LuaState) static int tolua_cScoreboard_GetTeamNames(lua_State * L) { cLuaState S(L); - if ( - !S.CheckParamUserType(1, "cScoreboard") || - !S.CheckParamEnd(2) - ) + if (!S.CheckParamUserType(1, "cScoreboard") || !S.CheckParamEnd(2)) { return 0; } @@ -3676,11 +3451,7 @@ static int tolua_cHopperEntity_GetOutputBlockPos(lua_State * tolua_S) // Exported manually because tolua would require meaningless params cLuaState L(tolua_S); - if ( - !L.CheckParamUserType(1, "cHopperEntity") || - !L.CheckParamNumber (2) || - !L.CheckParamEnd (3) - ) + if (!L.CheckParamUserType(1, "cHopperEntity") || !L.CheckParamNumber(2) || !L.CheckParamEnd(3)) { return 0; } @@ -3732,7 +3503,12 @@ static int tolua_cBoundingBox_CalcLineIntersection(lua_State * a_LuaState) if (!L.GetStackValues(1, bbox, pt1, pt2)) // Try the regular signature { L.LogStackValues(); - tolua_error(a_LuaState, "Invalid function params. Expected either bbox:CalcLineIntersection(pt1, pt2) or cBoundingBox:CalcLineIntersection(min, max, pt1, pt2).", nullptr); + tolua_error( + a_LuaState, + "Invalid function params. Expected either bbox:CalcLineIntersection(pt1, pt2) or " + "cBoundingBox:CalcLineIntersection(min, max, pt1, pt2).", + nullptr + ); return 0; } res = bbox->CalcLineIntersection(pt1, pt2, lineCoeff, blockFace); @@ -3793,7 +3569,11 @@ static int tolua_cChunkDesc_GetBlockTypeMeta(lua_State * a_LuaState) if (!L.GetStackValues(1, self, relX, relY, relZ)) { L.LogStackValues(); - tolua_error(a_LuaState, "Invalid function params. Expected chunkDesc:GetBlockTypeMeta(relX, relY, relZ)", nullptr); + tolua_error( + a_LuaState, + "Invalid function params. Expected chunkDesc:GetBlockTypeMeta(relX, relY, relZ)", + nullptr + ); return 0; } BLOCKTYPE blockType; @@ -3855,7 +3635,11 @@ static int tolua_cCompositeChat_new(lua_State * a_LuaState) if (!L.GetStackValue(3, messageTypeInt)) { tolua_Error err; - tolua_error(a_LuaState, "Invalid type of the MessageType parameter (2) in cCompositeChat constructor.", &err); + tolua_error( + a_LuaState, + "Invalid type of the MessageType parameter (2) in cCompositeChat constructor.", + &err + ); return 0; } if ((messageTypeInt < 0) || (messageTypeInt >= mtMaxPlusOne)) @@ -3865,7 +3649,8 @@ static int tolua_cCompositeChat_new(lua_State * a_LuaState) return 0; } } - L.Push(static_cast<cCompositeChat *>(Mtolua_new(cCompositeChat(parseText, static_cast<eMessageType>(messageTypeInt))))); + L.Push(static_cast<cCompositeChat *>(Mtolua_new(cCompositeChat(parseText, static_cast<eMessageType>(messageTypeInt)) + ))); return 1; } @@ -3895,10 +3680,7 @@ static int tolua_cCompositeChat_AddShowAchievementPart(lua_State * tolua_S) // Check params: cLuaState L(tolua_S); - if ( - !L.CheckParamUserType(1, "cCompositeChat") || - !L.CheckParamString(2, 3) - ) + if (!L.CheckParamUserType(1, "cCompositeChat") || !L.CheckParamString(2, 3)) { return 0; } @@ -3906,7 +3688,11 @@ static int tolua_cCompositeChat_AddShowAchievementPart(lua_State * tolua_S) cCompositeChat * self = static_cast<cCompositeChat *>(tolua_tousertype(tolua_S, 1, nullptr)); if (self == nullptr) { - tolua_error(tolua_S, "invalid 'self' in function call cCompositeChat::AddShowAchievementPart(string, string, string) const.", nullptr); + tolua_error( + tolua_S, + "invalid 'self' in function call cCompositeChat::AddShowAchievementPart(string, string, string) const.", + nullptr + ); return 0; } @@ -3933,10 +3719,7 @@ static int tolua_cCompositeChat_AddRunCommandPart(lua_State * tolua_S) // Check params: cLuaState L(tolua_S); - if ( - !L.CheckParamUserType(1, "cCompositeChat") || - !L.CheckParamString(2, 3) - ) + if (!L.CheckParamUserType(1, "cCompositeChat") || !L.CheckParamString(2, 3)) { return 0; } @@ -3970,10 +3753,7 @@ static int tolua_cCompositeChat_AddSuggestCommandPart(lua_State * tolua_S) // Check params: cLuaState L(tolua_S); - if ( - !L.CheckParamUserType(1, "cCompositeChat") || - !L.CheckParamString(2, 3) - ) + if (!L.CheckParamUserType(1, "cCompositeChat") || !L.CheckParamString(2, 3)) { return 0; } @@ -4007,10 +3787,7 @@ static int tolua_cCompositeChat_AddTextPart(lua_State * tolua_S) // Check params: cLuaState L(tolua_S); - if ( - !L.CheckParamUserType(1, "cCompositeChat") || - !L.CheckParamString(2) - ) + if (!L.CheckParamUserType(1, "cCompositeChat") || !L.CheckParamString(2)) { return 0; } @@ -4043,10 +3820,7 @@ static int tolua_cCompositeChat_AddUrlPart(lua_State * tolua_S) // Check params: cLuaState L(tolua_S); - if ( - !L.CheckParamUserType(1, "cCompositeChat") || - !L.CheckParamString(2, 3) - ) + if (!L.CheckParamUserType(1, "cCompositeChat") || !L.CheckParamString(2, 3)) { return 0; } @@ -4080,10 +3854,7 @@ static int tolua_cCompositeChat_Clear(lua_State * tolua_S) // Check params: cLuaState L(tolua_S); - if ( - !L.CheckParamUserType(1, "cCompositeChat") || - !L.CheckParamEnd(2) - ) + if (!L.CheckParamUserType(1, "cCompositeChat") || !L.CheckParamEnd(2)) { return 0; } @@ -4113,10 +3884,7 @@ static int tolua_cCompositeChat_ParseText(lua_State * tolua_S) // Check params: cLuaState L(tolua_S); - if ( - !L.CheckParamUserType(1, "cCompositeChat") || - !L.CheckParamString(2) - ) + if (!L.CheckParamUserType(1, "cCompositeChat") || !L.CheckParamString(2)) { return 0; } @@ -4148,10 +3916,7 @@ static int tolua_cCompositeChat_SetMessageType(lua_State * tolua_S) // Check params: cLuaState L(tolua_S); - if ( - !L.CheckParamUserType(1, "cCompositeChat") || - !L.CheckParamNumber(2) - ) + if (!L.CheckParamUserType(1, "cCompositeChat") || !L.CheckParamNumber(2)) { return 0; } @@ -4222,7 +3987,9 @@ static int tolua_cCuboid_Assign(lua_State * tolua_S) int x1, y1, z1, x2, y2, z2; if (L.GetStackValues(2, x1, y1, z1, x2, y2, z2)) { - LOGWARNING("cCuboid:Assign(x1, y1, z1, x2, y2, z2) is deprecated, use cCuboid:Assign(Vector3i, Vector3i) instead."); + LOGWARNING( + "cCuboid:Assign(x1, y1, z1, x2, y2, z2) is deprecated, use cCuboid:Assign(Vector3i, Vector3i) instead." + ); L.LogStackTrace(); self->Assign({x1, y1, z1}, {x2, y2, z2}); return 0; @@ -4269,7 +4036,7 @@ static int tolua_cCuboid_IsInside(lua_State * tolua_S) { LOGWARNING("cCuboid:IsInside(x, y, z) is deprecated, use cCuboid:IsInside(Vector3) instead."); L.LogStackTrace(); - L.Push(self->IsInside(Vector3i{x, y, z})); + L.Push(self->IsInside(Vector3i {x, y, z})); return 1; } @@ -4415,7 +4182,7 @@ static int tolua_cEntity_GetPosition(lua_State * tolua_S) return 0; } - L.Push(Mtolua_new((Vector3d)(self->GetPosition()))); + L.Push(Mtolua_new((Vector3d) (self->GetPosition()))); tolua_register_gc(L, lua_gettop(L)); // Make Lua own the object return 1; @@ -4437,7 +4204,7 @@ static int tolua_cEntity_GetSpeed(lua_State * tolua_S) return 0; } - L.Push(Mtolua_new((Vector3d)(self->GetSpeed()))); + L.Push(Mtolua_new((Vector3d) (self->GetSpeed()))); tolua_register_gc(L, lua_gettop(L)); // Make Lua own the object return 1; @@ -4514,259 +4281,259 @@ void cManualBindings::Bind(lua_State * tolua_S) { tolua_beginmodule(tolua_S, nullptr); - // Create the new classes: - tolua_usertype(tolua_S, "cCryptoHash"); - tolua_usertype(tolua_S, "cLineBlockTracer"); - tolua_usertype(tolua_S, "cStringCompression"); - tolua_usertype(tolua_S, "cUrlParser"); - // StatisticsManager was already created by cPlayer::GetStatistics' autogenerated bindings. - tolua_cclass(tolua_S, "cCryptoHash", "cCryptoHash", "", nullptr); - tolua_cclass(tolua_S, "cLineBlockTracer", "cLineBlockTracer", "", nullptr); - tolua_cclass(tolua_S, "cStringCompression", "cStringCompression", "", nullptr); - tolua_cclass(tolua_S, "cUrlParser", "cUrlParser", "", nullptr); - tolua_cclass(tolua_S, "StatisticsManager", "StatisticsManager", "", nullptr); - - // Globals: - tolua_function(tolua_S, "Clamp", tolua_Clamp); - tolua_function(tolua_S, "StringSplit", tolua_StringSplit); - tolua_function(tolua_S, "StringSplitWithQuotes", tolua_StringSplitWithQuotes); - tolua_function(tolua_S, "StringSplitAndTrim", tolua_StringSplitAndTrim); - tolua_function(tolua_S, "LOG", tolua_LOG); - tolua_function(tolua_S, "LOGINFO", tolua_LOGINFO); - tolua_function(tolua_S, "LOGWARN", tolua_LOGWARN); - tolua_function(tolua_S, "LOGWARNING", tolua_LOGWARN); - tolua_function(tolua_S, "LOGERROR", tolua_LOGERROR); - tolua_function(tolua_S, "Base64Encode", tolua_Base64Encode); - tolua_function(tolua_S, "Base64Decode", tolua_Base64Decode); - tolua_function(tolua_S, "md5", tolua_md5_obsolete); // OBSOLETE, use cCryptoHash.md5() instead - - tolua_beginmodule(tolua_S, "cBoundingBox"); - tolua_function(tolua_S, "CalcLineIntersection", tolua_cBoundingBox_CalcLineIntersection); - tolua_function(tolua_S, "Intersect", tolua_cBoundingBox_Intersect); - tolua_endmodule(tolua_S); - - tolua_beginmodule(tolua_S, "cChunkDesc"); - tolua_function(tolua_S, "GetBlockTypeMeta", tolua_cChunkDesc_GetBlockTypeMeta); - tolua_endmodule(tolua_S); - - tolua_beginmodule(tolua_S, "cClientHandle"); - tolua_constant(tolua_S, "MAX_VIEW_DISTANCE", cClientHandle::MAX_VIEW_DISTANCE); - tolua_constant(tolua_S, "MIN_VIEW_DISTANCE", cClientHandle::MIN_VIEW_DISTANCE); - - tolua_function(tolua_S, "GetForgeMods", tolua_cClientHandle_GetForgeMods); - tolua_function(tolua_S, "SendPluginMessage", tolua_cClientHandle_SendPluginMessage); - tolua_function(tolua_S, "SendTimeUpdate", tolua_cClientHandle_SendTimeUpdate); - tolua_function(tolua_S, "GetUUID", tolua_cClientHandle_GetUUID); - tolua_function(tolua_S, "GenerateOfflineUUID", tolua_cClientHandle_GenerateOfflineUUID); - tolua_function(tolua_S, "IsUUIDOnline", tolua_cClientHandle_IsUUIDOnline); - tolua_endmodule(tolua_S); - - tolua_beginmodule(tolua_S, "cColor"); - tolua_function(tolua_S, "GetColor", tolua_cColor_GetColor); - tolua_endmodule(tolua_S); - - tolua_beginmodule(tolua_S, "cCompositeChat"); - tolua_function(tolua_S, "new", tolua_cCompositeChat_new); - tolua_function(tolua_S, "new_local", tolua_cCompositeChat_new_local); - tolua_function(tolua_S, ".call", tolua_cCompositeChat_new_local); - tolua_function(tolua_S, "AddShowAchievementPart", tolua_cCompositeChat_AddShowAchievementPart); - tolua_function(tolua_S, "AddRunCommandPart", tolua_cCompositeChat_AddRunCommandPart); - tolua_function(tolua_S, "AddSuggestCommandPart", tolua_cCompositeChat_AddSuggestCommandPart); - tolua_function(tolua_S, "AddTextPart", tolua_cCompositeChat_AddTextPart); - tolua_function(tolua_S, "AddUrlPart", tolua_cCompositeChat_AddUrlPart); - tolua_function(tolua_S, "Clear", tolua_cCompositeChat_Clear); - tolua_function(tolua_S, "ParseText", tolua_cCompositeChat_ParseText); - tolua_function(tolua_S, "SetMessageType", tolua_cCompositeChat_SetMessageType); - tolua_function(tolua_S, "UnderlineUrls", tolua_cCompositeChat_UnderlineUrls); - tolua_endmodule(tolua_S); - - tolua_beginmodule(tolua_S, "cCryptoHash"); - tolua_function(tolua_S, "md5", tolua_md5); - tolua_function(tolua_S, "md5HexString", tolua_md5HexString); - tolua_function(tolua_S, "sha1", tolua_sha1); - tolua_function(tolua_S, "sha1HexString", tolua_sha1HexString); - tolua_endmodule(tolua_S); - - tolua_beginmodule(tolua_S, "cCuboid"); - tolua_function(tolua_S, "Assign", tolua_cCuboid_Assign); - tolua_function(tolua_S, "IsInside", tolua_cCuboid_IsInside); - tolua_function(tolua_S, "Move", tolua_cCuboid_Move); - tolua_endmodule(tolua_S); - - tolua_beginmodule(tolua_S, "cEntity"); - tolua_constant(tolua_S, "INVALID_ID", cEntity::INVALID_ID); - tolua_function(tolua_S, "Destroy", tolua_cEntity_Destroy); - tolua_function(tolua_S, "IsSubmerged", tolua_cEntity_IsSubmerged); - tolua_function(tolua_S, "IsSwimming", tolua_cEntity_IsSwimming); - tolua_function(tolua_S, "GetPosition", tolua_cEntity_GetPosition); - tolua_function(tolua_S, "GetSpeed", tolua_cEntity_GetSpeed); - tolua_endmodule(tolua_S); - - tolua_beginmodule(tolua_S, "cFile"); - tolua_function(tolua_S, "ChangeFileExt", tolua_cFile_ChangeFileExt); - tolua_function(tolua_S, "Copy", tolua_cFile_Copy); - tolua_function(tolua_S, "CreateFolder", tolua_cFile_CreateFolder); - tolua_function(tolua_S, "CreateFolderRecursive", tolua_cFile_CreateFolderRecursive); - tolua_function(tolua_S, "Delete", tolua_cFile_Delete); - tolua_function(tolua_S, "DeleteFile", tolua_cFile_DeleteFile); - tolua_function(tolua_S, "DeleteFolder", tolua_cFile_DeleteFolder); - tolua_function(tolua_S, "DeleteFolderContents", tolua_cFile_DeleteFolderContents); - tolua_function(tolua_S, "Exists", tolua_cFile_Exists); - tolua_function(tolua_S, "GetFolderContents", tolua_cFile_GetFolderContents); - tolua_function(tolua_S, "GetLastModificationTime", tolua_cFile_GetLastModificationTime); - tolua_function(tolua_S, "GetSize", tolua_cFile_GetSize); - tolua_function(tolua_S, "IsFile", tolua_cFile_IsFile); - tolua_function(tolua_S, "IsFolder", tolua_cFile_IsFolder); - tolua_function(tolua_S, "ReadWholeFile", tolua_cFile_ReadWholeFile); - tolua_function(tolua_S, "Rename", tolua_cFile_Rename); - tolua_endmodule(tolua_S); - - tolua_beginmodule(tolua_S, "cHopperEntity"); - tolua_function(tolua_S, "GetOutputBlockPos", tolua_cHopperEntity_GetOutputBlockPos); - tolua_endmodule(tolua_S); - - tolua_beginmodule(tolua_S, "cItem"); - tolua_function(tolua_S, "EnchantByXPLevels", tolua_cItem_EnchantByXPLevels); - tolua_variable(tolua_S, "m_LoreTable", tolua_get_cItem_m_LoreTable, tolua_set_cItem_m_LoreTable); - tolua_endmodule(tolua_S); - - tolua_beginmodule(tolua_S, "cItemGrid"); - tolua_function(tolua_S, "GetSlotCoords", Lua_ItemGrid_GetSlotCoords); - tolua_endmodule(tolua_S); - - tolua_beginmodule(tolua_S, "cLineBlockTracer"); - tolua_function(tolua_S, "FirstSolidHitTrace", tolua_cLineBlockTracer_FirstSolidHitTrace); - tolua_function(tolua_S, "LineOfSightTrace", tolua_cLineBlockTracer_LineOfSightTrace); - tolua_function(tolua_S, "Trace", tolua_cLineBlockTracer_Trace); - - tolua_constant(tolua_S, "losAir", cLineBlockTracer::losAir); - tolua_constant(tolua_S, "losWater", cLineBlockTracer::losWater); - tolua_constant(tolua_S, "losLava", cLineBlockTracer::losLava); - tolua_endmodule(tolua_S); - - tolua_beginmodule(tolua_S, "cLuaWindow"); - tolua_function(tolua_S, "new", tolua_cLuaWindow_new); - tolua_function(tolua_S, "new_local", tolua_cLuaWindow_new_local); - tolua_function(tolua_S, ".call", tolua_cLuaWindow_new_local); - tolua_function(tolua_S, "SetOnClicked", tolua_SetObjectCallback<cLuaWindow, &cLuaWindow::SetOnClicked>); - tolua_function(tolua_S, "SetOnClosing", tolua_SetObjectCallback<cLuaWindow, &cLuaWindow::SetOnClosing>); - tolua_function(tolua_S, "SetOnSlotChanged", tolua_SetObjectCallback<cLuaWindow, &cLuaWindow::SetOnSlotChanged>); - tolua_endmodule(tolua_S); - - tolua_beginmodule(tolua_S, "cMapManager"); - tolua_function(tolua_S, "DoWithMap", DoWithID<cMapManager, cMap, &cMapManager::DoWithMap>); - tolua_endmodule(tolua_S); - - tolua_beginmodule(tolua_S, "cMobHeadEntity"); - tolua_function(tolua_S, "SetOwner", tolua_cMobHeadEntity_SetOwner); - tolua_function(tolua_S, "GetOwnerUUID", tolua_cMobHeadEntity_GetOwnerUUID); - tolua_endmodule(tolua_S); - - tolua_beginmodule(tolua_S, "cMojangAPI"); - tolua_function(tolua_S, "AddPlayerNameToUUIDMapping", tolua_cMojangAPI_AddPlayerNameToUUIDMapping); - tolua_function(tolua_S, "GetPlayerNameFromUUID", tolua_cMojangAPI_GetPlayerNameFromUUID); - tolua_function(tolua_S, "GetUUIDFromPlayerName", tolua_cMojangAPI_GetUUIDFromPlayerName); - tolua_function(tolua_S, "GetUUIDsFromPlayerNames", tolua_cMojangAPI_GetUUIDsFromPlayerNames); - tolua_function(tolua_S, "MakeUUIDDashed", tolua_cMojangAPI_MakeUUIDDashed); - tolua_function(tolua_S, "MakeUUIDShort", tolua_cMojangAPI_MakeUUIDShort); - tolua_endmodule(tolua_S); - - tolua_beginmodule(tolua_S, "cPlayer"); - tolua_function(tolua_S, "GetPermissions", tolua_cPlayer_GetPermissions); - tolua_function(tolua_S, "GetRestrictions", tolua_cPlayer_GetRestrictions); - tolua_function(tolua_S, "GetUUID", tolua_cPlayer_GetUUID); - tolua_function(tolua_S, "PermissionMatches", tolua_cPlayer_PermissionMatches); - tolua_function(tolua_S, "PlaceBlock", tolua_cPlayer_PlaceBlock); - tolua_endmodule(tolua_S); - - tolua_beginmodule(tolua_S, "cPlugin"); - tolua_function(tolua_S, "GetDirectory", tolua_cPlugin_GetDirectory); - tolua_function(tolua_S, "GetLocalDirectory", tolua_cPlugin_GetLocalDirectory); - tolua_endmodule(tolua_S); - - tolua_beginmodule(tolua_S, "cPluginLua"); - tolua_function(tolua_S, "AddWebTab", tolua_cPluginLua_AddWebTab); - tolua_endmodule(tolua_S); - - tolua_beginmodule(tolua_S, "cPluginManager"); - tolua_function(tolua_S, "AddHook", tolua_cPluginManager_AddHook); - tolua_function(tolua_S, "BindCommand", tolua_cPluginManager_BindCommand); - tolua_function(tolua_S, "BindConsoleCommand", tolua_cPluginManager_BindConsoleCommand); - tolua_function(tolua_S, "CallPlugin", tolua_cPluginManager_CallPlugin); - tolua_function(tolua_S, "DoWithPlugin", StaticDoWith<cPluginManager, cPlugin, &cPluginManager::DoWithPlugin>); - tolua_function(tolua_S, "ExecuteConsoleCommand", tolua_cPluginManager_ExecuteConsoleCommand); - tolua_function(tolua_S, "FindPlugins", tolua_cPluginManager_FindPlugins); - tolua_function(tolua_S, "ForEachCommand", tolua_cPluginManager_ForEachCommand); - tolua_function(tolua_S, "ForEachConsoleCommand", tolua_cPluginManager_ForEachConsoleCommand); - tolua_function(tolua_S, "ForEachPlugin", StaticForEach<cPluginManager, cPlugin, &cPluginManager::ForEachPlugin>); - tolua_function(tolua_S, "GetAllPlugins", tolua_cPluginManager_GetAllPlugins); - tolua_function(tolua_S, "GetCurrentPlugin", tolua_cPluginManager_GetCurrentPlugin); - tolua_function(tolua_S, "GetPlugin", tolua_cPluginManager_GetPlugin); - tolua_function(tolua_S, "LogStackTrace", tolua_cPluginManager_LogStackTrace); - tolua_endmodule(tolua_S); - - tolua_beginmodule(tolua_S, "cRoot"); - tolua_function(tolua_S, "DoWithPlayerByUUID", tolua_cRoot_DoWithPlayerByUUID); - tolua_function(tolua_S, "FindAndDoWithPlayer", DoWith <cRoot, cPlayer, &cRoot::FindAndDoWithPlayer>); - tolua_function(tolua_S, "ForEachPlayer", ForEach<cRoot, cPlayer, &cRoot::ForEachPlayer>); - tolua_function(tolua_S, "ForEachWorld", ForEach<cRoot, cWorld, &cRoot::ForEachWorld>); - tolua_function(tolua_S, "GetBrewingRecipe", tolua_cRoot_GetBrewingRecipe); - tolua_function(tolua_S, "GetBuildCommitID", tolua_cRoot_GetBuildCommitID); - tolua_function(tolua_S, "GetBuildDateTime", tolua_cRoot_GetBuildDateTime); - tolua_function(tolua_S, "GetBuildID", tolua_cRoot_GetBuildID); - tolua_function(tolua_S, "GetBuildSeriesName", tolua_cRoot_GetBuildSeriesName); - tolua_function(tolua_S, "GetFurnaceRecipe", tolua_cRoot_GetFurnaceRecipe); - tolua_endmodule(tolua_S); - - tolua_beginmodule(tolua_S, "cScoreboard"); - tolua_function(tolua_S, "ForEachObjective", ForEach<cScoreboard, cObjective, &cScoreboard::ForEachObjective>); - tolua_function(tolua_S, "ForEachTeam", ForEach<cScoreboard, cTeam, &cScoreboard::ForEachTeam>); - tolua_function(tolua_S, "GetTeamNames", tolua_cScoreboard_GetTeamNames); - tolua_endmodule(tolua_S); - - tolua_beginmodule(tolua_S, "cServer"); - tolua_function(tolua_S, "RegisterForgeMod", tolua_cServer_RegisterForgeMod); - tolua_function(tolua_S, "ScheduleTask", tolua_cServer_ScheduleTask); - tolua_endmodule(tolua_S); - - tolua_beginmodule(tolua_S, "cStringCompression"); - tolua_function(tolua_S, "CompressStringZLIB", tolua_CompressStringZLIB); - tolua_function(tolua_S, "UncompressStringZLIB", tolua_UncompressStringZLIB); - tolua_function(tolua_S, "CompressStringGZIP", tolua_CompressStringGZIP); - tolua_function(tolua_S, "UncompressStringGZIP", tolua_InflateString); - tolua_function(tolua_S, "InflateString", tolua_InflateString); - tolua_endmodule(tolua_S); - - tolua_beginmodule(tolua_S, "cUrlParser"); - tolua_function(tolua_S, "GetDefaultPort", tolua_cUrlParser_GetDefaultPort); - tolua_function(tolua_S, "IsKnownScheme", tolua_cUrlParser_IsKnownScheme); - tolua_function(tolua_S, "Parse", tolua_cUrlParser_Parse); - tolua_function(tolua_S, "ParseAuthorityPart", tolua_cUrlParser_ParseAuthorityPart); - tolua_function(tolua_S, "UrlDecode", tolua_cUrlParser_UrlDecode); - tolua_function(tolua_S, "UrlEncode", tolua_cUrlParser_UrlEncode); - tolua_endmodule(tolua_S); - - tolua_beginmodule(tolua_S, "cWebAdmin"); - tolua_function(tolua_S, "AddWebTab", tolua_cWebAdmin_AddWebTab); - tolua_function(tolua_S, "GetAllWebTabs", tolua_cWebAdmin_GetAllWebTabs); - tolua_function(tolua_S, "GetPage", tolua_cWebAdmin_GetPage); - tolua_function(tolua_S, "GetURLEncodedString", tolua_cWebAdmin_GetURLEncodedString); - tolua_endmodule(tolua_S); - - tolua_beginmodule(tolua_S, "HTTPRequest"); - tolua_variable(tolua_S, "FormData", tolua_get_HTTPRequest_FormData, nullptr); - tolua_variable(tolua_S, "Params", tolua_get_HTTPRequest_Params, nullptr); - tolua_variable(tolua_S, "PostParams", tolua_get_HTTPRequest_PostParams, nullptr); - tolua_endmodule(tolua_S); - - tolua_beginmodule(tolua_S, "StatisticsManager"); - tolua_array(tolua_S, "Custom", tolua_get_StatisticsManager_Custom, tolua_set_StatisticsManager_Custom); - tolua_endmodule(tolua_S); - - BindNetwork(tolua_S); - BindRankManager(tolua_S); - BindWorld(tolua_S); - BindBlockArea(tolua_S); + // Create the new classes: + tolua_usertype(tolua_S, "cCryptoHash"); + tolua_usertype(tolua_S, "cLineBlockTracer"); + tolua_usertype(tolua_S, "cStringCompression"); + tolua_usertype(tolua_S, "cUrlParser"); + // StatisticsManager was already created by cPlayer::GetStatistics' autogenerated bindings. + tolua_cclass(tolua_S, "cCryptoHash", "cCryptoHash", "", nullptr); + tolua_cclass(tolua_S, "cLineBlockTracer", "cLineBlockTracer", "", nullptr); + tolua_cclass(tolua_S, "cStringCompression", "cStringCompression", "", nullptr); + tolua_cclass(tolua_S, "cUrlParser", "cUrlParser", "", nullptr); + tolua_cclass(tolua_S, "StatisticsManager", "StatisticsManager", "", nullptr); + + // Globals: + tolua_function(tolua_S, "Clamp", tolua_Clamp); + tolua_function(tolua_S, "StringSplit", tolua_StringSplit); + tolua_function(tolua_S, "StringSplitWithQuotes", tolua_StringSplitWithQuotes); + tolua_function(tolua_S, "StringSplitAndTrim", tolua_StringSplitAndTrim); + tolua_function(tolua_S, "LOG", tolua_LOG); + tolua_function(tolua_S, "LOGINFO", tolua_LOGINFO); + tolua_function(tolua_S, "LOGWARN", tolua_LOGWARN); + tolua_function(tolua_S, "LOGWARNING", tolua_LOGWARN); + tolua_function(tolua_S, "LOGERROR", tolua_LOGERROR); + tolua_function(tolua_S, "Base64Encode", tolua_Base64Encode); + tolua_function(tolua_S, "Base64Decode", tolua_Base64Decode); + tolua_function(tolua_S, "md5", tolua_md5_obsolete); // OBSOLETE, use cCryptoHash.md5() instead + + tolua_beginmodule(tolua_S, "cBoundingBox"); + tolua_function(tolua_S, "CalcLineIntersection", tolua_cBoundingBox_CalcLineIntersection); + tolua_function(tolua_S, "Intersect", tolua_cBoundingBox_Intersect); + tolua_endmodule(tolua_S); + + tolua_beginmodule(tolua_S, "cChunkDesc"); + tolua_function(tolua_S, "GetBlockTypeMeta", tolua_cChunkDesc_GetBlockTypeMeta); + tolua_endmodule(tolua_S); + + tolua_beginmodule(tolua_S, "cClientHandle"); + tolua_constant(tolua_S, "MAX_VIEW_DISTANCE", cClientHandle::MAX_VIEW_DISTANCE); + tolua_constant(tolua_S, "MIN_VIEW_DISTANCE", cClientHandle::MIN_VIEW_DISTANCE); + + tolua_function(tolua_S, "GetForgeMods", tolua_cClientHandle_GetForgeMods); + tolua_function(tolua_S, "SendPluginMessage", tolua_cClientHandle_SendPluginMessage); + tolua_function(tolua_S, "SendTimeUpdate", tolua_cClientHandle_SendTimeUpdate); + tolua_function(tolua_S, "GetUUID", tolua_cClientHandle_GetUUID); + tolua_function(tolua_S, "GenerateOfflineUUID", tolua_cClientHandle_GenerateOfflineUUID); + tolua_function(tolua_S, "IsUUIDOnline", tolua_cClientHandle_IsUUIDOnline); + tolua_endmodule(tolua_S); + + tolua_beginmodule(tolua_S, "cColor"); + tolua_function(tolua_S, "GetColor", tolua_cColor_GetColor); + tolua_endmodule(tolua_S); + + tolua_beginmodule(tolua_S, "cCompositeChat"); + tolua_function(tolua_S, "new", tolua_cCompositeChat_new); + tolua_function(tolua_S, "new_local", tolua_cCompositeChat_new_local); + tolua_function(tolua_S, ".call", tolua_cCompositeChat_new_local); + tolua_function(tolua_S, "AddShowAchievementPart", tolua_cCompositeChat_AddShowAchievementPart); + tolua_function(tolua_S, "AddRunCommandPart", tolua_cCompositeChat_AddRunCommandPart); + tolua_function(tolua_S, "AddSuggestCommandPart", tolua_cCompositeChat_AddSuggestCommandPart); + tolua_function(tolua_S, "AddTextPart", tolua_cCompositeChat_AddTextPart); + tolua_function(tolua_S, "AddUrlPart", tolua_cCompositeChat_AddUrlPart); + tolua_function(tolua_S, "Clear", tolua_cCompositeChat_Clear); + tolua_function(tolua_S, "ParseText", tolua_cCompositeChat_ParseText); + tolua_function(tolua_S, "SetMessageType", tolua_cCompositeChat_SetMessageType); + tolua_function(tolua_S, "UnderlineUrls", tolua_cCompositeChat_UnderlineUrls); + tolua_endmodule(tolua_S); + + tolua_beginmodule(tolua_S, "cCryptoHash"); + tolua_function(tolua_S, "md5", tolua_md5); + tolua_function(tolua_S, "md5HexString", tolua_md5HexString); + tolua_function(tolua_S, "sha1", tolua_sha1); + tolua_function(tolua_S, "sha1HexString", tolua_sha1HexString); + tolua_endmodule(tolua_S); + + tolua_beginmodule(tolua_S, "cCuboid"); + tolua_function(tolua_S, "Assign", tolua_cCuboid_Assign); + tolua_function(tolua_S, "IsInside", tolua_cCuboid_IsInside); + tolua_function(tolua_S, "Move", tolua_cCuboid_Move); + tolua_endmodule(tolua_S); + + tolua_beginmodule(tolua_S, "cEntity"); + tolua_constant(tolua_S, "INVALID_ID", cEntity::INVALID_ID); + tolua_function(tolua_S, "Destroy", tolua_cEntity_Destroy); + tolua_function(tolua_S, "IsSubmerged", tolua_cEntity_IsSubmerged); + tolua_function(tolua_S, "IsSwimming", tolua_cEntity_IsSwimming); + tolua_function(tolua_S, "GetPosition", tolua_cEntity_GetPosition); + tolua_function(tolua_S, "GetSpeed", tolua_cEntity_GetSpeed); + tolua_endmodule(tolua_S); + + tolua_beginmodule(tolua_S, "cFile"); + tolua_function(tolua_S, "ChangeFileExt", tolua_cFile_ChangeFileExt); + tolua_function(tolua_S, "Copy", tolua_cFile_Copy); + tolua_function(tolua_S, "CreateFolder", tolua_cFile_CreateFolder); + tolua_function(tolua_S, "CreateFolderRecursive", tolua_cFile_CreateFolderRecursive); + tolua_function(tolua_S, "Delete", tolua_cFile_Delete); + tolua_function(tolua_S, "DeleteFile", tolua_cFile_DeleteFile); + tolua_function(tolua_S, "DeleteFolder", tolua_cFile_DeleteFolder); + tolua_function(tolua_S, "DeleteFolderContents", tolua_cFile_DeleteFolderContents); + tolua_function(tolua_S, "Exists", tolua_cFile_Exists); + tolua_function(tolua_S, "GetFolderContents", tolua_cFile_GetFolderContents); + tolua_function(tolua_S, "GetLastModificationTime", tolua_cFile_GetLastModificationTime); + tolua_function(tolua_S, "GetSize", tolua_cFile_GetSize); + tolua_function(tolua_S, "IsFile", tolua_cFile_IsFile); + tolua_function(tolua_S, "IsFolder", tolua_cFile_IsFolder); + tolua_function(tolua_S, "ReadWholeFile", tolua_cFile_ReadWholeFile); + tolua_function(tolua_S, "Rename", tolua_cFile_Rename); + tolua_endmodule(tolua_S); + + tolua_beginmodule(tolua_S, "cHopperEntity"); + tolua_function(tolua_S, "GetOutputBlockPos", tolua_cHopperEntity_GetOutputBlockPos); + tolua_endmodule(tolua_S); + + tolua_beginmodule(tolua_S, "cItem"); + tolua_function(tolua_S, "EnchantByXPLevels", tolua_cItem_EnchantByXPLevels); + tolua_variable(tolua_S, "m_LoreTable", tolua_get_cItem_m_LoreTable, tolua_set_cItem_m_LoreTable); + tolua_endmodule(tolua_S); + + tolua_beginmodule(tolua_S, "cItemGrid"); + tolua_function(tolua_S, "GetSlotCoords", Lua_ItemGrid_GetSlotCoords); + tolua_endmodule(tolua_S); + + tolua_beginmodule(tolua_S, "cLineBlockTracer"); + tolua_function(tolua_S, "FirstSolidHitTrace", tolua_cLineBlockTracer_FirstSolidHitTrace); + tolua_function(tolua_S, "LineOfSightTrace", tolua_cLineBlockTracer_LineOfSightTrace); + tolua_function(tolua_S, "Trace", tolua_cLineBlockTracer_Trace); + + tolua_constant(tolua_S, "losAir", cLineBlockTracer::losAir); + tolua_constant(tolua_S, "losWater", cLineBlockTracer::losWater); + tolua_constant(tolua_S, "losLava", cLineBlockTracer::losLava); + tolua_endmodule(tolua_S); + + tolua_beginmodule(tolua_S, "cLuaWindow"); + tolua_function(tolua_S, "new", tolua_cLuaWindow_new); + tolua_function(tolua_S, "new_local", tolua_cLuaWindow_new_local); + tolua_function(tolua_S, ".call", tolua_cLuaWindow_new_local); + tolua_function(tolua_S, "SetOnClicked", tolua_SetObjectCallback<cLuaWindow, &cLuaWindow::SetOnClicked>); + tolua_function(tolua_S, "SetOnClosing", tolua_SetObjectCallback<cLuaWindow, &cLuaWindow::SetOnClosing>); + tolua_function(tolua_S, "SetOnSlotChanged", tolua_SetObjectCallback<cLuaWindow, &cLuaWindow::SetOnSlotChanged>); + tolua_endmodule(tolua_S); + + tolua_beginmodule(tolua_S, "cMapManager"); + tolua_function(tolua_S, "DoWithMap", DoWithID<cMapManager, cMap, &cMapManager::DoWithMap>); + tolua_endmodule(tolua_S); + + tolua_beginmodule(tolua_S, "cMobHeadEntity"); + tolua_function(tolua_S, "SetOwner", tolua_cMobHeadEntity_SetOwner); + tolua_function(tolua_S, "GetOwnerUUID", tolua_cMobHeadEntity_GetOwnerUUID); + tolua_endmodule(tolua_S); + + tolua_beginmodule(tolua_S, "cMojangAPI"); + tolua_function(tolua_S, "AddPlayerNameToUUIDMapping", tolua_cMojangAPI_AddPlayerNameToUUIDMapping); + tolua_function(tolua_S, "GetPlayerNameFromUUID", tolua_cMojangAPI_GetPlayerNameFromUUID); + tolua_function(tolua_S, "GetUUIDFromPlayerName", tolua_cMojangAPI_GetUUIDFromPlayerName); + tolua_function(tolua_S, "GetUUIDsFromPlayerNames", tolua_cMojangAPI_GetUUIDsFromPlayerNames); + tolua_function(tolua_S, "MakeUUIDDashed", tolua_cMojangAPI_MakeUUIDDashed); + tolua_function(tolua_S, "MakeUUIDShort", tolua_cMojangAPI_MakeUUIDShort); + tolua_endmodule(tolua_S); + + tolua_beginmodule(tolua_S, "cPlayer"); + tolua_function(tolua_S, "GetPermissions", tolua_cPlayer_GetPermissions); + tolua_function(tolua_S, "GetRestrictions", tolua_cPlayer_GetRestrictions); + tolua_function(tolua_S, "GetUUID", tolua_cPlayer_GetUUID); + tolua_function(tolua_S, "PermissionMatches", tolua_cPlayer_PermissionMatches); + tolua_function(tolua_S, "PlaceBlock", tolua_cPlayer_PlaceBlock); + tolua_endmodule(tolua_S); + + tolua_beginmodule(tolua_S, "cPlugin"); + tolua_function(tolua_S, "GetDirectory", tolua_cPlugin_GetDirectory); + tolua_function(tolua_S, "GetLocalDirectory", tolua_cPlugin_GetLocalDirectory); + tolua_endmodule(tolua_S); + + tolua_beginmodule(tolua_S, "cPluginLua"); + tolua_function(tolua_S, "AddWebTab", tolua_cPluginLua_AddWebTab); + tolua_endmodule(tolua_S); + + tolua_beginmodule(tolua_S, "cPluginManager"); + tolua_function(tolua_S, "AddHook", tolua_cPluginManager_AddHook); + tolua_function(tolua_S, "BindCommand", tolua_cPluginManager_BindCommand); + tolua_function(tolua_S, "BindConsoleCommand", tolua_cPluginManager_BindConsoleCommand); + tolua_function(tolua_S, "CallPlugin", tolua_cPluginManager_CallPlugin); + tolua_function(tolua_S, "DoWithPlugin", StaticDoWith<cPluginManager, cPlugin, &cPluginManager::DoWithPlugin>); + tolua_function(tolua_S, "ExecuteConsoleCommand", tolua_cPluginManager_ExecuteConsoleCommand); + tolua_function(tolua_S, "FindPlugins", tolua_cPluginManager_FindPlugins); + tolua_function(tolua_S, "ForEachCommand", tolua_cPluginManager_ForEachCommand); + tolua_function(tolua_S, "ForEachConsoleCommand", tolua_cPluginManager_ForEachConsoleCommand); + tolua_function(tolua_S, "ForEachPlugin", StaticForEach<cPluginManager, cPlugin, &cPluginManager::ForEachPlugin>); + tolua_function(tolua_S, "GetAllPlugins", tolua_cPluginManager_GetAllPlugins); + tolua_function(tolua_S, "GetCurrentPlugin", tolua_cPluginManager_GetCurrentPlugin); + tolua_function(tolua_S, "GetPlugin", tolua_cPluginManager_GetPlugin); + tolua_function(tolua_S, "LogStackTrace", tolua_cPluginManager_LogStackTrace); + tolua_endmodule(tolua_S); + + tolua_beginmodule(tolua_S, "cRoot"); + tolua_function(tolua_S, "DoWithPlayerByUUID", tolua_cRoot_DoWithPlayerByUUID); + tolua_function(tolua_S, "FindAndDoWithPlayer", DoWith<cRoot, cPlayer, &cRoot::FindAndDoWithPlayer>); + tolua_function(tolua_S, "ForEachPlayer", ForEach<cRoot, cPlayer, &cRoot::ForEachPlayer>); + tolua_function(tolua_S, "ForEachWorld", ForEach<cRoot, cWorld, &cRoot::ForEachWorld>); + tolua_function(tolua_S, "GetBrewingRecipe", tolua_cRoot_GetBrewingRecipe); + tolua_function(tolua_S, "GetBuildCommitID", tolua_cRoot_GetBuildCommitID); + tolua_function(tolua_S, "GetBuildDateTime", tolua_cRoot_GetBuildDateTime); + tolua_function(tolua_S, "GetBuildID", tolua_cRoot_GetBuildID); + tolua_function(tolua_S, "GetBuildSeriesName", tolua_cRoot_GetBuildSeriesName); + tolua_function(tolua_S, "GetFurnaceRecipe", tolua_cRoot_GetFurnaceRecipe); + tolua_endmodule(tolua_S); + + tolua_beginmodule(tolua_S, "cScoreboard"); + tolua_function(tolua_S, "ForEachObjective", ForEach<cScoreboard, cObjective, &cScoreboard::ForEachObjective>); + tolua_function(tolua_S, "ForEachTeam", ForEach<cScoreboard, cTeam, &cScoreboard::ForEachTeam>); + tolua_function(tolua_S, "GetTeamNames", tolua_cScoreboard_GetTeamNames); + tolua_endmodule(tolua_S); + + tolua_beginmodule(tolua_S, "cServer"); + tolua_function(tolua_S, "RegisterForgeMod", tolua_cServer_RegisterForgeMod); + tolua_function(tolua_S, "ScheduleTask", tolua_cServer_ScheduleTask); + tolua_endmodule(tolua_S); + + tolua_beginmodule(tolua_S, "cStringCompression"); + tolua_function(tolua_S, "CompressStringZLIB", tolua_CompressStringZLIB); + tolua_function(tolua_S, "UncompressStringZLIB", tolua_UncompressStringZLIB); + tolua_function(tolua_S, "CompressStringGZIP", tolua_CompressStringGZIP); + tolua_function(tolua_S, "UncompressStringGZIP", tolua_InflateString); + tolua_function(tolua_S, "InflateString", tolua_InflateString); + tolua_endmodule(tolua_S); + + tolua_beginmodule(tolua_S, "cUrlParser"); + tolua_function(tolua_S, "GetDefaultPort", tolua_cUrlParser_GetDefaultPort); + tolua_function(tolua_S, "IsKnownScheme", tolua_cUrlParser_IsKnownScheme); + tolua_function(tolua_S, "Parse", tolua_cUrlParser_Parse); + tolua_function(tolua_S, "ParseAuthorityPart", tolua_cUrlParser_ParseAuthorityPart); + tolua_function(tolua_S, "UrlDecode", tolua_cUrlParser_UrlDecode); + tolua_function(tolua_S, "UrlEncode", tolua_cUrlParser_UrlEncode); + tolua_endmodule(tolua_S); + + tolua_beginmodule(tolua_S, "cWebAdmin"); + tolua_function(tolua_S, "AddWebTab", tolua_cWebAdmin_AddWebTab); + tolua_function(tolua_S, "GetAllWebTabs", tolua_cWebAdmin_GetAllWebTabs); + tolua_function(tolua_S, "GetPage", tolua_cWebAdmin_GetPage); + tolua_function(tolua_S, "GetURLEncodedString", tolua_cWebAdmin_GetURLEncodedString); + tolua_endmodule(tolua_S); + + tolua_beginmodule(tolua_S, "HTTPRequest"); + tolua_variable(tolua_S, "FormData", tolua_get_HTTPRequest_FormData, nullptr); + tolua_variable(tolua_S, "Params", tolua_get_HTTPRequest_Params, nullptr); + tolua_variable(tolua_S, "PostParams", tolua_get_HTTPRequest_PostParams, nullptr); + tolua_endmodule(tolua_S); + + tolua_beginmodule(tolua_S, "StatisticsManager"); + tolua_array(tolua_S, "Custom", tolua_get_StatisticsManager_Custom, tolua_set_StatisticsManager_Custom); + tolua_endmodule(tolua_S); + + BindNetwork(tolua_S); + BindRankManager(tolua_S); + BindWorld(tolua_S); + BindBlockArea(tolua_S); tolua_endmodule(tolua_S); } |