From c8bbfbc8368d6ad036e0c810d4695ca13cc0998f Mon Sep 17 00:00:00 2001 From: PJB3005 Date: Tue, 7 Apr 2026 15:41:56 +0200 Subject: [PATCH 1/3] Fix Argorok Peahat camera init race condition Fixes #264 --- src/d/actor/d_a_e_ph.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/d/actor/d_a_e_ph.cpp b/src/d/actor/d_a_e_ph.cpp index dc20cb2361..df22c6cb66 100644 --- a/src/d/actor/d_a_e_ph.cpp +++ b/src/d/actor/d_a_e_ph.cpp @@ -1154,6 +1154,18 @@ int daE_PH_c::create() { int phase_state = dComIfG_resLoad(&mPhase, "E_PH"); if (phase_state == cPhs_COMPLEATE_e) { + +#if TARGET_PC + // Due to our loads being so much faster, peahats can initialize *before* the camera. + // This breaks the peahat used for camera focus during transition to phase 2 of Argorok. + // as it caches incorrect camera parameters in its init. + if (auto cam = dComIfGp_getCamera(0)) { + if (cam->phase_request.mpHandlerTable != nullptr) { + return cPhs_INIT_e; + } + } +#endif + mAction = fopAcM_GetParam(this) & 0xF; if (dComIfGs_isZoneSwitch(2, fopAcM_GetRoomNo(this)) && mAction == 4) { @@ -1256,6 +1268,10 @@ int daE_PH_c::create() { if (mAction == 5) { dCamera_c* camera_p = dCam_getBody(); mCamFovY = camera_p->Fovy(); + if (mCamFovY < 1) { + OSReport("GUH"); + mCamFovY = 10; + } mCamCenter = camera_p->Center(); mCamCenterTarget = mCamCenter; From 3229afa0b123acab6543a5df8dbde4984dc1e406 Mon Sep 17 00:00:00 2001 From: PJB3005 Date: Tue, 7 Apr 2026 15:44:37 +0200 Subject: [PATCH 2/3] More TU debug consistency Thought this was the cause of #264. Didn't end up being the case but figure it's still best to fix it. --- CMakeLists.txt | 4 ++-- include/d/d_camera.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 164d5aa893..66c86bb5f4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -137,8 +137,8 @@ add_library(game_base OBJECT ${DOLZEL_FILES} ${Z2AUDIOLIB_FILES} ${JSYSTEM_FILES src/dusk/imgui/ImGuiStubLog.cpp src/dusk/imgui/ImGuiAudio.cpp) -target_compile_definitions(game_debug PRIVATE ${GAME_COMPILE_DEFS} $<$:DEBUG=1>) -target_compile_definitions(game_base PRIVATE ${GAME_COMPILE_DEFS} NDEBUG=1 NDEBUG_DEFINED=1 DEBUG_DEFINED=0) +target_compile_definitions(game_debug PRIVATE ${GAME_COMPILE_DEFS} $<$:DEBUG=1> $<$:PARTIAL_DEBUG=1>) +target_compile_definitions(game_base PRIVATE ${GAME_COMPILE_DEFS} NDEBUG=1 NDEBUG_DEFINED=1 DEBUG_DEFINED=0 $<$:PARTIAL_DEBUG=1>) # only apply PCH to game_base since not all headers are necessarily validated with DEBUG=1 target_precompile_headers(game_base PRIVATE "$<$:${CMAKE_SOURCE_DIR}/include/dusk_pch.hpp>") diff --git a/include/d/d_camera.h b/include/d/d_camera.h index 37b634d18f..85e930c395 100644 --- a/include/d/d_camera.h +++ b/include/d/d_camera.h @@ -1154,7 +1154,7 @@ public: static engine_fn engine_tbl[]; /* 0x000 */ camera_class* field_0x0; -#if DEBUG +#if PARTIAL_DEBUG || DEBUG // Ensure struct layout consistent in all TUs. cXyz dbg_field_0x04[16]; s8 dbg_field_0xc4[0x10]; u32 dbg_field_0xd4; From 8e70468d027cbd1c65c2759a06aaf6f6e3798a41 Mon Sep 17 00:00:00 2001 From: PJB3005 Date: Tue, 7 Apr 2026 15:45:09 +0200 Subject: [PATCH 3/3] Guh --- src/d/actor/d_a_e_ph.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/d/actor/d_a_e_ph.cpp b/src/d/actor/d_a_e_ph.cpp index df22c6cb66..3213c2716e 100644 --- a/src/d/actor/d_a_e_ph.cpp +++ b/src/d/actor/d_a_e_ph.cpp @@ -1268,10 +1268,6 @@ int daE_PH_c::create() { if (mAction == 5) { dCamera_c* camera_p = dCam_getBody(); mCamFovY = camera_p->Fovy(); - if (mCamFovY < 1) { - OSReport("GUH"); - mCamFovY = 10; - } mCamCenter = camera_p->Center(); mCamCenterTarget = mCamCenter;