Browse Source

Fixed love.graphics.rectangle erroring when the width or height is 0.

Alex Szpakowski 10 years ago
parent
commit
8c1bc543b9
1 changed files with 9 additions and 2 deletions
  1. 9 2
      src/modules/graphics/opengl/wrap_Graphics.cpp

+ 9 - 2
src/modules/graphics/opengl/wrap_Graphics.cpp

@@ -1532,12 +1532,19 @@ int w_rectangle(lua_State *L)
 	float y = (float)luaL_checknumber(L, 3);
 	float w = (float)luaL_checknumber(L, 4);
 	float h = (float)luaL_checknumber(L, 5);
+
+	if (lua_isnoneornil(L, 6))
+	{
+		instance()->rectangle(mode, x, y, w, h);
+		return 0;
+	}
+
 	float rx = (float)luaL_optnumber(L, 6, 0.0);
 	float ry = (float)luaL_optnumber(L, 7, rx);
 
-	if (rx >= w / 2.0)
+	if (w > 0.0 && rx >= w / 2.0)
 		return luaL_error(L, "Invalid rectangle x-axis radius (must be less than half the width)");
-	if (ry >= h / 2.0)
+	if (h > 0.0 && ry >= h / 2.0)
 		return luaL_error(L, "Invalid rectangle y-axis radius (must be less than half the height)");
 
 	int points;