]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Apply to the ice nade code changes regarding revival progress from freezetag (no...
authorterencehill <piuntn@gmail.com>
Sun, 11 Apr 2021 20:12:17 +0000 (22:12 +0200)
committerterencehill <piuntn@gmail.com>
Sun, 11 Apr 2021 20:12:17 +0000 (22:12 +0200)
qcsrc/common/gamemodes/gamemode/freezetag/sv_freezetag.qc
qcsrc/common/mutators/mutator/nades/nades.qc

index b7319167174d5724fa317fd63c8a1baadb014c09..249c343d31cca2f29ba981ba1aec9fec027afbee 100644 (file)
@@ -486,8 +486,8 @@ MUTATOR_HOOKFUNCTION(ft, Damage_Calculate)
        }
 }
 
-#ifdef IS_REVIVING
-       #undef IS_REVIVING
+#ifdef IN_REVIVING_RANGE
+       #undef IN_REVIVING_RANGE
 #endif
 
 #define IN_REVIVING_RANGE(player, it, revive_extra_size) \
index c94c92c13432523237ca2258db4660e428b1b4e0..050e4dbc5ef4d410f17293f678ce9b5d0a38ac9c 100644 (file)
@@ -1258,13 +1258,13 @@ MUTATOR_HOOKFUNCTION(nades, ForbidThrowCurrentWeapon, CBC_ORDER_LAST)
        }
 }
 
-#ifdef IS_REVIVING
-       #undef IS_REVIVING
+#ifdef IN_REVIVING_RANGE
+       #undef IN_REVIVING_RANGE
 #endif
 
 // returns true if player is reviving it
-#define IS_REVIVING(player, it, revive_extra_size) \
-       (it != player && !STAT(FROZEN, it) && !IS_DEAD(it) && SAME_TEAM(it, player) \
+#define IN_REVIVING_RANGE(player, it, revive_extra_size) \
+       (it != player && !IS_DEAD(it) && SAME_TEAM(it, player) \
        && boxesoverlap(player.absmin - revive_extra_size, player.absmax + revive_extra_size, it.absmin, it.absmax))
 
 MUTATOR_HOOKFUNCTION(nades, PlayerPreThink)
@@ -1273,7 +1273,8 @@ MUTATOR_HOOKFUNCTION(nades, PlayerPreThink)
 
        if (!IS_PLAYER(player)) { return; }
 
-       if (player.nade && (player.offhand != OFFHAND_NADE || (STAT(WEAPONS, player) & WEPSET(HOOK)))) OFFHAND_NADE.offhand_think(OFFHAND_NADE, player, player.nade_altbutton);
+       if (player.nade && (player.offhand != OFFHAND_NADE || (STAT(WEAPONS, player) & WEPSET(HOOK))))
+               OFFHAND_NADE.offhand_think(OFFHAND_NADE, player, player.nade_altbutton);
 
        entity held_nade = player.nade;
        if (held_nade)
@@ -1344,7 +1345,8 @@ MUTATOR_HOOKFUNCTION(nades, PlayerPreThink)
        {
                int n = 0;
 
-               IntrusiveList reviving_players = NULL;
+               entity reviving_players_last = NULL;
+               entity reviving_players_first = NULL;
 
                if(player.freezetag_frozen_timeout > 0 && time >= player.freezetag_frozen_timeout)
                        n = -1;
@@ -1352,12 +1354,18 @@ MUTATOR_HOOKFUNCTION(nades, PlayerPreThink)
                {
                        vector revive_extra_size = '1 1 1' * autocvar_g_freezetag_revive_extra_size;
                        n = 0;
-                       FOREACH_CLIENT(IS_PLAYER(it) && IS_REVIVING(player, it, revive_extra_size), {
-                               if (!reviving_players)
-                                       reviving_players = IL_NEW();
-                               IL_PUSH(reviving_players, it);
+                       FOREACH_CLIENT(IS_PLAYER(it) && IN_REVIVING_RANGE(player, it, revive_extra_size), {
+                               if (STAT(FROZEN, it))
+                                       continue;
+                               if (reviving_players_last)
+                                       reviving_players_last.chain = it;
+                               reviving_players_last = it;
+                               if (!reviving_players_first)
+                                       reviving_players_first = it;
                                ++n;
                        });
+                       if (reviving_players_last)
+                               reviving_players_last.chain = NULL;
                }
 
                if (n > 0 && STAT(FROZEN, player) == FROZEN_TEMP_DYING) // OK, there is at least one teammate reviving us
@@ -1369,17 +1377,14 @@ MUTATOR_HOOKFUNCTION(nades, PlayerPreThink)
                        {
                                Unfreeze(player, false);
 
-                               entity first = IL_FIRST(reviving_players);
+                               entity first = reviving_players_first;
                                Send_Notification(NOTIF_ONE, player, MSG_CENTER, CENTER_FREEZETAG_REVIVED, first.netname);
                                Send_Notification(NOTIF_ONE, first, MSG_CENTER, CENTER_FREEZETAG_REVIVE, player.netname);
                        }
 
-                       IL_EACH(reviving_players, true, {
+                       for(entity it = reviving_players_first; it; it = it.chain)
                                STAT(REVIVE_PROGRESS, it) = STAT(REVIVE_PROGRESS, player);
-                       });
                }
-               if (reviving_players)
-                       IL_DELETE(reviving_players);
        }
 }