- use FSoundID in SoundEngine's interface.

This commit is contained in:
Christoph Oelckers 2022-11-24 14:30:19 +01:00
parent d13f12cc37
commit 1a6da52961
4 changed files with 30 additions and 29 deletions

View file

@ -867,7 +867,7 @@ bool SoundEngine::CheckSoundLimit(sfxinfo_t *sfx, const FVector3 &pos, int near_
//
//==========================================================================
void SoundEngine::StopSoundID(int sound_id)
void SoundEngine::StopSoundID(FSoundID sound_id)
{
FSoundChan* chan = Channels;
while (chan != NULL)
@ -889,7 +889,7 @@ void SoundEngine::StopSoundID(int sound_id)
//
//==========================================================================
void SoundEngine::StopSound (int channel, int sound_id)
void SoundEngine::StopSound (int channel, FSoundID sound_id)
{
FSoundChan *chan = Channels;
while (chan != NULL)
@ -911,7 +911,7 @@ void SoundEngine::StopSound (int channel, int sound_id)
//
//==========================================================================
void SoundEngine::StopSound(int sourcetype, const void* actor, int channel, int sound_id)
void SoundEngine::StopSound(int sourcetype, const void* actor, int channel, FSoundID sound_id)
{
FSoundChan* chan = Channels;
while (chan != NULL)
@ -1059,7 +1059,7 @@ void SoundEngine::SetVolume(FSoundChan* chan, float volume)
//
//==========================================================================
void SoundEngine::ChangeSoundPitch(int sourcetype, const void *source, int channel, double pitch, int sound_id)
void SoundEngine::ChangeSoundPitch(int sourcetype, const void *source, int channel, double pitch, FSoundID sound_id)
{
for (FSoundChan *chan = Channels; chan != NULL; chan = chan->NextChan)
{
@ -1087,7 +1087,7 @@ void SoundEngine::SetPitch(FSoundChan *chan, float pitch)
// Is a sound being played by a specific emitter?
//==========================================================================
int SoundEngine::GetSoundPlayingInfo (int sourcetype, const void *source, int sound_id, int chann)
int SoundEngine::GetSoundPlayingInfo (int sourcetype, const void *source, FSoundID sound_id, int chann)
{
int count = 0;
if (sound_id > 0)
@ -1153,7 +1153,7 @@ bool SoundEngine::IsChannelUsed(int sourcetype, const void *actor, int channel,
//
//==========================================================================
bool SoundEngine::IsSourcePlayingSomething (int sourcetype, const void *actor, int channel, int sound_id)
bool SoundEngine::IsSourcePlayingSomething (int sourcetype, const void *actor, int channel, FSoundID sound_id)
{
for (FSoundChan *chan = Channels; chan != NULL; chan = chan->NextChan)
{
@ -1463,7 +1463,7 @@ void SoundEngine::Reset()
// Given a logical name, find the sound's index in S_sfx.
//==========================================================================
int SoundEngine::FindSound(const char* logicalname)
FSoundID SoundEngine::FindSound(const char* logicalname)
{
int i;
@ -1482,7 +1482,7 @@ int SoundEngine::FindSound(const char* logicalname)
}
}
int SoundEngine::FindSoundByResID(int resid)
FSoundID SoundEngine::FindSoundByResID(int resid)
{
auto p = ResIdMap.CheckKey(resid);
return p ? *p : 0;
@ -1496,7 +1496,7 @@ int SoundEngine::FindSoundByResID(int resid)
// using the hash table.
//==========================================================================
int SoundEngine::FindSoundNoHash(const char* logicalname)
FSoundID SoundEngine::FindSoundNoHash(const char* logicalname)
{
unsigned int i;
@ -1517,7 +1517,7 @@ int SoundEngine::FindSoundNoHash(const char* logicalname)
// Given a sound lump, find the sound's index in S_sfx.
//==========================================================================
int SoundEngine::FindSoundByLump(int lump)
FSoundID SoundEngine::FindSoundByLump(int lump)
{
if (lump != -1)
{
@ -1537,7 +1537,7 @@ int SoundEngine::FindSoundByLump(int lump)
// Adds a new sound mapping to S_sfx.
//==========================================================================
int SoundEngine::AddSoundLump(const char* logicalname, int lump, int CurrentPitchMask, int resid, int nearlimit)
FSoundID SoundEngine::AddSoundLump(const char* logicalname, int lump, int CurrentPitchMask, int resid, int nearlimit)
{
S_sfx.Reserve(1);
sfxinfo_t &newsfx = S_sfx.Last();
@ -1566,7 +1566,7 @@ int SoundEngine::AddSoundLump(const char* logicalname, int lump, int CurrentPitc
int SoundEngine::FindSoundTentative(const char* name)
{
int id = FindSoundNoHash(name);
auto id = FindSoundNoHash(name);
if (id == 0)
{
id = AddSoundLump(name, -1, 0);

View file

@ -304,18 +304,18 @@ public:
const FVector3* pt, int channel, EChanFlags flags, FSoundID sound_id, float volume, float attenuation, FRolloffInfo* rolloff = nullptr, float spitch = 0.0f, float startTime = 0.0f);
// Stops an origin-less sound from playing from this channel.
void StopSoundID(int sound_id);
void StopSound(int channel, int sound_id = -1);
void StopSound(int sourcetype, const void* actor, int channel, int sound_id = -1);
void StopSoundID(FSoundID sound_id);
void StopSound(int channel, FSoundID sound_id = INVALID_SOUND);
void StopSound(int sourcetype, const void* actor, int channel, FSoundID sound_id = INVALID_SOUND);
void StopActorSounds(int sourcetype, const void* actor, int chanmin, int chanmax);
void RelinkSound(int sourcetype, const void* from, const void* to, const FVector3* optpos);
void ChangeSoundVolume(int sourcetype, const void* source, int channel, double dvolume);
void ChangeSoundPitch(int sourcetype, const void* source, int channel, double pitch, int sound_id = -1);
bool IsSourcePlayingSomething(int sourcetype, const void* actor, int channel, int sound_id = -1);
void ChangeSoundPitch(int sourcetype, const void* source, int channel, double pitch, FSoundID sound_id = INVALID_SOUND);
bool IsSourcePlayingSomething(int sourcetype, const void* actor, int channel, FSoundID sound_id = INVALID_SOUND);
// Stop and resume music, during game PAUSE.
int GetSoundPlayingInfo(int sourcetype, const void* source, int sound_id, int chan = -1);
int GetSoundPlayingInfo(int sourcetype, const void* source, FSoundID sound_id, int chan = -1);
void UnloadAllSounds();
void Reset();
void MarkUsed(int num);
@ -372,8 +372,9 @@ public:
{
return S_sfx[snd].UserData.Data();
}
bool isValidSoundId(int id)
bool isValidSoundId(FSoundID sid)
{
int id = sid.index();
return id > 0 && id < (int)S_sfx.Size() && !S_sfx[id].bTentative && S_sfx[id].lumpnum != sfx_empty;
}
@ -404,11 +405,11 @@ public:
virtual void SoundDone(FISoundChannel* ichan); // gets called when the sound has been completely taken down.
// Lookup utilities.
int FindSound(const char* logicalname);
int FindSoundByResID(int rid);
int FindSoundNoHash(const char* logicalname);
int FindSoundByLump(int lump);
virtual int AddSoundLump(const char* logicalname, int lump, int CurrentPitchMask, int resid = -1, int nearlimit = 2);
FSoundID FindSound(const char* 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);
void CacheRandomSound(sfxinfo_t* sfx);
unsigned int GetMSLength(FSoundID sound);

View file

@ -455,7 +455,7 @@ static FSoundID S_AddSound (const char *logicalname, int lumpnum, FScanner *sc)
}
else
{ // Otherwise, create a new definition.
sfxid = FSoundID(soundEngine->AddSoundLump (logicalname, lumpnum, CurrentPitchMask));
sfxid = soundEngine->AddSoundLump (logicalname, lumpnum, CurrentPitchMask);
}
return sfxid;
@ -483,7 +483,7 @@ int S_AddPlayerSound (const char *pclass, int gender, FSoundID refid, const char
int S_AddPlayerSound (const char *pclass, int gender, FSoundID refid, int lumpnum, bool fromskin)
{
FString fakename;
int id;
FSoundID id;
auto sfx = soundEngine->GetSfx(refid);
if (refid == 0 || !sfx) return 0;

View file

@ -85,11 +85,11 @@ class DoomSoundEngine : public SoundEngine
FSoundID ResolveSound(const void *ent, int type, FSoundID soundid, float &attenuation) override;
void CacheSound(sfxinfo_t* sfx) override;
void StopChannel(FSoundChan* chan) override;
int AddSoundLump(const char* logicalname, int lump, int CurrentPitchMask, int resid = -1, int nearlimit = 2) override
FSoundID AddSoundLump(const char* logicalname, int lump, int CurrentPitchMask, int resid = -1, int nearlimit = 2) override
{
auto ndx = SoundEngine::AddSoundLump(logicalname, lump, CurrentPitchMask, resid, nearlimit);
S_sfx[ndx].UserData.Resize(1);
S_sfx[ndx].UserData[0] = 0;
S_sfx[ndx.index()].UserData.Resize(1);
S_sfx[ndx.index()].UserData[0] = 0;
return ndx;
}
bool CheckSoundLimit(sfxinfo_t* sfx, const FVector3& pos, int near_limit, float limit_range, int sourcetype, const void* actor, int channel, float attenuation) override