Skip to content

Commit

Permalink
Dont compare short with bool (minetest#4963)
Browse files Browse the repository at this point in the history
Fixes a compiler warning on MSVC
  • Loading branch information
adrido authored and est31 committed Dec 28, 2016
1 parent 084cdea commit 5a0a59a
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/script/lua_api/l_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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);
}
Expand Down

0 comments on commit 5a0a59a

Please sign in to comment.