From: terencehill Date: Fri, 22 Feb 2019 18:13:05 +0000 (+0100) Subject: Refactor Item_GiveAmmoTo a little bit to reduce duplicated code X-Git-Tag: xonotic-v0.8.5~1591 X-Git-Url: http://de.git.xonotic.org/?a=commitdiff_plain;h=b4c80fa2d1073436bf9cf31ad3e6a14a86449b2a;p=xonotic%2Fxonotic-data.pk3dir.git Refactor Item_GiveAmmoTo a little bit to reduce duplicated code --- diff --git a/qcsrc/common/t_items.qc b/qcsrc/common/t_items.qc index bce35c7dd..c309ed35d 100644 --- a/qcsrc/common/t_items.qc +++ b/qcsrc/common/t_items.qc @@ -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; }