]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/weapons/selection.qh
Add REPLICATE_APPLYCHANGE macro
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / weapons / selection.qh
index 093d6612b348052416bbf609e26217583914b398..3e28b47455cd0413d1529ab0f779df2f7cfb7f91 100644 (file)
@@ -41,3 +41,13 @@ void W_PreviousWeapon(entity this, float list, .entity weaponentity);
 
 // previously used if exists and has ammo, (second) best otherwise
 void W_LastWeapon(entity this, .entity weaponentity);
+
+// fix switchweapon (needed when spectating is disabled, as PutClientInServer comes too early)
+REPLICATE_APPLYCHANGE("cl_weaponpriority",
+       for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
+       {
+               .entity weaponentity = weaponentities[slot];
+               if (this.(weaponentity) && (this.(weaponentity).m_weapon != WEP_Null || slot == 0))
+                       this.(weaponentity).m_switchweapon = w_getbestweapon(this, weaponentity);
+       }
+);