From 4f9a48620d1784ca2d6a99095fdd5bd615b73b9b Mon Sep 17 00:00:00 2001 From: MysterD Date: Sun, 10 Apr 2022 01:30:56 -0700 Subject: [PATCH] Allow DynOS to warp to level with castle levels --- data/dynos_level.cpp | 19 +++++++++++++++---- data/dynos_warps.cpp | 2 +- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/data/dynos_level.cpp b/data/dynos_level.cpp index 06bc1964..85137fde 100644 --- a/data/dynos_level.cpp +++ b/data/dynos_level.cpp @@ -832,23 +832,34 @@ static void DynOS_Level_ParseScript(const void *aScript, s32 (*aPreprocessFuncti s16 *DynOS_Level_GetWarp(s32 aLevel, s32 aArea, u8 aWarpId) { DynOS_Level_Init(); - //s16 *bestWarp = NULL; for (const auto &_Warp : sDynosLevelWarps[aLevel]) { if (_Warp.mArea == aArea) { if (_Warp.mId == aWarpId) { return (s16 *) &_Warp; - } else { - //bestWarp = (s16 *) &_Warp; } } } - //return bestWarp; return NULL; } s16 *DynOS_Level_GetWarpEntry(s32 aLevel, s32 aArea) { DynOS_Level_Init(); if (aLevel == LEVEL_TTM && aArea > 2) return NULL; + + // override vanilla castle warps + if (DynOS_Level_GetCourse(aLevel) == COURSE_NONE) { + extern const LevelScript level_castle_grounds_entry[]; + extern const LevelScript level_castle_inside_entry[]; + extern const LevelScript level_castle_courtyard_entry[]; + if (sDynosLevelScripts[aLevel] == level_castle_inside_entry) { + return DynOS_Level_GetWarp(aLevel, aArea, (aArea == 3) ? 0x00 : 0x01); + } else if (sDynosLevelScripts[aLevel] == level_castle_grounds_entry) { + return DynOS_Level_GetWarp(aLevel, aArea, 0x00); + } else if (sDynosLevelScripts[aLevel] == level_castle_courtyard_entry) { + return DynOS_Level_GetWarp(aLevel, aArea, 0x01); + } + } + return DynOS_Level_GetWarp(aLevel, aArea, 0x0A); } diff --git a/data/dynos_warps.cpp b/data/dynos_warps.cpp index b857092d..e472de8c 100644 --- a/data/dynos_warps.cpp +++ b/data/dynos_warps.cpp @@ -36,7 +36,7 @@ static s32 sDynosExitAreaNum = -1; // bool DynOS_Warp_ToLevel(s32 aLevel, s32 aArea, s32 aAct) { - if (/*DynOS_Level_GetCourse(aLevel) == COURSE_NONE || */!DynOS_Level_GetWarpEntry(aLevel, aArea)) { + if (!DynOS_Level_GetWarpEntry(aLevel, aArea)) { return false; }