From 9419cac8103fa9842235b2c81f2d9b50c1056f89 Mon Sep 17 00:00:00 2001 From: ZhilkinSerg Date: Wed, 1 Jul 2020 22:04:55 +0300 Subject: [PATCH] Fix compiling when using SDL and SOUND --- src/sounds.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/sounds.cpp b/src/sounds.cpp index 41af771d22db3..dc9f0d3e62129 100644 --- a/src/sounds.cpp +++ b/src/sounds.cpp @@ -1066,9 +1066,10 @@ sfx::sound_thread::sound_thread( const tripoint &source, const tripoint &target, { // This is function is run in the main thread. const int heard_volume = get_heard_volume( source ); - const player *p = g->critter_at( source ); - if( !p ) { - p = &g->u; + npc *np = g->critter_at( source ); + const player &p = np ? static_cast( *np ) : + dynamic_cast( get_player_character() ); + if( !p.is_npc() ) { // sound comes from the same place as the player is, calculation of angle wouldn't work ang_src = 0; vol_src = heard_volume; @@ -1079,8 +1080,8 @@ sfx::sound_thread::sound_thread( const tripoint &source, const tripoint &target, vol_targ = std::max( heard_volume - 20, 0 ); } ang_targ = get_heard_angle( target ); - weapon_skill = p->weapon.melee_skill(); - weapon_volume = p->weapon.volume() / units::legacy_volume_factor; + weapon_skill = p.weapon.melee_skill(); + weapon_volume = p.weapon.volume() / units::legacy_volume_factor; } // Operator overload required for thread API.