Skip to content

Commit 54c00ce

Browse files
authored
Two Sound Updates (#6781)
* Two Sound Updates On current master, destroyed engines still make noise and the `Engine Minimum Volume` is not used by big ships. This PR makes two new game settings flags which allow mods to mitigate those issues (`$Unify minimum engine sound:` and `$Disabled engines are silent:`). Tested and works as expected. I also added both of these to the 25.0 default, but happy to alter however. * disabled eng snd does not need flag fix * ensure retail large ships still sound loud
1 parent a9664ff commit 54c00ce

File tree

5 files changed

+13
-5
lines changed

5 files changed

+13
-5
lines changed

code/mod_table/mod_table.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ bool SCPUI_loads_hi_res_animations;
152152
bool Auto_assign_personas;
153153
bool Countermeasures_use_capacity;
154154
bool Play_thruster_sounds_for_player;
155+
bool Unify_minimum_engine_sound;
155156
std::array<std::tuple<float, float>, 6> Fred_spacemouse_nonlinearity;
156157
bool Randomize_particle_rotation;
157158
bool Disable_shield_effects;
@@ -1043,6 +1044,10 @@ void parse_mod_table(const char *filename)
10431044
stuff_boolean(&Play_thruster_sounds_for_player);
10441045
}
10451046

1047+
if (optional_string("$Unify minimum engine sound:")) {
1048+
stuff_boolean(&Unify_minimum_engine_sound);
1049+
}
1050+
10461051
optional_string("#FRED SETTINGS");
10471052

10481053
if (optional_string("$Disable Hard Coded Message Head Ani Files:")) {
@@ -1728,6 +1733,7 @@ void mod_table_reset()
17281733
Auto_assign_personas = true;
17291734
Countermeasures_use_capacity = false;
17301735
Play_thruster_sounds_for_player = false;
1736+
Unify_minimum_engine_sound = false;
17311737
Fred_spacemouse_nonlinearity = std::array<std::tuple<float, float>, 6>{{
17321738
std::tuple<float, float>{ 1.0f, 1.0f },
17331739
std::tuple<float, float>{ 1.0f, 1.0f },

code/mod_table/mod_table.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ extern bool SCPUI_loads_hi_res_animations;
167167
extern bool Auto_assign_personas;
168168
extern bool Countermeasures_use_capacity;
169169
extern bool Play_thruster_sounds_for_player;
170+
extern bool Unify_minimum_engine_sound;
170171
extern std::array<std::tuple<float, float>, 6> Fred_spacemouse_nonlinearity;
171172
extern bool Randomize_particle_rotation;
172173
extern bool Disable_shield_effects;

code/object/objectsnd.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ void obj_snd_do_frame()
517517

518518
// we don't want to start the engine sound unless the ship is
519519
// moving (unless flag SIF_BIG_SHIP is set)
520-
if ( (osp->flags & OS_ENGINE) && !(sip->is_big_or_huge()) ) {
520+
if ( (osp->flags & OS_ENGINE) && (!(sip->is_big_or_huge()) || Unify_minimum_engine_sound) ) {
521521
if ( objp->phys_info.max_vel.xyz.z <= 0.0f ) {
522522
percent_max = 0.0f;
523523
}
@@ -666,7 +666,8 @@ void obj_snd_do_frame()
666666
channel = ds_get_channel(osp->instance);
667667
// for DirectSound3D sounds, re-establish the maximum speed based on the
668668
// speed_vol_multiplier
669-
if ( (sp == nullptr) || !(osp->flags & OS_ENGINE) || (sp->flags[Ship::Ship_Flags::Engines_on]) ) {
669+
if ( (sp == nullptr) || !(osp->flags & OS_ENGINE) ||
670+
((sp->flags[Ship::Ship_Flags::Engine_sound_on]) && !(sp->flags[Ship::Ship_Flags::Disabled])) ) {
670671
snd_set_volume( osp->instance, gs->volume_range.next() *speed_vol_multiplier*rot_vol_mult*alive_vol_mult );
671672
}
672673
else {

code/ship/ship.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7370,7 +7370,7 @@ static void ship_set(int ship_index, int objnum, int ship_type)
73707370

73717371
ets_init_ship(objp); // init ship fields that are used for the ETS
73727372

7373-
shipp->flags.set(Ship_Flags::Engines_on);
7373+
shipp->flags.set(Ship_Flags::Engine_sound_on);
73747374

73757375
// set certain flags that used to be in ship_info - Goober5000
73767376
if (sip->flags[Ship::Info_Flags::Stealth])
@@ -9561,7 +9561,7 @@ static void ship_dying_frame(object *objp, int ship_num)
95619561
// If a ship is dying (and not a capital or big ship) then stutter the engine sound
95629562
if ( timestamp_elapsed(shipp->next_engine_stutter) ) {
95639563
if ( !(sip->is_big_or_huge()) ) {
9564-
shipp->flags.toggle(Ship_Flags::Engines_on); // toggle state of engines
9564+
shipp->flags.toggle(Ship_Flags::Engine_sound_on); // toggle state of engines
95659565
shipp->next_engine_stutter = timestamp_rand(50, 250);
95669566
}
95679567
}

code/ship/ship_flags.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ namespace Ship {
6565
Arriving_stage_1_dock_follower, // "Arriving but Not the Dock Leader"; these guys need some warp stuff done but not all
6666
Arriving_stage_2, // ship is arriving. In other words, doing warp in effect, stage 2
6767
Arriving_stage_2_dock_follower, // "Arriving but Not the Dock Leader"; these guys need some warp stuff done but not all
68-
Engines_on, // engines sound should play if set
68+
Engine_sound_on, // engines sound should play if set
6969
Dock_leader, // Goober5000 - this guy is in charge of everybody he's docked to
7070
Cargo_revealed, // ship's cargo is revealed to all friendly ships
7171
From_player_wing, // set for ships that are members of any player starting wing

0 commit comments

Comments
 (0)