mirror of
https://github.com/love2d/love.git
synced 2026-08-15 15:51:12 +02:00
Forward box2d asserts to exception, then catch those in the new* functions
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user