From 281ac3a49a9ccca6803f7517ff02a9ef91a2138d Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Fri, 25 Jan 2013 03:09:17 +0000 Subject: [PATCH] - Separate the player weapon state flags from the other player "cheat" flags. SVN r4041 (trunk) --- src/d_player.h | 17 +++++++++++------ src/p_pspr.cpp | 30 +++++++++++++++--------------- src/p_user.cpp | 11 +++++++++++ 3 files changed, 37 insertions(+), 21 deletions(-) diff --git a/src/d_player.h b/src/d_player.h index d1f564470..1b26bb776 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -195,7 +195,6 @@ typedef enum CF_INSTANTWEAPSWITCH= 1 << 11, // [RH] Switch weapons instantly CF_TOTALLYFROZEN = 1 << 12, // [RH] All players can do is press +use 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_HIGHJUMP = 1 << 18, // more Skulltag flags. Implementation not guaranteed though. ;) CF_REFLECTION = 1 << 19, @@ -203,15 +202,20 @@ typedef enum 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_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_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 } 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 WPIECE2 2 #define WPIECE3 4 @@ -305,6 +309,7 @@ public: int lastkilltime; // [RH] For multikills BYTE multicount; BYTE spreecount; // [RH] Keep track of killing sprees + BYTE WeaponState; AWeapon *ReadyWeapon; AWeapon *PendingWeapon; // WP_NOCHANGE if not changing diff --git a/src/p_pspr.cpp b/src/p_pspr.cpp index 4056794a4..15e60863e 100644 --- a/src/p_pspr.cpp +++ b/src/p_pspr.cpp @@ -95,7 +95,7 @@ void P_SetPsprite (player_t *player, int position, FState *state, bool nofunctio if (position == ps_weapon && !nofunction) { // 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]; @@ -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. // 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. - bobtarget = (player->cheats & CF_WEAPONBOBBING) ? player->bob : 0; + bobtarget = (player->cheats & WF_WEAPONBOBBING) ? player->bob : 0; if (curbob != bobtarget) { if (abs (bobtarget - curbob) <= 1*FRACUNIT) @@ -476,7 +476,7 @@ void DoReadyWeaponToSwitch (AActor * self) // Prepare for switching action. player_t *player; if (self && (player = self->player)) - player->cheats |= CF_WEAPONSWITCHOK; + player->cheats |= WF_WEAPONSWITCHOK; } void DoReadyWeaponToFire (AActor * self, bool prim, bool alt) @@ -506,7 +506,7 @@ void DoReadyWeaponToFire (AActor * self, bool prim, bool alt) } // 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; } @@ -515,7 +515,7 @@ void DoReadyWeaponToBob (AActor * self) if (self && self->player && self->player->ReadyWeapon) { // 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].sy = WEAPONTOP; } @@ -526,7 +526,7 @@ void DoReadyWeaponToReload (AActor * self) // Prepare for reload action. player_t *player; if (self && (player = self->player)) - player->cheats |= CF_WEAPONRELOADOK; + player->cheats |= WF_WEAPONRELOADOK; return; } @@ -535,7 +535,7 @@ void DoReadyWeaponToZoom (AActor * self) // Prepare for reload action. player_t *player; if (self && (player = self->player)) - player->cheats |= CF_WEAPONZOOMOK; + player->cheats |= WF_WEAPONZOOMOK; return; } @@ -591,7 +591,7 @@ void P_CheckWeaponFire (player_t *player) return; // 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)) { @@ -600,7 +600,7 @@ void P_CheckWeaponFire (player_t *player) 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)) { @@ -660,7 +660,7 @@ void P_CheckWeaponReload (player_t *player) return; // 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); } @@ -682,7 +682,7 @@ void P_CheckWeaponZoom (player_t *player) return; // 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); } @@ -1050,19 +1050,19 @@ void P_MovePsprites (player_t *player) } player->psprites[ps_flash].sx = player->psprites[ps_weapon].sx; player->psprites[ps_flash].sy = player->psprites[ps_weapon].sy; - if (player->cheats & CF_WEAPONSWITCHOK) + if (player->cheats & WF_WEAPONSWITCHOK) { P_CheckWeaponSwitch (player); } - if (player->cheats & (CF_WEAPONREADY | CF_WEAPONREADYALT)) + if (player->cheats & (WF_WEAPONREADY | WF_WEAPONREADYALT)) { P_CheckWeaponFire (player); } - if (player->cheats & CF_WEAPONRELOADOK) + if (player->cheats & WF_WEAPONRELOADOK) { P_CheckWeaponReload (player); } - if (player->cheats & CF_WEAPONZOOMOK) + if (player->cheats & WF_WEAPONZOOMOK) { P_CheckWeaponZoom (player); } diff --git a/src/p_user.cpp b/src/p_user.cpp index 0060641db..c936ea47e 100644 --- a/src/p_user.cpp +++ b/src/p_user.cpp @@ -247,6 +247,7 @@ player_t::player_t() ReadyWeapon(0), PendingWeapon(0), cheats(0), + WeaponState(0), timefreezer(0), refire(0), inconsistant(0), @@ -2670,6 +2671,16 @@ void player_t::Serialize (FArchive &arc) 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 << ConversationNPC << ConversationPC