From: terencehill Date: Wed, 9 Aug 2023 12:25:52 +0000 (+0200) Subject: StatusEffects_gettime now returns current time if end time is < current time since... X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=ee1f689b397abca64c2013c8ae70f5ca44469aef;p=xonotic%2Fxonotic-data.pk3dir.git StatusEffects_gettime now returns current time if end time is < current time since in the last frame, right before effect removal, even thought end time has passed the effect is still active. It prevents wrong usage of the returned value, e.g. in Fire_AddDamage mintime can be set to a negative value and used to apply a negative damage to the player --- diff --git a/qcsrc/common/mutators/mutator/status_effects/status_effects.qc b/qcsrc/common/mutators/mutator/status_effects/status_effects.qc index 2079182ac..9047df178 100644 --- a/qcsrc/common/mutators/mutator/status_effects/status_effects.qc +++ b/qcsrc/common/mutators/mutator/status_effects/status_effects.qc @@ -21,7 +21,10 @@ float StatusEffects_gettime(StatusEffects this, entity actor) store = actor.statuseffects; #endif if(!store) return 0; - return store.statuseffect_time[this.m_id]; + float eff_time = store.statuseffect_time[this.m_id]; + // if effect end time has passed and m_tick hasn't removed the effect yet + // return current time since the effect is actually still active in this frame + return (eff_time < time ? time : eff_time); } #endif #ifdef SVQC diff --git a/qcsrc/server/client.qc b/qcsrc/server/client.qc index 00063bba2..db1af076e 100644 --- a/qcsrc/server/client.qc +++ b/qcsrc/server/client.qc @@ -1530,7 +1530,7 @@ void player_powerups(entity this) else { play_countdown(this, StatusEffects_gettime(STATUSEFFECT_Superweapons, this), SND_POWEROFF); - if (time > StatusEffects_gettime(STATUSEFFECT_Superweapons, this)) + if (time >= StatusEffects_gettime(STATUSEFFECT_Superweapons, this)) { this.items = this.items - (this.items & IT_SUPERWEAPON); STAT(WEAPONS, this) &= ~WEPSET_SUPERWEAPONS;