]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/client/hud.qc
weaponpriority vs HUD fixes (a lot of them)
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / hud.qc
index 8a6c174e5be89d4634a80c29a30f78ccdaba924a..ffdd6a525b75949df1ed119ded896c8b59a3c93e 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);