Use lua_tointeger instead of lua_tonumber
This commit is contained in:
@@ -776,7 +776,7 @@ lua_State *L;
|
|||||||
if (lua_type(L, -1) == LUA_TTABLE) {
|
if (lua_type(L, -1) == LUA_TTABLE) {
|
||||||
int f, nflags;
|
int f, nflags;
|
||||||
lua_len(L, -1);
|
lua_len(L, -1);
|
||||||
nflags = lua_tonumber(L, -1);
|
nflags = lua_tointeger(L, -1);
|
||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
for (f = 0; f < nflags; f++) {
|
for (f = 0; f < nflags; f++) {
|
||||||
lua_pushinteger(L, f+1);
|
lua_pushinteger(L, f+1);
|
||||||
@@ -851,7 +851,7 @@ init_dungeons()
|
|||||||
panic("dungeon is not a lua table");
|
panic("dungeon is not a lua table");
|
||||||
|
|
||||||
lua_len(L, -1);
|
lua_len(L, -1);
|
||||||
g.n_dgns = lua_tonumber(L, -1);
|
g.n_dgns = lua_tointeger(L, -1);
|
||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
|
|
||||||
pd.start = 0;
|
pd.start = 0;
|
||||||
@@ -898,7 +898,7 @@ init_dungeons()
|
|||||||
if (lua_type(L, -1) == LUA_TTABLE) {
|
if (lua_type(L, -1) == LUA_TTABLE) {
|
||||||
int f, nlevels;
|
int f, nlevels;
|
||||||
lua_len(L, -1);
|
lua_len(L, -1);
|
||||||
nlevels = lua_tonumber(L, -1);
|
nlevels = lua_tointeger(L, -1);
|
||||||
pd.tmpdungeon[i].levels = nlevels;
|
pd.tmpdungeon[i].levels = nlevels;
|
||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
for (f = 0; f < nlevels; f++) {
|
for (f = 0; f < nlevels; f++) {
|
||||||
@@ -954,7 +954,7 @@ init_dungeons()
|
|||||||
if (lua_type(L, -1) == LUA_TTABLE) {
|
if (lua_type(L, -1) == LUA_TTABLE) {
|
||||||
int f, nbranches;
|
int f, nbranches;
|
||||||
lua_len(L, -1);
|
lua_len(L, -1);
|
||||||
nbranches = lua_tonumber(L, -1);
|
nbranches = lua_tointeger(L, -1);
|
||||||
pd.tmpdungeon[i].branches = nbranches;
|
pd.tmpdungeon[i].branches = nbranches;
|
||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
for (f = 0; f < nbranches; f++) {
|
for (f = 0; f < nbranches; f++) {
|
||||||
|
|||||||
@@ -213,8 +213,8 @@ lua_State *L;
|
|||||||
int argc = lua_gettop(L);
|
int argc = lua_gettop(L);
|
||||||
|
|
||||||
if (argc == 2) {
|
if (argc == 2) {
|
||||||
int x = (int) lua_tonumber(L, 1);
|
int x = lua_tointeger(L, 1);
|
||||||
int y = (int) lua_tonumber(L, 2);
|
int y = lua_tointeger(L, 2);
|
||||||
|
|
||||||
if (x >= 0 && x < COLNO && y >= 0 && y < ROWNO) {
|
if (x >= 0 && x < COLNO && y >= 0 && y < ROWNO) {
|
||||||
char buf[BUFSZ];
|
char buf[BUFSZ];
|
||||||
|
|||||||
@@ -4534,7 +4534,7 @@ int tableidx, entrynum;
|
|||||||
lua_pushinteger(L, entrynum);
|
lua_pushinteger(L, entrynum);
|
||||||
lua_gettable(L, tableidx);
|
lua_gettable(L, tableidx);
|
||||||
if (lua_isnumber(L, -1)) {
|
if (lua_isnumber(L, -1)) {
|
||||||
ret = lua_tonumber(L, -1);
|
ret = lua_tointeger(L, -1);
|
||||||
} else {
|
} else {
|
||||||
char buf[BUFSZ];
|
char buf[BUFSZ];
|
||||||
Sprintf(buf, "Array entry #%i is %s, expected number",
|
Sprintf(buf, "Array entry #%i is %s, expected number",
|
||||||
@@ -4564,7 +4564,7 @@ boolean optional;
|
|||||||
luaL_checktype(L, -1, LUA_TTABLE);
|
luaL_checktype(L, -1, LUA_TTABLE);
|
||||||
|
|
||||||
lua_len(L, -1);
|
lua_len(L, -1);
|
||||||
arrlen = lua_tonumber(L, -1);
|
arrlen = lua_tointeger(L, -1);
|
||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
if (arrlen != 4) {
|
if (arrlen != 4) {
|
||||||
nhl_error(L, "Not a region");
|
nhl_error(L, "Not a region");
|
||||||
@@ -4591,7 +4591,7 @@ int *x, *y;
|
|||||||
int arrlen;
|
int arrlen;
|
||||||
|
|
||||||
lua_len(L, index);
|
lua_len(L, index);
|
||||||
arrlen = lua_tonumber(L, -1);
|
arrlen = lua_tointeger(L, -1);
|
||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
if (arrlen != 2) {
|
if (arrlen != 2) {
|
||||||
nhl_error(L, "Not a coordinate");
|
nhl_error(L, "Not a coordinate");
|
||||||
|
|||||||
Reference in New Issue
Block a user