mirror of
https://github.com/zeldaret/oot.git
synced 2025-07-17 21:35:11 +00:00
assert
macro OK (#755)
* create assert macro and replace a bunch of __assert Signed-off-by: angie <angheloalf95@gmail.com> * Another bunch of assert Signed-off-by: angie <angheloalf95@gmail.com> * more assert Signed-off-by: angie <angheloalf95@gmail.com> * assert(false) Signed-off-by: angie <angheloalf95@gmail.com> * last assert used in matching code Signed-off-by: angie <angheloalf95@gmail.com> * the non-matchings Signed-off-by: angie <angheloalf95@gmail.com> * typo Signed-off-by: angie <angheloalf95@gmail.com> * format Signed-off-by: angie <angheloalf95@gmail.com> * change macro to uppercase Signed-off-by: angie <angheloalf95@gmail.com> * Apply suggestions from code review Co-authored-by: Roman971 <32455037+Roman971@users.noreply.github.com> * Change ASSERT(false) to ASSERT(0) Co-authored-by: Roman971 <32455037+Roman971@users.noreply.github.com>
This commit is contained in:
parent
0b8252cfe9
commit
98aef8988a
44 changed files with 148 additions and 301 deletions
|
@ -85,8 +85,7 @@ void SSNodeList_SetSSListHead(SSNodeList* nodeList, SSList* ssList, s16* polyId)
|
|||
void DynaSSNodeList_SetSSListHead(DynaSSNodeList* nodeList, SSList* ssList, s16* polyId) {
|
||||
u16 newNodeId = DynaSSNodeList_GetNextNodeIdx(nodeList);
|
||||
|
||||
(newNodeId != SS_NULL) ? (void)0 : __assert("new_node != SS_NULL", "../z_bgcheck.c", 1776);
|
||||
|
||||
ASSERT(newNodeId != SS_NULL, "new_node != SS_NULL", "../z_bgcheck.c", 1776);
|
||||
SSNode_SetValue(&nodeList->tbl[newNodeId], polyId, ssList->head);
|
||||
ssList->head = newNodeId;
|
||||
}
|
||||
|
@ -105,7 +104,7 @@ void DynaSSNodeList_Initialize(GlobalContext* globalCtx, DynaSSNodeList* nodeLis
|
|||
void DynaSSNodeList_Alloc(GlobalContext* globalCtx, DynaSSNodeList* nodeList, s32 max) {
|
||||
nodeList->tbl = THA_AllocEndAlign(&globalCtx->state.tha, max * sizeof(SSNode), -2);
|
||||
|
||||
(nodeList->tbl != NULL) ? (void)0 : __assert("psst->tbl != NULL", "../z_bgcheck.c", 1811);
|
||||
ASSERT(nodeList->tbl != NULL, "psst->tbl != NULL", "../z_bgcheck.c", 1811);
|
||||
|
||||
nodeList->max = max;
|
||||
nodeList->count = 0;
|
||||
|
@ -699,7 +698,7 @@ s32 BgCheck_SphVsStaticWall(StaticLookup* lookup, CollisionContext* colCtx, u16
|
|||
}
|
||||
}
|
||||
|
||||
(!IS_ZERO(normalXZ)) ? (void)0 : __assert("!IS_ZERO(ac_size)", "../z_bgcheck.c", 2854);
|
||||
ASSERT(!IS_ZERO(normalXZ), "!IS_ZERO(ac_size)", "../z_bgcheck.c", 2854);
|
||||
|
||||
invNormalXZ = 1.0f / normalXZ;
|
||||
temp_f16 = fabsf(nz) * invNormalXZ;
|
||||
|
@ -780,7 +779,7 @@ s32 BgCheck_SphVsStaticWall(StaticLookup* lookup, CollisionContext* colCtx, u16
|
|||
}
|
||||
}
|
||||
|
||||
(!IS_ZERO(normalXZ)) ? (void)0 : __assert("!IS_ZERO(ac_size)", "../z_bgcheck.c", 2964);
|
||||
ASSERT(!IS_ZERO(normalXZ), "!IS_ZERO(ac_size)", "../z_bgcheck.c", 2964);
|
||||
|
||||
invNormalXZ = 1.0f / normalXZ;
|
||||
temp_f16 = fabsf(nx) * invNormalXZ;
|
||||
|
@ -2407,9 +2406,11 @@ void SSNodeList_Alloc(GlobalContext* globalCtx, SSNodeList* this, s32 tblMax, s3
|
|||
this->count = 0;
|
||||
this->tbl = THA_AllocEndAlign(&globalCtx->state.tha, tblMax * sizeof(SSNode), -2);
|
||||
|
||||
(this->tbl != NULL) ? (void)0 : __assert("this->short_slist_node_tbl != NULL", "../z_bgcheck.c", 5975);
|
||||
ASSERT(this->tbl != NULL, "this->short_slist_node_tbl != NULL", "../z_bgcheck.c", 5975);
|
||||
|
||||
this->polyCheckTbl = GameState_Alloc(&globalCtx->state, numPolys, "../z_bgcheck.c", 5979);
|
||||
(this->polyCheckTbl != NULL) ? (void)0 : __assert("this->polygon_check != NULL", "../z_bgcheck.c", 5981);
|
||||
|
||||
ASSERT(this->polyCheckTbl != NULL, "this->polygon_check != NULL", "../z_bgcheck.c", 5981);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2417,11 +2418,10 @@ void SSNodeList_Alloc(GlobalContext* globalCtx, SSNodeList* this, s32 tblMax, s3
|
|||
*/
|
||||
SSNode* SSNodeList_GetNextNode(SSNodeList* this) {
|
||||
SSNode* result = &this->tbl[this->count];
|
||||
this->count++;
|
||||
|
||||
(this->count < this->max)
|
||||
? (void)0
|
||||
: __assert("this->short_slist_node_last_index < this->short_slist_node_size", "../z_bgcheck.c", 5998);
|
||||
this->count++;
|
||||
ASSERT(this->count < this->max, "this->short_slist_node_last_index < this->short_slist_node_size", "../z_bgcheck.c",
|
||||
5998);
|
||||
if (!(this->count < this->max)) {
|
||||
return NULL;
|
||||
}
|
||||
|
@ -2434,7 +2434,7 @@ SSNode* SSNodeList_GetNextNode(SSNodeList* this) {
|
|||
u16 SSNodeList_GetNextNodeIdx(SSNodeList* this) {
|
||||
u16 new_index = this->count++;
|
||||
|
||||
(new_index < this->max) ? (void)0 : __assert("new_index < this->short_slist_node_size", "../z_bgcheck.c", 6021);
|
||||
ASSERT(new_index < this->max, "new_index < this->short_slist_node_size", "../z_bgcheck.c", 6021);
|
||||
return new_index;
|
||||
}
|
||||
|
||||
|
@ -2540,7 +2540,7 @@ void DynaPoly_NullPolyList(CollisionPoly** polyList) {
|
|||
*/
|
||||
void DynaPoly_AllocPolyList(GlobalContext* globalCtx, CollisionPoly** polyList, s32 numPolys) {
|
||||
*polyList = THA_AllocEndAlign(&globalCtx->state.tha, numPolys * sizeof(CollisionPoly), -2);
|
||||
(*polyList != NULL) ? (void)0 : __assert("ptbl->pbuf != NULL", "../z_bgcheck.c", 6247);
|
||||
ASSERT(*polyList != NULL, "ptbl->pbuf != NULL", "../z_bgcheck.c", 6247);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2555,7 +2555,7 @@ void DynaPoly_NullVtxList(Vec3s** vtxList) {
|
|||
*/
|
||||
void DynaPoly_AllocVtxList(GlobalContext* globalCtx, Vec3s** vtxList, s32 numVtx) {
|
||||
*vtxList = THA_AllocEndAlign(&globalCtx->state.tha, numVtx * sizeof(Vec3s), -2);
|
||||
(*vtxList != NULL) ? (void)0 : __assert("ptbl->pbuf != NULL", "../z_bgcheck.c", 6277);
|
||||
ASSERT(*vtxList != NULL, "ptbl->pbuf != NULL", "../z_bgcheck.c", 6277);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2772,13 +2772,10 @@ void DynaPoly_ExpandSRT(GlobalContext* globalCtx, DynaCollisionContext* dyna, s3
|
|||
*vtxStartIndex + pbgdata->nbVertices, dyna->vtxListMax);
|
||||
}
|
||||
|
||||
(dyna->polyListMax >= *polyStartIndex + pbgdata->nbPolygons)
|
||||
? (void)0
|
||||
: __assert("pdyna_poly_info->poly_num >= *pstart_poly_index + pbgdata->poly_num", "../z_bgcheck.c", 6687);
|
||||
|
||||
(dyna->vtxListMax >= *vtxStartIndex + pbgdata->nbVertices)
|
||||
? (void)0
|
||||
: __assert("pdyna_poly_info->vert_num >= *pstart_vert_index + pbgdata->vtx_num", "../z_bgcheck.c", 6688);
|
||||
ASSERT(dyna->polyListMax >= *polyStartIndex + pbgdata->nbPolygons,
|
||||
"pdyna_poly_info->poly_num >= *pstart_poly_index + pbgdata->poly_num", "../z_bgcheck.c", 6687);
|
||||
ASSERT(dyna->vtxListMax >= *vtxStartIndex + pbgdata->nbVertices,
|
||||
"pdyna_poly_info->vert_num >= *pstart_vert_index + pbgdata->vtx_num", "../z_bgcheck.c", 6688);
|
||||
|
||||
if (!(dyna->bitFlag & DYNAPOLY_INVALIDATE_LOOKUP) &&
|
||||
(BgActor_IsTransformUnchanged(&dyna->bgActors[bgId]) == true)) {
|
||||
|
@ -3209,7 +3206,7 @@ s32 BgCheck_SphVsDynaWallInBgActor(CollisionContext* colCtx, u16 xpFlags, DynaCo
|
|||
poly = &dyna->polyList[polyId];
|
||||
CollisionPoly_GetNormalF(poly, &nx, &ny, &nz);
|
||||
normalXZ = sqrtf(SQ(nx) + SQ(nz));
|
||||
(!IS_ZERO(normalXZ)) ? (void)0 : __assert("!IS_ZERO(ac_size)", "../z_bgcheck.c", 7382);
|
||||
ASSERT(!IS_ZERO(normalXZ), "!IS_ZERO(ac_size)", "../z_bgcheck.c", 7382);
|
||||
|
||||
planeDist = Math3D_DistPlaneToPos(nx, ny, nz, poly->dist, &resultPos);
|
||||
if (radius < fabsf(planeDist) || COLPOLY_VIA_FLAG_TEST(poly->flags_vIA, xpFlags)) {
|
||||
|
@ -3282,7 +3279,7 @@ s32 BgCheck_SphVsDynaWallInBgActor(CollisionContext* colCtx, u16 xpFlags, DynaCo
|
|||
poly = &dyna->polyList[polyId];
|
||||
CollisionPoly_GetNormalF(poly, &nx, &ny, &nz);
|
||||
normalXZ = sqrtf(SQ(nx) + SQ(nz));
|
||||
(!IS_ZERO(normalXZ)) ? (void)0 : __assert("!IS_ZERO(ac_size)", "../z_bgcheck.c", 7489);
|
||||
ASSERT(!IS_ZERO(normalXZ), "!IS_ZERO(ac_size)", "../z_bgcheck.c", 7489);
|
||||
|
||||
planeDist = Math3D_DistPlaneToPos(nx, ny, nz, poly->dist, &resultPos);
|
||||
if (radius < fabsf(planeDist) || COLPOLY_VIA_FLAG_TEST(poly->flags_vIA, xpFlags)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue