Fix: Maximum permitted sound volume from NewGRF is 128. (#12222)

pull/678/head
Peter Nelson 3 months ago committed by GitHub
parent bc3bd642b9
commit 00b442d6f9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -3153,7 +3153,7 @@ static ChangeInfoResult SoundEffectChangeInfo(uint sid, int numinfo, int prop, B
switch (prop) { switch (prop) {
case 0x08: // Relative volume case 0x08: // Relative volume
sound->volume = buf->ReadByte(); sound->volume = Clamp(buf->ReadByte(), 0, SOUND_EFFECT_MAX_VOLUME);
break; break;
case 0x09: // Priority case 0x09: // Priority
@ -7857,7 +7857,7 @@ static void ImportGRFSound(SoundEntry *sound)
*sound = *GetSound(file->sound_offset + sound_id); *sound = *GetSound(file->sound_offset + sound_id);
/* Reset volume and priority, which TTDPatch doesn't copy */ /* Reset volume and priority, which TTDPatch doesn't copy */
sound->volume = 128; sound->volume = SOUND_EFFECT_MAX_VOLUME;
sound->priority = 0; sound->priority = 0;
} }
@ -7869,7 +7869,7 @@ static void ImportGRFSound(SoundEntry *sound)
static void LoadGRFSound(size_t offs, SoundEntry *sound) static void LoadGRFSound(size_t offs, SoundEntry *sound)
{ {
/* Set default volume and priority */ /* Set default volume and priority */
sound->volume = 0x80; sound->volume = SOUND_EFFECT_MAX_VOLUME;
sound->priority = 0; sound->priority = 0;
if (offs != SIZE_MAX) { if (offs != SIZE_MAX) {

@ -119,4 +119,6 @@ typedef uint16_t SoundID;
static const SoundID INVALID_SOUND = 0xFFFF; static const SoundID INVALID_SOUND = 0xFFFF;
static const uint8_t SOUND_EFFECT_MAX_VOLUME = 128;
#endif /* SOUND_TYPE_H */ #endif /* SOUND_TYPE_H */

Loading…
Cancel
Save