From af8022f7f2b1db7685d961fe9606fe00bdd1956a Mon Sep 17 00:00:00 2001 From: Rudolf Polzer Date: Fri, 25 Jan 2013 09:50:39 +0100 Subject: [PATCH] make crouch handling serverside again, for g_bloodloss --- qcsrc/common/csqcmodel_settings.qh | 3 +++ qcsrc/csqcmodellib/cl_player.qc | 8 ++++++++ qcsrc/server/cl_client.qc | 15 +++++++++++++-- qcsrc/server/cl_weaponsystem.qc | 2 +- qcsrc/server/w_shotgun.qc | 2 +- 5 files changed, 26 insertions(+), 4 deletions(-) diff --git a/qcsrc/common/csqcmodel_settings.qh b/qcsrc/common/csqcmodel_settings.qh index 028ce9b8c..a0076825b 100644 --- a/qcsrc/common/csqcmodel_settings.qh +++ b/qcsrc/common/csqcmodel_settings.qh @@ -4,6 +4,9 @@ // don't define this ever //#define CSQCMODEL_SUPPORT_GETTAGINFO_BEFORE_DRAW +// server decides crouching, this lags, but so be it +#define CSQCMODEL_SERVERSIDE_CROUCH + // a hack for Xonotic #ifdef CSQC # define TAG_ENTITY_NAME tag_networkentity diff --git a/qcsrc/csqcmodellib/cl_player.qc b/qcsrc/csqcmodellib/cl_player.qc index ac9373989..f77f95126 100644 --- a/qcsrc/csqcmodellib/cl_player.qc +++ b/qcsrc/csqcmodellib/cl_player.qc @@ -240,6 +240,14 @@ void CSQCPlayer_SetCamera() } CSQCPlayer_PredictTo(clientcommandframe + 1, TRUE); +#ifdef CSQCMODEL_SERVERSIDE_CROUCH + // get crouch state from the server (LAG) + if(getstati(STAT_VIEWHEIGHT) == PL_VIEW_OFS_z) + self.pmove_flags &~= PMF_DUCKED; + else if(getstati(STAT_VIEWHEIGHT) == PL_CROUCH_VIEW_OFS_z) + self.pmove_flags |= PMF_DUCKED; +#endif + CSQCPlayer_SetMinsMaxs(); self.angles_y = input_angles_y; diff --git a/qcsrc/server/cl_client.qc b/qcsrc/server/cl_client.qc index 1dcbf0d1f..02435cc60 100644 --- a/qcsrc/server/cl_client.qc +++ b/qcsrc/server/cl_client.qc @@ -2785,8 +2785,19 @@ void PlayerPreThink (void) self.prevorigin = self.origin; - if (!self.vehicle) - if (((self.BUTTON_CROUCH && !self.hook.state) || self.health <= g_bloodloss) && !self.freezetag_frozen) // FIXME-CSAD: prevent crouching if using melee attack + float do_crouch = self.BUTTON_CROUCH; + if(!self.hook.state) + do_crouch = 0; + if(self.health <= g_bloodloss) + do_crouch = 1; + if(self.vehicle) + do_crouch = 0; + if(self.freezetag_frozen) + do_crouch = 0; + if(self.weapon == WEP_SHOTGUN && self.weaponentity.wframe == WFRAME_FIRE2 && time < self.weapon_nextthink) + do_crouch = 0; + + if (do_crouch) { if (!self.crouch) { diff --git a/qcsrc/server/cl_weaponsystem.qc b/qcsrc/server/cl_weaponsystem.qc index a84a8a51b..a75e2be5a 100644 --- a/qcsrc/server/cl_weaponsystem.qc +++ b/qcsrc/server/cl_weaponsystem.qc @@ -1049,7 +1049,7 @@ void weapon_thinkf(float fr, float t, void() func) if((fr == WFRAME_FIRE1 || fr == WFRAME_FIRE2) && t) { - if(self.weapon == WEP_SHOTGUN && self.BUTTON_ATCK2) + if(self.weapon == WEP_SHOTGUN && fr == WFRAME_FIRE2) animdecide_setaction(self, ANIMACTION_MELEE, restartanim); else animdecide_setaction(self, ANIMACTION_SHOOT, restartanim); diff --git a/qcsrc/server/w_shotgun.qc b/qcsrc/server/w_shotgun.qc index fcf9a27c2..fdfa6af38 100644 --- a/qcsrc/server/w_shotgun.qc +++ b/qcsrc/server/w_shotgun.qc @@ -199,7 +199,7 @@ float w_shotgun(float req) } } if (self.clip_load >= 0) // we are not currently reloading - if (!self.crouch) // we are not currently crouching; this fixes an exploit where your melee anim is not visible, and besides wouldn't make much sense + if (!self.crouch) // no crouchmelee please if (self.BUTTON_ATCK2 && autocvar_g_balance_shotgun_secondary) if (weapon_prepareattack(1, autocvar_g_balance_shotgun_secondary_refire)) { -- 2.39.2