From 7262184d53d55a26f74422831476808fdeb330b3 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 8 Jan 2023 12:40:32 +0100 Subject: [PATCH] - SW: account for invalid player actors being passed to the sound engine. --- source/games/sw/src/sounds.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/source/games/sw/src/sounds.cpp b/source/games/sw/src/sounds.cpp index a6aeb6797..2f2f621d8 100644 --- a/source/games/sw/src/sounds.cpp +++ b/source/games/sw/src/sounds.cpp @@ -529,7 +529,16 @@ void SWSoundEngine::CalcPosVel(int type, const void* source, const float pt[3], } else if (type == SOURCE_Actor || type == SOURCE_Player) { - vPos = type == SOURCE_Actor ? ((DSWActor*)source)->spr.pos : ((PLAYER*)source)->actor->getPosWithOffsetZ(); + if (type == SOURCE_Actor) + { + vPos = ((DSWActor*)source)->spr.pos; + } + else + { + auto act = ((PLAYER*)source)->actor; + if (act) vPos = act->getPosWithOffsetZ(); + else vPos = pp->actor->getPosWithOffsetZ(); + } pancheck = true; FVector3 npos = GetSoundPos(vPos);