diff --git a/src/actor.h b/src/actor.h index bd6b51a4d..b6d67cd18 100644 --- a/src/actor.h +++ b/src/actor.h @@ -685,8 +685,6 @@ public: void LevelSpawned(); // Called after BeginPlay if this actor was spawned by the world void HandleSpawnFlags(); // Translates SpawnFlags into in-game flags. - virtual void MarkPrecacheSounds() const; // Marks sounds used by this actor for precaching. - virtual void Activate (AActor *activator); void CallActivate(AActor *activator); diff --git a/src/d_player.h b/src/d_player.h index 6099b57ae..1008f837d 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -92,7 +92,6 @@ public: virtual void AddInventory (AInventory *item) override; virtual void RemoveInventory (AInventory *item) override; virtual bool UseInventory (AInventory *item) override; - virtual void MarkPrecacheSounds () const override; virtual void BeginPlay () override; virtual bool UpdateWaterLevel (bool splash) override; diff --git a/src/g_inventory/a_pickups.cpp b/src/g_inventory/a_pickups.cpp index ac9cbe330..1399915ee 100644 --- a/src/g_inventory/a_pickups.cpp +++ b/src/g_inventory/a_pickups.cpp @@ -161,18 +161,6 @@ bool AInventory::Massacre() return false; } -//=========================================================================== -// -// AInventory :: MarkPrecacheSounds -// -//=========================================================================== - -void AInventory::MarkPrecacheSounds() const -{ - Super::MarkPrecacheSounds(); - PickupSound.MarkUsed(); -} - //=========================================================================== // // AInventory :: Grind diff --git a/src/g_inventory/a_pickups.h b/src/g_inventory/a_pickups.h index 3815c6f77..7e4ad03f1 100644 --- a/src/g_inventory/a_pickups.h +++ b/src/g_inventory/a_pickups.h @@ -72,7 +72,6 @@ public: virtual void Finalize(FStateDefinitions &statedef) override; virtual void Serialize(FSerializer &arc) override; - virtual void MarkPrecacheSounds() const override; virtual void OnDestroy() override; virtual void Tick() override; virtual bool Massacre() override; diff --git a/src/g_inventory/a_weapons.cpp b/src/g_inventory/a_weapons.cpp index f9e635756..8758a132d 100644 --- a/src/g_inventory/a_weapons.cpp +++ b/src/g_inventory/a_weapons.cpp @@ -184,18 +184,6 @@ void AWeapon::Serialize(FSerializer &arc) } -//=========================================================================== -// -// AWeapon :: MarkPrecacheSounds -// -//=========================================================================== - -void AWeapon::MarkPrecacheSounds() const -{ - Super::MarkPrecacheSounds(); - UpSound.MarkUsed(); - ReadySound.MarkUsed(); -} /* Weapon slots ***********************************************************/ diff --git a/src/g_inventory/a_weapons.h b/src/g_inventory/a_weapons.h index 1a7bfb0de..4c498f7c2 100644 --- a/src/g_inventory/a_weapons.h +++ b/src/g_inventory/a_weapons.h @@ -159,8 +159,6 @@ public: bool bAltFire; // *** only accessed from ZScript. Set when this weapon's alternate fire is used. bool bDehAmmo; - virtual void MarkPrecacheSounds() const; - void Finalize(FStateDefinitions &statedef) override; void Serialize(FSerializer &arc) override; diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 089fd1972..56b19a5de 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -5310,26 +5310,6 @@ void AActor::CallPostBeginPlay() E_WorldThingSpawned(this); } -void AActor::MarkPrecacheSounds() const -{ - SeeSound.MarkUsed(); - AttackSound.MarkUsed(); - PainSound.MarkUsed(); - DeathSound.MarkUsed(); - ActiveSound.MarkUsed(); - UseSound.MarkUsed(); - BounceSound.MarkUsed(); - WallBounceSound.MarkUsed(); - CrushPainSound.MarkUsed(); -} - -DEFINE_ACTION_FUNCTION(AActor, MarkPrecacheSounds) -{ - PARAM_SELF_PROLOGUE(AActor); - self->MarkPrecacheSounds(); - return 0; -} - bool AActor::isFast() { if (flags5&MF5_ALWAYSFAST) return true; diff --git a/src/p_user.cpp b/src/p_user.cpp index 50da7fe9a..9a8463c9d 100644 --- a/src/p_user.cpp +++ b/src/p_user.cpp @@ -833,16 +833,16 @@ void APlayerPawn::Serialize(FSerializer &arc) //=========================================================================== // -// APlayerPawn :: MarkPrecacheSounds +// APlayerPawn :: MarkPlayerSounds // //=========================================================================== -void APlayerPawn::MarkPrecacheSounds() const +DEFINE_ACTION_FUNCTION(APlayerPawn, MarkPlayerSounds) { - Super::MarkPrecacheSounds(); - S_MarkPlayerSounds(GetSoundClass()); + PARAM_SELF_PROLOGUE(APlayerPawn); + S_MarkPlayerSounds(self->GetSoundClass()); + return 0; } - //=========================================================================== // // APlayerPawn :: BeginPlay diff --git a/src/s_advsound.cpp b/src/s_advsound.cpp index f0ec171c6..0be53d7e9 100644 --- a/src/s_advsound.cpp +++ b/src/s_advsound.cpp @@ -2232,18 +2232,20 @@ void AAmbientSound::Serialize(FSerializer &arc) //========================================================================== // -// AmbientSound :: MarkPrecacheSounds +// AmbientSound :: MarkAmbientSounds // //========================================================================== -void AAmbientSound::MarkPrecacheSounds() const +DEFINE_ACTION_FUNCTION(AAmbientSound, MarkAmbientSounds) { - Super::MarkPrecacheSounds(); - FAmbientSound *ambient = Ambients.CheckKey(args[0]); + PARAM_SELF_PROLOGUE(AAmbientSound); + + FAmbientSound *ambient = Ambients.CheckKey(self->args[0]); if (ambient != NULL) { ambient->sound.MarkUsed(); } + return 0; } //========================================================================== @@ -2458,3 +2460,11 @@ void S_ParseMusInfo() } +DEFINE_ACTION_FUNCTION(DObject, MarkSound) +{ + PARAM_PROLOGUE; + PARAM_SOUND(sound_id); + sound_id.MarkUsed(); + return 0; +} + diff --git a/src/s_sound.cpp b/src/s_sound.cpp index 4ba1d476e..3eec90d39 100644 --- a/src/s_sound.cpp +++ b/src/s_sound.cpp @@ -504,14 +504,9 @@ void S_PrecacheLevel () { IFVIRTUALPTR(actor, AActor, MarkPrecacheSounds) { - // Without the type cast this picks the 'void *' assignment... VMValue params[1] = { actor }; VMCall(func, params, 1, nullptr, 0); } - else - { - actor->MarkPrecacheSounds(); - } } for (auto snd : gameinfo.PrecachedSounds) { diff --git a/wadsrc/static/zscript/actor.txt b/wadsrc/static/zscript/actor.txt index c2405b40e..3c2eec930 100644 --- a/wadsrc/static/zscript/actor.txt +++ b/wadsrc/static/zscript/actor.txt @@ -420,6 +420,18 @@ class Actor : Thinker native native clearscope static Vector2 RotateVector(Vector2 vec, double angle); native clearscope static double Normalize180(double ang); + virtual void MarkPrecacheSounds() + { + MarkSound(SeeSound); + MarkSound(AttackSound); + MarkSound(PainSound); + MarkSound(DeathSound); + MarkSound(ActiveSound); + MarkSound(UseSound); + MarkSound(BounceSound); + MarkSound(WallBounceSound); + MarkSound(CrushPainSound); + } bool IsPointerEqual(int ptr_select1, int ptr_select2) { @@ -439,7 +451,6 @@ class Actor : Thinker native virtual native void Die(Actor source, Actor inflictor, int dmgflags = 0, Name MeansOfDeath = 'none'); virtual native bool Slam(Actor victim); virtual native void Touch(Actor toucher); - virtual native void MarkPrecacheSounds(); native void Substitute(Actor replacement); // Called by PIT_CheckThing to check if two actors actually can collide. diff --git a/wadsrc/static/zscript/base.txt b/wadsrc/static/zscript/base.txt index 9a8baf990..3aec2fef7 100644 --- a/wadsrc/static/zscript/base.txt +++ b/wadsrc/static/zscript/base.txt @@ -385,6 +385,7 @@ class Object native native static void S_ResumeSound (bool notsfx); native static bool S_ChangeMusic(String music_name, int order = 0, bool looping = true, bool force = false); native static float S_GetLength(Sound sound_id); + native static void MarkSound(Sound snd); native static uint BAM(double angle); native static void SetMusicVolume(float vol); native static uint MSTime(); diff --git a/wadsrc/static/zscript/inventory/inventory.txt b/wadsrc/static/zscript/inventory/inventory.txt index 813119089..839e3aa71 100644 --- a/wadsrc/static/zscript/inventory/inventory.txt +++ b/wadsrc/static/zscript/inventory/inventory.txt @@ -74,6 +74,17 @@ class Inventory : Actor native Stop; } + //=========================================================================== + // + // AInventory :: MarkPrecacheSounds + // + //=========================================================================== + + override void MarkPrecacheSounds() + { + Super.MarkPrecacheSounds(); + MarkSound(PickupSound); + } //=========================================================================== // diff --git a/wadsrc/static/zscript/inventory/weapons.txt b/wadsrc/static/zscript/inventory/weapons.txt index 879063a63..b03edbde7 100644 --- a/wadsrc/static/zscript/inventory/weapons.txt +++ b/wadsrc/static/zscript/inventory/weapons.txt @@ -78,6 +78,18 @@ class Weapon : StateProvider native Stop; } + //=========================================================================== + // + // AWeapon :: MarkPrecacheSounds + // + //=========================================================================== + + override void MarkPrecacheSounds() + { + Super.MarkPrecacheSounds(); + MarkSound(UpSound); + MarkSound(ReadySound); + } virtual int, int CheckAddToSlots() { diff --git a/wadsrc/static/zscript/shared/player.txt b/wadsrc/static/zscript/shared/player.txt index 998b1ce6b..a213e2c0c 100644 --- a/wadsrc/static/zscript/shared/player.txt +++ b/wadsrc/static/zscript/shared/player.txt @@ -113,6 +113,18 @@ class PlayerPawn : Actor native Obituary "$OB_MPDEFAULT"; } + //=========================================================================== + // + // APlayerPawn :: MarkPrecacheSounds + // + //=========================================================================== + + override void MarkPrecacheSounds() + { + Super.MarkPrecacheSounds(); + MarkPlayerSounds(); + } + //---------------------------------------------------------------------------- // // @@ -2065,6 +2077,7 @@ class PlayerPawn : Actor native native void CheckEnvironment(); native void CheckUse(); native void CheckWeaponButtons(); + native void MarkPlayerSounds(); } class PlayerChunk : PlayerPawn diff --git a/wadsrc/static/zscript/shared/soundsequence.txt b/wadsrc/static/zscript/shared/soundsequence.txt index c5e2b2604..e7c3f8454 100644 --- a/wadsrc/static/zscript/shared/soundsequence.txt +++ b/wadsrc/static/zscript/shared/soundsequence.txt @@ -66,6 +66,14 @@ class AmbientSound : Actor native +NOSECTOR +DONTSPLASH } + + native void MarkAmbientSounds(); + + override void MarkPrecacheSounds() + { + Super.MarkPrecacheSounds(); + MarkAmbientSounds(); + } } class AmbientSoundNoGravity : AmbientSound