12#include "../newgrf_sound.h"
16#include "../safeguards.h"
30 if (_cur.
grffile->sound_offset == 0) {
31 GrfMsg(1,
"SoundEffectChangeInfo: No effects defined, skipping");
36 GrfMsg(1,
"SoundEffectChangeInfo: Attempting to change undefined sound effect ({}), max ({}). Ignoring.", last,
ORIGINAL_SAMPLE_COUNT + _cur.
grffile->num_sounds);
40 for (uint
id = first;
id < last; ++id) {
45 sound->volume =
Clamp(buf.
ReadByte(), 0, SOUND_EFFECT_MAX_VOLUME);
56 GrfMsg(1,
"SoundEffectChangeInfo: Original sound {} not defined (max {})", orig_sound,
ORIGINAL_SAMPLE_COUNT);
Class to read from a NewGRF file.
uint8_t ReadByte()
Read a single byte (8 bits).
constexpr T Clamp(const T a, const T min, const T max)
Clamp a value between an interval.
static ChangeInfoResult SoundEffectChangeInfo(uint first, uint last, int prop, ByteReader &buf)
Define properties for sound effects.
NewGRF buffer reader definition.
NewGRF internal processing state.
ChangeInfoResult
Possible return values for the GrfChangeInfoHandler functions.
@ CIR_INVALID_ID
Attempt to modify an invalid ID.
@ CIR_UNKNOWN
Variable is unknown.
@ CIR_UNHANDLED
Variable was parsed but unread.
@ CIR_SUCCESS
Variable was parsed and read.
static const uint ORIGINAL_SAMPLE_COUNT
The number of sounds in the original sample.cat.
GRFFile * grffile
Currently processed GRF file.