From 5eb5e678c533ea49ede69e0f66cd32e2a7bd3b3b Mon Sep 17 00:00:00 2001 From: MysterD Date: Sun, 4 Oct 2020 22:38:54 -0700 Subject: [PATCH] Prevent OOB warp by teleporting one player to the other when OOB is detected --- src/game/mario.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/game/mario.c b/src/game/mario.c index 99de9350..09e2a097 100644 --- a/src/game/mario.c +++ b/src/game/mario.c @@ -1380,6 +1380,9 @@ void update_mario_joystick_inputs(struct MarioState *m) { * Resolves wall collisions, and updates a variety of inputs. */ void update_mario_geometry_inputs(struct MarioState *m) { + u8 copiedPlayer = FALSE; +copyPlayerGoto:; + f32 gasLevel; f32 ceilToFloorDist; @@ -1431,6 +1434,19 @@ void update_mario_geometry_inputs(struct MarioState *m) { } } else { + if (!copiedPlayer) { + // try to prevent OOB by copying position of other player + struct Surface* floor2 = NULL; + for (int i = 0; i < MAX_PLAYERS; i++) { + struct MarioState* m2 = &gMarioStates[i]; + if (m == m2) { continue; } + find_floor(m2->pos[0], m2->pos[1], m2->pos[2], &floor2); + if (floor2 == NULL) { continue; } + vec3f_copy(m->pos, m2->pos); + copiedPlayer = TRUE; + goto copyPlayerGoto; + } + } level_trigger_warp(m, WARP_OP_DEATH); } }