From: terencehill Date: Fri, 18 Apr 2025 21:23:43 +0000 (+0200) Subject: Fix g_nades_ice_explode 1 and g_nades_darkness_explode 1 spamming div by 0 warnings... X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=refs%2Fheads%2Fterencehill%2Fnade_timer_fix;p=xonotic%2Fxonotic-data.pk3dir.git Fix g_nades_ice_explode 1 and g_nades_darkness_explode 1 spamming div by 0 warnings and showing a nade timer with the wrong values Regarding ice.qc and darknes.qc the only functional change is the addition of `timer.nade_lifetime = this.nade_lifetime;`, the remaining changes are cleanups to make the code more intuitive and readable --- diff --git a/qcsrc/common/mutators/mutator/nades/nade/darkness.qc b/qcsrc/common/mutators/mutator/nades/nade/darkness.qc index 2f5c135113..b9536d527d 100644 --- a/qcsrc/common/mutators/mutator/nades/nade/darkness.qc +++ b/qcsrc/common/mutators/mutator/nades/nade/darkness.qc @@ -77,8 +77,7 @@ void nade_darkness_boom(entity this) setorigin(fountain, fountain.origin); setthink(fountain, nade_darkness_think); fountain.nextthink = time; - fountain.ltime = time + autocvar_g_nades_darkness_time; - fountain.pushltime = fountain.wait = fountain.ltime; + fountain.pushltime = fountain.wait = fountain.ltime = time + autocvar_g_nades_darkness_time; fountain.team = this.team; set_movetype(fountain, MOVETYPE_TOSS); fountain.projectiledeathtype = DEATH_NADE.m_id; @@ -97,7 +96,8 @@ void nade_darkness_boom(entity this) timer.glowmod = this.glowmod; setthink(timer, nade_timer_think); timer.nextthink = time; - timer.wait = fountain.ltime; + timer.wait = fountain.wait; + timer.nade_lifetime = this.nade_lifetime; timer.owner = fountain; timer.skin = 10; } diff --git a/qcsrc/common/mutators/mutator/nades/nade/ice.qc b/qcsrc/common/mutators/mutator/nades/nade/ice.qc index 2d679fad00..27c7cfc1a2 100644 --- a/qcsrc/common/mutators/mutator/nades/nade/ice.qc +++ b/qcsrc/common/mutators/mutator/nades/nade/ice.qc @@ -86,8 +86,7 @@ void nade_ice_boom(entity this) setorigin(fountain, fountain.origin); setthink(fountain, nade_ice_think); fountain.nextthink = time; - fountain.ltime = time + autocvar_g_nades_ice_freeze_time; - fountain.pushltime = fountain.wait = fountain.ltime; + fountain.pushltime = fountain.wait = fountain.ltime = time + autocvar_g_nades_ice_freeze_time; fountain.team = this.team; set_movetype(fountain, MOVETYPE_TOSS); fountain.projectiledeathtype = DEATH_NADE_ICE.m_id; @@ -106,7 +105,8 @@ void nade_ice_boom(entity this) timer.glowmod = this.glowmod; setthink(timer, nade_timer_think); timer.nextthink = time; - timer.wait = fountain.ltime; + timer.wait = fountain.wait; + timer.nade_lifetime = this.nade_lifetime; timer.owner = fountain; timer.skin = 10; } diff --git a/qcsrc/common/mutators/mutator/nades/sv_nades.qc b/qcsrc/common/mutators/mutator/nades/sv_nades.qc index 0dc520c91f..6ae5d550db 100644 --- a/qcsrc/common/mutators/mutator/nades/sv_nades.qc +++ b/qcsrc/common/mutators/mutator/nades/sv_nades.qc @@ -7,7 +7,6 @@ #include .float nade_time_primed; -.float nade_lifetime; .entity nade_spawnloc; @@ -23,7 +22,7 @@ vector nades_PlayerColor(entity this, bool isPants) void nade_timer_think(entity this) { - this.skin = 8 - (this.owner.wait - time) / (this.owner.nade_lifetime / 10); + this.skin = 8 - (this.wait - time) / (this.nade_lifetime / 10); this.nextthink = time; if(!this.owner || wasfreed(this.owner)) delete(this); @@ -44,6 +43,7 @@ void nade_spawn(entity _nade) setthink(timer, nade_timer_think); timer.nextthink = time; timer.wait = _nade.wait; + timer.nade_lifetime = _nade.nade_lifetime; timer.owner = _nade; timer.skin = 10; diff --git a/qcsrc/common/mutators/mutator/nades/sv_nades.qh b/qcsrc/common/mutators/mutator/nades/sv_nades.qh index ced6e588f8..0d3311a3fa 100644 --- a/qcsrc/common/mutators/mutator/nades/sv_nades.qh +++ b/qcsrc/common/mutators/mutator/nades/sv_nades.qh @@ -42,6 +42,7 @@ int autocvar_g_nades_bonus_score_spree; .entity nade; .entity fake_nade; +.float nade_lifetime; .float nade_refire; .float nade_special_time; .string pokenade_type;