From c8bf12754fbaf1a842a15a6b28d0f5b97bcca197 Mon Sep 17 00:00:00 2001 From: Agent X <44549182+Agent-11@users.noreply.github.com> Date: Mon, 25 Mar 2024 19:03:59 -0400 Subject: [PATCH] Refactor verify_warp --- src/game/level_update.c | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/src/game/level_update.c b/src/game/level_update.c index 37779e4c..fbce8510 100644 --- a/src/game/level_update.c +++ b/src/game/level_update.c @@ -834,28 +834,27 @@ void initiate_painting_warp(s16 paintingIndex) { void verify_warp(struct MarioState *m, bool killMario) { - if (area_get_warp_node(sSourceWarpNodeId) == NULL) { - if (area_get_warp_node(WARP_NODE_DEATH) != NULL) { - if (killMario) { - m->numLives--; - if (m->numLives <= -1) { - sDelayedWarpOp = WARP_OP_GAME_OVER; - } else { - sSourceWarpNodeId = WARP_NODE_DEATH; - } - } - else { - sSourceWarpNodeId = WARP_NODE_DEATH; - } - } - else { - dynos_warp_to_start_level(); - } + if (area_get_warp_node(sSourceWarpNodeId) != NULL) { return; } + + if (area_get_warp_node(WARP_NODE_DEATH) == NULL) { + dynos_warp_to_start_level(); + return; + } + + if (!killMario) { + sSourceWarpNodeId = WARP_NODE_DEATH; + return; + } + + m->numLives--; + if (m->numLives < 0) { + sDelayedWarpOp = WARP_OP_GAME_OVER; + } else { + sSourceWarpNodeId = WARP_NODE_DEATH; } } - /** * If there is not already a delayed warp, schedule one. The source node is * based on the warp operation and sometimes Mario's used object.