Browse Source

love.graphics.draw(image, quad, x, y, ...) now errors instead of shifting parameters if the quad argument is nil

Alex Szpakowski 11 years ago
parent
commit
b556dde3cb

+ 4 - 0
src/modules/graphics/opengl/wrap_Graphics.cpp

@@ -1017,6 +1017,10 @@ int w_draw(lua_State *L)
 		quad = luax_totype<Quad>(L, 2, "Quad", GRAPHICS_QUAD_T);
 		startidx = 3;
 	}
+	else if (lua_isnil(L, 2) && !lua_isnoneornil(L, 3))
+	{
+		return luax_typerror(L, 2, "Quad");
+	}
 	else
 	{
 		drawable = luax_checktype<Drawable>(L, 1, "Drawable", GRAPHICS_DRAWABLE_T);

+ 4 - 0
src/modules/graphics/opengl/wrap_SpriteBatch.cpp

@@ -44,6 +44,8 @@ int w_SpriteBatch_add(lua_State *L)
 		quad = luax_totype<Quad>(L, 2, "Quad", GRAPHICS_QUAD_T);
 		startidx = 3;
 	}
+	else if (lua_isnil(L, 2) && !lua_isnoneornil(L, 3))
+		return luax_typerror(L, 2, "Quad");
 
 	float x  = (float) luaL_optnumber(L, startidx + 0, 0.0);
 	float y  = (float) luaL_optnumber(L, startidx + 1, 0.0);
@@ -80,6 +82,8 @@ int w_SpriteBatch_set(lua_State *L)
 		quad = luax_totype<Quad>(L, 3, "Quad", GRAPHICS_QUAD_T);
 		startidx = 4;
 	}
+	else if (lua_isnil(L, 3) && !lua_isnoneornil(L, 4))
+		return luax_typerror(L, 3, "Quad");
 
 	float x  = (float) luaL_optnumber(L, startidx + 0, 0.0);
 	float y  = (float) luaL_optnumber(L, startidx + 1, 0.0);