1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Improve Script CPP API diagnostics

This commit is contained in:
kwolekr 2015-08-05 00:49:35 -04:00
parent 3183d5a403
commit bcf47bc67c
16 changed files with 129 additions and 107 deletions

View file

@ -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
@ -104,8 +103,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 +118,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);
}