]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Set air_finished to 0 while player is out of water instead of updating it to time...
authorterencehill <piuntn@gmail.com>
Thu, 9 Apr 2020 15:49:47 +0000 (17:49 +0200)
committerterencehill <piuntn@gmail.com>
Thu, 9 Apr 2020 17:05:05 +0000 (19:05 +0200)
Remove the redundant field air_finished, rename the field pointer air_finished_stat to air_finished

qcsrc/common/vehicles/vehicle/racer.qc
qcsrc/server/client.qc
qcsrc/server/defs.qh
qcsrc/server/sv_main.qc

index 21069a94997a4fbf5e93a75c061ffcfeaad74081..b3cac72e5c8d8dddad0a0e72ae103ccf23d3fdf8 100644 (file)
@@ -163,6 +163,8 @@ bool racer_frame(entity this, float dt)
 
        int cont = Mod_Q1BSP_SuperContentsFromNativeContents(pointcontents(vehic.origin));
        if(!(cont & DPCONTENTS_WATER))
+               vehic.air_finished = 0;
+       else if (!vehic.air_finished)
                vehic.air_finished = time + autocvar_g_vehicle_racer_water_time;
 
        if(IS_DEAD(vehic))
index 9b6b6c4c1f2acab575201755536e1d79a2336356..271c803961bbd8cd6b4d28bcc065150018fea1d4 100644 (file)
@@ -337,7 +337,7 @@ void PutObserverInServer(entity this)
        this.strength_finished = 0;
        this.invincible_finished = 0;
        this.superweapons_finished = 0;
-       this.air_finished_stat = 0;
+       this.air_finished = 0;
        //this.dphitcontentsmask = 0;
        this.dphitcontentsmask = DPCONTENTS_SOLID;
        if (autocvar_g_playerclip_collisions)
@@ -648,7 +648,7 @@ void PutPlayerInServer(entity this)
        STAT(BUFFS, this) = 0;
        STAT(BUFF_TIME, this) = 0;
 
-       this.air_finished = time + autocvar_g_balance_contents_drowndelay;
+       this.air_finished = 0;
        this.waterlevel = WATERLEVEL_NONE;
        this.watertype = CONTENT_EMPTY;
 
@@ -1685,7 +1685,7 @@ void SpectateCopy(entity this, entity spectatee)
        this.strength_finished = spectatee.strength_finished;
        this.invincible_finished = spectatee.invincible_finished;
        this.superweapons_finished = spectatee.superweapons_finished;
-       this.air_finished_stat = spectatee.air_finished_stat;
+       this.air_finished = spectatee.air_finished;
        STAT(PRESSED_KEYS, this) = STAT(PRESSED_KEYS, spectatee);
        STAT(WEAPONS, this) = STAT(WEAPONS, spectatee);
        this.punchangle = spectatee.punchangle;
@@ -2610,22 +2610,23 @@ void DrownPlayer(entity this)
 
        if (this.waterlevel != WATERLEVEL_SUBMERGED || this.vehicle)
        {
-               if(this.air_finished < time)
+               if(this.air_finished && this.air_finished < time)
                        PlayerSound(this, playersound_gasp, CH_PLAYER, VOL_BASE, VOICETYPE_PLAYERSOUND);
-               this.air_finished = time + autocvar_g_balance_contents_drowndelay;
-               this.air_finished_stat = 0;
+               this.air_finished = 0;
        }
-       else if (this.air_finished < time)
-       {       // drown!
-               if (this.pain_finished < time)
-               {
-                       Damage (this, NULL, NULL, autocvar_g_balance_contents_playerdamage_drowning * autocvar_g_balance_contents_damagerate, DEATH_DROWN.m_id, DMG_NOWEP, this.origin, '0 0 0');
-                       this.pain_finished = time + 0.5;
+       else
+       {
+               if (!this.air_finished)
+                       this.air_finished = time + autocvar_g_balance_contents_drowndelay;
+               if (this.air_finished < time)
+               {       // drown!
+                       if (this.pain_finished < time)
+                       {
+                               Damage (this, NULL, NULL, autocvar_g_balance_contents_playerdamage_drowning * autocvar_g_balance_contents_damagerate, DEATH_DROWN.m_id, DMG_NOWEP, this.origin, '0 0 0');
+                               this.pain_finished = time + 0.5;
+                       }
                }
-               this.air_finished_stat = this.air_finished;
        }
-       else
-               this.air_finished_stat = this.air_finished;
 }
 
 .bool move_qcphysics;
index 3b5acfbd0dbb57be9c6ba5d668ce1deea51c7d75..c7ed5a5681cad4810afba9c1cb36d3871be8e0eb 100644 (file)
@@ -51,7 +51,7 @@ float server_is_dedicated;
 .float  crouch;        // Crouching or not?
 
 const .float superweapons_finished = _STAT(SUPERWEAPONS_FINISHED);
-const .float air_finished_stat = _STAT(AIR_FINISHED);
+const .float air_finished = _STAT(AIR_FINISHED);
 
 .float cnt; // used in too many places
 .float count;
@@ -93,7 +93,6 @@ const float MAX_DAMAGEEXTRARADIUS = 16;
 .float railgunhitsolidbackup;
 .vector railgunhitloc;
 
-.float         air_finished;
 .float         dmgtime;
 
 .float         killcount;
index 367cc99b7a64f3f45f25a2242b8ec0c350ba1219..3aef76e49a22074a71285ee56f29129b1799a103 100644 (file)
@@ -80,6 +80,8 @@ void CreatureFrame_Liquids(entity this)
                }
 
                CreatureFrame_hotliquids(this);
+               if (!this.air_finished)
+                       this.air_finished = time + autocvar_g_balance_contents_drowndelay;
        }
        else
        {
@@ -89,7 +91,7 @@ void CreatureFrame_Liquids(entity this)
                        this.flags &= ~FL_INWATER;
                        this.dmgtime = 0;
                }
-               this.air_finished = time + autocvar_g_balance_contents_drowndelay;
+               this.air_finished = 0;
        }
 }