Skip to content

Commit 611de4d

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 8270a38 commit 611de4d

File tree

2 files changed

+25
-27
lines changed

2 files changed

+25
-27
lines changed

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
@@ -2220,14 +2220,13 @@ void shipfx_do_lightning_arcs_frame( ship *shipp )
22202220
arc->endpoint_1 = v2;
22212221
arc->endpoint_2 = v3;
22222222
break;
2223-
22242223
case 2:
22252224
arc->endpoint_1 = v2;
22262225
arc->endpoint_2 = v4;
22272226
break;
22282227

22292228
default:
2230-
Int3();
2229+
UNREACHABLE("Unhandled case %d for electrical arc creation in shipfx_do_lightning_arcs_frame()!", n);
22312230
}
22322231

22332232
// determine what kind of arc to create
@@ -2244,30 +2243,30 @@ void shipfx_do_lightning_arcs_frame( ship *shipp )
22442243
} else if (arc->type == MARC_TYPE_DAMAGED || arc->type == MARC_TYPE_EMP) {
22452244
num_damage_arcs ++;
22462245
}
2246+
}
22472247

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

0 commit comments

Comments
 (0)