mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-11 07:11:54 +00:00
- removed dependency on global time in sound sequence code.
This can better use a countdown timer that doesn't depend on external behavior.
This commit is contained in:
parent
ed3bb2fd09
commit
36f0ab2ea1
2 changed files with 11 additions and 12 deletions
|
@ -34,6 +34,7 @@
|
|||
#include "po_man.h"
|
||||
#include "gi.h"
|
||||
#include "c_dispatch.h"
|
||||
|
||||
#include "g_level.h"
|
||||
#include "serializer.h"
|
||||
#include "d_player.h"
|
||||
|
@ -51,8 +52,6 @@
|
|||
#define HexenEnvSeq(a) ((a) | 0x80)
|
||||
#define HexenLastSeq (0xff)
|
||||
|
||||
#define TIME_REFERENCE level.time
|
||||
|
||||
// TYPES -------------------------------------------------------------------
|
||||
|
||||
typedef enum
|
||||
|
@ -326,7 +325,7 @@ void DSeqNode::Serialize(FSerializer &arc)
|
|||
if (arc.isWriting())
|
||||
{
|
||||
seqOffset = (int)SN_GetSequenceOffset(m_Sequence, m_SequencePtr);
|
||||
delayTics = m_DelayUntilTic;
|
||||
delayTics = m_DelayTics;
|
||||
volume = m_Volume;
|
||||
atten = m_Atten;
|
||||
id = m_CurrentSoundID;
|
||||
|
@ -373,7 +372,7 @@ void DSeqNode::Serialize(FSerializer &arc)
|
|||
// Can I just Destroy() here instead of erroring out?
|
||||
}
|
||||
|
||||
ChangeData (seqOffset, delayTics - TIME_REFERENCE, volume, id);
|
||||
ChangeData (seqOffset, delayTics, volume, id);
|
||||
|
||||
m_SequenceChoices.Resize(numchoices);
|
||||
if (numchoices > 0 && arc.BeginArray("choices"))
|
||||
|
@ -828,7 +827,7 @@ void DSeqNode::ActivateSequence (int sequence)
|
|||
{
|
||||
m_SequencePtr = Sequences[sequence]->Script;
|
||||
m_Sequence = sequence;
|
||||
m_DelayUntilTic = 0;
|
||||
m_DelayTics = 0;
|
||||
m_StopSound = Sequences[sequence]->StopSound;
|
||||
m_CurrentSoundID = 0;
|
||||
m_Volume = 1; // Start at max volume...
|
||||
|
@ -1192,9 +1191,9 @@ DEFINE_ACTION_FUNCTION(_Sector, IsMakingLoopingSound)
|
|||
|
||||
void DSeqNode::Tick ()
|
||||
{
|
||||
if (TIME_REFERENCE < m_DelayUntilTic)
|
||||
if (m_DelayTics > 0)
|
||||
{
|
||||
return;
|
||||
if (--m_DelayTics > 0) return;
|
||||
}
|
||||
for (;;)
|
||||
{
|
||||
|
@ -1239,7 +1238,7 @@ void DSeqNode::Tick ()
|
|||
// command will repeat until the sequence is stopped.
|
||||
m_CurrentSoundID = FSoundID(GetData(m_SequencePtr[0]));
|
||||
MakeSound (0, m_CurrentSoundID);
|
||||
m_DelayUntilTic = TIME_REFERENCE + m_SequencePtr[1];
|
||||
m_DelayTics = m_SequencePtr[1];
|
||||
return;
|
||||
|
||||
case SS_CMD_RANDOMSEQUENCE:
|
||||
|
@ -1274,13 +1273,13 @@ void DSeqNode::Tick ()
|
|||
break;
|
||||
|
||||
case SS_CMD_DELAY:
|
||||
m_DelayUntilTic = TIME_REFERENCE + GetData(*m_SequencePtr);
|
||||
m_DelayTics = GetData(*m_SequencePtr);
|
||||
m_SequencePtr++;
|
||||
m_CurrentSoundID = 0;
|
||||
return;
|
||||
|
||||
case SS_CMD_DELAYRAND:
|
||||
m_DelayUntilTic = TIME_REFERENCE + GetData(m_SequencePtr[0]) + pr_sndseq(m_SequencePtr[1]);
|
||||
m_DelayTics = GetData(m_SequencePtr[0]) + pr_sndseq(m_SequencePtr[1]);
|
||||
m_SequencePtr += 2;
|
||||
m_CurrentSoundID = 0;
|
||||
return;
|
||||
|
@ -1493,7 +1492,7 @@ void SN_ChangeNodeData (int nodeNum, int seqOffset, int delayTics, float volume,
|
|||
|
||||
void DSeqNode::ChangeData (int seqOffset, int delayTics, float volume, FSoundID currentSoundID)
|
||||
{
|
||||
m_DelayUntilTic = TIME_REFERENCE + delayTics;
|
||||
m_DelayTics = delayTics;
|
||||
m_Volume = volume;
|
||||
m_SequencePtr += seqOffset;
|
||||
m_CurrentSoundID = currentSoundID;
|
||||
|
|
|
@ -49,7 +49,7 @@ protected:
|
|||
|
||||
FSoundID m_CurrentSoundID;
|
||||
int m_StopSound;
|
||||
int m_DelayUntilTic;
|
||||
int m_DelayTics;
|
||||
float m_Volume;
|
||||
float m_Atten;
|
||||
int m_ModeNum;
|
||||
|
|
Loading…
Reference in a new issue