weaponpriority vs HUD fixes (a lot of them)
authorRudolf Polzer <divverent@alientrap.org>
Wed, 16 Jun 2010 18:58:04 +0000 (20:58 +0200)
committerRudolf Polzer <divverent@alientrap.org>
Wed, 16 Jun 2010 19:17:33 +0000 (21:17 +0200)
defaultXonotic.cfg
qcsrc/client/Main.qc
qcsrc/client/csqc_builtins.qc
qcsrc/client/hud.qc
qcsrc/common/items.qc
qcsrc/common/items.qh
qcsrc/server/cl_weapons.qc

index 73a9761..deac3f5 100644 (file)
@@ -916,18 +916,15 @@ alias +zoom +button4
 alias -zoom -button4
 alias +crouch +button5
 alias -crouch -button5
-alias weapnext "_weapnext_${_supports_weaponpriority}${cl_weaponpriority_useforcycling}"
-alias _weapnext_00 "impulse 10"
-alias _weapnext_01 "impulse 10"
-alias _weapnext_10 "impulse 10"
-alias _weapnext_11 "impulse 15"
+alias weapnext "_weapnext_${cl_weaponpriority_useforcycling}"
+alias _weapnext_0 "impulse 18"
+alias _weapnext_1 "impulse 15"
+alias _weapnext_2 "impulse 10"
 alias weaplast "impulse 11"
-alias weapprev "_weapprev_${_supports_weaponpriority}${cl_weaponpriority_useforcycling}"
-alias _weapprev_00 "impulse 12"
-alias _weapprev_01 "impulse 12"
-alias _weapprev_10 "impulse 12"
-alias _weapprev_11 "impulse 16"
-set _supports_weaponpriority 0 "set to 1 by csqc if supported, and to 0 on disconnect"
+alias weapprev "_weapprev_${cl_weaponpriority_useforcycling}"
+alias _weapprev_0 "impulse 19"
+alias _weapprev_1 "impulse 16"
+alias _weapprev_2 "impulse 12"
 alias weapbest "impulse 13"
 
 alias reload "impulse 20"
@@ -1668,7 +1665,7 @@ alias allready "sv_cmd allready"
 
 // note: these cvars use weapon NUMBERS. Use the menu to edit this cvar, or look the numbers up in qcsrc/common/constants.qh.
 seta cl_weaponpriority "minstanex rocketlauncher nex grenadelauncher fireball hlac hagar seeker crylink campingrifle uzi electro tuba shotgun laser hook porto" "weapon priority list"
-seta cl_weaponpriority_useforcycling 0 "when set, weapon cycling by the mouse wheel makes use of the weapon priority list"
+seta cl_weaponpriority_useforcycling 0 "when set, weapon cycling by the mouse wheel makes use of the weapon priority list (the special value 2 uses the weapon ID list for cycling)"
 seta cl_weaponpriority0 "rocketlauncher grenadelauncher hagar seeker fireball" "use impulse 200 for prev gun from this list, 210 for best gun, 220 for next gun.  Default value: explosives"
 seta cl_weaponpriority1 "minstanex nex crylink hlac electro laser"             "use impulse 201 for prev gun from this list, 211 for best gun, 221 for next gun.  Default value: energy"
 seta cl_weaponpriority2 "minstanex nex campingrifle"                           "use impulse 202 for prev gun from this list, 212 for best gun, 222 for next gun.  Default value: hitscan exact"
index bf903bd..2749790 100644 (file)
@@ -130,8 +130,6 @@ void CSQC_Init(void)
 
        GetTeam(COLOR_SPECTATOR, true); // add specs first
 
-       cvar_clientsettemp("_supports_weaponpriority", "1");
-
        RegisterWeapons();
 
        WaypointSprite_Load();
index 603ac55..ec2ab9a 100644 (file)
@@ -317,3 +317,4 @@ float particles_alphamin, particles_alphamax;
 #define PARTICLES_USECOLOR 2
 vector particles_colormin, particles_colormax;
 void(float effectindex, entity own, vector org_from, vector org_to, vector dir_from, vector dir_to, float countmultiplier, float flags)        boxparticles = #502;
+string(string format, ...) sprintf = #627;
index 8a6c174..ffdd6a5 100644 (file)
@@ -1453,14 +1453,13 @@ void weaponorder_swap(float i, float j, entity pass)
        weaponorder[j] = h;
 }
 
+string weaponorder_cmp_str;
 float weaponorder_cmp(float i, float j, entity pass)
 {
-       float d;
-       d = mod(weaponorder[i].impulse + 9, 10) - mod(weaponorder[j].impulse + 9, 10);
-       if(d)
-               return d;
-       d = weaponorder[i].weapon - weaponorder[j].weapon;
-       return d;
+       float ai, aj;
+       ai = strstrofs(weaponorder_cmp_str, sprintf(" %d ", weaponorder[i].weapon), 0);
+       aj = strstrofs(weaponorder_cmp_str, sprintf(" %d ", weaponorder[j].weapon), 0);
+       return aj - ai; // the string is in REVERSE order (higher prio at the right is what we want, but higher prio first is the string)
 }
 
 void HUD_WeaponIcons(void)
@@ -1483,6 +1482,9 @@ void HUD_WeaponIcons(void)
                        ++weapon_cnt;
                }
        }
+
+       // TODO make this configurable
+       weaponorder_cmp_str = strcat(" ", weaponorder_byimpulse, " ");
        heapsort(weapon_cnt, weaponorder_swap, weaponorder_cmp, world);
 
        HUD_Panel_DrawBg(id, pos, mySize, 0);
index e9ff445..0f1237d 100644 (file)
@@ -43,29 +43,29 @@ void register_weapons_done()
        dummy_weapon_info.model2 = "";
 
        float i;
-       weaponpriority_hudselector_0 = "";
+       weaponorder_byid = "";
        for(i = 24; i >= 1; --i)
                if(weapon_info[i-1])
-                       weaponpriority_hudselector_0 = strcat(weaponpriority_hudselector_0, " ", ftos(i));
+                       weaponorder_byid = strcat(weaponorder_byid, " ", ftos(i));
 
        float imp;
-       weaponpriority_hudselector_1 = "";
+       weaponorder_byimpulse = "";
        for(i = 1; i <= 24; ++i)
        {
                wi = weapon_info[i-1];
                if(wi && wi.impulse == 0)
-                       weaponpriority_hudselector_1 = strcat(weaponpriority_hudselector_1, " ", ftos(i));
+                       weaponorder_byimpulse = strcat(weaponorder_byimpulse, " ", ftos(i));
        }
        for(imp = 9; imp > 0; --imp)
                for(i = 1; i <= 24; ++i)
                {
                        wi = weapon_info[i-1];
                        if(wi && wi.impulse == imp)
-                               weaponpriority_hudselector_1 = strcat(weaponpriority_hudselector_1, " ", ftos(i));
+                               weaponorder_byimpulse = strcat(weaponorder_byimpulse, " ", ftos(i));
                }
 
-       weaponpriority_hudselector_0 = strzone(substring(weaponpriority_hudselector_0, 1, strlen(weaponpriority_hudselector_0) - 1));
-       weaponpriority_hudselector_1 = strzone(substring(weaponpriority_hudselector_1, 1, strlen(weaponpriority_hudselector_1) - 1));
+       weaponorder_byid = strzone(substring(weaponorder_byid, 1, strlen(weaponorder_byid) - 1));
+       weaponorder_byimpulse = strzone(substring(weaponorder_byimpulse, 1, strlen(weaponorder_byimpulse) - 1));
 }
 entity get_weaponinfo(float id)
 {
index 531a311..a410474 100644 (file)
@@ -50,8 +50,8 @@ float IT_PICKUPMASK           = 51; // IT_FUEL_REGEN | IT_JETPACK | IT_UNLIMITED
 float  IT_UNLIMITED_AMMO       = 3; // IT_UNLIMITED_SUPERWEAPONS | IT_UNLIMITED_WEAPON_AMMO;
 
 // variables:
-string weaponpriority_hudselector_0;
-string weaponpriority_hudselector_1;
+string weaponorder_byid;
+string weaponorder_byimpulse;
 
 // functions:
 entity get_weaponinfo(float id);
index 04b656c..4ab7abd 100644 (file)
@@ -121,9 +121,9 @@ void W_NextWeaponOnImpulse(float imp)
 void W_NextWeapon(float list)
 {
        if(list == 0)
-               W_CycleWeapon(weaponpriority_hudselector_0, -1);
+               W_CycleWeapon(weaponorder_byid, -1);
        else if(list == 1)
-               W_CycleWeapon(weaponpriority_hudselector_1, -1);
+               W_CycleWeapon(weaponorder_byimpulse, -1);
        else if(list == 2)
                W_CycleWeapon(self.cvar_cl_weaponpriority, -1);
 }
@@ -132,9 +132,9 @@ void W_NextWeapon(float list)
 void W_PreviousWeapon(float list)
 {
        if(list == 0)
-               W_CycleWeapon(weaponpriority_hudselector_0, +1);
+               W_CycleWeapon(weaponorder_byid, +1);
        else if(list == 1)
-               W_CycleWeapon(weaponpriority_hudselector_1, +1);
+               W_CycleWeapon(weaponorder_byimpulse, +1);
        else if(list == 2)
                W_CycleWeapon(self.cvar_cl_weaponpriority, +1);
 }