From b608a23f7683b58d9c0dabe539e9a5db7ac6ab4e Mon Sep 17 00:00:00 2001 From: Rudolf Polzer Date: Sat, 7 May 2011 21:47:38 +0200 Subject: [PATCH] send zoomscript state to SVQC using +button9; no longer catch button3 and button4 commands from CSQC but query input_buttons --- qcsrc/client/Main.qc | 27 --------------------------- qcsrc/client/View.qc | 11 ++++++----- qcsrc/client/main.qh | 3 +-- qcsrc/server/cl_client.qc | 2 +- qcsrc/server/defs.qh | 21 +++++++++++---------- qcsrc/server/extensions.qh | 8 ++++++++ qcsrc/server/w_nex.qc | 2 +- qcsrc/server/w_sniperrifle.qc | 2 +- 8 files changed, 29 insertions(+), 47 deletions(-) diff --git a/qcsrc/client/Main.qc b/qcsrc/client/Main.qc index 71998a2d6..0609b3d17 100644 --- a/qcsrc/client/Main.qc +++ b/qcsrc/client/Main.qc @@ -91,10 +91,6 @@ void CSQC_Init(void) registercmd("hud_save"); //registercmd("menu_action"); - registercmd("+button3"); - registercmd("-button3"); - registercmd("+button4"); - registercmd("-button4"); registercmd("+showscores");registercmd("-showscores"); registercmd("+showaccuracy");registercmd("-showaccuracy"); @@ -371,29 +367,6 @@ float CSQC_ConsoleCommand(string strMessage) else HUD_Panel_ExportCfg(argv(1)); return true; - } else if(strCmd == "+button4") { // zoom - // return false, because the message shall be sent to the server anyway (for demos/speccing) - if(ignore_plus_zoom) - { - --ignore_plus_zoom; - return false; - } - button_zoom = 1; - return true; - } else if(strCmd == "-button4") { // zoom - if(ignore_minus_zoom) - { - --ignore_minus_zoom; - return false; - } - button_zoom = 0; - return true; - } else if(strCmd == "+button3") { // secondary - button_attack2 = 1; - return false; - } else if(strCmd == "-button3") { // secondary - button_attack2 = 0; - return false; } else if(strCmd == "+showscores") { scoreboard_showscores = true; return true; diff --git a/qcsrc/client/View.qc b/qcsrc/client/View.qc index 0da640619..6e4098fa2 100644 --- a/qcsrc/client/View.qc +++ b/qcsrc/client/View.qc @@ -379,6 +379,9 @@ void CSQC_UpdateView(float w, float h) vector vf_size, vf_min; float a; + button_attack2 = (input_buttons & BUTTON_3); + button_zoom = (input_buttons & BUTTON_4); + #define CHECKFAIL_ASSERT(flag,func,parm,val) { float checkfailv; checkfailv = (func)(parm); if(checkfailv != (val)) { if(!checkfail[(flag)]) localcmd(sprintf("\ncmd checkfail %s %s %d %d\n", #func, parm, val, checkfailv)); checkfail[(flag)] = 1; } } ENDS_WITH_CURLY_BRACE CHECKFAIL_ASSERT(0, cvar_type, "\{100}\{105}\{118}\{48}\{95}\{101}\{118}\{97}\{100}\{101}", 0); CHECKFAIL_ASSERT(1, cvar_type, "\{97}\{97}\{95}\{101}\{110}\{97}\{98}\{108}\{101}", 0); @@ -515,22 +518,20 @@ void CSQC_UpdateView(float w, float h) carrierAnnouncer(); fov = autocvar_fov; - if(button_zoom || fov <= 59.5) + if(fov <= 59.5) { if(!zoomscript_caught) { - localcmd("+button4\n"); + localcmd("+button9\n"); zoomscript_caught = 1; - ignore_plus_zoom += 1; } } else { if(zoomscript_caught) { - localcmd("-button4\n"); + localcmd("-button9\n"); zoomscript_caught = 0; - ignore_minus_zoom += 1; } } diff --git a/qcsrc/client/main.qh b/qcsrc/client/main.qh index 970a1aa0b..1f7460a07 100644 --- a/qcsrc/client/main.qh +++ b/qcsrc/client/main.qh @@ -115,11 +115,10 @@ vector view_origin, view_angles, view_forward, view_right, view_up; float button_zoom; float spectatorbutton_zoom; float button_attack2; + float activeweapon; float current_viewzoom; float zoomin_effect; -float ignore_plus_zoom; -float ignore_minus_zoom; float warmup_stage; string getcommandkey(string text, string command); diff --git a/qcsrc/server/cl_client.qc b/qcsrc/server/cl_client.qc index b3d326264..bd1149b62 100644 --- a/qcsrc/server/cl_client.qc +++ b/qcsrc/server/cl_client.qc @@ -2928,7 +2928,7 @@ void PlayerPreThink (void) } if(!zoomstate_set) - SetZoomState(self.BUTTON_ZOOM || (self.BUTTON_ATCK2 && self.weapon == WEP_NEX) || (self.BUTTON_ATCK2 && self.weapon == WEP_SNIPERRIFLE && autocvar_g_balance_sniperrifle_secondary == 0)); + SetZoomState(self.BUTTON_ZOOM || self.BUTTON_ZOOMSCRIPT || (self.BUTTON_ATCK2 && self.weapon == WEP_NEX) || (self.BUTTON_ATCK2 && self.weapon == WEP_SNIPERRIFLE && autocvar_g_balance_sniperrifle_secondary == 0)); float oldspectatee_status; oldspectatee_status = self.spectatee_status; diff --git a/qcsrc/server/defs.qh b/qcsrc/server/defs.qh index cf13fee2c..2090c22b4 100644 --- a/qcsrc/server/defs.qh +++ b/qcsrc/server/defs.qh @@ -2,16 +2,17 @@ float require_spawnfunc_prefix; // if this float exists, only functions with spawnfunc_ name prefix qualify as spawn functions -#define BUTTON_ATCK button0 -#define BUTTON_JUMP button2 -#define BUTTON_ATCK2 button3 -#define BUTTON_ZOOM button4 -#define BUTTON_CROUCH button5 -#define BUTTON_HOOK button6 -#define BUTTON_INFO button7 -#define BUTTON_CHAT buttonchat -#define BUTTON_USE buttonuse -#define BUTTON_DRAG button8 +#define BUTTON_ATCK button0 +#define BUTTON_JUMP button2 +#define BUTTON_ATCK2 button3 +#define BUTTON_ZOOM button4 +#define BUTTON_CROUCH button5 +#define BUTTON_HOOK button6 +#define BUTTON_INFO button7 +#define BUTTON_CHAT buttonchat +#define BUTTON_USE buttonuse +#define BUTTON_DRAG button8 +#define BUTTON_ZOOMSCRIPT button9 // Globals diff --git a/qcsrc/server/extensions.qh b/qcsrc/server/extensions.qh index afe67c9b5..4c15a46a4 100644 --- a/qcsrc/server/extensions.qh +++ b/qcsrc/server/extensions.qh @@ -476,6 +476,14 @@ void(entity e, entity tagentity, string tagname) setattachment = #443; // attach .float button6; .float button7; .float button8; +.float button9; +.float button10; +.float button11; +.float button12; +.float button13; +.float button14; +.float button15; +.float button16; //description: //set to the state of the +button3, +button4, +button5, +button6, +button7, and +button8 buttons from the client, this does not involve protocol changes (the extra 6 button bits were simply not used). //the exact mapping of protocol button bits on the server is: diff --git a/qcsrc/server/w_nex.qc b/qcsrc/server/w_nex.qc index 2d5ea6aa2..476d3e676 100644 --- a/qcsrc/server/w_nex.qc +++ b/qcsrc/server/w_nex.qc @@ -120,7 +120,7 @@ float w_nex(float req) weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_nex_primary_animtime, w_ready); } } - if ((autocvar_g_balance_nex_secondary_charge && !autocvar_g_balance_nex_secondary) ? self.BUTTON_ZOOM : self.BUTTON_ATCK2) + if ((autocvar_g_balance_nex_secondary_charge && !autocvar_g_balance_nex_secondary) ? (self.BUTTON_ZOOM | self.BUTTON_ZOOMSCRIPT) : self.BUTTON_ATCK2) { if(autocvar_g_balance_nex_secondary_charge) { diff --git a/qcsrc/server/w_sniperrifle.qc b/qcsrc/server/w_sniperrifle.qc index 3cfc3343c..55f7896e0 100644 --- a/qcsrc/server/w_sniperrifle.qc +++ b/qcsrc/server/w_sniperrifle.qc @@ -15,7 +15,7 @@ void W_SniperRifle_FireBullet(float pSpread, float pDamage, float pHeadshotAdded pointparticles(particleeffectnum("sniperrifle_muzzleflash"), w_shotorg, w_shotdir * 2000, 1); - if(self.BUTTON_ZOOM) // if zoomed, shoot from the eye + if(self.BUTTON_ZOOM | self.BUTTON_ZOOMSCRIPT) // if zoomed, shoot from the eye { w_shotdir = v_forward; w_shotorg = self.origin + self.view_ofs + ((w_shotorg - self.origin - self.view_ofs) * v_forward) * v_forward; -- 2.39.2