]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Moved HARD_LIMIT check into player_regen.
authorLyberta <lyberta@lyberta.net>
Sat, 26 Aug 2017 16:33:07 +0000 (19:33 +0300)
committerLyberta <lyberta@lyberta.net>
Sat, 26 Aug 2017 16:33:07 +0000 (19:33 +0300)
qcsrc/common/t_items.qc
qcsrc/common/t_items.qh
qcsrc/server/client.qc

index 709cccd430f50a02d57bfa1cc65a6bceee608e66..9a6d4e397ede709f7c39178337cd06b3df751330 100644 (file)
@@ -34,9 +34,6 @@
 
 REGISTER_NET_LINKED(ENT_CLIENT_ITEM)
 
-/// \brief Unconditional maximum amount of items the player can have.
-const int ITEM_COUNT_HARD_LIMIT = 999; 
-
 #ifdef CSQC
 bool autocvar_cl_ghost_items_vehicle = true;
 .vector item_glowmod;
@@ -657,8 +654,14 @@ void GivePlayerHealth(entity player, float amount)
        {
                return;
        }
+       // Ugly hack. We do not check if health goes beyond hard limit since
+       // currently it is done in player_regen. We need to bring back this check
+       // when other code is ported to this function.
        player.health = bound(player.health, player.health + amount,
-                min(autocvar_g_balance_health_limit, ITEM_COUNT_HARD_LIMIT));
+               autocvar_g_balance_health_limit);
+       // Correct code:
+       //player.health = bound(player.health, player.health + amount,
+       //      min(autocvar_g_balance_health_limit, ITEM_COUNT_HARD_LIMIT));
        player.pauserothealth_finished = max(player.pauserothealth_finished, time +
                autocvar_g_balance_pause_health_rot);
 }
@@ -669,8 +672,14 @@ void GivePlayerArmor(entity player, float amount)
        {
                return;
        }
+       // Ugly hack. We do not check if armor goes beyond hard limit since
+       // currently it is done in player_regen. We need to bring back this check
+       // when other code is ported to this function.
        player.armorvalue = bound(player.armorvalue, player.armorvalue + amount,
-                min(autocvar_g_balance_armor_limit, ITEM_COUNT_HARD_LIMIT));
+               autocvar_g_balance_armor_limit);
+       // Correct code:
+       //player.armorvalue = bound(player.armorvalue, player.armorvalue + amount,
+       //      min(autocvar_g_balance_armor_limit, ITEM_COUNT_HARD_LIMIT));
        player.pauserotarmor_finished = max(player.pauserotarmor_finished, time +
                autocvar_g_balance_pause_armor_rot);
 }
@@ -705,11 +714,6 @@ void GivePlayerAmmo(entity player, .float ammotype, float amount)
                        maxvalue = g_pickup_nails_max;
                        break;
                }
-               case ammo_fuel:
-               {
-                       maxvalue = g_pickup_fuel_max;
-                       break;
-               }
        }
        player.(ammotype) = min(player.(ammotype) + amount,
                min(maxvalue, ITEM_COUNT_HARD_LIMIT));
index 777258939e2969f99576490dce76c62e45934be8..41843306f7bfdbc1ca97001894b78b883ba5b094 100644 (file)
@@ -4,6 +4,9 @@
 #include <server/defs.qh>
 #endif
 
+/// \brief Unconditional maximum amount of items the player can have.
+const int ITEM_COUNT_HARD_LIMIT = 999;
+
 const int AMMO_COUNT = 4; // amount of ammo types to show in the inventory panel
 
 // item networking
index b0eb75ae41bd1c1954a3bdad671924a5133b947c..143514c2e4655c0394a6c3968606fbd80f499962 100644 (file)
@@ -1622,6 +1622,12 @@ void player_regen(entity this)
        regen_health_stable = M_ARGV(9, float);
        regen_health_rotstable = M_ARGV(10, float);
 
+       // Ugly hack to make sure the haelth and armor don't go beyond hard limit.
+       // TODO: Remove this hack when all code uses GivePlayerHealth and
+       // GivePlayerArmor.
+       this.health = bound(0, this.health, ITEM_COUNT_HARD_LIMIT);
+       this.armorvalue = bound(0, this.armorvalue, ITEM_COUNT_HARD_LIMIT);
+       // End hack.
 
        if(!mutator_returnvalue)
        if(!STAT(FROZEN, this))