]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/client.qc
Forward impulses, movement and buttons to ClientState, also port impulse to ClientState
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / client.qc
index db62a801f73120c67fa65caf2b4a23277970caa8..11833b8c9e91d714f90b243b3e562842fd9b0086 100644 (file)
@@ -855,19 +855,19 @@ Called when a client types 'kill' in the console
 .float clientkill_nexttime;
 void ClientKill_Now_TeamChange(entity this)
 {
-       if(this.killindicator_teamchange == -1)
+       if(CS(this).killindicator_teamchange == -1)
        {
                JoinBestTeam( this, false, true );
        }
-       else if(this.killindicator_teamchange == -2)
+       else if(CS(this).killindicator_teamchange == -2)
        {
                if(blockSpectators)
                        Send_Notification(NOTIF_ONE_ONLY, this, MSG_INFO, INFO_SPECTATE_WARNING, autocvar_g_maxplayers_spectator_blocktime);
                PutObserverInServer(this);
        }
        else
-               SV_ChangeTeam(this, this.killindicator_teamchange - 1);
-       this.killindicator_teamchange = 0;
+               SV_ChangeTeam(this, CS(this).killindicator_teamchange - 1);
+       CS(this).killindicator_teamchange = 0;
 }
 
 void ClientKill_Now(entity this)
@@ -875,7 +875,7 @@ void ClientKill_Now(entity this)
        if(this.vehicle)
        {
            vehicles_exit(this.vehicle, VHEF_RELEASE);
-           if(!this.killindicator_teamchange)
+           if(!CS(this).killindicator_teamchange)
            {
             this.vehicle_health = -1;
             Damage(this, this, this, 1 , DEATH_KILL.m_id, this.origin, '0 0 0');
@@ -887,7 +887,7 @@ void ClientKill_Now(entity this)
 
        this.killindicator = NULL;
 
-       if(this.killindicator_teamchange)
+       if(CS(this).killindicator_teamchange)
                ClientKill_Now_TeamChange(this);
 
        if(!IS_SPEC(this) && !IS_OBSERVER(this))
@@ -950,7 +950,7 @@ void ClientKill_TeamChange (entity this, float targetteam) // 0 = don't change,
        return;
     killtime = M_ARGV(1, float);
 
-       this.killindicator_teamchange = targetteam;
+       CS(this).killindicator_teamchange = targetteam;
 
     if(!this.killindicator)
        {
@@ -1711,7 +1711,7 @@ void SpectateCopy(entity this, entity spectatee)
        this.clip_size = spectatee.clip_size;
        this.effects = spectatee.effects & EFMASK_CHEAP; // eat performance
        this.health = spectatee.health;
-       this.impulse = 0;
+       CS(this).impulse = 0;
        this.items = spectatee.items;
        this.last_pickup = spectatee.last_pickup;
        this.hit_time = spectatee.hit_time;
@@ -2108,10 +2108,10 @@ bool joinAllowed(entity this)
 
 void ObserverThink(entity this)
 {
-       if ( this.impulse )
+       if ( CS(this).impulse )
        {
-               MinigameImpulse(this, this.impulse);
-               this.impulse = 0;
+               MinigameImpulse(this, CS(this).impulse);
+               CS(this).impulse = 0;
        }
 
        if (this.flags & FL_JUMPRELEASED) {
@@ -2142,15 +2142,15 @@ void ObserverThink(entity this)
 
 void SpectatorThink(entity this)
 {
-       if ( this.impulse )
+       if ( CS(this).impulse )
        {
-               if(MinigameImpulse(this, this.impulse))
-                       this.impulse = 0;
+               if(MinigameImpulse(this, CS(this).impulse))
+                       CS(this).impulse = 0;
 
-               if (this.impulse == IMP_weapon_drop.impulse)
+               if (CS(this).impulse == IMP_weapon_drop.impulse)
                {
                        STAT(CAMERA_SPECTATOR, this) = (STAT(CAMERA_SPECTATOR, this) + 1) % 3;
-                       this.impulse = 0;
+                       CS(this).impulse = 0;
                        return;
                }
        }
@@ -2159,7 +2159,7 @@ void SpectatorThink(entity this)
                if (PHYS_INPUT_BUTTON_JUMP(this) && joinAllowed(this)) {
                        this.flags &= ~FL_JUMPRELEASED;
                        this.flags |= FL_SPAWNING;
-               } else if(PHYS_INPUT_BUTTON_ATCK(this) || this.impulse == 10 || this.impulse == 15 || this.impulse == 18 || (this.impulse >= 200 && this.impulse <= 209)) {
+               } else if(PHYS_INPUT_BUTTON_ATCK(this) || CS(this).impulse == 10 || CS(this).impulse == 15 || CS(this).impulse == 18 || (CS(this).impulse >= 200 && CS(this).impulse <= 209)) {
                        this.flags &= ~FL_JUMPRELEASED;
                        if(SpectateNext(this)) {
                                TRANSMUTE(Spectator, this);
@@ -2167,8 +2167,8 @@ void SpectatorThink(entity this)
                                TRANSMUTE(Observer, this);
                                PutClientInServer(this);
                        }
-                       this.impulse = 0;
-               } else if(this.impulse == 12 || this.impulse == 16  || this.impulse == 19 || (this.impulse >= 220 && this.impulse <= 229)) {
+                       CS(this).impulse = 0;
+               } else if(CS(this).impulse == 12 || CS(this).impulse == 16  || CS(this).impulse == 19 || (CS(this).impulse >= 220 && CS(this).impulse <= 229)) {
                        this.flags &= ~FL_JUMPRELEASED;
                        if(SpectatePrev(this)) {
                                TRANSMUTE(Spectator, this);
@@ -2176,7 +2176,7 @@ void SpectatorThink(entity this)
                                TRANSMUTE(Observer, this);
                                PutClientInServer(this);
                        }
-                       this.impulse = 0;
+                       CS(this).impulse = 0;
                } else if (PHYS_INPUT_BUTTON_ATCK2(this)) {
                        this.flags &= ~FL_JUMPRELEASED;
                        TRANSMUTE(Observer, this);
@@ -2408,7 +2408,7 @@ void PlayerPreThink (entity this)
                                if (time > this.respawn_time) {
                                        STAT(RESPAWN_TIME, this) = this.respawn_time = time + 1; // only retry once a second
                                        respawn(this);
-                                       this.impulse = CHIMPULSE_SPEEDRUN.impulse;
+                                       CS(this).impulse = CHIMPULSE_SPEEDRUN.impulse;
                                }
                        } else {
                                if (frametime) player_anim(this);
@@ -2649,12 +2649,12 @@ void Player_Physics(entity this)
        if(!this.move_qcphysics)
                return;
 
-       if(!frametime && !this.pm_frametime)
+       if(!frametime && !CS(this).pm_frametime)
                return;
 
-       Movetype_Physics_NoMatchTicrate(this, this.pm_frametime, true);
+       Movetype_Physics_NoMatchTicrate(this, CS(this).pm_frametime, true);
 
-       this.pm_frametime = 0;
+       CS(this).pm_frametime = 0;
 }
 
 /*
@@ -2664,7 +2664,6 @@ PlayerPostThink
 Called every frame for each client after the physics are run
 =============
 */
-.float idlekick_lasttimeleft;
 void PlayerPostThink (entity this)
 {
        Player_Physics(this);
@@ -2687,9 +2686,9 @@ void PlayerPostThink (entity this)
                { /* do nothing */ }
                else if (time - CS(this).parm_idlesince < 1) // instead of (time == this.parm_idlesince) to support sv_maxidle <= 10
                {
-                       if (this.idlekick_lasttimeleft)
+                       if (CS(this).idlekick_lasttimeleft)
                        {
-                               this.idlekick_lasttimeleft = 0;
+                               CS(this).idlekick_lasttimeleft = 0;
                                Kill_Notification(NOTIF_ONE_ONLY, this, MSG_CENTER, CPID_IDLING);
                        }
                }
@@ -2697,7 +2696,7 @@ void PlayerPostThink (entity this)
                {
                        float timeleft = ceil(sv_maxidle - (time - CS(this).parm_idlesince));
                        if (timeleft == min(10, sv_maxidle - 1)) { // - 1 to support sv_maxidle <= 10
-                               if (!this.idlekick_lasttimeleft)
+                               if (!CS(this).idlekick_lasttimeleft)
                                        Send_Notification(NOTIF_ONE_ONLY, this, MSG_CENTER, CENTER_DISCONNECT_IDLING, timeleft);
                        }
                        if (timeleft <= 0) {
@@ -2706,10 +2705,10 @@ void PlayerPostThink (entity this)
                                return;
                        }
                        else if (timeleft <= 10) {
-                               if (timeleft != this.idlekick_lasttimeleft) {
+                               if (timeleft != CS(this).idlekick_lasttimeleft) {
                                    Send_Notification(NOTIF_ONE, this, MSG_ANNCE, Announcer_PickNumber(CNT_IDLE, timeleft));
                 }
-                               this.idlekick_lasttimeleft = timeleft;
+                               CS(this).idlekick_lasttimeleft = timeleft;
                        }
                }
        }
@@ -2728,7 +2727,7 @@ void PlayerPostThink (entity this)
                DrownPlayer(this);
                CheckRules_Player(this);
                UpdateChatBubble(this);
-               if (this.impulse) ImpulseCommands(this);
+               if (CS(this).impulse) ImpulseCommands(this);
                if (game_stopped)
                {
                        CSQCMODEL_AUTOUPDATE(this);
@@ -2746,3 +2745,41 @@ void PlayerPostThink (entity this)
 
        CSQCMODEL_AUTOUPDATE(this);
 }
+
+// hack to copy the button fields from the client entity to the Client State
+void PM_UpdateButtons(entity this)
+{
+       if(this.impulse)
+               CS(this).impulse = this.impulse;
+       this.impulse = 0;
+
+       CS(this).button0 = this.button0;
+       CS(this).button2 = this.button2;
+       CS(this).button3 = this.button3;
+       CS(this).button4 = this.button4;
+       CS(this).button5 = this.button5;
+       CS(this).button6 = this.button6;
+       CS(this).button7 = this.button7;
+       CS(this).button8 = this.button8;
+       CS(this).button9 = this.button9;
+       CS(this).button10 = this.button10;
+       CS(this).button11 = this.button11;
+       CS(this).button12 = this.button12;
+       CS(this).button13 = this.button13;
+       CS(this).button14 = this.button14;
+       CS(this).button15 = this.button15;
+       CS(this).button16 = this.button16;
+       CS(this).buttonuse = this.buttonuse;
+       CS(this).buttonchat = this.buttonchat;
+
+       CS(this).cursor_active = this.cursor_active;
+       CS(this).cursor_screen = this.cursor_screen;
+       CS(this).cursor_trace_start = this.cursor_trace_start;
+       CS(this).cursor_trace_endpos = this.cursor_trace_endpos;
+       CS(this).cursor_trace_ent = this.cursor_trace_ent;
+
+       // TODO: ping?
+
+       CS(this).v_angle = this.v_angle;
+       CS(this).movement = this.movement;
+}