Skip to content

Commit 5f119b0

Browse files
committed
fix scope of ship arc sound generation
The code for generating spark sounds was incorrectly copied from debris to ships, dating all the way back to retail. The sound should be played once per generation event, not once for every electrical arc active on the ship. This fixes a bug that caused overlapping electrical arc sounds.
1 parent 05b44cd commit 5f119b0

2 files changed

Lines changed: 25 additions & 27 deletions

File tree

code/debris/debris.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,14 +302,13 @@ void debris_process_post(object * obj, float frame_time)
302302
arc->endpoint_1 = v2;
303303
arc->endpoint_2 = v3;
304304
break;
305-
306305
case 2:
307306
arc->endpoint_1 = v2;
308307
arc->endpoint_2 = v4;
309308
break;
310309

311310
default:
312-
Int3();
311+
UNREACHABLE("Unhandled case %d for electrical arc creation in debris_process_post()!", n);
313312
}
314313

315314
n++;

code/ship/shipfx.cpp

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2214,14 +2214,13 @@ void shipfx_do_lightning_arcs_frame( ship *shipp )
22142214
arc->endpoint_1 = v2;
22152215
arc->endpoint_2 = v3;
22162216
break;
2217-
22182217
case 2:
22192218
arc->endpoint_1 = v2;
22202219
arc->endpoint_2 = v4;
22212220
break;
22222221

22232222
default:
2224-
Int3();
2223+
UNREACHABLE("Unhandled case %d for electrical arc creation in shipfx_do_lightning_arcs_frame()!", n);
22252224
}
22262225

22272226
// determine what kind of arc to create
@@ -2238,30 +2237,30 @@ void shipfx_do_lightning_arcs_frame( ship *shipp )
22382237
} else if (arc->type == MARC_TYPE_DAMAGED || arc->type == MARC_TYPE_EMP) {
22392238
num_damage_arcs ++;
22402239
}
2240+
}
22412241

2242-
// rotate v2 out of local coordinates into world.
2243-
// Use v2 since it is used in every bolt. See above switch().
2244-
vec3d snd_pos;
2245-
vm_vec_unrotate(&snd_pos, &v2, &obj->orient);
2246-
vm_vec_add2(&snd_pos, &obj->pos );
2247-
2248-
//Play a sound effect
2249-
if ( lifetime > 750 ) {
2250-
// 1.00 second effect
2251-
snd_play_3d( gamesnd_get_game_sound(GameSounds::DEBRIS_ARC_05), &snd_pos, &View_position, obj->radius );
2252-
} else if ( lifetime > 500 ) {
2253-
// 0.75 second effect
2254-
snd_play_3d( gamesnd_get_game_sound(GameSounds::DEBRIS_ARC_04), &snd_pos, &View_position, obj->radius );
2255-
} else if ( lifetime > 250 ) {
2256-
// 0.50 second effect
2257-
snd_play_3d( gamesnd_get_game_sound(GameSounds::DEBRIS_ARC_03), &snd_pos, &View_position, obj->radius );
2258-
} else if ( lifetime > 100 ) {
2259-
// 0.25 second effect
2260-
snd_play_3d( gamesnd_get_game_sound(GameSounds::DEBRIS_ARC_02), &snd_pos, &View_position, obj->radius );
2261-
} else {
2262-
// 0.10 second effect
2263-
snd_play_3d( gamesnd_get_game_sound(GameSounds::DEBRIS_ARC_01), &snd_pos, &View_position, obj->radius );
2264-
}
2242+
// rotate v2 out of local coordinates into world.
2243+
// Use v2 since it is used in every bolt. See above switch().
2244+
vec3d snd_pos;
2245+
vm_vec_unrotate(&snd_pos, &v2, &obj->orient);
2246+
vm_vec_add2(&snd_pos, &obj->pos );
2247+
2248+
//Play a sound effect
2249+
if ( lifetime > 750 ) {
2250+
// 1.00 second effect
2251+
snd_play_3d( gamesnd_get_game_sound(GameSounds::DEBRIS_ARC_05), &snd_pos, &View_position, obj->radius );
2252+
} else if ( lifetime > 500 ) {
2253+
// 0.75 second effect
2254+
snd_play_3d( gamesnd_get_game_sound(GameSounds::DEBRIS_ARC_04), &snd_pos, &View_position, obj->radius );
2255+
} else if ( lifetime > 250 ) {
2256+
// 0.50 second effect
2257+
snd_play_3d( gamesnd_get_game_sound(GameSounds::DEBRIS_ARC_03), &snd_pos, &View_position, obj->radius );
2258+
} else if ( lifetime > 100 ) {
2259+
// 0.25 second effect
2260+
snd_play_3d( gamesnd_get_game_sound(GameSounds::DEBRIS_ARC_02), &snd_pos, &View_position, obj->radius );
2261+
} else {
2262+
// 0.10 second effect
2263+
snd_play_3d( gamesnd_get_game_sound(GameSounds::DEBRIS_ARC_01), &snd_pos, &View_position, obj->radius );
22652264
}
22662265
}
22672266

0 commit comments

Comments
 (0)