From 8c1bc543b9f30e1a68f6ef9abcb80e94c39d98c5 Mon Sep 17 00:00:00 2001 From: Alex Szpakowski Date: Sun, 7 Jun 2015 17:45:43 -0300 Subject: [PATCH] Fixed love.graphics.rectangle erroring when the width or height is 0. --- src/modules/graphics/opengl/wrap_Graphics.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/modules/graphics/opengl/wrap_Graphics.cpp b/src/modules/graphics/opengl/wrap_Graphics.cpp index c2ae34437..d25c0d387 100644 --- a/src/modules/graphics/opengl/wrap_Graphics.cpp +++ b/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;