summaryrefslogtreecommitdiff
path: root/src/script/cpp_api
diff options
context:
space:
mode:
Diffstat (limited to 'src/script/cpp_api')
-rw-r--r--src/script/cpp_api/s_base.cpp4
-rw-r--r--src/script/cpp_api/s_security.cpp7
2 files changed, 10 insertions, 1 deletions
diff --git a/src/script/cpp_api/s_base.cpp b/src/script/cpp_api/s_base.cpp
index ecb1ba39b..f234a15d4 100644
--- a/src/script/cpp_api/s_base.cpp
+++ b/src/script/cpp_api/s_base.cpp
@@ -90,7 +90,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
diff --git a/src/script/cpp_api/s_security.cpp b/src/script/cpp_api/s_security.cpp
index b5abcfb5d..2afa3a191 100644
--- a/src/script/cpp_api/s_security.cpp
+++ b/src/script/cpp_api/s_security.cpp
@@ -499,7 +499,12 @@ bool ScriptApiSecurity::checkPath(lua_State *L, const char *path,
// Get server from registry
lua_rawgeti(L, LUA_REGISTRYINDEX, CUSTOM_RIDX_SCRIPTAPI);
- ScriptApiBase *script = (ScriptApiBase *) lua_touserdata(L, -1);
+ ScriptApiBase *script;
+#if INDIRECT_SCRIPTAPI_RIDX
+ script = (ScriptApiBase *) *(void**)(lua_touserdata(L, -1));
+#else
+ script = (ScriptApiBase *) lua_touserdata(L, -1);
+#endif
lua_pop(L, 1);
const IGameDef *gamedef = script->getGameDef();
if (!gamedef)