From e4b829b8248236aa006d4b0e567a0220cdfbab2c Mon Sep 17 00:00:00 2001 From: Mario Date: Mon, 18 Jun 2018 08:28:02 +1000 Subject: [PATCH] Use a constant to define the 'unlimited' resource limit --- qcsrc/common/resources.qh | 1 + qcsrc/server/resources.qc | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) 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; -- 2.39.2