OpenTTD Source
20241120-master-g6d3adc6169
|
Handling NewGRF provided sounds. More...
#include "stdafx.h"
#include "engine_base.h"
#include "newgrf.h"
#include "newgrf_engine.h"
#include "newgrf_sound.h"
#include "vehicle_base.h"
#include "sound_func.h"
#include "random_access_file_type.h"
#include "debug.h"
#include "settings_type.h"
#include "safeguards.h"
Go to the source code of this file.
Functions | |
SoundEntry * | AllocateSound (uint num) |
Allocate sound slots. More... | |
void | InitializeSoundPool () |
SoundEntry * | GetSound (SoundID index) |
uint | GetNumSounds () |
bool | LoadNewGRFSound (SoundEntry *sound) |
Extract meta data from a NewGRF sound. More... | |
SoundID | GetNewGRFSoundID (const GRFFile *file, SoundID sound_id) |
Resolve NewGRF sound ID. More... | |
bool | PlayVehicleSound (const Vehicle *v, VehicleSoundEvent event, bool force) |
Checks whether a NewGRF wants to play a different vehicle sound effect. More... | |
void | PlayTileSound (const GRFFile *file, SoundID sound_id, TileIndex tile) |
Play a NewGRF sound effect at the location of a specific tile. More... | |
Variables | |
static std::vector< SoundEntry > | _sounds |
Handling NewGRF provided sounds.
Definition in file newgrf_sound.cpp.
SoundEntry* AllocateSound | ( | uint | num | ) |
Allocate sound slots.
num | Number of slots to allocate. |
Definition at line 31 of file newgrf_sound.cpp.
SoundID GetNewGRFSoundID | ( | const GRFFile * | file, |
SoundID | sound_id | ||
) |
Resolve NewGRF sound ID.
file | NewGRF to get sound from. |
sound_id | GRF-specific sound ID. (GRF-local for IDs above ORIGINAL_SAMPLE_COUNT) |
Definition at line 169 of file newgrf_sound.cpp.
References ORIGINAL_SAMPLE_COUNT.
Referenced by PlayTileSound().
bool LoadNewGRFSound | ( | SoundEntry * | sound | ) |
Extract meta data from a NewGRF sound.
sound | Sound to load. |
Definition at line 66 of file newgrf_sound.cpp.
References BSWAP32(), Debug, RandomAccessFile::GetPos(), RandomAccessFile::GetSimplifiedFilename(), SoundEntry::grf_container_ver, MemSetT(), RandomAccessFile::ReadBlock(), RandomAccessFile::ReadByte(), RandomAccessFile::ReadDword(), RandomAccessFile::ReadWord(), RandomAccessFile::SeekTo(), and RandomAccessFile::SkipBytes().
Play a NewGRF sound effect at the location of a specific tile.
file | NewGRF triggering the sound effect. |
sound_id | Sound effect the NewGRF wants to play. |
tile | Location of the effect. |
Definition at line 220 of file newgrf_sound.cpp.
References GetNewGRFSoundID().
bool PlayVehicleSound | ( | const Vehicle * | v, |
VehicleSoundEvent | event, | ||
bool | force | ||
) |
Checks whether a NewGRF wants to play a different vehicle sound effect.
v | Vehicle to play sound effect for. |
event | Trigger for the sound effect. |
force | Should we play the sound effect even if vehicle sound effects are muted? |
Definition at line 187 of file newgrf_sound.cpp.
References _settings_client, Vehicle::GetGRF(), ClientSettings::sound, and SoundSettings::vehicle.
Referenced by Vehicle::HandleBreakdown(), and Train::PlayLeaveStationSound().