diff --git a/src/actor.h b/src/actor.h index 751e3579e5..1b4e5ac91d 100644 --- a/src/actor.h +++ b/src/actor.h @@ -583,15 +583,14 @@ public: bool AdjustReflectionAngle (AActor *thing, angle_t &angle); // Returns true if this actor is within melee range of its target - bool CheckMeleeRange (); + bool CheckMeleeRange(); - // BeginPlay: Called just after the actor is created - virtual void BeginPlay (); - virtual void PostBeginPlay (); - // LevelSpawned: Called after BeginPlay if this actor was spawned by the world - virtual void LevelSpawned (); - // Translates SpawnFlags into in-game flags. - virtual void HandleSpawnFlags (); + virtual void BeginPlay(); // Called immediately after the actor is created + virtual void PostBeginPlay(); // Called immediately before the actor's first tick + virtual void LevelSpawned(); // Called after BeginPlay if this actor was spawned by the world + virtual 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); virtual void Deactivate (AActor *activator); diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 4ccd669f76..1acdc2927a 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -3993,6 +3993,19 @@ void AActor::PostBeginPlay () PrevAngle = angle; } +void AActor::MarkPrecacheSounds() const +{ + SeeSound.MarkUsed(); + AttackSound.MarkUsed(); + PainSound.MarkUsed(); + DeathSound.MarkUsed(); + ActiveSound.MarkUsed(); + UseSound.MarkUsed(); + BounceSound.MarkUsed(); + WallBounceSound.MarkUsed(); + CrushPainSound.MarkUsed(); +} + bool AActor::isFast() { if (flags5&MF5_ALWAYSFAST) return true; diff --git a/src/s_sound.cpp b/src/s_sound.cpp index dadd1a6d72..de383a1f69 100644 --- a/src/s_sound.cpp +++ b/src/s_sound.cpp @@ -480,17 +480,12 @@ void S_PrecacheLevel () // Precache all sounds known to be used by the currently spawned actors. while ( (actor = iterator.Next()) != NULL ) { - S_sfx[actor->SeeSound].bUsed = true; - S_sfx[actor->AttackSound].bUsed = true; - S_sfx[actor->PainSound].bUsed = true; - S_sfx[actor->DeathSound].bUsed = true; - S_sfx[actor->ActiveSound].bUsed = true; - S_sfx[actor->UseSound].bUsed = true; + actor->MarkPrecacheSounds(); } // Precache all extra sounds requested by this map. for (i = 0; i < level.info->PrecacheSounds.Size(); ++i) { - S_sfx[level.info->PrecacheSounds[i]].bUsed = true; + level.info->PrecacheSounds[i].MarkUsed(); } for (i = 1; i < S_sfx.Size(); ++i) diff --git a/src/s_sound.h b/src/s_sound.h index 84881862ca..2c2a398ae1 100644 --- a/src/s_sound.h +++ b/src/s_sound.h @@ -65,6 +65,8 @@ struct sfxinfo_t FRolloffInfo Rolloff; float Attenuation; // Multiplies the attenuation passed to S_Sound. + + void MarkUsed(); // Marks this sound as used. }; // Rolloff types @@ -132,6 +134,10 @@ public: { return ID ? S_sfx[ID].name.GetChars() : NULL; } + void MarkUsed() const + { + S_sfx[ID].MarkUsed(); + } private: int ID; protected: