From: nhmall Date: Fri, 29 Nov 2019 22:38:51 +0000 (-0500) Subject: casting lua_tointeger X-Git-Tag: NetHack-3.7.0_WIP~206 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=453745701fcf958e78a1c964724c5d3c98a04c47;p=nethack casting lua_tointeger --- diff --git a/src/dungeon.c b/src/dungeon.c index de7319b88..ae6e6866b 100644 --- a/src/dungeon.c +++ b/src/dungeon.c @@ -779,8 +779,9 @@ lua_State *L; lua_getfield(L, -1, "flags"); if (lua_type(L, -1) == LUA_TTABLE) { int f, nflags; + lua_len(L, -1); - nflags = LUA_INTCAST(lua_tointeger(L, -1)); + nflags = (int) lua_tointeger(L, -1); lua_pop(L, 1); for (f = 0; f < nflags; f++) { lua_pushinteger(L, f+1); @@ -856,7 +857,7 @@ init_dungeons() panic("dungeon is not a lua table"); lua_len(L, -1); - g.n_dgns = LUA_INTCAST(lua_tointeger(L, -1)); + g.n_dgns = (int) lua_tointeger(L, -1); lua_pop(L, 1); pd.start = 0; @@ -905,8 +906,9 @@ init_dungeons() lua_getfield(L, -1, "levels"); if (lua_type(L, -1) == LUA_TTABLE) { int f, nlevels; + lua_len(L, -1); - nlevels = LUA_INTCAST(lua_tointeger(L, -1)); + nlevels = (int) lua_tointeger(L, -1); pd.tmpdungeon[i].levels = nlevels; lua_pop(L, 1); for (f = 0; f < nlevels; f++) { @@ -965,8 +967,9 @@ init_dungeons() lua_getfield(L, -1, "branches"); if (lua_type(L, -1) == LUA_TTABLE) { int f, nbranches; + lua_len(L, -1); - nbranches = LUA_INTCAST(lua_tointeger(L, -1)); + nbranches = (int) lua_tointeger(L, -1); pd.tmpdungeon[i].branches = nbranches; lua_pop(L, 1); for (f = 0; f < nbranches; f++) { diff --git a/src/nhlua.c b/src/nhlua.c index 39c71496e..678dd7338 100644 --- a/src/nhlua.c +++ b/src/nhlua.c @@ -217,8 +217,8 @@ lua_State *L; int argc = lua_gettop(L); if (argc == 2) { - int x = LUA_INTCAST(lua_tointeger(L, 1)); - int y = LUA_INTCAST(lua_tointeger(L, 2)); + int x = (int) lua_tointeger(L, 1); + int y = (int) lua_tointeger(L, 2); if (x >= 0 && x < COLNO && y >= 0 && y < ROWNO) { char buf[BUFSZ]; diff --git a/src/questpgr.c b/src/questpgr.c index 64eea0c4d..594e4952b 100644 --- a/src/questpgr.c +++ b/src/questpgr.c @@ -484,8 +484,9 @@ const char *msgid; if (!synopsis && !text) { int nelems; + lua_len(L, -1); - nelems = LUA_INTCAST(lua_tointeger(L, -1)); + nelems = (int) lua_tointeger(L, -1); lua_pop(L, 1); if (nelems < 2) { impossible("com_pager: questtext[%s][%s] in %s in not an array of strings", section, msgid, QTEXT_FILE);