Replaced use of lua_opt/checkint(eger) with lua_opt/checknumber

Using lua_check/opt/tonumber() assures a non-integer number is floored
when cast to an int, in contrast to lua_tointeger() which is "truncated
in some non-specified way."
This commit is contained in:
rxi
2016-10-14 21:47:40 +01:00
parent d775f36960
commit 4f771230fb
3 changed files with 32 additions and 32 deletions

View File

@@ -99,7 +99,7 @@ int l_mouse_isDown(lua_State *L) {
int res = 0;
int i;
for (i = 1; i <= n; i++) {
int idx = luaL_checkinteger(L, i) - 1;
int idx = luaL_checknumber(L, i) - 1;
if (idx >= 0 && idx < MOUSE_BUTTON_MAX) {
res |= mouse_buttonsDown[idx];
}