* Updated to ZDoom r3845:

- Precache sounds played by ASoundSequence actors. (This includes Heretic's ambient sounds.)
- Precache $ambient sounds.
- Store ambient sound names as FSoundID rather than as FString.
- Precache PickupSound, UpSound, and ReadySound.
- Precache player sounds at level load.

git-svn-id: http://mancubus.net/svn/hosted/gzdoom/trunk@1447 b0f79afe-0144-0410-b225-9a4edf0717df
This commit is contained in:
gez 2012-08-25 14:00:17 +00:00
parent e13d5ac2ca
commit d135217b18
11 changed files with 156 additions and 14 deletions

View file

@ -90,6 +90,7 @@ public:
virtual void AddInventory (AInventory *item);
virtual void RemoveInventory (AInventory *item);
virtual bool UseInventory (AInventory *item);
virtual void MarkPrecacheSounds () const;
virtual void PlayIdle ();
virtual void PlayRunning ();
@ -107,7 +108,7 @@ public:
void GiveDefaultInventory ();
void PlayAttacking ();
void PlayAttacking2 ();
const char *GetSoundClass ();
const char *GetSoundClass () const;
enum EInvulState
{

View file

@ -459,6 +459,18 @@ void AInventory::Serialize (FArchive &arc)
arc << Owner << Amount << MaxAmount << RespawnTics << ItemFlags << Icon << PickupSound << SpawnPointClass;
}
//===========================================================================
//
// AInventory :: MarkPrecacheSounds
//
//===========================================================================
void AInventory::MarkPrecacheSounds() const
{
Super::MarkPrecacheSounds();
PickupSound.MarkUsed();
}
//===========================================================================
//
// AInventory :: SpecialDropAction

View file

@ -143,6 +143,7 @@ public:
virtual void Touch (AActor *toucher);
virtual void Serialize (FArchive &arc);
virtual void MarkPrecacheSounds() const;
virtual void BeginPlay ();
virtual void Destroy ();
virtual void Tick ();
@ -276,6 +277,7 @@ public:
bool bAltFire; // Set when this weapon's alternate fire is used.
virtual void MarkPrecacheSounds() const;
virtual void Serialize (FArchive &arc);
virtual bool ShouldStay ();
virtual void AttachToOwner (AActor *other);

View file

@ -105,6 +105,7 @@ public:
void PostBeginPlay ();
void Activate (AActor *activator);
void Deactivate (AActor *activator);
void MarkPrecacheSounds () const;
};
IMPLEMENT_CLASS (ASoundSequence)
@ -154,6 +155,18 @@ void ASoundSequence::PostBeginPlay ()
}
}
//==========================================================================
//
// ASoundSequence :: MarkPrecacheSounds
//
//==========================================================================
void ASoundSequence::MarkPrecacheSounds() const
{
Super::MarkPrecacheSounds();
SN_MarkPrecacheSounds(args[0], SEQ_ENVIRONMENT);
}
//==========================================================================
//
// ASoundSequence :: Activate
@ -175,4 +188,3 @@ void ASoundSequence::Deactivate (AActor *activator)
{
SN_StopSequence (this);
}

View file

@ -67,6 +67,19 @@ void AWeapon::Serialize (FArchive &arc)
<< Crosshair;
}
//===========================================================================
//
// AWeapon :: MarkPrecacheSounds
//
//===========================================================================
void AWeapon::MarkPrecacheSounds() const
{
Super::MarkPrecacheSounds();
UpSound.MarkUsed();
ReadySound.MarkUsed();
}
//===========================================================================
//
// AWeapon :: TryPickup

View file

@ -475,6 +475,18 @@ void APlayerPawn::Serialize (FArchive &arc)
}
}
//===========================================================================
//
// APlayerPawn :: MarkPrecacheSounds
//
//===========================================================================
void APlayerPawn::MarkPrecacheSounds() const
{
Super::MarkPrecacheSounds();
S_MarkPlayerSounds(GetSoundClass());
}
//===========================================================================
//
// APlayerPawn :: BeginPlay
@ -968,7 +980,7 @@ void APlayerPawn::FilterCoopRespawnInventory (APlayerPawn *oldplayer)
//
//===========================================================================
const char *APlayerPawn::GetSoundClass ()
const char *APlayerPawn::GetSoundClass() const
{
if (player != NULL &&
(player->mo == NULL || !(player->mo->flags4 &MF4_NOSKIN)) &&

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
@ -122,7 +123,7 @@ struct FAmbientSound
int periodmax; // max # of tics for random ambients
float volume; // relative volume of sound
float attenuation;
FString sound; // Logical name of sound to play
FSoundID sound; // Sound to play
};
TMap<int, FAmbientSound> Ambients;
@ -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
@ -984,10 +1004,10 @@ static void S_AddSNDINFO (int lump)
ambient->periodmax = 0;
ambient->volume = 0;
ambient->attenuation = 0;
ambient->sound = "";
ambient->sound = 0;
sc.MustGetString ();
ambient->sound = sc.String;
ambient->sound = FSoundID(S_FindSoundTentative(sc.String));
ambient->attenuation = 0;
sc.MustGetString ();
@ -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
@ -2027,6 +2072,7 @@ class AAmbientSound : public AActor
public:
void Serialize (FArchive &arc);
void MarkPrecacheSounds () const;
void BeginPlay ();
void Tick ();
void Activate (AActor *activator);
@ -2053,6 +2099,22 @@ void AAmbientSound::Serialize (FArchive &arc)
arc << bActive << NextCheck;
}
//==========================================================================
//
// AmbientSound :: MarkPrecacheSounds
//
//==========================================================================
void AAmbientSound::MarkPrecacheSounds() const
{
Super::MarkPrecacheSounds();
FAmbientSound *ambient = Ambients.CheckKey(args[0]);
if (ambient != NULL)
{
ambient->sound.MarkUsed();
}
}
//==========================================================================
//
// AmbientSound :: Tick
@ -2080,7 +2142,7 @@ void AAmbientSound::Tick ()
loop = CHAN_LOOP;
}
if (ambient->sound.IsNotEmpty())
if (ambient->sound != 0)
{
// The second argument scales the ambient sound's volume.
// 0 and 100 are normal volume. The maximum volume level

View file

@ -760,7 +760,7 @@ static void AddSequence (int curseq, FName seqname, FName slot, int stopsound, c
Sequences[curseq] = (FSoundSequence *)M_Malloc (sizeof(FSoundSequence) + sizeof(DWORD)*ScriptTemp.Size());
Sequences[curseq]->SeqName = seqname;
Sequences[curseq]->Slot = slot;
Sequences[curseq]->StopSound = stopsound;
Sequences[curseq]->StopSound = FSoundID(stopsound);
memcpy (Sequences[curseq]->Script, &ScriptTemp[0], sizeof(DWORD)*ScriptTemp.Size());
Sequences[curseq]->Script[ScriptTemp.Size()] = MakeCommand(SS_CMD_END, 0);
}
@ -1311,6 +1311,32 @@ FName SN_GetSequenceSlot (int sequence, seqtype_t type)
return NAME_None;
}
//==========================================================================
//
// SN_MarkPrecacheSounds
//
// Marks all sounds played by this sequence for precaching.
//
//==========================================================================
void SN_MarkPrecacheSounds(int sequence, seqtype_t type)
{
if (TwiddleSeqNum(sequence, type))
{
FSoundSequence *seq = Sequences[sequence];
seq->StopSound.MarkUsed();
for (int i = 0; GetCommand(seq->Script[i]) != SS_CMD_END; ++i)
{
int cmd = GetCommand(seq->Script[i]);
if (cmd == SS_CMD_PLAY || cmd == SS_CMD_PLAYREPEAT || cmd == SS_CMD_PLAYLOOP)
{
FSoundID(GetData(seq->Script[i])).MarkUsed();
}
}
}
}
//==========================================================================
//
// SN_ChangeNodeData

View file

@ -71,10 +71,10 @@ void SN_StopAllSequences (void);
struct FSoundSequence
{
FName SeqName;
FName Slot;
int StopSound;
SDWORD Script[1]; // + more until end of sequence script
FName SeqName;
FName Slot;
FSoundID StopSound;
SDWORD Script[1]; // + more until end of sequence script
};
void S_ParseSndSeq (int levellump);
@ -98,6 +98,7 @@ void SN_DoStop (void *);
void SN_ChangeNodeData (int nodeNum, int seqOffset, int delayTics,
float volume, int currentSoundID);
FName SN_GetSequenceSlot (int sequence, seqtype_t type);
void SN_MarkPrecacheSounds (int sequence, seqtype_t type);
bool SN_IsMakingLoopingSound (sector_t *sector);
#endif //__S_SNDSEQ_H__

View file

@ -357,6 +357,7 @@ int S_AddSoundLump (const char *logicalname, int lump); // Add sound by lump ind
int S_AddPlayerSound (const char *playerclass, const int gender, int refid, const char *lumpname);
int S_AddPlayerSound (const char *playerclass, const int gender, int refid, int lumpnum, bool fromskin=false);
int S_AddPlayerSoundExisting (const char *playerclass, const int gender, int refid, int aliasto, bool fromskin=false);
void S_MarkPlayerSounds (const char *playerclass);
void S_ShrinkPlayerSoundLists ();
void S_UnloadSound (sfxinfo_t *sfx);
sfxinfo_t *S_LoadSound(sfxinfo_t *sfx);

View file

@ -3,5 +3,5 @@
// This file was automatically generated by the
// updaterevision tool. Do not edit by hand.
#define ZD_SVN_REVISION_STRING "3840"
#define ZD_SVN_REVISION_NUMBER 3840
#define ZD_SVN_REVISION_STRING "3845"
#define ZD_SVN_REVISION_NUMBER 3845