diff options
author | abmyii <52673001+abmyii@users.noreply.github.com> | 2019-10-12 09:16:16 +0100 |
---|---|---|
committer | Niels Martin Hansen <nielsm@indvikleren.dk> | 2019-10-12 10:16:16 +0200 |
commit | ac2111873626263ae5492bd2c18ec30f69e84158 (patch) | |
tree | ac3c70e71649f92b1afe3e2b08c147757b0d623f | |
parent | e2e112baaabaaeec1f04f13c3759f24c06b42cf2 (diff) | |
download | openttd-ac2111873626263ae5492bd2c18ec30f69e84158.tar.xz |
Fix #7703: Prevent sounds being produced by inactive industries (#7752)
-rw-r--r-- | src/industry_cmd.cpp | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/industry_cmd.cpp b/src/industry_cmd.cpp index 38edc0835..dfc9cf222 100644 --- a/src/industry_cmd.cpp +++ b/src/industry_cmd.cpp @@ -1124,11 +1124,16 @@ static void ProduceIndustryGoods(Industry *i) /* play a sound? */ if ((i->counter & 0x3F) == 0) { uint32 r; - uint num; - if (Chance16R(1, 14, r) && (num = indsp->number_of_sounds) != 0 && _settings_client.sound.ambient) { - SndPlayTileFx( - (SoundFx)(indsp->random_sounds[((r >> 16) * num) >> 16]), - i->location.tile); + if (Chance16R(1, 14, r) && indsp->number_of_sounds != 0 && _settings_client.sound.ambient) { + for (size_t j = 0; j < lengthof(i->last_month_production); j++) { + if (i->last_month_production[j] > 0) { + /* Play sound since last month had production */ + SndPlayTileFx( + (SoundFx)(indsp->random_sounds[((r >> 16) * indsp->number_of_sounds) >> 16]), + i->location.tile); + break; + } + } } } |