From 65a26d6779e31e464e063f3d018822e5d4e24866 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 24 Nov 2022 16:49:04 +0100 Subject: [PATCH] - removed the string constructors from FSoundID. Due to C++ conversion rules this was a bit too volatile. There's really not enough places where being able to pass a string directly into the sound API was beneficial - the two most frequent functions now got overloaded variants. --- src/common/audio/sound/s_sound.cpp | 6 +++--- src/common/audio/sound/s_soundinternal.h | 21 +-------------------- src/common/console/c_buttons.h | 6 ++++++ src/common/engine/serializer.cpp | 2 +- src/common/scripting/backend/codegen.cpp | 2 +- src/common/scripting/core/types.cpp | 2 +- src/gamedata/a_keys.cpp | 8 ++++---- src/gamedata/d_dehacked.cpp | 2 +- src/gamedata/g_mapinfo.cpp | 2 +- src/gamedata/p_terrain.cpp | 2 +- src/gamedata/textures/anim_switches.cpp | 2 +- src/intermission/intermission.cpp | 4 ++-- src/maploader/strifedialogue.cpp | 4 ++-- src/playsim/p_acs.cpp | 20 ++++++++++---------- src/playsim/p_effect.cpp | 2 +- src/playsim/p_enemy.cpp | 8 ++++---- src/playsim/p_lnspec.cpp | 7 ++++--- src/playsim/p_switch.cpp | 2 +- src/playsim/p_user.cpp | 4 ++-- src/r_data/sprites.cpp | 2 +- src/scripting/decorate/olddecorations.cpp | 6 +++--- src/scripting/decorate/thingdef_parse.cpp | 4 ++-- src/scripting/zscript/zcc_compile_doom.cpp | 2 +- src/sound/s_advsound.cpp | 4 ++-- src/sound/s_doomsound.cpp | 4 ++-- src/sound/s_doomsound.h | 8 ++++++++ 26 files changed, 66 insertions(+), 70 deletions(-) diff --git a/src/common/audio/sound/s_sound.cpp b/src/common/audio/sound/s_sound.cpp index c00d8e9eae..a9f12d8d27 100644 --- a/src/common/audio/sound/s_sound.cpp +++ b/src/common/audio/sound/s_sound.cpp @@ -1463,7 +1463,7 @@ void SoundEngine::Reset() // Given a logical name, find the sound's index in S_sfx. //========================================================================== -int SoundEngine::GetSoundIndex(const char* logicalname) +FSoundID SoundEngine::FindSound(const char* logicalname) { int i; @@ -1474,11 +1474,11 @@ int SoundEngine::GetSoundIndex(const char* logicalname) while ((i != 0) && stricmp(S_sfx[i].name, logicalname)) i = S_sfx[i].next; - return i; + return FSoundID::fromInt(i); } else { - return 0; + return NO_SOUND; } } diff --git a/src/common/audio/sound/s_soundinternal.h b/src/common/audio/sound/s_soundinternal.h index 7d446c9ff9..57a8372b2c 100644 --- a/src/common/audio/sound/s_soundinternal.h +++ b/src/common/audio/sound/s_soundinternal.h @@ -34,14 +34,6 @@ public: { return FSoundID(i); } - FSoundID(const char *name) - { - ID = GetSoundIndex(name); - } - FSoundID(const FString &name) - { - ID = GetSoundIndex(name.GetChars()); - } FSoundID(const FSoundID &other) = default; FSoundID &operator=(const FSoundID &other) = default; bool operator !=(FSoundID other) const @@ -63,7 +55,6 @@ public: return ID > 0; } private: - static inline int GetSoundIndex(const char* name); int ID; }; @@ -223,8 +214,6 @@ private: // Checks if a copy of this sound is already playing. bool CheckSingular(FSoundID sound_id); virtual TArray 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); @@ -398,10 +387,7 @@ public: virtual void SoundDone(FISoundChannel* ichan); // gets called when the sound has been completely taken down. // Lookup utilities. - inline FSoundID FindSound(const char* logicalname) - { - return FSoundID::fromInt(GetSoundIndex(logicalname)); - } + FSoundID FindSound(const char* logicalname); FSoundID FindSoundByResID(int rid); FSoundID FindSoundNoHash(const char* logicalname); FSoundID FindSoundByLump(int lump); @@ -436,9 +422,4 @@ inline FSoundID S_FindSound(const char* name) return soundEngine->FindSound(name); } -inline int FSoundID::GetSoundIndex(const char* name) -{ - return soundEngine->GetSoundIndex(name); -} - int SoundEnabled(); diff --git a/src/common/console/c_buttons.h b/src/common/console/c_buttons.h index 3567a85482..3bfbbd0fb0 100644 --- a/src/common/console/c_buttons.h +++ b/src/common/console/c_buttons.h @@ -72,6 +72,12 @@ public: return Buttons[x].bWentUp; } + void ButtonSet(int x) const + { + Buttons[x].bDown = Buttons[x].bWentDown = true; + Buttons[x].bWentUp = false; + } + void ClearButton(int x) { Buttons[x].Reset(); diff --git a/src/common/engine/serializer.cpp b/src/common/engine/serializer.cpp index 237865697d..808b0fedc3 100644 --- a/src/common/engine/serializer.cpp +++ b/src/common/engine/serializer.cpp @@ -1354,7 +1354,7 @@ FSerializer &Serialize(FSerializer &arc, const char *key, FSoundID &sid, FSoundI assert(val->IsString() || val->IsNull()); if (val->IsString()) { - sid = UnicodeToString(val->GetString()); + sid = S_FindSound(UnicodeToString(val->GetString())); } else if (val->IsNull()) { diff --git a/src/common/scripting/backend/codegen.cpp b/src/common/scripting/backend/codegen.cpp index f61a7345b9..c993ad0932 100644 --- a/src/common/scripting/backend/codegen.cpp +++ b/src/common/scripting/backend/codegen.cpp @@ -1475,7 +1475,7 @@ FxExpression *FxSoundCast::Resolve(FCompileContext &ctx) if (basex->isConstant()) { ExpVal constval = static_cast(basex)->GetValue(); - FxExpression *x = new FxConstant(FSoundID(constval.GetString()), ScriptPosition); + FxExpression *x = new FxConstant(S_FindSound(constval.GetString()), ScriptPosition); delete this; return x; } diff --git a/src/common/scripting/core/types.cpp b/src/common/scripting/core/types.cpp index f8387d10d2..376587d157 100644 --- a/src/common/scripting/core/types.cpp +++ b/src/common/scripting/core/types.cpp @@ -1351,7 +1351,7 @@ bool PSound::ReadValue(FSerializer &ar, const char *key, void *addr) const } else { - *(FSoundID *)addr = FSoundID(cptr); + *(FSoundID *)addr = S_FindSound(cptr); return true; } } diff --git a/src/gamedata/a_keys.cpp b/src/gamedata/a_keys.cpp index 2663d9c406..406b0fbb80 100644 --- a/src/gamedata/a_keys.cpp +++ b/src/gamedata/a_keys.cpp @@ -254,8 +254,8 @@ static void ParseLock(FScanner &sc, int ¤tnumber) auto lock = keynum == -1? &sink : &Locks.InsertNew(keynum); - lock->locksound.Push("*keytry"); - lock->locksound.Push("misc/keytry"); + lock->locksound.Push(S_FindSound("*keytry")); + lock->locksound.Push(S_FindSound("misc/keytry")); while (!sc.CheckString("}")) { @@ -298,7 +298,7 @@ static void ParseLock(FScanner &sc, int ¤tnumber) for (;;) { sc.MustGetString(); - lock->locksound.Push(sc.String); + lock->locksound.Push(S_FindSound(sc.String)); if (!sc.GetString()) { break; @@ -469,7 +469,7 @@ int P_CheckKeys (AActor *owner, int keynum, bool remote, bool quiet) // Just a safety precaution. The messages should have been initialized upon game start. if (!keysdone) P_InitKeyMessages(); - FSoundID failage[2] = { "*keytry", "misc/keytry" }; + FSoundID failage[2] = { S_FindSound("*keytry"), S_FindSound("misc/keytry") }; auto lock = Locks.CheckKey(keynum); if (!lock) diff --git a/src/gamedata/d_dehacked.cpp b/src/gamedata/d_dehacked.cpp index f0aca76559..5543a42df1 100644 --- a/src/gamedata/d_dehacked.cpp +++ b/src/gamedata/d_dehacked.cpp @@ -1394,7 +1394,7 @@ static int PatchThing (int thingy) { // Sound was not a (valid) number, // so treat it as an actual sound name. stripwhite (Line2); - snd = Line2; + snd = S_FindSound(Line2); } } else diff --git a/src/gamedata/g_mapinfo.cpp b/src/gamedata/g_mapinfo.cpp index b90b8e1a69..eb1e755763 100644 --- a/src/gamedata/g_mapinfo.cpp +++ b/src/gamedata/g_mapinfo.cpp @@ -1242,7 +1242,7 @@ DEFINE_MAP_OPTION(PrecacheSounds, true) do { parse.sc.MustGetString(); - FSoundID snd = parse.sc.String; + FSoundID snd = S_FindSound(parse.sc.String); if (snd == NO_SOUND) { parse.sc.ScriptMessage("Unknown sound \"%s\"", parse.sc.String); diff --git a/src/gamedata/p_terrain.cpp b/src/gamedata/p_terrain.cpp index 9619f579b9..4d0efcff98 100644 --- a/src/gamedata/p_terrain.cpp +++ b/src/gamedata/p_terrain.cpp @@ -537,7 +537,7 @@ static void GenericParse (FScanner &sc, FGenericParse *parser, const char **keyw case GEN_Sound: sc.MustGetString (); - SET_FIELD (FSoundID, FSoundID(sc.String)); + SET_FIELD (FSoundID, S_FindSound(sc.String)); /* unknown sounds never produce errors anywhere else so they shouldn't here either. if (val == 0) { diff --git a/src/gamedata/textures/anim_switches.cpp b/src/gamedata/textures/anim_switches.cpp index 8089648fe9..78e49508df 100644 --- a/src/gamedata/textures/anim_switches.cpp +++ b/src/gamedata/textures/anim_switches.cpp @@ -242,7 +242,7 @@ FSwitchDef *FTextureAnimator::ParseSwitchDef (FScanner &sc, bool ignoreBad) sc.ScriptError ("Switch state already has a sound"); } sc.MustGetString (); - sound = sc.String; + sound = S_FindSound(sc.String); } else if (sc.Compare ("pic")) { diff --git a/src/intermission/intermission.cpp b/src/intermission/intermission.cpp index 829ffc3d1a..fdcdd03253 100644 --- a/src/intermission/intermission.cpp +++ b/src/intermission/intermission.cpp @@ -503,7 +503,7 @@ void DIntermissionScreenCast::Init(FIntermissionAction *desc, bool first) { mCastSounds[i].mSequence = static_cast(desc)->mCastSounds[i].mSequence; mCastSounds[i].mIndex = static_cast(desc)->mCastSounds[i].mIndex; - mCastSounds[i].mSound = static_cast(desc)->mCastSounds[i].mSound; + mCastSounds[i].mSound = S_FindSound(static_cast(desc)->mCastSounds[i].mSound); } caststate = mDefaults->SeeState; if (mClass->IsDescendantOf(NAME_PlayerPawn)) @@ -551,7 +551,7 @@ int DIntermissionScreenCast::Responder (FInputEvent *ev) if (mClass->IsDescendantOf(NAME_PlayerPawn)) { - auto snd = S_FindSkinnedSound(players[consoleplayer].mo, "*death"); + auto snd = S_FindSkinnedSound(players[consoleplayer].mo, S_FindSound("*death")); if (snd != NO_SOUND) S_Sound (CHAN_VOICE, CHANF_UI, snd, 1, ATTN_NONE); } else if (mDefaults->DeathSound.isvalid()) diff --git a/src/maploader/strifedialogue.cpp b/src/maploader/strifedialogue.cpp index b09435dc27..cb2b2665bb 100644 --- a/src/maploader/strifedialogue.cpp +++ b/src/maploader/strifedialogue.cpp @@ -319,7 +319,7 @@ FStrifeDialogueNode *MapLoader::ReadRetailNode (const char *name, FileReader &lu // The speaker's voice for this node, if any. speech.Backdrop[0] = 0; //speech.Sound[8] = 0; mysnprintf (fullsound, countof(fullsound), "svox/%s", speech.Sound); - node->SpeakerVoice = fullsound; + node->SpeakerVoice = S_FindSound(fullsound); // The speaker's name, if any. speech.Sound[0] = 0; //speech.Name[16] = 0; @@ -415,7 +415,7 @@ FStrifeDialogueNode *MapLoader::ReadTeaserNode (const char *name, FileReader &lu if (speech.VoiceNumber != 0) { mysnprintf (fullsound, countof(fullsound), "svox/voc%u", speech.VoiceNumber); - node->SpeakerVoice = fullsound; + node->SpeakerVoice = S_FindSound(fullsound); } else { diff --git a/src/playsim/p_acs.cpp b/src/playsim/p_acs.cpp index 6636460d28..01def47586 100644 --- a/src/playsim/p_acs.cpp +++ b/src/playsim/p_acs.cpp @@ -4200,23 +4200,23 @@ void DLevelScript::DoSetActorProperty (AActor *actor, int property, int value) break; case APROP_SeeSound: - actor->SeeSound = Level->Behaviors.LookupString(value); + actor->SeeSound = S_FindSound(Level->Behaviors.LookupString(value)); break; case APROP_AttackSound: - actor->AttackSound = Level->Behaviors.LookupString(value); + actor->AttackSound = S_FindSound(Level->Behaviors.LookupString(value)); break; case APROP_PainSound: - actor->PainSound = Level->Behaviors.LookupString(value); + actor->PainSound = S_FindSound(Level->Behaviors.LookupString(value)); break; case APROP_DeathSound: - actor->DeathSound = Level->Behaviors.LookupString(value); + actor->DeathSound = S_FindSound(Level->Behaviors.LookupString(value)); break; case APROP_ActiveSound: - actor->ActiveSound = Level->Behaviors.LookupString(value); + actor->ActiveSound = S_FindSound(Level->Behaviors.LookupString(value)); break; case APROP_Species: @@ -5623,7 +5623,7 @@ int DLevelScript::CallFunction(int argCount, int funcIndex, int32_t *args) } case ACSF_Radius_Quake2: - P_StartQuake(Level, activator, args[0], args[1], args[2], args[3], args[4], Level->Behaviors.LookupString(args[5])); + P_StartQuake(Level, activator, args[0], args[1], args[2], args[3], args[4], S_FindSound(Level->Behaviors.LookupString(args[5]))); break; case ACSF_CheckActorClass: @@ -5910,7 +5910,7 @@ int DLevelScript::CallFunction(int argCount, int funcIndex, int32_t *args) const char *lookup = Level->Behaviors.LookupString(args[1]); if (lookup != NULL) { - sid = lookup; + sid = S_FindSound(lookup); } } if (sid != NO_SOUND || funcIndex == ACSF_PlayActorSound) @@ -6196,7 +6196,7 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound) case ACSF_QuakeEx: { - return P_StartQuakeXYZ(Level, activator, args[0], args[1], args[2], args[3], args[4], args[5], args[6], Level->Behaviors.LookupString(args[7]), + return P_StartQuakeXYZ(Level, activator, args[0], args[1], args[2], args[3], args[4], args[5], args[6], S_FindSound(Level->Behaviors.LookupString(args[7])), argCount > 8 ? args[8] : 0, argCount > 9 ? ACSToDouble(args[9]) : 1.0, argCount > 10 ? ACSToDouble(args[10]) : 1.0, @@ -6737,7 +6737,7 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound) const char* lookup = Level->Behaviors.LookupString(args[1]); if (lookup != nullptr) { - sid = lookup; + sid = S_FindSound(lookup); } activator->player->SetSubtitle(logNum, sid); @@ -8871,7 +8871,7 @@ scriptwait: S_Sound ( activationline->frontsector, CHAN_AUTO, 0, // Not CHAN_AREA, because that'd probably break existing scripts. - lookup, + S_FindSound(lookup), (float)(STACK(1)) / 127.f, ATTN_NORM); } diff --git a/src/playsim/p_effect.cpp b/src/playsim/p_effect.cpp index 073531ad90..72c6b56a9a 100644 --- a/src/playsim/p_effect.cpp +++ b/src/playsim/p_effect.cpp @@ -720,7 +720,7 @@ void P_DrawRailTrail(AActor *source, TArray &portalhits, int color1, if (!source->player) sound = source->AttackSound; else if (source->player->ReadyWeapon) sound = source->player->ReadyWeapon->AttackSound; else sound = NO_SOUND; - if (!sound.isvalid()) sound = "weapons/railgf"; + if (!sound.isvalid()) sound = S_FindSound("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. diff --git a/src/playsim/p_enemy.cpp b/src/playsim/p_enemy.cpp index cb8ede9fd4..7eea4cefb4 100644 --- a/src/playsim/p_enemy.cpp +++ b/src/playsim/p_enemy.cpp @@ -2836,7 +2836,7 @@ bool P_CheckForResurrection(AActor* self, bool usevilestates, FState* state = nu self->SetState(archvile->FindState(NAME_Heal)); } } - if (sound == NO_SOUND) sound = "vile/raise"; + if (sound == NO_SOUND) sound = S_FindSound("vile/raise"); S_Sound(corpsehit, CHAN_BODY, 0, sound, 1, ATTN_IDLE); info = corpsehit->GetDefault(); @@ -3131,18 +3131,18 @@ DEFINE_ACTION_FUNCTION(AActor, A_Pain) FString pain_sound = pain_amount; pain_sound += '-'; pain_sound += self->player->LastDamageType.GetChars(); - sfx_id = pain_sound; + sfx_id = S_FindSound(pain_sound); if (sfx_id == NO_SOUND) { // Try again without a specific pain amount. pain_sound = "*pain-"; pain_sound += self->player->LastDamageType.GetChars(); - sfx_id = pain_sound; + sfx_id = S_FindSound(pain_sound); } } if (sfx_id == NO_SOUND) { - sfx_id = pain_amount; + sfx_id = S_FindSound(pain_amount); } S_Sound (self, CHAN_VOICE, 0, sfx_id, 1, ATTN_NORM); diff --git a/src/playsim/p_lnspec.cpp b/src/playsim/p_lnspec.cpp index d73f18e5e3..6d3c23eccd 100644 --- a/src/playsim/p_lnspec.cpp +++ b/src/playsim/p_lnspec.cpp @@ -2161,7 +2161,7 @@ FUNC(LS_Light_Stop) FUNC(LS_Radius_Quake) // Radius_Quake (intensity, duration, damrad, tremrad, tid) { - return P_StartQuake (Level, it, arg4, arg0, arg1, arg2*64, arg3*64, "world/quake"); + return P_StartQuake (Level, it, arg4, arg0, arg1, arg2*64, arg3*64, S_FindSound("world/quake")); } FUNC(LS_UsePuzzleItem) @@ -3218,8 +3218,9 @@ FUNC(LS_SendToCommunicator) if (it->CheckLocalView()) { S_StopSound (CHAN_VOICE); - it->player->SetSubtitle(arg0, name); - S_Sound (CHAN_VOICE, 0, name, 1, ATTN_NORM); + auto snd = S_FindSound(name); + it->player->SetSubtitle(arg0, snd); + S_Sound (CHAN_VOICE, 0, snd, 1, ATTN_NORM); // Get the message from the LANGUAGE lump. FString msg; diff --git a/src/playsim/p_switch.cpp b/src/playsim/p_switch.cpp index 12a314bd4c..73aa95daac 100644 --- a/src/playsim/p_switch.cpp +++ b/src/playsim/p_switch.cpp @@ -404,7 +404,7 @@ void DActiveButton::Tick () { m_Frame = -1; S_Sound (Level, DVector3(m_Pos, 0), CHAN_VOICE, CHANF_LISTENERZ, - def->Sound != NO_SOUND ? FSoundID(def->Sound) : FSoundID("switches/normbutn"), + def->Sound != NO_SOUND ? FSoundID(def->Sound) : S_FindSound("switches/normbutn"), 1, ATTN_STATIC); bFlippable = false; } diff --git a/src/playsim/p_user.cpp b/src/playsim/p_user.cpp index 9aae42884d..038ae89d1d 100644 --- a/src/playsim/p_user.cpp +++ b/src/playsim/p_user.cpp @@ -908,7 +908,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_PlayerScream) (DF_FORCE_FALLINGZD | DF_FORCE_FALLINGHX)) && self->Vel.Z <= -39) { - sound = S_FindSkinnedSound (self, "*splat"); + sound = S_FindSkinnedSound (self, S_FindSound("*splat")); chan = CHAN_BODY; } @@ -1169,7 +1169,7 @@ void P_CheckEnvironment(player_t *player) player->mo->Vel.Z >= -player->mo->FloatVar(NAME_FallingScreamMaxSpeed) && !player->morphTics && player->mo->waterlevel == 0) { - auto id = S_FindSkinnedSound(player->mo, "*falling"); + auto id = S_FindSkinnedSound(player->mo, S_FindSound("*falling")); if (id != NO_SOUND && !S_IsActorPlayingSomething(player->mo, CHAN_VOICE, id)) { S_Sound(player->mo, CHAN_VOICE, 0, id, 1, ATTN_NORM); diff --git a/src/r_data/sprites.cpp b/src/r_data/sprites.cpp index 25ac50f9bd..07a106e65f 100644 --- a/src/r_data/sprites.cpp +++ b/src/r_data/sprites.cpp @@ -583,7 +583,7 @@ void R_InitSkins (void) for (j = 0; j < NUMSKINSOUNDS; ++j) { - playersoundrefs[j] = skinsoundnames[j][1]; + playersoundrefs[j] = S_FindSound(skinsoundnames[j][1]); } while ((base = fileSystem.FindLump ("S_SKIN", &lastlump, true)) != -1) diff --git a/src/scripting/decorate/olddecorations.cpp b/src/scripting/decorate/olddecorations.cpp index a9152539b8..82d40d34d2 100644 --- a/src/scripting/decorate/olddecorations.cpp +++ b/src/scripting/decorate/olddecorations.cpp @@ -504,17 +504,17 @@ static void ParseInsideDecoration (Baggage &bag, AActor *defaults, sc.Compare ("DeathSound")) { sc.MustGetString (); - defaults->DeathSound = sc.String; + defaults->DeathSound = S_FindSound(sc.String); } else if (def == DEF_BreakableDecoration && sc.Compare ("BurnDeathSound")) { sc.MustGetString (); - defaults->ActiveSound = sc.String; + defaults->ActiveSound = S_FindSound(sc.String); } else if (def == DEF_Projectile && sc.Compare ("SpawnSound")) { sc.MustGetString (); - defaults->SeeSound = sc.String; + defaults->SeeSound = S_FindSound(sc.String); } else if (def == DEF_Projectile && sc.Compare ("DoomBounce")) { diff --git a/src/scripting/decorate/thingdef_parse.cpp b/src/scripting/decorate/thingdef_parse.cpp index 96c654e3b5..8d49f76044 100644 --- a/src/scripting/decorate/thingdef_parse.cpp +++ b/src/scripting/decorate/thingdef_parse.cpp @@ -144,7 +144,7 @@ FxExpression *ParseParameter(FScanner &sc, PClassActor *cls, PType *type) if (type == TypeSound) { sc.MustGetString(); - x = new FxConstant(FSoundID(sc.String), sc); + x = new FxConstant(S_FindSound(sc.String), sc); } else if (type == TypeBool || type == TypeSInt32 || type == TypeFloat64) { @@ -879,7 +879,7 @@ static void DispatchScriptProperty(FScanner &sc, PProperty *prop, AActor *defaul else if (f->Type == TypeSound) { sc.MustGetString(); - *(FSoundID*)addr = sc.String; + *(FSoundID*)addr = S_FindSound(sc.String); } else if (f->Type == TypeColor) { diff --git a/src/scripting/zscript/zcc_compile_doom.cpp b/src/scripting/zscript/zcc_compile_doom.cpp index 4a6fa7dc91..69b8b773f8 100644 --- a/src/scripting/zscript/zcc_compile_doom.cpp +++ b/src/scripting/zscript/zcc_compile_doom.cpp @@ -467,7 +467,7 @@ void ZCCDoomCompiler::DispatchScriptProperty(PProperty *prop, ZCC_PropertyStmt * } else if (f->Type == TypeSound) { - *(FSoundID*)addr = GetStringConst(ex, ctx); + *(FSoundID*)addr = S_FindSound(GetStringConst(ex, ctx)); } else if (f->Type == TypeColor && ex->ValueType == TypeString) // colors can also be specified as ints. { diff --git a/src/sound/s_advsound.cpp b/src/sound/s_advsound.cpp index 0b4c7a755f..ef1ac65ef8 100644 --- a/src/sound/s_advsound.cpp +++ b/src/sound/s_advsound.cpp @@ -1514,11 +1514,11 @@ FSoundID S_FindSkinnedSoundEx (AActor *actor, const char *name, const char *exte fullname = name; fullname += '-'; fullname += extendedname; - FSoundID id = fullname; + FSoundID id = S_FindSound(fullname); if (!id.isvalid()) { // Look for "name" - id = name; + id = S_FindSound(name); } return S_FindSkinnedSound (actor, id); } diff --git a/src/sound/s_doomsound.cpp b/src/sound/s_doomsound.cpp index f2259e7f29..68786ae699 100644 --- a/src/sound/s_doomsound.cpp +++ b/src/sound/s_doomsound.cpp @@ -1386,7 +1386,7 @@ CCMD (playsound) { if (argv.argc() > 1) { - FSoundID id = argv[1]; + FSoundID id = S_FindSound(argv[1]); if (!id.isvalid()) { Printf("'%s' is not a sound\n", argv[1]); @@ -1408,7 +1408,7 @@ CCMD (loopsound) { if (players[consoleplayer].mo != nullptr && !netgame && argv.argc() > 1) { - FSoundID id = argv[1]; + FSoundID id = S_FindSound(argv[1]); if (!id.isvalid()) { Printf("'%s' is not a sound\n", argv[1]); diff --git a/src/sound/s_doomsound.h b/src/sound/s_doomsound.h index 35191110fa..b6c6dc3367 100644 --- a/src/sound/s_doomsound.h +++ b/src/sound/s_doomsound.h @@ -16,10 +16,18 @@ void S_PrecacheLevel(FLevelLocals* l); // Start sound for thing at void S_Sound(int channel, EChanFlags flags, FSoundID sfxid, float volume, float attenuation); +inline void S_Sound(int channel, EChanFlags flags, const char* sfxid, float volume, float attenuation) +{ + S_Sound(channel, flags, S_FindSound(sfxid), volume, attenuation); +} void S_SoundPitch(int channel, EChanFlags flags, FSoundID sfxid, float volume, float attenuation, float pitch, float startTime = 0.f); void S_Sound (AActor *ent, int channel, EChanFlags flags, FSoundID sfxid, float volume, float attenuation); +inline void S_Sound(AActor* ent, int channel, EChanFlags flags, const char* sfxid, float volume, float attenuation) +{ + S_Sound(ent, channel, flags, S_FindSound(sfxid), volume, attenuation); +} void S_SoundMinMaxDist (AActor *ent, int channel, EChanFlags flags, FSoundID sfxid, float volume, float mindist, float maxdist); void S_Sound (const FPolyObj *poly, int channel, EChanFlags flags, FSoundID sfxid, float volume, float attenuation); void S_Sound (const sector_t *sec, int channel, EChanFlags flags, FSoundID sfxid, float volume, float attenuation);