diff --git a/src/p_pspr.cpp b/src/p_pspr.cpp index 25b23ca92..99c6427fd 100644 --- a/src/p_pspr.cpp +++ b/src/p_pspr.cpp @@ -28,6 +28,7 @@ #include "thingdef/thingdef.h" #include "g_level.h" #include "farchive.h" +#include "d_player.h" // MACROS ------------------------------------------------------------------ @@ -58,6 +59,30 @@ static FRandom pr_gunshot ("GunShot"); // CODE -------------------------------------------------------------------- +//--------------------------------------------------------------------------- +// +// PROC P_NewPspriteTick +// +//--------------------------------------------------------------------------- + +void P_NewPspriteTick() +{ + // This function should be called after the beginning of a tick, before any possible + // prprite-event, or near the end, after any possible psprite event. + // Because data is reset for every tick (which it must be) this has no impact on savegames. + for (int i = 0; ipsprites[position]; + psp->processPending = false; // Do not subsequently perform periodic processing within the same tick. + do { if (state == NULL) @@ -837,7 +864,7 @@ void P_MovePsprites (player_t *player) psp = &player->psprites[0]; for (i = 0; i < NUMPSPRITES; i++, psp++) { - if ((state = psp->state) != NULL) // a null state means not active + if ((state = psp->state) != NULL && psp->processPending) // a null state means not active { // drop tic count and possibly change state if (psp->tics != -1) // a -1 tic count never changes diff --git a/src/p_pspr.h b/src/p_pspr.h index d7011714c..83cce732a 100644 --- a/src/p_pspr.h +++ b/src/p_pspr.h @@ -70,6 +70,7 @@ struct pspdef_t fixed_t sy; int sprite; int frame; + bool processPending; // true: waiting for periodic processing on this tick }; class FArchive; @@ -80,6 +81,7 @@ class player_t; class AActor; struct FState; +void P_NewPspriteTick(); void P_SetPsprite (player_t *player, int position, FState *state, bool nofunction=false); void P_CalcSwing (player_t *player); void P_BringUpWeapon (player_t *player); diff --git a/src/p_tick.cpp b/src/p_tick.cpp index b2ef3d379..5f6636063 100644 --- a/src/p_tick.cpp +++ b/src/p_tick.cpp @@ -84,6 +84,8 @@ void P_Ticker (void) if (paused || P_CheckTickerPaused()) return; + P_NewPspriteTick(); + // [RH] Frozen mode is only changed every 4 tics, to make it work with A_Tracer(). if ((level.time & 3) == 0) {