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
+10 -10
View File
@@ -158,8 +158,8 @@ static pushpixel pushFormats[PIXELFORMAT_MAX_ENUM] = {};
int w_ImageData_getPixel(lua_State *L)
{
ImageData *t = luax_checkimagedata(L, 1);
int x = (int) luaL_checknumber(L, 2);
int y = (int) luaL_checknumber(L, 3);
int x = (int) luaL_checkinteger(L, 2);
int y = (int) luaL_checkinteger(L, 3);
PixelFormat format = t->getFormat();
@@ -172,8 +172,8 @@ int w_ImageData_getPixel(lua_State *L)
int w_ImageData_setPixel(lua_State *L)
{
ImageData *t = luax_checkimagedata(L, 1);
int x = (int) luaL_checknumber(L, 2);
int y = (int) luaL_checknumber(L, 3);
int x = (int) luaL_checkinteger(L, 2);
int y = (int) luaL_checkinteger(L, 3);
PixelFormat format = t->getFormat();
@@ -247,12 +247,12 @@ int w_ImageData_paste(lua_State *L)
{
ImageData *t = luax_checkimagedata(L, 1);
ImageData *src = luax_checkimagedata(L, 2);
int dx = (int) luaL_checknumber(L, 3);
int dy = (int) luaL_checknumber(L, 4);
int sx = (int) luaL_optnumber(L, 5, 0);
int sy = (int) luaL_optnumber(L, 6, 0);
int sw = (int) luaL_optnumber(L, 7, src->getWidth());
int sh = (int) luaL_optnumber(L, 8, src->getHeight());
int dx = (int) luaL_checkinteger(L, 3);
int dy = (int) luaL_checkinteger(L, 4);
int sx = (int) luaL_optinteger(L, 5, 0);
int sy = (int) luaL_optinteger(L, 6, 0);
int sw = (int) luaL_optinteger(L, 7, src->getWidth());
int sh = (int) luaL_optinteger(L, 8, src->getHeight());
t->paste((love::image::ImageData *)src, dx, dy, sx, sy, sw, sh);
return 0;
}