From f94b3080629523d991683fabff7f6ec3584534d8 Mon Sep 17 00:00:00 2001 From: jerrrrycho Date: Thu, 15 Oct 2026 22:26:13 +0200 Subject: [PATCH] fix(sound): check for the player train in the outer noise test of a vehicle The test whether a vehicle belongs to the player train dereferenced simulation::Train without a null check (commented out long ago). The driver mode switches to the free camera in the same frame the player train goes through a portal, before the sounds are updated, so it isn't known to crash, but nothing else guards it. --- vehicle/DynObj.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vehicle/DynObj.cpp b/vehicle/DynObj.cpp index c6793e454..6f151f0e8 100644 --- a/vehicle/DynObj.cpp +++ b/vehicle/DynObj.cpp @@ -4863,7 +4863,7 @@ void TDynamicObject::RenderSounds() { #endif && ( // compound test whether the vehicle belongs to user-driven consist (as these don't emit outer noise in cab view) FreeFlyModeFlag ? true : // in external view all vehicles emit outer noise - // Global.pWorld->train() == nullptr ? true : // (can skip this check, with no player train the external view is a given) + simulation::Train == nullptr ? true : // no player train, e.g. it went through a portal and the view isn't switched yet ctOwner == nullptr ? true : // standalone vehicle, can't be part of user-driven train ctOwner != simulation::Train->Dynamic()->ctOwner ? true : // confirmed isn't a part of the user-driven train Global.CabWindowOpen ? true : // sticking head out we get to hear outer noise