Browse Source

Fixed SpriteBatch:addg/setg to error properly instead of crash when attempting to use a Geometry without exactly 4 vertices

Alex Szpakowski 12 years ago
parent
commit
89265107ea
1 changed files with 16 additions and 2 deletions
  1. 16 2
      src/modules/graphics/opengl/wrap_SpriteBatch.cpp

+ 16 - 2
src/modules/graphics/opengl/wrap_SpriteBatch.cpp

@@ -63,7 +63,14 @@ int w_SpriteBatch_addg(lua_State *L)
 	float oy = (float)luaL_optnumber(L, 9, 0);
 	float oy = (float)luaL_optnumber(L, 9, 0);
 	float kx = (float)luaL_optnumber(L, 10, 0);
 	float kx = (float)luaL_optnumber(L, 10, 0);
 	float ky = (float)luaL_optnumber(L, 11, 0);
 	float ky = (float)luaL_optnumber(L, 11, 0);
-	lua_pushnumber(L, t->addg(g, x, y, angle, sx, sy, ox, oy, kx, ky));
+	try
+	{
+		lua_pushnumber(L, t->addg(g, x, y, angle, sx, sy, ox, oy, kx, ky));
+	}
+	catch (love::Exception &e)
+	{
+		return luaL_error(L, "%s", e.what());
+	}
 	return 1;
 	return 1;
 }
 }
 
 
@@ -99,7 +106,14 @@ int w_SpriteBatch_setg(lua_State *L)
 	float oy = (float)luaL_optnumber(L, 10, 0);
 	float oy = (float)luaL_optnumber(L, 10, 0);
 	float kx = (float)luaL_optnumber(L, 11, 0);
 	float kx = (float)luaL_optnumber(L, 11, 0);
 	float ky = (float)luaL_optnumber(L, 12, 0);
 	float ky = (float)luaL_optnumber(L, 12, 0);
-	t->addg(g, x, y, angle, sx, sy, ox, oy, kx, ky, index);
+	try
+	{
+		t->addg(g, x, y, angle, sx, sy, ox, oy, kx, ky, index);
+	}
+	catch (love::Exception &e)
+	{
+		return luaL_error(L, "%s", e.what());
+	}
 	return 0;
 	return 0;
 }
 }