Skip to content

Commit c013c73

Browse files
tomasbrodest31
authored andcommitted
Lua->C getintfield() use lua_tointeger (#4408)
previously function used tonumber which returned float this caused errors in large numbers and resulted in obj-def-handlers being invalid when retrived from lua tables in c
1 parent 4503b50 commit c013c73

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/script/common/c_converter.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ bool getintfield(lua_State *L, int table,
391391
lua_getfield(L, table, fieldname);
392392
bool got = false;
393393
if(lua_isnumber(L, -1)){
394-
result = lua_tonumber(L, -1);
394+
result = lua_tointeger(L, -1);
395395
got = true;
396396
}
397397
lua_pop(L, 1);
@@ -404,7 +404,7 @@ bool getintfield(lua_State *L, int table,
404404
lua_getfield(L, table, fieldname);
405405
bool got = false;
406406
if(lua_isnumber(L, -1)){
407-
result = lua_tonumber(L, -1);
407+
result = lua_tointeger(L, -1);
408408
got = true;
409409
}
410410
lua_pop(L, 1);
@@ -417,7 +417,7 @@ bool getintfield(lua_State *L, int table,
417417
lua_getfield(L, table, fieldname);
418418
bool got = false;
419419
if(lua_isnumber(L, -1)){
420-
result = lua_tonumber(L, -1);
420+
result = lua_tointeger(L, -1);
421421
got = true;
422422
}
423423
lua_pop(L, 1);
@@ -430,7 +430,7 @@ bool getintfield(lua_State *L, int table,
430430
lua_getfield(L, table, fieldname);
431431
bool got = false;
432432
if(lua_isnumber(L, -1)){
433-
result = lua_tonumber(L, -1);
433+
result = lua_tointeger(L, -1);
434434
got = true;
435435
}
436436
lua_pop(L, 1);

0 commit comments

Comments
 (0)