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"

Go to the source code of this file.

Functions

SoundEntryAllocateSound (uint num)
 Allocate sound slots.
void InitializeSoundPool ()
SoundEntryGetSound (SoundID index)
uint GetNumSounds ()
bool LoadNewGRFSound (SoundEntry *sound)
 Extract meta data from a NewGRF sound.
bool PlayVehicleSound (const Vehicle *v, VehicleSoundEvent event)
 Checks whether a NewGRF wants to play a different vehicle sound effect.
void PlayTileSound (const GRFFile *file, SoundID sound_id, TileIndex tile)
 Play a NewGRF sound effect at the location of a specfic tile.

Variables

static SmallVector< SoundEntry, 8 > _sounds

Detailed Description

Handling NewGRF provided sounds.

Definition in file newgrf_sound.cpp.


Function Documentation

SoundEntry* AllocateSound ( uint  num  ) 

Allocate sound slots.

Parameters:
num Number of slots to allocate.
Returns:
First allocated slot.

Definition at line 31 of file newgrf_sound.cpp.

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

bool LoadNewGRFSound ( SoundEntry sound  ) 

Extract meta data from a NewGRF sound.

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

Definition at line 66 of file newgrf_sound.cpp.

References AllocaM, BSWAP32(), DEBUG, FioGetFilename(), FioGetPos(), FioReadBlock(), FioReadByte(), FioReadDword(), FioReadWord(), FioSeekToFile(), FioSkipBytes(), SoundEntry::grf_container_ver, and MemSetT().

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

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

Parameters:
file NewGRF triggering the sound effect.
sound_id Sound effect the NewGRF wants to play.
tile Location of the effect.

Definition at line 206 of file newgrf_sound.cpp.

References ORIGINAL_SAMPLE_COUNT.

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

bool PlayVehicleSound ( const Vehicle v,
VehicleSoundEvent  event 
)

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

Parameters:
v Vehicle to play sound effect for.
event Trigger for the sound effect.
Returns:
false if the default sound effect shall be played instead.

Definition at line 169 of file newgrf_sound.cpp.

References _settings_client, CALLBACK_FAILED, CBID_VEHICLE_SOUND_EFFECT, CBM_VEHICLE_SOUND_EFFECT, Vehicle::engine_type, Vehicle::GetGRF(), GetVehicleCallback(), HasBit(), ORIGINAL_SAMPLE_COUNT, ClientSettings::sound, and SoundSettings::vehicle.

Referenced by AircraftController(), AircraftLandAirplane(), Vehicle::HandleBreakdown(), Train::PlayLeaveStationSound(), and Vehicle::ShowVisualEffect().