From: Mario Date: Wed, 5 Oct 2016 11:48:09 +0000 (+1000) Subject: Clean up some slot 0 cases on client (fixes reticles) X-Git-Tag: xonotic-v0.8.2~326^2~56 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=8f88a1a2f467d3e1f02ce14af4083ea3f58d999b;p=xonotic%2Fxonotic-data.pk3dir.git Clean up some slot 0 cases on client (fixes reticles) --- diff --git a/qcsrc/client/hud/hud.qh b/qcsrc/client/hud/hud.qh index 4cd0ee88e..58e6a1b7d 100644 --- a/qcsrc/client/hud/hud.qh +++ b/qcsrc/client/hud/hud.qh @@ -90,8 +90,8 @@ float complain_weapon_time; PlayerScoreField ps_primary, ps_secondary; int ts_primary, ts_secondary; -Weapon last_switchweapon; -Weapon last_activeweapon; +.Weapon last_switchweapon; +.Weapon last_activeweapon; float weapontime; float weaponprevtime; diff --git a/qcsrc/client/view.qc b/qcsrc/client/view.qc index def064d49..93c632e70 100644 --- a/qcsrc/client/view.qc +++ b/qcsrc/client/view.qc @@ -1782,33 +1782,36 @@ void CSQC_UpdateView(entity this, float w, float h) ColorTranslateMode = autocvar_cl_stripcolorcodes; - entity wepent = viewmodels[0]; // TODO: unhardcode - - if(last_switchweapon != wepent.switchweapon) + for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot) { - weapontime = time; - last_switchweapon = wepent.switchweapon; - if(button_zoom && autocvar_cl_unpress_zoom_on_weapon_switch) + entity wepent = viewmodels[slot]; + + if(wepent.last_switchweapon != wepent.switchweapon) { - localcmd("-zoom\n"); - button_zoom = false; + weapontime = time; + wepent.last_switchweapon = wepent.switchweapon; + if(slot == 0 && button_zoom && autocvar_cl_unpress_zoom_on_weapon_switch) + { + localcmd("-zoom\n"); + button_zoom = false; + } + if(slot == 0 && autocvar_cl_unpress_attack_on_weapon_switch) + { + localcmd("-fire\n"); + localcmd("-fire2\n"); + button_attack2 = false; + } } - if(autocvar_cl_unpress_attack_on_weapon_switch) + if(wepent.last_activeweapon != wepent.activeweapon) { - localcmd("-fire\n"); - localcmd("-fire2\n"); - button_attack2 = false; - } - } - if(last_activeweapon != wepent.activeweapon) - { - last_activeweapon = wepent.activeweapon; + wepent.last_activeweapon = wepent.activeweapon; - e = wepent.activeweapon; - if(e.netname != "") - localcmd(strcat("\ncl_hook_activeweapon ", e.netname), "\n"); - else - localcmd("\ncl_hook_activeweapon none\n"); + e = wepent.activeweapon; + if(e.netname != "") + localcmd(strcat("\ncl_hook_activeweapon ", e.netname), "\n"); + else if(slot == 0) + localcmd("\ncl_hook_activeweapon none\n"); + } } // ALWAYS Clear Current Scene First @@ -1936,7 +1939,7 @@ void CSQC_UpdateView(entity this, float w, float h) if(autocvar_cl_reticle) { - string reticle_image = wepent.activeweapon.w_reticle; + string reticle_image = ""; bool wep_zoomed = false; for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot) { @@ -1945,7 +1948,8 @@ void CSQC_UpdateView(entity this, float w, float h) if(wep != WEP_Null && wep.wr_zoom) { bool do_zoom = wep.wr_zoom(wep, NULL); - reticle_image = wep.w_reticle; + if(wep.w_reticle && wep.w_reticle != "") + reticle_image = wep.w_reticle; wep_zoomed += do_zoom; } }