mirror of https://github.com/OpenTTD/OpenTTD
(svn r16345) -Codechange: replace the Sound(Entry) pool with a simple vector of SoundEntries.
parent
4a04dfc07c
commit
543cc6b75e
|
@ -8,26 +8,21 @@
|
||||||
#include "newgrf_sound.h"
|
#include "newgrf_sound.h"
|
||||||
#include "vehicle_base.h"
|
#include "vehicle_base.h"
|
||||||
#include "sound_func.h"
|
#include "sound_func.h"
|
||||||
|
#include "core/smallvec_type.hpp"
|
||||||
|
|
||||||
static uint _sound_count = 0;
|
static SmallVector<SoundEntry, ORIGINAL_SAMPLE_COUNT> _sounds;
|
||||||
STATIC_OLD_POOL(SoundInternal, SoundEntry, 3, 1000, NULL, NULL)
|
|
||||||
|
|
||||||
|
|
||||||
/* Allocate a new Sound */
|
/* Allocate a new Sound */
|
||||||
SoundEntry *AllocateSound()
|
SoundEntry *AllocateSound()
|
||||||
{
|
{
|
||||||
if (_sound_count == GetSoundInternalPoolSize()) {
|
return _sounds.Append();
|
||||||
if (!_SoundInternal_pool.AddBlockToPool()) return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return GetSoundInternal(_sound_count++);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void InitializeSoundPool()
|
void InitializeSoundPool()
|
||||||
{
|
{
|
||||||
_SoundInternal_pool.CleanPool();
|
_sounds.Clear();
|
||||||
_sound_count = 0;
|
|
||||||
|
|
||||||
/* Copy original sound data to the pool */
|
/* Copy original sound data to the pool */
|
||||||
SndCopyToPool();
|
SndCopyToPool();
|
||||||
|
@ -36,14 +31,14 @@ void InitializeSoundPool()
|
||||||
|
|
||||||
SoundEntry *GetSound(SoundID index)
|
SoundEntry *GetSound(SoundID index)
|
||||||
{
|
{
|
||||||
if (index >= GetNumSounds()) return NULL;
|
if (index >= _sounds.Length()) return NULL;
|
||||||
return GetSoundInternal(index);
|
return &_sounds[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
uint GetNumSounds()
|
uint GetNumSounds()
|
||||||
{
|
{
|
||||||
return _sound_count;
|
return _sounds.Length();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue