]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Fix #2079: "Progress indicator sometimes missing when reviving teammates in FT"
authorterencehill <piuntn@gmail.com>
Sun, 23 Sep 2018 16:35:39 +0000 (18:35 +0200)
committerterencehill <piuntn@gmail.com>
Sun, 23 Sep 2018 16:40:38 +0000 (18:40 +0200)
qcsrc/common/gamemodes/gamemode/freezetag/sv_freezetag.qc
qcsrc/common/gamemodes/gamemode/freezetag/sv_freezetag.qh
qcsrc/common/mutators/mutator/nades/nades.qc

index be6e92523518824a01ff2892bb5ac64c4876e61a..32a956857b75c790e5b75941edff21b988a7d35b 100644 (file)
@@ -454,6 +454,15 @@ MUTATOR_HOOKFUNCTION(ft, Unfreeze)
        targ.freezetag_frozen_timeout = 0;
 }
 
+#ifdef IS_REVIVING
+       #undef IS_REVIVING
+#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) \
+       && boxesoverlap(player.absmin - revive_extra_size, player.absmax + revive_extra_size, it.absmin, it.absmax))
+
 MUTATOR_HOOKFUNCTION(ft, PlayerPreThink, CBC_ORDER_FIRST)
 {
        if(game_stopped)
@@ -465,6 +474,7 @@ MUTATOR_HOOKFUNCTION(ft, PlayerPreThink, CBC_ORDER_FIRST)
 
        int n;
        entity o = NULL;
+       vector revive_extra_size = '1 1 1' * autocvar_g_freezetag_revive_extra_size;
        entity player = M_ARGV(0, entity);
        //if (STAT(FROZEN, player) == FROZEN_NORMAL)
        //if(player.freezetag_frozen_timeout > 0 && time < player.freezetag_frozen_timeout)
@@ -474,18 +484,11 @@ MUTATOR_HOOKFUNCTION(ft, PlayerPreThink, CBC_ORDER_FIRST)
                n = -1;
        else
        {
-               vector revive_extra_size = '1 1 1' * autocvar_g_freezetag_revive_extra_size;
                n = 0;
-               FOREACH_CLIENT(IS_PLAYER(it) && it != player, {
-                       if (!STAT(FROZEN, it) && !IS_DEAD(it) && SAME_TEAM(it, player))
-                       if(boxesoverlap(player.absmin - revive_extra_size, player.absmax + revive_extra_size, it.absmin, it.absmax))
-                       {
-                               if(!o)
-                                       o = it;
-                               if (STAT(FROZEN, player) == FROZEN_NORMAL)
-                                       it.reviving = true;
-                               ++n;
-                       }
+               FOREACH_CLIENT(IS_PLAYER(it) && IS_REVIVING(player, it, revive_extra_size), {
+                       if(!o)
+                               o = it;
+                       ++n;
                });
        }
 
@@ -507,10 +510,10 @@ MUTATOR_HOOKFUNCTION(ft, PlayerPreThink, CBC_ORDER_FIRST)
                        }
 
                        // EVERY team mate nearby gets a point (even if multiple!)
-                       FOREACH_CLIENT(IS_PLAYER(it) && it.reviving, {
+                       FOREACH_CLIENT(IS_PLAYER(it) && IS_REVIVING(player, it, revive_extra_size), {
                                GameRules_scoring_add(it, FREEZETAG_REVIVALS, +1);
                                GameRules_scoring_add(it, SCORE, +1);
-                               nades_GiveBonus(it,autocvar_g_nades_bonus_score_low);
+                               nades_GiveBonus(it, autocvar_g_nades_bonus_score_low);
                        });
 
                        Send_Notification(NOTIF_ONE, player, MSG_CENTER, CENTER_FREEZETAG_REVIVED, o.netname);
@@ -518,9 +521,8 @@ MUTATOR_HOOKFUNCTION(ft, PlayerPreThink, CBC_ORDER_FIRST)
                        Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_FREEZETAG_REVIVED, player.netname, o.netname);
                }
 
-               FOREACH_CLIENT(IS_PLAYER(it) && it.reviving, {
+               FOREACH_CLIENT(IS_PLAYER(it) && IS_REVIVING(player, it, revive_extra_size), {
                        STAT(REVIVE_PROGRESS, it) = STAT(REVIVE_PROGRESS, player);
-                       it.reviving = false;
                });
        }
        else if (!n && STAT(FROZEN, player) == FROZEN_NORMAL) // only if no teammate is nearby will we reset
index 4a3d80fd1b33605de50576c2d9f1becbf86e3bf8..d637ae46f6a52f934f2d806adc5c1cdb49334098 100644 (file)
@@ -27,8 +27,6 @@ const float ICE_MAX_ALPHA = 1;
 const float ICE_MIN_ALPHA = 0.1;
 float freezetag_teams;
 
-.float reviving; // temp var
-
 float autocvar_g_freezetag_revive_extra_size;
 float autocvar_g_freezetag_revive_speed;
 bool autocvar_g_freezetag_revive_nade;
index b6dafe7604dc709798bf2be59de7e01d9b45f5d8..45a6bae97aabeb2082466f952e68fb4394906d1f 100644 (file)
@@ -1258,6 +1258,15 @@ MUTATOR_HOOKFUNCTION(nades, ForbidThrowCurrentWeapon, CBC_ORDER_LAST)
        }
 }
 
+#ifdef IS_REVIVING
+       #undef IS_REVIVING
+#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) \
+       && boxesoverlap(player.absmin - revive_extra_size, player.absmax + revive_extra_size, it.absmin, it.absmax))
+
 MUTATOR_HOOKFUNCTION(nades, PlayerPreThink)
 {
        entity player = M_ARGV(0, entity);
@@ -1330,21 +1339,16 @@ MUTATOR_HOOKFUNCTION(nades, PlayerPreThink)
 
        int n = 0;
        entity o = NULL;
+       vector revive_extra_size = '1 1 1' * autocvar_g_freezetag_revive_extra_size;
        if(player.freezetag_frozen_timeout > 0 && time >= player.freezetag_frozen_timeout)
                n = -1;
        else 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) && it != player, {
-                       if (!IS_DEAD(it) && !STAT(FROZEN, it) && SAME_TEAM(it, player))
-                       if(boxesoverlap(player.absmin - revive_extra_size, player.absmax + revive_extra_size, it.absmin, it.absmax))
-                       {
-                               if(!o)
-                                       o = it;
-                               it.reviving = true;
-                               ++n;
-                       }
+               FOREACH_CLIENT(IS_PLAYER(it) && IS_REVIVING(player, it, revive_extra_size), {
+                       if(!o)
+                               o = it;
+                       ++n;
                });
        }
 
@@ -1361,9 +1365,8 @@ MUTATOR_HOOKFUNCTION(nades, PlayerPreThink)
                        Send_Notification(NOTIF_ONE, o, MSG_CENTER, CENTER_FREEZETAG_REVIVE, player.netname);
                }
 
-               FOREACH_CLIENT(IS_PLAYER(it) && it.reviving, {
+               FOREACH_CLIENT(IS_PLAYER(it) && IS_REVIVING(player, it, revive_extra_size), {
                        STAT(REVIVE_PROGRESS, it) = STAT(REVIVE_PROGRESS, player);
-                       it.reviving = false;
                });
        }
 }