- Separate the player weapon state flags from the other player "cheat" flags.

SVN r4041 (trunk)
This commit is contained in:
Randy Heit 2013-01-25 03:09:17 +00:00
parent 47cb2ad6bc
commit 281ac3a49a
3 changed files with 37 additions and 21 deletions

View file

@ -195,7 +195,6 @@ typedef enum
CF_INSTANTWEAPSWITCH= 1 << 11, // [RH] Switch weapons instantly CF_INSTANTWEAPSWITCH= 1 << 11, // [RH] Switch weapons instantly
CF_TOTALLYFROZEN = 1 << 12, // [RH] All players can do is press +use CF_TOTALLYFROZEN = 1 << 12, // [RH] All players can do is press +use
CF_PREDICTING = 1 << 13, // [RH] Player movement is being predicted CF_PREDICTING = 1 << 13, // [RH] Player movement is being predicted
CF_WEAPONREADY = 1 << 14, // [RH] Weapon is in the ready state and can fire its primary attack
CF_DRAIN = 1 << 16, // Player owns a drain powerup CF_DRAIN = 1 << 16, // Player owns a drain powerup
CF_HIGHJUMP = 1 << 18, // more Skulltag flags. Implementation not guaranteed though. ;) CF_HIGHJUMP = 1 << 18, // more Skulltag flags. Implementation not guaranteed though. ;)
CF_REFLECTION = 1 << 19, CF_REFLECTION = 1 << 19,
@ -203,15 +202,20 @@ typedef enum
CF_DOUBLEFIRINGSPEED= 1 << 21, // Player owns a double firing speed artifact CF_DOUBLEFIRINGSPEED= 1 << 21, // Player owns a double firing speed artifact
CF_EXTREMELYDEAD = 1 << 22, // [RH] Reliably let the status bar know about extreme deaths. CF_EXTREMELYDEAD = 1 << 22, // [RH] Reliably let the status bar know about extreme deaths.
CF_INFINITEAMMO = 1 << 23, // Player owns an infinite ammo artifact CF_INFINITEAMMO = 1 << 23, // Player owns an infinite ammo artifact
CF_WEAPONBOBBING = 1 << 24, // [HW] Bob weapon while the player is moving
CF_WEAPONREADYALT = 1 << 25, // Weapon can fire its secondary attack
CF_WEAPONSWITCHOK = 1 << 26, // It is okay to switch away from this weapon
CF_BUDDHA = 1 << 27, // [SP] Buddha mode - take damage, but don't die CF_BUDDHA = 1 << 27, // [SP] Buddha mode - take damage, but don't die
CF_WEAPONRELOADOK = 1 << 28, // [XA] Okay to reload this weapon.
CF_WEAPONZOOMOK = 1 << 29, // [XA] Okay to use weapon zoom function.
CF_NOCLIP2 = 1 << 30, // [RH] More Quake-like noclip CF_NOCLIP2 = 1 << 30, // [RH] More Quake-like noclip
} cheat_t; } cheat_t;
enum
{
WF_WEAPONREADY = 1 << 0, // [RH] Weapon is in the ready state and can fire its primary attack
WF_WEAPONBOBBING = 1 << 1, // [HW] Bob weapon while the player is moving
WF_WEAPONREADYALT = 1 << 2, // Weapon can fire its secondary attack
WF_WEAPONSWITCHOK = 1 << 3, // It is okay to switch away from this weapon
WF_WEAPONRELOADOK = 1 << 5, // [XA] Okay to reload this weapon.
WF_WEAPONZOOMOK = 1 << 6, // [XA] Okay to use weapon zoom function.
};
#define WPIECE1 1 #define WPIECE1 1
#define WPIECE2 2 #define WPIECE2 2
#define WPIECE3 4 #define WPIECE3 4
@ -305,6 +309,7 @@ public:
int lastkilltime; // [RH] For multikills int lastkilltime; // [RH] For multikills
BYTE multicount; BYTE multicount;
BYTE spreecount; // [RH] Keep track of killing sprees BYTE spreecount; // [RH] Keep track of killing sprees
BYTE WeaponState;
AWeapon *ReadyWeapon; AWeapon *ReadyWeapon;
AWeapon *PendingWeapon; // WP_NOCHANGE if not changing AWeapon *PendingWeapon; // WP_NOCHANGE if not changing

View file

@ -95,7 +95,7 @@ void P_SetPsprite (player_t *player, int position, FState *state, bool nofunctio
if (position == ps_weapon && !nofunction) if (position == ps_weapon && !nofunction)
{ // A_WeaponReady will re-set these as needed { // A_WeaponReady will re-set these as needed
player->cheats &= ~(CF_WEAPONREADY | CF_WEAPONREADYALT | CF_WEAPONBOBBING | CF_WEAPONSWITCHOK | CF_WEAPONRELOADOK | CF_WEAPONZOOMOK); player->WeaponState &= ~(WF_WEAPONREADY | WF_WEAPONREADYALT | WF_WEAPONBOBBING | WF_WEAPONSWITCHOK | WF_WEAPONRELOADOK | WF_WEAPONZOOMOK);
} }
psp = &player->psprites[position]; psp = &player->psprites[position];
@ -397,7 +397,7 @@ void P_BobWeapon (player_t *player, pspdef_t *psp, fixed_t *x, fixed_t *y)
// [RH] Smooth transitions between bobbing and not-bobbing frames. // [RH] Smooth transitions between bobbing and not-bobbing frames.
// This also fixes the bug where you can "stick" a weapon off-center by // This also fixes the bug where you can "stick" a weapon off-center by
// shooting it when it's at the peak of its swing. // shooting it when it's at the peak of its swing.
bobtarget = (player->cheats & CF_WEAPONBOBBING) ? player->bob : 0; bobtarget = (player->cheats & WF_WEAPONBOBBING) ? player->bob : 0;
if (curbob != bobtarget) if (curbob != bobtarget)
{ {
if (abs (bobtarget - curbob) <= 1*FRACUNIT) if (abs (bobtarget - curbob) <= 1*FRACUNIT)
@ -476,7 +476,7 @@ void DoReadyWeaponToSwitch (AActor * self)
// Prepare for switching action. // Prepare for switching action.
player_t *player; player_t *player;
if (self && (player = self->player)) if (self && (player = self->player))
player->cheats |= CF_WEAPONSWITCHOK; player->cheats |= WF_WEAPONSWITCHOK;
} }
void DoReadyWeaponToFire (AActor * self, bool prim, bool alt) void DoReadyWeaponToFire (AActor * self, bool prim, bool alt)
@ -506,7 +506,7 @@ void DoReadyWeaponToFire (AActor * self, bool prim, bool alt)
} }
// Prepare for firing action. // Prepare for firing action.
player->cheats |= ((prim ? CF_WEAPONREADY : 0) | (alt ? CF_WEAPONREADYALT : 0)); player->cheats |= ((prim ? WF_WEAPONREADY : 0) | (alt ? WF_WEAPONREADYALT : 0));
return; return;
} }
@ -515,7 +515,7 @@ void DoReadyWeaponToBob (AActor * self)
if (self && self->player && self->player->ReadyWeapon) if (self && self->player && self->player->ReadyWeapon)
{ {
// Prepare for bobbing action. // Prepare for bobbing action.
self->player->cheats |= CF_WEAPONBOBBING; self->player->cheats |= WF_WEAPONBOBBING;
self->player->psprites[ps_weapon].sx = 0; self->player->psprites[ps_weapon].sx = 0;
self->player->psprites[ps_weapon].sy = WEAPONTOP; self->player->psprites[ps_weapon].sy = WEAPONTOP;
} }
@ -526,7 +526,7 @@ void DoReadyWeaponToReload (AActor * self)
// Prepare for reload action. // Prepare for reload action.
player_t *player; player_t *player;
if (self && (player = self->player)) if (self && (player = self->player))
player->cheats |= CF_WEAPONRELOADOK; player->cheats |= WF_WEAPONRELOADOK;
return; return;
} }
@ -535,7 +535,7 @@ void DoReadyWeaponToZoom (AActor * self)
// Prepare for reload action. // Prepare for reload action.
player_t *player; player_t *player;
if (self && (player = self->player)) if (self && (player = self->player))
player->cheats |= CF_WEAPONZOOMOK; player->cheats |= WF_WEAPONZOOMOK;
return; return;
} }
@ -591,7 +591,7 @@ void P_CheckWeaponFire (player_t *player)
return; return;
// Check for fire. Some weapons do not auto fire. // Check for fire. Some weapons do not auto fire.
if ((player->cheats & CF_WEAPONREADY) && (player->cmd.ucmd.buttons & BT_ATTACK)) if ((player->cheats & WF_WEAPONREADY) && (player->cmd.ucmd.buttons & BT_ATTACK))
{ {
if (!player->attackdown || !(weapon->WeaponFlags & WIF_NOAUTOFIRE)) if (!player->attackdown || !(weapon->WeaponFlags & WIF_NOAUTOFIRE))
{ {
@ -600,7 +600,7 @@ void P_CheckWeaponFire (player_t *player)
return; return;
} }
} }
else if ((player->cheats & CF_WEAPONREADYALT) && (player->cmd.ucmd.buttons & BT_ALTATTACK)) else if ((player->cheats & WF_WEAPONREADYALT) && (player->cmd.ucmd.buttons & BT_ALTATTACK))
{ {
if (!player->attackdown || !(weapon->WeaponFlags & WIF_NOAUTOFIRE)) if (!player->attackdown || !(weapon->WeaponFlags & WIF_NOAUTOFIRE))
{ {
@ -660,7 +660,7 @@ void P_CheckWeaponReload (player_t *player)
return; return;
// Check for reload. // Check for reload.
if ((player->cheats & CF_WEAPONRELOADOK) && (player->cmd.ucmd.buttons & BT_RELOAD)) if ((player->cheats & WF_WEAPONRELOADOK) && (player->cmd.ucmd.buttons & BT_RELOAD))
{ {
P_ReloadWeapon (player, NULL); P_ReloadWeapon (player, NULL);
} }
@ -682,7 +682,7 @@ void P_CheckWeaponZoom (player_t *player)
return; return;
// Check for zoom. // Check for zoom.
if ((player->cheats & CF_WEAPONZOOMOK) && (player->cmd.ucmd.buttons & BT_ZOOM)) if ((player->cheats & WF_WEAPONZOOMOK) && (player->cmd.ucmd.buttons & BT_ZOOM))
{ {
P_ZoomWeapon (player, NULL); P_ZoomWeapon (player, NULL);
} }
@ -1050,19 +1050,19 @@ void P_MovePsprites (player_t *player)
} }
player->psprites[ps_flash].sx = player->psprites[ps_weapon].sx; player->psprites[ps_flash].sx = player->psprites[ps_weapon].sx;
player->psprites[ps_flash].sy = player->psprites[ps_weapon].sy; player->psprites[ps_flash].sy = player->psprites[ps_weapon].sy;
if (player->cheats & CF_WEAPONSWITCHOK) if (player->cheats & WF_WEAPONSWITCHOK)
{ {
P_CheckWeaponSwitch (player); P_CheckWeaponSwitch (player);
} }
if (player->cheats & (CF_WEAPONREADY | CF_WEAPONREADYALT)) if (player->cheats & (WF_WEAPONREADY | WF_WEAPONREADYALT))
{ {
P_CheckWeaponFire (player); P_CheckWeaponFire (player);
} }
if (player->cheats & CF_WEAPONRELOADOK) if (player->cheats & WF_WEAPONRELOADOK)
{ {
P_CheckWeaponReload (player); P_CheckWeaponReload (player);
} }
if (player->cheats & CF_WEAPONZOOMOK) if (player->cheats & WF_WEAPONZOOMOK)
{ {
P_CheckWeaponZoom (player); P_CheckWeaponZoom (player);
} }

View file

@ -247,6 +247,7 @@ player_t::player_t()
ReadyWeapon(0), ReadyWeapon(0),
PendingWeapon(0), PendingWeapon(0),
cheats(0), cheats(0),
WeaponState(0),
timefreezer(0), timefreezer(0),
refire(0), refire(0),
inconsistant(0), inconsistant(0),
@ -2670,6 +2671,16 @@ void player_t::Serialize (FArchive &arc)
mo->stamina = oldstamina; mo->stamina = oldstamina;
} }
} }
if (SaveVersion < 4041)
{
// Move weapon state flags from cheats and into WeaponState.
WeaponState = ((cheats >> 14) & 1) | ((cheats & (0x37 << 24)) >> (24 - 1));
cheats &= ~((1 << 14) | (0x37 << 24));
}
else
{
arc << WeaponState;
}
arc << LogText arc << LogText
<< ConversationNPC << ConversationNPC
<< ConversationPC << ConversationPC