aboutsummaryrefslogtreecommitdiff
path: root/src/script/cpp_api/s_base.cpp
diff options
context:
space:
mode:
authorElias Fleckenstein <eliasfleckenstein@web.de>2020-07-18 13:53:15 +0200
committerElias Fleckenstein <eliasfleckenstein@web.de>2020-07-18 13:53:15 +0200
commitffe3c2ae0db6fed0f2b08b71bfa69f3d3df3bb1f (patch)
treecc7d9f74a43215c5d8e3965a2bfc2aea5867a7a0 /src/script/cpp_api/s_base.cpp
parent45aa2516b2fc675df7049bc9ed713600c95b6423 (diff)
parent82731d0d3d8bfe9e56f89466991f13c037f3a61e (diff)
downloaddragonfireclient-ffe3c2ae0db6fed0f2b08b71bfa69f3d3df3bb1f.tar.xz
Update to minetest 5.4.0-dev
Diffstat (limited to 'src/script/cpp_api/s_base.cpp')
-rw-r--r--src/script/cpp_api/s_base.cpp15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/script/cpp_api/s_base.cpp b/src/script/cpp_api/s_base.cpp
index c9a17f659..1d62d8b65 100644
--- a/src/script/cpp_api/s_base.cpp
+++ b/src/script/cpp_api/s_base.cpp
@@ -22,7 +22,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "cpp_api/s_security.h"
#include "lua_api/l_object.h"
#include "common/c_converter.h"
-#include "serverobject.h"
+#include "server/player_sao.h"
#include "filesys.h"
#include "content/mods.h"
#include "porting.h"
@@ -43,7 +43,6 @@ extern "C" {
#include <cstdio>
#include <cstdarg>
#include "script/common/c_content.h"
-#include "content_sao.h"
#include <sstream>
@@ -90,7 +89,11 @@ ScriptApiBase::ScriptApiBase(ScriptingType type):
luaL_openlibs(m_luastack);
// Make the ScriptApiBase* accessible to ModApiBase
+#if INDIRECT_SCRIPTAPI_RIDX
+ *(void **)(lua_newuserdata(m_luastack, sizeof(void *))) = this;
+#else
lua_pushlightuserdata(m_luastack, this);
+#endif
lua_rawseti(m_luastack, LUA_REGISTRYINDEX, CUSTOM_RIDX_SCRIPTAPI);
// Add and save an error handler
@@ -184,7 +187,9 @@ void ScriptApiBase::loadScript(const std::string &script_path)
}
ok = ok && !lua_pcall(L, 0, 0, error_handler);
if (!ok) {
- std::string error_msg = readParam<std::string>(L, -1);
+ const char *error_msg = lua_tostring(L, -1);
+ if (!error_msg)
+ error_msg = "(error object is not a string)";
lua_pop(L, 2); // Pop error message and error handler
throw ModError("Failed to load and run script from " +
script_path + ":\n" + error_msg);
@@ -216,7 +221,9 @@ void ScriptApiBase::loadModFromMemory(const std::string &mod_name)
if (ok)
ok = !lua_pcall(L, 0, 0, error_handler);
if (!ok) {
- std::string error_msg = luaL_checkstring(L, -1);
+ const char *error_msg = lua_tostring(L, -1);
+ if (!error_msg)
+ error_msg = "(error object is not a string)";
lua_pop(L, 2); // Pop error message and error handler
throw ModError("Failed to load and run mod \"" +
mod_name + "\":\n" + error_msg);