From dccded964b7b2777544ef36480822474f7821358 Mon Sep 17 00:00:00 2001 From: gymnast86 Date: Sun, 7 Jun 2026 21:09:31 -0700 Subject: [PATCH] fix hang on swim spawn with no water --- src/d/d_stage.cpp | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/src/d/d_stage.cpp b/src/d/d_stage.cpp index aa153ebd74..5ed5a918b5 100644 --- a/src/d/d_stage.cpp +++ b/src/d/d_stage.cpp @@ -27,6 +27,9 @@ #include "dusk/logging.h" #include "dusk/string.hpp" #include "dusk/randomizer/game/randomizer_context.hpp" +#include "dusk/randomizer/game/flags.h" +#include "dusk/randomizer/game/stages.h" +#include "dusk/randomizer/game/tools.h" #include #include #endif @@ -1731,6 +1734,41 @@ static int dStage_playerInit(dStage_dt_c* i_stage, void* i_data, int num, void* i_stage->setPlayer(player); i_stage->setPlayerNum(num); +#if TARGET_PC + // Modify entrance types in certain situations to avoid crashes + if (randomizer_IsActive()) { + for (size_t i = 0; i < num; ++i) { + u8& entranceType = reinterpret_cast(&player_data[i].base.parameters)[2]; + switch (entranceType) { + // Only replace the entrance type if it is a door. + case 0x80: + case 0xA0: + case 0xB0: + { + if (dComIfGs_getTransformStatus() == TF_STATUS_WOLF) { + // Change the entrance type to play the animation of walking out of the loading zone instead of entering + // through the door. + entranceType = 0x50; + } + break; + } + + // Water swimming entrance. If we have this, but there isn't any water to spawn in, the game hangs + case 0xD0: + { + // If there's no water, change to non-swimming entrance + if (getStageID() == Lake_Hylia && !dComIfGs_isEventBit(WARPED_METEOR_TO_ZORAS_DOMAIN)) { + entranceType = 0x50; + } + break; + } + default: + break; + } + } + } +#endif + if (dComIfGp_getPlayer(0) != NULL || dComIfGp_getStartStageRoomNo() != i_stage->getRoomNo()) { return 1; }