]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Use a constant to define the 'unlimited' resource limit
authorMario <mario@smbclan.net>
Sun, 17 Jun 2018 22:28:02 +0000 (08:28 +1000)
committerMario <mario@smbclan.net>
Sun, 17 Jun 2018 22:28:02 +0000 (08:28 +1000)
qcsrc/common/resources.qh
qcsrc/server/resources.qc

index 7e81f05dd8d135ebb01896a05c1e3f32562764be..8e33c649b3bf5e68e09b5050252f53f48002e8b7 100644 (file)
@@ -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
index 20587da9ec9b576f588af68a19f91f8e4c29baff..3614daf49e9fc1f4778c411d39e104ff656c93e7 100644 (file)
@@ -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;