]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Add debug in case a weapon causes negative ammo
authorSamual Lenks <samual@xonotic.org>
Sun, 5 Jan 2014 15:54:01 +0000 (10:54 -0500)
committerSamual Lenks <samual@xonotic.org>
Sun, 5 Jan 2014 15:54:01 +0000 (10:54 -0500)
qcsrc/common/weapons/weapons.qc
qcsrc/common/weapons/weapons.qh
qcsrc/server/weapons/weaponsystem.qc

index 425fe5f64aa73a1d03c6a093922741873a1dfb1b..628a70de5eae699a2b0d48280445050ff233fbd1 100644 (file)
@@ -261,6 +261,19 @@ void W_RandomWeapons(entity e, float n)
        e.weapons = result;
 }
 
+string GetAmmoPicture(.float ammotype)
+{
+       switch(ammotype)
+       {
+               case ammo_shells:  return "ammo_shells";
+               case ammo_nails:   return "ammo_nails";
+               case ammo_rockets: return "ammo_rockets";
+               case ammo_cells:   return "ammo_cells";
+               case ammo_fuel:    return "ammo_fuel";
+               default: return ""; // wtf, no ammo type?
+       }
+}
+
 #ifdef CSQC
 .float GetAmmoFieldFromNum(float i)
 {
@@ -275,19 +288,6 @@ void W_RandomWeapons(entity e, float n)
        }
 }
 
-string GetAmmoPicture(.float ammotype)
-{
-       switch(ammotype)
-       {
-               case ammo_shells:  return "ammo_shells";
-               case ammo_nails:   return "ammo_nails";
-               case ammo_rockets: return "ammo_rockets";
-               case ammo_cells:   return "ammo_cells";
-               case ammo_fuel:    return "ammo_fuel";
-               default: return ""; // wtf, no ammo type?
-       }
-}
-
 float GetAmmoStat(.float ammotype)
 {
        switch(ammotype)
index ba2e8a15e1cd7d63f23fd975759e64100eaf78b7..720f65f6ea4e41fb1a9a004893a8d3a21ac360e3 100644 (file)
@@ -72,9 +72,10 @@ string W_FixWeaponOrder_AllowIncomplete(string order);
 string W_FixWeaponOrder_ForceComplete(string order);
 void W_RandomWeapons(entity e, float n);
 
+string GetAmmoPicture(.float ammotype);
+
 #ifdef CSQC
 .float GetAmmoFieldFromNum(float i);
-string GetAmmoPicture(.float ammotype);
 float GetAmmoStat(.float ammotype);
 #endif
 
index e99c450ec0a64fdf6192135e306eb781bb3f3364..70b916cedbe4bf50eae97b988b2af5335f9e0ee1 100644 (file)
@@ -813,7 +813,21 @@ void W_DecreaseAmmo(float ammo_use)
                self.(weapon_load[self.weapon]) = self.clip_load;
        }
        else
+       {
                self.(wep.ammo_field) -= ammo_use;
+               if(self.(wep.ammo_field) < 0)
+               {
+                       backtrace(sprintf(
+                               "W_DecreaseAmmo(%.2f): '%s' subtracted too much %s from '%s', resulting with '%.2f' left... "
+                               "Please notify Samual immediately with a copy of this backtrace!\n",
+                               ammo_use,
+                               wep.netname,
+                               GetAmmoPicture(wep.ammo_field),
+                               self.netname,
+                               self.(wep.ammo_field)
+                       ));
+               }
+       }
 }
 
 // weapon reloading code