From: Lyberta Date: Mon, 28 Aug 2017 05:10:18 +0000 (+0300) Subject: URS: Added player argument to GetResourceLimit. X-Git-Tag: xonotic-v0.8.5~2488^2~22 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=08a497d2f4f9c84e7a27c490f629c372ba59f87a;p=xonotic%2Fxonotic-data.pk3dir.git URS: Added player argument to GetResourceLimit. --- diff --git a/qcsrc/common/t_items.qc b/qcsrc/common/t_items.qc index 95f315ad2..458a0dcb2 100644 --- a/qcsrc/common/t_items.qc +++ b/qcsrc/common/t_items.qc @@ -716,7 +716,7 @@ int GetResourceType(.float resource_property) return health; } -float GetResourceLimit(int resource_type) +float GetResourceLimit(entity player, int resource_type) { float limit; switch (resource_type) @@ -767,8 +767,8 @@ float GetResourceLimit(int resource_type) return 0; } } - MUTATOR_CALLHOOK(GetResourceLimit, resource_type, limit); - limit = M_ARGV(1, float); + MUTATOR_CALLHOOK(GetResourceLimit, player, resource_type, limit); + limit = M_ARGV(2, float); if (limit > RESOURCE_AMOUNT_HARD_LIMIT) { limit = RESOURCE_AMOUNT_HARD_LIMIT; @@ -791,7 +791,7 @@ void GivePlayerResource(entity player, int resource_type, float amount) resource_type = M_ARGV(1, int); amount = M_ARGV(2, float); .float resource_property = GetResourceProperty(resource_type); - float max_amount = GetResourceLimit(resource_type); + float max_amount = GetResourceLimit(player, resource_type); player.(resource_property) = bound(player.(resource_property), player.(resource_property) + amount, max_amount); switch (resource_type) diff --git a/qcsrc/common/t_items.qh b/qcsrc/common/t_items.qh index 38598e098..613a78dde 100644 --- a/qcsrc/common/t_items.qh +++ b/qcsrc/common/t_items.qh @@ -111,9 +111,10 @@ int GetResourceType(.float resource_property); .float GetResourceProperty(int resource_type); /// \brief Returns the maximum amount of the given resource. +/// \param[in] player Player to check. /// \param[in] resource_type Type of the resource (a RESOURCE_* constant). /// \return Maximum amount of the given resource. -float GetResourceLimit(int resource_type); +float GetResourceLimit(entity player, int resource_type); /// \brief Gives player a resource such as health, armor or ammo. /// \param[in,out] player Player to give resource to. diff --git a/qcsrc/server/client.qc b/qcsrc/server/client.qc index 9d4df94e7..b7d3a294c 100644 --- a/qcsrc/server/client.qc +++ b/qcsrc/server/client.qc @@ -1628,8 +1628,8 @@ void player_regen(entity this) float mina, maxa, limith, limita; maxa = autocvar_g_balance_armor_rotstable; mina = autocvar_g_balance_armor_regenstable; - limith = GetResourceLimit(RESOURCE_HEALTH); - limita = GetResourceLimit(RESOURCE_ARMOR); + limith = GetResourceLimit(this, RESOURCE_HEALTH); + limita = GetResourceLimit(this, RESOURCE_ARMOR); regen_health_rotstable = regen_health_rotstable * max_mod; regen_health_stable = regen_health_stable * max_mod; @@ -1656,7 +1656,7 @@ void player_regen(entity this) maxf = autocvar_g_balance_fuel_rotstable; minf = autocvar_g_balance_fuel_regenstable; - limitf = GetResourceLimit(RESOURCE_FUEL); + limitf = GetResourceLimit(this, RESOURCE_FUEL); this.ammo_fuel = CalcRotRegen(this.ammo_fuel, minf, autocvar_g_balance_fuel_regen, autocvar_g_balance_fuel_regenlinear, frametime * (time > this.pauseregen_finished) * ((this.items & ITEM_JetpackRegen.m_itemid) != 0), maxf, autocvar_g_balance_fuel_rot, autocvar_g_balance_fuel_rotlinear, frametime * (time > this.pauserotfuel_finished), limitf); } diff --git a/qcsrc/server/mutators/events.qh b/qcsrc/server/mutators/events.qh index eddb1e5ca..6c286c607 100644 --- a/qcsrc/server/mutators/events.qh +++ b/qcsrc/server/mutators/events.qh @@ -623,9 +623,10 @@ enum { /** Called when the amount of player resources changes. Can be used to override resource limit. */ #define EV_GetResourceLimit(i, o) \ - /** resource type */ i(int, MUTATOR_ARGV_0_int) \ - /** limit */ i(float, MUTATOR_ARGV_1_float) \ - /**/ o(float, MUTATOR_ARGV_1_float) \ + /** player */ i(entity, MUTATOR_ARGV_0_entity) \ + /** resource type */ i(int, MUTATOR_ARGV_1_int) \ + /** limit */ i(float, MUTATOR_ARGV_2_float) \ + /**/ o(float, MUTATOR_ARGV_2_float) \ /**/ MUTATOR_HOOKABLE(GetResourceLimit, EV_GetResourceLimit);