Skip sound effects handling earlier if effects volume is 0

pull/428/head
Jonathan G Rennison 2 years ago
parent 4fd8634ff9
commit 0bec49fa56

@ -185,7 +185,7 @@ SoundID GetNewGRFSoundID(const GRFFile *file, SoundID sound_id)
*/ */
bool PlayVehicleSound(const Vehicle *v, VehicleSoundEvent event) bool PlayVehicleSound(const Vehicle *v, VehicleSoundEvent event)
{ {
if (!_settings_client.sound.vehicle) return true; if (!_settings_client.sound.vehicle || _settings_client.music.effect_vol == 0) return true;
const GRFFile *file = v->GetGRF(); const GRFFile *file = v->GetGRF();
uint16 callback; uint16 callback;

@ -256,8 +256,6 @@ void SndCopyToPool()
*/ */
static void SndPlayScreenCoordFx(SoundID sound, int left, int right, int top, int bottom) static void SndPlayScreenCoordFx(SoundID sound, int left, int right, int top, int bottom)
{ {
if (_settings_client.music.effect_vol == 0) return;
for (const Window *w : Window::IterateFromBack()) { for (const Window *w : Window::IterateFromBack()) {
const Viewport *vp = w->viewport; const Viewport *vp = w->viewport;
@ -280,6 +278,8 @@ static void SndPlayScreenCoordFx(SoundID sound, int left, int right, int top, in
void SndPlayTileFx(SoundID sound, TileIndex tile) void SndPlayTileFx(SoundID sound, TileIndex tile)
{ {
if (_settings_client.music.effect_vol == 0) return;
/* emits sound from center of the tile */ /* emits sound from center of the tile */
int x = std::min(MapMaxX() - 1, TileX(tile)) * TILE_SIZE + TILE_SIZE / 2; int x = std::min(MapMaxX() - 1, TileX(tile)) * TILE_SIZE + TILE_SIZE / 2;
int y = std::min(MapMaxY() - 1, TileY(tile)) * TILE_SIZE - TILE_SIZE / 2; int y = std::min(MapMaxY() - 1, TileY(tile)) * TILE_SIZE - TILE_SIZE / 2;
@ -292,6 +292,8 @@ void SndPlayTileFx(SoundID sound, TileIndex tile)
void SndPlayVehicleFx(SoundID sound, const Vehicle *v) void SndPlayVehicleFx(SoundID sound, const Vehicle *v)
{ {
if (_settings_client.music.effect_vol == 0) return;
SndPlayScreenCoordFx(sound, SndPlayScreenCoordFx(sound,
v->coord.left, v->coord.right, v->coord.left, v->coord.right,
v->coord.top, v->coord.bottom v->coord.top, v->coord.bottom

@ -1442,7 +1442,7 @@ void VehicleTickMotion(Vehicle *v, Vehicle *front)
if (v->vehstatus & VS_HIDDEN) return; if (v->vehstatus & VS_HIDDEN) return;
v->motion_counter += front->cur_speed; v->motion_counter += front->cur_speed;
if (_settings_client.sound.vehicle) { if (_settings_client.sound.vehicle && _settings_client.music.effect_vol != 0) {
/* Play a running sound if the motion counter passes 256 (Do we not skip sounds?) */ /* Play a running sound if the motion counter passes 256 (Do we not skip sounds?) */
if (GB(v->motion_counter, 0, 8) < front->cur_speed) PlayVehicleSound(v, VSE_RUNNING); if (GB(v->motion_counter, 0, 8) < front->cur_speed) PlayVehicleSound(v, VSE_RUNNING);

Loading…
Cancel
Save