Browse Source

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

--HG--
branch : minor
Alex Szpakowski 8 years ago
parent
commit
34ebe18f14

+ 1 - 1
src/modules/audio/wrap_Audio.cpp

@@ -84,7 +84,7 @@ int w_newQueueableSource(lua_State *L)
 	Source *t = nullptr;
 	Source *t = nullptr;
 
 
 	luax_catchexcept(L, [&]() {
 	luax_catchexcept(L, [&]() {
-		t = instance()->newSource((int)luaL_checknumber(L, 1), (int)luaL_checknumber(L, 2), (int)luaL_checknumber(L, 3), (int)luaL_optnumber(L, 4, 0));
+		t = instance()->newSource((int)luaL_checkinteger(L, 1), (int)luaL_checkinteger(L, 2), (int)luaL_checkinteger(L, 3), (int)luaL_optinteger(L, 4, 0));
 	});
 	});
 
 
 	if (t != nullptr)
 	if (t != nullptr)

+ 3 - 3
src/modules/font/wrap_Font.cpp

@@ -72,7 +72,7 @@ int w_newTrueTypeRasterizer(lua_State *L)
 	if (lua_type(L, 1) == LUA_TNUMBER || lua_isnone(L, 1))
 	if (lua_type(L, 1) == LUA_TNUMBER || lua_isnone(L, 1))
 	{
 	{
 		// First argument is a number: use the default TrueType font.
 		// First argument is a number: use the default TrueType font.
-		int size = (int) luaL_optnumber(L, 1, 12);
+		int size = (int) luaL_optinteger(L, 1, 12);
 
 
 		const char *hintstr = lua_isnoneornil(L, 2) ? nullptr : luaL_checkstring(L, 2);
 		const char *hintstr = lua_isnoneornil(L, 2) ? nullptr : luaL_checkstring(L, 2);
 		if (hintstr && !TrueTypeRasterizer::getConstant(hintstr, hinting))
 		if (hintstr && !TrueTypeRasterizer::getConstant(hintstr, hinting))
@@ -98,7 +98,7 @@ int w_newTrueTypeRasterizer(lua_State *L)
 		else
 		else
 			d = filesystem::luax_getfiledata(L, 1);
 			d = filesystem::luax_getfiledata(L, 1);
 
 
-		int size = (int) luaL_optnumber(L, 2, 12);
+		int size = (int) luaL_optinteger(L, 2, 12);
 
 
 		const char *hintstr = lua_isnoneornil(L, 3) ? nullptr : luaL_checkstring(L, 3);
 		const char *hintstr = lua_isnoneornil(L, 3) ? nullptr : luaL_checkstring(L, 3);
 		if (hintstr && !TrueTypeRasterizer::getConstant(hintstr, hinting))
 		if (hintstr && !TrueTypeRasterizer::getConstant(hintstr, hinting))
@@ -180,7 +180,7 @@ int w_newImageRasterizer(lua_State *L)
 
 
 	image::ImageData *d = luax_checktype<image::ImageData>(L, 1);
 	image::ImageData *d = luax_checktype<image::ImageData>(L, 1);
 	std::string glyphs = luax_checkstring(L, 2);
 	std::string glyphs = luax_checkstring(L, 2);
-	int extraspacing = (int) luaL_optnumber(L, 3, 0);
+	int extraspacing = (int) luaL_optinteger(L, 3, 0);
 	float pixeldensity = (float) luaL_optnumber(L, 4, 1.0);
 	float pixeldensity = (float) luaL_optnumber(L, 4, 1.0);
 
 
 	luax_catchexcept(L, [&](){ t = instance()->newImageRasterizer(d, glyphs, extraspacing, pixeldensity); });
 	luax_catchexcept(L, [&](){ t = instance()->newImageRasterizer(d, glyphs, extraspacing, pixeldensity); });

+ 1 - 1
src/modules/graphics/opengl/Mesh.cpp

@@ -96,7 +96,7 @@ void Mesh::drawInstanced(love::graphics::Graphics *gfx, const love::Matrix4 &m,
 	if (vertexCount <= 0 || instancecount <= 0)
 	if (vertexCount <= 0 || instancecount <= 0)
 		return;
 		return;
 
 
-	if (instancecount > 1 && !gl.isInstancingSupported())
+	if (instancecount > 1 && !gfx->getCapabilities().features[Graphics::FEATURE_INSTANCING])
 		throw love::Exception("Instancing is not supported on this system.");
 		throw love::Exception("Instancing is not supported on this system.");
 
 
 	gfx->flushStreamDraws();
 	gfx->flushStreamDraws();

+ 1 - 1
src/modules/graphics/wrap_Canvas.cpp

@@ -46,7 +46,7 @@ int w_Canvas_renderTo(lua_State *L)
 
 
 	if (rt.canvas->getTextureType() != TEXTURE_2D)
 	if (rt.canvas->getTextureType() != TEXTURE_2D)
 	{
 	{
-		rt.slice = (int) luaL_checknumber(L, 2) - 1;
+		rt.slice = (int) luaL_checkinteger(L, 2) - 1;
 		startidx++;
 		startidx++;
 	}
 	}
 
 

+ 25 - 25
src/modules/graphics/wrap_Graphics.cpp

@@ -321,7 +321,7 @@ int w_setCanvas(lua_State *L)
 
 
 			if (i == 1 && type != TEXTURE_2D)
 			if (i == 1 && type != TEXTURE_2D)
 			{
 			{
-				target.slice = (int) luaL_checknumber(L, i + 1) - 1;
+				target.slice = (int) luaL_checkinteger(L, i + 1) - 1;
 				target.mipmap = (int) luaL_optinteger(L, i + 2, 1) - 1;
 				target.mipmap = (int) luaL_optinteger(L, i + 2, 1) - 1;
 				targets.colors.push_back(target);
 				targets.colors.push_back(target);
 				break;
 				break;
@@ -470,10 +470,10 @@ int w_setScissor(lua_State *L)
 	}
 	}
 
 
 	Rect rect;
 	Rect rect;
-	rect.x = (int) luaL_checknumber(L, 1);
-	rect.y = (int) luaL_checknumber(L, 2);
-	rect.w = (int) luaL_checknumber(L, 3);
-	rect.h = (int) luaL_checknumber(L, 4);
+	rect.x = (int) luaL_checkinteger(L, 1);
+	rect.y = (int) luaL_checkinteger(L, 2);
+	rect.w = (int) luaL_checkinteger(L, 3);
+	rect.h = (int) luaL_checkinteger(L, 4);
 
 
 	if (rect.w < 0 || rect.h < 0)
 	if (rect.w < 0 || rect.h < 0)
 		return luaL_error(L, "Can't set scissor with negative width and/or height.");
 		return luaL_error(L, "Can't set scissor with negative width and/or height.");
@@ -485,10 +485,10 @@ int w_setScissor(lua_State *L)
 int w_intersectScissor(lua_State *L)
 int w_intersectScissor(lua_State *L)
 {
 {
 	Rect rect;
 	Rect rect;
-	rect.x = (int) luaL_checknumber(L, 1);
-	rect.y = (int) luaL_checknumber(L, 2);
-	rect.w = (int) luaL_checknumber(L, 3);
-	rect.h = (int) luaL_checknumber(L, 4);
+	rect.x = (int) luaL_checkinteger(L, 1);
+	rect.y = (int) luaL_checkinteger(L, 2);
+	rect.w = (int) luaL_checkinteger(L, 3);
+	rect.h = (int) luaL_checkinteger(L, 4);
 
 
 	if (rect.w < 0 || rect.h < 0)
 	if (rect.w < 0 || rect.h < 0)
 		return luaL_error(L, "Can't set scissor with negative width and/or height.");
 		return luaL_error(L, "Can't set scissor with negative width and/or height.");
@@ -524,7 +524,7 @@ int w_stencil(lua_State *L)
 			return luaL_error(L, "Invalid stencil draw action: %s", actionstr);
 			return luaL_error(L, "Invalid stencil draw action: %s", actionstr);
 	}
 	}
 
 
-	int stencilvalue = (int) luaL_optnumber(L, 3, 1);
+	int stencilvalue = (int) luaL_optinteger(L, 3, 1);
 
 
 	// Fourth argument: whether to keep the contents of the stencil buffer.
 	// Fourth argument: whether to keep the contents of the stencil buffer.
 	OptionalInt stencilclear;
 	OptionalInt stencilclear;
@@ -561,7 +561,7 @@ int w_setStencilTest(lua_State *L)
 		if (!getConstant(comparestr, compare))
 		if (!getConstant(comparestr, compare))
 			return luaL_error(L, "Invalid compare mode: %s", comparestr);
 			return luaL_error(L, "Invalid compare mode: %s", comparestr);
 
 
-		comparevalue = (int) luaL_checknumber(L, 2);
+		comparevalue = (int) luaL_checkinteger(L, 2);
 	}
 	}
 
 
 	luax_catchexcept(L, [&](){ instance()->setStencilTest(compare, comparevalue); });
 	luax_catchexcept(L, [&](){ instance()->setStencilTest(compare, comparevalue); });
@@ -942,14 +942,14 @@ int w_newQuad(lua_State *L)
 	}
 	}
 	else if (luax_istype(L, 6, Texture::type))
 	else if (luax_istype(L, 6, Texture::type))
 	{
 	{
-		layer = (int) luaL_checknumber(L, 5) - 1;
+		layer = (int) luaL_checkinteger(L, 5) - 1;
 		Texture *texture = luax_checktexture(L, 6);
 		Texture *texture = luax_checktexture(L, 6);
 		sw = texture->getWidth();
 		sw = texture->getWidth();
 		sh = texture->getHeight();
 		sh = texture->getHeight();
 	}
 	}
 	else if (!lua_isnoneornil(L, 7))
 	else if (!lua_isnoneornil(L, 7))
 	{
 	{
-		layer = (int) luaL_checknumber(L, 5) - 1;
+		layer = (int) luaL_checkinteger(L, 5) - 1;
 		sw = luaL_checknumber(L, 6);
 		sw = luaL_checknumber(L, 6);
 		sh = luaL_checknumber(L, 7);
 		sh = luaL_checknumber(L, 7);
 	}
 	}
@@ -1030,7 +1030,7 @@ int w_newSpriteBatch(lua_State *L)
 	luax_checkgraphicscreated(L);
 	luax_checkgraphicscreated(L);
 
 
 	Texture *texture = luax_checktexture(L, 1);
 	Texture *texture = luax_checktexture(L, 1);
-	int size = (int) luaL_optnumber(L, 2, 1000);
+	int size = (int) luaL_optinteger(L, 2, 1000);
 	vertex::Usage usage = vertex::USAGE_DYNAMIC;
 	vertex::Usage usage = vertex::USAGE_DYNAMIC;
 	if (lua_gettop(L) > 2)
 	if (lua_gettop(L) > 2)
 	{
 	{
@@ -1075,8 +1075,8 @@ int w_newCanvas(lua_State *L)
 	Canvas::Settings settings;
 	Canvas::Settings settings;
 
 
 	// check if width and height are given. else default to screen dimensions.
 	// check if width and height are given. else default to screen dimensions.
-	settings.width  = (int) luaL_optnumber(L, 1, instance()->getWidth());
-	settings.height = (int) luaL_optnumber(L, 2, instance()->getHeight());
+	settings.width  = (int) luaL_optinteger(L, 1, instance()->getWidth());
+	settings.height = (int) luaL_optinteger(L, 2, instance()->getHeight());
 
 
 	// Default to the screen's current pixel density scale.
 	// Default to the screen's current pixel density scale.
 	settings.pixeldensity = instance()->getScreenPixelDensity();
 	settings.pixeldensity = instance()->getScreenPixelDensity();
@@ -1085,7 +1085,7 @@ int w_newCanvas(lua_State *L)
 
 
 	if (lua_isnumber(L, 3))
 	if (lua_isnumber(L, 3))
 	{
 	{
-		settings.layers = (int) luaL_checknumber(L, 3);
+		settings.layers = (int) luaL_checkinteger(L, 3);
 		settings.type = TEXTURE_2D_ARRAY;
 		settings.type = TEXTURE_2D_ARRAY;
 		startidx = 4;
 		startidx = 4;
 	}
 	}
@@ -1352,7 +1352,7 @@ static Mesh *newStandardMesh(lua_State *L)
 	}
 	}
 	else
 	else
 	{
 	{
-		int count = (int) luaL_checknumber(L, 1);
+		int count = (int) luaL_checkinteger(L, 1);
 		luax_catchexcept(L, [&](){ t = instance()->newMesh(count, drawmode, usage); });
 		luax_catchexcept(L, [&](){ t = instance()->newMesh(count, drawmode, usage); });
 	}
 	}
 
 
@@ -1397,7 +1397,7 @@ static Mesh *newCustomMesh(lua_State *L)
 			return nullptr;
 			return nullptr;
 		}
 		}
 
 
-		format.components = (int) luaL_checknumber(L, -1);
+		format.components = (int) luaL_checkinteger(L, -1);
 		if (format.components <= 0 || format.components > 4)
 		if (format.components <= 0 || format.components > 4)
 		{
 		{
 			luaL_error(L, "Number of vertex attribute components must be between 1 and 4 (got %d)", format.components);
 			luaL_error(L, "Number of vertex attribute components must be between 1 and 4 (got %d)", format.components);
@@ -1410,7 +1410,7 @@ static Mesh *newCustomMesh(lua_State *L)
 
 
 	if (lua_isnumber(L, 2))
 	if (lua_isnumber(L, 2))
 	{
 	{
-		int vertexcount = (int) luaL_checknumber(L, 2);
+		int vertexcount = (int) luaL_checkinteger(L, 2);
 		luax_catchexcept(L, [&](){ t = instance()->newMesh(vertexformat, vertexcount, drawmode, usage); });
 		luax_catchexcept(L, [&](){ t = instance()->newMesh(vertexformat, vertexcount, drawmode, usage); });
 	}
 	}
 	else if (luax_istype(L, 2, Data::type))
 	else if (luax_istype(L, 2, Data::type))
@@ -2135,7 +2135,7 @@ int w_drawLayer(lua_State *L)
 {
 {
 	Texture *texture = luax_checktexture(L, 1);
 	Texture *texture = luax_checktexture(L, 1);
 	Quad *quad = nullptr;
 	Quad *quad = nullptr;
-	int layer = (int) luaL_checknumber(L, 2) - 1;
+	int layer = (int) luaL_checkinteger(L, 2) - 1;
 	int startidx = 3;
 	int startidx = 3;
 
 
 	if (luax_istype(L, startidx, Quad::type))
 	if (luax_istype(L, startidx, Quad::type))
@@ -2403,7 +2403,7 @@ int w_rectangle(lua_State *L)
 		luax_catchexcept(L, [&](){ instance()->rectangle(mode, x, y, w, h, rx, ry); });
 		luax_catchexcept(L, [&](){ instance()->rectangle(mode, x, y, w, h, rx, ry); });
 	else
 	else
 	{
 	{
-		int points = (int) luaL_checknumber(L, 8);
+		int points = (int) luaL_checkinteger(L, 8);
 		luax_catchexcept(L, [&](){ instance()->rectangle(mode, x, y, w, h, rx, ry, points); });
 		luax_catchexcept(L, [&](){ instance()->rectangle(mode, x, y, w, h, rx, ry, points); });
 	}
 	}
 
 
@@ -2425,7 +2425,7 @@ int w_circle(lua_State *L)
 		luax_catchexcept(L, [&](){ instance()->circle(mode, x, y, radius); });
 		luax_catchexcept(L, [&](){ instance()->circle(mode, x, y, radius); });
 	else
 	else
 	{
 	{
-		int points = (int) luaL_checknumber(L, 5);
+		int points = (int) luaL_checkinteger(L, 5);
 		luax_catchexcept(L, [&](){ instance()->circle(mode, x, y, radius, points); });
 		luax_catchexcept(L, [&](){ instance()->circle(mode, x, y, radius, points); });
 	}
 	}
 
 
@@ -2448,7 +2448,7 @@ int w_ellipse(lua_State *L)
 		luax_catchexcept(L, [&](){ instance()->ellipse(mode, x, y, a, b); });
 		luax_catchexcept(L, [&](){ instance()->ellipse(mode, x, y, a, b); });
 	else
 	else
 	{
 	{
-		int points = (int) luaL_checknumber(L, 6);
+		int points = (int) luaL_checkinteger(L, 6);
 		luax_catchexcept(L, [&](){ instance()->ellipse(mode, x, y, a, b, points); });
 		luax_catchexcept(L, [&](){ instance()->ellipse(mode, x, y, a, b, points); });
 	}
 	}
 
 
@@ -2485,7 +2485,7 @@ int w_arc(lua_State *L)
 		luax_catchexcept(L, [&](){ instance()->arc(drawmode, arcmode, x, y, radius, angle1, angle2); });
 		luax_catchexcept(L, [&](){ instance()->arc(drawmode, arcmode, x, y, radius, angle1, angle2); });
 	else
 	else
 	{
 	{
-		int points = (int) luaL_checknumber(L, startidx + 5);
+		int points = (int) luaL_checkinteger(L, startidx + 5);
 		luax_catchexcept(L, [&](){ instance()->arc(drawmode, arcmode, x, y, radius, angle1, angle2, points); });
 		luax_catchexcept(L, [&](){ instance()->arc(drawmode, arcmode, x, y, radius, angle1, angle2, points); });
 	}
 	}
 
 

+ 3 - 3
src/modules/graphics/wrap_Image.cpp

@@ -56,12 +56,12 @@ int w_Image_replacePixels(lua_State *L)
 
 
 	if (i->getTextureType() != TEXTURE_2D)
 	if (i->getTextureType() != TEXTURE_2D)
 	{
 	{
-		slice = (int) luaL_checknumber(L, 3) - 1;
+		slice = (int) luaL_checkinteger(L, 3) - 1;
 		if (!reloadmipmaps)
 		if (!reloadmipmaps)
-			mipmap = (int) luaL_optnumber(L, 4, 1) - 1;
+			mipmap = (int) luaL_optinteger(L, 4, 1) - 1;
 	}
 	}
 	else if (!reloadmipmaps)
 	else if (!reloadmipmaps)
-		mipmap = (int) luaL_optnumber(L, 3, 1) - 1;
+		mipmap = (int) luaL_optinteger(L, 3, 1) - 1;
 
 
 	luax_catchexcept(L, [&](){ i->replacePixels(id, slice, mipmap, reloadmipmaps); });
 	luax_catchexcept(L, [&](){ i->replacePixels(id, slice, mipmap, reloadmipmaps); });
 	return 0;
 	return 0;

+ 3 - 3
src/modules/graphics/wrap_Mesh.cpp

@@ -386,7 +386,7 @@ int w_Mesh_setVertexMap(lua_State *L)
 
 
 		size_t datatypesize = vertex::getIndexDataSize(indextype);
 		size_t datatypesize = vertex::getIndexDataSize(indextype);
 
 
-		int indexcount = (int) luaL_optnumber(L, 4, d->getSize() / datatypesize);
+		int indexcount = (int) luaL_optinteger(L, 4, d->getSize() / datatypesize);
 
 
 		if (indexcount < 1 || indexcount * datatypesize > d->getSize())
 		if (indexcount < 1 || indexcount * datatypesize > d->getSize())
 			return luaL_error(L, "Invalid index count: %d", indexcount);
 			return luaL_error(L, "Invalid index count: %d", indexcount);
@@ -515,8 +515,8 @@ int w_Mesh_setDrawRange(lua_State *L)
 		t->setDrawRange();
 		t->setDrawRange();
 	else
 	else
 	{
 	{
-		int start = (int) luaL_checknumber(L, 2) - 1;
-		int count = (int) luaL_checknumber(L, 3);
+		int start = (int) luaL_checkinteger(L, 2) - 1;
+		int count = (int) luaL_checkinteger(L, 3);
 		luax_catchexcept(L, [&](){ t->setDrawRange(start, count); });
 		luax_catchexcept(L, [&](){ t->setDrawRange(start, count); });
 	}
 	}
 
 

+ 1 - 1
src/modules/graphics/wrap_ParticleSystem.cpp

@@ -699,7 +699,7 @@ int w_ParticleSystem_reset(lua_State *L)
 int w_ParticleSystem_emit(lua_State *L)
 int w_ParticleSystem_emit(lua_State *L)
 {
 {
 	ParticleSystem *t = luax_checkparticlesystem(L, 1);
 	ParticleSystem *t = luax_checkparticlesystem(L, 1);
-	int num = (int) luaL_checknumber(L, 2);
+	int num = (int) luaL_checkinteger(L, 2);
 	t->emit(num);
 	t->emit(num);
 	return 0;
 	return 0;
 }
 }

+ 1 - 1
src/modules/graphics/wrap_Quad.cpp

@@ -77,7 +77,7 @@ int w_Quad_getTextureDimensions(lua_State *L)
 int w_Quad_setLayer(lua_State *L)
 int w_Quad_setLayer(lua_State *L)
 {
 {
 	Quad *quad = luax_checkquad(L, 1);
 	Quad *quad = luax_checkquad(L, 1);
-	int layer = (int) luaL_checknumber(L, 2) - 1;
+	int layer = (int) luaL_checkinteger(L, 2) - 1;
 	quad->setLayer(layer);
 	quad->setLayer(layer);
 	return 0;
 	return 0;
 }
 }

+ 5 - 5
src/modules/graphics/wrap_SpriteBatch.cpp

@@ -63,7 +63,7 @@ static inline int w_SpriteBatch_add_or_set(lua_State *L, SpriteBatch *t, int sta
 static int w_SpriteBatch_addLayer_or_setLayer(lua_State *L, SpriteBatch *t, int startidx, int index)
 static int w_SpriteBatch_addLayer_or_setLayer(lua_State *L, SpriteBatch *t, int startidx, int index)
 {
 {
 	Quad *quad = nullptr;
 	Quad *quad = nullptr;
-	int layer = (int) luaL_checknumber(L, startidx) - 1;
+	int layer = (int) luaL_checkinteger(L, startidx) - 1;
 	startidx++;
 	startidx++;
 
 
 	if (luax_istype(L, startidx, Quad::type))
 	if (luax_istype(L, startidx, Quad::type))
@@ -101,7 +101,7 @@ int w_SpriteBatch_add(lua_State *L)
 int w_SpriteBatch_set(lua_State *L)
 int w_SpriteBatch_set(lua_State *L)
 {
 {
 	SpriteBatch *t = luax_checkspritebatch(L, 1);
 	SpriteBatch *t = luax_checkspritebatch(L, 1);
-	int index = (int) luaL_checknumber(L, 2) - 1;
+	int index = (int) luaL_checkinteger(L, 2) - 1;
 
 
 	w_SpriteBatch_add_or_set(L, t, 3, index);
 	w_SpriteBatch_add_or_set(L, t, 3, index);
 
 
@@ -121,7 +121,7 @@ int w_SpriteBatch_addLayer(lua_State *L)
 int w_SpriteBatch_setLayer(lua_State *L)
 int w_SpriteBatch_setLayer(lua_State *L)
 {
 {
 	SpriteBatch *t = luax_checkspritebatch(L, 1);
 	SpriteBatch *t = luax_checkspritebatch(L, 1);
-	int index = (int) luaL_checknumber(L, 2) - 1;
+	int index = (int) luaL_checkinteger(L, 2) - 1;
 
 
 	w_SpriteBatch_addLayer_or_setLayer(L, t, 3, index);
 	w_SpriteBatch_addLayer_or_setLayer(L, t, 3, index);
 	
 	
@@ -251,8 +251,8 @@ int w_SpriteBatch_setDrawRange(lua_State *L)
 		t->setDrawRange();
 		t->setDrawRange();
 	else
 	else
 	{
 	{
-		int start = (int) luaL_checknumber(L, 2) - 1;
-		int count = (int) luaL_checknumber(L, 3);
+		int start = (int) luaL_checkinteger(L, 2) - 1;
+		int count = (int) luaL_checkinteger(L, 3);
 		luax_catchexcept(L, [&](){ t->setDrawRange(start, count); });
 		luax_catchexcept(L, [&](){ t->setDrawRange(start, count); });
 	}
 	}
 
 

+ 3 - 3
src/modules/graphics/wrap_Text.cpp

@@ -183,7 +183,7 @@ int w_Text_getFont(lua_State *L)
 int w_Text_getWidth(lua_State *L)
 int w_Text_getWidth(lua_State *L)
 {
 {
 	Text *t = luax_checktext(L, 1);
 	Text *t = luax_checktext(L, 1);
-	int index = (int) luaL_optnumber(L, 2, 0) - 1;
+	int index = (int) luaL_optinteger(L, 2, 0) - 1;
 	lua_pushnumber(L, t->getWidth(index));
 	lua_pushnumber(L, t->getWidth(index));
 	return 1;
 	return 1;
 }
 }
@@ -191,7 +191,7 @@ int w_Text_getWidth(lua_State *L)
 int w_Text_getHeight(lua_State *L)
 int w_Text_getHeight(lua_State *L)
 {
 {
 	Text *t = luax_checktext(L, 1);
 	Text *t = luax_checktext(L, 1);
-	int index = (int) luaL_optnumber(L, 2, 0) - 1;
+	int index = (int) luaL_optinteger(L, 2, 0) - 1;
 	lua_pushnumber(L, t->getHeight(index));
 	lua_pushnumber(L, t->getHeight(index));
 	return 1;
 	return 1;
 }
 }
@@ -199,7 +199,7 @@ int w_Text_getHeight(lua_State *L)
 int w_Text_getDimensions(lua_State *L)
 int w_Text_getDimensions(lua_State *L)
 {
 {
 	Text *t = luax_checktext(L, 1);
 	Text *t = luax_checktext(L, 1);
-	int index = (int) luaL_optnumber(L, 2, 0) - 1;
+	int index = (int) luaL_optinteger(L, 2, 0) - 1;
 	lua_pushnumber(L, t->getWidth(index));
 	lua_pushnumber(L, t->getWidth(index));
 	lua_pushnumber(L, t->getHeight(index));
 	lua_pushnumber(L, t->getHeight(index));
 	return 2;
 	return 2;

+ 3 - 3
src/modules/image/wrap_CompressedImageData.cpp

@@ -43,7 +43,7 @@ int w_CompressedImageData_clone(lua_State *L)
 int w_CompressedImageData_getWidth(lua_State *L)
 int w_CompressedImageData_getWidth(lua_State *L)
 {
 {
 	CompressedImageData *t = luax_checkcompressedimagedata(L, 1);
 	CompressedImageData *t = luax_checkcompressedimagedata(L, 1);
-	int miplevel = (int) luaL_optnumber(L, 2, 1);
+	int miplevel = (int) luaL_optinteger(L, 2, 1);
 	int width = 0;
 	int width = 0;
 
 
 	luax_catchexcept(L, [&](){ width = t->getWidth(miplevel - 1); });
 	luax_catchexcept(L, [&](){ width = t->getWidth(miplevel - 1); });
@@ -55,7 +55,7 @@ int w_CompressedImageData_getWidth(lua_State *L)
 int w_CompressedImageData_getHeight(lua_State *L)
 int w_CompressedImageData_getHeight(lua_State *L)
 {
 {
 	CompressedImageData *t = luax_checkcompressedimagedata(L, 1);
 	CompressedImageData *t = luax_checkcompressedimagedata(L, 1);
-	int miplevel = (int) luaL_optnumber(L, 2, 1);
+	int miplevel = (int) luaL_optinteger(L, 2, 1);
 	int height = 0;
 	int height = 0;
 
 
 	luax_catchexcept(L, [&](){ height = t->getHeight(miplevel - 1); });
 	luax_catchexcept(L, [&](){ height = t->getHeight(miplevel - 1); });
@@ -67,7 +67,7 @@ int w_CompressedImageData_getHeight(lua_State *L)
 int w_CompressedImageData_getDimensions(lua_State *L)
 int w_CompressedImageData_getDimensions(lua_State *L)
 {
 {
 	CompressedImageData *t = luax_checkcompressedimagedata(L, 1);
 	CompressedImageData *t = luax_checkcompressedimagedata(L, 1);
-	int miplevel = (int) luaL_optnumber(L, 2, 1);
+	int miplevel = (int) luaL_optinteger(L, 2, 1);
 	int width = 0, height = 0;
 	int width = 0, height = 0;
 
 
 	luax_catchexcept(L, [&]()
 	luax_catchexcept(L, [&]()

+ 2 - 2
src/modules/image/wrap_Image.cpp

@@ -39,8 +39,8 @@ int w_newImageData(lua_State *L)
 	// Case 1: width & height.
 	// Case 1: width & height.
 	if (lua_isnumber(L, 1))
 	if (lua_isnumber(L, 1))
 	{
 	{
-		int w = (int) luaL_checknumber(L, 1);
-		int h = (int) luaL_checknumber(L, 2);
+		int w = (int) luaL_checkinteger(L, 1);
+		int h = (int) luaL_checkinteger(L, 2);
 		if (w <= 0 || h <= 0)
 		if (w <= 0 || h <= 0)
 			return luaL_error(L, "Invalid image size.");
 			return luaL_error(L, "Invalid image size.");
 
 

+ 10 - 10
src/modules/image/wrap_ImageData.cpp

@@ -158,8 +158,8 @@ static pushpixel pushFormats[PIXELFORMAT_MAX_ENUM] = {};
 int w_ImageData_getPixel(lua_State *L)
 int w_ImageData_getPixel(lua_State *L)
 {
 {
 	ImageData *t = luax_checkimagedata(L, 1);
 	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();
 	PixelFormat format = t->getFormat();
 
 
@@ -172,8 +172,8 @@ int w_ImageData_getPixel(lua_State *L)
 int w_ImageData_setPixel(lua_State *L)
 int w_ImageData_setPixel(lua_State *L)
 {
 {
 	ImageData *t = luax_checkimagedata(L, 1);
 	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();
 	PixelFormat format = t->getFormat();
 
 
@@ -247,12 +247,12 @@ int w_ImageData_paste(lua_State *L)
 {
 {
 	ImageData *t = luax_checkimagedata(L, 1);
 	ImageData *t = luax_checkimagedata(L, 1);
 	ImageData *src = luax_checkimagedata(L, 2);
 	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);
 	t->paste((love::image::ImageData *)src, dx, dy, sx, sy, sw, sh);
 	return 0;
 	return 0;
 }
 }

+ 4 - 4
src/modules/joystick/wrap_Joystick.cpp

@@ -95,7 +95,7 @@ int w_Joystick_getHatCount(lua_State *L)
 int w_Joystick_getAxis(lua_State *L)
 int w_Joystick_getAxis(lua_State *L)
 {
 {
 	Joystick *j = luax_checkjoystick(L, 1);
 	Joystick *j = luax_checkjoystick(L, 1);
-	int axisindex = (int) luaL_checknumber(L, 2) - 1;
+	int axisindex = (int) luaL_checkinteger(L, 2) - 1;
 	lua_pushnumber(L, j->getAxis(axisindex));
 	lua_pushnumber(L, j->getAxis(axisindex));
 	return 1;
 	return 1;
 }
 }
@@ -114,7 +114,7 @@ int w_Joystick_getAxes(lua_State *L)
 int w_Joystick_getHat(lua_State *L)
 int w_Joystick_getHat(lua_State *L)
 {
 {
 	Joystick *j = luax_checkjoystick(L, 1);
 	Joystick *j = luax_checkjoystick(L, 1);
-	int hatindex = (int) luaL_checknumber(L, 2) - 1;
+	int hatindex = (int) luaL_checkinteger(L, 2) - 1;
 
 
 	Joystick::Hat h = j->getHat(hatindex);
 	Joystick::Hat h = j->getHat(hatindex);
 
 
@@ -143,14 +143,14 @@ int w_Joystick_isDown(lua_State *L)
 		for (int i = 0; i < num; i++)
 		for (int i = 0; i < num; i++)
 		{
 		{
 			lua_rawgeti(L, 2, i + 1);
 			lua_rawgeti(L, 2, i + 1);
-			buttons.push_back((int) luaL_checknumber(L, -1) - 1);
+			buttons.push_back((int) luaL_checkinteger(L, -1) - 1);
 			lua_pop(L, 1);
 			lua_pop(L, 1);
 		}
 		}
 	}
 	}
 	else
 	else
 	{
 	{
 		for (int i = 0; i < num; i++)
 		for (int i = 0; i < num; i++)
-			buttons.push_back((int) luaL_checknumber(L, i + 2) - 1);
+			buttons.push_back((int) luaL_checkinteger(L, i + 2) - 1);
 	}
 	}
 
 
 	luax_pushboolean(L, j->isDown(buttons));
 	luax_pushboolean(L, j->isDown(buttons));

+ 3 - 3
src/modules/joystick/wrap_JoystickModule.cpp

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

+ 3 - 3
src/modules/love/love.cpp

@@ -225,9 +225,9 @@ static int w_love_isVersionCompatible(lua_State *L)
 		version = luaL_checkstring(L, 1);
 		version = luaL_checkstring(L, 1);
 	else
 	else
 	{
 	{
-		int major = (int) luaL_checknumber(L, 1);
-		int minor = (int) luaL_checknumber(L, 2);
-		int rev   = (int) luaL_checknumber(L, 3);
+		int major = (int) luaL_checkinteger(L, 1);
+		int minor = (int) luaL_checkinteger(L, 2);
+		int rev   = (int) luaL_checkinteger(L, 3);
 
 
 		// Convert the numbers to a string, since VERSION_COMPATIBILITY is an
 		// Convert the numbers to a string, since VERSION_COMPATIBILITY is an
 		// array of version strings.
 		// array of version strings.

+ 6 - 6
src/modules/math/wrap_BezierCurve.cpp

@@ -52,7 +52,7 @@ int w_BezierCurve_getDerivative(lua_State *L)
 int w_BezierCurve_getControlPoint(lua_State *L)
 int w_BezierCurve_getControlPoint(lua_State *L)
 {
 {
 	BezierCurve *curve = luax_checkbeziercurve(L, 1);
 	BezierCurve *curve = luax_checkbeziercurve(L, 1);
-	int idx = (int) luaL_checknumber(L, 2);
+	int idx = (int) luaL_checkinteger(L, 2);
 
 
 	if (idx > 0) // 1-indexing
 	if (idx > 0) // 1-indexing
 		idx--;
 		idx--;
@@ -69,7 +69,7 @@ int w_BezierCurve_getControlPoint(lua_State *L)
 int w_BezierCurve_setControlPoint(lua_State *L)
 int w_BezierCurve_setControlPoint(lua_State *L)
 {
 {
 	BezierCurve *curve = luax_checkbeziercurve(L, 1);
 	BezierCurve *curve = luax_checkbeziercurve(L, 1);
-	int idx = (int) luaL_checknumber(L, 2);
+	int idx = (int) luaL_checkinteger(L, 2);
 	float vx = (float) luaL_checknumber(L, 3);
 	float vx = (float) luaL_checknumber(L, 3);
 	float vy = (float) luaL_checknumber(L, 4);
 	float vy = (float) luaL_checknumber(L, 4);
 
 
@@ -85,7 +85,7 @@ int w_BezierCurve_insertControlPoint(lua_State *L)
 	BezierCurve *curve = luax_checkbeziercurve(L, 1);
 	BezierCurve *curve = luax_checkbeziercurve(L, 1);
 	float vx = (float) luaL_checknumber(L, 2);
 	float vx = (float) luaL_checknumber(L, 2);
 	float vy = (float) luaL_checknumber(L, 3);
 	float vy = (float) luaL_checknumber(L, 3);
-	int idx = (int) luaL_optnumber(L, 4, -1);
+	int idx = (int) luaL_optinteger(L, 4, -1);
 
 
 	if (idx > 0) // 1-indexing
 	if (idx > 0) // 1-indexing
 		idx--;
 		idx--;
@@ -97,7 +97,7 @@ int w_BezierCurve_insertControlPoint(lua_State *L)
 int w_BezierCurve_removeControlPoint(lua_State *L)
 int w_BezierCurve_removeControlPoint(lua_State *L)
 {
 {
 	BezierCurve *curve = luax_checkbeziercurve(L, 1);
 	BezierCurve *curve = luax_checkbeziercurve(L, 1);
-	int idx = (int) luaL_checknumber(L, 2);
+	int idx = (int) luaL_checkinteger(L, 2);
 
 
 	if (idx > 0) // 1-indexing
 	if (idx > 0) // 1-indexing
 		idx--;
 		idx--;
@@ -174,7 +174,7 @@ int w_BezierCurve_getSegment(lua_State *L)
 int w_BezierCurve_render(lua_State *L)
 int w_BezierCurve_render(lua_State *L)
 {
 {
 	BezierCurve *curve = luax_checkbeziercurve(L, 1);
 	BezierCurve *curve = luax_checkbeziercurve(L, 1);
-	int accuracy = (int) luaL_optnumber(L, 2, 5);
+	int accuracy = (int) luaL_optinteger(L, 2, 5);
 
 
 	std::vector<Vector2> points;
 	std::vector<Vector2> points;
 	luax_catchexcept(L, [&](){ points = curve->render(accuracy); });
 	luax_catchexcept(L, [&](){ points = curve->render(accuracy); });
@@ -196,7 +196,7 @@ int w_BezierCurve_renderSegment(lua_State *L)
 	BezierCurve *curve = luax_checkbeziercurve(L, 1);
 	BezierCurve *curve = luax_checkbeziercurve(L, 1);
 	double start = luaL_checknumber(L, 2);
 	double start = luaL_checknumber(L, 2);
 	double end = luaL_checknumber(L, 3);
 	double end = luaL_checknumber(L, 3);
-	int accuracy = (int) luaL_optnumber(L, 4, 5);
+	int accuracy = (int) luaL_optinteger(L, 4, 5);
 
 
 	std::vector<Vector2> points;
 	std::vector<Vector2> points;
 	luax_catchexcept(L, [&](){ points = curve->renderSegment(start, end, accuracy); });
 	luax_catchexcept(L, [&](){ points = curve->renderSegment(start, end, accuracy); });

+ 1 - 1
src/modules/math/wrap_Math.cpp

@@ -354,7 +354,7 @@ int w_compress(lua_State *L)
 	if (fstr && !Compressor::getConstant(fstr, format))
 	if (fstr && !Compressor::getConstant(fstr, format))
 		return luaL_error(L, "Invalid compressed data format: %s", fstr);
 		return luaL_error(L, "Invalid compressed data format: %s", fstr);
 
 
-	int level = (int) luaL_optnumber(L, 3, -1);
+	int level = (int) luaL_optinteger(L, 3, -1);
 
 
 	CompressedData *cdata = nullptr;
 	CompressedData *cdata = nullptr;
 	if (lua_isstring(L, 1))
 	if (lua_isstring(L, 1))

+ 4 - 4
src/modules/mouse/wrap_Mouse.cpp

@@ -41,8 +41,8 @@ int w_newCursor(lua_State *L)
 		luax_convobj(L, 1, "image", "newImageData");
 		luax_convobj(L, 1, "image", "newImageData");
 
 
 	love::image::ImageData *data = luax_checktype<love::image::ImageData>(L, 1);
 	love::image::ImageData *data = luax_checktype<love::image::ImageData>(L, 1);
-	int hotx = (int) luaL_optnumber(L, 2, 0);
-	int hoty = (int) luaL_optnumber(L, 3, 0);
+	int hotx = (int) luaL_optinteger(L, 2, 0);
+	int hoty = (int) luaL_optinteger(L, 3, 0);
 
 
 	luax_catchexcept(L, [&](){ cursor = instance()->newCursor(data, hotx, hoty); });
 	luax_catchexcept(L, [&](){ cursor = instance()->newCursor(data, hotx, hoty); });
 
 
@@ -154,14 +154,14 @@ int w_isDown(lua_State *L)
 		for (int i = 0; i < num; i++)
 		for (int i = 0; i < num; i++)
 		{
 		{
 			lua_rawgeti(L, 1, i + 1);
 			lua_rawgeti(L, 1, i + 1);
-			buttons.push_back((int) luaL_checknumber(L, -1));
+			buttons.push_back((int) luaL_checkinteger(L, -1));
 			lua_pop(L, 1);
 			lua_pop(L, 1);
 		}
 		}
 	}
 	}
 	else
 	else
 	{
 	{
 		for (int i = 0; i < num; i++)
 		for (int i = 0; i < num; i++)
-			buttons.push_back((int) luaL_checknumber(L, i + 1));
+			buttons.push_back((int) luaL_checkinteger(L, i + 1));
 	}
 	}
 
 
 	luax_pushboolean(L, instance()->isDown(buttons));
 	luax_pushboolean(L, instance()->isDown(buttons));

+ 2 - 2
src/modules/physics/box2d/Fixture.cpp

@@ -280,7 +280,7 @@ int Fixture::rayCast(lua_State *L) const
 	float p2x = Physics::scaleDown((float)luaL_checknumber(L, 3));
 	float p2x = Physics::scaleDown((float)luaL_checknumber(L, 3));
 	float p2y = Physics::scaleDown((float)luaL_checknumber(L, 4));
 	float p2y = Physics::scaleDown((float)luaL_checknumber(L, 4));
 	float maxFraction = (float)luaL_checknumber(L, 5);
 	float maxFraction = (float)luaL_checknumber(L, 5);
-	int childIndex = (int) luaL_optnumber(L, 6, 1) - 1; // Convert from 1-based index
+	int childIndex = (int) luaL_optinteger(L, 6, 1) - 1; // Convert from 1-based index
 	b2RayCastInput input;
 	b2RayCastInput input;
 	input.p1.Set(p1x, p1y);
 	input.p1.Set(p1x, p1y);
 	input.p2.Set(p2x, p2y);
 	input.p2.Set(p2x, p2y);
@@ -296,7 +296,7 @@ int Fixture::rayCast(lua_State *L) const
 
 
 int Fixture::getBoundingBox(lua_State *L) const
 int Fixture::getBoundingBox(lua_State *L) const
 {
 {
-	int childIndex = (int) luaL_optnumber(L, 1, 1) - 1; // Convert from 1-based index
+	int childIndex = (int) luaL_optinteger(L, 1, 1) - 1; // Convert from 1-based index
 	b2AABB box;
 	b2AABB box;
 	luax_catchexcept(L, [&]() { box = fixture->GetAABB(childIndex); });
 	luax_catchexcept(L, [&]() { box = fixture->GetAABB(childIndex); });
 	box = Physics::scaleUp(box);
 	box = Physics::scaleUp(box);

+ 9 - 9
src/modules/physics/box2d/Physics.cpp

@@ -31,7 +31,7 @@ namespace physics
 namespace box2d
 namespace box2d
 {
 {
 
 
-int Physics::meter = Physics::DEFAULT_METER;
+float Physics::meter = Physics::DEFAULT_METER;
 
 
 const char *Physics::getName() const
 const char *Physics::getName() const
 {
 {
@@ -323,37 +323,37 @@ int Physics::getDistance(lua_State *L)
 	return 5;
 	return 5;
 }
 }
 
 
-void Physics::setMeter(int scale)
+void Physics::setMeter(float scale)
 {
 {
 	if (scale < 1) throw love::Exception("Physics error: invalid meter");
 	if (scale < 1) throw love::Exception("Physics error: invalid meter");
 	Physics::meter = scale;
 	Physics::meter = scale;
 }
 }
 
 
-int Physics::getMeter()
+float Physics::getMeter()
 {
 {
 	return meter;
 	return meter;
 }
 }
 
 
 void Physics::scaleDown(float &x, float &y)
 void Physics::scaleDown(float &x, float &y)
 {
 {
-	x /= (float)meter;
-	y /= (float)meter;
+	x /= meter;
+	y /= meter;
 }
 }
 
 
 void Physics::scaleUp(float &x, float &y)
 void Physics::scaleUp(float &x, float &y)
 {
 {
-	x *= (float)meter;
-	y *= (float)meter;
+	x *= meter;
+	y *= meter;
 }
 }
 
 
 float Physics::scaleDown(float f)
 float Physics::scaleDown(float f)
 {
 {
-	return f/(float)meter;
+	return f/meter;
 }
 }
 
 
 float Physics::scaleUp(float f)
 float Physics::scaleUp(float f)
 {
 {
-	return f*(float)meter;
+	return f*meter;
 }
 }
 
 
 b2Vec2 Physics::scaleDown(const b2Vec2 &v)
 b2Vec2 Physics::scaleDown(const b2Vec2 &v)

+ 3 - 3
src/modules/physics/box2d/Physics.h

@@ -292,13 +292,13 @@ public:
 	 * Sets the number of pixels in one meter.
 	 * Sets the number of pixels in one meter.
 	 * @param scale The number of pixels in one meter. (1m ~= 3.3ft).
 	 * @param scale The number of pixels in one meter. (1m ~= 3.3ft).
 	 **/
 	 **/
-	static void setMeter(int scale);
+	static void setMeter(float scale);
 
 
 	/**
 	/**
 	 * Gets the number of pixels in one meter.
 	 * Gets the number of pixels in one meter.
 	 * @return The number of pixels in one meter. (1m ~= 3.3ft).
 	 * @return The number of pixels in one meter. (1m ~= 3.3ft).
 	 **/
 	 **/
-	static int getMeter();
+	static float getMeter();
 
 
 	/**
 	/**
 	 * Scales a value down according to the current meter in pixels.
 	 * Scales a value down according to the current meter in pixels.
@@ -359,7 +359,7 @@ public:
 private:
 private:
 
 
 	// The length of one meter in pixels.
 	// The length of one meter in pixels.
-	static int meter;
+	static float meter;
 }; // Physics
 }; // Physics
 
 
 } // box2d
 } // box2d

+ 2 - 2
src/modules/physics/box2d/Shape.cpp

@@ -105,7 +105,7 @@ int Shape::rayCast(lua_State *L) const
 	float x = Physics::scaleDown((float)luaL_checknumber(L, 6));
 	float x = Physics::scaleDown((float)luaL_checknumber(L, 6));
 	float y = Physics::scaleDown((float)luaL_checknumber(L, 7));
 	float y = Physics::scaleDown((float)luaL_checknumber(L, 7));
 	float r = (float)luaL_checknumber(L, 8);
 	float r = (float)luaL_checknumber(L, 8);
-	int childIndex = (int) luaL_optnumber(L, 9, 1) - 1; // Convert from 1-based index
+	int childIndex = (int) luaL_optinteger(L, 9, 1) - 1; // Convert from 1-based index
 	b2RayCastInput input;
 	b2RayCastInput input;
 	input.p1.Set(p1x, p1y);
 	input.p1.Set(p1x, p1y);
 	input.p2.Set(p2x, p2y);
 	input.p2.Set(p2x, p2y);
@@ -125,7 +125,7 @@ int Shape::computeAABB(lua_State *L) const
 	float x = Physics::scaleDown((float)luaL_checknumber(L, 1));
 	float x = Physics::scaleDown((float)luaL_checknumber(L, 1));
 	float y = Physics::scaleDown((float)luaL_checknumber(L, 2));
 	float y = Physics::scaleDown((float)luaL_checknumber(L, 2));
 	float r = (float)luaL_checknumber(L, 3);
 	float r = (float)luaL_checknumber(L, 3);
-	int childIndex = (int) luaL_optnumber(L, 4, 1) - 1; // Convert from 1-based index
+	int childIndex = (int) luaL_optinteger(L, 4, 1) - 1; // Convert from 1-based index
 	b2Transform transform(b2Vec2(x, y), b2Rot(r));
 	b2Transform transform(b2Vec2(x, y), b2Rot(r));
 	b2AABB box;
 	b2AABB box;
 	shape->ComputeAABB(&box, transform, childIndex);
 	shape->ComputeAABB(&box, transform, childIndex);

+ 2 - 2
src/modules/physics/box2d/wrap_ChainShape.cpp

@@ -65,7 +65,7 @@ int w_ChainShape_setPreviousVertex(lua_State *L)
 int w_ChainShape_getChildEdge(lua_State *L)
 int w_ChainShape_getChildEdge(lua_State *L)
 {
 {
 	ChainShape *c = luax_checkchainshape(L, 1);
 	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;
 	EdgeShape *e = 0;
 	luax_catchexcept(L, [&](){ e = c->getChildEdge(index); });
 	luax_catchexcept(L, [&](){ e = c->getChildEdge(index); });
 	luax_pushtype(L, e);
 	luax_pushtype(L, e);
@@ -84,7 +84,7 @@ int w_ChainShape_getVertexCount(lua_State *L)
 int w_ChainShape_getPoint(lua_State *L)
 int w_ChainShape_getPoint(lua_State *L)
 {
 {
 	ChainShape *c = luax_checkchainshape(L, 1);
 	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;
 	b2Vec2 v;
 	luax_catchexcept(L, [&](){ v = c->getPoint(index); });
 	luax_catchexcept(L, [&](){ v = c->getPoint(index); });
 	lua_pushnumber(L, v.x);
 	lua_pushnumber(L, v.x);

+ 4 - 4
src/modules/physics/box2d/wrap_Fixture.cpp

@@ -164,9 +164,9 @@ int w_Fixture_setFilterData(lua_State *L)
 {
 {
 	Fixture *t = luax_checkfixture(L, 1);
 	Fixture *t = luax_checkfixture(L, 1);
 	int v[3];
 	int v[3];
-	v[0] = (int) luaL_checknumber(L, 2);
-	v[1] = (int) luaL_checknumber(L, 3);
-	v[2] = (int) luaL_checknumber(L, 4);
+	v[0] = (int) luaL_checkinteger(L, 2);
+	v[1] = (int) luaL_checkinteger(L, 3);
+	v[2] = (int) luaL_checkinteger(L, 4);
 	t->setFilterData(v);
 	t->setFilterData(v);
 	return 0;
 	return 0;
 }
 }
@@ -249,7 +249,7 @@ int w_Fixture_getGroupIndex(lua_State *L)
 int w_Fixture_setGroupIndex(lua_State *L)
 int w_Fixture_setGroupIndex(lua_State *L)
 {
 {
 	Fixture *t = luax_checkfixture(L, 1);
 	Fixture *t = luax_checkfixture(L, 1);
-	int i = (int) luaL_checknumber(L, 2);
+	int i = (int) luaL_checkinteger(L, 2);
 	t->setGroupIndex(i);
 	t->setGroupIndex(i);
 	return 0;
 	return 0;
 }
 }

+ 1 - 1
src/modules/physics/box2d/wrap_Physics.cpp

@@ -471,7 +471,7 @@ int w_getDistance(lua_State *L)
 
 
 int w_setMeter(lua_State *L)
 int w_setMeter(lua_State *L)
 {
 {
-	int arg1 = (int) luaL_checknumber(L, 1);
+	float arg1 = (float) luaL_checknumber(L, 1);
 	luax_catchexcept(L, [&](){ Physics::setMeter(arg1); });
 	luax_catchexcept(L, [&](){ Physics::setMeter(arg1); });
 	return 0;
 	return 0;
 
 

+ 2 - 2
src/modules/physics/box2d/wrap_World.cpp

@@ -47,8 +47,8 @@ int w_World_update(lua_State *L)
 		luax_catchexcept(L, [&](){ t->update(dt); });
 		luax_catchexcept(L, [&](){ t->update(dt); });
 	else
 	else
 	{
 	{
-		int velocityiterations = (int) luaL_checknumber(L, 3);
-		int positioniterations = (int) luaL_checknumber(L, 4);
+		int velocityiterations = (int) luaL_checkinteger(L, 3);
+		int positioniterations = (int) luaL_checkinteger(L, 4);
 		luax_catchexcept(L, [&](){ t->update(dt, velocityiterations, positioniterations); });
 		luax_catchexcept(L, [&](){ t->update(dt, velocityiterations, positioniterations); });
 	}
 	}
 
 

+ 5 - 5
src/modules/sound/wrap_Sound.cpp

@@ -35,7 +35,7 @@ namespace sound
 int w_newDecoder(lua_State *L)
 int w_newDecoder(lua_State *L)
 {
 {
 	love::filesystem::FileData *data = love::filesystem::luax_getfiledata(L, 1);
 	love::filesystem::FileData *data = love::filesystem::luax_getfiledata(L, 1);
-	int bufferSize = (int) luaL_optnumber(L, 2, Decoder::DEFAULT_BUFFER_SIZE);
+	int bufferSize = (int) luaL_optinteger(L, 2, Decoder::DEFAULT_BUFFER_SIZE);
 
 
 	Decoder *t = nullptr;
 	Decoder *t = nullptr;
 	luax_catchexcept(L,
 	luax_catchexcept(L,
@@ -57,10 +57,10 @@ int w_newSoundData(lua_State *L)
 
 
 	if (lua_isnumber(L, 1))
 	if (lua_isnumber(L, 1))
 	{
 	{
-		int samples = (int) luaL_checknumber(L, 1);
-		int sampleRate = (int) luaL_optnumber(L, 2, Decoder::DEFAULT_SAMPLE_RATE);
-		int bitDepth = (int) luaL_optnumber(L, 3, Decoder::DEFAULT_BIT_DEPTH);
-		int channels = (int) luaL_optnumber(L, 4, Decoder::DEFAULT_CHANNELS);
+		int samples = (int) luaL_checkinteger(L, 1);
+		int sampleRate = (int) luaL_optinteger(L, 2, Decoder::DEFAULT_SAMPLE_RATE);
+		int bitDepth = (int) luaL_optinteger(L, 3, Decoder::DEFAULT_BIT_DEPTH);
+		int channels = (int) luaL_optinteger(L, 4, Decoder::DEFAULT_CHANNELS);
 
 
 		luax_catchexcept(L, [&](){ t = instance()->newSoundData(samples, sampleRate, bitDepth, channels); });
 		luax_catchexcept(L, [&](){ t = instance()->newSoundData(samples, sampleRate, bitDepth, channels); });
 	}
 	}

+ 14 - 14
src/modules/window/wrap_Window.cpp

@@ -36,7 +36,7 @@ int w_getDisplayCount(lua_State *L)
 
 
 int w_getDisplayName(lua_State *L)
 int w_getDisplayName(lua_State *L)
 {
 {
-	int index = (int) luaL_checknumber(L, 1) - 1;
+	int index = (int) luaL_checkinteger(L, 1) - 1;
 
 
 	const char *name = nullptr;
 	const char *name = nullptr;
 	luax_catchexcept(L, [&](){ name = instance()->getDisplayName(index); });
 	luax_catchexcept(L, [&](){ name = instance()->getDisplayName(index); });
@@ -105,8 +105,8 @@ static int readWindowSettings(lua_State *L, int idx, WindowSettings &settings)
 	settings.useposition = !(lua_isnoneornil(L, -2) && lua_isnoneornil(L, -1));
 	settings.useposition = !(lua_isnoneornil(L, -2) && lua_isnoneornil(L, -1));
 	if (settings.useposition)
 	if (settings.useposition)
 	{
 	{
-		settings.x = (int) luaL_optnumber(L, -2, 0);
-		settings.y = (int) luaL_optnumber(L, -1, 0);
+		settings.x = (int) luaL_optinteger(L, -2, 0);
+		settings.y = (int) luaL_optinteger(L, -1, 0);
 	}
 	}
 	lua_pop(L, 2);
 	lua_pop(L, 2);
 
 
@@ -116,8 +116,8 @@ static int readWindowSettings(lua_State *L, int idx, WindowSettings &settings)
 
 
 int w_setMode(lua_State *L)
 int w_setMode(lua_State *L)
 {
 {
-	int w = (int) luaL_checknumber(L, 1);
-	int h = (int) luaL_checknumber(L, 2);
+	int w = (int) luaL_checkinteger(L, 1);
+	int h = (int) luaL_checkinteger(L, 2);
 
 
 	if (lua_isnoneornil(L, 3))
 	if (lua_isnoneornil(L, 3))
 	{
 	{
@@ -150,8 +150,8 @@ int w_updateMode(lua_State *L)
 	if (lua_isnumber(L, 1))
 	if (lua_isnumber(L, 1))
 	{
 	{
 		idx = 3;
 		idx = 3;
-		w = (int) luaL_checknumber(L, 1);
-		h = (int) luaL_checknumber(L, 2);
+		w = (int) luaL_checkinteger(L, 1);
+		h = (int) luaL_checkinteger(L, 2);
 	}
 	}
 
 
 	if (!lua_isnoneornil(L, idx))
 	if (!lua_isnoneornil(L, idx))
@@ -232,7 +232,7 @@ int w_getFullscreenModes(lua_State *L)
 {
 {
 	int displayindex = 0;
 	int displayindex = 0;
 	if (!lua_isnoneornil(L, 1))
 	if (!lua_isnoneornil(L, 1))
-		displayindex = (int) luaL_checknumber(L, 1) - 1;
+		displayindex = (int) luaL_checkinteger(L, 1) - 1;
 	else
 	else
 	{
 	{
 		int x, y;
 		int x, y;
@@ -317,7 +317,7 @@ int w_getDesktopDimensions(lua_State *L)
 	int width = 0, height = 0;
 	int width = 0, height = 0;
 	int displayindex = 0;
 	int displayindex = 0;
 	if (!lua_isnoneornil(L, 1))
 	if (!lua_isnoneornil(L, 1))
-		displayindex = (int) luaL_checknumber(L, 1) - 1;
+		displayindex = (int) luaL_checkinteger(L, 1) - 1;
 	else
 	else
 	{
 	{
 		int x, y;
 		int x, y;
@@ -331,12 +331,12 @@ int w_getDesktopDimensions(lua_State *L)
 
 
 int w_setPosition(lua_State *L)
 int w_setPosition(lua_State *L)
 {
 {
-	int x = (int) luaL_checknumber(L, 1);
-	int y = (int) luaL_checknumber(L, 2);
+	int x = (int) luaL_checkinteger(L, 1);
+	int y = (int) luaL_checkinteger(L, 2);
 
 
 	int displayindex = 0;
 	int displayindex = 0;
 	if (!lua_isnoneornil(L, 3))
 	if (!lua_isnoneornil(L, 3))
-		displayindex = (int) luaL_checknumber(L, 3) - 1;
+		displayindex = (int) luaL_checkinteger(L, 3) - 1;
 	else
 	else
 	{
 	{
 		int x_unused, y_unused;
 		int x_unused, y_unused;
@@ -509,7 +509,7 @@ int w_showMessageBox(lua_State *L)
 		// Optional table entry specifying the button to use when enter is pressed.
 		// Optional table entry specifying the button to use when enter is pressed.
 		lua_getfield(L, 3, "enterbutton");
 		lua_getfield(L, 3, "enterbutton");
 		if (!lua_isnoneornil(L, -1))
 		if (!lua_isnoneornil(L, -1))
-			data.enterButtonIndex = (int) luaL_checknumber(L, -1) - 1;
+			data.enterButtonIndex = (int) luaL_checkinteger(L, -1) - 1;
 		else
 		else
 			data.enterButtonIndex = 0;
 			data.enterButtonIndex = 0;
 		lua_pop(L, 1);
 		lua_pop(L, 1);
@@ -517,7 +517,7 @@ int w_showMessageBox(lua_State *L)
 		// Optional table entry specifying the button to use when esc is pressed.
 		// Optional table entry specifying the button to use when esc is pressed.
 		lua_getfield(L, 3, "escapebutton");
 		lua_getfield(L, 3, "escapebutton");
 		if (!lua_isnoneornil(L, -1))
 		if (!lua_isnoneornil(L, -1))
-			data.escapeButtonIndex = (int) luaL_checknumber(L, -1) - 1;
+			data.escapeButtonIndex = (int) luaL_checkinteger(L, -1) - 1;
 		else
 		else
 			data.escapeButtonIndex = (int) data.buttons.size() - 1;
 			data.escapeButtonIndex = (int) data.buttons.size() - 1;
 		lua_pop(L, 1);
 		lua_pop(L, 1);