Skip to content

Commit ddb50fb

Browse files
authored
Merge pull request scp-fs2open#7207 from Baezon/start-loop-end-snds-fix
Misc fixes to start/loop/end sounds
2 parents 2d4ca56 + d313cf8 commit ddb50fb

1 file changed

Lines changed: 12 additions & 12 deletions

File tree

code/ship/ship.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10778,31 +10778,31 @@ void update_firing_sounds(object* objp, ship* shipp)
1077810778
// equality comparisons to -1 are correct here, -2 is valid and means a loop is active but the modder didnt specify an actual loop sound
1077910779

1078010780
if (swp->firing_loop_sounds[i] == -1 && trigger_down && !primaries_locked && selected && has_resources && burst_only_allowed && !dying) {
10781+
auto* pm = model_get(Ship_info[shipp->ship_info_index].model_num);
10782+
vec3d snd_pos;
10783+
vm_vec_avg_n(&snd_pos, pm->gun_banks[i].num_slots, pm->gun_banks[i].pnt);
10784+
1078110785
if (wip->start_firing_snd.isValid() && start_snd_played != wip->start_firing_snd) {
10782-
if (objp == Player_obj)
10783-
snd_play(gamesnd_get_game_sound(wip->start_firing_snd));
10784-
else
10785-
snd_play_3d(gamesnd_get_game_sound(wip->start_firing_snd), &objp->pos, &View_position);
10786+
obj_snd_assign(shipp->objnum, wip->start_firing_snd, &snd_pos, OS_PLAY_ON_PLAYER | OS_LOOPING_DISABLED);
1078610787

1078710788
start_snd_played = wip->start_firing_snd;
1078810789
}
1078910790

10790-
vec3d pos = model_get(Ship_info[shipp->ship_info_index].model_num)->view_positions[0].pnt;
10791-
1079210791
if (wip->linked_loop_firing_snd.isValid() && shipp->flags[Ship::Ship_Flags::Primary_linked])
10793-
swp->firing_loop_sounds[i] = obj_snd_assign(shipp->objnum, wip->linked_loop_firing_snd, &pos, OS_PLAY_ON_PLAYER);
10792+
swp->firing_loop_sounds[i] = obj_snd_assign(shipp->objnum, wip->linked_loop_firing_snd, &snd_pos, OS_PLAY_ON_PLAYER);
1079410793
else if (wip->loop_firing_snd.isValid())
10795-
swp->firing_loop_sounds[i] = obj_snd_assign(shipp->objnum, wip->loop_firing_snd, &pos, OS_PLAY_ON_PLAYER);
10794+
swp->firing_loop_sounds[i] = obj_snd_assign(shipp->objnum, wip->loop_firing_snd, &snd_pos, OS_PLAY_ON_PLAYER);
1079610795
else
1079710796
swp->firing_loop_sounds[i] = -2;
1079810797
}
1079910798

1080010799
if (swp->firing_loop_sounds[i] != -1 && (!trigger_down || primaries_locked || !selected || !has_resources || !burst_only_allowed || dying)) {
10800+
auto* pm = model_get(Ship_info[shipp->ship_info_index].model_num);
10801+
vec3d snd_pos;
10802+
vm_vec_avg_n(&snd_pos, pm->gun_banks[i].num_slots, pm->gun_banks[i].pnt);
10803+
1080110804
if (wip->end_firing_snd.isValid() && end_snd_played != wip->end_firing_snd) {
10802-
if (objp == Player_obj)
10803-
snd_play(gamesnd_get_game_sound(wip->end_firing_snd));
10804-
else
10805-
snd_play_3d(gamesnd_get_game_sound(wip->end_firing_snd), &objp->pos, &View_position);
10805+
obj_snd_assign(shipp->objnum, wip->end_firing_snd, &snd_pos, OS_PLAY_ON_PLAYER | OS_LOOPING_DISABLED);
1080610806

1080710807
end_snd_played = wip->end_firing_snd;
1080810808
}

0 commit comments

Comments
 (0)