Use lua_tointeger instead of lua_tonumber

This commit is contained in:
Pasi Kallinen
2019-11-07 19:28:58 +02:00
parent 293082079c
commit 4e438e0146
3 changed files with 9 additions and 9 deletions

View File

@@ -776,7 +776,7 @@ lua_State *L;
if (lua_type(L, -1) == LUA_TTABLE) {
int f, nflags;
lua_len(L, -1);
nflags = lua_tonumber(L, -1);
nflags = lua_tointeger(L, -1);
lua_pop(L, 1);
for (f = 0; f < nflags; f++) {
lua_pushinteger(L, f+1);
@@ -851,7 +851,7 @@ init_dungeons()
panic("dungeon is not a lua table");
lua_len(L, -1);
g.n_dgns = lua_tonumber(L, -1);
g.n_dgns = lua_tointeger(L, -1);
lua_pop(L, 1);
pd.start = 0;
@@ -898,7 +898,7 @@ init_dungeons()
if (lua_type(L, -1) == LUA_TTABLE) {
int f, nlevels;
lua_len(L, -1);
nlevels = lua_tonumber(L, -1);
nlevels = lua_tointeger(L, -1);
pd.tmpdungeon[i].levels = nlevels;
lua_pop(L, 1);
for (f = 0; f < nlevels; f++) {
@@ -954,7 +954,7 @@ init_dungeons()
if (lua_type(L, -1) == LUA_TTABLE) {
int f, nbranches;
lua_len(L, -1);
nbranches = lua_tonumber(L, -1);
nbranches = lua_tointeger(L, -1);
pd.tmpdungeon[i].branches = nbranches;
lua_pop(L, 1);
for (f = 0; f < nbranches; f++) {

View File

@@ -213,8 +213,8 @@ lua_State *L;
int argc = lua_gettop(L);
if (argc == 2) {
int x = (int) lua_tonumber(L, 1);
int y = (int) lua_tonumber(L, 2);
int x = lua_tointeger(L, 1);
int y = lua_tointeger(L, 2);
if (x >= 0 && x < COLNO && y >= 0 && y < ROWNO) {
char buf[BUFSZ];

View File

@@ -4534,7 +4534,7 @@ int tableidx, entrynum;
lua_pushinteger(L, entrynum);
lua_gettable(L, tableidx);
if (lua_isnumber(L, -1)) {
ret = lua_tonumber(L, -1);
ret = lua_tointeger(L, -1);
} else {
char buf[BUFSZ];
Sprintf(buf, "Array entry #%i is %s, expected number",
@@ -4564,7 +4564,7 @@ boolean optional;
luaL_checktype(L, -1, LUA_TTABLE);
lua_len(L, -1);
arrlen = lua_tonumber(L, -1);
arrlen = lua_tointeger(L, -1);
lua_pop(L, 1);
if (arrlen != 4) {
nhl_error(L, "Not a region");
@@ -4591,7 +4591,7 @@ int *x, *y;
int arrlen;
lua_len(L, index);
arrlen = lua_tonumber(L, -1);
arrlen = lua_tointeger(L, -1);
lua_pop(L, 1);
if (arrlen != 2) {
nhl_error(L, "Not a coordinate");