Forward box2d asserts to exception, then catch those in the new* functions

This commit is contained in:
Bart van Strien
2011-10-12 21:36:46 +02:00
parent 57f9cf439e
commit b32464f0d3
4 changed files with 53 additions and 22 deletions
+9 -1
View File
@@ -21,6 +21,8 @@
#include <cstdio>
#include <cstdarg>
#include "common/Exception.h"
b2Version b2_version = {2, 2, 1};
// Memory allocators. Modify these to use your own allocator.
@@ -41,4 +43,10 @@ void b2Log(const char* string, ...)
va_start(args, string);
vprintf(string, args);
va_end(args);
}
}
void loveAssert(bool test, const char *teststr)
{
if (!test)
throw love::Exception("Box2D error: %s", teststr);
}
+4 -1
View File
@@ -22,8 +22,11 @@
#include <cassert>
#include <cmath>
void loveAssert(bool test, const char *teststr);
#define B2_NOT_USED(x) ((void)(x))
#define b2Assert(A) assert(A)
//#define b2Assert(A) assert(A)
#define b2Assert(A) loveAssert((A), #A)
typedef signed char int8;
typedef signed short int16;