summaryrefslogtreecommitdiff
path: root/src/code/z_actor.c
diff options
context:
space:
mode:
authorAnghelo Carvajal <angheloalf95@gmail.com>2021-04-29 14:39:46 -0400
committerGitHub <noreply@github.com>2021-04-29 14:39:46 -0400
commit98aef8988adbcb5960e8001e70141d0d1a9034bd (patch)
treea0443e402cb6fa06b0f964aad6d38bf185fb2a9b /src/code/z_actor.c
parent0b8252cfe99651b3174ac8652ba133781e8e2105 (diff)
`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>
Diffstat (limited to 'src/code/z_actor.c')
-rw-r--r--src/code/z_actor.c34
1 files changed, 9 insertions, 25 deletions
diff --git a/src/code/z_actor.c b/src/code/z_actor.c
index aec121001..c3e445f8c 100644
--- a/src/code/z_actor.c
+++ b/src/code/z_actor.c
@@ -1997,10 +1997,8 @@ void Actor_UpdateAll(GlobalContext* globalCtx, ActorContext* actorCtx) {
player = PLAYER;
if (0) {
- // This assert is optimized out but it exists due to its presence in rodata
- if (gMaxActorId != ACTOR_ID_MAX) {
- __assert("MaxProfile == ACTOR_DLF_MAX", "../z_actor.c", UNK_LINE);
- }
+ // This ASSERT is optimized out but it exists due to its presence in rodata
+ ASSERT(gMaxActorId == ACTOR_ID_MAX, "MaxProfile == ACTOR_DLF_MAX", "../z_actor.c", UNK_LINE);
}
sp74 = NULL;
@@ -2390,9 +2388,8 @@ void func_800315AC(GlobalContext* globalCtx, ActorContext* actorCtx) {
if ((actor->flags & 0x80) &&
((globalCtx->roomCtx.curRoom.showInvisActors == 0) || (globalCtx->actorCtx.unk_03 != 0) ||
(actor->room != globalCtx->roomCtx.curRoom.num))) {
- if (invisibleActorCounter >= INVISIBLE_ACTOR_MAX) {
- __assert("invisible_actor_counter < INVISIBLE_ACTOR_MAX", "../z_actor.c", 6464);
- }
+ ASSERT(invisibleActorCounter < INVISIBLE_ACTOR_MAX,
+ "invisible_actor_counter < INVISIBLE_ACTOR_MAX", "../z_actor.c", 6464);
invisibleActors[invisibleActorCounter] = actor;
invisibleActorCounter++;
} else {
@@ -2632,10 +2629,7 @@ Actor* Actor_Spawn(ActorContext* actorCtx, GlobalContext* globalCtx, s16 actorId
u32 overlaySize;
overlayEntry = &gActorOverlayTable[actorId];
-
- if (actorId >= ACTOR_ID_MAX) {
- __assert("profile < ACTOR_DLF_MAX", "../z_actor.c", 6883);
- }
+ ASSERT(actorId < ACTOR_ID_MAX, "profile < ACTOR_DLF_MAX", "../z_actor.c", 6883);
name = overlayEntry->name != NULL ? overlayEntry->name : "";
overlaySize = (u32)overlayEntry->vramEnd - (u32)overlayEntry->vramStart;
@@ -2666,9 +2660,7 @@ Actor* Actor_Spawn(ActorContext* actorCtx, GlobalContext* globalCtx, s16 actorId
}
} else {
if (overlayEntry->allocType & ALLOCTYPE_ABSOLUTE) {
- if (overlaySize > AM_FIELD_SIZE) {
- __assert("actor_segsize <= AM_FIELD_SIZE", "../z_actor.c", 6934);
- }
+ ASSERT(overlaySize <= AM_FIELD_SIZE, "actor_segsize <= AM_FIELD_SIZE", "../z_actor.c", 6934);
if (actorCtx->absoluteSpace == NULL) {
// Translates to: "AMF: ABSOLUTE MAGIC FIELD"
@@ -2732,9 +2724,7 @@ Actor* Actor_Spawn(ActorContext* actorCtx, GlobalContext* globalCtx, s16 actorId
return NULL;
}
- if (overlayEntry->nbLoaded >= 255) {
- __assert("actor_dlftbl->clients < 255", "../z_actor.c", 7031);
- }
+ ASSERT(overlayEntry->nbLoaded < 255, "actor_dlftbl->clients < 255", "../z_actor.c", 7031);
overlayEntry->nbLoaded++;
@@ -2873,14 +2863,8 @@ Actor* Actor_Delete(ActorContext* actorCtx, Actor* actor, GlobalContext* globalC
osSyncPrintf("オーバーレイではありません\n");
}
} else {
- if (overlayEntry->loadedRamAddr == NULL) {
- __assert("actor_dlftbl->allocp != NULL", "../z_actor.c", 7251);
- }
-
- if (overlayEntry->nbLoaded <= 0) {
- __assert("actor_dlftbl->clients > 0", "../z_actor.c", 7252);
- }
-
+ ASSERT(overlayEntry->loadedRamAddr != NULL, "actor_dlftbl->allocp != NULL", "../z_actor.c", 7251);
+ ASSERT(overlayEntry->nbLoaded > 0, "actor_dlftbl->clients > 0", "../z_actor.c", 7252);
overlayEntry->nbLoaded--;
Actor_FreeOverlay(overlayEntry);
}