- Precache player sounds at level load.

SVN r3841 (trunk)
This commit is contained in:
Randy Heit 2012-08-22 23:46:47 +00:00
commit 0ac94c5265
4 changed files with 61 additions and 2 deletions

View file

@ -100,6 +100,7 @@ public:
void AddSound (int player_sound_id, int sfx_id);
int LookupSound (int player_sound_id);
FPlayerSoundHashTable &operator= (const FPlayerSoundHashTable &other);
void MarkUsed();
protected:
struct Entry
@ -830,6 +831,25 @@ int FPlayerSoundHashTable::LookupSound (int player_sound_id)
return entry != NULL ? entry->SfxID : 0;
}
//==========================================================================
//
// FPlayerSoundHashTable :: Mark
//
// Marks all sounds defined for this class/gender as used.
//
//==========================================================================
void FPlayerSoundHashTable::MarkUsed()
{
for (size_t i = 0; i < NUM_BUCKETS; ++i)
{
for (Entry *probe = Buckets[i]; probe != NULL; probe = probe->Next)
{
S_sfx[probe->SfxID].bUsed = true;
}
}
}
//==========================================================================
//
// S_ClearSoundData
@ -1912,6 +1932,31 @@ void sfxinfo_t::MarkUsed()
bUsed = true;
}
//==========================================================================
//
// S_MarkPlayerSounds
//
// Marks all sounds from a particular player class for precaching.
//
//==========================================================================
void S_MarkPlayerSounds (const char *playerclass)
{
int classidx = S_FindPlayerClass(playerclass);
if (classidx < 0)
{
classidx = DefPlayerClass;
}
for (int g = 0; g < 3; ++g)
{
int listidx = PlayerClassLookups[classidx].ListIndex[0];
if (listidx != 0xffff)
{
PlayerSounds[listidx].MarkUsed();
}
}
}
//==========================================================================
//
// CCMD soundlist