summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2009-05-17 19:36:28 +0000
committerrubidium <rubidium@openttd.org>2009-05-17 19:36:28 +0000
commit543cc6b75eac3dc8864c21ed65707e1affa2e78f (patch)
treed75e70c35ece8dc0c1444783fc026acf2121acf8
parent4a04dfc07c916cff565de54e527402a7c082b8ed (diff)
downloadopenttd-543cc6b75eac3dc8864c21ed65707e1affa2e78f.tar.xz
(svn r16345) -Codechange: replace the Sound(Entry) pool with a simple vector of SoundEntries.
-rw-r--r--src/newgrf_sound.cpp19
1 files changed, 7 insertions, 12 deletions
diff --git a/src/newgrf_sound.cpp b/src/newgrf_sound.cpp
index 249ea03ba..ffdddd5ca 100644
--- a/src/newgrf_sound.cpp
+++ b/src/newgrf_sound.cpp
@@ -8,26 +8,21 @@
#include "newgrf_sound.h"
#include "vehicle_base.h"
#include "sound_func.h"
+#include "core/smallvec_type.hpp"
-static uint _sound_count = 0;
-STATIC_OLD_POOL(SoundInternal, SoundEntry, 3, 1000, NULL, NULL)
+static SmallVector<SoundEntry, ORIGINAL_SAMPLE_COUNT> _sounds;
/* Allocate a new Sound */
SoundEntry *AllocateSound()
{
- if (_sound_count == GetSoundInternalPoolSize()) {
- if (!_SoundInternal_pool.AddBlockToPool()) return NULL;
- }
-
- return GetSoundInternal(_sound_count++);
+ return _sounds.Append();
}
void InitializeSoundPool()
{
- _SoundInternal_pool.CleanPool();
- _sound_count = 0;
+ _sounds.Clear();
/* Copy original sound data to the pool */
SndCopyToPool();
@@ -36,14 +31,14 @@ void InitializeSoundPool()
SoundEntry *GetSound(SoundID index)
{
- if (index >= GetNumSounds()) return NULL;
- return GetSoundInternal(index);
+ if (index >= _sounds.Length()) return NULL;
+ return &_sounds[index];
}
uint GetNumSounds()
{
- return _sound_count;
+ return _sounds.Length();
}