]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Strip some player-only stuff out of the main CreatureFrame loop
authorMario <mario@smbclan.net>
Thu, 3 Dec 2015 07:33:17 +0000 (17:33 +1000)
committerMario <mario@smbclan.net>
Thu, 3 Dec 2015 07:33:17 +0000 (17:33 +1000)
qcsrc/server/cl_client.qc
qcsrc/server/sv_main.qc

index f68cff0a4a7aaa55c4652849ff053afe6534adf5..4fa6820f806007674498a6b39c879fce5c5e01d2 100644 (file)
@@ -2520,6 +2520,57 @@ void PlayerPreThink ()
                self.clip_load = self.clip_size = 0;
 }
 
+void Player_Footsteps(entity this)
+{
+       // play stupid sounds
+       if (g_footsteps && !gameover && (this.flags & FL_ONGROUND))
+       if (!this.crouch && (vlen(this.velocity) > autocvar_sv_maxspeed * 0.6) && this.deadflag == DEAD_NO && time < this.lastground + 0.2)
+       {
+               if((time > this.nextstep) || (time < (this.nextstep - 10.0)))
+               {
+                       this.nextstep = time + 0.3 + random() * 0.1;
+                       trace_dphitq3surfaceflags = 0;
+                       tracebox(this.origin, this.mins, this.maxs, this.origin - '0 0 1', MOVE_NOMONSTERS, this);
+                       /*
+                       if(trace_fraction == 1)
+                               dprint("nohit\n");
+                       else
+                               dprint(ftos(trace_dphitq3surfaceflags), "\n");
+                       */
+                       if (!(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOSTEPS))
+                       {
+                               if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_METALSTEPS)
+                                       GlobalSound(this, GS_STEP_METAL, CH_PLAYER, VOICETYPE_PLAYERSOUND);
+                               else
+                                       GlobalSound(this, GS_STEP, CH_PLAYER, VOICETYPE_PLAYERSOUND);
+                       }
+               }
+       }
+}
+
+void DrownPlayer(entity this)
+{
+       if(this.deadflag != DEAD_NO)
+               return;
+
+       if (this.waterlevel != WATERLEVEL_SUBMERGED)
+       {
+               if(this.air_finished < time)
+                       PlayerSound(this, playersound_gasp, CH_PLAYER, VOICETYPE_PLAYERSOUND);
+               this.air_finished = time + autocvar_g_balance_contents_drowndelay;
+               this.dmg = 2;
+       }
+       else if (this.air_finished < time)
+       {       // drown!
+               if (!this.deadflag)
+               if (this.pain_finished < time)
+               {
+                       Damage (this, world, world, autocvar_g_balance_contents_playerdamage_drowning * autocvar_g_balance_contents_damagerate, DEATH_DROWN.m_id, this.origin, '0 0 0');
+                       this.pain_finished = time + 0.5;
+               }
+       }
+}
+
 /*
 =============
 PlayerPostThink
@@ -2571,6 +2622,8 @@ void PlayerPostThink ()
        //CheckPlayerJump();
 
        if(IS_PLAYER(self)) {
+               DrownPlayer(self);
+               Player_Footsteps(self);
                CheckRules_Player();
                UpdateChatBubble();
                if (self.impulse)
index f05203c5859c903d6732063000ebe8301aa5e31f..90e9f79384cd3dfc4eaaf8fdddb6fedf4d4b3fe4 100644 (file)
 .float lastground;
 .int state;
 
-void CreatureFrame_drowning(entity this)
-{
-       if(!IS_VEHICLE(this) && !(this.flags & FL_PROJECTILE) && !IS_MONSTER(this)) // vehicles, monsters and projectiles don't drown
-       {
-               if (this.waterlevel != WATERLEVEL_SUBMERGED)
-               {
-                       if(this.air_finished < time)
-                               PlayerSound(this, playersound_gasp, CH_PLAYER, VOICETYPE_PLAYERSOUND);
-                       this.air_finished = time + autocvar_g_balance_contents_drowndelay;
-                       this.dmg = 2;
-               }
-               else if (this.air_finished < time)
-               {       // drown!
-                       if (!this.deadflag)
-                       if (this.pain_finished < time)
-                       {
-                               Damage (this, world, world, autocvar_g_balance_contents_playerdamage_drowning * autocvar_g_balance_contents_damagerate, DEATH_DROWN.m_id, this.origin, '0 0 0');
-                               this.pain_finished = time + 0.5;
-                       }
-               }
-       }
-}
-
 void CreatureFrame_hotliquids(entity this)
 {
        if (this.dmgtime < time)
@@ -100,8 +77,6 @@ void CreatureFrame_Liquids(entity this)
                        this.dmgtime = 0;
                }
 
-               CreatureFrame_drowning(this);
-
                CreatureFrame_hotliquids(this);
        }
        else
@@ -139,35 +114,6 @@ void CreatureFrame_FallDamage(entity this)
        }
 }
 
-void CreatureFrame_Footsteps(entity this)
-{
-       // play stupid sounds
-       if (g_footsteps && !gameover && (this.flags & FL_ONGROUND))
-       if (!IS_VEHICLE(this) && !(this.flags & FL_PROJECTILE))
-       if (!this.crouch && (vlen(this.velocity) > autocvar_sv_maxspeed * 0.6) && !this.deadflag && time < this.lastground + 0.2)
-       {
-               if((time > this.nextstep) || (time < (this.nextstep - 10.0)))
-               {
-                       this.nextstep = time + 0.3 + random() * 0.1;
-                       trace_dphitq3surfaceflags = 0;
-                       tracebox(this.origin, this.mins, this.maxs, this.origin - '0 0 1', MOVE_NOMONSTERS, this);
-                       /*
-                       if(trace_fraction == 1)
-                               dprint("nohit\n");
-                       else
-                               dprint(ftos(trace_dphitq3surfaceflags), "\n");
-                       */
-                       if (!(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOSTEPS))
-                       {
-                               if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_METALSTEPS)
-                                       GlobalSound(this, GS_STEP_METAL, CH_PLAYER, VOICETYPE_PLAYERSOUND);
-                               else
-                                       GlobalSound(this, GS_STEP, CH_PLAYER, VOICETYPE_PLAYERSOUND);
-                       }
-               }
-       }
-}
-
 void CreatureFrame_All()
 {
        for(entity e = world; (e = findfloat(e, damagedbycontents, true)); )
@@ -176,7 +122,6 @@ void CreatureFrame_All()
 
                CreatureFrame_Liquids(e);
                CreatureFrame_FallDamage(e);
-               CreatureFrame_Footsteps(e);
 
         e.oldvelocity = e.velocity;
        }