]> git.lizzy.rs Git - minetest.git/commitdiff
Lua->C getintfield() use lua_tointeger (#4408)
authorTomas <tomasbrod@azet.sk>
Wed, 10 Aug 2016 10:17:48 +0000 (12:17 +0200)
committerest31 <est31@users.noreply.github.com>
Wed, 10 Aug 2016 10:17:48 +0000 (12:17 +0200)
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

src/script/common/c_converter.cpp

index 55c4a5f5a1119d1bef8a926eb8619e4c6808ec34..857300fa5fcf3ea77034dc5f52f22778fef23b79 100644 (file)
@@ -391,7 +391,7 @@ bool getintfield(lua_State *L, int table,
        lua_getfield(L, table, fieldname);
        bool got = false;
        if(lua_isnumber(L, -1)){
-               result = lua_tonumber(L, -1);
+               result = lua_tointeger(L, -1);
                got = true;
        }
        lua_pop(L, 1);
@@ -404,7 +404,7 @@ bool getintfield(lua_State *L, int table,
        lua_getfield(L, table, fieldname);
        bool got = false;
        if(lua_isnumber(L, -1)){
-               result = lua_tonumber(L, -1);
+               result = lua_tointeger(L, -1);
                got = true;
        }
        lua_pop(L, 1);
@@ -417,7 +417,7 @@ bool getintfield(lua_State *L, int table,
        lua_getfield(L, table, fieldname);
        bool got = false;
        if(lua_isnumber(L, -1)){
-               result = lua_tonumber(L, -1);
+               result = lua_tointeger(L, -1);
                got = true;
        }
        lua_pop(L, 1);
@@ -430,7 +430,7 @@ bool getintfield(lua_State *L, int table,
        lua_getfield(L, table, fieldname);
        bool got = false;
        if(lua_isnumber(L, -1)){
-               result = lua_tonumber(L, -1);
+               result = lua_tointeger(L, -1);
                got = true;
        }
        lua_pop(L, 1);