mirror of
https://github.com/zeldaret/tww.git
synced 2026-05-23 06:54:16 -04:00
Make JUT_ASSERT macro more accurate
(COND) == 0 and !(COND) both only match sometimes, but (void)((COND) || ...) seems to work all the time.
This commit is contained in:
@@ -4,11 +4,7 @@
|
||||
#include "dolphin/types.h"
|
||||
#include "dolphin/os/OS.h"
|
||||
|
||||
#define JUT_ASSERT(LINE, COND) \
|
||||
if ((COND) == 0) { \
|
||||
JUTAssertion::showAssert(JUTAssertion::getSDevice(), __FILE__, LINE, #COND); \
|
||||
OSPanic(__FILE__, LINE, "Halt"); \
|
||||
}
|
||||
#define JUT_ASSERT(LINE, COND) (void)((COND) || (JUTAssertion::showAssert(JUTAssertion::getSDevice(), __FILE__, LINE, #COND), OSPanic(__FILE__, LINE, "Halt"), 0));
|
||||
|
||||
// Favored by JAI (JAudio)
|
||||
#define JUT_ASSERT_MSG(LINE, COND, MSG) \
|
||||
@@ -20,14 +16,6 @@
|
||||
} \
|
||||
}
|
||||
|
||||
// Some asserts on floats have the wrong codegen with JUT_ASSERT's (COND) == 0 check.
|
||||
// Using !(COND) instead fixes them.
|
||||
#define JUT_ASSERT_FLOAT(LINE, COND) \
|
||||
if (!(COND)) { \
|
||||
JUTAssertion::showAssert(JUTAssertion::getSDevice(), __FILE__, LINE, #COND); \
|
||||
OSPanic(__FILE__, LINE, "Halt"); \
|
||||
}
|
||||
|
||||
#define JUT_PANIC(LINE) \
|
||||
JUTAssertion::showAssert(JUTAssertion::getSDevice(), __FILE__, LINE, "0"); \
|
||||
OSPanic(__FILE__, LINE, "Halt");
|
||||
|
||||
@@ -17,7 +17,7 @@ void cM2d_CrossCirLin(cM2dGCir& circle, f32 x0, f32 y0, f32 x1, f32 y1, f32* pDs
|
||||
f32 c = (fVar1 * fVar1 + fVar15 * fVar15) - (circle.GetR() * circle.GetR());
|
||||
f32 t;
|
||||
|
||||
JUT_ASSERT_FLOAT(0x47, c < 0.0f);
|
||||
JUT_ASSERT(0x47, c < 0.0f);
|
||||
|
||||
if (cM3d_IsZero(dVar13)) {
|
||||
if (!cM3d_IsZero(dVar14)) {
|
||||
@@ -48,7 +48,7 @@ void cM2d_CrossCirLin(cM2dGCir& circle, f32 x0, f32 y0, f32 x1, f32 y1, f32* pDs
|
||||
*pDstX = x0;
|
||||
*pDstY = y0;
|
||||
} else {
|
||||
JUT_ASSERT_FLOAT(0x89, t >= 0.0f);
|
||||
JUT_ASSERT(0x89, t >= 0.0f);
|
||||
*pDstX = x0 + (t * x1);
|
||||
*pDstY = y0 + (t * y1);
|
||||
}
|
||||
|
||||
@@ -303,8 +303,8 @@ void dBgS_Acch::CrrPos(dBgS& i_bgs) {
|
||||
SetWaterIn();
|
||||
}
|
||||
|
||||
JUT_ASSERT_FLOAT(718, m_wtr.GetHeight() >= ground.y);
|
||||
JUT_ASSERT_FLOAT(719, m_wtr.GetHeight() <= top);
|
||||
JUT_ASSERT(718, m_wtr.GetHeight() >= ground.y);
|
||||
JUT_ASSERT(719, m_wtr.GetHeight() <= top);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user