From 5172811ca1681144cddd447c3ae9c5a0acef9912 Mon Sep 17 00:00:00 2001 From: Mario Date: Mon, 17 Jul 2017 08:27:20 +1000 Subject: [PATCH] Clean up Physics_UpdateStats a bit --- qcsrc/common/physics/player.qc | 8 +++++++- qcsrc/common/physics/player.qh | 2 +- qcsrc/ecs/systems/sv_physics.qc | 4 +--- qcsrc/server/client.qc | 4 +--- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/qcsrc/common/physics/player.qc b/qcsrc/common/physics/player.qc index 47249356b..ec255c8d3 100644 --- a/qcsrc/common/physics/player.qc +++ b/qcsrc/common/physics/player.qc @@ -30,8 +30,14 @@ float Physics_ClientOption(entity this, string option, float defaultval) return defaultval; } -void Physics_UpdateStats(entity this, float maxspd_mod) +void Physics_UpdateStats(entity this) { + // update this first, as it's used on all stats (wouldn't want to update them all manually from a mutator hook now, would we?) + STAT(MOVEVARS_HIGHSPEED, this) = autocvar_g_movement_highspeed; + + MUTATOR_CALLHOOK(PlayerPhysics_UpdateStats, this); + float maxspd_mod = PHYS_HIGHSPEED(this); + STAT(MOVEVARS_AIRACCEL_QW, this) = AdjustAirAccelQW(Physics_ClientOption(this, "airaccel_qw", autocvar_sv_airaccel_qw), maxspd_mod); STAT(MOVEVARS_AIRSTRAFEACCEL_QW, this) = (Physics_ClientOption(this, "airstrafeaccel_qw", autocvar_sv_airstrafeaccel_qw)) ? AdjustAirAccelQW(Physics_ClientOption(this, "airstrafeaccel_qw", autocvar_sv_airstrafeaccel_qw), maxspd_mod) diff --git a/qcsrc/common/physics/player.qh b/qcsrc/common/physics/player.qh index 5f43c2a5b..a77a03b58 100644 --- a/qcsrc/common/physics/player.qh +++ b/qcsrc/common/physics/player.qh @@ -247,7 +247,7 @@ STATIC_INIT(PHYS_INPUT_BUTTON_DODGE) bool Physics_Valid(string thecvar); - void Physics_UpdateStats(entity this, float maxspd_mod); + void Physics_UpdateStats(entity this); void PM_UpdateButtons(entity this, entity store); diff --git a/qcsrc/ecs/systems/sv_physics.qc b/qcsrc/ecs/systems/sv_physics.qc index 1a69c75fc..87982b5d5 100644 --- a/qcsrc/ecs/systems/sv_physics.qc +++ b/qcsrc/ecs/systems/sv_physics.qc @@ -3,9 +3,7 @@ void sys_phys_fix(entity this, float dt) { WarpZone_PlayerPhysics_FixVAngle(this); - STAT(MOVEVARS_HIGHSPEED, this) = autocvar_g_movement_highspeed; - MUTATOR_CALLHOOK(PlayerPhysics_UpdateStats, this); // do it BEFORE the function so we can modify highspeed! - Physics_UpdateStats(this, PHYS_HIGHSPEED(this)); + Physics_UpdateStats(this); } bool sys_phys_override(entity this, float dt) diff --git a/qcsrc/server/client.qc b/qcsrc/server/client.qc index 26cdbde2d..70b0455f2 100644 --- a/qcsrc/server/client.qc +++ b/qcsrc/server/client.qc @@ -1253,9 +1253,7 @@ void ClientConnect(entity this) sv_notice_join(this); // update physics stats (players can spawn before physics runs) - STAT(MOVEVARS_HIGHSPEED, this) = autocvar_g_movement_highspeed; - MUTATOR_CALLHOOK(PlayerPhysics_UpdateStats, this); // do it BEFORE the function so we can modify highspeed! - Physics_UpdateStats(this, PHYS_HIGHSPEED(this)); + Physics_UpdateStats(this); IL_EACH(g_initforplayer, it.init_for_player, { it.init_for_player(it, this); -- 2.39.2