Browse Source

make love.physics.setMeter error on invalid meters (anything less than 1)

--HG--
branch : box2d-update
Bill Meltsner 14 years ago
parent
commit
735c52b228

+ 1 - 0
src/modules/physics/box2d/Physics.cpp

@@ -234,6 +234,7 @@ namespace box2d
 	
 	void Physics::setMeter(int meter)
 	{
+		if (meter < 1) throw love::Exception("Physics error: invalid meter");
 		Physics::meter = meter;
 	}
 	

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

@@ -304,7 +304,11 @@ namespace box2d
 	int w_setMeter(lua_State * L)
 	{
 		int arg1 = luaL_checkint(L, 1);
-		Physics::setMeter(arg1);
+		try {
+			Physics::setMeter(arg1);
+		} catch (love::Exception e) {
+			return luaL_error(L, e.what());
+		}
 		return 0;
 		
 	}