From: terencehill Date: Sun, 11 Apr 2021 21:58:06 +0000 (+0200) Subject: Reduce code indentation X-Git-Tag: xonotic-v0.8.5~449^2 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=74d6e69cc8e6023acb834d00d78637ce899678c8;p=xonotic%2Fxonotic-data.pk3dir.git Reduce code indentation --- diff --git a/qcsrc/common/mutators/mutator/nades/nades.qc b/qcsrc/common/mutators/mutator/nades/nades.qc index 51e6981e6..e71c61855 100644 --- a/qcsrc/common/mutators/mutator/nades/nades.qc +++ b/qcsrc/common/mutators/mutator/nades/nades.qc @@ -1341,64 +1341,62 @@ MUTATOR_HOOKFUNCTION(nades, PlayerPreThink) } } - if (frametime && IS_PLAYER(player)) - { - int n = 0; - - entity revivers_last = NULL; - entity revivers_first = NULL; - - bool player_is_reviving = false; - vector revive_extra_size = '1 1 1' * autocvar_g_freezetag_revive_extra_size; - n = 0; - FOREACH_CLIENT(IS_PLAYER(it) && IN_REVIVING_RANGE(player, it, revive_extra_size), { - // check if player is reviving anyone - if (STAT(FROZEN, it) == FROZEN_TEMP_DYING) - { - if ((STAT(FROZEN, player) == FROZEN_TEMP_DYING)) - continue; - if (!IN_REVIVING_RANGE(player, it, revive_extra_size)) - continue; - player_is_reviving = true; - break; - } + if (!(frametime && IS_PLAYER(player))) + return true; - if (!(STAT(FROZEN, player) == FROZEN_TEMP_DYING)) - continue; // both player and it are NOT frozen - if (revivers_last) - revivers_last.chain = it; - revivers_last = it; - if (!revivers_first) - revivers_first = it; - ++n; - }); - if (revivers_last) - revivers_last.chain = NULL; + entity revivers_last = NULL; + entity revivers_first = NULL; - if (!n) // no teammate nearby + bool player_is_reviving = false; + int n = 0; + vector revive_extra_size = '1 1 1' * autocvar_g_freezetag_revive_extra_size; + FOREACH_CLIENT(IS_PLAYER(it) && IN_REVIVING_RANGE(player, it, revive_extra_size), { + // check if player is reviving anyone + if (STAT(FROZEN, it) == FROZEN_TEMP_DYING) { - // freezetag already resets revive progress - if (!g_freezetag && !STAT(FROZEN, player) && !player_is_reviving) - STAT(REVIVE_PROGRESS, player) = 0; // thawing nobody + if ((STAT(FROZEN, player) == FROZEN_TEMP_DYING)) + continue; + if (!IN_REVIVING_RANGE(player, it, revive_extra_size)) + continue; + player_is_reviving = true; + break; } - else if (n > 0 && STAT(FROZEN, player) == FROZEN_TEMP_DYING) // 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); - // undo what PlayerPreThink did - STAT(REVIVE_PROGRESS, player) = bound(0, STAT(REVIVE_PROGRESS, player) + frametime * player.revive_speed, 1); - SetResource(player, RES_HEALTH, max(1, STAT(REVIVE_PROGRESS, player) * start_health)); - if(STAT(REVIVE_PROGRESS, player) >= 1) - { - Unfreeze(player, false); + if (!(STAT(FROZEN, player) == FROZEN_TEMP_DYING)) + continue; // both player and it are NOT frozen + if (revivers_last) + revivers_last.chain = it; + revivers_last = it; + if (!revivers_first) + revivers_first = it; + ++n; + }); + if (revivers_last) + revivers_last.chain = NULL; - Send_Notification(NOTIF_ONE, player, MSG_CENTER, CENTER_FREEZETAG_REVIVED, revivers_first.netname); - Send_Notification(NOTIF_ONE, revivers_first, MSG_CENTER, CENTER_FREEZETAG_REVIVE, player.netname); - } + if (!n) // no teammate nearby + { + // freezetag already resets revive progress + if (!g_freezetag && !STAT(FROZEN, player) && !player_is_reviving) + STAT(REVIVE_PROGRESS, player) = 0; // thawing nobody + } + else if (n > 0 && STAT(FROZEN, player) == FROZEN_TEMP_DYING) // 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); + // undo what PlayerPreThink did + STAT(REVIVE_PROGRESS, player) = bound(0, STAT(REVIVE_PROGRESS, player) + frametime * player.revive_speed, 1); + SetResource(player, RES_HEALTH, max(1, STAT(REVIVE_PROGRESS, player) * start_health)); - for(entity it = revivers_first; it; it = it.chain) - STAT(REVIVE_PROGRESS, it) = STAT(REVIVE_PROGRESS, player); + if(STAT(REVIVE_PROGRESS, player) >= 1) + { + Unfreeze(player, false); + + Send_Notification(NOTIF_ONE, player, MSG_CENTER, CENTER_FREEZETAG_REVIVED, revivers_first.netname); + Send_Notification(NOTIF_ONE, revivers_first, MSG_CENTER, CENTER_FREEZETAG_REVIVE, player.netname); } + + for(entity it = revivers_first; it; it = it.chain) + STAT(REVIVE_PROGRESS, it) = STAT(REVIVE_PROGRESS, player); } }