From 2b9e57a03dc50e4821dd66257d071e075bd514c2 Mon Sep 17 00:00:00 2001 From: terencehill Date: Tue, 25 Sep 2018 14:34:00 +0200 Subject: [PATCH] Rearrange code to avoid redundant checks --- .../gamemode/freezetag/sv_freezetag.qc | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/qcsrc/common/gamemodes/gamemode/freezetag/sv_freezetag.qc b/qcsrc/common/gamemodes/gamemode/freezetag/sv_freezetag.qc index 32a956857..d740bd0b9 100644 --- a/qcsrc/common/gamemodes/gamemode/freezetag/sv_freezetag.qc +++ b/qcsrc/common/gamemodes/gamemode/freezetag/sv_freezetag.qc @@ -492,7 +492,17 @@ MUTATOR_HOOKFUNCTION(ft, PlayerPreThink, CBC_ORDER_FIRST) }); } - if (n && STAT(FROZEN, player) == FROZEN_NORMAL) // OK, there is at least one teammate reviving us + if (!n) // no teammate nearby + { + if (STAT(FROZEN, player) == FROZEN_NORMAL) + { + STAT(REVIVE_PROGRESS, player) = bound(0, STAT(REVIVE_PROGRESS, player) - frametime * autocvar_g_freezetag_revive_clearspeed, 1); + SetResourceAmountExplicit(player, RESOURCE_HEALTH, max(1, STAT(REVIVE_PROGRESS, player) * ((warmup_stage) ? warmup_start_health : start_health))); + } + else if (!STAT(FROZEN, player)) + STAT(REVIVE_PROGRESS, player) = 0; // thawing nobody + } + else if (STAT(FROZEN, player) == FROZEN_NORMAL) // OK, there is at least one teammate reviving us { STAT(REVIVE_PROGRESS, player) = bound(0, STAT(REVIVE_PROGRESS, player) + frametime * max(1/60, autocvar_g_freezetag_revive_speed), 1); SetResourceAmountExplicit(player, RESOURCE_HEALTH, max(1, STAT(REVIVE_PROGRESS, player) * ((warmup_stage) ? warmup_start_health : start_health))); @@ -525,15 +535,6 @@ MUTATOR_HOOKFUNCTION(ft, PlayerPreThink, CBC_ORDER_FIRST) STAT(REVIVE_PROGRESS, it) = STAT(REVIVE_PROGRESS, player); }); } - else if (!n && STAT(FROZEN, player) == FROZEN_NORMAL) // only if no teammate is nearby will we reset - { - STAT(REVIVE_PROGRESS, player) = bound(0, STAT(REVIVE_PROGRESS, player) - frametime * autocvar_g_freezetag_revive_clearspeed, 1); - SetResourceAmountExplicit(player, RESOURCE_HEALTH, max(1, STAT(REVIVE_PROGRESS, player) * ((warmup_stage) ? warmup_start_health : start_health))); - } - else if (!n && !STAT(FROZEN, player)) - { - STAT(REVIVE_PROGRESS, player) = 0; // thawing nobody - } return true; } -- 2.39.2