41 void InitializeSoundPool()
52 if (index >= _sounds.
Length())
return NULL;
53 return &_sounds[index];
70 if (sound->file_offset == SIZE_MAX || sound->file_slot == 0)
return false;
85 char *name =
AllocaM(
char, name_len + 1);
89 if (name[name_len] != 0) {
90 DEBUG(grf, 2,
"LoadNewGRFSound [%s]: Name not properly terminated",
FioGetFilename(sound->file_slot));
94 DEBUG(grf, 2,
"LoadNewGRFSound [%s]: Sound name '%s'...",
FioGetFilename(sound->file_slot), name);
97 DEBUG(grf, 1,
"LoadNewGRFSound [%s]: Missing RIFF header",
FioGetFilename(sound->file_slot));
102 uint header_size = 11;
104 if (total_size + name_len + header_size > num) {
105 DEBUG(grf, 1,
"LoadNewGRFSound [%s]: RIFF was truncated",
FioGetFilename(sound->file_slot));
110 DEBUG(grf, 1,
"LoadNewGRFSound [%s]: Invalid RIFF type",
FioGetFilename(sound->file_slot));
114 while (total_size >= 8) {
118 if (total_size < size) {
128 DEBUG(grf, 1,
"LoadGRFSound [%s]: Invalid audio format",
FioGetFilename(sound->file_slot));
142 sound->file_size = size;
145 DEBUG(grf, 2,
"LoadNewGRFSound [%s]: channels %u, sample rate %u, bits per sample %u, length %u",
FioGetFilename(sound->file_slot), sound->channels, sound->rate, sound->bits_per_sample, size);
157 DEBUG(grf, 1,
"LoadNewGRFSound [%s]: RIFF does not contain any sound data",
FioGetFilename(sound->file_slot));
176 if (file == NULL || sound_id >= file->num_sounds)
return INVALID_SOUND;
178 return file->sound_offset + sound_id;
195 if (file == NULL)
return false;
207 if (callback == INVALID_SOUND)
return true;
209 assert(callback < GetNumSounds());
210 SndPlayVehicleFx(callback, v);
223 if (sound_id == INVALID_SOUND)
return;
225 assert(sound_id < GetNumSounds());
226 SndPlayTileFx(sound_id, tile);
Functions for NewGRF engines.
static const uint CALLBACK_FAILED
Different values for Callback result evaluations.
Functions related to debugging.
uint16 FioReadWord()
Read a word (16 bits) from the file (in low endian format).
static const uint ORIGINAL_SAMPLE_COUNT
The number of sounds in the original sample.cat.
void Clear()
Remove all items from the list.
Functions for Standard In/Out file operations.
const char * FioGetFilename(uint8 slot)
Get the filename associated with a slot.
Simple vector template class.
#define AllocaM(T, num_elements)
alloca() has to be called in the parent function, so define AllocaM() as a macro
byte FioReadByte()
Read a byte from the file.
Vehicle uses custom sound effects.
byte grf_container_ver
NewGRF container version if the sound is from a NewGRF.
T * Append(uint to_add=1)
Append an item and return it.
uint Length() const
Get the number of items in the list.
Called to play a special sound effect.
SoundSettings sound
sound effect settings
bool LoadNewGRFSound(SoundEntry *sound)
Extract meta data from a NewGRF sound.
void PlayTileSound(const GRFFile *file, SoundID sound_id, TileIndex tile)
Play a NewGRF sound effect at the location of a specific tile.
ClientSettings _settings_client
The current settings for this game.
Types related to global configuration settings.
SoundID GetNewGRFSoundID(const GRFFile *file, SoundID sound_id)
Resolve NewGRF sound ID.
Definition of base types and functions in a cross-platform compatible way.
A number of safeguards to prevent using unsafe methods.
void FioSeekToFile(uint8 slot, size_t pos)
Switch to a different file and seek to a position.
void FioReadBlock(void *ptr, size_t size)
Read a block.
bool vehicle
Play vehicle sound effects.
Functions related to sound.
bool PlayVehicleSound(const Vehicle *v, VehicleSoundEvent event)
Checks whether a NewGRF wants to play a different vehicle sound effect.
SoundEntry * AllocateSound(uint num)
Allocate sound slots.
#define DEBUG(name, level,...)
Output a line of debugging information.
uint32 FioReadDword()
Read a double word (32 bits) from the file (in low endian format).
Base class for all vehicles.
uint32 TileIndex
The index/ID of a Tile.
void FioSkipBytes(int n)
Skip n bytes ahead in the file.
uint16 GetVehicleCallback(CallbackID callback, uint32 param1, uint32 param2, EngineID engine, const Vehicle *v)
Evaluate a newgrf callback for vehicles.
EngineID engine_type
The type of engine used for this vehicle.
VehicleSoundEvent
Events at which a sound might be played.
static bool HasBit(const T x, const uint8 y)
Checks if a bit in a value is set.
Functions related to NewGRF provided sounds.
const GRFFile * GetGRF() const
Retrieve the NewGRF the vehicle is tied to.
size_t FioGetPos()
Get position in the current file.
static uint32 BSWAP32(uint32 x)
Perform a 32 bits endianness bitswap on x.
static void MemSetT(T *ptr, byte value, size_t num=1)
Type-safe version of memset().
Dynamic data of a loaded NewGRF.
Base for the NewGRF implementation.