mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-10 23:02:08 +00:00
- moved MarkPrecacheSounds completely to the script side and added native support to make this a usable feature.
This commit is contained in:
parent
8fa16b6c30
commit
7012179904
16 changed files with 76 additions and 65 deletions
|
@ -685,8 +685,6 @@ public:
|
||||||
void LevelSpawned(); // Called after BeginPlay if this actor was spawned by the world
|
void LevelSpawned(); // Called after BeginPlay if this actor was spawned by the world
|
||||||
void HandleSpawnFlags(); // Translates SpawnFlags into in-game flags.
|
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 Activate (AActor *activator);
|
||||||
void CallActivate(AActor *activator);
|
void CallActivate(AActor *activator);
|
||||||
|
|
||||||
|
|
|
@ -92,7 +92,6 @@ public:
|
||||||
virtual void AddInventory (AInventory *item) override;
|
virtual void AddInventory (AInventory *item) override;
|
||||||
virtual void RemoveInventory (AInventory *item) override;
|
virtual void RemoveInventory (AInventory *item) override;
|
||||||
virtual bool UseInventory (AInventory *item) override;
|
virtual bool UseInventory (AInventory *item) override;
|
||||||
virtual void MarkPrecacheSounds () const override;
|
|
||||||
virtual void BeginPlay () override;
|
virtual void BeginPlay () override;
|
||||||
virtual bool UpdateWaterLevel (bool splash) override;
|
virtual bool UpdateWaterLevel (bool splash) override;
|
||||||
|
|
||||||
|
|
|
@ -161,18 +161,6 @@ bool AInventory::Massacre()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//===========================================================================
|
|
||||||
//
|
|
||||||
// AInventory :: MarkPrecacheSounds
|
|
||||||
//
|
|
||||||
//===========================================================================
|
|
||||||
|
|
||||||
void AInventory::MarkPrecacheSounds() const
|
|
||||||
{
|
|
||||||
Super::MarkPrecacheSounds();
|
|
||||||
PickupSound.MarkUsed();
|
|
||||||
}
|
|
||||||
|
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// AInventory :: Grind
|
// AInventory :: Grind
|
||||||
|
|
|
@ -72,7 +72,6 @@ public:
|
||||||
|
|
||||||
virtual void Finalize(FStateDefinitions &statedef) override;
|
virtual void Finalize(FStateDefinitions &statedef) override;
|
||||||
virtual void Serialize(FSerializer &arc) override;
|
virtual void Serialize(FSerializer &arc) override;
|
||||||
virtual void MarkPrecacheSounds() const override;
|
|
||||||
virtual void OnDestroy() override;
|
virtual void OnDestroy() override;
|
||||||
virtual void Tick() override;
|
virtual void Tick() override;
|
||||||
virtual bool Massacre() override;
|
virtual bool Massacre() override;
|
||||||
|
|
|
@ -184,18 +184,6 @@ void AWeapon::Serialize(FSerializer &arc)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//===========================================================================
|
|
||||||
//
|
|
||||||
// AWeapon :: MarkPrecacheSounds
|
|
||||||
//
|
|
||||||
//===========================================================================
|
|
||||||
|
|
||||||
void AWeapon::MarkPrecacheSounds() const
|
|
||||||
{
|
|
||||||
Super::MarkPrecacheSounds();
|
|
||||||
UpSound.MarkUsed();
|
|
||||||
ReadySound.MarkUsed();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Weapon slots ***********************************************************/
|
/* Weapon slots ***********************************************************/
|
||||||
|
|
||||||
|
|
|
@ -159,8 +159,6 @@ public:
|
||||||
bool bAltFire; // *** only accessed from ZScript. Set when this weapon's alternate fire is used.
|
bool bAltFire; // *** only accessed from ZScript. Set when this weapon's alternate fire is used.
|
||||||
bool bDehAmmo;
|
bool bDehAmmo;
|
||||||
|
|
||||||
virtual void MarkPrecacheSounds() const;
|
|
||||||
|
|
||||||
void Finalize(FStateDefinitions &statedef) override;
|
void Finalize(FStateDefinitions &statedef) override;
|
||||||
void Serialize(FSerializer &arc) override;
|
void Serialize(FSerializer &arc) override;
|
||||||
|
|
||||||
|
|
|
@ -5310,26 +5310,6 @@ void AActor::CallPostBeginPlay()
|
||||||
E_WorldThingSpawned(this);
|
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()
|
bool AActor::isFast()
|
||||||
{
|
{
|
||||||
if (flags5&MF5_ALWAYSFAST) return true;
|
if (flags5&MF5_ALWAYSFAST) return true;
|
||||||
|
|
|
@ -833,16 +833,16 @@ void APlayerPawn::Serialize(FSerializer &arc)
|
||||||
|
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// APlayerPawn :: MarkPrecacheSounds
|
// APlayerPawn :: MarkPlayerSounds
|
||||||
//
|
//
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
|
|
||||||
void APlayerPawn::MarkPrecacheSounds() const
|
DEFINE_ACTION_FUNCTION(APlayerPawn, MarkPlayerSounds)
|
||||||
{
|
{
|
||||||
Super::MarkPrecacheSounds();
|
PARAM_SELF_PROLOGUE(APlayerPawn);
|
||||||
S_MarkPlayerSounds(GetSoundClass());
|
S_MarkPlayerSounds(self->GetSoundClass());
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// APlayerPawn :: BeginPlay
|
// APlayerPawn :: BeginPlay
|
||||||
|
|
|
@ -2232,18 +2232,20 @@ void AAmbientSound::Serialize(FSerializer &arc)
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
//
|
//
|
||||||
// AmbientSound :: MarkPrecacheSounds
|
// AmbientSound :: MarkAmbientSounds
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
void AAmbientSound::MarkPrecacheSounds() const
|
DEFINE_ACTION_FUNCTION(AAmbientSound, MarkAmbientSounds)
|
||||||
{
|
{
|
||||||
Super::MarkPrecacheSounds();
|
PARAM_SELF_PROLOGUE(AAmbientSound);
|
||||||
FAmbientSound *ambient = Ambients.CheckKey(args[0]);
|
|
||||||
|
FAmbientSound *ambient = Ambients.CheckKey(self->args[0]);
|
||||||
if (ambient != NULL)
|
if (ambient != NULL)
|
||||||
{
|
{
|
||||||
ambient->sound.MarkUsed();
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -504,14 +504,9 @@ void S_PrecacheLevel ()
|
||||||
{
|
{
|
||||||
IFVIRTUALPTR(actor, AActor, MarkPrecacheSounds)
|
IFVIRTUALPTR(actor, AActor, MarkPrecacheSounds)
|
||||||
{
|
{
|
||||||
// Without the type cast this picks the 'void *' assignment...
|
|
||||||
VMValue params[1] = { actor };
|
VMValue params[1] = { actor };
|
||||||
VMCall(func, params, 1, nullptr, 0);
|
VMCall(func, params, 1, nullptr, 0);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
actor->MarkPrecacheSounds();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
for (auto snd : gameinfo.PrecachedSounds)
|
for (auto snd : gameinfo.PrecachedSounds)
|
||||||
{
|
{
|
||||||
|
|
|
@ -420,6 +420,18 @@ class Actor : Thinker native
|
||||||
native clearscope static Vector2 RotateVector(Vector2 vec, double angle);
|
native clearscope static Vector2 RotateVector(Vector2 vec, double angle);
|
||||||
native clearscope static double Normalize180(double ang);
|
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)
|
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 void Die(Actor source, Actor inflictor, int dmgflags = 0, Name MeansOfDeath = 'none');
|
||||||
virtual native bool Slam(Actor victim);
|
virtual native bool Slam(Actor victim);
|
||||||
virtual native void Touch(Actor toucher);
|
virtual native void Touch(Actor toucher);
|
||||||
virtual native void MarkPrecacheSounds();
|
|
||||||
native void Substitute(Actor replacement);
|
native void Substitute(Actor replacement);
|
||||||
|
|
||||||
// Called by PIT_CheckThing to check if two actors actually can collide.
|
// Called by PIT_CheckThing to check if two actors actually can collide.
|
||||||
|
|
|
@ -385,6 +385,7 @@ class Object native
|
||||||
native static void S_ResumeSound (bool notsfx);
|
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 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 float S_GetLength(Sound sound_id);
|
||||||
|
native static void MarkSound(Sound snd);
|
||||||
native static uint BAM(double angle);
|
native static uint BAM(double angle);
|
||||||
native static void SetMusicVolume(float vol);
|
native static void SetMusicVolume(float vol);
|
||||||
native static uint MSTime();
|
native static uint MSTime();
|
||||||
|
|
|
@ -74,6 +74,17 @@ class Inventory : Actor native
|
||||||
Stop;
|
Stop;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//===========================================================================
|
||||||
|
//
|
||||||
|
// AInventory :: MarkPrecacheSounds
|
||||||
|
//
|
||||||
|
//===========================================================================
|
||||||
|
|
||||||
|
override void MarkPrecacheSounds()
|
||||||
|
{
|
||||||
|
Super.MarkPrecacheSounds();
|
||||||
|
MarkSound(PickupSound);
|
||||||
|
}
|
||||||
|
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
|
|
|
@ -78,6 +78,18 @@ class Weapon : StateProvider native
|
||||||
Stop;
|
Stop;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//===========================================================================
|
||||||
|
//
|
||||||
|
// AWeapon :: MarkPrecacheSounds
|
||||||
|
//
|
||||||
|
//===========================================================================
|
||||||
|
|
||||||
|
override void MarkPrecacheSounds()
|
||||||
|
{
|
||||||
|
Super.MarkPrecacheSounds();
|
||||||
|
MarkSound(UpSound);
|
||||||
|
MarkSound(ReadySound);
|
||||||
|
}
|
||||||
|
|
||||||
virtual int, int CheckAddToSlots()
|
virtual int, int CheckAddToSlots()
|
||||||
{
|
{
|
||||||
|
|
|
@ -113,6 +113,18 @@ class PlayerPawn : Actor native
|
||||||
Obituary "$OB_MPDEFAULT";
|
Obituary "$OB_MPDEFAULT";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//===========================================================================
|
||||||
|
//
|
||||||
|
// APlayerPawn :: MarkPrecacheSounds
|
||||||
|
//
|
||||||
|
//===========================================================================
|
||||||
|
|
||||||
|
override void MarkPrecacheSounds()
|
||||||
|
{
|
||||||
|
Super.MarkPrecacheSounds();
|
||||||
|
MarkPlayerSounds();
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
|
@ -2065,6 +2077,7 @@ class PlayerPawn : Actor native
|
||||||
native void CheckEnvironment();
|
native void CheckEnvironment();
|
||||||
native void CheckUse();
|
native void CheckUse();
|
||||||
native void CheckWeaponButtons();
|
native void CheckWeaponButtons();
|
||||||
|
native void MarkPlayerSounds();
|
||||||
}
|
}
|
||||||
|
|
||||||
class PlayerChunk : PlayerPawn
|
class PlayerChunk : PlayerPawn
|
||||||
|
|
|
@ -66,6 +66,14 @@ class AmbientSound : Actor native
|
||||||
+NOSECTOR
|
+NOSECTOR
|
||||||
+DONTSPLASH
|
+DONTSPLASH
|
||||||
}
|
}
|
||||||
|
|
||||||
|
native void MarkAmbientSounds();
|
||||||
|
|
||||||
|
override void MarkPrecacheSounds()
|
||||||
|
{
|
||||||
|
Super.MarkPrecacheSounds();
|
||||||
|
MarkAmbientSounds();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class AmbientSoundNoGravity : AmbientSound
|
class AmbientSoundNoGravity : AmbientSound
|
||||||
|
|
Loading…
Reference in a new issue