OpenTTD
Functions | Variables
newgrf_sound.cpp File Reference

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 "fileio_func.h"
#include "debug.h"
#include "settings_type.h"
#include "safeguards.h"

Go to the source code of this file.

Functions

SoundEntryAllocateSound (uint num)
 Allocate sound slots. More...
 
void InitializeSoundPool ()
 
SoundEntryGetSound (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)
 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 SmallVector< SoundEntry, 8 > _sounds
 

Detailed Description

Handling NewGRF provided sounds.

Definition in file newgrf_sound.cpp.

Function Documentation

◆ AllocateSound()

SoundEntry* AllocateSound ( uint  num)

Allocate sound slots.

Parameters
numNumber of slots to allocate.
Returns
First allocated slot.

Definition at line 33 of file newgrf_sound.cpp.

References SmallVector< T, S >::Append(), and MemSetT().

◆ GetNewGRFSoundID()

SoundID GetNewGRFSoundID ( const GRFFile file,
SoundID  sound_id 
)

Resolve NewGRF sound ID.

Parameters
fileNewGRF to get sound from.
sound_idGRF-specific sound ID. (GRF-local for IDs above ORIGINAL_SAMPLE_COUNT)
Returns
Translated (global) sound ID, or INVALID_SOUND.

Definition at line 170 of file newgrf_sound.cpp.

References ORIGINAL_SAMPLE_COUNT.

Referenced by PlayTileSound(), RoadVehicleChangeInfo(), and ShipVehicleChangeInfo().

◆ LoadNewGRFSound()

bool LoadNewGRFSound ( SoundEntry sound)

Extract meta data from a NewGRF sound.

Parameters
soundSound to load.
Returns
True if a valid sound was loaded.

Definition at line 68 of file newgrf_sound.cpp.

◆ PlayTileSound()

void PlayTileSound ( const GRFFile file,
SoundID  sound_id,
TileIndex  tile 
)

Play a NewGRF sound effect at the location of a specific tile.

Parameters
fileNewGRF triggering the sound effect.
sound_idSound effect the NewGRF wants to play.
tileLocation of the effect.

Definition at line 220 of file newgrf_sound.cpp.

References GetNewGRFSoundID().

Referenced by AnimationBase< IndustryAnimationBase, IndustryTileSpec, Industry, int, GetSimpleIndustryCallback >::ChangeAnimationFrame().

◆ PlayVehicleSound()

bool PlayVehicleSound ( const Vehicle v,
VehicleSoundEvent  event 
)

Checks whether a NewGRF wants to play a different vehicle sound effect.

Parameters
vVehicle to play sound effect for.
eventTrigger for the sound effect.
Returns
false if the default sound effect shall be played instead.

Definition at line 187 of file newgrf_sound.cpp.

References _settings_client, Vehicle::GetGRF(), HasBit(), ClientSettings::sound, and SoundSettings::vehicle.

Referenced by AircraftLandAirplane(), and Vehicle::HandleBreakdown().