mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-26 05:51:20 +00:00
- migrate a large part of the sound code to FSoundIDs.
This has always been a wild mixture of IDs and ints.
This commit is contained in:
parent
1a6da52961
commit
160633a4a2
35 changed files with 224 additions and 205 deletions
|
@ -119,11 +119,11 @@ void SoundEngine::Shutdown ()
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
void SoundEngine::MarkUsed(int id)
|
||||
void SoundEngine::MarkUsed(FSoundID sid)
|
||||
{
|
||||
if ((unsigned)id < S_sfx.Size())
|
||||
if (isValidSoundId(sid))
|
||||
{
|
||||
S_sfx[id].bUsed = true;
|
||||
S_sfx[sid.index()].bUsed = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -167,9 +167,9 @@ void SoundEngine::CacheSound (sfxinfo_t *sfx)
|
|||
{
|
||||
if (GSnd && !sfx->bTentative)
|
||||
{
|
||||
while (!sfx->bRandomHeader && sfx->link != sfxinfo_t::NO_LINK)
|
||||
while (!sfx->bRandomHeader && isValidSoundId(sfx->link))
|
||||
{
|
||||
sfx = &S_sfx[sfx->link];
|
||||
sfx = &S_sfx[sfx->link.index()];
|
||||
}
|
||||
if (sfx->bRandomHeader)
|
||||
{
|
||||
|
@ -315,7 +315,7 @@ FString SoundEngine::ListSoundChannels()
|
|||
|
||||
CalcPosVel(chan, &chanorigin, nullptr);
|
||||
|
||||
output.AppendFormat("%s at (%1.5f, %1.5f, %1.5f)\n", (const char*)S_sfx[chan->SoundID].name.GetChars(), chanorigin.X, chanorigin.Y, chanorigin.Z);
|
||||
output.AppendFormat("%s at (%1.5f, %1.5f, %1.5f)\n", (const char*)S_sfx[chan->SoundID.index()].name.GetChars(), chanorigin.X, chanorigin.Y, chanorigin.Z);
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
@ -354,7 +354,7 @@ bool SoundEngine::ValidatePosVel(const FSoundChan* const chan, const FVector3& p
|
|||
|
||||
FSoundID SoundEngine::ResolveSound(const void *, int, FSoundID soundid, float &attenuation)
|
||||
{
|
||||
const sfxinfo_t &sfx = S_sfx[soundid];
|
||||
const sfxinfo_t &sfx = S_sfx[soundid.index()];
|
||||
|
||||
if (sfx.bRandomHeader)
|
||||
{
|
||||
|
@ -391,13 +391,13 @@ FSoundChan *SoundEngine::StartSound(int type, const void *source,
|
|||
FVector3 pos, vel;
|
||||
FRolloffInfo *rolloff;
|
||||
|
||||
if (sound_id <= 0 || volume <= 0 || nosfx || !SoundEnabled() || blockNewSounds || (unsigned)sound_id >= S_sfx.Size())
|
||||
if (!isValidSoundId(sound_id) || volume <= 0 || nosfx || !SoundEnabled() || blockNewSounds)
|
||||
return NULL;
|
||||
|
||||
// prevent crashes.
|
||||
if (type == SOURCE_Unattached && pt == nullptr) type = SOURCE_None;
|
||||
|
||||
org_id = sound_id;
|
||||
org_id = sound_id.index();
|
||||
|
||||
CalcPosVel(type, source, &pt->X, channel, chanflags, sound_id, &pos, &vel, nullptr);
|
||||
|
||||
|
@ -406,7 +406,7 @@ FSoundChan *SoundEngine::StartSound(int type, const void *source,
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
sfx = &S_sfx[sound_id];
|
||||
sfx = &S_sfx[org_id];
|
||||
|
||||
// Scale volume according to SNDINFO data.
|
||||
volume = min(volume * sfx->Volume, 1.f);
|
||||
|
@ -426,8 +426,8 @@ FSoundChan *SoundEngine::StartSound(int type, const void *source,
|
|||
while (sfx->link != sfxinfo_t::NO_LINK)
|
||||
{
|
||||
sound_id = ResolveSound(source, type, sound_id, attenuation);
|
||||
if (sound_id < 0) return nullptr;
|
||||
auto newsfx = &S_sfx[sound_id];
|
||||
if (!isValidSoundId(sound_id)) return nullptr;
|
||||
auto newsfx = &S_sfx[sound_id.index()];
|
||||
if (newsfx != sfx)
|
||||
{
|
||||
if (near_limit < 0)
|
||||
|
@ -653,7 +653,7 @@ void SoundEngine::RestartChannel(FSoundChan *chan)
|
|||
assert(chan->ChanFlags & CHANF_EVICTED);
|
||||
|
||||
FSoundChan *ochan;
|
||||
sfxinfo_t *sfx = &S_sfx[chan->SoundID];
|
||||
sfxinfo_t *sfx = &S_sfx[chan->SoundID.index()];
|
||||
|
||||
// If this is a singular sound, don't play it if it's already playing.
|
||||
if (sfx->bSingular && CheckSingular(chan->SoundID))
|
||||
|
@ -688,7 +688,7 @@ void SoundEngine::RestartChannel(FSoundChan *chan)
|
|||
|
||||
// If this sound doesn't like playing near itself, don't play it if
|
||||
// that's what would happen.
|
||||
if (chan->NearLimit > 0 && CheckSoundLimit(&S_sfx[chan->SoundID], pos, chan->NearLimit, chan->LimitRange, 0, NULL, 0, chan->DistanceScale))
|
||||
if (chan->NearLimit > 0 && CheckSoundLimit(&S_sfx[chan->SoundID.index()], pos, chan->NearLimit, chan->LimitRange, 0, NULL, 0, chan->DistanceScale))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -799,7 +799,7 @@ sfxinfo_t *SoundEngine::LoadSound(sfxinfo_t *sfx)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
bool SoundEngine::CheckSingular(int sound_id)
|
||||
bool SoundEngine::CheckSingular(FSoundID sound_id)
|
||||
{
|
||||
for (FSoundChan *chan = Channels; chan != NULL; chan = chan->NextChan)
|
||||
{
|
||||
|
@ -837,7 +837,7 @@ bool SoundEngine::CheckSoundLimit(sfxinfo_t *sfx, const FVector3 &pos, int near_
|
|||
for (chan = Channels, count = 0; chan != NULL && count < near_limit; chan = chan->NextChan)
|
||||
{
|
||||
if (chan->ChanFlags & CHANF_FORGETTABLE) continue;
|
||||
if (!(chan->ChanFlags & CHANF_EVICTED) && &S_sfx[chan->SoundID] == sfx)
|
||||
if (!(chan->ChanFlags & CHANF_EVICTED) && &S_sfx[chan->SoundID.index()] == sfx)
|
||||
{
|
||||
FVector3 chanorigin;
|
||||
|
||||
|
@ -895,7 +895,7 @@ void SoundEngine::StopSound (int channel, FSoundID sound_id)
|
|||
while (chan != NULL)
|
||||
{
|
||||
FSoundChan *next = chan->NextChan;
|
||||
if ((chan->SourceType == SOURCE_None && (sound_id == -1 || sound_id == chan->OrgID)) && (channel == CHAN_AUTO || channel == chan->EntChannel))
|
||||
if ((chan->SourceType == SOURCE_None && (sound_id == INVALID_SOUND || sound_id == chan->OrgID)) && (channel == CHAN_AUTO || channel == chan->EntChannel))
|
||||
{
|
||||
StopChannel(chan);
|
||||
}
|
||||
|
@ -919,7 +919,7 @@ void SoundEngine::StopSound(int sourcetype, const void* actor, int channel, FSou
|
|||
FSoundChan* next = chan->NextChan;
|
||||
if (chan->SourceType == sourcetype &&
|
||||
chan->Source == actor &&
|
||||
(sound_id == -1? (chan->EntChannel == channel || channel < 0) : (chan->OrgID == sound_id)))
|
||||
(sound_id == INVALID_SOUND? (chan->EntChannel == channel || channel < 0) : (chan->OrgID == sound_id)))
|
||||
{
|
||||
StopChannel(chan);
|
||||
}
|
||||
|
@ -1065,7 +1065,7 @@ void SoundEngine::ChangeSoundPitch(int sourcetype, const void *source, int chann
|
|||
{
|
||||
if (chan->SourceType == sourcetype &&
|
||||
chan->Source == source &&
|
||||
(sound_id == -1? (chan->EntChannel == channel) : (chan->OrgID == sound_id)))
|
||||
(sound_id == INVALID_SOUND? (chan->EntChannel == channel) : (chan->OrgID == sound_id)))
|
||||
{
|
||||
SetPitch(chan, (float)pitch);
|
||||
}
|
||||
|
@ -1090,7 +1090,7 @@ void SoundEngine::SetPitch(FSoundChan *chan, float pitch)
|
|||
int SoundEngine::GetSoundPlayingInfo (int sourcetype, const void *source, FSoundID sound_id, int chann)
|
||||
{
|
||||
int count = 0;
|
||||
if (sound_id > 0)
|
||||
if (sound_id.isvalid())
|
||||
{
|
||||
for (FSoundChan *chan = Channels; chan != NULL; chan = chan->NextChan)
|
||||
{
|
||||
|
@ -1159,7 +1159,7 @@ bool SoundEngine::IsSourcePlayingSomething (int sourcetype, const void *actor, i
|
|||
{
|
||||
if (chan->SourceType == sourcetype && (sourcetype == SOURCE_None || sourcetype == SOURCE_Unattached || chan->Source == actor))
|
||||
{
|
||||
if ((channel == 0 || chan->EntChannel == channel) && (sound_id <= 0 || chan->OrgID == sound_id))
|
||||
if ((channel == 0 || chan->EntChannel == channel) && (sound_id == INVALID_SOUND || chan->OrgID == sound_id))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@ -1355,7 +1355,7 @@ void SoundEngine::ChannelEnded(FISoundChannel *ichan)
|
|||
else
|
||||
{
|
||||
unsigned int pos = GSnd->GetPosition(schan);
|
||||
unsigned int len = GSnd->GetSampleLength(S_sfx[schan->SoundID].data);
|
||||
unsigned int len = GSnd->GetSampleLength(S_sfx[schan->SoundID.index()].data);
|
||||
if (pos == 0)
|
||||
{
|
||||
evicted = !!(schan->ChanFlags & CHANF_JUSTSTARTED);
|
||||
|
@ -1463,7 +1463,7 @@ void SoundEngine::Reset()
|
|||
// Given a logical name, find the sound's index in S_sfx.
|
||||
//==========================================================================
|
||||
|
||||
FSoundID SoundEngine::FindSound(const char* logicalname)
|
||||
int SoundEngine::GetSoundIndex(const char* logicalname)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
@ -1564,13 +1564,13 @@ FSoundID SoundEngine::AddSoundLump(const char* logicalname, int lump, int Curren
|
|||
// an associated lump is created.
|
||||
//==========================================================================
|
||||
|
||||
int SoundEngine::FindSoundTentative(const char* name)
|
||||
FSoundID SoundEngine::FindSoundTentative(const char* name)
|
||||
{
|
||||
auto id = FindSoundNoHash(name);
|
||||
if (id == 0)
|
||||
if (id == NO_SOUND)
|
||||
{
|
||||
id = AddSoundLump(name, -1, 0);
|
||||
S_sfx[id].bTentative = true;
|
||||
S_sfx[id.index()].bTentative = true;
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
@ -1588,12 +1588,12 @@ void SoundEngine::CacheRandomSound(sfxinfo_t* sfx)
|
|||
{
|
||||
if (sfx->bRandomHeader)
|
||||
{
|
||||
const FRandomSoundList* list = &S_rnd[sfx->link];
|
||||
const FRandomSoundList* list = &S_rnd[sfx->link.index()];
|
||||
for (unsigned i = 0; i < list->Choices.Size(); ++i)
|
||||
{
|
||||
sfx = &S_sfx[list->Choices[i]];
|
||||
sfx = &S_sfx[list->Choices[i].index()];
|
||||
sfx->bUsed = true;
|
||||
CacheSound(&S_sfx[list->Choices[i]]);
|
||||
CacheSound(&S_sfx[list->Choices[i].index()]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1609,12 +1609,12 @@ void SoundEngine::CacheRandomSound(sfxinfo_t* sfx)
|
|||
|
||||
unsigned int SoundEngine::GetMSLength(FSoundID sound)
|
||||
{
|
||||
if ((unsigned int)sound >= S_sfx.Size())
|
||||
if (!isValidSoundId(sound))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
sfxinfo_t* sfx = &S_sfx[sound];
|
||||
sfxinfo_t* sfx = &S_sfx[sound.index()];
|
||||
|
||||
// Resolve player sounds, random sounds, and aliases
|
||||
if (sfx->link != sfxinfo_t::NO_LINK)
|
||||
|
@ -1626,7 +1626,7 @@ unsigned int SoundEngine::GetMSLength(FSoundID sound)
|
|||
// I think the longest one makes more sense.
|
||||
|
||||
int length = 0;
|
||||
const FRandomSoundList* list = &S_rnd[sfx->link];
|
||||
const FRandomSoundList* list = &S_rnd[sfx->link.index()];
|
||||
|
||||
for (auto& me : list->Choices)
|
||||
{
|
||||
|
@ -1638,7 +1638,7 @@ unsigned int SoundEngine::GetMSLength(FSoundID sound)
|
|||
}
|
||||
else
|
||||
{
|
||||
sfx = &S_sfx[sfx->link];
|
||||
sfx = &S_sfx[sfx->link.index()];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1655,11 +1655,11 @@ unsigned int SoundEngine::GetMSLength(FSoundID sound)
|
|||
// is not the head of a random list, then the sound passed is returned.
|
||||
//==========================================================================
|
||||
|
||||
int SoundEngine::PickReplacement(int refid)
|
||||
FSoundID SoundEngine::PickReplacement(FSoundID refid)
|
||||
{
|
||||
while (S_sfx[refid].bRandomHeader)
|
||||
while (S_sfx[refid.index()].bRandomHeader)
|
||||
{
|
||||
const FRandomSoundList* list = &S_rnd[S_sfx[refid].link];
|
||||
const FRandomSoundList* list = &S_rnd[S_sfx[refid.index()].link.index()];
|
||||
refid = list->Choices[rand() % int(list->Choices.Size())];
|
||||
}
|
||||
return refid;
|
||||
|
@ -1701,9 +1701,9 @@ void SoundEngine::AddRandomSound(FSoundID Owner, TArray<FSoundID> list)
|
|||
auto& random = S_rnd.Last();
|
||||
random.Choices = std::move(list);
|
||||
random.Owner = Owner;
|
||||
S_sfx[Owner].link = FSoundID::fromInt(index);
|
||||
S_sfx[Owner].bRandomHeader = true;
|
||||
S_sfx[Owner].NearLimit = -1;
|
||||
S_sfx[Owner.index()].link = FSoundID::fromInt(index);
|
||||
S_sfx[Owner.index()].bRandomHeader = true;
|
||||
S_sfx[Owner.index()].NearLimit = -1;
|
||||
}
|
||||
|
||||
void S_SoundReset()
|
||||
|
|
|
@ -18,8 +18,6 @@ enum
|
|||
ROLLOFF_Custom // Lookup volume from SNDCURVE
|
||||
};
|
||||
|
||||
inline int S_FindSoundByResID(int ndx);
|
||||
inline int S_FindSound(const char* name);
|
||||
|
||||
// An index into the S_sfx[] array.
|
||||
class FSoundID
|
||||
|
@ -36,36 +34,40 @@ public:
|
|||
}
|
||||
FSoundID(const char *name)
|
||||
{
|
||||
ID = S_FindSound(name);
|
||||
ID = GetSoundIndex(name);
|
||||
}
|
||||
FSoundID(const FString &name)
|
||||
{
|
||||
ID = S_FindSound(name.GetChars());
|
||||
ID = GetSoundIndex(name.GetChars());
|
||||
}
|
||||
FSoundID(const FSoundID &other) = default;
|
||||
FSoundID &operator=(const FSoundID &other) = default;
|
||||
FSoundID &operator=(const char *name)
|
||||
{
|
||||
ID = S_FindSound(name);
|
||||
ID = GetSoundIndex(name);
|
||||
return *this;
|
||||
}
|
||||
FSoundID &operator=(const FString &name)
|
||||
{
|
||||
ID = S_FindSound(name.GetChars());
|
||||
ID = GetSoundIndex(name.GetChars());
|
||||
return *this;
|
||||
}
|
||||
bool operator !=(FSoundID other) const
|
||||
{
|
||||
return ID != other.ID;
|
||||
}
|
||||
bool operator !=(int other) const
|
||||
bool operator ==(FSoundID other) const
|
||||
{
|
||||
return ID != other;
|
||||
return ID == other.ID;
|
||||
}
|
||||
bool operator ==(int other) const = delete;
|
||||
bool operator !=(int other) const = delete;
|
||||
/*
|
||||
operator int() const
|
||||
{
|
||||
return ID;
|
||||
}
|
||||
*/
|
||||
constexpr int index() const
|
||||
{
|
||||
return ID;
|
||||
|
@ -75,6 +77,8 @@ public:
|
|||
return ID > 0;
|
||||
}
|
||||
private:
|
||||
static inline int GetSoundIndex(const char* name);
|
||||
|
||||
int ID;
|
||||
};
|
||||
|
||||
|
@ -231,8 +235,11 @@ private:
|
|||
bool ValidatePosVel(const FSoundChan* const chan, const FVector3& pos, const FVector3& vel);
|
||||
|
||||
// Checks if a copy of this sound is already playing.
|
||||
bool CheckSingular(int sound_id);
|
||||
bool CheckSingular(FSoundID sound_id);
|
||||
virtual TArray<uint8_t> ReadSound(int lumpnum) = 0;
|
||||
int GetSoundIndex(const char* logicalname); // this is only for setting up FSoundID
|
||||
friend class FSoundID;
|
||||
|
||||
protected:
|
||||
virtual bool CheckSoundLimit(sfxinfo_t* sfx, const FVector3& pos, int near_limit, float limit_range, int sourcetype, const void* actor, int channel, float attenuation);
|
||||
virtual FSoundID ResolveSound(const void *ent, int srctype, FSoundID soundid, float &attenuation);
|
||||
|
@ -291,7 +298,7 @@ public:
|
|||
|
||||
// Loads a sound, including any random sounds it might reference.
|
||||
virtual void CacheSound(sfxinfo_t* sfx);
|
||||
void CacheSound(int sfx) { CacheSound(&S_sfx[sfx]); }
|
||||
void CacheSound(FSoundID sfx) { CacheSound(&S_sfx[sfx.index()]); }
|
||||
void UnloadSound(sfxinfo_t* sfx);
|
||||
void UnloadSound(int sfx)
|
||||
{
|
||||
|
@ -318,7 +325,7 @@ public:
|
|||
int GetSoundPlayingInfo(int sourcetype, const void* source, FSoundID sound_id, int chan = -1);
|
||||
void UnloadAllSounds();
|
||||
void Reset();
|
||||
void MarkUsed(int num);
|
||||
void MarkUsed(FSoundID num);
|
||||
void CacheMarkedSounds();
|
||||
TArray<FSoundChan*> AllActiveChannels();
|
||||
virtual void SetSoundPaused(int state) {}
|
||||
|
@ -354,7 +361,7 @@ public:
|
|||
}
|
||||
const char *GetSoundName(FSoundID id)
|
||||
{
|
||||
return id == 0 ? "" : S_sfx[id].name.GetChars();
|
||||
return !id.isvalid() ? "" : S_sfx[id.index()].name.GetChars();
|
||||
}
|
||||
FRolloffInfo& GlobalRolloff() // this is meant for sound list generators, not for gaining cheap access to the sound engine's innards.
|
||||
{
|
||||
|
@ -362,15 +369,15 @@ public:
|
|||
}
|
||||
FRandomSoundList *ResolveRandomSound(sfxinfo_t* sfx)
|
||||
{
|
||||
return &S_rnd[sfx->link];
|
||||
return &S_rnd[sfx->link.index()];
|
||||
}
|
||||
void ClearRandoms()
|
||||
{
|
||||
S_rnd.Clear();
|
||||
}
|
||||
int *GetUserData(int snd)
|
||||
int *GetUserData(FSoundID snd)
|
||||
{
|
||||
return S_sfx[snd].UserData.Data();
|
||||
return S_sfx[snd.index()].UserData.Data();
|
||||
}
|
||||
bool isValidSoundId(FSoundID sid)
|
||||
{
|
||||
|
@ -405,15 +412,18 @@ public:
|
|||
virtual void SoundDone(FISoundChannel* ichan); // gets called when the sound has been completely taken down.
|
||||
|
||||
// Lookup utilities.
|
||||
FSoundID FindSound(const char* logicalname);
|
||||
inline FSoundID FindSound(const char* logicalname)
|
||||
{
|
||||
return FSoundID::fromInt(GetSoundIndex(logicalname));
|
||||
}
|
||||
FSoundID FindSoundByResID(int rid);
|
||||
FSoundID FindSoundNoHash(const char* logicalname);
|
||||
FSoundID FindSoundByLump(int lump);
|
||||
virtual FSoundID AddSoundLump(const char* logicalname, int lump, int CurrentPitchMask, int resid = -1, int nearlimit = 2);
|
||||
int FindSoundTentative(const char* name);
|
||||
FSoundID FindSoundTentative(const char* name);
|
||||
void CacheRandomSound(sfxinfo_t* sfx);
|
||||
unsigned int GetMSLength(FSoundID sound);
|
||||
int PickReplacement(int refid);
|
||||
FSoundID PickReplacement(FSoundID refid);
|
||||
void HashSounds();
|
||||
void AddRandomSound(FSoundID Owner, TArray<FSoundID> list);
|
||||
};
|
||||
|
@ -430,14 +440,19 @@ struct FReverbField
|
|||
};
|
||||
|
||||
|
||||
inline int S_FindSoundByResID(int ndx)
|
||||
inline FSoundID S_FindSoundByResID(int ndx)
|
||||
{
|
||||
return soundEngine->FindSoundByResID(ndx);
|
||||
}
|
||||
|
||||
inline int S_FindSound(const char* name)
|
||||
inline FSoundID S_FindSound(const char* name)
|
||||
{
|
||||
return soundEngine->FindSound(name);
|
||||
}
|
||||
|
||||
inline int FSoundID::GetSoundIndex(const char* name)
|
||||
{
|
||||
return soundEngine->GetSoundIndex(name);
|
||||
}
|
||||
|
||||
int SoundEnabled();
|
||||
|
|
|
@ -153,10 +153,10 @@ void AddGenericVideo(DObject* runner, const FString& fn, int soundid, int fps)
|
|||
|
||||
int CutsceneDef::GetSound()
|
||||
{
|
||||
int id = -1;
|
||||
FSoundID id = INVALID_SOUND;
|
||||
if (soundName.IsNotEmpty()) id = soundEngine->FindSound(soundName);
|
||||
if (id <= 0) id = soundEngine->FindSoundByResID(soundID);
|
||||
return id;
|
||||
if (id == INVALID_SOUND) id = soundEngine->FindSoundByResID(soundID);
|
||||
return id.index();
|
||||
}
|
||||
|
||||
void CutsceneDef::Create(DObject* runner)
|
||||
|
|
|
@ -1332,7 +1332,7 @@ FSerializer &Serialize(FSerializer &arc, const char *key, FSoundID &sid, FSoundI
|
|||
if (!arc.soundNamesAreUnique)
|
||||
{
|
||||
//If sound name here is not reliable, we need to save by index instead.
|
||||
int id = sid;
|
||||
int id = sid.index();
|
||||
Serialize(arc, key, id, nullptr);
|
||||
if (arc.isReading()) sid = FSoundID(id);
|
||||
}
|
||||
|
|
|
@ -450,7 +450,7 @@ public:
|
|||
FxConstant(FSoundID val, const FScriptPosition &pos) : FxExpression(EFX_Constant, pos)
|
||||
{
|
||||
ValueType = value.Type = TypeSound;
|
||||
value.Int = val;
|
||||
value.Int = val.index();
|
||||
isresolved = true;
|
||||
}
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ static int CastS2N(FString *b) { return b->Len() == 0 ? NAME_None : FName(*b).Ge
|
|||
static void CastN2S(FString *a, int b) { FName name = FName(ENamedName(b)); *a = name.IsValidName() ? name.GetChars() : ""; }
|
||||
static int CastS2Co(FString *b) { return V_GetColor(*b); }
|
||||
static void CastCo2S(FString *a, int b) { PalEntry c(b); a->Format("%02x %02x %02x", c.r, c.g, c.b); }
|
||||
static int CastS2So(FString *b) { return FSoundID(*b); }
|
||||
static int CastS2So(FString *b) { return S_FindSound(*b).index(); }
|
||||
static void CastSo2S(FString* a, int b) { *a = soundEngine->GetSoundName(b); }
|
||||
static void CastSID2S(FString* a, unsigned int b) { VM_CastSpriteIDToString(a, b); }
|
||||
static void CastTID2S(FString *a, int b) { auto tex = TexMan.GetGameTexture(*(FTextureID*)&b); *a = (tex == nullptr) ? "(null)" : tex->GetName().GetChars(); }
|
||||
|
|
|
@ -2122,7 +2122,7 @@ static void DoCast(const VMRegisters ®, const VMFrame *f, int a, int b, int c
|
|||
|
||||
case CAST_S2So:
|
||||
ASSERTD(a); ASSERTS(b);
|
||||
reg.d[a] = FSoundID(reg.s[b]);
|
||||
reg.d[a] = S_FindSound(reg.s[b]).index();
|
||||
break;
|
||||
|
||||
case CAST_So2S:
|
||||
|
|
|
@ -501,10 +501,10 @@ int P_CheckKeys (AActor *owner, int keynum, bool remote, bool quiet)
|
|||
// Play the first defined key sound.
|
||||
for (int i = 0; i < numfailsounds; ++i)
|
||||
{
|
||||
if (failsound[i] != 0)
|
||||
if (failsound[i] != NO_SOUND)
|
||||
{
|
||||
int snd = S_FindSkinnedSound(owner, failsound[i]);
|
||||
if (snd != 0)
|
||||
auto snd = S_FindSkinnedSound(owner, failsound[i]);
|
||||
if (snd != NO_SOUND)
|
||||
{
|
||||
S_Sound (owner, CHAN_VOICE, 0, snd, 1, ATTN_NORM);
|
||||
break;
|
||||
|
|
|
@ -184,7 +184,7 @@ struct MBFParamState
|
|||
int GetSoundArg(int i, int def = 0)
|
||||
{
|
||||
int num = argsused & (1 << i) ? (int)args[i] : def;
|
||||
if (num > 0 && num <= int(SoundMap.Size())) return SoundMap[num-1];
|
||||
if (num > 0 && num <= int(SoundMap.Size())) return SoundMap[num-1].index();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -724,7 +724,7 @@ static void CreateFaceFunc(FunctionCallEmitter &emitters, int value1, int value2
|
|||
static void CreateScratchFunc(FunctionCallEmitter &emitters, int value1, int value2, MBFParamState* state)
|
||||
{ // A_CustomMeleeAttack
|
||||
emitters.AddParameterIntConst(value1); // damage
|
||||
emitters.AddParameterIntConst(value2 ? (int)SoundMap[value2 - 1] : 0); // hit sound
|
||||
emitters.AddParameterIntConst(value2 ? (int)SoundMap[value2 - 1].index() : 0); // hit sound
|
||||
emitters.AddParameterIntConst(0); // miss sound
|
||||
emitters.AddParameterIntConst(NAME_None); // damage type
|
||||
emitters.AddParameterIntConst(true); // bleed
|
||||
|
@ -733,7 +733,7 @@ static void CreateScratchFunc(FunctionCallEmitter &emitters, int value1, int val
|
|||
// misc1 = sound, misc2 = attenuation none (true) or normal (false)
|
||||
static void CreatePlaySoundFunc(FunctionCallEmitter &emitters, int value1, int value2, MBFParamState* state)
|
||||
{ // A_PlaySound
|
||||
emitters.AddParameterIntConst(value1 ? (int)SoundMap[value1 - 1] : 0); // soundid
|
||||
emitters.AddParameterIntConst(value1 ? (int)SoundMap[value1 - 1].index() : 0); // soundid
|
||||
emitters.AddParameterIntConst(CHAN_BODY); // channel
|
||||
emitters.AddParameterFloatConst(1); // volume
|
||||
emitters.AddParameterIntConst(false); // looping
|
||||
|
@ -2207,7 +2207,7 @@ static int PatchWeapon (int weapNum)
|
|||
FState* state = FindState(67); // S_SAW
|
||||
if (readyState == state)
|
||||
{
|
||||
info->IntVar(NAME_ReadySound) = S_FindSound("weapons/sawidle");
|
||||
info->IntVar(NAME_ReadySound) = S_FindSound("weapons/sawidle").index();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -1243,7 +1243,7 @@ DEFINE_MAP_OPTION(PrecacheSounds, true)
|
|||
{
|
||||
parse.sc.MustGetString();
|
||||
FSoundID snd = parse.sc.String;
|
||||
if (snd == 0)
|
||||
if (snd == NO_SOUND)
|
||||
{
|
||||
parse.sc.ScriptMessage("Unknown sound \"%s\"", parse.sc.String);
|
||||
}
|
||||
|
|
|
@ -389,7 +389,7 @@ struct level_info_t
|
|||
|
||||
TArray<FSpecialAction> specialactions;
|
||||
|
||||
TArray<int> PrecacheSounds;
|
||||
TArray<FSoundID> PrecacheSounds;
|
||||
TArray<FString> PrecacheTextures;
|
||||
TArray<FName> PrecacheClasses;
|
||||
|
||||
|
|
|
@ -156,7 +156,7 @@ const char* GameInfoBorders[] =
|
|||
{ \
|
||||
sc.ScriptError("Value for '%s' can not be longer than %d characters.", #key, length); \
|
||||
} \
|
||||
gameinfo.key[gameinfo.key.Reserve(1)] = FSoundID(sc.String); \
|
||||
gameinfo.key[gameinfo.key.Reserve(1)] = S_FindSound(sc.String); \
|
||||
} \
|
||||
while (sc.CheckToken(',')); \
|
||||
}
|
||||
|
|
|
@ -131,7 +131,7 @@ struct gameinfo_t
|
|||
|
||||
TArray<FName> PrecachedClasses;
|
||||
TArray<FString> PrecachedTextures;
|
||||
TArray<int> PrecachedSounds;
|
||||
TArray<FSoundID> PrecachedSounds;
|
||||
TArray<FString> EventHandlers;
|
||||
|
||||
FString titleMusic;
|
||||
|
|
|
@ -237,7 +237,7 @@ FSwitchDef *FTextureAnimator::ParseSwitchDef (FScanner &sc, bool ignoreBad)
|
|||
{
|
||||
if (sc.Compare ("sound"))
|
||||
{
|
||||
if (sound != 0)
|
||||
if (sound != NO_SOUND)
|
||||
{
|
||||
sc.ScriptError ("Switch state already has a sound");
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include "name.h"
|
||||
#include "textureid.h"
|
||||
#include "tarray.h"
|
||||
#include "s_soundinternal.h"
|
||||
|
||||
struct FAnimDef
|
||||
{
|
||||
|
@ -39,7 +40,7 @@ struct FSwitchDef
|
|||
FSwitchDef* PairDef; // switch def to use to return to PreTexture
|
||||
uint16_t NumFrames; // # of animation frames
|
||||
bool QuestPanel; // Special texture for Strife mission
|
||||
int Sound; // sound to play at start of animation. Changed to int to avoiud having to include s_sound here.
|
||||
FSoundID Sound; // sound to play at start of animation. Changed to int to avoiud having to include s_sound here.
|
||||
struct frame // Array of times followed by array of textures
|
||||
{ // actual length of each array is <NumFrames>
|
||||
uint16_t TimeMin;
|
||||
|
|
|
@ -524,7 +524,7 @@ void DIntermissionScreenCast::Init(FIntermissionAction *desc, bool first)
|
|||
castframes = 0;
|
||||
castonmelee = 0;
|
||||
castattacking = false;
|
||||
if (mDefaults->SeeSound)
|
||||
if (mDefaults->SeeSound.isvalid())
|
||||
{
|
||||
S_Sound (CHAN_VOICE, CHANF_UI, mDefaults->SeeSound, 1, ATTN_NONE);
|
||||
}
|
||||
|
@ -551,10 +551,10 @@ int DIntermissionScreenCast::Responder (FInputEvent *ev)
|
|||
|
||||
if (mClass->IsDescendantOf(NAME_PlayerPawn))
|
||||
{
|
||||
int snd = S_FindSkinnedSound(players[consoleplayer].mo, "*death");
|
||||
if (snd != 0) S_Sound (CHAN_VOICE, CHANF_UI, snd, 1, ATTN_NONE);
|
||||
auto snd = S_FindSkinnedSound(players[consoleplayer].mo, "*death");
|
||||
if (snd != NO_SOUND) S_Sound (CHAN_VOICE, CHANF_UI, snd, 1, ATTN_NONE);
|
||||
}
|
||||
else if (mDefaults->DeathSound)
|
||||
else if (mDefaults->DeathSound.isvalid())
|
||||
{
|
||||
S_Sound (CHAN_VOICE, CHANF_UI, mDefaults->DeathSound, 1, ATTN_NONE);
|
||||
}
|
||||
|
|
|
@ -359,10 +359,10 @@ class USDFParser : public UDMFParserBase
|
|||
{
|
||||
FString soundname = "svox/";
|
||||
soundname += name;
|
||||
node->SpeakerVoice = FSoundID(S_FindSound(soundname));
|
||||
if (node->SpeakerVoice == 0 && (namespace_bits & ( Zd | Gz )))
|
||||
node->SpeakerVoice = S_FindSound(soundname);
|
||||
if (node->SpeakerVoice == NO_SOUND && (namespace_bits & ( Zd | Gz )))
|
||||
{
|
||||
node->SpeakerVoice = FSoundID(S_FindSound(name));
|
||||
node->SpeakerVoice = S_FindSound(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -395,12 +395,12 @@ void P_StartConversation (AActor *npc, AActor *pc, bool facetalker, bool saveang
|
|||
}
|
||||
|
||||
// [Nash] Play voice clip from the actor so that positional audio can be heard by all players
|
||||
if (CurNode->SpeakerVoice != 0) S_Sound(npc, CHAN_VOICE, CHANF_NOPAUSE, CurNode->SpeakerVoice, 1, ATTN_NORM);
|
||||
if (CurNode->SpeakerVoice != NO_SOUND) S_Sound(npc, CHAN_VOICE, CHANF_NOPAUSE, CurNode->SpeakerVoice, 1, ATTN_NORM);
|
||||
|
||||
// The rest is only done when the conversation is actually displayed.
|
||||
if (pc->player == Level->GetConsolePlayer())
|
||||
{
|
||||
if (CurNode->SpeakerVoice != 0)
|
||||
if (CurNode->SpeakerVoice != NO_SOUND)
|
||||
{
|
||||
I_SetMusicVolume (dlg_musicvolume);
|
||||
}
|
||||
|
|
|
@ -349,7 +349,7 @@ static FSoundID T_FindSound(const char * name)
|
|||
char buffer[40];
|
||||
FSoundID so=S_FindSound(name);
|
||||
|
||||
if (so>0) return so;
|
||||
if (so.isvalid()) return so;
|
||||
|
||||
// Now it gets dirty!
|
||||
|
||||
|
@ -364,9 +364,9 @@ static FSoundID T_FindSound(const char * name)
|
|||
if (fileSystem.CheckNumForName(buffer, ns_sounds)<0) mysnprintf(buffer, countof(buffer), "DS%.35s", name);
|
||||
}
|
||||
|
||||
int id = S_AddSound(name, buffer);
|
||||
FSoundID id = S_AddSound(name, buffer);
|
||||
soundEngine->HashSounds();
|
||||
return FSoundID(id);
|
||||
return id;
|
||||
}
|
||||
|
||||
|
||||
|
@ -2912,7 +2912,7 @@ void FParser::SF_SpawnExplosion()
|
|||
{
|
||||
spawn->ClearCounters();
|
||||
t_return.value.i = spawn->SetState(spawn->FindState(NAME_Death));
|
||||
if(spawn->DeathSound) S_Sound (spawn, CHAN_BODY, 0, spawn->DeathSound, 1, ATTN_NORM);
|
||||
if(spawn->DeathSound.isvalid()) S_Sound (spawn, CHAN_BODY, 0, spawn->DeathSound, 1, ATTN_NORM);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5259,7 +5259,7 @@ int DLevelScript::SwapActorTeleFog(AActor *activator, int tid)
|
|||
}
|
||||
else if (argtype == TypeSound)
|
||||
{
|
||||
params.Push(int(FSoundID(Level->Behaviors.LookupString(args[i]))));
|
||||
params.Push(S_FindSound(Level->Behaviors.LookupString(args[i])).index());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -5913,7 +5913,7 @@ int DLevelScript::CallFunction(int argCount, int funcIndex, int32_t *args)
|
|||
sid = lookup;
|
||||
}
|
||||
}
|
||||
if (sid != 0 || funcIndex == ACSF_PlayActorSound)
|
||||
if (sid != NO_SOUND || funcIndex == ACSF_PlayActorSound)
|
||||
{
|
||||
auto it = Level->GetActorIterator(args[0]);
|
||||
AActor *spot;
|
||||
|
@ -5935,7 +5935,7 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound)
|
|||
{
|
||||
sid = GetActorSound(spot, args[1]);
|
||||
}
|
||||
if (sid != 0)
|
||||
if (sid != NO_SOUND)
|
||||
{
|
||||
// What a mess. I think it's a given that this was used with sound flags so it will forever be restricted to the original 8 channels.
|
||||
if (local) chan |= CHANF_LOCAL;
|
||||
|
|
|
@ -1076,7 +1076,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_CustomMeleeAttack)
|
|||
A_FaceTarget (self);
|
||||
if (P_CheckMeleeRange(self))
|
||||
{
|
||||
if (meleesound)
|
||||
if (meleesound.isvalid())
|
||||
S_Sound (self, CHAN_WEAPON, 0, meleesound, 1, ATTN_NORM);
|
||||
int newdam = P_DamageMobj (self->target, self, self, damage, damagetype);
|
||||
if (bleed)
|
||||
|
@ -1084,7 +1084,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_CustomMeleeAttack)
|
|||
}
|
||||
else
|
||||
{
|
||||
if (misssound)
|
||||
if (misssound.isvalid())
|
||||
S_Sound (self, CHAN_WEAPON, 0, misssound, 1, ATTN_NORM);
|
||||
}
|
||||
return 0;
|
||||
|
@ -1113,7 +1113,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_CustomComboAttack)
|
|||
{
|
||||
if (damagetype == NAME_None)
|
||||
damagetype = NAME_Melee; // Melee is the default type
|
||||
if (meleesound)
|
||||
if (meleesound.isvalid())
|
||||
S_Sound (self, CHAN_WEAPON, 0, meleesound, 1, ATTN_NORM);
|
||||
int newdam = P_DamageMobj (self->target, self, self, damage, damagetype);
|
||||
if (bleed)
|
||||
|
|
|
@ -719,8 +719,8 @@ void P_DrawRailTrail(AActor *source, TArray<SPortalHit> &portalhits, int color1,
|
|||
// Allow other sounds than 'weapons/railgf'!
|
||||
if (!source->player) sound = source->AttackSound;
|
||||
else if (source->player->ReadyWeapon) sound = source->player->ReadyWeapon->AttackSound;
|
||||
else sound = 0;
|
||||
if (!sound) sound = "weapons/railgf";
|
||||
else sound = NO_SOUND;
|
||||
if (!sound.isvalid()) sound = "weapons/railgf";
|
||||
|
||||
// The railgun's sound is special. It gets played from the
|
||||
// point on the slug's trail that is closest to the hearing player.
|
||||
|
|
|
@ -1963,7 +1963,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_Look)
|
|||
if (self->reactiontime > self->Level->maptime)
|
||||
self->target = nullptr;
|
||||
}
|
||||
else if (self->SeeSound)
|
||||
else if (self->SeeSound.isvalid())
|
||||
{
|
||||
if ((self->flags2 & MF2_BOSS) || (self->flags8 & MF8_FULLVOLSEE))
|
||||
{ // full volume
|
||||
|
@ -2145,7 +2145,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_LookEx)
|
|||
if (self->reactiontime > self->Level->maptime)
|
||||
self->target = nullptr;
|
||||
}
|
||||
else if (self->SeeSound && !(flags & LOF_NOSEESOUND))
|
||||
else if (self->SeeSound.isvalid() && !(flags & LOF_NOSEESOUND))
|
||||
{
|
||||
if (flags & LOF_FULLVOLSEESOUND)
|
||||
{ // full volume
|
||||
|
@ -2574,7 +2574,7 @@ void A_DoChase (AActor *actor, bool fastchase, FState *meleestate, FState *missi
|
|||
// check for melee attack
|
||||
if (meleestate && P_CheckMeleeRange(actor))
|
||||
{
|
||||
if (actor->AttackSound)
|
||||
if (actor->AttackSound.isvalid())
|
||||
S_Sound (actor, CHAN_WEAPON, 0, actor->AttackSound, 1, ATTN_NORM);
|
||||
|
||||
actor->SetState (meleestate);
|
||||
|
@ -2836,7 +2836,7 @@ bool P_CheckForResurrection(AActor* self, bool usevilestates, FState* state = nu
|
|||
self->SetState(archvile->FindState(NAME_Heal));
|
||||
}
|
||||
}
|
||||
if (sound == 0) sound = "vile/raise";
|
||||
if (sound == NO_SOUND) sound = "vile/raise";
|
||||
S_Sound(corpsehit, CHAN_BODY, 0, sound, 1, ATTN_IDLE);
|
||||
info = corpsehit->GetDefault();
|
||||
|
||||
|
@ -3132,7 +3132,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_Pain)
|
|||
pain_sound += '-';
|
||||
pain_sound += self->player->LastDamageType.GetChars();
|
||||
sfx_id = pain_sound;
|
||||
if (sfx_id == 0)
|
||||
if (sfx_id == NO_SOUND)
|
||||
{
|
||||
// Try again without a specific pain amount.
|
||||
pain_sound = "*pain-";
|
||||
|
@ -3140,14 +3140,14 @@ DEFINE_ACTION_FUNCTION(AActor, A_Pain)
|
|||
sfx_id = pain_sound;
|
||||
}
|
||||
}
|
||||
if (sfx_id == 0)
|
||||
if (sfx_id == NO_SOUND)
|
||||
{
|
||||
sfx_id = pain_amount;
|
||||
}
|
||||
|
||||
S_Sound (self, CHAN_VOICE, 0, sfx_id, 1, ATTN_NORM);
|
||||
}
|
||||
else if (self->PainSound)
|
||||
else if (self->PainSound.isvalid())
|
||||
{
|
||||
S_Sound (self, CHAN_VOICE, 0, self->PainSound, 1, ATTN_NORM);
|
||||
}
|
||||
|
|
|
@ -4613,7 +4613,7 @@ AActor *P_LineAttack(AActor *t1, DAngle angle, double distance,
|
|||
if (!Trace(tempos, t1->Sector, direction, distance, MF_SHOOTABLE,
|
||||
ML_BLOCKEVERYTHING | ML_BLOCKHITSCAN, t1, trace, tflags, CheckForActor, &TData))
|
||||
{ // hit nothing
|
||||
if (!nointeract && puffDefaults && puffDefaults->ActiveSound)
|
||||
if (!nointeract && puffDefaults && puffDefaults->ActiveSound.isvalid())
|
||||
{ // Play miss sound
|
||||
S_Sound(t1, CHAN_WEAPON, 0, puffDefaults->ActiveSound, 1, ATTN_NORM);
|
||||
}
|
||||
|
@ -6379,7 +6379,7 @@ void P_DoCrunch(AActor *thing, FChangePosition *cpos)
|
|||
P_DrawSplash2(thing->Level, 32, thing->PosPlusZ(thing->Height/2), an, 2, thing->BloodColor);
|
||||
}
|
||||
}
|
||||
if (thing->CrushPainSound != 0 && !S_GetSoundPlayingInfo(thing, thing->CrushPainSound))
|
||||
if (thing->CrushPainSound != NO_SOUND && !S_GetSoundPlayingInfo(thing, thing->CrushPainSound))
|
||||
{
|
||||
S_Sound(thing, CHAN_VOICE, 0, thing->CrushPainSound, 1.f, ATTN_NORM);
|
||||
}
|
||||
|
|
|
@ -1436,7 +1436,7 @@ void P_ExplodeMissile (AActor *mo, line_t *line, AActor *target, bool onsky, FNa
|
|||
}
|
||||
|
||||
// play the sound before changing the state, so that AActor::OnDestroy can call S_RelinkSounds on it and the death state can override it.
|
||||
if (mo->DeathSound)
|
||||
if (mo->DeathSound.isvalid())
|
||||
{
|
||||
S_Sound (mo, CHAN_VOICE, 0, mo->DeathSound, 1,
|
||||
(mo->flags3 & MF3_FULLVOLDEATH) ? ATTN_NONE : ATTN_NORM);
|
||||
|
@ -1504,7 +1504,7 @@ void AActor::PlayBounceSound(bool onfloor)
|
|||
{
|
||||
S_Sound (this, CHAN_VOICE, 0, SeeSound, 1, ATTN_IDLE);
|
||||
}
|
||||
else if (onfloor || WallBounceSound <= 0)
|
||||
else if (onfloor || !WallBounceSound.isvalid())
|
||||
{
|
||||
S_Sound (this, CHAN_VOICE, 0, BounceSound, 1, ATTN_IDLE);
|
||||
}
|
||||
|
@ -3299,7 +3299,7 @@ void AActor::AlterWeaponSprite(visstyle_t *vis)
|
|||
|
||||
void AActor::PlayActiveSound ()
|
||||
{
|
||||
if (ActiveSound && !S_IsActorPlayingSomething (this, CHAN_VOICE, -1))
|
||||
if (ActiveSound.isvalid() && !S_IsActorPlayingSomething(this, CHAN_VOICE, -1))
|
||||
{
|
||||
S_Sound (this, CHAN_VOICE, 0, ActiveSound, 1,
|
||||
(flags3 & MF3_FULLVOLACTIVE) ? ATTN_NONE : ATTN_IDLE);
|
||||
|
@ -5864,11 +5864,11 @@ AActor *P_SpawnPuff (AActor *source, PClassActor *pufftype, const DVector3 &pos1
|
|||
if (cl_pufftype == 1) puff->renderflags |= RF_INVISIBLE;
|
||||
}
|
||||
|
||||
if ((flags & PF_HITTHING) && puff->SeeSound)
|
||||
if ((flags & PF_HITTHING) && puff->SeeSound.isvalid())
|
||||
{ // Hit thing sound
|
||||
S_Sound (puff, CHAN_BODY, 0, puff->SeeSound, 1, ATTN_NORM);
|
||||
}
|
||||
else if (puff->AttackSound)
|
||||
else if (puff->AttackSound.isvalid())
|
||||
{
|
||||
S_Sound (puff, CHAN_BODY, 0, puff->AttackSound, 1, ATTN_NORM);
|
||||
}
|
||||
|
@ -6498,7 +6498,7 @@ DEFINE_ACTION_FUNCTION(AActor, CheckMissileSpawn)
|
|||
|
||||
void P_PlaySpawnSound(AActor *missile, AActor *spawner)
|
||||
{
|
||||
if (missile->SeeSound != 0)
|
||||
if (missile->SeeSound != NO_SOUND)
|
||||
{
|
||||
if (!(missile->flags & MF_SPAWNSOUNDSOURCE))
|
||||
{
|
||||
|
|
|
@ -250,7 +250,7 @@ bool P_CheckSwitchRange(AActor *user, line_t *line, int sideno, const DVector3 *
|
|||
bool P_ChangeSwitchTexture (side_t *side, int useAgain, uint8_t special, bool *quest)
|
||||
{
|
||||
int texture;
|
||||
int sound;
|
||||
FSoundID sound;
|
||||
FSwitchDef *Switch;
|
||||
|
||||
if ((Switch = TexAnim.FindSwitch (side->GetTexture(side_t::top))) != NULL)
|
||||
|
@ -275,7 +275,7 @@ bool P_ChangeSwitchTexture (side_t *side, int useAgain, uint8_t special, bool *q
|
|||
}
|
||||
|
||||
// EXIT SWITCH?
|
||||
if (Switch->Sound != 0)
|
||||
if (Switch->Sound != NO_SOUND)
|
||||
{
|
||||
sound = Switch->Sound;
|
||||
}
|
||||
|
@ -404,7 +404,7 @@ void DActiveButton::Tick ()
|
|||
{
|
||||
m_Frame = -1;
|
||||
S_Sound (Level, DVector3(m_Pos, 0), CHAN_VOICE, CHANF_LISTENERZ,
|
||||
def->Sound != 0 ? FSoundID(def->Sound) : FSoundID("switches/normbutn"),
|
||||
def->Sound != NO_SOUND ? FSoundID(def->Sound) : FSoundID("switches/normbutn"),
|
||||
1, ATTN_STATIC);
|
||||
bFlippable = false;
|
||||
}
|
||||
|
|
|
@ -446,7 +446,7 @@ void player_t::SetSubtitle(int num, FSoundID soundid)
|
|||
if (text != nullptr)
|
||||
{
|
||||
SubtitleText = lumpname;
|
||||
int sl = soundid == 0 ? 7000 : max<int>(7000, S_GetMSLength(soundid));
|
||||
int sl = soundid == NO_SOUND ? 7000 : max<int>(7000, S_GetMSLength(soundid));
|
||||
SubtitleCounter = sl * TICRATE / 1000;
|
||||
}
|
||||
}
|
||||
|
@ -887,12 +887,12 @@ DEFINE_ACTION_FUNCTION(AActor, A_PlayerScream)
|
|||
{
|
||||
PARAM_SELF_PROLOGUE(AActor);
|
||||
|
||||
int sound = 0;
|
||||
FSoundID sound = 0;
|
||||
int chan = CHAN_VOICE;
|
||||
|
||||
if (self->player == NULL || self->DeathSound != 0)
|
||||
if (self->player == NULL || self->DeathSound != NO_SOUND)
|
||||
{
|
||||
if (self->DeathSound != 0)
|
||||
if (self->DeathSound != NO_SOUND)
|
||||
{
|
||||
S_Sound (self, CHAN_VOICE, 0, self->DeathSound, 1, ATTN_NORM);
|
||||
}
|
||||
|
@ -912,27 +912,27 @@ DEFINE_ACTION_FUNCTION(AActor, A_PlayerScream)
|
|||
chan = CHAN_BODY;
|
||||
}
|
||||
|
||||
if (!sound && self->special1<10)
|
||||
if (!sound.isvalid() && self->special1<10)
|
||||
{ // Wimpy death sound
|
||||
sound = S_FindSkinnedSoundEx (self, "*wimpydeath", self->player->LastDamageType.GetChars());
|
||||
}
|
||||
if (!sound && self->health <= -50)
|
||||
if (!sound.isvalid() && self->health <= -50)
|
||||
{
|
||||
if (self->health > -100)
|
||||
{ // Crazy death sound
|
||||
sound = S_FindSkinnedSoundEx (self, "*crazydeath", self->player->LastDamageType.GetChars());
|
||||
}
|
||||
if (!sound)
|
||||
if (!sound.isvalid())
|
||||
{ // Extreme death sound
|
||||
sound = S_FindSkinnedSoundEx (self, "*xdeath", self->player->LastDamageType.GetChars());
|
||||
if (!sound)
|
||||
if (!sound.isvalid())
|
||||
{
|
||||
sound = S_FindSkinnedSoundEx (self, "*gibbed", self->player->LastDamageType.GetChars());
|
||||
chan = CHAN_BODY;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!sound)
|
||||
if (!sound.isvalid())
|
||||
{ // Normal death sound
|
||||
sound = S_FindSkinnedSoundEx (self, "*death", self->player->LastDamageType.GetChars());
|
||||
}
|
||||
|
@ -1169,8 +1169,8 @@ void P_CheckEnvironment(player_t *player)
|
|||
player->mo->Vel.Z >= -player->mo->FloatVar(NAME_FallingScreamMaxSpeed) && !player->morphTics &&
|
||||
player->mo->waterlevel == 0)
|
||||
{
|
||||
int id = S_FindSkinnedSound(player->mo, "*falling");
|
||||
if (id != 0 && !S_IsActorPlayingSomething(player->mo, CHAN_VOICE, id))
|
||||
auto id = S_FindSkinnedSound(player->mo, "*falling");
|
||||
if (id != NO_SOUND && !S_IsActorPlayingSomething(player->mo, CHAN_VOICE, id))
|
||||
{
|
||||
S_Sound(player->mo, CHAN_VOICE, 0, id, 1, ATTN_NORM);
|
||||
}
|
||||
|
|
|
@ -573,7 +573,7 @@ void R_InitSkins (void)
|
|||
unsigned i;
|
||||
int j, k, base;
|
||||
int lastlump;
|
||||
int aliasid;
|
||||
FSoundID aliasid;
|
||||
bool remove;
|
||||
PClassActor *basetype, *transtype;
|
||||
|
||||
|
@ -733,8 +733,8 @@ void R_InitSkins (void)
|
|||
}
|
||||
else
|
||||
{
|
||||
int sndref = soundEngine->FindSoundNoHash (key);
|
||||
if (sndref != 0)
|
||||
auto sndref = soundEngine->FindSoundNoHash (key);
|
||||
if (sndref.isvalid())
|
||||
{
|
||||
S_AddPlayerSound (Skins[i].Name, Skins[i].gender, sndref, lump, true);
|
||||
}
|
||||
|
|
|
@ -531,7 +531,7 @@ static void ParseInsideDecoration (Baggage &bag, AActor *defaults,
|
|||
else if (def == DEF_Pickup && sc.Compare ("PickupSound"))
|
||||
{
|
||||
sc.MustGetString ();
|
||||
defaults->IntVar(NAME_PickupSound) = FSoundID(sc.String);
|
||||
defaults->IntVar(NAME_PickupSound) = S_FindSound(sc.String).index();
|
||||
}
|
||||
else if (def == DEF_Pickup && sc.Compare ("PickupMessage"))
|
||||
{
|
||||
|
|
|
@ -173,7 +173,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(AActor, A_SoundVolume, S_ChangeActorSoundVolume)
|
|||
DEFINE_ACTION_FUNCTION_NATIVE(AActor, A_PlaySound, A_PlaySound)
|
||||
{
|
||||
PARAM_SELF_PROLOGUE(AActor);
|
||||
PARAM_SOUND(soundid);
|
||||
PARAM_INT(soundid);
|
||||
PARAM_INT(channel);
|
||||
PARAM_FLOAT(volume);
|
||||
PARAM_BOOL(looping);
|
||||
|
@ -187,7 +187,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(AActor, A_PlaySound, A_PlaySound)
|
|||
DEFINE_ACTION_FUNCTION_NATIVE(AActor, A_StartSound, A_StartSound)
|
||||
{
|
||||
PARAM_SELF_PROLOGUE(AActor);
|
||||
PARAM_SOUND(soundid);
|
||||
PARAM_INT(soundid);
|
||||
PARAM_INT(channel);
|
||||
PARAM_INT(flags);
|
||||
PARAM_FLOAT(volume);
|
||||
|
|
|
@ -187,7 +187,7 @@ static int S_AddPlayerClass (const char *name);
|
|||
static int S_AddPlayerGender (int classnum, int gender);
|
||||
static int S_FindPlayerClass (const char *name);
|
||||
static FSoundID S_LookupPlayerSound (int classidx, int gender, FSoundID refid);
|
||||
static void S_ParsePlayerSoundCommon (FScanner &sc, FString &pclass, int &gender, int &refid);
|
||||
static void S_ParsePlayerSoundCommon (FScanner &sc, FString &pclass, int &gender, FSoundID &refid);
|
||||
static void S_AddSNDINFO (int lumpnum);
|
||||
static void S_AddBloodSFX (int lumpnum);
|
||||
static void S_AddStrifeVoice (int lumpnum);
|
||||
|
@ -416,7 +416,7 @@ static FSoundID S_AddSound (const char *logicalname, int lumpnum, FScanner *sc)
|
|||
{
|
||||
FSoundID sfxid = soundEngine->FindSoundNoHash (logicalname);
|
||||
|
||||
if (sfxid > 0)
|
||||
if (sfxid.isvalid())
|
||||
{ // If the sound has already been defined, change the old definition
|
||||
auto sfx = soundEngine->GetWritableSfx(sfxid);
|
||||
|
||||
|
@ -468,7 +468,7 @@ static FSoundID S_AddSound (const char *logicalname, int lumpnum, FScanner *sc)
|
|||
// Adds the given sound lump to the player sound lists.
|
||||
//==========================================================================
|
||||
|
||||
int S_AddPlayerSound (const char *pclass, int gender, FSoundID refid, const char *lumpname)
|
||||
FSoundID S_AddPlayerSound (const char *pclass, int gender, FSoundID refid, const char *lumpname)
|
||||
{
|
||||
int lump=-1;
|
||||
|
||||
|
@ -480,13 +480,13 @@ int S_AddPlayerSound (const char *pclass, int gender, FSoundID refid, const char
|
|||
return S_AddPlayerSound (pclass, gender, refid, lump);
|
||||
}
|
||||
|
||||
int S_AddPlayerSound (const char *pclass, int gender, FSoundID refid, int lumpnum, bool fromskin)
|
||||
FSoundID S_AddPlayerSound (const char *pclass, int gender, FSoundID refid, int lumpnum, bool fromskin)
|
||||
{
|
||||
FString fakename;
|
||||
FSoundID id;
|
||||
|
||||
auto sfx = soundEngine->GetSfx(refid);
|
||||
if (refid == 0 || !sfx) return 0;
|
||||
if (refid == NO_SOUND || !sfx) return 0;
|
||||
|
||||
fakename = pclass;
|
||||
fakename += '"';
|
||||
|
@ -512,12 +512,12 @@ int S_AddPlayerSound (const char *pclass, int gender, FSoundID refid, int lumpnu
|
|||
// Adds the player sound as an alias to an existing sound.
|
||||
//==========================================================================
|
||||
|
||||
int S_AddPlayerSoundExisting (const char *pclass, int gender, FSoundID refid, FSoundID aliasto, bool fromskin)
|
||||
FSoundID S_AddPlayerSoundExisting (const char *pclass, int gender, FSoundID refid, FSoundID aliasto, bool fromskin)
|
||||
{
|
||||
int classnum = S_AddPlayerClass (pclass);
|
||||
int soundlist = S_AddPlayerGender (classnum, gender);
|
||||
auto sfx = soundEngine->GetSfx(refid);
|
||||
if (refid == 0 || !sfx) return 0;
|
||||
if (refid == NO_SOUND || !sfx) return 0;
|
||||
|
||||
PlayerSounds[soundlist].AddSound (sfx->link, aliasto);
|
||||
|
||||
|
@ -535,7 +535,7 @@ int S_AddPlayerSoundExisting (const char *pclass, int gender, FSoundID refid, FS
|
|||
|
||||
FSoundID S_DupPlayerSound (const char *pclass, int gender, FSoundID refid, FSoundID aliasref)
|
||||
{
|
||||
int aliasto = S_LookupPlayerSound (pclass, gender, aliasref);
|
||||
auto aliasto = S_LookupPlayerSound (pclass, gender, aliasref);
|
||||
return S_AddPlayerSoundExisting (pclass, gender, refid, aliasto);
|
||||
}
|
||||
|
||||
|
@ -772,7 +772,8 @@ static void S_AddSNDINFO (int lump)
|
|||
case SI_PlayerSound: {
|
||||
// $playersound <player class> <gender> <logical name> <lump name>
|
||||
FString pclass;
|
||||
int gender, refid, sfxnum;
|
||||
int gender;
|
||||
FSoundID refid, sfxnum;
|
||||
|
||||
S_ParsePlayerSoundCommon (sc, pclass, gender, refid);
|
||||
sfxnum = S_AddPlayerSound (pclass, gender, refid, sc.String);
|
||||
|
@ -786,7 +787,8 @@ static void S_AddSNDINFO (int lump)
|
|||
case SI_PlayerSoundDup: {
|
||||
// $playersounddup <player class> <gender> <logical name> <target sound name>
|
||||
FString pclass;
|
||||
int gender, refid, targid;
|
||||
int gender;
|
||||
FSoundID refid, targid;
|
||||
|
||||
S_ParsePlayerSoundCommon (sc, pclass, gender, refid);
|
||||
targid = soundEngine->FindSoundNoHash (sc.String);
|
||||
|
@ -802,7 +804,8 @@ static void S_AddSNDINFO (int lump)
|
|||
case SI_PlayerCompat: {
|
||||
// $playercompat <player class> <gender> <logical name> <compat sound name>
|
||||
FString pclass;
|
||||
int gender, refid;
|
||||
int gender;
|
||||
FSoundID refid;
|
||||
FSoundID sfxfrom, aliasto;
|
||||
|
||||
S_ParsePlayerSoundCommon (sc, pclass, gender, refid);
|
||||
|
@ -817,8 +820,8 @@ static void S_AddSNDINFO (int lump)
|
|||
case SI_PlayerAlias: {
|
||||
// $playeralias <player class> <gender> <logical name> <logical name of existing sound>
|
||||
FString pclass;
|
||||
int gender, refid;
|
||||
int soundnum;
|
||||
int gender;
|
||||
FSoundID refid, soundnum;
|
||||
|
||||
S_ParsePlayerSoundCommon (sc, pclass, gender, refid);
|
||||
soundnum = soundEngine->FindSoundTentative (sc.String);
|
||||
|
@ -828,7 +831,7 @@ static void S_AddSNDINFO (int lump)
|
|||
|
||||
case SI_Alias: {
|
||||
// $alias <name of alias> <name of real sound>
|
||||
int sfxfrom;
|
||||
FSoundID sfxfrom;
|
||||
|
||||
sc.MustGetString ();
|
||||
sfxfrom = S_AddSound (sc.String, -1, &sc);
|
||||
|
@ -838,14 +841,14 @@ static void S_AddSNDINFO (int lump)
|
|||
{
|
||||
sfxfrom = sfx->link;
|
||||
}
|
||||
sfx->link = FSoundID::fromInt(soundEngine->FindSoundTentative (sc.String));
|
||||
sfx->link = soundEngine->FindSoundTentative (sc.String);
|
||||
sfx->NearLimit = -1; // Aliases must use the original sound's limit.
|
||||
}
|
||||
break;
|
||||
|
||||
case SI_Limit: {
|
||||
// $limit <logical name> <max channels> [<distance>]
|
||||
int sfxfrom;
|
||||
FSoundID sfxfrom;
|
||||
|
||||
sc.MustGetString ();
|
||||
sfxfrom = soundEngine->FindSoundTentative (sc.String);
|
||||
|
@ -861,7 +864,7 @@ static void S_AddSNDINFO (int lump)
|
|||
|
||||
case SI_Singular: {
|
||||
// $singular <logical name>
|
||||
int sfx;
|
||||
FSoundID sfx;
|
||||
|
||||
sc.MustGetString ();
|
||||
sfx = soundEngine->FindSoundTentative (sc.String);
|
||||
|
@ -872,7 +875,7 @@ static void S_AddSNDINFO (int lump)
|
|||
|
||||
case SI_PitchShift: {
|
||||
// $pitchshift <logical name> <pitch shift amount>
|
||||
int sfx;
|
||||
FSoundID sfx;
|
||||
|
||||
sc.MustGetString ();
|
||||
sfx = soundEngine->FindSoundTentative (sc.String);
|
||||
|
@ -884,7 +887,7 @@ static void S_AddSNDINFO (int lump)
|
|||
|
||||
case SI_PitchSet: {
|
||||
// $pitchset <logical name> <pitch amount as float> [range maximum]
|
||||
int sfx;
|
||||
FSoundID sfx;
|
||||
|
||||
sc.MustGetString();
|
||||
sfx = soundEngine->FindSoundTentative(sc.String);
|
||||
|
@ -910,7 +913,7 @@ static void S_AddSNDINFO (int lump)
|
|||
|
||||
case SI_Volume: {
|
||||
// $volume <logical name> <volume>
|
||||
int sfx;
|
||||
FSoundID sfx;
|
||||
|
||||
sc.MustGetString();
|
||||
sfx = soundEngine->FindSoundTentative(sc.String);
|
||||
|
@ -922,7 +925,7 @@ static void S_AddSNDINFO (int lump)
|
|||
|
||||
case SI_Attenuation: {
|
||||
// $attenuation <logical name> <attenuation>
|
||||
int sfx;
|
||||
FSoundID sfx;
|
||||
|
||||
sc.MustGetString();
|
||||
sfx = soundEngine->FindSoundTentative(sc.String);
|
||||
|
@ -937,12 +940,12 @@ static void S_AddSNDINFO (int lump)
|
|||
// Using * for the name makes it the default for sounds that don't specify otherwise.
|
||||
FRolloffInfo *rolloff;
|
||||
int type;
|
||||
int sfx;
|
||||
FSoundID sfx;
|
||||
|
||||
sc.MustGetString();
|
||||
if (sc.Compare("*"))
|
||||
{
|
||||
sfx = -1;
|
||||
sfx = INVALID_SOUND;
|
||||
rolloff = &soundEngine->GlobalRolloff();
|
||||
}
|
||||
else
|
||||
|
@ -985,11 +988,11 @@ static void S_AddSNDINFO (int lump)
|
|||
|
||||
list.Clear ();
|
||||
sc.MustGetString ();
|
||||
uint32_t Owner = S_AddSound (sc.String, -1, &sc);
|
||||
FSoundID Owner = S_AddSound (sc.String, -1, &sc);
|
||||
sc.MustGetStringName ("{");
|
||||
while (sc.GetString () && !sc.Compare ("}"))
|
||||
{
|
||||
uint32_t sfxto = soundEngine->FindSoundTentative (sc.String);
|
||||
FSoundID sfxto = soundEngine->FindSoundTentative (sc.String);
|
||||
if (sfxto == random.Owner)
|
||||
{
|
||||
Printf("Definition of random sound '%s' refers to itself recursively.\n", sc.String);
|
||||
|
@ -1133,7 +1136,7 @@ static void S_AddStrifeVoice (int lumpnum)
|
|||
// (player class, gender, and ref id)
|
||||
//==========================================================================
|
||||
|
||||
static void S_ParsePlayerSoundCommon (FScanner &sc, FString &pclass, int &gender, int &refid)
|
||||
static void S_ParsePlayerSoundCommon (FScanner &sc, FString &pclass, int &gender, FSoundID &refid)
|
||||
{
|
||||
sc.MustGetString ();
|
||||
pclass = sc.String;
|
||||
|
@ -1142,11 +1145,11 @@ static void S_ParsePlayerSoundCommon (FScanner &sc, FString &pclass, int &gender
|
|||
sc.MustGetString ();
|
||||
refid = soundEngine->FindSoundNoHash (sc.String);
|
||||
auto sfx = soundEngine->GetWritableSfx(refid);
|
||||
if (refid > 0 && sfx && !(sfx->UserData[0] & SND_PlayerReserve) && !sfx->bTentative)
|
||||
if (refid.isvalid() && sfx && !(sfx->UserData[0] & SND_PlayerReserve) && !sfx->bTentative)
|
||||
{
|
||||
sc.ScriptError ("%s has already been used for a non-player sound.", sc.String);
|
||||
}
|
||||
if (refid == 0)
|
||||
if (refid == NO_SOUND)
|
||||
{
|
||||
refid = S_AddSound (sc.String, -1, &sc);
|
||||
sfx = soundEngine->GetWritableSfx(refid);
|
||||
|
@ -1336,12 +1339,12 @@ static FSoundID S_LookupPlayerSound (int classidx, int gender, FSoundID refid)
|
|||
auto sfxp = soundEngine->GetWritableSfx(refid);
|
||||
if (!sfxp) return 0;
|
||||
|
||||
int sndnum = PlayerSounds[listidx].LookupSound (sfxp->link);
|
||||
FSoundID sndnum = PlayerSounds[listidx].LookupSound (sfxp->link);
|
||||
sfxp = soundEngine->GetWritableSfx(sndnum);
|
||||
|
||||
// If we're not done parsing SNDINFO yet, assume that the target sound is valid
|
||||
if (PlayerClassesIsSorted &&
|
||||
(!sfxp || sndnum == 0 ||
|
||||
(!sfxp || sndnum == NO_SOUND ||
|
||||
((sfxp->lumpnum == -1 || sfxp->lumpnum == sfx_empty) &&
|
||||
sfxp->link == sfxinfo_t::NO_LINK &&
|
||||
!(sfxp->UserData[0] & SND_PlayerSilent))))
|
||||
|
@ -1411,7 +1414,7 @@ bool S_AreSoundsEquivalent (AActor *actor, FSoundID id1, FSoundID id2)
|
|||
{
|
||||
return true;
|
||||
}
|
||||
if (id1 == 0 || id2 == 0)
|
||||
if (!id1.isvalid() || !id2.isvalid())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -1503,7 +1506,7 @@ FSoundID S_FindSkinnedSound (AActor *actor, FSoundID refid)
|
|||
// Tries looking for both "name-extendedname" and "name" in that order.
|
||||
//==========================================================================
|
||||
|
||||
int S_FindSkinnedSoundEx (AActor *actor, const char *name, const char *extendedname)
|
||||
FSoundID S_FindSkinnedSoundEx (AActor *actor, const char *name, const char *extendedname)
|
||||
{
|
||||
FString fullname;
|
||||
|
||||
|
@ -1513,7 +1516,7 @@ int S_FindSkinnedSoundEx (AActor *actor, const char *name, const char *extendedn
|
|||
fullname += extendedname;
|
||||
FSoundID id = fullname;
|
||||
|
||||
if (id == 0)
|
||||
if (!id.isvalid())
|
||||
{ // Look for "name"
|
||||
id = name;
|
||||
}
|
||||
|
@ -1590,7 +1593,7 @@ CCMD (playersounds)
|
|||
if (sfx->UserData[0] & SND_PlayerReserve)
|
||||
{
|
||||
++j;
|
||||
reserveNames[sfx->link] = sfx->name;
|
||||
reserveNames[sfx->link.index()] = sfx->name;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1757,7 +1760,7 @@ DEFINE_ACTION_FUNCTION(AAmbientSound, Activate)
|
|||
{
|
||||
if ((amb->type & 3) == 0 && amb->periodmin == 0)
|
||||
{
|
||||
if (amb->sound == 0)
|
||||
if (!amb->sound.isvalid())
|
||||
{
|
||||
self->Destroy ();
|
||||
return 0;
|
||||
|
|
|
@ -81,7 +81,7 @@ class DoomSoundEngine : public SoundEngine
|
|||
void CalcPosVel(int type, const void* source, const float pt[3], int channum, int chanflags, FSoundID soundid, FVector3* pos, FVector3* vel, FSoundChan *) override;
|
||||
bool ValidatePosVel(int sourcetype, const void* source, const FVector3& pos, const FVector3& vel);
|
||||
TArray<uint8_t> ReadSound(int lumpnum);
|
||||
int PickReplacement(int refid);
|
||||
FSoundID PickReplacement(FSoundID refid);
|
||||
FSoundID ResolveSound(const void *ent, int type, FSoundID soundid, float &attenuation) override;
|
||||
void CacheSound(sfxinfo_t* sfx) override;
|
||||
void StopChannel(FSoundChan* chan) override;
|
||||
|
@ -413,7 +413,7 @@ DEFINE_ACTION_FUNCTION(DObject, S_Sound)
|
|||
PARAM_FLOAT(attn);
|
||||
PARAM_FLOAT(pitch);
|
||||
PARAM_FLOAT(startTime);
|
||||
S_SoundPitch(channel & 7, EChanFlags::FromInt(channel & ~7), FSoundID::fromInt(id), static_cast<float>(volume), static_cast<float>(attn), static_cast<float>(pitch), static_cast<float>(startTime));
|
||||
S_SoundPitch(channel & 7, EChanFlags::FromInt(channel & ~7), id, static_cast<float>(volume), static_cast<float>(attn), static_cast<float>(pitch), static_cast<float>(startTime));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -427,7 +427,7 @@ DEFINE_ACTION_FUNCTION(DObject, S_StartSound)
|
|||
PARAM_FLOAT(attn);
|
||||
PARAM_FLOAT(pitch);
|
||||
PARAM_FLOAT(startTime);
|
||||
S_SoundPitch(channel, EChanFlags::FromInt(flags), FSoundID::fromInt(id), static_cast<float>(volume), static_cast<float>(attn), static_cast<float>(pitch), static_cast<float>(startTime));
|
||||
S_SoundPitch(channel, EChanFlags::FromInt(flags), id, static_cast<float>(volume), static_cast<float>(attn), static_cast<float>(pitch), static_cast<float>(startTime));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -451,7 +451,7 @@ void DoomSoundEngine::CacheSound(sfxinfo_t* sfx)
|
|||
|
||||
FSoundID DoomSoundEngine::ResolveSound(const void * ent, int type, FSoundID soundid, float &attenuation)
|
||||
{
|
||||
auto sfx = &S_sfx[soundid];
|
||||
auto sfx = &S_sfx[soundid.index()];
|
||||
if (sfx->UserData[0] & SND_PlayerReserve)
|
||||
{
|
||||
AActor *src;
|
||||
|
@ -1177,11 +1177,11 @@ TArray<uint8_t> DoomSoundEngine::ReadSound(int lumpnum)
|
|||
//==========================================================================
|
||||
static FRandom pr_randsound("RandSound");
|
||||
|
||||
int DoomSoundEngine::PickReplacement(int refid)
|
||||
FSoundID DoomSoundEngine::PickReplacement(FSoundID refid)
|
||||
{
|
||||
while (S_sfx[refid].bRandomHeader)
|
||||
while (S_sfx[refid.index()].bRandomHeader)
|
||||
{
|
||||
const FRandomSoundList* list = &S_rnd[S_sfx[refid].link];
|
||||
const FRandomSoundList* list = &S_rnd[S_sfx[refid.index()].link.index()];
|
||||
refid = list->Choices[pr_randsound(list->Choices.Size())];
|
||||
}
|
||||
return refid;
|
||||
|
@ -1238,7 +1238,7 @@ void DoomSoundEngine::NoiseDebug()
|
|||
color = (chan->ChanFlags & CHANF_LOOP) ? CR_BROWN : CR_GREY;
|
||||
|
||||
// Name
|
||||
fileSystem.GetFileShortName(temp, S_sfx[chan->SoundID].lumpnum);
|
||||
fileSystem.GetFileShortName(temp, S_sfx[chan->SoundID.index()].lumpnum);
|
||||
temp[8] = 0;
|
||||
DrawText(twod, NewConsoleFont, color, 0, y, temp, TAG_DONE);
|
||||
|
||||
|
@ -1343,10 +1343,10 @@ void DoomSoundEngine::PrintSoundList()
|
|||
if (sfx->bRandomHeader)
|
||||
{
|
||||
Printf("%3d. %s -> #%d {", i, sfx->name.GetChars(), sfx->link);
|
||||
const FRandomSoundList* list = &S_rnd[sfx->link];
|
||||
const FRandomSoundList* list = &S_rnd[sfx->link.index()];
|
||||
for (auto& me : list->Choices)
|
||||
{
|
||||
Printf(" %s ", S_sfx[me].name.GetChars());
|
||||
Printf(" %s ", S_sfx[me.index()].name.GetChars());
|
||||
}
|
||||
Printf("}\n");
|
||||
}
|
||||
|
@ -1361,7 +1361,7 @@ void DoomSoundEngine::PrintSoundList()
|
|||
}
|
||||
else if (S_sfx[i].link != sfxinfo_t::NO_LINK)
|
||||
{
|
||||
Printf("%3d. %s -> %s\n", i, sfx->name.GetChars(), S_sfx[sfx->link].name.GetChars());
|
||||
Printf("%3d. %s -> %s\n", i, sfx->name.GetChars(), S_sfx[sfx->link.index()].name.GetChars());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1387,7 +1387,7 @@ CCMD (playsound)
|
|||
if (argv.argc() > 1)
|
||||
{
|
||||
FSoundID id = argv[1];
|
||||
if (id == 0)
|
||||
if (!id.isvalid())
|
||||
{
|
||||
Printf("'%s' is not a sound\n", argv[1]);
|
||||
}
|
||||
|
@ -1409,7 +1409,7 @@ CCMD (loopsound)
|
|||
if (players[consoleplayer].mo != nullptr && !netgame && argv.argc() > 1)
|
||||
{
|
||||
FSoundID id = argv[1];
|
||||
if (id == 0)
|
||||
if (!id.isvalid())
|
||||
{
|
||||
Printf("'%s' is not a sound\n", argv[1]);
|
||||
}
|
||||
|
|
|
@ -155,7 +155,7 @@ public:
|
|||
}
|
||||
bool IsPlaying()
|
||||
{
|
||||
return m_CurrentSoundID != 0 && S_GetSoundPlayingInfo (m_Poly, m_CurrentSoundID);
|
||||
return m_CurrentSoundID.isvalid() && S_GetSoundPlayingInfo (m_Poly, m_CurrentSoundID);
|
||||
}
|
||||
void *Source()
|
||||
{
|
||||
|
@ -184,7 +184,7 @@ public:
|
|||
}
|
||||
bool IsPlaying()
|
||||
{
|
||||
return m_CurrentSoundID != 0 && S_GetSoundPlayingInfo (m_Sector, m_CurrentSoundID);
|
||||
return m_CurrentSoundID.isvalid() && S_GetSoundPlayingInfo (m_Sector, m_CurrentSoundID);
|
||||
}
|
||||
void *Source()
|
||||
{
|
||||
|
@ -570,7 +570,7 @@ void S_ParseSndSeq (int levellump)
|
|||
char seqtype = ':';
|
||||
FName seqname = NAME_None;
|
||||
FName slot = NAME_None;
|
||||
int stopsound;
|
||||
FSoundID stopsound;
|
||||
int delaybase;
|
||||
float volumebase;
|
||||
int curseq = -1;
|
||||
|
@ -636,7 +636,7 @@ void S_ParseSndSeq (int levellump)
|
|||
if (sc.String[0] == ']')
|
||||
{ // End of this definition
|
||||
ScriptTemp[0] = MakeCommand(SS_CMD_SELECT, (ScriptTemp.Size()-1)/2);
|
||||
AddSequence (curseq, seqname, slot, stopsound, ScriptTemp);
|
||||
AddSequence (curseq, seqname, slot, stopsound.index(), ScriptTemp);
|
||||
curseq = -1;
|
||||
sc.SetCMode (false);
|
||||
}
|
||||
|
@ -661,30 +661,30 @@ void S_ParseSndSeq (int levellump)
|
|||
{
|
||||
case SS_STRING_PLAYUNTILDONE:
|
||||
sc.MustGetString ();
|
||||
ScriptTemp.Push(MakeCommand(SS_CMD_PLAY, S_FindSound (sc.String)));
|
||||
ScriptTemp.Push(MakeCommand(SS_CMD_PLAY, S_FindSound (sc.String).index()));
|
||||
ScriptTemp.Push(MakeCommand(SS_CMD_WAITUNTILDONE, 0));
|
||||
break;
|
||||
|
||||
case SS_STRING_PLAY:
|
||||
sc.MustGetString ();
|
||||
ScriptTemp.Push(MakeCommand(SS_CMD_PLAY, S_FindSound (sc.String)));
|
||||
ScriptTemp.Push(MakeCommand(SS_CMD_PLAY, S_FindSound (sc.String).index()));
|
||||
break;
|
||||
|
||||
case SS_STRING_PLAYTIME:
|
||||
sc.MustGetString ();
|
||||
ScriptTemp.Push(MakeCommand(SS_CMD_PLAY, S_FindSound (sc.String)));
|
||||
ScriptTemp.Push(MakeCommand(SS_CMD_PLAY, S_FindSound (sc.String).index()));
|
||||
sc.MustGetNumber ();
|
||||
ScriptTemp.Push(MakeCommand(SS_CMD_DELAY, sc.Number));
|
||||
break;
|
||||
|
||||
case SS_STRING_PLAYREPEAT:
|
||||
sc.MustGetString ();
|
||||
ScriptTemp.Push(MakeCommand (SS_CMD_PLAYREPEAT, S_FindSound (sc.String)));
|
||||
ScriptTemp.Push(MakeCommand (SS_CMD_PLAYREPEAT, S_FindSound (sc.String).index()));
|
||||
break;
|
||||
|
||||
case SS_STRING_PLAYLOOP:
|
||||
sc.MustGetString ();
|
||||
ScriptTemp.Push(MakeCommand (SS_CMD_PLAYLOOP, S_FindSound (sc.String)));
|
||||
ScriptTemp.Push(MakeCommand (SS_CMD_PLAYLOOP, S_FindSound (sc.String).index()));
|
||||
sc.MustGetNumber ();
|
||||
ScriptTemp.Push(sc.Number);
|
||||
break;
|
||||
|
@ -733,7 +733,7 @@ void S_ParseSndSeq (int levellump)
|
|||
break;
|
||||
|
||||
case SS_STRING_NOSTOPCUTOFF:
|
||||
stopsound = -1;
|
||||
stopsound = INVALID_SOUND;
|
||||
ScriptTemp.Push(MakeCommand(SS_CMD_STOPSOUND, 0));
|
||||
break;
|
||||
|
||||
|
@ -759,7 +759,7 @@ void S_ParseSndSeq (int levellump)
|
|||
break;
|
||||
|
||||
case SS_STRING_END:
|
||||
AddSequence (curseq, seqname, slot, stopsound, ScriptTemp);
|
||||
AddSequence (curseq, seqname, slot, stopsound.index(), ScriptTemp);
|
||||
curseq = -1;
|
||||
break;
|
||||
|
||||
|
@ -1127,27 +1127,27 @@ void SN_DoStop (FLevelLocals *Level, void *source)
|
|||
|
||||
void DSeqActorNode::OnDestroy ()
|
||||
{
|
||||
if (m_StopSound >= 0)
|
||||
if (m_StopSound != INVALID_SOUND)
|
||||
S_StopSound (m_Actor, CHAN_BODY);
|
||||
if (m_StopSound >= 1)
|
||||
if (m_StopSound.isvalid())
|
||||
MakeSound (0, m_StopSound);
|
||||
Super::OnDestroy();
|
||||
}
|
||||
|
||||
void DSeqSectorNode::OnDestroy ()
|
||||
{
|
||||
if (m_StopSound >= 0)
|
||||
if (m_StopSound != INVALID_SOUND)
|
||||
S_StopSound (m_Sector, Channel & 7);
|
||||
if (m_StopSound >= 1)
|
||||
if (m_StopSound.isvalid())
|
||||
MakeSound (0, m_StopSound);
|
||||
Super::OnDestroy();
|
||||
}
|
||||
|
||||
void DSeqPolyNode::OnDestroy ()
|
||||
{
|
||||
if (m_StopSound >= 0)
|
||||
if (m_StopSound != INVALID_SOUND)
|
||||
S_StopSound (m_Poly, CHAN_BODY);
|
||||
if (m_StopSound >= 1)
|
||||
if (m_StopSound.isvalid())
|
||||
MakeSound (0, m_StopSound);
|
||||
Super::OnDestroy();
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ protected:
|
|||
int m_Sequence;
|
||||
|
||||
FSoundID m_CurrentSoundID;
|
||||
int m_StopSound;
|
||||
FSoundID m_StopSound;
|
||||
int m_DelayTics;
|
||||
float m_Volume;
|
||||
float m_Atten;
|
||||
|
|
|
@ -70,11 +70,11 @@ bool S_AreSoundsEquivalent (AActor *actor, FSoundID id1, FSoundID id2);
|
|||
FSoundID S_LookupPlayerSound (const char *playerclass, int gender, FSoundID refid);
|
||||
const char *S_GetSoundClass(AActor *pp);
|
||||
FSoundID S_FindSkinnedSound (AActor *actor, FSoundID refid);
|
||||
int S_FindSkinnedSoundEx (AActor *actor, const char *logicalname, const char *extendedname);
|
||||
FSoundID S_FindSkinnedSoundEx (AActor *actor, const char *logicalname, const char *extendedname);
|
||||
FSoundID S_AddSound (const char *logicalname, const char *lumpname, FScanner *sc=NULL); // Add sound by lumpname
|
||||
int S_AddPlayerSound (const char *playerclass, const int gender, FSoundID refid, const char *lumpname);
|
||||
int S_AddPlayerSound (const char *playerclass, const int gender, FSoundID refid, int lumpnum, bool fromskin=false);
|
||||
int S_AddPlayerSoundExisting (const char *playerclass, const int gender, FSoundID refid, FSoundID aliasto, bool fromskin=false);
|
||||
FSoundID S_AddPlayerSound (const char *playerclass, const int gender, FSoundID refid, const char *lumpname);
|
||||
FSoundID S_AddPlayerSound (const char *playerclass, const int gender, FSoundID refid, int lumpnum, bool fromskin=false);
|
||||
FSoundID S_AddPlayerSoundExisting (const char *playerclass, const int gender, FSoundID refid, FSoundID aliasto, bool fromskin=false);
|
||||
void S_MarkPlayerSounds (AActor *player);
|
||||
void S_ShrinkPlayerSoundLists ();
|
||||
unsigned int S_GetMSLength(FSoundID sound);
|
||||
|
|
Loading…
Reference in a new issue