mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-01-22 09:11:21 +00:00
Refactor this code into P_ApplySuperFlagToSprite2
This commit is contained in:
parent
7bc86509c5
commit
a60c55e866
4 changed files with 30 additions and 39 deletions
|
@ -1565,22 +1565,8 @@ boolean HWR_DrawModel(gl_vissprite_t *spr)
|
|||
{
|
||||
UINT16 next_spr2 = P_GetStateSprite2(&states[spr->mobj->state->nextstate]);
|
||||
|
||||
// Add/Remove SPR2F_SUPER based on certain conditions
|
||||
if (spr->mobj->player)
|
||||
{
|
||||
if (spr->mobj->player->charflags & SF_NOSUPERSPRITES)
|
||||
next_spr2 &= ~SPR2F_SUPER;
|
||||
else if (spr->mobj->player->powers[pw_super])
|
||||
next_spr2 |= SPR2F_SUPER;
|
||||
}
|
||||
|
||||
if (next_spr2 & SPR2F_SUPER)
|
||||
{
|
||||
if (spr->mobj->eflags & MFE_FORCENOSUPER)
|
||||
next_spr2 &= ~SPR2F_SUPER;
|
||||
}
|
||||
else if (spr->mobj->eflags & MFE_FORCESUPER)
|
||||
next_spr2 |= SPR2F_SUPER;
|
||||
// Add or remove SPR2F_SUPER based on certain conditions
|
||||
next_spr2 = P_ApplySuperFlagToSprite2(next_spr2, spr->mobj);
|
||||
|
||||
if (HWR_CanInterpolateSprite2(spr2frames)
|
||||
&& (spr->mobj->frame & FF_ANIMATE
|
||||
|
|
29
src/p_mobj.c
29
src/p_mobj.c
|
@ -411,21 +411,10 @@ boolean P_SetPlayerMobjState(mobj_t *mobj, statenum_t state)
|
|||
{
|
||||
spr2 = P_GetStateSprite2(st);
|
||||
|
||||
// Add/Remove SPR2F_SUPER based on certain conditions
|
||||
if (player->charflags & SF_NOSUPERSPRITES)
|
||||
spr2 &= ~SPR2F_SUPER;
|
||||
else if (player->powers[pw_super])
|
||||
spr2 |= SPR2F_SUPER;
|
||||
// Add or remove SPR2F_SUPER based on certain conditions
|
||||
spr2 = P_ApplySuperFlagToSprite2(spr2, mobj);
|
||||
|
||||
if (spr2 & SPR2F_SUPER)
|
||||
{
|
||||
if (mobj->eflags & MFE_FORCENOSUPER)
|
||||
spr2 &= ~SPR2F_SUPER;
|
||||
}
|
||||
else if (mobj->eflags & MFE_FORCESUPER)
|
||||
spr2 |= SPR2F_SUPER;
|
||||
|
||||
// Get the sprite2 and frame number
|
||||
// Get the needed sprite2 and frame number
|
||||
spr2 = P_GetSkinSprite2(skin, spr2, mobj->player);
|
||||
|
||||
spritedef_t *sprdef = P_GetSkinSpritedef(skin, spr2);
|
||||
|
@ -568,16 +557,10 @@ boolean P_SetMobjState(mobj_t *mobj, statenum_t state)
|
|||
{
|
||||
spr2 = P_GetStateSprite2(st);
|
||||
|
||||
// Add/Remove SPR2F_SUPER based on certain conditions
|
||||
if (spr2 & SPR2F_SUPER)
|
||||
{
|
||||
if (mobj->eflags & MFE_FORCENOSUPER)
|
||||
spr2 &= ~SPR2F_SUPER;
|
||||
}
|
||||
else if (mobj->eflags & MFE_FORCESUPER)
|
||||
spr2 |= SPR2F_SUPER;
|
||||
// Add or remove SPR2F_SUPER based on certain conditions
|
||||
spr2 = P_ApplySuperFlagToSprite2(spr2, mobj);
|
||||
|
||||
// Get the sprite2 and frame number
|
||||
// Get the needed sprite2 and frame number
|
||||
spr2 = P_GetSkinSprite2(skin, spr2, NULL);
|
||||
|
||||
spritedef_t *sprdef = P_GetSkinSpritedef(skin, spr2);
|
||||
|
|
|
@ -76,6 +76,27 @@ boolean P_IsStateSprite2Super(state_t *state)
|
|||
return false;
|
||||
}
|
||||
|
||||
UINT16 P_ApplySuperFlagToSprite2(UINT16 spr2, mobj_t *mobj)
|
||||
{
|
||||
if (mobj->player)
|
||||
{
|
||||
if (mobj->player->charflags & SF_NOSUPERSPRITES)
|
||||
spr2 &= ~SPR2F_SUPER;
|
||||
else if (mobj->player->powers[pw_super])
|
||||
spr2 |= SPR2F_SUPER;
|
||||
}
|
||||
|
||||
if (spr2 & SPR2F_SUPER)
|
||||
{
|
||||
if (mobj->eflags & MFE_FORCENOSUPER)
|
||||
spr2 &= ~SPR2F_SUPER;
|
||||
}
|
||||
else if (mobj->eflags & MFE_FORCESUPER)
|
||||
spr2 |= SPR2F_SUPER;
|
||||
|
||||
return spr2;
|
||||
}
|
||||
|
||||
//
|
||||
// P_GetSkinSprite2
|
||||
// For non-super players, tries each sprite2's immediate predecessor until it finds one with a number of frames or ends up at standing.
|
||||
|
|
|
@ -108,6 +108,7 @@ void R_PatchSkins(UINT16 wadnum, boolean mainfile);
|
|||
UINT16 P_GetStateSprite2(state_t *state);
|
||||
UINT16 P_GetSprite2StateFrame(state_t *state);
|
||||
UINT16 P_GetSkinSprite2(skin_t *skin, UINT16 spr2, player_t *player);
|
||||
UINT16 P_ApplySuperFlagToSprite2(UINT16 spr2, mobj_t *mobj);
|
||||
spritedef_t *P_GetSkinSpritedef(skin_t *skin, UINT16 spr2);
|
||||
spriteinfo_t *P_GetSkinSpriteInfo(skin_t *skin, UINT16 spr2);
|
||||
boolean P_IsValidSprite2(skin_t *skin, UINT16 spr2);
|
||||
|
|
Loading…
Reference in a new issue