summaryrefslogtreecommitdiff
path: root/src/script/cpp_api/s_server.cpp
diff options
context:
space:
mode:
authorLoïc Blot <nerzhul@users.noreply.github.com>2018-06-30 17:11:38 +0200
committerGitHub <noreply@github.com>2018-06-30 17:11:38 +0200
commiteef62c82a2e58700fc1216b0b8c03e421bc77995 (patch)
tree4c49e659069036cb53d69535dc33d33f29d963f4 /src/script/cpp_api/s_server.cpp
parent227c71eb76e019873b30e2d3893b68307d51d58f (diff)
downloadminetest-eef62c82a2e58700fc1216b0b8c03e421bc77995.tar.gz
minetest-eef62c82a2e58700fc1216b0b8c03e421bc77995.tar.bz2
minetest-eef62c82a2e58700fc1216b0b8c03e421bc77995.zip
Modernize lua read (part 2 & 3): C++ templating assurance (#7410)
* Modernize lua read (part 2 & 3): C++ templating assurance Implement the boolean reader Implement the string reader Also remove unused & unimplemented script_error_handler Add a reader with default value
Diffstat (limited to 'src/script/cpp_api/s_server.cpp')
-rw-r--r--src/script/cpp_api/s_server.cpp5
1 files changed, 2 insertions, 3 deletions
diff --git a/src/script/cpp_api/s_server.cpp b/src/script/cpp_api/s_server.cpp
index b0459fbfa..3b461a2a3 100644
--- a/src/script/cpp_api/s_server.cpp
+++ b/src/script/cpp_api/s_server.cpp
@@ -88,7 +88,7 @@ void ScriptApiServer::readPrivileges(int index, std::set<std::string> &result)
while (lua_next(L, index) != 0) {
// key at index -2 and value at index -1
std::string key = luaL_checkstring(L, -2);
- bool value = lua_toboolean(L, -1);
+ bool value = readParam<bool>(L, -1);
if (value)
result.insert(key);
// removes value, keeps key for next iteration
@@ -143,8 +143,7 @@ bool ScriptApiServer::on_chat_message(const std::string &name,
lua_pushstring(L, name.c_str());
lua_pushstring(L, message.c_str());
runCallbacks(2, RUN_CALLBACKS_MODE_OR_SC);
- bool ate = lua_toboolean(L, -1);
- return ate;
+ return readParam<bool>(L, -1);
}
void ScriptApiServer::on_mods_loaded()