]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
StatusEffects_gettime now returns current time if end time is < current time since... terencehill/status_effect_fix_test
authorterencehill <piuntn@gmail.com>
Wed, 9 Aug 2023 12:25:52 +0000 (14:25 +0200)
committerterencehill <piuntn@gmail.com>
Wed, 9 Aug 2023 12:25:52 +0000 (14:25 +0200)
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

qcsrc/common/mutators/mutator/status_effects/status_effects.qc
qcsrc/server/client.qc

index 2079182ac3e9c3935ed9ddcb08e43e646cb7275b..9047df17814de64ededdfa0eb3d257c1d63bd919 100644 (file)
@@ -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
index 00063bba214fae3ba064a144ec18bf2983db2eae..db1af076eef13722056df6a813d5c2148f373896 100644 (file)
@@ -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;