diff options
| author | Garrett Cox <garrettjcox@gmail.com> | 2025-11-08 15:49:35 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-11-08 15:49:35 -0600 |
| commit | 0e162cbb7c21f142d3a5cb97d8aa48281171f5bc (patch) | |
| tree | 06ac6104bcb9b2f385019721b36c4fafb7d8e5a4 | |
| parent | 3793e821c8be82c14dcfdc10921c20b483500370 (diff) | |
Fix skybox being manipulated outside of appropriate scenes, other tweaks to disable 2d backgrounds impl (#5925)
| -rw-r--r-- | soh/soh/Enhancements/Graphics/Disable2DBackgrounds.cpp | 83 | ||||
| -rw-r--r-- | soh/soh/z_scene_otr.cpp | 5 |
2 files changed, 31 insertions, 57 deletions
diff --git a/soh/soh/Enhancements/Graphics/Disable2DBackgrounds.cpp b/soh/soh/Enhancements/Graphics/Disable2DBackgrounds.cpp index 253e0abd2..9fbc3375d 100644 --- a/soh/soh/Enhancements/Graphics/Disable2DBackgrounds.cpp +++ b/soh/soh/Enhancements/Graphics/Disable2DBackgrounds.cpp @@ -13,7 +13,7 @@ extern PlayState* gPlayState; #define CVAR_NAME CVAR_ENHANCEMENT("3DSceneRender") #define CVAR_VALUE CVarGetInteger(CVAR_NAME, 0) -std::vector<SceneID> fogControlList = { +std::set<SceneID> fogControlList = { SCENE_MARKET_ENTRANCE_DAY, SCENE_MARKET_ENTRANCE_NIGHT, SCENE_MARKET_ENTRANCE_RUINS, @@ -46,7 +46,7 @@ std::vector<SceneID> fogControlList = { SCENE_GRAVEKEEPERS_HUT, }; -std::vector<SceneID> skyboxSceneControlList = { +std::set<SceneID> skyboxSceneControlList = { SCENE_MARKET_ENTRANCE_DAY, SCENE_MARKET_ENTRANCE_NIGHT, SCENE_MARKET_ENTRANCE_RUINS, @@ -62,7 +62,7 @@ std::vector<SceneID> skyboxSceneControlList = { SCENE_FOREST_TEMPLE, }; -std::vector<SkyboxId> skyboxIdControlList = { +std::set<SkyboxId> skyboxIdControlList = { SKYBOX_BAZAAR, SKYBOX_HOUSE_LINK, SKYBOX_MARKET_ADULT, @@ -88,74 +88,49 @@ std::vector<SkyboxId> skyboxIdControlList = { void Register3DPreRenderedScenes() { COND_HOOK(AfterSceneCommands, CVAR_VALUE, [](int16_t sceneNum) { - // Check if this scene is in the skyboxControlList - bool shouldControlSkybox = false; - for (const auto& scene : skyboxSceneControlList) { - if (sceneNum == scene) { - shouldControlSkybox = true; - break; - } + if (!skyboxSceneControlList.contains(static_cast<SceneID>(sceneNum))) { + return; } - if (shouldControlSkybox) { - // Add a skybox on scenes from skyboxSceneControlList - gPlayState->envCtx.skyboxDisabled = false; + // Add a skybox on scenes from skyboxSceneControlList + gPlayState->envCtx.skyboxDisabled = false; - // Replace skybox with normal sky - gPlayState->skyboxId = SKYBOX_NORMAL_SKY; - // Apply the always cloudy skybox as an adult for Temple of Time and the Market - if (sceneNum == SCENE_TEMPLE_OF_TIME_EXTERIOR_RUINS || sceneNum == SCENE_MARKET_RUINS || - sceneNum == SCENE_MARKET_ENTRANCE_RUINS) { - gWeatherMode = 3; - } + // Replace skybox with normal sky + gPlayState->skyboxId = SKYBOX_NORMAL_SKY; + // Apply the always cloudy skybox as an adult for Temple of Time and the Market + if (sceneNum == SCENE_TEMPLE_OF_TIME_EXTERIOR_RUINS || sceneNum == SCENE_MARKET_RUINS || + sceneNum == SCENE_MARKET_ENTRANCE_RUINS) { + gWeatherMode = 3; } }); COND_HOOK(OnPlayDrawBegin, CVAR_VALUE, []() { - if (!CVarGetInteger(CVAR_ENHANCEMENT("3DSceneRender"), 0)) { + if (!fogControlList.contains(static_cast<SceneID>(gPlayState->sceneNum))) { return; } - for (auto& scene : fogControlList) { - if (scene == gPlayState->sceneNum) { - if ((HREG(80) != 10) || (HREG(82) != 0)) { - // Furthest possible fog and zFar - gPlayState->view.zFar = 12800; - gPlayState->lightCtx.fogNear = 996; // Set to 1000 to complete disable fog entirely - gPlayState->lightCtx.fogFar = 12800; - // General gray fog color - gPlayState->lightCtx.fogColor[0] = 100; - gPlayState->lightCtx.fogColor[1] = 100; - gPlayState->lightCtx.fogColor[2] = 100; - } - break; - } - } - }); - REGISTER_VB_SHOULD(VB_DRAW_2D_BACKGROUND, { - if (CVAR_VALUE) { - *should = false; - return; + if ((HREG(80) != 10) || (HREG(82) != 0)) { + // Furthest possible fog and zFar + gPlayState->view.zFar = 12800; + gPlayState->lightCtx.fogNear = 996; // Set to 1000 to complete disable fog entirely + gPlayState->lightCtx.fogFar = 12800; + // General gray fog color + gPlayState->lightCtx.fogColor[0] = 100; + gPlayState->lightCtx.fogColor[1] = 100; + gPlayState->lightCtx.fogColor[2] = 100; } }); - REGISTER_VB_SHOULD(VB_LOAD_SKYBOX, { - if (!gPlayState) { - return; - } + COND_VB_SHOULD(VB_DRAW_2D_BACKGROUND, CVAR_VALUE, { *should = false; }); - if (!CVAR_VALUE) { + COND_VB_SHOULD(VB_LOAD_SKYBOX, CVAR_VALUE, { + if (!gPlayState || !skyboxIdControlList.contains(static_cast<SkyboxId>(gPlayState->skyboxCtx.skyboxId))) { return; } - for (auto& skybox : skyboxIdControlList) { - if (gPlayState->skyboxCtx.skyboxId == skybox) { - gPlayState->skyboxCtx.unk_140 = 0; - *should = false; - return; - } - } + gPlayState->skyboxCtx.unk_140 = 0; + *should = false; }); } -static RegisterShipInitFunc initFunc(Register3DPreRenderedScenes, { CVAR_NAME });
\ No newline at end of file +static RegisterShipInitFunc initFunc(Register3DPreRenderedScenes, { CVAR_NAME }); diff --git a/soh/soh/z_scene_otr.cpp b/soh/soh/z_scene_otr.cpp index d49367024..1da9d729a 100644 --- a/soh/soh/z_scene_otr.cpp +++ b/soh/soh/z_scene_otr.cpp @@ -472,13 +472,12 @@ extern "C" s32 OTRfunc_800973FC(PlayState* play, RoomContext* roomCtx) { gSegments[3] = VIRTUAL_TO_PHYSICAL(roomCtx->unk_34); OTRScene_ExecuteCommands(play, (SOH::Scene*)roomCtx->roomToLoad); - if (!GameInteractor_Should(VB_DRAW_2D_BACKGROUND, true)) { - play->envCtx.skyboxDisabled = false; - } Player_SetBootData(play, GET_PLAYER(play)); Actor_SpawnTransitionActors(play, &play->actorCtx); + GameInteractor_ExecuteAfterSceneCommands(play->sceneNum); + return 1; } |
