summaryrefslogtreecommitdiff
path: root/src/script/lua_api/l_util.cpp
diff options
context:
space:
mode:
authoradrido <robots_only_adrido@gmx.com>2016-12-28 21:22:01 +0100
committerest31 <est31@users.noreply.github.com>2016-12-28 21:22:01 +0100
commit5a0a59ad463143d4452524837d69c108908f20d5 (patch)
tree74aac3fa97b0d112c462c0c118c825c76934f9eb /src/script/lua_api/l_util.cpp
parent084cdea6862cb65fe4bb807a211a9e1c17cffec8 (diff)
downloadminetest-5a0a59ad463143d4452524837d69c108908f20d5.tar.gz
minetest-5a0a59ad463143d4452524837d69c108908f20d5.tar.bz2
minetest-5a0a59ad463143d4452524837d69c108908f20d5.zip
Dont compare short with bool (#4963)
Fixes a compiler warning on MSVC
Diffstat (limited to 'src/script/lua_api/l_util.cpp')
-rw-r--r--src/script/lua_api/l_util.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/script/lua_api/l_util.cpp b/src/script/lua_api/l_util.cpp
index 26e2b985c..c26791646 100644
--- a/src/script/lua_api/l_util.cpp
+++ b/src/script/lua_api/l_util.cpp
@@ -398,7 +398,8 @@ int ModApiUtil::l_get_dir_list(lua_State *L)
{
NO_MAP_LOCK_REQUIRED;
const char *path = luaL_checkstring(L, 1);
- short is_dir = lua_isboolean(L, 2) ? lua_toboolean(L, 2) : -1;
+ bool list_all = !lua_isboolean(L, 2); // if its not a boolean list all
+ bool list_dirs = lua_toboolean(L, 2); // true: list dirs, false: list files
CHECK_SECURE_PATH(L, path, false);
@@ -408,7 +409,7 @@ int ModApiUtil::l_get_dir_list(lua_State *L)
lua_newtable(L);
for (size_t i = 0; i < list.size(); i++) {
- if (is_dir == -1 || is_dir == list[i].dir) {
+ if (list_all || list_dirs == list[i].dir) {
lua_pushstring(L, list[i].name.c_str());
lua_rawseti(L, -2, ++index);
}