From 6d4053005d90b4cb70e03a3c2b694a6e0adf6bd8 Mon Sep 17 00:00:00 2001 From: Mario Date: Tue, 19 May 2020 10:56:38 +1000 Subject: [PATCH] Remove the 2 second buffer applied to water jumps and rely on the waterjump flag to be accurate when needed, also check water status on both the server and client before physics is run to ensure they aren't being used from a previous physics frame, fixes various prediction errors with water --- qcsrc/common/physics/player.qc | 10 +--------- qcsrc/common/physics/player.qh | 4 ---- qcsrc/ecs/systems/cl_physics.qc | 1 - qcsrc/ecs/systems/physics.qc | 14 ++++---------- qcsrc/lib/csqcmodel/cl_player.qc | 2 +- 5 files changed, 6 insertions(+), 25 deletions(-) diff --git a/qcsrc/common/physics/player.qc b/qcsrc/common/physics/player.qc index cba24ff8e..6e4822422 100644 --- a/qcsrc/common/physics/player.qc +++ b/qcsrc/common/physics/player.qc @@ -163,11 +163,8 @@ void PM_ClientMovement_UpdateStatus(entity this) setsize(this, STAT(PL_MIN, this), STAT(PL_MAX, this)); } } -#ifdef CSQC - if (IS_ONGROUND(this) || this.velocity.z <= 0 || PHYS_WATERJUMP_TIME(this) <= 0) - PHYS_WATERJUMP_TIME(this) = 0; -#endif + _Movetype_CheckWater(this); // needs to be run on the client, might as well use the latest on the server too! } void CPM_PM_Aircontrol(entity this, float dt, vector wishdir, float wishspeed) @@ -453,11 +450,6 @@ void CheckWaterJump(entity this) this.velocity_z = 225; this.flags |= FL_WATERJUMP; SET_JUMP_HELD(this); - #ifdef SVQC - PHYS_TELEPORT_TIME(this) = time + 2; // safety net - #elif defined(CSQC) - PHYS_WATERJUMP_TIME(this) = 2; - #endif } } } diff --git a/qcsrc/common/physics/player.qh b/qcsrc/common/physics/player.qh index 97a422423..3237fd437 100644 --- a/qcsrc/common/physics/player.qh +++ b/qcsrc/common/physics/player.qh @@ -158,10 +158,6 @@ STATIC_INIT(PHYS_INPUT_BUTTON) #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 diff --git a/qcsrc/ecs/systems/cl_physics.qc b/qcsrc/ecs/systems/cl_physics.qc index fa087b5eb..624e0a912 100644 --- a/qcsrc/ecs/systems/cl_physics.qc +++ b/qcsrc/ecs/systems/cl_physics.qc @@ -3,7 +3,6 @@ void sys_phys_fix(entity this, float dt) { this.team = myteam + 1; // is this correct? - PHYS_WATERJUMP_TIME(this) -= dt; this.movement = PHYS_INPUT_MOVEVALUES(this); this.items = STAT(ITEMS, this); if (!(PHYS_INPUT_BUTTON_JUMP(this))) // !jump diff --git a/qcsrc/ecs/systems/physics.qc b/qcsrc/ecs/systems/physics.qc index 41506ec31..4af74e002 100644 --- a/qcsrc/ecs/systems/physics.qc +++ b/qcsrc/ecs/systems/physics.qc @@ -90,13 +90,8 @@ void sys_phys_update(entity this, float dt) if (this.flags & FL_WATERJUMP) { this.velocity_x = this.movedir.x; this.velocity_y = this.movedir.y; - if (this.waterlevel == WATERLEVEL_NONE - || time > PHYS_TELEPORT_TIME(this) - || PHYS_WATERJUMP_TIME(this) <= 0 - ) { + if (this.waterlevel == WATERLEVEL_NONE) { this.flags &= ~FL_WATERJUMP; - PHYS_TELEPORT_TIME(this) = 0; - PHYS_WATERJUMP_TIME(this) = 0; } } else if (MUTATOR_CALLHOOK(PM_Physics, this, maxspeed_mod, dt)) { // handled @@ -261,8 +256,7 @@ void sys_phys_simulate(entity this, float dt) float wishspeed = min(vlen(wishvel), this.com_phys_vel_max); if (this.com_phys_air) { - if ((IS_SVQC && time >= PHYS_TELEPORT_TIME(this)) - || (IS_CSQC && PHYS_WATERJUMP_TIME(this) <= 0)) { + if (!(this.flags & FL_WATERJUMP)) { // apply air speed limit float airaccelqw = PHYS_AIRACCEL_QW(this); float wishspeed0 = wishspeed; @@ -323,7 +317,7 @@ void sys_phys_simulate(entity this, float dt) if (this.com_phys_water) { wishspeed *= 0.7; - // if (PHYS_WATERJUMP_TIME(this) <= 0) // TODO: use + // if (!(this.flags & FL_WATERJUMP)) // TODO: use { // water friction float f = 1 - dt * PHYS_FRICTION(this); @@ -407,7 +401,7 @@ void sys_phys_simulate(entity this, float dt) return; } - if (IS_CSQC ? PHYS_WATERJUMP_TIME(this) <= 0 : time >= PHYS_TELEPORT_TIME(this)) { + if (!(this.flags & FL_WATERJUMP)) { PM_Accelerate(this, dt, wishdir, wishspeed, wishspeed, this.com_phys_acc_rate, 1, 0, 0, 0); } } diff --git a/qcsrc/lib/csqcmodel/cl_player.qc b/qcsrc/lib/csqcmodel/cl_player.qc index a5610b3de..ef2ca0b9f 100644 --- a/qcsrc/lib/csqcmodel/cl_player.qc +++ b/qcsrc/lib/csqcmodel/cl_player.qc @@ -129,7 +129,7 @@ void CSQCPlayer_Physics(entity this) { if(!autocvar_cl_movement) { return; } - _Movetype_CheckWater(this); // we apparently need to check water *before* physics so it can use this for water jump + //_Movetype_CheckWater(this); // we apparently need to check water *before* physics so it can use this for water jump vector oldv_angle = this.v_angle; vector oldangles = this.angles; // we need to save these, as they're abused by other code -- 2.39.2