]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Forward impulses, movement and buttons to ClientState, also port impulse to ClientState
authorMario <mario@smbclan.net>
Sat, 15 Jul 2017 17:37:37 +0000 (03:37 +1000)
committerMario <mario@smbclan.net>
Sat, 15 Jul 2017 17:37:37 +0000 (03:37 +1000)
qcsrc/common/physics/player.qc
qcsrc/common/physics/player.qh
qcsrc/ecs/systems/sv_physics.qc
qcsrc/server/bot/default/havocbot/havocbot.qc
qcsrc/server/bot/default/scripting.qc
qcsrc/server/cheats.qc
qcsrc/server/client.qc
qcsrc/server/client.qh
qcsrc/server/impulse.qc
qcsrc/server/mapvoting.qc
qcsrc/server/mutators/mutator/gamemode_ctf.qc

index 2f62c409ad30a02e372f38fe0f969c4a02a756f0..2dbc7bbcd1f6a59cd6fe01c5ddd3893aa00073ba 100644 (file)
@@ -818,6 +818,11 @@ void SV_PlayerPhysics(entity this)
 void CSQC_ClientMovement_PlayerMove_Frame(entity this)
 #endif
 {
+#ifdef SVQC
+       // needs to be called before physics are run!
+       PM_UpdateButtons(this);
+#endif
+
        sys_phys_update(this, PHYS_INPUT_TIMELENGTH);
 
 #ifdef SVQC
index 4af97abdc6af321da7940f8f98f2389d6ab9a677..1e94bec575cb0c3021abad5247e4f41eb71e1b7f 100644 (file)
@@ -244,6 +244,8 @@ STATIC_INIT(PHYS_INPUT_BUTTON_DODGE)
 
        void Physics_UpdateStats(entity this, float maxspd_mod);
 
+       void PM_UpdateButtons(entity this);
+
        .float stat_sv_airspeedlimit_nonqw = _STAT(MOVEVARS_AIRSPEEDLIMIT_NONQW);
        .float stat_sv_maxspeed = _STAT(MOVEVARS_MAXSPEED);
 
index 20cd53144f884ffff258aef9d9c7ff37b15f6045..fc065b2ad7f62de8d9bff42d3177378531adfeb9 100644 (file)
@@ -57,28 +57,28 @@ void sys_phys_spectator_control(entity this)
 {
        float maxspeed_mod = autocvar_sv_spectator_speed_multiplier;
        if (!this.spectatorspeed) { this.spectatorspeed = maxspeed_mod; }
-       if ((this.impulse >= 1 && this.impulse <= 19)
-           || (this.impulse >= 200 && this.impulse <= 209)
-           || (this.impulse >= 220 && this.impulse <= 229)
+       if ((CS(this).impulse >= 1 && CS(this).impulse <= 19)
+           || (CS(this).impulse >= 200 && CS(this).impulse <= 209)
+           || (CS(this).impulse >= 220 && CS(this).impulse <= 229)
           ) {
                if (this.lastclassname != STR_PLAYER) {
-                       if (this.impulse == 10
-                           || this.impulse == 15
-                           || this.impulse == 18
-                           || (this.impulse >= 200 && this.impulse <= 209)
-                          ) { this.spectatorspeed = bound(1, this.spectatorspeed + 0.5, 5); } else if (this.impulse == 11) {
+                       if (CS(this).impulse == 10
+                           || CS(this).impulse == 15
+                           || CS(this).impulse == 18
+                           || (CS(this).impulse >= 200 && CS(this).impulse <= 209)
+                          ) { this.spectatorspeed = bound(1, this.spectatorspeed + 0.5, 5); } else if (CS(this).impulse == 11) {
                                this.spectatorspeed = maxspeed_mod;
-                       } else if (this.impulse == 12
-                           || this.impulse == 16
-                           || this.impulse == 19
-                           || (this.impulse >= 220 && this.impulse <= 229)
+                       } else if (CS(this).impulse == 12
+                           || CS(this).impulse == 16
+                           || CS(this).impulse == 19
+                           || (CS(this).impulse >= 220 && CS(this).impulse <= 229)
                                  ) {
                                this.spectatorspeed = bound(1, this.spectatorspeed - 0.5, 5);
-                       } else if (this.impulse >= 1 && this.impulse <= 9) {
-                               this.spectatorspeed = 1 + 0.5 * (this.impulse - 1);
+                       } else if (CS(this).impulse >= 1 && CS(this).impulse <= 9) {
+                               this.spectatorspeed = 1 + 0.5 * (CS(this).impulse - 1);
                        }
                }  // otherwise just clear
-               this.impulse = 0;
+               CS(this).impulse = 0;
        }
 }
 
index 42f51af8c7f279c3e1e510fd2ff3c1e56dd469d0..712157f558b0f3617848eb2ec94b87edbf83691e 100644 (file)
@@ -180,7 +180,7 @@ void havocbot_ai(entity this)
                        // we are currently holding a weapon that's not fully loaded, reload it
                        if(skill >= 2) // bots can only reload the held weapon on purpose past this skill
                        if(this.(weaponentity).clip_load < this.(weaponentity).clip_size)
-                               this.impulse = IMP_weapon_reload.impulse; // not sure if this is done right
+                               CS(this).impulse = IMP_weapon_reload.impulse; // not sure if this is done right
 
                        // if we're not reloading a weapon, switch to any weapon in our invnetory that's not fully loaded to reload it next
                        // the code above executes next frame, starting the reloading then
index 7ba7defbac08c66d6b91869f590263e4fa584da8..da93d955668a7f406c5a7d7e27752b4e14ba4625 100644 (file)
@@ -485,7 +485,7 @@ float bot_cmd_cc(entity this)
 
 float bot_cmd_impulse(entity this)
 {
-       this.impulse = bot_cmd.bot_cmd_parm_float;
+       CS(this).impulse = bot_cmd.bot_cmd_parm_float;
        return CMD_STATUS_FINISHED;
 }
 
index ded5e8409885efa1500d13237e5b2b2921bdab45..6d78e160cf1624b9a43cd5339f710e69b3c00f2d 100644 (file)
@@ -780,21 +780,21 @@ float Drag(entity this, float force_allow_pick, float ischeat)
                        {
                                if(PHYS_INPUT_BUTTON_DRAG(this))
                                {
-                                       if(this.impulse == 10 || this.impulse == 15 || this.impulse == 18)
+                                       if(CS(this).impulse == 10 || CS(this).impulse == 15 || CS(this).impulse == 18)
                                        {
                                                Drag_MoveForward(this);
-                                               this.impulse = 0;
+                                               CS(this).impulse = 0;
                                        }
-                                       else if(this.impulse == 12 || this.impulse == 16 || this.impulse == 19)
+                                       else if(CS(this).impulse == 12 || CS(this).impulse == 16 || CS(this).impulse == 19)
                                        {
                                                Drag_MoveBackward(this);
-                                               this.impulse = 0;
+                                               CS(this).impulse = 0;
                                        }
-                                       else if(this.impulse >= 1 && this.impulse <= 9)
+                                       else if(CS(this).impulse >= 1 && CS(this).impulse <= 9)
                                        {
-                                               Drag_SetSpeed(this, this.impulse - 1);
+                                               Drag_SetSpeed(this, CS(this).impulse - 1);
                                        }
-                                       else if(this.impulse == 14)
+                                       else if(CS(this).impulse == 14)
                                        {
                                                Drag_SetSpeed(this, 9);
                                        }
index 196297e5224f450c450590a2ae81477f344ff1fb..11833b8c9e91d714f90b243b3e562842fd9b0086 100644 (file)
@@ -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);
@@ -2727,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);
@@ -2745,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;
+}
index eb33c89b497fe94831dce29b8ae84534d1ca433d..e444f71293cb9ad3798a2badd6f0c51f468e489e 100644 (file)
@@ -29,6 +29,37 @@ CLASS(Client, Object)
     /** the string "HMAC-SHA256" if signing, and string_null if plaintext */
     ATTRIB(Client, crypto_signmethod, string, this.crypto_signmethod);
 
+    // engine client fields
+    ATTRIB(Client, impulse, int, this.impulse);
+
+    ATTRIB(Client, button0, int, this.button0);
+    ATTRIB(Client, button2, int, this.button2);
+    ATTRIB(Client, button3, int, this.button3);
+    ATTRIB(Client, button4, int, this.button4);
+    ATTRIB(Client, button5, int, this.button5);
+    ATTRIB(Client, button6, int, this.button6);
+    ATTRIB(Client, button7, int, this.button7);
+    ATTRIB(Client, button8, int, this.button8);
+    ATTRIB(Client, button9, int, this.button9);
+    ATTRIB(Client, button10, int, this.button10);
+    ATTRIB(Client, button11, int, this.button11);
+    ATTRIB(Client, button12, int, this.button12);
+    ATTRIB(Client, button13, int, this.button13);
+    ATTRIB(Client, button14, int, this.button14);
+    ATTRIB(Client, button15, int, this.button15);
+    ATTRIB(Client, button16, int, this.button16);
+    ATTRIB(Client, buttonuse, int, this.buttonuse);
+    ATTRIB(Client, buttonchat, int, this.buttonchat);
+
+    ATTRIB(Client, cursor_active, int, this.cursor_active);
+    ATTRIB(Client, cursor_screen, vector, this.cursor_screen);
+    ATTRIB(Client, cursor_trace_start, vector, this.cursor_trace_start);
+    ATTRIB(Client, cursor_trace_endpos, vector, this.cursor_trace_endpos);
+    ATTRIB(Client, cursor_trace_ent, entity, this.cursor_trace_ent);
+
+    ATTRIB(Client, v_angle, vector, this.v_angle);
+    ATTRIB(Client, movement, vector, this.movement);
+
     // custom
 
     ATTRIB(Client, playerid, int, this.playerid);
index c6e3911a199237277a36ca7377de842c7788c815..d9036dea519ac5ade2431f2d31be037625523676 100644 (file)
@@ -352,9 +352,9 @@ void ImpulseCommands(entity this)
 {
        if (game_stopped) return;
 
-       int imp = this.impulse;
+       int imp = CS(this).impulse;
        if (!imp) return;
-       this.impulse = 0;
+       CS(this).impulse = 0;
 
        if (MinigameImpulse(this, imp)) return;
 
index 638b40f65e52f18580b46c5ab890e2e3a4fc118b..7ccb2a30b72205e9c2471b1c54ccbd177c153ee3 100644 (file)
@@ -599,7 +599,7 @@ void MapVote_Tick()
                if(it.health != 2342)
                {
                        it.health = 2342;
-                       it.impulse = 0;
+                       CS(it).impulse = 0;
 
                        msg_entity = it;
                        WriteByte(MSG_ONE, SVC_FINALE);
@@ -610,13 +610,13 @@ void MapVote_Tick()
                if ( !(mapvote_maps_flags[it.mapvote-1] & GTV_AVAILABLE) )
                        it.mapvote = 0;
                // use impulses as new vote
-               if(it.impulse >= 1 && it.impulse <= mapvote_count)
-                       if( mapvote_maps_flags[it.impulse - 1] & GTV_AVAILABLE )
+               if(CS(it).impulse >= 1 && CS(it).impulse <= mapvote_count)
+                       if( mapvote_maps_flags[CS(it).impulse - 1] & GTV_AVAILABLE )
                        {
-                               it.mapvote = it.impulse;
+                               it.mapvote = CS(it).impulse;
                                MapVote_TouchVotes(it);
                        }
-               it.impulse = 0;
+               CS(it).impulse = 0;
 
                if(it.mapvote)
                        ++totalvotes;
index 595671882b496d0980f500e1e9008847de4cf923..253a07e722275646c5bdcb603a277b3018646921 100644 (file)
@@ -994,7 +994,7 @@ void ctf_FlagThink(entity this)
                                this.health = 0;
                                ctf_CheckFlagReturn(this, RETURN_SPEEDRUN);
 
-                               this.owner.impulse = CHIMPULSE_SPEEDRUN.impulse; // move the player back to the waypoint they set
+                               CS(this.owner).impulse = CHIMPULSE_SPEEDRUN.impulse; // move the player back to the waypoint they set
                                ImpulseCommands(this.owner);
                        }
                        if(autocvar_g_ctf_stalemate)