]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Fix circular bar stuck on screen when stopping a revival of a player frozen by an...
authorterencehill <piuntn@gmail.com>
Sun, 11 Apr 2021 21:54:20 +0000 (23:54 +0200)
committerterencehill <piuntn@gmail.com>
Sun, 11 Apr 2021 21:54:20 +0000 (23:54 +0200)
qcsrc/common/mutators/mutator/nades/nades.qc

index a75a008043fd8770bac1b5c3cac4f5d8bc42c3ae..51e6981e63c51df4b969a31e60eae63793835114 100644 (file)
@@ -1348,25 +1348,40 @@ MUTATOR_HOOKFUNCTION(nades, PlayerPreThink)
                entity revivers_last = NULL;
                entity revivers_first = NULL;
 
-               if (STAT(FROZEN, player) == FROZEN_TEMP_DYING)
-               {
-                       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), {
-                               if (STAT(FROZEN, it))
+               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;
-                               if (revivers_last)
-                                       revivers_last.chain = it;
-                               revivers_last = it;
-                               if (!revivers_first)
-                                       revivers_first = it;
-                               ++n;
-                       });
+                               player_is_reviving = true;
+                               break;
+                       }
+
+                       if (!(STAT(FROZEN, player) == FROZEN_TEMP_DYING))
+                               continue; // both player and it are NOT frozen
                        if (revivers_last)
-                               revivers_last.chain = NULL;
-               }
+                               revivers_last.chain = it;
+                       revivers_last = it;
+                       if (!revivers_first)
+                               revivers_first = it;
+                       ++n;
+               });
+               if (revivers_last)
+                       revivers_last.chain = NULL;
 
-               if (n > 0 && STAT(FROZEN, player) == FROZEN_TEMP_DYING) // OK, there is at least one teammate reviving us
+               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