]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Refactor Item_GiveAmmoTo a little bit to reduce duplicated code
authorterencehill <piuntn@gmail.com>
Fri, 22 Feb 2019 18:13:05 +0000 (19:13 +0100)
committerterencehill <piuntn@gmail.com>
Fri, 22 Feb 2019 18:13:05 +0000 (19:13 +0100)
qcsrc/common/t_items.qc

index bce35c7dd78f5a3c56e53bb9f754bb65ec49a9a7..c309ed35d404733c241af350705004d587d0793f 100644 (file)
@@ -743,23 +743,16 @@ bool Item_GiveAmmoTo(entity item, entity player, int res_type, float ammomax)
        if (item.spawnshieldtime)
        {
                if ((player_amount >= ammomax) && (item.pickup_anyway <= 0))
-               {
                        return false;
-               }
-               if (amount < 0)
-                       TakeResourceWithLimit(player, res_type, -amount, ammomax);
-               else
-                       GiveResourceWithLimit(player, res_type, amount, ammomax);
-               return true;
        }
-       if (g_weapon_stay != 2)
-       {
+       else if (g_weapon_stay == 2)
+               ammomax = min(amount, ammomax);
+       else
                return false;
-       }
        if (amount < 0)
-               TakeResourceWithLimit(player, res_type, -amount, min(amount, ammomax));
+               TakeResourceWithLimit(player, res_type, -amount, ammomax);
        else
-               GiveResourceWithLimit(player, res_type, amount, min(amount, ammomax));
+               GiveResourceWithLimit(player, res_type, amount, ammomax);
        return true;
 }