]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Move PM_Main to ecs
authorTimePath <andrew.hardaker1995@gmail.com>
Thu, 23 Jun 2016 11:59:43 +0000 (21:59 +1000)
committerTimePath <andrew.hardaker1995@gmail.com>
Thu, 23 Jun 2016 11:59:43 +0000 (21:59 +1000)
13 files changed:
qcsrc/common/physics/player.qc
qcsrc/common/physics/player.qh
qcsrc/ecs/components/input.qh
qcsrc/ecs/systems/_mod.inc
qcsrc/ecs/systems/_mod.qh
qcsrc/ecs/systems/cl_physics.qc [new file with mode: 0644]
qcsrc/ecs/systems/input.qc [new file with mode: 0644]
qcsrc/ecs/systems/input.qh [new file with mode: 0644]
qcsrc/ecs/systems/physics.qc
qcsrc/ecs/systems/physics.qh
qcsrc/ecs/systems/sv_physics.qc [new file with mode: 0644]
qcsrc/lib/_all.inc
qcsrc/uncrustify.cfg

index b8c2b375d69da108bd156c35e0c2d6b491a2428d..5925ada7bfc86c6dfe0ea85737e30d5add58a21e 100644 (file)
@@ -198,8 +198,8 @@ void PM_ClientMovement_UpdateStatus(entity this, bool ground)
                }
        }
 
-       if (IS_ONGROUND(this) || this.velocity.z <= 0 || pmove_waterjumptime <= 0)
-               pmove_waterjumptime = 0;
+       if (IS_ONGROUND(this) || this.velocity.z <= 0 || PHYS_WATERJUMP_TIME(this) <= 0)
+               PHYS_WATERJUMP_TIME(this) = 0;
 #endif
 }
 
@@ -570,7 +570,7 @@ void CheckWaterJump(entity this)
                #ifdef SVQC
                        PHYS_TELEPORT_TIME(this) = time + 2;    // safety net
                #elif defined(CSQC)
-                       pmove_waterjumptime = 2;
+                       PHYS_WATERJUMP_TIME(this) = 2;
                #endif
                }
        }
@@ -862,7 +862,7 @@ void PM_swim(entity this, float maxspd_mod)
                                this.velocity = forward * 50;
                                this.velocity_z = 310;
                        #ifdef CSQC
-                               pmove_waterjumptime = 2;
+                               PHYS_WATERJUMP_TIME(this) = 2;
                        #endif
                                UNSET_ONGROUND(this);
                                SET_JUMP_HELD(this);
@@ -886,7 +886,7 @@ void PM_swim(entity this, float maxspd_mod)
        if (IS_DUCKED(this))
        wishspeed *= 0.5;
 
-//     if (pmove_waterjumptime <= 0) // TODO: use
+//     if (PHYS_WATERJUMP_TIME(this) <= 0) // TODO: use
     {
                // water friction
                float f = 1 - PHYS_INPUT_TIMELENGTH * PHYS_FRICTION(this);
@@ -1215,7 +1215,7 @@ void PM_air(entity this, float buttons_prev, float maxspd_mod)
 #ifdef SVQC
        if(time >= PHYS_TELEPORT_TIME(this))
 #elif defined(CSQC)
-       if(pmove_waterjumptime <= 0)
+       if(PHYS_WATERJUMP_TIME(this) <= 0)
 #endif
        {
                float maxairspd = PHYS_MAXAIRSPEED(this) * min(maxspd_mod, 1);
@@ -1297,256 +1297,6 @@ bool IsFlying(entity this)
        return true;
 }
 
-void PM_Main(entity this)
-{
-       int buttons = PHYS_INPUT_BUTTON_MASK(this);
-#ifdef CSQC
-       this.items = STAT(ITEMS);
-
-       this.movement = PHYS_INPUT_MOVEVALUES(this);
-
-       this.spectatorspeed = STAT(SPECTATORSPEED);
-
-       this.team = myteam + 1; // is this correct?
-       if (!(PHYS_INPUT_BUTTON_JUMP(this))) // !jump
-               UNSET_JUMP_HELD(this); // canjump = true
-       pmove_waterjumptime -= PHYS_INPUT_TIMELENGTH;
-
-       PM_ClientMovement_UpdateStatus(this, true);
-#endif
-
-       this.oldmovement = this.movement;
-
-
-#ifdef SVQC
-       WarpZone_PlayerPhysics_FixVAngle(this);
-#endif
-       float maxspeed_mod = 1;
-       maxspeed_mod *= PHYS_HIGHSPEED(this);
-
-#ifdef SVQC
-       Physics_UpdateStats(this, maxspeed_mod);
-
-       if (this.PlayerPhysplug)
-               if (this.PlayerPhysplug(this))
-                       return;
-#elif defined(CSQC)
-       if(hud != HUD_NORMAL)
-               return; // no vehicle prediction (yet)
-#endif
-
-#ifdef SVQC
-       anticheat_physics(this);
-#endif
-
-       if (PM_check_specialcommand(this, buttons))
-               return;
-#ifdef SVQC
-       if (sv_maxidle > 0)
-       {
-               if (buttons != this.buttons_old || this.movement != this.movement_old || this.v_angle != this.v_angle_old)
-                       this.parm_idlesince = time;
-       }
-#endif
-       int buttons_prev = this.buttons_old;
-       this.buttons_old = buttons;
-       this.movement_old = this.movement;
-       this.v_angle_old = this.v_angle;
-
-       PM_check_nickspam(this);
-
-       PM_check_punch(this);
-#ifdef SVQC
-       if (IS_BOT_CLIENT(this))
-       {
-               if (playerdemo_read(this))
-                       return;
-               bot_think(this);
-       }
-#endif
-
-#ifdef SVQC
-       if (IS_PLAYER(this))
-       {
-               const bool allowed_to_move = (time >= game_starttime);
-               if (!allowed_to_move)
-               {
-                       this.velocity = '0 0 0';
-                       this.movetype = MOVETYPE_NONE;
-                       this.disableclientprediction = 2;
-               }
-               else if (this.disableclientprediction == 2)
-               {
-                       if (this.movetype == MOVETYPE_NONE)
-                               this.movetype = MOVETYPE_WALK;
-                       this.disableclientprediction = 0;
-               }
-       }
-#endif
-
-#ifdef SVQC
-       if (this.movetype == MOVETYPE_NONE)
-               return;
-
-       // when we get here, disableclientprediction cannot be 2
-       this.disableclientprediction = 0;
-#endif
-
-       viewloc_PlayerPhysics(this);
-
-       PM_check_frozen(this);
-
-       PM_check_blocked(this);
-
-       maxspeed_mod = 1;
-
-       if (this.in_swamp)
-               maxspeed_mod *= this.swamp_slowdown; //cvar("g_balance_swamp_moverate");
-
-       // conveyors: first fix velocity
-       if (this.conveyor.state)
-               this.velocity -= this.conveyor.movedir;
-
-       MUTATOR_CALLHOOK(PlayerPhysics, this);
-
-       if (!IS_PLAYER(this))
-       {
-#ifdef SVQC
-               maxspeed_mod = autocvar_sv_spectator_speed_multiplier;
-               if (!this.spectatorspeed)
-                       this.spectatorspeed = maxspeed_mod;
-               if (this.impulse && this.impulse <= 19 || (this.impulse >= 200 && this.impulse <= 209) || (this.impulse >= 220 && 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)
-                                       this.spectatorspeed = maxspeed_mod;
-                               else if (this.impulse == 12 || this.impulse == 16  || this.impulse == 19 || (this.impulse >= 220 && 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);
-                       } // otherwise just clear
-                       this.impulse = 0;
-               }
-#endif
-               maxspeed_mod = this.spectatorspeed;
-       }
-#ifdef SVQC
-
-       float spd = max(PHYS_MAXSPEED(this), PHYS_MAXAIRSPEED(this)) * maxspeed_mod;
-       if(this.speed != spd)
-       {
-               this.speed = spd;
-               string temps = ftos(spd);
-               stuffcmd(this, strcat("cl_forwardspeed ", temps, "\n"));
-               stuffcmd(this, strcat("cl_backspeed ", temps, "\n"));
-               stuffcmd(this, strcat("cl_sidespeed ", temps, "\n"));
-               stuffcmd(this, strcat("cl_upspeed ", temps, "\n"));
-       }
-
-       if(this.jumpspeedcap_min != autocvar_sv_jumpspeedcap_min)
-       {
-               this.jumpspeedcap_min = autocvar_sv_jumpspeedcap_min;
-               stuffcmd(this, sprintf("\ncl_jumpspeedcap_min \"%s\"\n", autocvar_sv_jumpspeedcap_min));
-       }
-       if(this.jumpspeedcap_max != autocvar_sv_jumpspeedcap_max)
-       {
-               this.jumpspeedcap_max = autocvar_sv_jumpspeedcap_max;
-               stuffcmd(this, sprintf("\ncl_jumpspeedcap_max \"%s\"\n", autocvar_sv_jumpspeedcap_max));
-       }
-#endif
-
-       if(IS_DEAD(this))
-       {
-               // handle water here
-               vector midpoint = ((this.absmin + this.absmax) * 0.5);
-               if(pointcontents(midpoint) == CONTENT_WATER)
-               {
-                       this.velocity = this.velocity * 0.5;
-
-                       // do we want this?
-                       //if(pointcontents(midpoint + '0 0 2') == CONTENT_WATER)
-                               //{ this.velocity_z = 70; }
-               }
-               goto end;
-       }
-
-#ifdef SVQC
-       if (!this.fixangle)
-               this.angles = '0 1 0' * this.v_angle.y;
-#endif
-
-       if (IS_PLAYER(this) && IS_ONGROUND(this))
-       {
-               PM_check_hitground(this);
-               PM_Footsteps(this);
-       }
-
-#ifdef SVQC
-       if(IsFlying(this))
-               this.wasFlying = 1;
-#endif
-
-       if (IS_PLAYER(this))
-               CheckPlayerJump(this);
-
-       if (this.flags & FL_WATERJUMP)
-       {
-               this.velocity_x = this.movedir.x;
-               this.velocity_y = this.movedir.y;
-               if (time > PHYS_TELEPORT_TIME(this) || this.waterlevel == WATERLEVEL_NONE
-               #ifdef CSQC
-                       || pmove_waterjumptime <= 0
-               #endif
-                       )
-               {
-                       this.flags &= ~FL_WATERJUMP;
-                       PHYS_TELEPORT_TIME(this) = 0;
-               #ifdef CSQC
-                       pmove_waterjumptime = 0;
-               #endif
-               }
-       }
-
-       else if (MUTATOR_CALLHOOK(PM_Physics, this, maxspeed_mod))
-               { }
-
-#ifdef SVQC
-       else if (this.movetype == MOVETYPE_NOCLIP || this.movetype == MOVETYPE_FLY || this.movetype == MOVETYPE_FLY_WORLDONLY || MUTATOR_CALLHOOK(IsFlying, this))
-#elif defined(CSQC)
-       else if (this.move_movetype == MOVETYPE_NOCLIP || this.move_movetype == MOVETYPE_FLY || this.move_movetype == MOVETYPE_FLY_WORLDONLY || MUTATOR_CALLHOOK(IsFlying, this))
-#endif
-               PM_fly(this, maxspeed_mod);
-
-       else if (this.waterlevel >= WATERLEVEL_SWIMMING)
-               PM_swim(this, maxspeed_mod);
-
-       else if (time < this.ladder_time)
-               PM_ladder(this, maxspeed_mod);
-
-       else if (ITEMS_STAT(this) & IT_USING_JETPACK)
-               PM_jetpack(this, maxspeed_mod);
-
-       else if (IS_ONGROUND(this))
-               PM_walk(this, maxspeed_mod);
-
-       else
-               PM_air(this, buttons_prev, maxspeed_mod);
-
-LABEL(end)
-       if (IS_ONGROUND(this))
-               this.lastground = time;
-
-       // conveyors: then break velocity again
-       if(this.conveyor.state)
-               this.velocity += this.conveyor.movedir;
-
-       this.lastflags = this.flags;
-
-       this.lastclassname = this.classname;
-}
 
 void sys_phys_update(entity this, float dt);
 #if defined(SVQC)
index fd1b610de68811c11c405afdd6eef9f8eed43b58..5ce35dedceb80398e374662084de1bfe6b63f56e 100644 (file)
@@ -156,14 +156,19 @@ STATIC_INIT(PHYS_INPUT_BUTTON_JETPACK)
 #define ITEMS_STAT(s)                       ((s).items)
 
 .float teleport_time;
+#define PHYS_TELEPORT_TIME(s)               ((s).teleport_time)
+
+.float waterjump_time;
+#define PHYS_WATERJUMP_TIME(s)               ((s).waterjump_time)
 
 #ifdef CSQC
 
+       #define PHYS_FIXANGLE(s) ('0 0 0')
+       #define PHYS_MOVETYPE(s) ((s).move_movetype)
+
        string autocvar_cl_jumpspeedcap_min;
        string autocvar_cl_jumpspeedcap_max;
 
-       noref float pmove_waterjumptime;
-
        const int FL_WATERJUMP = 2048;  // player jumping out of water
        const int FL_JUMPRELEASED = 4096;  // for jump debouncing
 
@@ -187,8 +192,6 @@ STATIC_INIT(PHYS_INPUT_BUTTON_JETPACK)
 
        #define PHYS_GRAVITY(s)                     STAT(MOVEVARS_GRAVITY, s)
 
-       #define PHYS_TELEPORT_TIME(s)               ((s).teleport_time)
-
        #define TICRATE                             ticrate
 
        #define PHYS_INPUT_ANGLES(s)                input_angles
@@ -237,6 +240,9 @@ STATIC_INIT(PHYS_INPUT_BUTTON_JETPACK)
 
 #elif defined(SVQC)
 
+       #define PHYS_FIXANGLE(s) ((s).fixangle)
+       #define PHYS_MOVETYPE(s) ((s).movetype)
+
        bool Physics_Valid(string thecvar);
 
        .float stat_sv_airspeedlimit_nonqw = _STAT(MOVEVARS_AIRSPEEDLIMIT_NONQW);
@@ -246,8 +252,6 @@ STATIC_INIT(PHYS_INPUT_BUTTON_JETPACK)
        .string jumpspeedcap_min;
        .string jumpspeedcap_max;
 
-       #define PHYS_TELEPORT_TIME(s)               ((s).teleport_time)
-
        #define PHYS_GRAVITY(s)                     autocvar_sv_gravity
 
        #define TICRATE sys_frametime
index 37944ca5c3f8d026ce1ae1b5a7c9da7188ec5b08..bc1c66ace4cb1746ed0b723bcfa1d7dcb4b6374a 100644 (file)
@@ -1,6 +1,7 @@
 #pragma once
 
 COMPONENT(in);
-.vector com_in_move;
+.vector com_in_move, com_in_move_prev;
 .vector com_in_angles;
 .bool   com_in_jump;
+.bool   com_in_crouch;
index f79d7f065134aaff00519783a734cb1bba4ea8b7..a5ada6cfbed8684281f77a42c6ee4b24c0c161bd 100644 (file)
@@ -1,2 +1,9 @@
 // generated file; do not modify
+#include <ecs/systems/input.qc>
 #include <ecs/systems/physics.qc>
+#ifdef CSQC
+    #include <ecs/systems/cl_physics.qc>
+#endif
+#ifdef SVQC
+    #include <ecs/systems/sv_physics.qc>
+#endif
index e71e0591c747dfe996fa2295a73d1b363ac395dc..869aefd5571e4907ba47f65867eb415a276f6767 100644 (file)
@@ -1,2 +1,3 @@
 // generated file; do not modify
+#include <ecs/systems/input.qh>
 #include <ecs/systems/physics.qh>
diff --git a/qcsrc/ecs/systems/cl_physics.qc b/qcsrc/ecs/systems/cl_physics.qc
new file mode 100644 (file)
index 0000000..52e8ed0
--- /dev/null
@@ -0,0 +1,30 @@
+#include "physics.qh"
+
+void sys_phys_fix(entity this, float dt)
+{
+       this.team = myteam + 1; // is this correct?
+       PHYS_WATERJUMP_TIME(this) -= dt;
+       this.oldmovement = this.movement;
+       this.movement = PHYS_INPUT_MOVEVALUES(this);
+       this.items = STAT(ITEMS, this);
+       this.spectatorspeed = STAT(SPECTATORSPEED, this);
+       if (!(PHYS_INPUT_BUTTON_JUMP(this))) // !jump
+               UNSET_JUMP_HELD(this);           // canjump = true
+       PM_ClientMovement_UpdateStatus(this, true);
+}
+
+bool sys_phys_override(entity this)
+{
+       // no vehicle prediction
+       return hud != HUD_NORMAL;
+}
+
+void sys_phys_monitor(entity this) {}
+
+void sys_phys_ai(entity this) {}
+
+void sys_phys_pregame_hold(entity this) {}
+
+void sys_phys_spectator_control(entity this) {}
+
+void sys_phys_fixspeed(entity this, float maxspeed_mod) {}
diff --git a/qcsrc/ecs/systems/input.qc b/qcsrc/ecs/systems/input.qc
new file mode 100644 (file)
index 0000000..eac3625
--- /dev/null
@@ -0,0 +1,7 @@
+#include "input.qh"
+
+void sys_in_update(entity this, float dt)
+{
+       this.com_in_jump = PHYS_INPUT_BUTTON_JUMP(this);
+       this.com_in_crouch = PHYS_INPUT_BUTTON_CROUCH(this);
+}
diff --git a/qcsrc/ecs/systems/input.qh b/qcsrc/ecs/systems/input.qh
new file mode 100644 (file)
index 0000000..fc3f11a
--- /dev/null
@@ -0,0 +1,3 @@
+#pragma once
+
+SYSTEM(in, 30, 10);
index 8348b87851cc82f8e3bf6999d54bd01a6246116b..3457198c5e093d0af6d5888aaa2b11901f776ab7 100644 (file)
@@ -1,6 +1,113 @@
 #include "physics.qh"
+#include "input.qh"
+
+.int disableclientprediction;
 
 void sys_phys_update(entity this, float dt)
 {
-       PM_Main(this);
+       sys_in_update(this, dt);
+
+       sys_phys_fix(this, dt);
+       if (sys_phys_override(this)) return;
+       sys_phys_monitor(this);
+
+       int buttons_prev = this.buttons_old;
+       this.buttons_old = PHYS_INPUT_BUTTON_MASK(this);
+       this.movement_old = this.movement;
+       this.v_angle_old = this.v_angle;
+
+       sys_phys_ai(this);
+
+       sys_phys_pregame_hold(this);
+
+       if (IS_SVQC) {
+               if (PHYS_MOVETYPE(this) == MOVETYPE_NONE) return;
+
+               // when we get here, disableclientprediction cannot be 2
+               this.disableclientprediction = 0;
+       }
+
+       viewloc_PlayerPhysics(this);
+
+       PM_check_frozen(this);
+
+       PM_check_blocked(this);
+
+       float maxspeed_mod = (!this.in_swamp) ? 1 : this.swamp_slowdown; // cvar("g_balance_swamp_moverate");
+
+// conveyors: first fix velocity
+       if (this.conveyor.state) this.velocity -= this.conveyor.movedir;
+
+       MUTATOR_CALLHOOK(PlayerPhysics, this);
+
+       if (!IS_PLAYER(this)) {
+               sys_phys_spectator_control(this);
+               maxspeed_mod = this.spectatorspeed;
+       }
+       sys_phys_fixspeed(this, maxspeed_mod);
+
+       if (IS_DEAD(this)) {
+               // handle water here
+               vector midpoint = ((this.absmin + this.absmax) * 0.5);
+               if (pointcontents(midpoint) == CONTENT_WATER) {
+                       this.velocity = this.velocity * 0.5;
+
+                       // do we want this?
+                       // if(pointcontents(midpoint + '0 0 2') == CONTENT_WATER)
+                       // { this.velocity_z = 70; }
+               }
+               goto end;
+       }
+
+       if (IS_SVQC && !PHYS_FIXANGLE(this)) this.angles = '0 1 0' * this.v_angle.y;
+
+       if (IS_PLAYER(this)) {
+               if (IS_ONGROUND(this)) {
+                       PM_check_hitground(this);
+                       PM_Footsteps(this);
+               } else if (IsFlying(this)) {
+                       this.wasFlying = true;
+               }
+               CheckPlayerJump(this);
+       }
+
+       if (this.flags & FL_WATERJUMP) {
+               this.velocity_x = this.movedir.x;
+               this.velocity_y = this.movedir.y;
+               if (time > PHYS_TELEPORT_TIME(this)
+                   || this.waterlevel == WATERLEVEL_NONE
+                   || PHYS_WATERJUMP_TIME(this) <= 0
+                  ) {
+                       this.flags &= ~FL_WATERJUMP;
+                       PHYS_TELEPORT_TIME(this) = 0;
+                       PHYS_WATERJUMP_TIME(this) = 0;
+               }
+       } else if (MUTATOR_CALLHOOK(PM_Physics, this, maxspeed_mod)) {
+               // handled
+       } else if (PHYS_MOVETYPE(this) == MOVETYPE_NOCLIP
+           || PHYS_MOVETYPE(this) == MOVETYPE_FLY
+           || PHYS_MOVETYPE(this) == MOVETYPE_FLY_WORLDONLY
+           || MUTATOR_CALLHOOK(IsFlying, this)) {
+               PM_fly(this, maxspeed_mod);
+       } else if (this.waterlevel >= WATERLEVEL_SWIMMING) {
+               PM_swim(this, maxspeed_mod);
+       } else if (time < this.ladder_time) {
+               PM_ladder(this, maxspeed_mod);
+       } else if (ITEMS_STAT(this) & IT_USING_JETPACK) {
+               PM_jetpack(this, maxspeed_mod);
+       } else if (IS_ONGROUND(this)) {
+               PM_walk(this, maxspeed_mod);
+       } else {
+               PM_air(this, buttons_prev, maxspeed_mod);
+       }
+
+       LABEL(end)
+       if (IS_ONGROUND(this)) this.lastground = time;
+
+// conveyors: then break velocity again
+       if (this.conveyor.state) this.velocity += this.conveyor.movedir;
+
+       this.lastflags = this.flags;
+
+       this.lastclassname = this.classname;
 }
index 38d4e55e55e94da8a31ba67c1ff3f832a286932c..16c996adee6ccf97ae82f3400a0fd71eeb14fb7f 100644 (file)
@@ -1,3 +1,11 @@
 #pragma once
 
 SYSTEM(phys, 30, 10);
+
+void sys_phys_fix(entity this, float dt);
+bool sys_phys_override(entity this);
+void sys_phys_monitor(entity this);
+void sys_phys_pregame_hold(entity this);
+void sys_phys_ai(entity this);
+void sys_phys_spectator_control(entity this);
+void sys_phys_fixspeed(entity this, float maxspeed_mod);
diff --git a/qcsrc/ecs/systems/sv_physics.qc b/qcsrc/ecs/systems/sv_physics.qc
new file mode 100644 (file)
index 0000000..5c480fe
--- /dev/null
@@ -0,0 +1,97 @@
+#include "physics.qh"
+
+void sys_phys_fix(entity this, float dt)
+{
+       WarpZone_PlayerPhysics_FixVAngle(this);
+       Physics_UpdateStats(this, PHYS_HIGHSPEED(this));
+}
+
+bool sys_phys_override(entity this)
+{
+       int buttons = PHYS_INPUT_BUTTON_MASK(this);
+       if (PM_check_specialcommand(this, buttons)) return true;
+       if (this.PlayerPhysplug && this.PlayerPhysplug(this)) return true;
+       return false;
+}
+
+void sys_phys_monitor(entity this)
+{
+       int buttons = PHYS_INPUT_BUTTON_MASK(this);
+       anticheat_physics(this);
+       if (sv_maxidle > 0) {
+               if (buttons != this.buttons_old
+                   || this.movement != this.movement_old
+                   || this.v_angle != this.v_angle_old) this.parm_idlesince = time;
+       }
+       PM_check_nickspam(this);
+       PM_check_punch(this);
+}
+
+void sys_phys_ai(entity this)
+{
+       if (!IS_BOT_CLIENT(this)) return;
+       if (playerdemo_read(this)) return;
+       bot_think(this);
+}
+
+void sys_phys_pregame_hold(entity this)
+{
+       if (!IS_PLAYER(this)) return;
+       const bool allowed_to_move = (time >= game_starttime);
+       if (!allowed_to_move) {
+               this.velocity = '0 0 0';
+               this.movetype = MOVETYPE_NONE;
+               this.disableclientprediction = 2;
+       } else if (this.disableclientprediction == 2) {
+               if (this.movetype == MOVETYPE_NONE) this.movetype = MOVETYPE_WALK;
+               this.disableclientprediction = 0;
+       }
+}
+
+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 (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) this.spectatorspeed = maxspeed_mod;
+                       else if (this.impulse == 12
+                           || this.impulse == 16
+                           || this.impulse == 19
+                           || (this.impulse >= 220 && 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);
+               }  // otherwise just clear
+               this.impulse = 0;
+       }
+}
+
+void sys_phys_fixspeed(entity this, float maxspeed_mod)
+{
+       float spd = max(PHYS_MAXSPEED(this), PHYS_MAXAIRSPEED(this)) * maxspeed_mod;
+       if (this.speed != spd) {
+               this.speed = spd;
+               string temps = ftos(spd);
+               stuffcmd(this, strcat("cl_forwardspeed ", temps, "\n"));
+               stuffcmd(this, strcat("cl_backspeed ", temps, "\n"));
+               stuffcmd(this, strcat("cl_sidespeed ", temps, "\n"));
+               stuffcmd(this, strcat("cl_upspeed ", temps, "\n"));
+       }
+
+       if (this.jumpspeedcap_min != autocvar_sv_jumpspeedcap_min) {
+               this.jumpspeedcap_min = autocvar_sv_jumpspeedcap_min;
+               stuffcmd(this, sprintf("\ncl_jumpspeedcap_min \"%s\"\n", autocvar_sv_jumpspeedcap_min));
+       }
+       if (this.jumpspeedcap_max != autocvar_sv_jumpspeedcap_max) {
+               this.jumpspeedcap_max = autocvar_sv_jumpspeedcap_max;
+               stuffcmd(this, sprintf("\ncl_jumpspeedcap_max \"%s\"\n", autocvar_sv_jumpspeedcap_max));
+       }
+}
index 61755fe94322e1d360390792823fcb0d9ed77d6e..d121f1e661371e121a65d56e358ebb4ddbc39ac3 100644 (file)
@@ -2,6 +2,18 @@
        #define COMPAT_NO_MOD_IS_XONOTIC
 #endif
 
+#ifdef CSQC
+#define IS_CSQC 1
+#else
+#define IS_CSQC 0
+#endif
+
+#ifdef SVQC
+#define IS_SVQC 1
+#else
+#define IS_SVQC 0
+#endif
+
 #include "compiler.qh"
 
 #ifndef QCC_SUPPORT_INT
index 98cdab9dd51b3036def6ce08a78f128abdc91d22..692cb06eef295d5f2c7f2e20c73182b735722743 100644 (file)
@@ -418,7 +418,7 @@ sp_angle_shift                           = ignore   # ignore/add/remove/force
 sp_permit_cpp11_shift                    = false    # false/true
 
 # Add or remove space before '(' of 'if', 'for', 'switch', and 'while'
-sp_before_sparen                         = add      # ignore/add/remove/force #force
+sp_before_sparen                         = force    # ignore/add/remove/force #force
 
 # Add or remove space inside if-condition '(' and ')'
 # NOTE: is 68 worse than ignore
@@ -431,10 +431,10 @@ sp_inside_sparen_close                   = ignore   # ignore/add/remove/force #f
 sp_inside_sparen_open                    = ignore   # ignore/add/remove/force #force
 
 # Add or remove space after ')' of 'if', 'for', 'switch', and 'while'
-sp_after_sparen                          = add      # ignore/add/remove/force
+sp_after_sparen                          = force    # ignore/add/remove/force
 
 # Add or remove space between ')' and '{' of 'if', 'for', 'switch', and 'while'
-sp_sparen_brace                          = add      # ignore/add/remove/force
+sp_sparen_brace                          = force    # ignore/add/remove/force
 
 # Add or remove space between 'invariant' and '(' in the D language.
 sp_invariant_paren                       = ignore   # ignore/add/remove/force #ignore
@@ -630,11 +630,11 @@ sp_macro                                 = remove   # ignore/add/remove/force #f
 sp_macro_func                            = remove   # ignore/add/remove/force #force
 
 # Add or remove space between 'else' and '{' if on the same line
-sp_else_brace                            = add      # ignore/add/remove/force
+sp_else_brace                            = force    # ignore/add/remove/force
 
 # Add or remove space between '}' and 'else' if on the same line
 # WARNING: Code doesn't seem to use this feature - delete from the config?
-sp_brace_else                            = ignore   # ignore/add/remove/force
+sp_brace_else                            = force    # ignore/add/remove/force
 
 # Add or remove space between '}' and the name of a typedef on the same line
 sp_brace_typedef                         = add      # ignore/add/remove/force
@@ -1116,17 +1116,17 @@ nl_union_brace                           = ignore   # ignore/add/remove/force
 
 # Add or remove newline between 'if' and '{'
 # NOTE: is 136 worse than ignore
-nl_if_brace                              = add      # ignore/add/remove/force
+nl_if_brace                              = remove   # ignore/add/remove/force
 
 # Add or remove newline between '}' and 'else'
-nl_brace_else                            = add      # ignore/add/remove/force
+nl_brace_else                            = remove   # ignore/add/remove/force
 
 # Add or remove newline between 'else if' and '{'
 # If set to ignore, nl_if_brace is used instead
-nl_elseif_brace                          = add      # ignore/add/remove/force
+nl_elseif_brace                          = remove   # ignore/add/remove/force
 
 # Add or remove newline between 'else' and '{'
-nl_else_brace                            = add      # ignore/add/remove/force
+nl_else_brace                            = remove   # ignore/add/remove/force
 
 # Add or remove newline between 'else' and 'if'
 nl_else_if                               = remove   # ignore/add/remove/force
@@ -1137,7 +1137,7 @@ nl_brace_finally                         = ignore   # ignore/add/remove/force
 
 # Add or remove newline between 'finally' and '{'
 # WARNING: Code doesn't seem to use this feature - delete from the config?
-nl_finally_brace                         = ignore   # ignore/add/remove/force
+nl_finally_brace                         = remove   # ignore/add/remove/force
 
 # Add or remove newline between 'try' and '{'
 # WARNING: Code doesn't seem to use this feature - delete from the config?
@@ -1149,7 +1149,7 @@ nl_getset_brace                          = ignore   # ignore/add/remove/force
 
 # Add or remove newline between 'for' and '{'
 # NOTE: is 109 worse than ignore
-nl_for_brace                             = add      # ignore/add/remove/force
+nl_for_brace                             = remove   # ignore/add/remove/force
 
 # Add or remove newline between 'catch' and '{'
 # WARNING: Code doesn't seem to use this feature - delete from the config?
@@ -1161,7 +1161,7 @@ nl_brace_catch                           = ignore   # ignore/add/remove/force
 
 # Add or remove newline between 'while' and '{'
 # NOTE: is 22 worse than ignore
-nl_while_brace                           = add      # ignore/add/remove/force
+nl_while_brace                           = remove   # ignore/add/remove/force
 
 # Add or remove newline between 'scope (x)' and '{' (D)
 # WARNING: Code doesn't seem to use this feature - delete from the config?
@@ -1608,7 +1608,7 @@ mod_pawn_semicolon                       = false    # false/true
 mod_full_paren_if_bool                   = false    # false/true
 
 # Whether to remove superfluous semicolons
-mod_remove_extra_semicolon               = false    # false/true
+mod_remove_extra_semicolon               = true     # false/true
 
 # If a function body exceeds the specified number of newlines and doesn't have a comment after
 # the close brace, a comment will be added.