- Extended state sprite/frame repetition to psprites.

SVN r2295 (trunk)
This commit is contained in:
Randy Heit 2010-04-21 01:40:03 +00:00
parent 14fc5516a8
commit f6cd776e2d
3 changed files with 32 additions and 8 deletions

View file

@ -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;
}

View file

@ -68,7 +68,8 @@ struct pspdef_t
int tics;
fixed_t sx;
fixed_t sy;
int sprite;
int frame;
};
class FArchive;

View file

@ -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;