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
+3 -3
View File
@@ -91,14 +91,14 @@ int w_setGamepadMapping(lua_State *L)
switch (jinput.type)
{
case Joystick::INPUT_TYPE_AXIS:
jinput.axis = (int) luaL_checknumber(L, 4) - 1;
jinput.axis = (int) luaL_checkinteger(L, 4) - 1;
break;
case Joystick::INPUT_TYPE_BUTTON:
jinput.button = (int) luaL_checknumber(L, 4) - 1;
jinput.button = (int) luaL_checkinteger(L, 4) - 1;
break;
case Joystick::INPUT_TYPE_HAT:
// Hats need both a hat index and a hat value.
jinput.hat.index = (int) luaL_checknumber(L, 4) - 1;
jinput.hat.index = (int) luaL_checkinteger(L, 4) - 1;
hatstr = luaL_checkstring(L, 5);
if (!Joystick::getConstant(hatstr, jinput.hat.value))
return luaL_error(L, "Invalid joystick hat: %s", hatstr);