]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Clean up code by avoiding resetting player's health in Unfreeze as it's not needed...
authorterencehill <piuntn@gmail.com>
Sat, 22 Sep 2018 19:10:33 +0000 (21:10 +0200)
committerterencehill <piuntn@gmail.com>
Sat, 22 Sep 2018 19:10:33 +0000 (21:10 +0200)
qcsrc/common/gamemodes/gamemode/freezetag/sv_freezetag.qc
qcsrc/common/monsters/sv_monsters.qc
qcsrc/common/mutators/mutator/nades/nades.qc
qcsrc/server/client.qc
qcsrc/server/command/vote.qc
qcsrc/server/g_damage.qc
qcsrc/server/g_damage.qh
qcsrc/server/player.qc

index 4b9306f0cb3e83aec4574bd7acc8d4b1647007e3..42b3b77f52eede1653ac845ddcd49610ac490376 100644 (file)
@@ -329,7 +329,7 @@ void ft_RemovePlayer(entity this)
 {
        if(!STAT(FROZEN, this))
                freezetag_LastPlayerForTeam_Notify(this);
-       Unfreeze(this);
+       Unfreeze(this, false);
 
        SetResourceAmountExplicit(this, RESOURCE_HEALTH, 0); // neccessary to correctly count alive players
        freezetag_count_alive_players();
@@ -360,7 +360,7 @@ MUTATOR_HOOKFUNCTION(ft, PlayerDies)
        if(round_handler_CountdownRunning())
        {
                if(STAT(FROZEN, frag_target))
-                       Unfreeze(frag_target);
+                       Unfreeze(frag_target, true);
                freezetag_count_alive_players();
                return true; // let the player die so that he can respawn whenever he wants
        }
@@ -378,8 +378,7 @@ MUTATOR_HOOKFUNCTION(ft, PlayerDies)
                        freezetag_LastPlayerForTeam_Notify(frag_target);
                }
                else
-                       Unfreeze(frag_target); // remove ice
-               SetResourceAmountExplicit(frag_target, RESOURCE_HEALTH, 0); // Unfreeze resets health
+                       Unfreeze(frag_target, false); // remove ice
                frag_target.freezetag_frozen_timeout = -2; // freeze on respawn
                return true;
        }
@@ -452,8 +451,6 @@ MUTATOR_HOOKFUNCTION(ft, Unfreeze)
        entity targ = M_ARGV(0, entity);
        targ.freezetag_frozen_time = 0;
        targ.freezetag_frozen_timeout = 0;
-
-       freezetag_count_alive_players();
 }
 
 MUTATOR_HOOKFUNCTION(ft, PlayerPreThink, CBC_ORDER_FIRST)
@@ -501,7 +498,7 @@ MUTATOR_HOOKFUNCTION(ft, PlayerPreThink, CBC_ORDER_FIRST)
 
                if(STAT(REVIVE_PROGRESS, player) >= 1)
                {
-                       Unfreeze(player);
+                       Unfreeze(player, false);
                        freezetag_count_alive_players();
 
                        if(n == -1)
index f30c5974a0ba6d1085fc57e576e7de66404aee92..011e14ca385627e91a276132f420e2e3fb276cca 100644 (file)
@@ -894,7 +894,7 @@ void Monster_Reset(entity this)
        setorigin(this, this.pos1);
        this.angles = this.pos2;
 
-       Unfreeze(this); // remove any icy remains
+       Unfreeze(this, false); // remove any icy remains
 
        SetResourceAmountExplicit(this, RESOURCE_HEALTH, this.max_health);
        this.velocity = '0 0 0';
@@ -930,10 +930,7 @@ void Monster_Dead(entity this, entity attacker, float gibbed)
        this.monster_lifetime = time + 5;
 
        if(STAT(FROZEN, this))
-       {
-               Unfreeze(this); // remove any icy remains
-               SetResourceAmountExplicit(this, RESOURCE_HEALTH, 0); // reset by Unfreeze (TODO)
-       }
+               Unfreeze(this, false); // remove any icy remains
 
        monster_dropitem(this, attacker);
 
@@ -1160,7 +1157,7 @@ void Monster_Anim(entity this)
 
 void Monster_Frozen_Think(entity this)
 {
-       if(STAT(FROZEN, this) == 2)
+       if (STAT(FROZEN, this) == 2) // reviving in progress
        {
                STAT(REVIVE_PROGRESS, this) = bound(0, STAT(REVIVE_PROGRESS, this) + this.ticrate * this.revive_speed, 1);
                SetResourceAmountExplicit(this, RESOURCE_HEALTH, max(1, STAT(REVIVE_PROGRESS, this) * this.max_health));
@@ -1170,9 +1167,9 @@ void Monster_Frozen_Think(entity this)
                        WaypointSprite_UpdateHealth(this.sprite, GetResourceAmount(this, RESOURCE_HEALTH));
 
                if(STAT(REVIVE_PROGRESS, this) >= 1)
-                       Unfreeze(this);
+                       Unfreeze(this, false);
        }
-       else if(STAT(FROZEN, this) == 3)
+       else if (STAT(FROZEN, this) == 3) // ice nade progress until explosion
        {
                STAT(REVIVE_PROGRESS, this) = bound(0, STAT(REVIVE_PROGRESS, this) - this.ticrate * this.revive_speed, 1);
                SetResourceAmountExplicit(this, RESOURCE_HEALTH, max(0, autocvar_g_nades_ice_health + (this.max_health-autocvar_g_nades_ice_health) * STAT(REVIVE_PROGRESS, this)));
@@ -1182,14 +1179,12 @@ void Monster_Frozen_Think(entity this)
 
                if(GetResourceAmount(this, RESOURCE_HEALTH) < 1)
                {
-                       Unfreeze(this);
-                       SetResourceAmountExplicit(this, RESOURCE_HEALTH, 0);
+                       Unfreeze(this, false);
                        if(this.event_damage)
                                this.event_damage(this, this, this.frozen_by, 1, DEATH_NADE_ICE_FREEZE.m_id, DMG_NOWEP, this.origin, '0 0 0');
                }
-
                else if ( STAT(REVIVE_PROGRESS, this) <= 0 )
-                       Unfreeze(this);
+                       Unfreeze(this, false);
        }
        // otherwise, no revival!
 
index 68a3af3baf76d5ae65f46819004a865c91ce604e..ef9be3459a53a995fa6af2db5c49f9d2a75f7f9a 100644 (file)
@@ -1355,7 +1355,7 @@ MUTATOR_HOOKFUNCTION(nades, PlayerPreThink)
 
                if(STAT(REVIVE_PROGRESS, player) >= 1)
                {
-                       Unfreeze(player);
+                       Unfreeze(player, false);
 
                        Send_Notification(NOTIF_ONE, player, MSG_CENTER, CENTER_FREEZETAG_REVIVED, o.netname);
                        Send_Notification(NOTIF_ONE, o, MSG_CENTER, CENTER_FREEZETAG_REVIVE, player.netname);
@@ -1468,7 +1468,7 @@ MUTATOR_HOOKFUNCTION(nades, Damage_Calculate)
        if(autocvar_g_freezetag_revive_nade && STAT(FROZEN, frag_target) && frag_attacker == frag_target && frag_deathtype == DEATH_NADE.m_id)
        if(time - frag_inflictor.toss_time <= 0.1)
        {
-               Unfreeze(frag_target);
+               Unfreeze(frag_target, false);
                SetResourceAmount(frag_target, RESOURCE_HEALTH, autocvar_g_freezetag_revive_nade_health);
                Send_Effect(EFFECT_ICEORGLASS, frag_target.origin, '0 0 0', 3);
                M_ARGV(4, float) = 0;
index da0d84979f5e139531a89f86f410184b51ea7759..d927e9c6f8d693081086d140b9a735d5dd7e0ab3 100644 (file)
@@ -274,7 +274,7 @@ void PutObserverInServer(entity this)
 
     RemoveGrapplingHooks(this);
        Portal_ClearAll(this);
-       Unfreeze(this);
+       Unfreeze(this, false);
        SetSpectatee(this, NULL);
 
        if (this.alivetime)
@@ -733,7 +733,7 @@ void PutPlayerInServer(entity this)
                //spot.target = s;
        }
 
-       Unfreeze(this);
+       Unfreeze(this, false);
 
        MUTATOR_CALLHOOK(PlayerSpawn, this, spot);
 
@@ -1196,7 +1196,7 @@ void ClientDisconnect(entity this)
 
        Portal_ClearAll(this);
 
-       Unfreeze(this);
+       Unfreeze(this, false);
 
        RemoveGrapplingHooks(this);
 
@@ -2404,16 +2404,16 @@ void PlayerPreThink (entity this)
 
        if(IS_PLAYER(this))
        {
-               if (STAT(FROZEN, this) == 2)
+               if (STAT(FROZEN, this) == 2) // reviving in progress
                {
                        STAT(REVIVE_PROGRESS, this) = bound(0, STAT(REVIVE_PROGRESS, this) + frametime * this.revive_speed, 1);
                        SetResourceAmountExplicit(this, RESOURCE_HEALTH, max(1, STAT(REVIVE_PROGRESS, this) * start_health));
                        this.iceblock.alpha = bound(0.2, 1 - STAT(REVIVE_PROGRESS, this), 1);
 
                        if (STAT(REVIVE_PROGRESS, this) >= 1)
-                               Unfreeze(this);
+                               Unfreeze(this, false);
                }
-               else if (STAT(FROZEN, this) == 3)
+               else if (STAT(FROZEN, this) == 3) // ice nade progress until explosion
                {
                        STAT(REVIVE_PROGRESS, this) = bound(0, STAT(REVIVE_PROGRESS, this) - frametime * this.revive_speed, 1);
                        SetResourceAmountExplicit(this, RESOURCE_HEALTH, max(0, autocvar_g_nades_ice_health + (start_health-autocvar_g_nades_ice_health) * STAT(REVIVE_PROGRESS, this)));
@@ -2426,7 +2426,7 @@ void PlayerPreThink (entity this)
                                        this.event_damage(this, this, this.frozen_by, 1, DEATH_NADE_ICE_FREEZE.m_id, DMG_NOWEP, this.origin, '0 0 0');
                        }
                        else if (STAT(REVIVE_PROGRESS, this) <= 0)
-                               Unfreeze(this);
+                               Unfreeze(this, false);
                }
        }
 
index 83c62cd2b004a60fd641f27f401b4fa5ab426c2e..1cb26d1fdeea47b3200bbdefee5fcb1ec6a1e6cf 100644 (file)
@@ -365,7 +365,7 @@ void reset_map(bool dorespawn)
                if (it.reset2) it.reset2(it);
        });
 
-       FOREACH_CLIENT(IS_PLAYER(it) && STAT(FROZEN, it), { Unfreeze(it); });
+       FOREACH_CLIENT(IS_PLAYER(it) && STAT(FROZEN, it), { Unfreeze(it, false); });
 
        // Moving the player reset code here since the player-reset depends
        // on spawnpoint entities which have to be reset first --blub
index eb05e2c85b7e87e24ba7749d8ceee21ed5760286..c2c2b85bc54bcf0678121697bc2334ae40ba69a5 100644 (file)
@@ -529,16 +529,15 @@ void Freeze(entity targ, float revivespeed, int frozen_type, bool show_waypoint)
                WaypointSprite_Spawn(WP_Frozen, 0, 0, targ, '0 0 64', NULL, targ.team, targ, waypointsprite_attached, true, RADARICON_WAYPOINT);
 }
 
-void Unfreeze(entity targ)
+void Unfreeze(entity targ, bool reset_health)
 {
        if(!STAT(FROZEN, targ))
                return;
 
-       if(STAT(FROZEN, targ) && STAT(FROZEN, targ) != 3) // only reset health if target was frozen
-       {
+       if (reset_health && STAT(FROZEN, targ) != 3) // only reset health if target was frozen
                SetResourceAmount(targ, RESOURCE_HEALTH, ((IS_PLAYER(targ)) ? start_health : targ.max_health));
-               targ.pauseregen_finished = time + autocvar_g_balance_pause_health_regen;
-       }
+
+       targ.pauseregen_finished = time + autocvar_g_balance_pause_health_regen;
 
        STAT(FROZEN, targ) = 0;
        STAT(REVIVE_PROGRESS, targ) = 0;
@@ -697,7 +696,7 @@ void Damage(entity targ, entity inflictor, entity attacker, float damage, int de
                        if(deathtype == DEATH_FALL.m_id)
                        if(damage >= autocvar_g_frozen_revive_falldamage)
                        {
-                               Unfreeze(targ);
+                               Unfreeze(targ, false);
                                SetResourceAmount(targ, RESOURCE_HEALTH, autocvar_g_frozen_revive_falldamage_health);
                                Send_Effect(EFFECT_ICEORGLASS, targ.origin, '0 0 0', 3);
                                Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_FREEZETAG_REVIVED_FALL, targ.netname);
index 617eca1985108e4ca82fc2b31167a8b23c69ff9b..1d100e7a5a86874b2be4ed55771584f708581fd0 100644 (file)
@@ -85,7 +85,7 @@ void Ice_Think(entity this);
 
 void Freeze(entity targ, float freeze_time, int frozen_type, bool show_waypoint);
 
-void Unfreeze (entity targ);
+void Unfreeze(entity targ, bool reset_health);
 
 // NOTE: the .weaponentity parameter can be set to DMG_NOWEP if the attack wasn't caused by a weapon or player
 void Damage (entity targ, entity inflictor, entity attacker, float damage, int deathtype, .entity weaponentity, vector hitloc, vector force);
index 87005ad4bbf6c0476dab47635e1a34c8db616e04..a0d622c7734c79605a6c1787e1bd6777cb6c68d5 100644 (file)
@@ -592,8 +592,7 @@ void PlayerDamage(entity this, entity inflictor, entity attacker, float damage,
 
                // when we get here, player actually dies
 
-               Unfreeze(this); // remove any icy remains
-               SetResourceAmountExplicit(this, RESOURCE_HEALTH, 0); // Unfreeze resets health, so we need to set it back
+               Unfreeze(this, false); // remove any icy remains
 
                // clear waypoints
                WaypointSprite_PlayerDead(this);