From: Lyberta Date: Sat, 26 Aug 2017 16:33:07 +0000 (+0300) Subject: Moved HARD_LIMIT check into player_regen. X-Git-Tag: xonotic-v0.8.5~2499^2~9 X-Git-Url: http://de.git.xonotic.org/?a=commitdiff_plain;h=9e14789bb5952a9afb3044912954247a43fd5a74;p=xonotic%2Fxonotic-data.pk3dir.git Moved HARD_LIMIT check into player_regen. --- diff --git a/qcsrc/common/t_items.qc b/qcsrc/common/t_items.qc index 709cccd43..9a6d4e397 100644 --- a/qcsrc/common/t_items.qc +++ b/qcsrc/common/t_items.qc @@ -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)); diff --git a/qcsrc/common/t_items.qh b/qcsrc/common/t_items.qh index 777258939..41843306f 100644 --- a/qcsrc/common/t_items.qh +++ b/qcsrc/common/t_items.qh @@ -4,6 +4,9 @@ #include #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 diff --git a/qcsrc/server/client.qc b/qcsrc/server/client.qc index b0eb75ae4..143514c2e 100644 --- a/qcsrc/server/client.qc +++ b/qcsrc/server/client.qc @@ -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))