Use luaL_check/optinteger instead of luaL_check/optnumber when getting integer arguments to functions. Resolves issue #1251.

--HG--
branch : minor
This commit is contained in:
Alex Szpakowski
2017-07-16 12:17:50 -03:00
parent abcade9421
commit 34ebe18f14
30 changed files with 127 additions and 127 deletions
@@ -65,7 +65,7 @@ int w_ChainShape_setPreviousVertex(lua_State *L)
int w_ChainShape_getChildEdge(lua_State *L)
{
ChainShape *c = luax_checkchainshape(L, 1);
int index = (int) luaL_checknumber(L, 2) - 1; // Convert from 1-based index
int index = (int) luaL_checkinteger(L, 2) - 1; // Convert from 1-based index
EdgeShape *e = 0;
luax_catchexcept(L, [&](){ e = c->getChildEdge(index); });
luax_pushtype(L, e);
@@ -84,7 +84,7 @@ int w_ChainShape_getVertexCount(lua_State *L)
int w_ChainShape_getPoint(lua_State *L)
{
ChainShape *c = luax_checkchainshape(L, 1);
int index = (int) luaL_checknumber(L, 2) - 1; // Convert from 1-based index
int index = (int) luaL_checkinteger(L, 2) - 1; // Convert from 1-based index
b2Vec2 v;
luax_catchexcept(L, [&](){ v = c->getPoint(index); });
lua_pushnumber(L, v.x);