mirror of https://github.com/OpenTTD/OpenTTD
(svn r16337) -Codechange: remove pointless variable + wrapper function; having it return anything else than ORIGINAL_SAMPLE_COUNT is asking for NewGRFs failing to load (due to invalid sample index), thus desyncs
parent
10ea72a08e
commit
83dc6ef6e6
|
@ -2020,7 +2020,7 @@ static ChangeInfoResult SoundEffectChangeInfo(uint sid, int numinfo, int prop, b
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < numinfo; i++) {
|
for (int i = 0; i < numinfo; i++) {
|
||||||
uint sound = sid + i + _cur_grffile->sound_offset - GetNumOriginalSounds();
|
uint sound = sid + i + _cur_grffile->sound_offset - ORIGINAL_SAMPLE_COUNT;
|
||||||
|
|
||||||
if (sound >= GetNumSounds()) {
|
if (sound >= GetNumSounds()) {
|
||||||
grfmsg(1, "SoundEffectChangeInfo: Sound %d not defined (max %d)", sound, GetNumSounds());
|
grfmsg(1, "SoundEffectChangeInfo: Sound %d not defined (max %d)", sound, GetNumSounds());
|
||||||
|
|
|
@ -60,7 +60,7 @@ bool PlayVehicleSound(const Vehicle *v, VehicleSoundEvent event)
|
||||||
|
|
||||||
callback = GetVehicleCallback(CBID_VEHICLE_SOUND_EFFECT, event, 0, v->engine_type, v);
|
callback = GetVehicleCallback(CBID_VEHICLE_SOUND_EFFECT, event, 0, v->engine_type, v);
|
||||||
if (callback == CALLBACK_FAILED) return false;
|
if (callback == CALLBACK_FAILED) return false;
|
||||||
if (callback >= GetNumOriginalSounds()) callback += file->sound_offset - GetNumOriginalSounds();
|
if (callback >= ORIGINAL_SAMPLE_COUNT) callback += file->sound_offset - ORIGINAL_SAMPLE_COUNT;
|
||||||
|
|
||||||
if (callback < GetNumSounds()) SndPlayVehicleFx((SoundFx)callback, v);
|
if (callback < GetNumSounds()) SndPlayVehicleFx((SoundFx)callback, v);
|
||||||
return true;
|
return true;
|
||||||
|
@ -68,7 +68,7 @@ bool PlayVehicleSound(const Vehicle *v, VehicleSoundEvent event)
|
||||||
|
|
||||||
bool PlayTileSound(const GRFFile *file, uint16 sound_id, TileIndex tile)
|
bool PlayTileSound(const GRFFile *file, uint16 sound_id, TileIndex tile)
|
||||||
{
|
{
|
||||||
if (sound_id >= GetNumOriginalSounds()) sound_id += file->sound_offset - GetNumOriginalSounds();
|
if (sound_id >= ORIGINAL_SAMPLE_COUNT) sound_id += file->sound_offset - ORIGINAL_SAMPLE_COUNT;
|
||||||
|
|
||||||
if (sound_id < GetNumSounds()) {
|
if (sound_id < GetNumSounds()) {
|
||||||
SndPlayTileFx((SoundFx)sound_id, tile);
|
SndPlayTileFx((SoundFx)sound_id, tile);
|
||||||
|
|
|
@ -13,20 +13,15 @@
|
||||||
#include "vehicle_base.h"
|
#include "vehicle_base.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
|
||||||
static uint _file_count;
|
|
||||||
static FileEntry *_files;
|
static FileEntry *_files;
|
||||||
MusicFileSettings msf;
|
MusicFileSettings msf;
|
||||||
|
|
||||||
/* Number of levels of panning per side */
|
/* Number of levels of panning per side */
|
||||||
#define PANNING_LEVELS 16
|
#define PANNING_LEVELS 16
|
||||||
|
|
||||||
/** The number of sounds in the original sample.cat */
|
|
||||||
static const uint ORIGINAL_SAMPLE_COUNT = 73;
|
|
||||||
|
|
||||||
static void OpenBankFile(const char *filename)
|
static void OpenBankFile(const char *filename)
|
||||||
{
|
{
|
||||||
FileEntry *fe = CallocT<FileEntry>(ORIGINAL_SAMPLE_COUNT);
|
FileEntry *fe = CallocT<FileEntry>(ORIGINAL_SAMPLE_COUNT);
|
||||||
_file_count = ORIGINAL_SAMPLE_COUNT;
|
|
||||||
_files = fe;
|
_files = fe;
|
||||||
|
|
||||||
FioOpenFile(SOUND_SLOT, filename);
|
FioOpenFile(SOUND_SLOT, filename);
|
||||||
|
@ -99,11 +94,6 @@ static void OpenBankFile(const char *filename)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint GetNumOriginalSounds()
|
|
||||||
{
|
|
||||||
return _file_count;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool SetBankSource(MixerChannel *mc, const FileEntry *fe)
|
static bool SetBankSource(MixerChannel *mc, const FileEntry *fe)
|
||||||
{
|
{
|
||||||
assert(fe != NULL);
|
assert(fe != NULL);
|
||||||
|
@ -187,7 +177,7 @@ static const byte _sound_idx[] = {
|
||||||
|
|
||||||
void SndCopyToPool()
|
void SndCopyToPool()
|
||||||
{
|
{
|
||||||
for (uint i = 0; i < _file_count; i++) {
|
for (uint i = 0; i < ORIGINAL_SAMPLE_COUNT; i++) {
|
||||||
FileEntry *orig = &_files[_sound_idx[i]];
|
FileEntry *orig = &_files[_sound_idx[i]];
|
||||||
FileEntry *fe = AllocateFileEntry();
|
FileEntry *fe = AllocateFileEntry();
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,6 @@
|
||||||
extern MusicFileSettings msf;
|
extern MusicFileSettings msf;
|
||||||
|
|
||||||
bool SoundInitialize(const char *filename);
|
bool SoundInitialize(const char *filename);
|
||||||
uint GetNumOriginalSounds();
|
|
||||||
|
|
||||||
void SndPlayTileFx(SoundFx sound, TileIndex tile);
|
void SndPlayTileFx(SoundFx sound, TileIndex tile);
|
||||||
void SndPlayVehicleFx(SoundFx sound, const Vehicle *v);
|
void SndPlayVehicleFx(SoundFx sound, const Vehicle *v);
|
||||||
|
|
|
@ -110,4 +110,7 @@ enum SoundFx {
|
||||||
template <> struct EnumPropsT<SoundFx> : MakeEnumPropsT<SoundFx, byte, SND_BEGIN, SND_END, SND_END> {};
|
template <> struct EnumPropsT<SoundFx> : MakeEnumPropsT<SoundFx, byte, SND_BEGIN, SND_END, SND_END> {};
|
||||||
typedef TinyEnumT<SoundFx> SoundFxByte;
|
typedef TinyEnumT<SoundFx> SoundFxByte;
|
||||||
|
|
||||||
|
/** The number of sounds in the original sample.cat */
|
||||||
|
static const uint ORIGINAL_SAMPLE_COUNT = 73;
|
||||||
|
|
||||||
#endif /* SOUND_TYPE_H */
|
#endif /* SOUND_TYPE_H */
|
||||||
|
|
Loading…
Reference in New Issue