From 5d74fd48b51d5953f36a18cd859f29cb24a2c4be Mon Sep 17 00:00:00 2001 From: Kp Date: Sat, 14 Jul 2018 17:23:15 +0000 Subject: [PATCH] Fix player appearance sound truncation The player appearance sound was tied to the player appearance vclip, but this is wrong because the vclip has a shorter lifetime than the sound. This mistake was previously hidden by the hack that caused non-permanent sounds to be routed off to a separate queue that lost the association between object and sound. Commit 4a98e79 eliminated that hack because it complicated the work of that commit. However, without the hack, object sound effects cannot outlive their host object. Fix this by binding the sound to the position of the appearance effect, not to the appearance object. This works since the appearance effect cannot move, so there was no value to binding the sound to the object. This solution could not be used for objects that move and terminate before their associated sound effect. Reported-by: Ryusei117 Fixes: 4a98e796abb099eb4c592d9520e4edbef7a15d7e ("Prevent stacking weapon rotation sounds") --- similar/main/gameseq.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/similar/main/gameseq.cpp b/similar/main/gameseq.cpp index 9eed02e84..7bd15f90d 100644 --- a/similar/main/gameseq.cpp +++ b/similar/main/gameseq.cpp @@ -641,13 +641,15 @@ void create_player_appearance_effect(const object_base &player_obj) ? vm_vec_scale_add(player_obj.pos, player_obj.orient.fvec, fixmul(player_obj.size, flash_dist)) : player_obj.pos; - const auto &&effect_obj = object_create_explosion(vmsegptridx(player_obj.segnum), pos, player_obj.size, VCLIP_PLAYER_APPEARANCE); + const auto &&seg = vmsegptridx(player_obj.segnum); + const auto &&effect_obj = object_create_explosion(seg, pos, player_obj.size, VCLIP_PLAYER_APPEARANCE); if (effect_obj) { effect_obj->orient = player_obj.orient; - if ( Vclip[VCLIP_PLAYER_APPEARANCE].sound_num > -1 ) - digi_link_sound_to_object(Vclip[VCLIP_PLAYER_APPEARANCE].sound_num, effect_obj, 0, F1_0, sound_stack::allow_stacking); + const auto sound_num = Vclip[VCLIP_PLAYER_APPEARANCE].sound_num; + if (sound_num > -1) + digi_link_sound_to_pos(sound_num, seg, 0, effect_obj->pos, 0, F1_0); } } }