summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/newgrf.cpp2
-rw-r--r--src/newgrf_sound.cpp4
-rw-r--r--src/sound.cpp12
-rw-r--r--src/sound_func.h1
-rw-r--r--src/sound_type.h3
5 files changed, 7 insertions, 15 deletions
diff --git a/src/newgrf.cpp b/src/newgrf.cpp
index 43a5e9f1f..b058d8fd0 100644
--- a/src/newgrf.cpp
+++ b/src/newgrf.cpp
@@ -2020,7 +2020,7 @@ static ChangeInfoResult SoundEffectChangeInfo(uint sid, int numinfo, int prop, b
}
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()) {
grfmsg(1, "SoundEffectChangeInfo: Sound %d not defined (max %d)", sound, GetNumSounds());
diff --git a/src/newgrf_sound.cpp b/src/newgrf_sound.cpp
index 7f8f31179..72f2da840 100644
--- a/src/newgrf_sound.cpp
+++ b/src/newgrf_sound.cpp
@@ -60,7 +60,7 @@ bool PlayVehicleSound(const Vehicle *v, VehicleSoundEvent event)
callback = GetVehicleCallback(CBID_VEHICLE_SOUND_EFFECT, event, 0, v->engine_type, v);
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);
return true;
@@ -68,7 +68,7 @@ bool PlayVehicleSound(const Vehicle *v, VehicleSoundEvent event)
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()) {
SndPlayTileFx((SoundFx)sound_id, tile);
diff --git a/src/sound.cpp b/src/sound.cpp
index 4401fc67b..a12b2b840 100644
--- a/src/sound.cpp
+++ b/src/sound.cpp
@@ -13,20 +13,15 @@
#include "vehicle_base.h"
#include "debug.h"
-static uint _file_count;
static FileEntry *_files;
MusicFileSettings msf;
/* Number of levels of panning per side */
#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)
{
FileEntry *fe = CallocT<FileEntry>(ORIGINAL_SAMPLE_COUNT);
- _file_count = ORIGINAL_SAMPLE_COUNT;
_files = fe;
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)
{
assert(fe != NULL);
@@ -187,7 +177,7 @@ static const byte _sound_idx[] = {
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 *fe = AllocateFileEntry();
diff --git a/src/sound_func.h b/src/sound_func.h
index d60822ca5..8de679cd1 100644
--- a/src/sound_func.h
+++ b/src/sound_func.h
@@ -12,7 +12,6 @@
extern MusicFileSettings msf;
bool SoundInitialize(const char *filename);
-uint GetNumOriginalSounds();
void SndPlayTileFx(SoundFx sound, TileIndex tile);
void SndPlayVehicleFx(SoundFx sound, const Vehicle *v);
diff --git a/src/sound_type.h b/src/sound_type.h
index 8efc6a22a..0879ff717 100644
--- a/src/sound_type.h
+++ b/src/sound_type.h
@@ -110,4 +110,7 @@ enum SoundFx {
template <> struct EnumPropsT<SoundFx> : MakeEnumPropsT<SoundFx, byte, SND_BEGIN, SND_END, SND_END> {};
typedef TinyEnumT<SoundFx> SoundFxByte;
+/** The number of sounds in the original sample.cat */
+static const uint ORIGINAL_SAMPLE_COUNT = 73;
+
#endif /* SOUND_TYPE_H */