]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
StatusEffects_gettime now returns current time if end time is < current time because... terencehill/status_effect_fix 1228/head
authorterencehill <piuntn@gmail.com>
Sun, 24 Mar 2024 22:09:46 +0000 (23:09 +0100)
committerterencehill <piuntn@gmail.com>
Sun, 24 Mar 2024 22:09:46 +0000 (23:09 +0100)
It prevents wrong usage of the returned value, for example in Fire_AddDamage where 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 2bb18247e53b5d23bfa0aaf4086f42f213fd2cad..70b2461f539175098b69ac0725dc38f721e108d6 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 6a39e4538d3d42202e15cdfe929e2a59e69b16c4..89deedaf750c16359cf4ab9325424cd0e7d24bf5 100644 (file)
@@ -1534,7 +1534,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;