OpenTTD Source 20241224-master-gf74b0cf984
|
Functions related to NewGRF provided sounds. More...
Go to the source code of this file.
Enumerations | |
enum | VehicleSoundEvent { VSE_START = 1 , VSE_TUNNEL = 2 , VSE_BREAKDOWN = 3 , VSE_RUNNING = 4 , VSE_TOUCHDOWN = 5 , VSE_VISUAL_EFFECT = 6 , VSE_RUNNING_16 = 7 , VSE_STOPPED_16 = 8 , VSE_LOAD_UNLOAD = 9 } |
Events at which a sound might be played. More... | |
Functions | |
SoundEntry * | AllocateSound (uint num) |
Allocate sound slots. | |
void | InitializeSoundPool () |
bool | LoadNewGRFSound (SoundEntry &sound, SoundID sound_id) |
Extract meta data from a NewGRF sound. | |
SoundID | GetNewGRFSoundID (const struct GRFFile *file, SoundID sound_id) |
SoundEntry * | GetSound (SoundID sound_id) |
uint | GetNumSounds () |
size_t | GetSoundPoolAllocatedMemory () |
Get size of memory allocated to sound effects. | |
bool | PlayVehicleSound (const Vehicle *v, VehicleSoundEvent event, bool force=false) |
Checks whether a NewGRF wants to play a different vehicle sound effect. | |
void | PlayTileSound (const struct GRFFile *file, SoundID sound_id, TileIndex tile) |
Functions related to NewGRF provided sounds.
Definition in file newgrf_sound.h.
enum VehicleSoundEvent |
Events at which a sound might be played.
Enumerator | |
---|---|
VSE_START | Vehicle starting, i.e. leaving, the station. |
VSE_TUNNEL | Train entering a tunnel. |
VSE_BREAKDOWN | Vehicle breaking down. |
VSE_RUNNING | Vehicle running normally. |
VSE_TOUCHDOWN | Whenever a plane touches down. |
VSE_VISUAL_EFFECT | Vehicle visual effect (steam, diesel smoke or electric spark) is shown. |
VSE_RUNNING_16 | Every 16 ticks while the vehicle is running (speed > 0). |
VSE_STOPPED_16 | Every 16 ticks while the vehicle is stopped (speed == 0). |
VSE_LOAD_UNLOAD | Whenever cargo payment is made for a vehicle. |
Definition at line 18 of file newgrf_sound.h.
SoundEntry * AllocateSound | ( | uint | num | ) |
Allocate sound slots.
num | Number of slots to allocate. |
Definition at line 33 of file newgrf_sound.cpp.
uint GetNumSounds | ( | ) |
Definition at line 57 of file newgrf_sound.cpp.
SoundEntry * GetSound | ( | SoundID | sound_id | ) |
Definition at line 50 of file newgrf_sound.cpp.
size_t GetSoundPoolAllocatedMemory | ( | ) |
Get size of memory allocated to sound effects.
Definition at line 66 of file newgrf_sound.cpp.
void InitializeSoundPool | ( | ) |
Definition at line 41 of file newgrf_sound.cpp.
bool LoadNewGRFSound | ( | SoundEntry & | sound, |
SoundID | sound_id | ||
) |
Extract meta data from a NewGRF sound.
sound | Sound to load. |
Definition at line 83 of file newgrf_sound.cpp.
References Debug, RandomAccessFile::GetSimplifiedFilename(), SoundEntry::grf_container_ver, RandomAccessFile::ReadBlock(), RandomAccessFile::ReadByte(), RandomAccessFile::ReadDword(), RandomAccessFile::ReadWord(), RandomAccessFile::SeekTo(), and StrMakeValid().
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 143 of file newgrf_sound.cpp.
References _settings_client, CALLBACK_FAILED, EngineInfo::callback_mask, CBID_VEHICLE_SOUND_EFFECT, CBM_VEHICLE_SOUND_EFFECT, Vehicle::engine_type, Vehicle::GetGRF(), GetNewGRFSoundID(), GetVehicleCallback(), HasBit(), ClientSettings::sound, and SoundSettings::vehicle.
Referenced by AircraftController(), AircraftLandAirplane(), Vehicle::HandleBreakdown(), Ship::PlayLeaveStationSound(), Train::PlayLeaveStationSound(), and Vehicle::ShowVisualEffect().