- Precache sounds played by ASoundSequence actors. (This includes Heretic's ambient sounds.)

SVN r3845 (trunk)
This commit is contained in:
Randy Heit 2012-08-23 00:15:41 +00:00
parent 04f09d9b57
commit 69fc0142eb
3 changed files with 45 additions and 6 deletions

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

@ -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__