mirror of https://github.com/ZDoom/gzdoom.git
- handle all remaining places of sound ID conversions after removing the conversion operators.
This commit is contained in:
parent
160633a4a2
commit
d173c0453c
|
@ -385,7 +385,7 @@ FSoundChan *SoundEngine::StartSound(int type, const void *source,
|
||||||
sfxinfo_t *sfx;
|
sfxinfo_t *sfx;
|
||||||
EChanFlags chanflags = flags;
|
EChanFlags chanflags = flags;
|
||||||
int basepriority;
|
int basepriority;
|
||||||
int org_id;
|
FSoundID org_id;
|
||||||
int pitch;
|
int pitch;
|
||||||
FSoundChan *chan;
|
FSoundChan *chan;
|
||||||
FVector3 pos, vel;
|
FVector3 pos, vel;
|
||||||
|
@ -397,7 +397,7 @@ FSoundChan *SoundEngine::StartSound(int type, const void *source,
|
||||||
// prevent crashes.
|
// prevent crashes.
|
||||||
if (type == SOURCE_Unattached && pt == nullptr) type = SOURCE_None;
|
if (type == SOURCE_Unattached && pt == nullptr) type = SOURCE_None;
|
||||||
|
|
||||||
org_id = sound_id.index();
|
org_id = sound_id;
|
||||||
|
|
||||||
CalcPosVel(type, source, &pt->X, channel, chanflags, sound_id, &pos, &vel, nullptr);
|
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;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
sfx = &S_sfx[org_id];
|
sfx = &S_sfx[sound_id.index()];
|
||||||
|
|
||||||
// Scale volume according to SNDINFO data.
|
// Scale volume according to SNDINFO data.
|
||||||
volume = min(volume * sfx->Volume, 1.f);
|
volume = min(volume * sfx->Volume, 1.f);
|
||||||
|
@ -595,7 +595,7 @@ FSoundChan *SoundEngine::StartSound(int type, const void *source,
|
||||||
if (chan != NULL)
|
if (chan != NULL)
|
||||||
{
|
{
|
||||||
chan->SoundID = sound_id;
|
chan->SoundID = sound_id;
|
||||||
chan->OrgID = FSoundID(org_id);
|
chan->OrgID = org_id;
|
||||||
chan->EntChannel = channel;
|
chan->EntChannel = channel;
|
||||||
chan->Volume = float(volume);
|
chan->Volume = float(volume);
|
||||||
chan->ChanFlags |= chanflags;
|
chan->ChanFlags |= chanflags;
|
||||||
|
@ -1485,7 +1485,7 @@ int SoundEngine::GetSoundIndex(const char* logicalname)
|
||||||
FSoundID SoundEngine::FindSoundByResID(int resid)
|
FSoundID SoundEngine::FindSoundByResID(int resid)
|
||||||
{
|
{
|
||||||
auto p = ResIdMap.CheckKey(resid);
|
auto p = ResIdMap.CheckKey(resid);
|
||||||
return p ? *p : 0;
|
return p ? *p : NO_SOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
@ -1504,10 +1504,10 @@ FSoundID SoundEngine::FindSoundNoHash(const char* logicalname)
|
||||||
{
|
{
|
||||||
if (stricmp(S_sfx[i].name, logicalname) == 0)
|
if (stricmp(S_sfx[i].name, logicalname) == 0)
|
||||||
{
|
{
|
||||||
return i;
|
return FSoundID::fromInt(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return NO_SOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
@ -1525,9 +1525,9 @@ FSoundID SoundEngine::FindSoundByLump(int lump)
|
||||||
|
|
||||||
for (i = 1; i < S_sfx.Size(); i++)
|
for (i = 1; i < S_sfx.Size(); i++)
|
||||||
if (S_sfx[i].lumpnum == lump)
|
if (S_sfx[i].lumpnum == lump)
|
||||||
return i;
|
return FSoundID::fromInt(i);
|
||||||
}
|
}
|
||||||
return 0;
|
return NO_SOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
@ -1549,9 +1549,10 @@ FSoundID SoundEngine::AddSoundLump(const char* logicalname, int lump, int Curren
|
||||||
newsfx.NearLimit = nearlimit;
|
newsfx.NearLimit = nearlimit;
|
||||||
newsfx.ResourceId = resid;
|
newsfx.ResourceId = resid;
|
||||||
newsfx.bTentative = false;
|
newsfx.bTentative = false;
|
||||||
|
auto id = FSoundID::fromInt(S_sfx.Size() - 1);
|
||||||
|
|
||||||
if (resid >= 0) ResIdMap[resid] = S_sfx.Size() - 1;
|
if (resid >= 0) ResIdMap[resid] = id;
|
||||||
return (int)S_sfx.Size()-1;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1736,8 +1737,8 @@ CCMD(cachesound)
|
||||||
}
|
}
|
||||||
for (int i = 1; i < argv.argc(); ++i)
|
for (int i = 1; i < argv.argc(); ++i)
|
||||||
{
|
{
|
||||||
FSoundID sfxnum = argv[i];
|
FSoundID sfxnum = S_FindSound(argv[i]);
|
||||||
if (sfxnum != FSoundID(0))
|
if (sfxnum != NO_SOUND)
|
||||||
{
|
{
|
||||||
soundEngine->CacheSound(sfxnum);
|
soundEngine->CacheSound(sfxnum);
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,9 +25,11 @@ class FSoundID
|
||||||
public:
|
public:
|
||||||
FSoundID() = default;
|
FSoundID() = default;
|
||||||
|
|
||||||
|
private:
|
||||||
constexpr FSoundID(int id) : ID(id)
|
constexpr FSoundID(int id) : ID(id)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
public:
|
||||||
static constexpr FSoundID fromInt(int i)
|
static constexpr FSoundID fromInt(int i)
|
||||||
{
|
{
|
||||||
return FSoundID(i);
|
return FSoundID(i);
|
||||||
|
@ -62,12 +64,6 @@ public:
|
||||||
}
|
}
|
||||||
bool operator ==(int other) const = delete;
|
bool operator ==(int other) const = delete;
|
||||||
bool operator !=(int other) const = delete;
|
bool operator !=(int other) const = delete;
|
||||||
/*
|
|
||||||
operator int() const
|
|
||||||
{
|
|
||||||
return ID;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
constexpr int index() const
|
constexpr int index() const
|
||||||
{
|
{
|
||||||
return ID;
|
return ID;
|
||||||
|
@ -82,10 +78,13 @@ private:
|
||||||
int ID;
|
int ID;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
constexpr FSoundID NO_SOUND = FSoundID::fromInt(0);
|
||||||
|
constexpr FSoundID INVALID_SOUND = FSoundID::fromInt(-1);
|
||||||
|
|
||||||
struct FRandomSoundList
|
struct FRandomSoundList
|
||||||
{
|
{
|
||||||
TArray<FSoundID> Choices;
|
TArray<FSoundID> Choices;
|
||||||
FSoundID Owner = 0;
|
FSoundID Owner = NO_SOUND;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -130,9 +129,6 @@ private:
|
||||||
float Attenuation = 1.f; // Multiplies the attenuation passed to S_Sound.
|
float Attenuation = 1.f; // Multiplies the attenuation passed to S_Sound.
|
||||||
};
|
};
|
||||||
|
|
||||||
constexpr FSoundID NO_SOUND = FSoundID::fromInt(0);
|
|
||||||
constexpr FSoundID INVALID_SOUND = FSoundID::fromInt(-1);
|
|
||||||
|
|
||||||
|
|
||||||
struct FSoundChan : public FISoundChannel
|
struct FSoundChan : public FISoundChannel
|
||||||
{
|
{
|
||||||
|
@ -215,7 +211,7 @@ protected:
|
||||||
TArray<sfxinfo_t> S_sfx;
|
TArray<sfxinfo_t> S_sfx;
|
||||||
FRolloffInfo S_Rolloff{};
|
FRolloffInfo S_Rolloff{};
|
||||||
TArray<uint8_t> S_SoundCurve;
|
TArray<uint8_t> S_SoundCurve;
|
||||||
TMap<int, int> ResIdMap;
|
TMap<int, FSoundID> ResIdMap;
|
||||||
TArray<FRandomSoundList> S_rnd;
|
TArray<FRandomSoundList> S_rnd;
|
||||||
bool blockNewSounds = false;
|
bool blockNewSounds = false;
|
||||||
|
|
||||||
|
|
|
@ -210,14 +210,14 @@ public:
|
||||||
{
|
{
|
||||||
if (animSnd[i] == curframe)
|
if (animSnd[i] == curframe)
|
||||||
{
|
{
|
||||||
int sound = animSnd[i+1];
|
auto sound = FSoundID::fromInt(animSnd[i+1]);
|
||||||
if (sound == -1)
|
if (sound == INVALID_SOUND)
|
||||||
soundEngine->StopAllChannels();
|
soundEngine->StopAllChannels();
|
||||||
else
|
else
|
||||||
soundEngine->StartSound(SOURCE_None, nullptr, nullptr, CHAN_AUTO, nostopsound? CHANF_UI : CHANF_NONE, sound, 1.f, ATTN_NONE);
|
soundEngine->StartSound(SOURCE_None, nullptr, nullptr, CHAN_AUTO, nostopsound? CHANF_UI : CHANF_NONE, sound, 1.f, ATTN_NONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!nostopsound && curframe == numframes && soundEngine->GetSoundPlayingInfo(SOURCE_None, nullptr, -1)) return true;
|
if (!nostopsound && curframe == numframes && soundEngine->GetSoundPlayingInfo(SOURCE_None, nullptr, INVALID_SOUND)) return true;
|
||||||
curframe++;
|
curframe++;
|
||||||
return curframe < numframes;
|
return curframe < numframes;
|
||||||
}
|
}
|
||||||
|
@ -586,8 +586,8 @@ public:
|
||||||
{
|
{
|
||||||
if (animSnd[i] == soundframe)
|
if (animSnd[i] == soundframe)
|
||||||
{
|
{
|
||||||
int sound = animSnd[i + 1];
|
auto sound = FSoundID::fromInt(animSnd[i + 1]);
|
||||||
if (sound == -1)
|
if (sound == INVALID_SOUND)
|
||||||
soundEngine->StopAllChannels();
|
soundEngine->StopAllChannels();
|
||||||
else
|
else
|
||||||
soundEngine->StartSound(SOURCE_None, nullptr, nullptr, CHAN_AUTO, nostopsound ? CHANF_UI : CHANF_NONE, sound, 1.f, ATTN_NONE);
|
soundEngine->StartSound(SOURCE_None, nullptr, nullptr, CHAN_AUTO, nostopsound ? CHANF_UI : CHANF_NONE, sound, 1.f, ATTN_NONE);
|
||||||
|
@ -790,8 +790,8 @@ public:
|
||||||
{
|
{
|
||||||
if (animSnd[i] == nFrame)
|
if (animSnd[i] == nFrame)
|
||||||
{
|
{
|
||||||
int sound = animSnd[i + 1];
|
auto sound = FSoundID::fromInt(animSnd[i + 1]);
|
||||||
if (sound == -1)
|
if (sound == INVALID_SOUND)
|
||||||
soundEngine->StopAllChannels();
|
soundEngine->StopAllChannels();
|
||||||
else
|
else
|
||||||
soundEngine->StartSound(SOURCE_None, nullptr, nullptr, CHAN_AUTO, nostopsound ? CHANF_UI : CHANF_NONE, sound, 1.f, ATTN_NONE);
|
soundEngine->StartSound(SOURCE_None, nullptr, nullptr, CHAN_AUTO, nostopsound ? CHANF_UI : CHANF_NONE, sound, 1.f, ATTN_NONE);
|
||||||
|
|
|
@ -1334,7 +1334,7 @@ FSerializer &Serialize(FSerializer &arc, const char *key, FSoundID &sid, FSoundI
|
||||||
//If sound name here is not reliable, we need to save by index instead.
|
//If sound name here is not reliable, we need to save by index instead.
|
||||||
int id = sid.index();
|
int id = sid.index();
|
||||||
Serialize(arc, key, id, nullptr);
|
Serialize(arc, key, id, nullptr);
|
||||||
if (arc.isReading()) sid = FSoundID(id);
|
if (arc.isReading()) sid = FSoundID::fromInt(id);
|
||||||
}
|
}
|
||||||
else if (arc.isWriting())
|
else if (arc.isWriting())
|
||||||
{
|
{
|
||||||
|
|
|
@ -1299,7 +1299,7 @@ FxExpression *FxStringCast::Resolve(FCompileContext &ctx)
|
||||||
if (basex->isConstant())
|
if (basex->isConstant())
|
||||||
{
|
{
|
||||||
ExpVal constval = static_cast<FxConstant *>(basex)->GetValue();
|
ExpVal constval = static_cast<FxConstant *>(basex)->GetValue();
|
||||||
FxExpression *x = new FxConstant(soundEngine->GetSoundName(constval.GetInt()), ScriptPosition);
|
FxExpression *x = new FxConstant(soundEngine->GetSoundName(FSoundID::fromInt(constval.GetInt())), ScriptPosition);
|
||||||
delete this;
|
delete this;
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,7 +61,7 @@ static void CastN2S(FString *a, int b) { FName name = FName(ENamedName(b)); *a =
|
||||||
static int CastS2Co(FString *b) { return V_GetColor(*b); }
|
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 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 S_FindSound(*b).index(); }
|
static int CastS2So(FString *b) { return S_FindSound(*b).index(); }
|
||||||
static void CastSo2S(FString* a, int b) { *a = soundEngine->GetSoundName(b); }
|
static void CastSo2S(FString* a, int b) { *a = soundEngine->GetSoundName(FSoundID::fromInt(b)); }
|
||||||
static void CastSID2S(FString* a, unsigned int b) { VM_CastSpriteIDToString(a, 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(); }
|
static void CastTID2S(FString *a, int b) { auto tex = TexMan.GetGameTexture(*(FTextureID*)&b); *a = (tex == nullptr) ? "(null)" : tex->GetName().GetChars(); }
|
||||||
|
|
||||||
|
|
|
@ -539,7 +539,7 @@ bool AssertObject(void * ob);
|
||||||
#define PARAM_UINT_AT(p,x) assert((p) < numparam); assert(reginfo[p] == REGT_INT); unsigned x = param[p].i;
|
#define PARAM_UINT_AT(p,x) assert((p) < numparam); assert(reginfo[p] == REGT_INT); unsigned x = param[p].i;
|
||||||
#define PARAM_BOOL_AT(p,x) assert((p) < numparam); assert(reginfo[p] == REGT_INT); bool x = !!param[p].i;
|
#define PARAM_BOOL_AT(p,x) assert((p) < numparam); assert(reginfo[p] == REGT_INT); bool x = !!param[p].i;
|
||||||
#define PARAM_NAME_AT(p,x) assert((p) < numparam); assert(reginfo[p] == REGT_INT); FName x = ENamedName(param[p].i);
|
#define PARAM_NAME_AT(p,x) assert((p) < numparam); assert(reginfo[p] == REGT_INT); FName x = ENamedName(param[p].i);
|
||||||
#define PARAM_SOUND_AT(p,x) assert((p) < numparam); assert(reginfo[p] == REGT_INT); FSoundID x = param[p].i;
|
#define PARAM_SOUND_AT(p,x) assert((p) < numparam); assert(reginfo[p] == REGT_INT); FSoundID x = FSoundID::fromInt(param[p].i);
|
||||||
#define PARAM_COLOR_AT(p,x) assert((p) < numparam); assert(reginfo[p] == REGT_INT); PalEntry x = param[p].i;
|
#define PARAM_COLOR_AT(p,x) assert((p) < numparam); assert(reginfo[p] == REGT_INT); PalEntry x = param[p].i;
|
||||||
#define PARAM_FLOAT_AT(p,x) assert((p) < numparam); assert(reginfo[p] == REGT_FLOAT); double x = param[p].f;
|
#define PARAM_FLOAT_AT(p,x) assert((p) < numparam); assert(reginfo[p] == REGT_FLOAT); double x = param[p].f;
|
||||||
#define PARAM_ANGLE_AT(p,x) assert((p) < numparam); assert(reginfo[p] == REGT_FLOAT); DAngle x = DAngle::fromDeg(param[p].f);
|
#define PARAM_ANGLE_AT(p,x) assert((p) < numparam); assert(reginfo[p] == REGT_FLOAT); DAngle x = DAngle::fromDeg(param[p].f);
|
||||||
|
|
|
@ -2127,7 +2127,7 @@ static void DoCast(const VMRegisters ®, const VMFrame *f, int a, int b, int c
|
||||||
|
|
||||||
case CAST_So2S:
|
case CAST_So2S:
|
||||||
ASSERTS(a); ASSERTD(b);
|
ASSERTS(a); ASSERTD(b);
|
||||||
reg.s[a] = soundEngine->GetSoundName(reg.d[b]);
|
reg.s[a] = soundEngine->GetSoundName(FSoundID::fromInt(reg.d[b]));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CAST_SID2S:
|
case CAST_SID2S:
|
||||||
|
|
|
@ -1386,7 +1386,7 @@ static int PatchThing (int thingy)
|
||||||
}
|
}
|
||||||
else if (stricmp (Line1 + linelen - 6, " sound") == 0)
|
else if (stricmp (Line1 + linelen - 6, " sound") == 0)
|
||||||
{
|
{
|
||||||
FSoundID snd = 0;
|
FSoundID snd = NO_SOUND;
|
||||||
|
|
||||||
if (val == 0 || val >= SoundMap.Size())
|
if (val == 0 || val >= SoundMap.Size())
|
||||||
{
|
{
|
||||||
|
|
|
@ -229,7 +229,7 @@ FSwitchDef *FTextureAnimator::ParseSwitchDef (FScanner &sc, bool ignoreBad)
|
||||||
FSwitchDef::frame thisframe;
|
FSwitchDef::frame thisframe;
|
||||||
FTextureID picnum;
|
FTextureID picnum;
|
||||||
bool bad;
|
bool bad;
|
||||||
FSoundID sound = 0;
|
FSoundID sound = NO_SOUND;
|
||||||
|
|
||||||
bad = false;
|
bad = false;
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ struct FStrifeDialogueNode
|
||||||
|
|
||||||
PClassActor *SpeakerType = nullptr;
|
PClassActor *SpeakerType = nullptr;
|
||||||
FString SpeakerName;
|
FString SpeakerName;
|
||||||
FSoundID SpeakerVoice = 0;
|
FSoundID SpeakerVoice = NO_SOUND;
|
||||||
FString Backdrop;
|
FString Backdrop;
|
||||||
FString Dialogue;
|
FString Dialogue;
|
||||||
FString Goodbye; // must init to null for binary scripts to work as intended
|
FString Goodbye; // must init to null for binary scripts to work as intended
|
||||||
|
|
|
@ -4673,7 +4673,7 @@ static FSoundID GetActorSound(AActor *actor, int soundtype)
|
||||||
case SOUND_CrushPain: return actor->CrushPainSound;
|
case SOUND_CrushPain: return actor->CrushPainSound;
|
||||||
case SOUND_Howl: return actor->SoundVar(NAME_HowlSound);
|
case SOUND_Howl: return actor->SoundVar(NAME_HowlSound);
|
||||||
case SOUND_Push: return actor->SoundVar(NAME_PushSound);
|
case SOUND_Push: return actor->SoundVar(NAME_PushSound);
|
||||||
default: return 0;
|
default: return NO_SOUND;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5292,7 +5292,7 @@ int DLevelScript::SwapActorTeleFog(AActor *activator, int tid)
|
||||||
}
|
}
|
||||||
else if (rettype == TypeSound)
|
else if (rettype == TypeSound)
|
||||||
{
|
{
|
||||||
retval = GlobalACSStrings.AddString(S_GetSoundName(FSoundID(retval)));
|
retval = GlobalACSStrings.AddString(S_GetSoundName(FSoundID::fromInt(retval)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (rettype == TypeFloat64)
|
else if (rettype == TypeFloat64)
|
||||||
|
@ -5903,7 +5903,7 @@ int DLevelScript::CallFunction(int argCount, int funcIndex, int32_t *args)
|
||||||
case ACSF_PlayActorSound:
|
case ACSF_PlayActorSound:
|
||||||
// PlaySound(tid, "SoundName", channel, volume, looping, attenuation, local)
|
// PlaySound(tid, "SoundName", channel, volume, looping, attenuation, local)
|
||||||
{
|
{
|
||||||
FSoundID sid = 0;
|
FSoundID sid = NO_SOUND;
|
||||||
|
|
||||||
if (funcIndex == ACSF_PlaySound)
|
if (funcIndex == ACSF_PlaySound)
|
||||||
{
|
{
|
||||||
|
@ -6732,7 +6732,7 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound)
|
||||||
if (activator != nullptr && activator->player != nullptr)
|
if (activator != nullptr && activator->player != nullptr)
|
||||||
{
|
{
|
||||||
int logNum = args[0];
|
int logNum = args[0];
|
||||||
FSoundID sid = 0;
|
FSoundID sid = NO_SOUND;
|
||||||
|
|
||||||
const char* lookup = Level->Behaviors.LookupString(args[1]);
|
const char* lookup = Level->Behaviors.LookupString(args[1]);
|
||||||
if (lookup != nullptr)
|
if (lookup != nullptr)
|
||||||
|
|
|
@ -2735,7 +2735,7 @@ bool P_CanResurrect(AActor *raiser, AActor *thing)
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
bool P_CheckForResurrection(AActor* self, bool usevilestates, FState* state = nullptr, FSoundID sound = 0)
|
bool P_CheckForResurrection(AActor* self, bool usevilestates, FState* state = nullptr, FSoundID sound = NO_SOUND)
|
||||||
{
|
{
|
||||||
const AActor *info;
|
const AActor *info;
|
||||||
AActor *temp;
|
AActor *temp;
|
||||||
|
@ -3114,7 +3114,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_Pain)
|
||||||
if (self->player && self->player->morphTics == 0)
|
if (self->player && self->player->morphTics == 0)
|
||||||
{
|
{
|
||||||
const char *pain_amount;
|
const char *pain_amount;
|
||||||
FSoundID sfx_id = 0;
|
FSoundID sfx_id = NO_SOUND;
|
||||||
|
|
||||||
if (self->health < 25)
|
if (self->health < 25)
|
||||||
pain_amount = "*pain25";
|
pain_amount = "*pain25";
|
||||||
|
|
|
@ -3299,7 +3299,7 @@ void AActor::AlterWeaponSprite(visstyle_t *vis)
|
||||||
|
|
||||||
void AActor::PlayActiveSound ()
|
void AActor::PlayActiveSound ()
|
||||||
{
|
{
|
||||||
if (ActiveSound.isvalid() && !S_IsActorPlayingSomething(this, CHAN_VOICE, -1))
|
if (ActiveSound.isvalid() && !S_IsActorPlayingSomething(this, CHAN_VOICE))
|
||||||
{
|
{
|
||||||
S_Sound (this, CHAN_VOICE, 0, ActiveSound, 1,
|
S_Sound (this, CHAN_VOICE, 0, ActiveSound, 1,
|
||||||
(flags3 & MF3_FULLVOLACTIVE) ? ATTN_NONE : ATTN_IDLE);
|
(flags3 & MF3_FULLVOLACTIVE) ? ATTN_NONE : ATTN_IDLE);
|
||||||
|
|
|
@ -887,7 +887,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_PlayerScream)
|
||||||
{
|
{
|
||||||
PARAM_SELF_PROLOGUE(AActor);
|
PARAM_SELF_PROLOGUE(AActor);
|
||||||
|
|
||||||
FSoundID sound = 0;
|
FSoundID sound = NO_SOUND;
|
||||||
int chan = CHAN_VOICE;
|
int chan = CHAN_VOICE;
|
||||||
|
|
||||||
if (self->player == NULL || self->DeathSound != NO_SOUND)
|
if (self->player == NULL || self->DeathSound != NO_SOUND)
|
||||||
|
|
|
@ -59,7 +59,7 @@
|
||||||
DVector2 AM_GetPosition();
|
DVector2 AM_GetPosition();
|
||||||
int Net_GetLatency(int *ld, int *ad);
|
int Net_GetLatency(int *ld, int *ad);
|
||||||
void PrintPickupMessage(bool localview, const FString &str);
|
void PrintPickupMessage(bool localview, const FString &str);
|
||||||
bool P_CheckForResurrection(AActor* self, bool usevilestates, FState* state = nullptr, FSoundID sound = 0);
|
bool P_CheckForResurrection(AActor* self, bool usevilestates, FState* state = nullptr, FSoundID sound = NO_SOUND);
|
||||||
|
|
||||||
// FCheckPosition requires explicit construction and destruction when used in the VM
|
// FCheckPosition requires explicit construction and destruction when used in the VM
|
||||||
|
|
||||||
|
@ -201,7 +201,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(AActor, A_StartSound, A_StartSound)
|
||||||
|
|
||||||
void A_StartSoundIfNotSame(AActor *self, int soundid, int checksoundid, int channel, int flags, double volume, double attenuation, double pitch, double startTime)
|
void A_StartSoundIfNotSame(AActor *self, int soundid, int checksoundid, int channel, int flags, double volume, double attenuation, double pitch, double startTime)
|
||||||
{
|
{
|
||||||
if (!S_AreSoundsEquivalent (self, soundid, checksoundid))
|
if (!S_AreSoundsEquivalent (self, FSoundID::fromInt(soundid), FSoundID::fromInt(checksoundid)))
|
||||||
A_StartSound(self, soundid, channel, flags, volume, attenuation, pitch, startTime);
|
A_StartSound(self, soundid, channel, flags, volume, attenuation, pitch, startTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1621,7 +1621,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(AActor, A_ExtChase, A_ExtChase)
|
||||||
|
|
||||||
int CheckForResurrection(AActor *self, FState* state, int sound)
|
int CheckForResurrection(AActor *self, FState* state, int sound)
|
||||||
{
|
{
|
||||||
return P_CheckForResurrection(self, false, state, sound);
|
return P_CheckForResurrection(self, false, state, FSoundID::fromInt(sound));
|
||||||
}
|
}
|
||||||
|
|
||||||
DEFINE_ACTION_FUNCTION_NATIVE(AActor, A_CheckForResurrection, CheckForResurrection)
|
DEFINE_ACTION_FUNCTION_NATIVE(AActor, A_CheckForResurrection, CheckForResurrection)
|
||||||
|
@ -1629,7 +1629,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(AActor, A_CheckForResurrection, CheckForResurrecti
|
||||||
PARAM_SELF_PROLOGUE(AActor);
|
PARAM_SELF_PROLOGUE(AActor);
|
||||||
PARAM_STATE(state);
|
PARAM_STATE(state);
|
||||||
PARAM_INT(sound);
|
PARAM_INT(sound);
|
||||||
ACTION_RETURN_BOOL(P_CheckForResurrection(self, false, state, sound));
|
ACTION_RETURN_BOOL(CheckForResurrection(self, state, sound));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ZS_Face(AActor *self, AActor *faceto, double max_turn, double max_pitch, double ang_offset, double pitch_offset, int flags, double z_add)
|
static void ZS_Face(AActor *self, AActor *faceto, double max_turn, double max_pitch, double ang_offset, double pitch_offset, int flags, double z_add)
|
||||||
|
|
|
@ -80,7 +80,7 @@ public:
|
||||||
FSoundID LookupSound(FSoundID player_sound_id)
|
FSoundID LookupSound(FSoundID player_sound_id)
|
||||||
{
|
{
|
||||||
auto v = map.CheckKey(player_sound_id.index());
|
auto v = map.CheckKey(player_sound_id.index());
|
||||||
return v ? *v : FSoundID(0);
|
return v ? *v : NO_SOUND;
|
||||||
}
|
}
|
||||||
void MarkUsed()
|
void MarkUsed()
|
||||||
{
|
{
|
||||||
|
@ -327,14 +327,14 @@ void S_CheckIntegrity()
|
||||||
memset(&broken[0], 0, sizeof(bool) * soundEngine->GetNumSounds());
|
memset(&broken[0], 0, sizeof(bool) * soundEngine->GetNumSounds());
|
||||||
for (unsigned i = 0; i < soundEngine->GetNumSounds(); i++)
|
for (unsigned i = 0; i < soundEngine->GetNumSounds(); i++)
|
||||||
{
|
{
|
||||||
auto &sfx = *soundEngine->GetWritableSfx(i);
|
auto &sfx = *soundEngine->GetWritableSfx(FSoundID::fromInt(i));
|
||||||
broken[i] = !S_CheckSound(&sfx, &sfx, chain);
|
broken[i] = !S_CheckSound(&sfx, &sfx, chain);
|
||||||
}
|
}
|
||||||
for (unsigned i = 0; i < soundEngine->GetNumSounds(); i++)
|
for (unsigned i = 0; i < soundEngine->GetNumSounds(); i++)
|
||||||
{
|
{
|
||||||
if (broken[i])
|
if (broken[i])
|
||||||
{
|
{
|
||||||
auto& sfx = *soundEngine->GetWritableSfx(i);
|
auto& sfx = *soundEngine->GetWritableSfx(FSoundID::fromInt(i));
|
||||||
Printf(TEXTCOLOR_RED "Sound %s has been disabled\n", sfx.name.GetChars());
|
Printf(TEXTCOLOR_RED "Sound %s has been disabled\n", sfx.name.GetChars());
|
||||||
sfx.bRandomHeader = false;
|
sfx.bRandomHeader = false;
|
||||||
sfx.link = 0; // link to the empty sound.
|
sfx.link = 0; // link to the empty sound.
|
||||||
|
@ -486,7 +486,7 @@ FSoundID S_AddPlayerSound (const char *pclass, int gender, FSoundID refid, int l
|
||||||
FSoundID id;
|
FSoundID id;
|
||||||
|
|
||||||
auto sfx = soundEngine->GetSfx(refid);
|
auto sfx = soundEngine->GetSfx(refid);
|
||||||
if (refid == NO_SOUND || !sfx) return 0;
|
if (refid == NO_SOUND || !sfx) return NO_SOUND;
|
||||||
|
|
||||||
fakename = pclass;
|
fakename = pclass;
|
||||||
fakename += '"';
|
fakename += '"';
|
||||||
|
@ -517,7 +517,7 @@ FSoundID S_AddPlayerSoundExisting (const char *pclass, int gender, FSoundID refi
|
||||||
int classnum = S_AddPlayerClass (pclass);
|
int classnum = S_AddPlayerClass (pclass);
|
||||||
int soundlist = S_AddPlayerGender (classnum, gender);
|
int soundlist = S_AddPlayerGender (classnum, gender);
|
||||||
auto sfx = soundEngine->GetSfx(refid);
|
auto sfx = soundEngine->GetSfx(refid);
|
||||||
if (refid == NO_SOUND || !sfx) return 0;
|
if (refid == NO_SOUND || !sfx) return NO_SOUND;
|
||||||
|
|
||||||
PlayerSounds[soundlist].AddSound (sfx->link, aliasto);
|
PlayerSounds[soundlist].AddSound (sfx->link, aliasto);
|
||||||
|
|
||||||
|
@ -1332,12 +1332,12 @@ static FSoundID S_LookupPlayerSound (int classidx, int gender, FSoundID refid)
|
||||||
{
|
{
|
||||||
return S_LookupPlayerSound (DefPlayerClass, gender, refid);
|
return S_LookupPlayerSound (DefPlayerClass, gender, refid);
|
||||||
}
|
}
|
||||||
return 0;
|
return NO_SOUND;
|
||||||
}
|
}
|
||||||
gender = g;
|
gender = g;
|
||||||
}
|
}
|
||||||
auto sfxp = soundEngine->GetWritableSfx(refid);
|
auto sfxp = soundEngine->GetWritableSfx(refid);
|
||||||
if (!sfxp) return 0;
|
if (!sfxp) return NO_SOUND;
|
||||||
|
|
||||||
FSoundID sndnum = PlayerSounds[listidx].LookupSound (sfxp->link);
|
FSoundID sndnum = PlayerSounds[listidx].LookupSound (sfxp->link);
|
||||||
sfxp = soundEngine->GetWritableSfx(sndnum);
|
sfxp = soundEngine->GetWritableSfx(sndnum);
|
||||||
|
@ -1562,7 +1562,7 @@ CCMD (soundlinks)
|
||||||
|
|
||||||
for (i = 0; i < soundEngine->GetNumSounds(); i++)
|
for (i = 0; i < soundEngine->GetNumSounds(); i++)
|
||||||
{
|
{
|
||||||
const sfxinfo_t* sfx = soundEngine->GetSfx(i);
|
const sfxinfo_t* sfx = soundEngine->GetSfx(FSoundID::fromInt(i));
|
||||||
|
|
||||||
if (sfx->link != sfxinfo_t::NO_LINK &&
|
if (sfx->link != sfxinfo_t::NO_LINK &&
|
||||||
!sfx->bRandomHeader &&
|
!sfx->bRandomHeader &&
|
||||||
|
@ -1589,7 +1589,7 @@ CCMD (playersounds)
|
||||||
memset (reserveNames, 0, sizeof(reserveNames));
|
memset (reserveNames, 0, sizeof(reserveNames));
|
||||||
for (i = j = 0; j < NumPlayerReserves && i < soundEngine->GetNumSounds(); ++i)
|
for (i = j = 0; j < NumPlayerReserves && i < soundEngine->GetNumSounds(); ++i)
|
||||||
{
|
{
|
||||||
auto sfx = soundEngine->GetSfx(i);
|
auto sfx = soundEngine->GetSfx(FSoundID::fromInt(i));
|
||||||
if (sfx->UserData[0] & SND_PlayerReserve)
|
if (sfx->UserData[0] & SND_PlayerReserve)
|
||||||
{
|
{
|
||||||
++j;
|
++j;
|
||||||
|
@ -1606,7 +1606,7 @@ CCMD (playersounds)
|
||||||
Printf ("\n%s, %s:\n", PlayerClassLookups[i].Name.GetChars(), GenderNames[j]);
|
Printf ("\n%s, %s:\n", PlayerClassLookups[i].Name.GetChars(), GenderNames[j]);
|
||||||
for (k = 0; k < NumPlayerReserves; ++k)
|
for (k = 0; k < NumPlayerReserves; ++k)
|
||||||
{
|
{
|
||||||
auto sndid = PlayerSounds[l].LookupSound(k);
|
auto sndid = PlayerSounds[l].LookupSound(FSoundID::fromInt(k));
|
||||||
auto sfx = soundEngine->GetSfx(sndid);
|
auto sfx = soundEngine->GetSfx(sndid);
|
||||||
Printf (" %-16s%s\n", reserveNames[k], sfx->name.GetChars());
|
Printf (" %-16s%s\n", reserveNames[k], sfx->name.GetChars());
|
||||||
}
|
}
|
||||||
|
@ -1691,7 +1691,7 @@ DEFINE_ACTION_FUNCTION(AAmbientSound, Tick)
|
||||||
loop = CHANF_LOOP;
|
loop = CHANF_LOOP;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ambient->sound != FSoundID(0))
|
if (ambient->sound != NO_SOUND)
|
||||||
{
|
{
|
||||||
// The second argument scales the ambient sound's volume.
|
// The second argument scales the ambient sound's volume.
|
||||||
// 0 and 100 are normal volume. The maximum volume level
|
// 0 and 100 are normal volume. The maximum volume level
|
||||||
|
|
|
@ -1339,7 +1339,7 @@ void DoomSoundEngine::PrintSoundList()
|
||||||
lumpname[8] = 0;
|
lumpname[8] = 0;
|
||||||
for (i = 0; i < soundEngine->GetNumSounds(); i++)
|
for (i = 0; i < soundEngine->GetNumSounds(); i++)
|
||||||
{
|
{
|
||||||
const sfxinfo_t* sfx = soundEngine->GetSfx(i);
|
const sfxinfo_t* sfx = soundEngine->GetSfx(FSoundID::fromInt(i));
|
||||||
if (sfx->bRandomHeader)
|
if (sfx->bRandomHeader)
|
||||||
{
|
{
|
||||||
Printf("%3d. %s -> #%d {", i, sfx->name.GetChars(), sfx->link);
|
Printf("%3d. %s -> #%d {", i, sfx->name.GetChars(), sfx->link);
|
||||||
|
|
|
@ -313,7 +313,7 @@ void DSeqNode::Serialize(FSerializer &arc)
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
FName seqName = NAME_None;
|
FName seqName = NAME_None;
|
||||||
int delayTics = 0;
|
int delayTics = 0;
|
||||||
FSoundID id = 0;
|
FSoundID id = NO_SOUND;
|
||||||
float volume;
|
float volume;
|
||||||
float atten = ATTN_NORM;
|
float atten = ATTN_NORM;
|
||||||
int seqnum;
|
int seqnum;
|
||||||
|
@ -796,13 +796,13 @@ static void AddSequence (int curseq, FName seqname, FName slot, int stopsound, c
|
||||||
Sequences[curseq] = (FSoundSequence *)M_Malloc (sizeof(FSoundSequence) + sizeof(uint32_t)*ScriptTemp.Size());
|
Sequences[curseq] = (FSoundSequence *)M_Malloc (sizeof(FSoundSequence) + sizeof(uint32_t)*ScriptTemp.Size());
|
||||||
Sequences[curseq]->SeqName = seqname;
|
Sequences[curseq]->SeqName = seqname;
|
||||||
Sequences[curseq]->Slot = slot;
|
Sequences[curseq]->Slot = slot;
|
||||||
Sequences[curseq]->StopSound = FSoundID(stopsound);
|
Sequences[curseq]->StopSound = FSoundID::fromInt(stopsound);
|
||||||
memcpy (Sequences[curseq]->Script, &ScriptTemp[0], sizeof(uint32_t)*ScriptTemp.Size());
|
memcpy (Sequences[curseq]->Script, &ScriptTemp[0], sizeof(uint32_t)*ScriptTemp.Size());
|
||||||
Sequences[curseq]->Script[ScriptTemp.Size()] = MakeCommand(SS_CMD_END, 0);
|
Sequences[curseq]->Script[ScriptTemp.Size()] = MakeCommand(SS_CMD_END, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
DSeqNode::DSeqNode (FLevelLocals *l, int sequence, int modenum)
|
DSeqNode::DSeqNode (FLevelLocals *l, int sequence, int modenum)
|
||||||
: m_CurrentSoundID(0), m_ModeNum(modenum), m_SequenceChoices(0)
|
: m_CurrentSoundID(NO_SOUND), m_ModeNum(modenum), m_SequenceChoices(0)
|
||||||
{
|
{
|
||||||
Level = l;
|
Level = l;
|
||||||
ActivateSequence (sequence);
|
ActivateSequence (sequence);
|
||||||
|
@ -1204,7 +1204,7 @@ void DSeqNode::Tick ()
|
||||||
case SS_CMD_PLAY:
|
case SS_CMD_PLAY:
|
||||||
if (!IsPlaying())
|
if (!IsPlaying())
|
||||||
{
|
{
|
||||||
m_CurrentSoundID = FSoundID(GetData(*m_SequencePtr));
|
m_CurrentSoundID = FSoundID::fromInt(GetData(*m_SequencePtr));
|
||||||
MakeSound (0, m_CurrentSoundID);
|
MakeSound (0, m_CurrentSoundID);
|
||||||
}
|
}
|
||||||
m_SequencePtr++;
|
m_SequencePtr++;
|
||||||
|
@ -1226,7 +1226,7 @@ void DSeqNode::Tick ()
|
||||||
if (!IsPlaying())
|
if (!IsPlaying())
|
||||||
{
|
{
|
||||||
// Does not advance sequencePtr, so it will repeat as necessary.
|
// Does not advance sequencePtr, so it will repeat as necessary.
|
||||||
m_CurrentSoundID = FSoundID(GetData(*m_SequencePtr));
|
m_CurrentSoundID = FSoundID::fromInt(GetData(*m_SequencePtr));
|
||||||
MakeSound (CHANF_LOOP, m_CurrentSoundID);
|
MakeSound (CHANF_LOOP, m_CurrentSoundID);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
@ -1234,7 +1234,7 @@ void DSeqNode::Tick ()
|
||||||
case SS_CMD_PLAYLOOP:
|
case SS_CMD_PLAYLOOP:
|
||||||
// Like SS_CMD_PLAYREPEAT, sequencePtr is not advanced, so this
|
// Like SS_CMD_PLAYREPEAT, sequencePtr is not advanced, so this
|
||||||
// command will repeat until the sequence is stopped.
|
// command will repeat until the sequence is stopped.
|
||||||
m_CurrentSoundID = FSoundID(GetData(m_SequencePtr[0]));
|
m_CurrentSoundID = FSoundID::fromInt(GetData(m_SequencePtr[0]));
|
||||||
MakeSound (0, m_CurrentSoundID);
|
MakeSound (0, m_CurrentSoundID);
|
||||||
m_DelayTics = m_SequencePtr[1];
|
m_DelayTics = m_SequencePtr[1];
|
||||||
return;
|
return;
|
||||||
|
@ -1444,7 +1444,7 @@ void SN_MarkPrecacheSounds(int sequence, seqtype_t type)
|
||||||
int cmd = GetCommand(seq->Script[i]);
|
int cmd = GetCommand(seq->Script[i]);
|
||||||
if (cmd == SS_CMD_PLAY || cmd == SS_CMD_PLAYREPEAT || cmd == SS_CMD_PLAYLOOP)
|
if (cmd == SS_CMD_PLAY || cmd == SS_CMD_PLAYREPEAT || cmd == SS_CMD_PLAYLOOP)
|
||||||
{
|
{
|
||||||
soundEngine->MarkUsed(GetData(seq->Script[i]));
|
soundEngine->MarkUsed(FSoundID::fromInt(GetData(seq->Script[i])));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1468,7 +1468,7 @@ DEFINE_ACTION_FUNCTION(DSeqNode, MarkPrecacheSounds)
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
void SN_ChangeNodeData (FLevelLocals *Level, int nodeNum, int seqOffset, int delayTics, float volume,
|
void SN_ChangeNodeData (FLevelLocals *Level, int nodeNum, int seqOffset, int delayTics, float volume,
|
||||||
int currentSoundID)
|
FSoundID currentSoundID)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
DSeqNode *node;
|
DSeqNode *node;
|
||||||
|
|
Loading…
Reference in New Issue