summaryrefslogtreecommitdiff
path: root/src/script/cpp_api/s_server.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/script/cpp_api/s_server.cpp')
-rw-r--r--src/script/cpp_api/s_server.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/script/cpp_api/s_server.cpp b/src/script/cpp_api/s_server.cpp
index 21fe164aa..ec2f9c0af 100644
--- a/src/script/cpp_api/s_server.cpp
+++ b/src/script/cpp_api/s_server.cpp
@@ -32,8 +32,7 @@ bool ScriptApiServer::getAuth(const std::string &playername,
if (lua_type(L, -1) != LUA_TFUNCTION)
throw LuaError("Authentication handler missing get_auth");
lua_pushstring(L, playername.c_str());
- if (lua_pcall(L, 1, 1, m_errorhandler))
- scriptError();
+ PCALL_RES(lua_pcall(L, 1, 1, m_errorhandler));
lua_remove(L, -2); // Remove auth handler
// nil = login not allowed
@@ -68,6 +67,9 @@ void ScriptApiServer::getAuthHandler()
lua_pop(L, 1);
lua_getfield(L, -1, "builtin_auth_handler");
}
+
+ setOriginFromTable(-1);
+
lua_remove(L, -2); // Remove core
if (lua_type(L, -1) != LUA_TTABLE)
throw LuaError("Authentication handler table not valid");
@@ -104,8 +106,7 @@ void ScriptApiServer::createAuth(const std::string &playername,
throw LuaError("Authentication handler missing create_auth");
lua_pushstring(L, playername.c_str());
lua_pushstring(L, password.c_str());
- if (lua_pcall(L, 2, 0, m_errorhandler))
- scriptError();
+ PCALL_RES(lua_pcall(L, 2, 0, m_errorhandler));
}
bool ScriptApiServer::setPassword(const std::string &playername,
@@ -120,8 +121,7 @@ bool ScriptApiServer::setPassword(const std::string &playername,
throw LuaError("Authentication handler missing set_password");
lua_pushstring(L, playername.c_str());
lua_pushstring(L, password.c_str());
- if (lua_pcall(L, 2, 1, m_errorhandler))
- scriptError();
+ PCALL_RES(lua_pcall(L, 2, 1, m_errorhandler));
return lua_toboolean(L, -1);
}
@@ -136,7 +136,7 @@ bool ScriptApiServer::on_chat_message(const std::string &name,
// Call callbacks
lua_pushstring(L, name.c_str());
lua_pushstring(L, message.c_str());
- script_run_callbacks(L, 2, RUN_CALLBACKS_MODE_OR_SC);
+ runCallbacks(2, RUN_CALLBACKS_MODE_OR_SC);
bool ate = lua_toboolean(L, -1);
return ate;
}
@@ -149,6 +149,6 @@ void ScriptApiServer::on_shutdown()
lua_getglobal(L, "core");
lua_getfield(L, -1, "registered_on_shutdown");
// Call callbacks
- script_run_callbacks(L, 0, RUN_CALLBACKS_MODE_FIRST);
+ runCallbacks(0, RUN_CALLBACKS_MODE_FIRST);
}