]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Pause in singleplayer when using any menu. Closes #1196
authorTimePath <andrew.hardaker1995@gmail.com>
Tue, 22 Dec 2015 10:55:10 +0000 (21:55 +1100)
committerTimePath <andrew.hardaker1995@gmail.com>
Tue, 22 Dec 2015 10:55:41 +0000 (21:55 +1100)
qcsrc/client/view.qc
qcsrc/common/movetypes/movetypes.qc
qcsrc/common/movetypes/step.qc
qcsrc/common/movetypes/toss.qc
qcsrc/common/movetypes/walk.qc
qcsrc/common/mutators/mutator/dodging/dodging.qc
qcsrc/common/physics.qc
qcsrc/common/physics.qh
qcsrc/server/defs.qh
qcsrc/server/sv_main.qc

index 6d2811f8b69008aa42829fad9cb48212663b426b..83505237de521f9903f25e3739d77ec2a46c3190 100644 (file)
@@ -2197,6 +2197,7 @@ void CSQC_UpdateView(float w, float h)
                HUD_Radar_Mouse();
 
        cl_notice_run();
+       unpause_update();
        Net_Flush();
 
        // let's reset the view back to normal for the end
index ab7d51fe6de7c59006e876f599058fdaca69bdc1..fc9396b30b63fb25292fd20c06760ffd262c5bbb 100644 (file)
@@ -226,7 +226,7 @@ int _Movetype_FlyMove(entity this, float dt, bool applygravity, vector stepnorma
        }
 
        // LordHavoc: this came from QW and allows you to get out of water more easily
-       if(GAMEPLAYFIX_EASIERWATERJUMP && (this.move_flags & FL_WATERJUMP) && !(blocked & 8))
+       if(GAMEPLAYFIX_EASIERWATERJUMP(this) && (this.move_flags & FL_WATERJUMP) && !(blocked & 8))
                this.move_velocity = primal_velocity;
 
        if(applygravity)
index eec9b4c0965d4b27e640bc29441d503625fca5f7..d7a2d562747ebd2aa8967daef7028fb150b6eaee 100644 (file)
@@ -2,7 +2,7 @@ void _Movetype_Physics_Step(entity this, float dt) // SV_Physics_Step
 {
        if(this.move_flags & FL_ONGROUND)
        {
-               if(this.velocity_z >= (1.0 / 32.0) && UPWARD_VELOCITY_CLEARS_ONGROUND)
+               if(this.velocity_z >= (1.0 / 32.0) && UPWARD_VELOCITY_CLEARS_ONGROUND(this))
                {
                        this.move_flags &= ~FL_ONGROUND;
                        _Movetype_CheckVelocity(this);
index 3029c9a9df8b4385ffd3c541de993648dd73b787..43b5a8a1a8e41d5dfe019fff8a686a0f32fff7ae 100644 (file)
@@ -4,7 +4,7 @@ void _Movetype_Physics_Toss(entity this, float dt)  // SV_Physics_Toss
 {
        if (this.move_flags & FL_ONGROUND)
        {
-               if (this.move_velocity.z >= 1 / 32 && UPWARD_VELOCITY_CLEARS_ONGROUND)
+               if (this.move_velocity.z >= 1 / 32 && UPWARD_VELOCITY_CLEARS_ONGROUND(this))
                {
                        this.move_flags &= ~FL_ONGROUND;
                }
index 7fab2787ea01ceb85baacc4c5f4680074b9f9044..e926246266c6761215058a7f293adc421e18562a 100644 (file)
@@ -6,7 +6,7 @@ void _Movetype_Physics_Walk(entity this, float dt)  // SV_WalkMove
        if (dt <= 0)
                return;
 
-       if (GAMEPLAYFIX_UNSTICKPLAYERS)
+       if (GAMEPLAYFIX_UNSTICKPLAYERS(this))
                _Movetype_UnstickEntity(this);
 
        bool applygravity = (!_Movetype_CheckWater(this) && this.move_movetype == MOVETYPE_WALK && !(this.move_flags & FL_WATERJUMP));
@@ -19,9 +19,9 @@ void _Movetype_Physics_Walk(entity this, float dt)  // SV_WalkMove
        vector start_origin = this.move_origin;
        vector start_velocity = this.move_velocity;
 
-       int clip = _Movetype_FlyMove(this, dt, applygravity, stepnormal, GAMEPLAYFIX_STEPMULTIPLETIMES ? PHYS_STEPHEIGHT : 0);
+       int clip = _Movetype_FlyMove(this, dt, applygravity, stepnormal, GAMEPLAYFIX_STEPMULTIPLETIMES(this) ? PHYS_STEPHEIGHT(this) : 0);
 
-       if (GAMEPLAYFIX_DOWNTRACEONGROUND && !(clip & 1))
+       if (GAMEPLAYFIX_DOWNTRACEONGROUND(this) && !(clip & 1))
        {
                // only try this if there was no floor in the way in the trace (no,
                // this check seems to be not REALLY necessary, because if clip & 1,
@@ -54,7 +54,7 @@ void _Movetype_Physics_Walk(entity this, float dt)  // SV_WalkMove
        if (this.move_flags & FL_WATERJUMP)
                return;
 
-       if (PHYS_NOSTEP)
+       if (PHYS_NOSTEP(this))
                return;
 
        vector originalmove_origin = this.move_origin;
@@ -77,7 +77,7 @@ void _Movetype_Physics_Walk(entity this, float dt)  // SV_WalkMove
                                return;
 
                        // return if attempting to jump while airborn (unless sv_jumpstep)
-                       if (!PHYS_JUMPSTEP)
+                       if (!PHYS_JUMPSTEP(this))
                                if (!oldonground && this.move_waterlevel == 0)
                                        return;
                }
@@ -88,7 +88,7 @@ void _Movetype_Physics_Walk(entity this, float dt)  // SV_WalkMove
                this.move_velocity = start_velocity;
 
                // move up
-               vector upmove = '0 0 1' * PHYS_STEPHEIGHT;
+               vector upmove = '0 0 1' * PHYS_STEPHEIGHT(this);
                _Movetype_PushEntity(this, upmove, true);
                if(wasfreed(this))
                        return;
@@ -133,17 +133,17 @@ void _Movetype_Physics_Walk(entity this, float dt)  // SV_WalkMove
                // Con_Printf("step - ");
 
                // extra friction based on view angle
-               if ((clip & 2) && PHYS_WALLFRICTION)
+               if ((clip & 2) && PHYS_WALLFRICTION(this))
                        _Movetype_WallFriction(this, stepnormal);
        }
        // don't do the down move if stepdown is disabled, moving upward, not in water, or the move started offground or ended onground
-       else if (!GAMEPLAYFIX_STEPDOWN || this.move_waterlevel >= 3 || start_velocity.z >= (1.0 / 32.0) || !oldonground || (this.move_flags & FL_ONGROUND))
+       else if (!GAMEPLAYFIX_STEPDOWN(this) || this.move_waterlevel >= 3 || start_velocity.z >= (1.0 / 32.0) || !oldonground || (this.move_flags & FL_ONGROUND))
        {
                return;
        }
 
        // move down
-       vector downmove = '0 0 1' * (-PHYS_STEPHEIGHT + start_velocity.z * dt);
+       vector downmove = '0 0 1' * (-PHYS_STEPHEIGHT(this) + start_velocity.z * dt);
        _Movetype_PushEntity(this, downmove, true);
        if(wasfreed(this))
                return;
index 3521ca77f7c838c05efa5094a9b4215f2f087c13..d2debd8bf07d1c8345ab0da3b0a78479227fbca7 100644 (file)
@@ -115,7 +115,7 @@ float PM_dodging_checkpressedkeys(entity this)
        if(!PHYS_DODGING)
                return false;
 
-       float frozen_dodging = (PHYS_FROZEN(this) && PHYS_DODGING_FROZEN);
+       float frozen_dodging = (PHYS_FROZEN(this) && PHYS_DODGING_FROZEN(this));
        float frozen_no_doubletap = (frozen_dodging && !PHYS_DODGING_FROZEN_NODOUBLETAP);
 
        // first check if the last dodge is far enough back in time so we can dodge again
index 6bfb5ac131b26582c38c252cbd5ab5e56cc9aee1..32c2fbfa84ad95d51e4c29637612a0536b755e45 100644 (file)
@@ -232,9 +232,9 @@ void PM_ClientMovement_Move(entity this)
                        // may be a step or wall, try stepping up
                        // first move forward at a higher level
                        currentorigin2 = this.origin;
-                       currentorigin2_z += PHYS_STEPHEIGHT;
+                       currentorigin2_z += PHYS_STEPHEIGHT(this);
                        neworigin2 = neworigin;
-                       neworigin2_z += PHYS_STEPHEIGHT;
+                       neworigin2_z += PHYS_STEPHEIGHT(this);
                        tracebox(currentorigin2, this.mins, this.maxs, neworigin2, MOVE_NORMAL, this);
                        trace2_endpos = trace_endpos;
                        trace2_fraction = trace_fraction;
@@ -491,7 +491,7 @@ bool PlayerJump(entity this)
                // don't do jump speedcaps on ramps to preserve old xonotic ramjump style
                tracebox(this.origin + '0 0 0.01', this.mins, this.maxs, this.origin - '0 0 0.01', MOVE_NORMAL, this);
 
-               if (!(trace_fraction < 1 && trace_plane_normal_z < 0.98 && PHYS_JUMPSPEEDCAP_DISABLE_ONRAMPS))
+               if (!(trace_fraction < 1 && trace_plane_normal_z < 0.98 && PHYS_JUMPSPEEDCAP_DISABLE_ONRAMPS(this)))
                {
                        float maxjumpspeed = mjumpheight * stof(PHYS_JUMPSPEEDCAP_MAX);
 
@@ -508,8 +508,9 @@ bool PlayerJump(entity this)
 #endif
                if(this.lastground < time - 0.3)
                {
-                       this.velocity_x *= (1 - PHYS_FRICTION_ONLAND);
-                       this.velocity_y *= (1 - PHYS_FRICTION_ONLAND);
+                       float f = (1 - PHYS_FRICTION_ONLAND(this));
+                       this.velocity_x *= f;
+                       this.velocity_y *= f;
                }
 #ifdef SVQC
                if(this.jumppadcount > 1)
@@ -585,7 +586,7 @@ void CheckPlayerJump(entity this)
        {
                float air_jump = !PlayerJump(this) || player_multijump; // PlayerJump() has important side effects
                float activate = JETPACK_JUMP(this) && air_jump && PHYS_INPUT_BUTTON_JUMP(this) || PHYS_INPUT_BUTTON_JETPACK(this);
-               float has_fuel = !PHYS_JETPACK_FUEL || PHYS_AMMO_FUEL(this) || ITEMS_STAT(this) & IT_UNLIMITED_WEAPON_AMMO;
+               float has_fuel = !PHYS_JETPACK_FUEL(this) || PHYS_AMMO_FUEL(this) || ITEMS_STAT(this) & IT_UNLIMITED_WEAPON_AMMO;
 
                if (!(ITEMS_STAT(this) & ITEM_Jetpack.m_itemid)) { }
                else if (this.jetpack_stopped) { }
@@ -730,7 +731,7 @@ void PM_check_frozen(entity this)
 {
        if (!PHYS_FROZEN(this))
                return;
-       if (PHYS_DODGING_FROZEN
+       if (PHYS_DODGING_FROZEN(this)
 #ifdef SVQC
        && IS_REAL_CLIENT(this)
 #endif
@@ -995,9 +996,9 @@ void PM_jetpack(entity this, float maxspd_mod)
                wishvel_z = sqrt(max(0, 1 - wishvel * wishvel));
 
        // it is now normalized, so...
-       float a_side = PHYS_JETPACK_ACCEL_SIDE;
-       float a_up = PHYS_JETPACK_ACCEL_UP;
-       float a_add = PHYS_JETPACK_ANTIGRAVITY * PHYS_GRAVITY(this);
+       float a_side = PHYS_JETPACK_ACCEL_SIDE(this);
+       float a_up = PHYS_JETPACK_ACCEL_UP(this);
+       float a_add = PHYS_JETPACK_ANTIGRAVITY(this) * PHYS_GRAVITY(this);
 
        wishvel_x *= a_side;
        wishvel_y *= a_side;
@@ -1045,11 +1046,11 @@ void PM_jetpack(entity this, float maxspd_mod)
        //print("best possible acceleration: ", ftos(best), "\n");
 
        float fxy, fz;
-       fxy = bound(0, 1 - (this.velocity * normalize(wishvel_x * '1 0 0' + wishvel_y * '0 1 0')) / PHYS_JETPACK_MAXSPEED_SIDE, 1);
+       fxy = bound(0, 1 - (this.velocity * normalize(wishvel_x * '1 0 0' + wishvel_y * '0 1 0')) / PHYS_JETPACK_MAXSPEED_SIDE(this), 1);
        if (wishvel_z - PHYS_GRAVITY(this) > 0)
-               fz = bound(0, 1 - this.velocity_z / PHYS_JETPACK_MAXSPEED_UP, 1);
+               fz = bound(0, 1 - this.velocity_z / PHYS_JETPACK_MAXSPEED_UP(this), 1);
        else
-               fz = bound(0, 1 + this.velocity_z / PHYS_JETPACK_MAXSPEED_UP, 1);
+               fz = bound(0, 1 + this.velocity_z / PHYS_JETPACK_MAXSPEED_UP(this), 1);
 
        float fvel;
        fvel = vlen(wishvel);
@@ -1058,8 +1059,8 @@ void PM_jetpack(entity this, float maxspd_mod)
        wishvel_z = (wishvel_z - PHYS_GRAVITY(this)) * fz + PHYS_GRAVITY(this);
 
        fvel = min(1, vlen(wishvel) / best);
-       if (PHYS_JETPACK_FUEL && !(ITEMS_STAT(this) & IT_UNLIMITED_WEAPON_AMMO))
-               f = min(1, PHYS_AMMO_FUEL(this) / (PHYS_JETPACK_FUEL * PHYS_INPUT_TIMELENGTH * fvel));
+       if (PHYS_JETPACK_FUEL(this) && !(ITEMS_STAT(this) & IT_UNLIMITED_WEAPON_AMMO))
+               f = min(1, PHYS_AMMO_FUEL(this) / (PHYS_JETPACK_FUEL(this) * PHYS_INPUT_TIMELENGTH * fvel));
        else
                f = 1;
 
@@ -1072,7 +1073,7 @@ void PM_jetpack(entity this, float maxspd_mod)
 
 #ifdef SVQC
                if (!(ITEMS_STAT(this) & IT_UNLIMITED_WEAPON_AMMO))
-                       this.ammo_fuel -= PHYS_JETPACK_FUEL * PHYS_INPUT_TIMELENGTH * fvel * f;
+                       this.ammo_fuel -= PHYS_JETPACK_FUEL(this) * PHYS_INPUT_TIMELENGTH * fvel * f;
 
                ITEMS_STAT(this) |= IT_USING_JETPACK;
 
@@ -1109,7 +1110,7 @@ void PM_walk(entity this, float maxspd_mod)
                        LOG_TRACE(strcat("landing velocity: ", vtos(this.velocity), " (abs: ", ftos(vlen(this.velocity)), ")\n"));
 #endif
                if (this.lastground < time - 0.3)
-                       this.velocity *= (1 - PHYS_FRICTION_ONLAND);
+                       this.velocity *= (1 - PHYS_FRICTION_ONLAND(this));
 #ifdef SVQC
                if (this.jumppadcount > 1)
                        LOG_TRACE(strcat(ftos(this.jumppadcount), "x jumppad combo\n"));
@@ -1136,7 +1137,7 @@ void PM_walk(entity this, float maxspd_mod)
                // TODO: apply edge friction
                // apply ground friction
                const int realfriction = (trace_dphitq3surfaceflags & Q3SURFACEFLAG_SLICK)
-                       ? PHYS_FRICTION_SLICK
+                       ? PHYS_FRICTION_SLICK(this)
                        : PHYS_FRICTION(this);
 
                float f = sqrt(f2);
@@ -1312,7 +1313,7 @@ void PM_Main(entity this)
        WarpZone_PlayerPhysics_FixVAngle();
 #endif
        float maxspeed_mod = 1;
-       maxspeed_mod *= PHYS_HIGHSPEED;
+       maxspeed_mod *= PHYS_HIGHSPEED(this);
 
 #ifdef SVQC
        Physics_UpdateStats(this, maxspeed_mod);
index 92891ead255826e5c52445ab90bd18cbca5c5a60..66824bbcf6c24c3ee52eee80a231d663619dfd74 100644 (file)
@@ -30,11 +30,11 @@ bool IsFlying(entity a);
 
 #define BUFFS_STAT(s)                       STAT(BUFFS, s)
 
-#define GAMEPLAYFIX_DOWNTRACEONGROUND       STAT(GAMEPLAYFIX_DOWNTRACEONGROUND, this)
-#define GAMEPLAYFIX_EASIERWATERJUMP         STAT(GAMEPLAYFIX_EASIERWATERJUMP, this)
-#define GAMEPLAYFIX_STEPDOWN                STAT(GAMEPLAYFIX_STEPDOWN, this)
-#define GAMEPLAYFIX_STEPMULTIPLETIMES       STAT(GAMEPLAYFIX_STEPMULTIPLETIMES, this)
-#define GAMEPLAYFIX_UNSTICKPLAYERS          STAT(GAMEPLAYFIX_UNSTICKPLAYERS, this)
+#define GAMEPLAYFIX_DOWNTRACEONGROUND(s)    STAT(GAMEPLAYFIX_DOWNTRACEONGROUND, s)
+#define GAMEPLAYFIX_EASIERWATERJUMP(s)      STAT(GAMEPLAYFIX_EASIERWATERJUMP, s)
+#define GAMEPLAYFIX_STEPDOWN(s)             STAT(GAMEPLAYFIX_STEPDOWN, s)
+#define GAMEPLAYFIX_STEPMULTIPLETIMES(s)    STAT(GAMEPLAYFIX_STEPMULTIPLETIMES, s)
+#define GAMEPLAYFIX_UNSTICKPLAYERS(s)       STAT(GAMEPLAYFIX_UNSTICKPLAYERS, s)
 
 #define PHYS_ACCELERATE(s)                  STAT(MOVEVARS_ACCELERATE, s)
 #define PHYS_AIRACCELERATE(s)               STAT(MOVEVARS_AIRACCELERATE, s)
@@ -51,39 +51,39 @@ bool IsFlying(entity a);
 
 #define PHYS_AMMO_FUEL(s)                   STAT(FUEL, s)
 
-#define PHYS_DODGING_FROZEN                                    STAT(DODGING_FROZEN, this)
+#define PHYS_DODGING_FROZEN(s)              STAT(DODGING_FROZEN, s)
 
 #define PHYS_FRICTION(s)                    STAT(MOVEVARS_FRICTION, s)
-#define PHYS_FRICTION_ONLAND                STAT(MOVEVARS_FRICTION_ONLAND, this)
-#define PHYS_FRICTION_SLICK                 STAT(MOVEVARS_FRICTION_SLICK, this)
+#define PHYS_FRICTION_ONLAND(s)             STAT(MOVEVARS_FRICTION_ONLAND, s)
+#define PHYS_FRICTION_SLICK(s)              STAT(MOVEVARS_FRICTION_SLICK, s)
 
 #define PHYS_FROZEN(s)                      STAT(FROZEN, s)
 
-#define PHYS_HIGHSPEED                      STAT(MOVEVARS_HIGHSPEED, this)
+#define PHYS_HIGHSPEED(s)                   STAT(MOVEVARS_HIGHSPEED, s)
 
-#define PHYS_JETPACK_ACCEL_SIDE                        STAT(JETPACK_ACCEL_SIDE, this)
-#define PHYS_JETPACK_ACCEL_UP                          STAT(JETPACK_ACCEL_UP, this)
-#define PHYS_JETPACK_ANTIGRAVITY                       STAT(JETPACK_ANTIGRAVITY, this)
-#define PHYS_JETPACK_FUEL                                      STAT(JETPACK_FUEL, this)
-#define PHYS_JETPACK_MAXSPEED_SIDE                     STAT(JETPACK_MAXSPEED_SIDE, this)
-#define PHYS_JETPACK_MAXSPEED_UP                       STAT(JETPACK_MAXSPEED_UP, this)
+#define PHYS_JETPACK_ACCEL_SIDE(s)          STAT(JETPACK_ACCEL_SIDE, s)
+#define PHYS_JETPACK_ACCEL_UP(s)            STAT(JETPACK_ACCEL_UP, s)
+#define PHYS_JETPACK_ANTIGRAVITY(s)         STAT(JETPACK_ANTIGRAVITY, s)
+#define PHYS_JETPACK_FUEL(s)                STAT(JETPACK_FUEL, s)
+#define PHYS_JETPACK_MAXSPEED_SIDE(s)       STAT(JETPACK_MAXSPEED_SIDE, s)
+#define PHYS_JETPACK_MAXSPEED_UP(s)         STAT(JETPACK_MAXSPEED_UP, s)
 
-#define PHYS_JUMPSPEEDCAP_DISABLE_ONRAMPS   STAT(MOVEVARS_JUMPSPEEDCAP_DISABLE_ONRAMPS, this)
-#define PHYS_JUMPSTEP                                          STAT(MOVEVARS_JUMPSTEP, this)
+#define PHYS_JUMPSPEEDCAP_DISABLE_ONRAMPS(s) STAT(MOVEVARS_JUMPSPEEDCAP_DISABLE_ONRAMPS, s)
+#define PHYS_JUMPSTEP(s)                    STAT(MOVEVARS_JUMPSTEP, s)
 #define PHYS_JUMPVELOCITY(s)                STAT(MOVEVARS_JUMPVELOCITY, s)
 
 #define PHYS_MAXAIRSPEED(s)                 STAT(MOVEVARS_MAXAIRSPEED, s)
 #define PHYS_MAXAIRSTRAFESPEED(s)           STAT(MOVEVARS_MAXAIRSTRAFESPEED, s)
 #define PHYS_MAXSPEED(s)                    STAT(MOVEVARS_MAXSPEED, s)
 
-#define PHYS_NOSTEP                                                    STAT(NOSTEP, this)
-#define PHYS_STEPHEIGHT                     STAT(MOVEVARS_STEPHEIGHT, this)
+#define PHYS_NOSTEP(s)                      STAT(NOSTEP, s)
+#define PHYS_STEPHEIGHT(s)                  STAT(MOVEVARS_STEPHEIGHT, s)
 
 #define PHYS_STOPSPEED(s)                   STAT(MOVEVARS_STOPSPEED, s)
 
 #define PHYS_TRACK_CANJUMP(s)               STAT(MOVEVARS_TRACK_CANJUMP, s)
 
-#define PHYS_WALLFRICTION                                      STAT(MOVEVARS_WALLFRICTION, this)
+#define PHYS_WALLFRICTION(s)                STAT(MOVEVARS_WALLFRICTION, s)
 
 #define PHYS_WARSOWBUNNY_ACCEL(s)           STAT(MOVEVARS_WARSOWBUNNY_ACCEL, s)
 #define PHYS_WARSOWBUNNY_AIRFORWARDACCEL(s) STAT(MOVEVARS_WARSOWBUNNY_AIRFORWARDACCEL, s)
@@ -91,7 +91,56 @@ bool IsFlying(entity a);
 #define PHYS_WARSOWBUNNY_TOPSPEED(s)        STAT(MOVEVARS_WARSOWBUNNY_TOPSPEED, s)
 #define PHYS_WARSOWBUNNY_TURNACCEL(s)       STAT(MOVEVARS_WARSOWBUNNY_TURNACCEL, s)
 
-#define UPWARD_VELOCITY_CLEARS_ONGROUND     STAT(GAMEPLAYFIX_UPVELOCITYCLEARSONGROUND, this)
+#define UPWARD_VELOCITY_CLEARS_ONGROUND(s)  STAT(GAMEPLAYFIX_UPVELOCITYCLEARSONGROUND, s)
+
+#define PHYS_INPUT_BUTTON_ATCK(s)           PHYS_INPUT_BUTTON_BUTTON1(s)
+#define PHYS_INPUT_BUTTON_JUMP(s)           PHYS_INPUT_BUTTON_BUTTON2(s)
+#define PHYS_INPUT_BUTTON_ATCK2(s)          PHYS_INPUT_BUTTON_BUTTON3(s)
+#define PHYS_INPUT_BUTTON_ZOOM(s)           PHYS_INPUT_BUTTON_BUTTON4(s)
+#define PHYS_INPUT_BUTTON_CROUCH(s)         PHYS_INPUT_BUTTON_BUTTON5(s)
+#define PHYS_INPUT_BUTTON_HOOK(s)           PHYS_INPUT_BUTTON_BUTTON6(s)
+#define PHYS_INPUT_BUTTON_INFO(s)           PHYS_INPUT_BUTTON_BUTTON7(s)
+#define PHYS_INPUT_BUTTON_DRAG(s)           PHYS_INPUT_BUTTON_BUTTON8(s)
+#define PHYS_INPUT_BUTTON_USE(s)            PHYS_INPUT_BUTTON_BUTTON_USE(s)
+#define PHYS_INPUT_BUTTON_CHAT(s)           PHYS_INPUT_BUTTON_BUTTON_CHAT(s)
+#define PHYS_INPUT_BUTTON_PRYDON(s)         PHYS_INPUT_BUTTON_BUTTON_PRYDON(s)
+#define PHYS_INPUT_BUTTON_ZOOMSCRIPT(s)     PHYS_INPUT_BUTTON_BUTTON9(s)
+#define PHYS_INPUT_BUTTON_JETPACK(s)        PHYS_INPUT_BUTTON_BUTTON10(s)
+
+// if more buttons are needed, start using impulse bits as buttons
+
+#define PHYS_INPUT_BUTTON_BACKWARD(s)       (PHYS_INPUT_MOVEVALUES(s).x < 0)
+#define PHYS_INPUT_BUTTON_FORWARD(s)        (PHYS_INPUT_MOVEVALUES(s).x > 0)
+#define PHYS_INPUT_BUTTON_LEFT(s)           (PHYS_INPUT_MOVEVALUES(s).y < 0)
+#define PHYS_INPUT_BUTTON_RIGHT(s)          (PHYS_INPUT_MOVEVALUES(s).y > 0)
+
+// used for special commands and idle checking, not from the engine
+// TODO: cache
+#define PHYS_INPUT_BUTTON_MASK(s) ( \
+         (1 <<  0) * PHYS_INPUT_BUTTON_ATCK(s) \
+       | (1 <<  1) * PHYS_INPUT_BUTTON_JUMP(s) \
+       | (1 <<  2) * PHYS_INPUT_BUTTON_ATCK2(s) \
+       | (1 <<  3) * PHYS_INPUT_BUTTON_ZOOM(s) \
+       | (1 <<  4) * PHYS_INPUT_BUTTON_CROUCH(s) \
+       | (1 <<  5) * PHYS_INPUT_BUTTON_HOOK(s) \
+       | (1 <<  6) * PHYS_INPUT_BUTTON_USE(s) \
+       | (1 <<  7) * PHYS_INPUT_BUTTON_BACKWARD(s) \
+       | (1 <<  8) * PHYS_INPUT_BUTTON_FORWARD(s) \
+       | (1 <<  9) * PHYS_INPUT_BUTTON_LEFT(s) \
+       | (1 << 10) * PHYS_INPUT_BUTTON_RIGHT(s) \
+       )
+
+#define IS_JUMP_HELD(s)                     (!((s).flags & FL_JUMPRELEASED))
+#define SET_JUMP_HELD(s)                    ((s).flags &= ~FL_JUMPRELEASED)
+#define UNSET_JUMP_HELD(s)                  ((s).flags |= FL_JUMPRELEASED)
+
+#define IS_ONGROUND(s)                      boolean((s).flags & FL_ONGROUND)
+#define SET_ONGROUND(s)                     ((s).flags |= FL_ONGROUND)
+#define UNSET_ONGROUND(s)                   ((s).flags &= ~FL_ONGROUND)
+
+#define WAS_ONGROUND(s)                     boolean((s).lastflags & FL_ONGROUND)
+
+#define ITEMS_STAT(s)                       ((s).items)
 
 #ifdef CSQC
 
@@ -100,8 +149,8 @@ bool IsFlying(entity a);
 
        noref float pmove_waterjumptime;
 
-       const int FL_WATERJUMP = 2048;  // player jumping out of water
-       const int FL_JUMPRELEASED = 4096;       // for jump debouncing
+       const int FL_WATERJUMP = 2048;  // player jumping out of water
+       const int FL_JUMPRELEASED = 4096;  // for jump debouncing
 
        .float watertype;
        .float waterlevel;
@@ -111,67 +160,61 @@ bool IsFlying(entity a);
        .vector v_angle;
 
 // TODO
-       #define IS_CLIENT(s)                                            (s).isplayermodel
-       #define IS_PLAYER(s)                                            (s).isplayermodel
-       #define IS_NOT_A_CLIENT(s)                                 !(s).isplayermodel
-       #define isPushable(s)                                           ((s).isplayermodel || (s).pushable || ((s).flags & FL_PROJECTILE))
+       #define IS_CLIENT(s)                        ((s).isplayermodel)
+       #define IS_PLAYER(s)                        ((s).isplayermodel)
+       #define IS_NOT_A_CLIENT(s)                  (!(s).isplayermodel)
+       #define isPushable(s)                       ((s).isplayermodel || (s).pushable || ((s).flags & FL_PROJECTILE))
 
        //float player_multijump;
        //float player_jumpheight;
 
        #define PHYS_GRAVITY(s)                     STAT(MOVEVARS_GRAVITY, s)
 
-       #define PHYS_TELEPORT_TIME(s)                           s.teleport_time
+       #define PHYS_TELEPORT_TIME(s)               ((s).teleport_time)
 
-       #define TICRATE ticrate
+       #define TICRATE                             ticrate
 
-       #define PHYS_INPUT_ANGLES(s)                            input_angles
+       #define PHYS_INPUT_ANGLES(s)                input_angles
 // TODO
-       #define PHYS_WORLD_ANGLES(s)                            input_angles
-
-       #define PHYS_INPUT_TIMELENGTH                           input_timelength
-       #define PHYS_INPUT_FRAMETIME                            serverdeltatime
-
-       #define PHYS_INPUT_MOVEVALUES(s)                        input_movevalues
-
-       #define PHYS_INPUT_BUTTON_MASK(s)               (input_buttons | BIT(7) * (input_movevalues.x < 0) | BIT(8) * (input_movevalues.x > 0) | BIT(9) * (input_movevalues.y < 0) | BIT(10) * (input_movevalues.y > 0))
-       #define PHYS_INPUT_BUTTON_ATCK(s)                       boolean(input_buttons & BIT(0))
-       #define PHYS_INPUT_BUTTON_JUMP(s)                       boolean(input_buttons & BIT(1))
-       #define PHYS_INPUT_BUTTON_ATCK2(s)                      boolean(input_buttons & BIT(2))
-       #define PHYS_INPUT_BUTTON_ZOOM(s)                       boolean(input_buttons & BIT(3))
-       #define PHYS_INPUT_BUTTON_CROUCH(s)                     boolean(input_buttons & BIT(4))
-       #define PHYS_INPUT_BUTTON_HOOK(s)                       boolean(input_buttons & BIT(5))
-       #define PHYS_INPUT_BUTTON_USE(s)                        boolean(input_buttons & BIT(6))
-       #define PHYS_INPUT_BUTTON_BACKWARD(s)           boolean(input_buttons & BIT(7))
-       #define PHYS_INPUT_BUTTON_FORWARD(s)            boolean(input_buttons & BIT(8))
-       #define PHYS_INPUT_BUTTON_LEFT(s)                       boolean(input_buttons & BIT(9))
-       #define PHYS_INPUT_BUTTON_RIGHT(s)                      boolean(input_buttons & BIT(10))
-       #define PHYS_INPUT_BUTTON_JETPACK(s)            boolean(input_buttons & BIT(12))
-
-       #define PHYS_DEAD(s)                                            s.csqcmodel_isdead
-
-       #define GAMEPLAYFIX_GRAVITYUNAFFECTEDBYTICRATE  (boolean(moveflags & MOVEFLAG_GRAVITYUNAFFECTEDBYTICRATE))
-       #define GAMEPLAYFIX_NOGRAVITYONGROUND                   (boolean(moveflags & MOVEFLAG_NOGRAVITYONGROUND))
-       #define GAMEPLAYFIX_Q2AIRACCELERATE                             (boolean(moveflags & MOVEFLAG_Q2AIRACCELERATE))
-
-       #define IS_DUCKED(s)                                            boolean(s.flags & FL_DUCKED)
-       #define SET_DUCKED(s)                                           s.flags |= FL_DUCKED
-       #define UNSET_DUCKED(s)                                         s.flags &= ~FL_DUCKED
-
-       #define IS_JUMP_HELD(s)                                         !(s.flags & FL_JUMPRELEASED)
-       #define SET_JUMP_HELD(s)                                        s.flags &= ~FL_JUMPRELEASED
-       #define UNSET_JUMP_HELD(s)                                      s.flags |= FL_JUMPRELEASED
-
-       #define IS_ONGROUND(s)                                          boolean(s.flags & FL_ONGROUND)
-       #define SET_ONGROUND(s)                                         s.flags |= FL_ONGROUND
-       #define UNSET_ONGROUND(s)                                       s.flags &= ~FL_ONGROUND
-
-       #define WAS_ONGROUND(s)                                         boolean(s.lastflags & FL_ONGROUND)
-
-       #define ITEMS_STAT(s)                                           (s).items
-
-       #define PHYS_JUMPSPEEDCAP_MIN                           autocvar_cl_jumpspeedcap_min
-       #define PHYS_JUMPSPEEDCAP_MAX                           autocvar_cl_jumpspeedcap_max
+       #define PHYS_WORLD_ANGLES(s)                input_angles
+
+       #define PHYS_INPUT_TIMELENGTH               input_timelength
+       #define PHYS_INPUT_FRAMETIME                serverdeltatime
+
+       #define PHYS_INPUT_MOVEVALUES(s)            input_movevalues
+
+       #define PHYS_INPUT_BUTTON_BUTTON1(s)        boolean(input_buttons & BIT(0))
+       #define PHYS_INPUT_BUTTON_BUTTON2(s)        boolean(input_buttons & BIT(1))
+       #define PHYS_INPUT_BUTTON_BUTTON3(s)        boolean(input_buttons & BIT(2))
+       #define PHYS_INPUT_BUTTON_BUTTON4(s)        boolean(input_buttons & BIT(3))
+       #define PHYS_INPUT_BUTTON_BUTTON5(s)        boolean(input_buttons & BIT(4))
+       #define PHYS_INPUT_BUTTON_BUTTON6(s)        boolean(input_buttons & BIT(5))
+       #define PHYS_INPUT_BUTTON_BUTTON7(s)        boolean(input_buttons & BIT(6))
+       #define PHYS_INPUT_BUTTON_BUTTON8(s)        boolean(input_buttons & BIT(7))
+       #define PHYS_INPUT_BUTTON_BUTTON_USE(s)     boolean(input_buttons & BIT(8))
+       #define PHYS_INPUT_BUTTON_BUTTON_CHAT(s)    boolean(input_buttons & BIT(9))
+       #define PHYS_INPUT_BUTTON_BUTTON_PRYDON(s)  boolean(input_buttons & BIT(10))
+       #define PHYS_INPUT_BUTTON_BUTTON9(s)        boolean(input_buttons & BIT(11))
+       #define PHYS_INPUT_BUTTON_BUTTON10(s)       boolean(input_buttons & BIT(12))
+       #define PHYS_INPUT_BUTTON_BUTTON11(s)       boolean(input_buttons & BIT(13))
+       #define PHYS_INPUT_BUTTON_BUTTON12(s)       boolean(input_buttons & BIT(14))
+       #define PHYS_INPUT_BUTTON_BUTTON13(s)       boolean(input_buttons & BIT(15))
+       #define PHYS_INPUT_BUTTON_BUTTON14(s)       boolean(input_buttons & BIT(16))
+       #define PHYS_INPUT_BUTTON_BUTTON15(s)       boolean(input_buttons & BIT(17))
+       #define PHYS_INPUT_BUTTON_BUTTON16(s)       boolean(input_buttons & BIT(18))
+
+       #define PHYS_DEAD(s)                        ((s).csqcmodel_isdead)
+
+       #define GAMEPLAYFIX_GRAVITYUNAFFECTEDBYTICRATE  (boolean(moveflags & MOVEFLAG_GRAVITYUNAFFECTEDBYTICRATE))
+       #define GAMEPLAYFIX_NOGRAVITYONGROUND           (boolean(moveflags & MOVEFLAG_NOGRAVITYONGROUND))
+       #define GAMEPLAYFIX_Q2AIRACCELERATE             (boolean(moveflags & MOVEFLAG_Q2AIRACCELERATE))
+
+       #define IS_DUCKED(s)                        (boolean((s).flags & FL_DUCKED))
+       #define SET_DUCKED(s)                       ((s).flags |= FL_DUCKED)
+       #define UNSET_DUCKED(s)                     ((s).flags &= ~FL_DUCKED)
+
+       #define PHYS_JUMPSPEEDCAP_MIN               autocvar_cl_jumpspeedcap_min
+       #define PHYS_JUMPSPEEDCAP_MAX               autocvar_cl_jumpspeedcap_max
 
        #define PHYS_CL_TRACK_CANJUMP(s)            STAT(MOVEVARS_CL_TRACK_CANJUMP, s)
        // FIXME: 0 doesn't mean zero gravity
@@ -188,61 +231,80 @@ bool IsFlying(entity a);
        .string jumpspeedcap_min;
        .string jumpspeedcap_max;
 
-       #define PHYS_TELEPORT_TIME(s)                           s.teleport_time
+       #define PHYS_TELEPORT_TIME(s)               ((s).teleport_time)
 
        #define PHYS_GRAVITY(s)                     autocvar_sv_gravity
 
        #define TICRATE sys_frametime
 
-       #define PHYS_INPUT_ANGLES(s)                            s.v_angle
-       #define PHYS_WORLD_ANGLES(s)                            s.angles
-
-       #define PHYS_INPUT_TIMELENGTH                           frametime
-       #define PHYS_INPUT_FRAMETIME                            sys_frametime
-
-       #define PHYS_INPUT_MOVEVALUES(s)                        s.movement
-       // TODO: cache
-       #define PHYS_INPUT_BUTTON_MASK(s)               (s.BUTTON_ATCK | 2 * s.BUTTON_JUMP | 4 * s.BUTTON_ATCK2 | 8 * s.BUTTON_ZOOM | 16 * s.BUTTON_CROUCH | 32 * s.BUTTON_HOOK | 64 * s.BUTTON_USE | 128 * (s.movement_x < 0) | 256 * (s.movement_x > 0) | 512 * (s.movement_y < 0) | 1024 * (s.movement_y > 0))
-       #define PHYS_INPUT_BUTTON_ATCK(s)                       s.BUTTON_ATCK
-       #define PHYS_INPUT_BUTTON_JUMP(s)                       s.BUTTON_JUMP
-       #define PHYS_INPUT_BUTTON_ATCK2(s)                      s.BUTTON_ATCK2
-       #define PHYS_INPUT_BUTTON_ZOOM(s)                       s.BUTTON_ZOOM
-       #define PHYS_INPUT_BUTTON_CROUCH(s)                     s.BUTTON_CROUCH
-       #define PHYS_INPUT_BUTTON_HOOK(s)                       s.BUTTON_HOOK
-       #define PHYS_INPUT_BUTTON_USE(s)                        s.BUTTON_USE
-       #define PHYS_INPUT_BUTTON_BACKWARD(s)           (s.movement_x < 0)
-       #define PHYS_INPUT_BUTTON_FORWARD(s)            (s.movement_x > 0)
-       #define PHYS_INPUT_BUTTON_LEFT(s)                       (s.movement_y < 0)
-       #define PHYS_INPUT_BUTTON_RIGHT(s)                      (s.movement_y > 0)
-       #define PHYS_INPUT_BUTTON_JETPACK(s)            s.BUTTON_JETPACK
+       #define PHYS_INPUT_ANGLES(s)                ((s).v_angle)
+       #define PHYS_WORLD_ANGLES(s)                ((s).angles)
+
+       #define PHYS_INPUT_TIMELENGTH               frametime
+       #define PHYS_INPUT_FRAMETIME                sys_frametime
+
+       #define PHYS_INPUT_MOVEVALUES(s)            ((s).movement)
+
+       #define PHYS_INPUT_BUTTON_BUTTON1(s)        ((s).button0)
+       #define PHYS_INPUT_BUTTON_BUTTON2(s)        ((s).button2)
+       #define PHYS_INPUT_BUTTON_BUTTON3(s)        ((s).button3)
+       #define PHYS_INPUT_BUTTON_BUTTON4(s)        ((s).button4)
+       #define PHYS_INPUT_BUTTON_BUTTON5(s)        ((s).button5)
+       #define PHYS_INPUT_BUTTON_BUTTON6(s)        ((s).button6)
+       #define PHYS_INPUT_BUTTON_BUTTON7(s)        ((s).button7)
+       #define PHYS_INPUT_BUTTON_BUTTON8(s)        ((s).button8)
+       #define PHYS_INPUT_BUTTON_BUTTON_USE(s)     ((s).buttonuse)
+       #define PHYS_INPUT_BUTTON_BUTTON_CHAT(s)    ((s).buttonchat)
+       #define PHYS_INPUT_BUTTON_BUTTON_PRYDON(s)  ((s).cursor_active)
+       #define PHYS_INPUT_BUTTON_BUTTON9(s)        ((s).button9)
+       #define PHYS_INPUT_BUTTON_BUTTON10(s)       ((s).button10)
+       #define PHYS_INPUT_BUTTON_BUTTON11(s)       ((s).button11)
+       #define PHYS_INPUT_BUTTON_BUTTON12(s)       ((s).button12)
+       #define PHYS_INPUT_BUTTON_BUTTON13(s)       ((s).button13)
+       #define PHYS_INPUT_BUTTON_BUTTON14(s)       ((s).button14)
+       #define PHYS_INPUT_BUTTON_BUTTON15(s)       ((s).button15)
+       #define PHYS_INPUT_BUTTON_BUTTON16(s)       ((s).button16)
+
+       #define PHYS_DEAD(s)                        ((s).deadflag != DEAD_NO)
+
+       #define GAMEPLAYFIX_GRAVITYUNAFFECTEDBYTICRATE  autocvar_sv_gameplayfix_gravityunaffectedbyticrate
+       #define GAMEPLAYFIX_NOGRAVITYONGROUND           autocvar_sv_gameplayfix_nogravityonground
+       #define GAMEPLAYFIX_Q2AIRACCELERATE             autocvar_sv_gameplayfix_q2airaccelerate
+
+       #define IS_DUCKED(s)                        ((s).crouch)
+       #define SET_DUCKED(s)                       ((s).crouch = true)
+       #define UNSET_DUCKED(s)                     ((s).crouch = false)
+
+       #define PHYS_JUMPSPEEDCAP_MIN               autocvar_sv_jumpspeedcap_min
+       #define PHYS_JUMPSPEEDCAP_MAX               autocvar_sv_jumpspeedcap_max
+
+       #define PHYS_CL_TRACK_CANJUMP(s)            ((s).cvar_cl_movement_track_canjump)
+       #define PHYS_ENTGRAVITY(s)                  ((s).gravity)
 
-       #define PHYS_DEAD(s)                                            s.deadflag != DEAD_NO
-
-       #define GAMEPLAYFIX_GRAVITYUNAFFECTEDBYTICRATE  autocvar_sv_gameplayfix_gravityunaffectedbyticrate
-       #define GAMEPLAYFIX_NOGRAVITYONGROUND                   autocvar_sv_gameplayfix_nogravityonground
-       #define GAMEPLAYFIX_Q2AIRACCELERATE                             autocvar_sv_gameplayfix_q2airaccelerate
-
-       #define IS_DUCKED(s)                                            s.crouch
-       #define SET_DUCKED(s)                                           s.crouch = true
-       #define UNSET_DUCKED(s)                                         s.crouch = false
-
-       #define IS_JUMP_HELD(s)                                         !(s.flags & FL_JUMPRELEASED)
-       #define SET_JUMP_HELD(s)                                        s.flags &= ~FL_JUMPRELEASED
-       #define UNSET_JUMP_HELD(s)                                      s.flags |= FL_JUMPRELEASED
-
-       #define IS_ONGROUND(s)                                          boolean(s.flags & FL_ONGROUND)
-       #define SET_ONGROUND(s)                                         s.flags |= FL_ONGROUND
-       #define UNSET_ONGROUND(s)                                       s.flags &= ~FL_ONGROUND
-
-       #define WAS_ONGROUND(s)                                         boolean((s).lastflags & FL_ONGROUND)
-
-       #define ITEMS_STAT(s)                                           s.items
-
-       #define PHYS_JUMPSPEEDCAP_MIN                           autocvar_sv_jumpspeedcap_min
-       #define PHYS_JUMPSPEEDCAP_MAX                           autocvar_sv_jumpspeedcap_max
-
-       #define PHYS_CL_TRACK_CANJUMP(s)                        s.cvar_cl_movement_track_canjump
-       #define PHYS_ENTGRAVITY(s)                                      s.gravity
+#endif
 
+REGISTER_NET_C2S(setpause)
+#ifdef CSQC
+void unpause_update()
+{
+       static bool waspaused;
+       bool ispaused = PHYS_INPUT_BUTTON_CHAT(this);
+       if (ispaused == waspaused) return;
+       waspaused = ispaused;
+       // if (!serverispaused) return; // TODO: find out somehow
+       if (ispaused) return; // ignore setting pause, server will get those presses anyway, but it won't get releases
+       int channel = MSG_C2S;
+       WriteHeader(channel, setpause);
+       WriteByte(channel, ispaused);
+}
 #endif
+#ifdef SVQC
+NET_HANDLE(setpause, bool)
+{
+       bool ispaused = boolean(ReadByte());
+       PHYS_INPUT_BUTTON_CHAT(sender) = ispaused;
+       return true;
+}
+#endif
+
 #endif
index 28fd9b0c6e949ae746b48e078f9bc50bc3cbd13c..ecc5b3cb1b0cabfe6960bac0d273271785f549d1 100644 (file)
@@ -6,6 +6,8 @@
 
 #define INDEPENDENT_ATTACK_FINISHED 1
 
+// TODO: deprecated: remove. Replaced by physics.qh PHYS_INPUT_BUTTON_*
+
 #define BUTTON_ATCK       button0
 #define BUTTON_JUMP       button2
 #define BUTTON_ATCK2      button3
 #define BUTTON_CROUCH     button5
 #define BUTTON_HOOK       button6
 #define BUTTON_INFO       button7
-#define BUTTON_CHAT       buttonchat
-#define BUTTON_USE        buttonuse
 #define BUTTON_DRAG       button8
+#define BUTTON_USE        buttonuse
+#define BUTTON_CHAT       buttonchat
+#define BUTTON_PRYDON     cursor_active
 #define BUTTON_ZOOMSCRIPT button9
 #define BUTTON_JETPACK    button10
 
index 1e9d3a766c18bfc784837d09cfe85a5e3ff8f8c3..ded24016f2dc424f0310196b347a6d4c7a2de98d 100644 (file)
@@ -127,6 +127,23 @@ void CreatureFrame_All()
        }
 }
 
+void Pause_TryPause(bool ispaused)
+{
+       int n = 0;
+       entity it;
+       FOR_EACH_REALPLAYER(it)
+       {
+               if (PHYS_INPUT_BUTTON_CHAT(it) != ispaused) return;
+               ++n;
+       }
+       if (!n) return;
+       setpause(ispaused);
+}
+
+void SV_PausedTic(float elapsedtime)
+{
+       if (!server_is_dedicated) Pause_TryPause(false);
+}
 
 /*
 =============
@@ -144,6 +161,7 @@ void StartFrame()
 {
        SELFPARAM();
        execute_next_frame();
+       if (!server_is_dedicated) Pause_TryPause(true);
 
        remove = remove_unsafely; // not during spawning!
        serverprevtime = servertime;