From f6cd776e2d8ca749bfc6e413d161c1df1fce0216 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Wed, 21 Apr 2010 01:40:03 +0000 Subject: [PATCH] - Extended state sprite/frame repetition to psprites. SVN r2295 (trunk) --- src/p_pspr.cpp | 25 ++++++++++++++++++++++++- src/p_pspr.h | 3 ++- src/r_things.cpp | 12 ++++++------ 3 files changed, 32 insertions(+), 8 deletions(-) diff --git a/src/p_pspr.cpp b/src/p_pspr.cpp index 7606b43a4..a30e2d736 100644 --- a/src/p_pspr.cpp +++ b/src/p_pspr.cpp @@ -80,6 +80,19 @@ void P_SetPsprite (player_t *player, int position, FState *state, bool nofunctio } psp->state = state; + if (state->sprite != SPR_FIXED) + { // okay to change sprite and/or frame + if (!state->GetSameFrame()) + { // okay to change frame + psp->frame = state->GetFrame(); + } + if (state->sprite != SPR_NOCHANGE) + { // okay to change sprite + psp->sprite = state->sprite; + } + } + + if (sv_fastweapons >= 2 && position == ps_weapon) psp->tics = state->ActionFunc == NULL? 0 : 1; else if (sv_fastweapons) @@ -848,5 +861,15 @@ void P_MovePsprites (player_t *player) FArchive &operator<< (FArchive &arc, pspdef_t &def) { - return arc << def.state << def.tics << def.sx << def.sy; + arc << def.state << def.tics << def.sx << def.sy; + if (SaveVersion >= 2295) + { + arc << def.sprite << def.frame; + } + else + { + def.sprite = def.state->sprite; + def.frame = def.state->Frame; + } + return arc; } diff --git a/src/p_pspr.h b/src/p_pspr.h index 99eee7883..d7011714c 100644 --- a/src/p_pspr.h +++ b/src/p_pspr.h @@ -68,7 +68,8 @@ struct pspdef_t int tics; fixed_t sx; fixed_t sy; - + int sprite; + int frame; }; class FArchive; diff --git a/src/r_things.cpp b/src/r_things.cpp index 5815ca484..1750b3095 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -1530,18 +1530,18 @@ void R_DrawPSprite (pspdef_t* psp, int pspnum, AActor *owner, fixed_t sx, fixed_ assert(pspnum >= 0 && pspnum < NUMPSPRITES); // decide which patch to use - if ( (unsigned)psp->state->sprite >= (unsigned)sprites.Size ()) + if ( (unsigned)psp->sprite >= (unsigned)sprites.Size ()) { - DPrintf ("R_DrawPSprite: invalid sprite number %i\n", psp->state->sprite); + DPrintf ("R_DrawPSprite: invalid sprite number %i\n", psp->sprite); return; } - sprdef = &sprites[psp->state->sprite]; - if (psp->state->GetFrame() >= sprdef->numframes) + sprdef = &sprites[psp->sprite]; + if (psp->frame >= sprdef->numframes) { - DPrintf ("R_DrawPSprite: invalid sprite frame %i : %i\n", psp->state->sprite, psp->state->GetFrame()); + DPrintf ("R_DrawPSprite: invalid sprite frame %i : %i\n", psp->sprite, psp->frame); return; } - sprframe = &SpriteFrames[sprdef->spriteframes + psp->state->GetFrame()]; + sprframe = &SpriteFrames[sprdef->spriteframes + psp->frame]; picnum = sprframe->Texture[0]; flip = sprframe->Flip & 1;