From: Mario Date: Sun, 17 Jun 2018 22:28:02 +0000 (+1000) Subject: Use a constant to define the 'unlimited' resource limit X-Git-Tag: xonotic-v0.8.5~2024 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=e4b829b8248236aa006d4b0e567a0220cdfbab2c;p=xonotic%2Fxonotic-data.pk3dir.git Use a constant to define the 'unlimited' resource limit --- diff --git a/qcsrc/common/resources.qh b/qcsrc/common/resources.qh index 7e81f05dd..8e33c649b 100644 --- a/qcsrc/common/resources.qh +++ b/qcsrc/common/resources.qh @@ -7,6 +7,7 @@ /// \brief Unconditional maximum amount of resources the entity can have. const int RESOURCE_AMOUNT_HARD_LIMIT = 999; +const int RESOURCE_LIMIT_NONE = -1; /// \brief Describes the available resource types. enum diff --git a/qcsrc/server/resources.qc b/qcsrc/server/resources.qc index 20587da9e..3614daf49 100644 --- a/qcsrc/server/resources.qc +++ b/qcsrc/server/resources.qc @@ -11,7 +11,7 @@ float GetResourceLimit(entity e, int resource_type) { if(!IS_PLAYER(e)) - return -1; // no limits on non-players + return RESOURCE_LIMIT_NONE; // no limits on non-players float limit; switch (resource_type) @@ -99,7 +99,7 @@ void SetResourceAmount(entity e, int resource_type, float amount) amount = M_ARGV(2, float); float max_amount = GetResourceLimit(e, resource_type); // TODO: should allow overriding these limits if cheats are enabled! float amount_wasted = 0; - if (amount > max_amount && max_amount >= 0) + if (amount > max_amount && max_amount != RESOURCE_LIMIT_NONE) { amount_wasted = amount - max_amount; amount = max_amount;