From: Rudolf Polzer Date: Wed, 27 Oct 2010 16:34:10 +0000 (+0200) Subject: multiple fixes for the weapon priority management X-Git-Tag: xonotic-v0.1.0preview~238^2~7 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=420822f1010a27c370d3a4f2483b4c8c1d0d748b;p=xonotic%2Fxonotic-data.pk3dir.git multiple fixes for the weapon priority management --- diff --git a/qcsrc/client/Defs.qc b/qcsrc/client/Defs.qc index 0fcd33773..0d822e164 100644 --- a/qcsrc/client/Defs.qc +++ b/qcsrc/client/Defs.qc @@ -266,3 +266,4 @@ float cr_maxbullets; float bgmtime; string weaponorder_byimpulse; +string weaponorder_bypriority; diff --git a/qcsrc/client/Main.qc b/qcsrc/client/Main.qc index 897626a4e..9c50d7a34 100644 --- a/qcsrc/client/Main.qc +++ b/qcsrc/client/Main.qc @@ -338,8 +338,6 @@ void PostInit(void) Porto_Init(); TrueAim_Init(); - weaponorder_byimpulse = W_FixWeaponOrder_BuildImpulseList(W_FixWeaponOrder_ForceComplete(W_NumberWeaponOrder(cvar_string("cl_weaponpriority")))); - postinit = true; } diff --git a/qcsrc/client/hud.qc b/qcsrc/client/hud.qc index 3d2ba9f2b..4272aefbb 100644 --- a/qcsrc/client/hud.qc +++ b/qcsrc/client/hud.qc @@ -1448,7 +1448,6 @@ void weaponorder_swap(float i, float j, entity pass) weaponorder[j] = h; } -string weaponorder_cmp_str_save; string weaponorder_cmp_str; float weaponorder_cmp(float i, float j, entity pass) { @@ -1597,13 +1596,17 @@ void HUD_Weapons(void) } // TODO make this configurable - weaponorder_cmp_str = strcat(" ", weaponorder_byimpulse, " "); - - if(weaponorder_cmp_str != weaponorder_cmp_str_save) + if(weaponorder_bypriority != cvar_string("cl_weaponpriority")) { - if(weaponorder_cmp_str_save) - strunzone(weaponorder_cmp_str_save); - weaponorder_cmp_str_save = strzone(weaponorder_cmp_str); + if(weaponorder_bypriority) + strunzone(weaponorder_bypriority); + if(weaponorder_byimpulse) + strunzone(weaponorder_byimpulse); + + weaponorder_bypriority = strzone(cvar_string("cl_weaponpriority")); + weaponorder_byimpulse = strzone(W_FixWeaponOrder_BuildImpulseList(W_FixWeaponOrder_ForceComplete(W_NumberWeaponOrder(weaponorder_bypriority)))); + weaponorder_cmp_str = strcat(" ", weaponorder_byimpulse, " "); + weapon_cnt = 0; for(i = WEP_FIRST; i <= WEP_LAST; ++i) { @@ -1615,6 +1618,8 @@ void HUD_Weapons(void) } } heapsort(weapon_cnt, weaponorder_swap, weaponorder_cmp, world); + + weaponorder_cmp_str = string_null; } HUD_Panel_DrawBg(1); diff --git a/qcsrc/server/miscfunctions.qc b/qcsrc/server/miscfunctions.qc index d774958ad..fd3f38458 100644 --- a/qcsrc/server/miscfunctions.qc +++ b/qcsrc/server/miscfunctions.qc @@ -581,9 +581,7 @@ void GetCvars_handleFloatOnce(string thisname, float f, .float field, string nam stuffcmd(self, strcat("cl_cmd sendcvar ", name, "\n")); } } -string W_FixWeaponOrder_ForceComplete(string s); -string W_FixWeaponOrder_AllowIncomplete(string s); -string W_FixWeaponOrder_BuildImpulseList(string s); +float w_getbestweapon(entity e); string W_FixWeaponOrder_ForceComplete_AndBuildImpulseList(string wo) { string o, s;