From 46682a49ba71f1664e5625fe2d9c3be5e95db901 Mon Sep 17 00:00:00 2001 From: Mario Date: Sun, 16 Jul 2017 04:50:36 +1000 Subject: [PATCH] Port movement and movement_old to ClientState --- .../mutators/mutator/bugrigs/bugrigs.qc | 4 +- .../mutators/mutator/dodging/sv_dodging.qc | 13 +++--- .../mutators/mutator/multijump/multijump.qc | 4 +- qcsrc/common/physics/player.qc | 24 +++++------ qcsrc/common/physics/player.qh | 4 +- qcsrc/common/vehicles/vehicle/bumblebee.qc | 18 ++++----- qcsrc/common/vehicles/vehicle/racer.qc | 12 +++--- qcsrc/common/vehicles/vehicle/raptor.qc | 20 +++++----- qcsrc/common/vehicles/vehicle/spiderbot.qc | 38 +++++++++--------- qcsrc/common/viewloc.qc | 14 +++---- qcsrc/common/weapons/weapon/tuba.qc | 8 ++-- qcsrc/ecs/systems/physics.qc | 16 ++++---- qcsrc/ecs/systems/sv_physics.qc | 2 +- qcsrc/server/anticheat.qc | 4 +- qcsrc/server/bot/default/bot.qc | 6 +-- qcsrc/server/bot/default/havocbot/havocbot.qc | 40 +++++++++---------- qcsrc/server/bot/default/scripting.qc | 12 +++--- qcsrc/server/client.qc | 8 ++-- qcsrc/server/client.qh | 1 + qcsrc/server/command/vote.qc | 2 +- qcsrc/server/mutators/mutator/gamemode_cts.qc | 32 +++++++-------- .../server/mutators/mutator/gamemode_race.qc | 32 +++++++-------- qcsrc/server/playerdemo.qc | 2 +- 23 files changed, 160 insertions(+), 156 deletions(-) diff --git a/qcsrc/common/mutators/mutator/bugrigs/bugrigs.qc b/qcsrc/common/mutators/mutator/bugrigs/bugrigs.qc index 318cc10f4..0293f4d6a 100644 --- a/qcsrc/common/mutators/mutator/bugrigs/bugrigs.qc +++ b/qcsrc/common/mutators/mutator/bugrigs/bugrigs.qc @@ -71,8 +71,8 @@ void RaceCarPhysics(entity this, float dt) vector rigvel; vector angles_save = this.angles; - float accel = bound(-1, this.movement.x / PHYS_MAXSPEED(this), 1); - float steer = bound(-1, this.movement.y / PHYS_MAXSPEED(this), 1); + float accel = bound(-1, PHYS_CS(this).movement.x / PHYS_MAXSPEED(this), 1); + float steer = bound(-1, PHYS_CS(this).movement.y / PHYS_MAXSPEED(this), 1); if (PHYS_BUGRIGS_REVERSE_SPEEDING(this)) { diff --git a/qcsrc/common/mutators/mutator/dodging/sv_dodging.qc b/qcsrc/common/mutators/mutator/dodging/sv_dodging.qc index 8e90ef353..93feb5d94 100644 --- a/qcsrc/common/mutators/mutator/dodging/sv_dodging.qc +++ b/qcsrc/common/mutators/mutator/dodging/sv_dodging.qc @@ -157,9 +157,10 @@ bool PM_dodging_checkpressedkeys(entity this) float tap_direction_x = 0; float tap_direction_y = 0; bool dodge_detected = false; + vector mymovement = PHYS_CS(this).movement; #define X(COND,BTN,RESULT) \ - if (this.movement_##COND) \ + if (mymovement_##COND) \ /* is this a state change? */ \ if(!(PHYS_DODGING_PRESSED_KEYS(this) & KEY_##BTN) || frozen_no_doubletap) { \ tap_direction_##RESULT; \ @@ -237,7 +238,7 @@ void PM_dodging(entity this) if (this.dodging_action == 1) { //disable jump key during dodge accel phase - if(this.movement_z > 0) { this.movement_z = 0; } + if(PHYS_CS(this).movement.z > 0) { PHYS_CS(this).movement_z = 0; } this.velocity += ((this.dodging_direction_y * velocity_difference) * v_right) + ((this.dodging_direction_x * velocity_difference) * v_forward); @@ -280,10 +281,10 @@ void PM_dodging_GetPressedKeys(entity this) PM_dodging_checkpressedkeys(this); int keys = this.pressedkeys; - keys = BITSET(keys, KEY_FORWARD, this.movement.x > 0); - keys = BITSET(keys, KEY_BACKWARD, this.movement.x < 0); - keys = BITSET(keys, KEY_RIGHT, this.movement.y > 0); - keys = BITSET(keys, KEY_LEFT, this.movement.y < 0); + keys = BITSET(keys, KEY_FORWARD, PHYS_CS(this).movement.x > 0); + keys = BITSET(keys, KEY_BACKWARD, PHYS_CS(this).movement.x < 0); + keys = BITSET(keys, KEY_RIGHT, PHYS_CS(this).movement.y > 0); + keys = BITSET(keys, KEY_LEFT, PHYS_CS(this).movement.y < 0); keys = BITSET(keys, KEY_JUMP, PHYS_INPUT_BUTTON_JUMP(this)); keys = BITSET(keys, KEY_CROUCH, PHYS_INPUT_BUTTON_CROUCH(this)); diff --git a/qcsrc/common/mutators/mutator/multijump/multijump.qc b/qcsrc/common/mutators/mutator/multijump/multijump.qc index ecedc4759..b00ad7475 100644 --- a/qcsrc/common/mutators/mutator/multijump/multijump.qc +++ b/qcsrc/common/mutators/mutator/multijump/multijump.qc @@ -82,7 +82,7 @@ MUTATOR_HOOKFUNCTION(multijump, PlayerJump) if(M_ARGV(2, bool)) { if(PHYS_MULTIJUMP_DODGING(player)) - if(player.movement_x != 0 || player.movement_y != 0) // don't remove all speed if player isnt pressing any movement keys + if(PHYS_CS(player).movement_x != 0 || PHYS_CS(player).movement_y != 0) // don't remove all speed if player isnt pressing any movement keys { float curspeed; vector wishvel, wishdir; @@ -97,7 +97,7 @@ MUTATOR_HOOKFUNCTION(multijump, PlayerJump) //#endif makevectors(player.v_angle_y * '0 1 0'); - wishvel = v_forward * player.movement_x + v_right * player.movement_y; + wishvel = v_forward * PHYS_CS(player).movement_x + v_right * PHYS_CS(player).movement_y; wishdir = normalize(wishvel); player.velocity_x = wishdir_x * curspeed; // allow "dodging" at a multijump diff --git a/qcsrc/common/physics/player.qc b/qcsrc/common/physics/player.qc index de408f1b9..587156bd6 100644 --- a/qcsrc/common/physics/player.qc +++ b/qcsrc/common/physics/player.qc @@ -135,13 +135,13 @@ void PM_ClientMovement_UpdateStatus(entity this) void CPM_PM_Aircontrol(entity this, float dt, vector wishdir, float wishspeed) { - float movity = IsMoveInDirection(this.movement, 0); + float movity = IsMoveInDirection(PHYS_CS(this).movement, 0); if(PHYS_AIRCONTROL_BACKWARDS(this)) - movity += IsMoveInDirection(this.movement, 180); + movity += IsMoveInDirection(PHYS_CS(this).movement, 180); if(PHYS_AIRCONTROL_SIDEWARDS(this)) { - movity += IsMoveInDirection(this.movement, 90); - movity += IsMoveInDirection(this.movement, -90); + movity += IsMoveInDirection(PHYS_CS(this).movement, 90); + movity += IsMoveInDirection(PHYS_CS(this).movement, -90); } float k = 32 * (2 * movity - 1); @@ -550,7 +550,7 @@ void PM_check_nickspam(entity this) if (this.nickspamcount >= autocvar_g_nick_flood_penalty_yellow) { // slight annoyance for nick change scripts - this.movement = -1 * this.movement; + PHYS_CS(this).movement = -1 * PHYS_CS(this).movement; PHYS_INPUT_BUTTON_ATCK(this) = PHYS_INPUT_BUTTON_JUMP(this) = PHYS_INPUT_BUTTON_ATCK2(this) = PHYS_INPUT_BUTTON_ZOOM(this) = PHYS_INPUT_BUTTON_CROUCH(this) = PHYS_INPUT_BUTTON_HOOK(this) = PHYS_INPUT_BUTTON_USE(this) = false; if (this.nickspamcount >= autocvar_g_nick_flood_penalty_red) // if you are persistent and the slight annoyance above does not stop you, I'll show you! @@ -598,12 +598,12 @@ void PM_check_frozen(entity this) #endif ) { - this.movement_x = bound(-5, this.movement.x, 5); - this.movement_y = bound(-5, this.movement.y, 5); - this.movement_z = bound(-5, this.movement.z, 5); + PHYS_CS(this).movement_x = bound(-5, PHYS_CS(this).movement.x, 5); + PHYS_CS(this).movement_y = bound(-5, PHYS_CS(this).movement.y, 5); + PHYS_CS(this).movement_z = bound(-5, PHYS_CS(this).movement.z, 5); } else - this.movement = '0 0 0'; + PHYS_CS(this).movement = '0 0 0'; vector midpoint = ((this.absmin + this.absmax) * 0.5); if (pointcontents(midpoint) == CONTENT_WATER) @@ -684,7 +684,7 @@ void PM_check_blocked(entity this) #ifdef SVQC if (!this.player_blocked) return; - this.movement = '0 0 0'; + PHYS_CS(this).movement = '0 0 0'; this.disableclientprediction = 1; #endif } @@ -693,8 +693,8 @@ void PM_jetpack(entity this, float maxspd_mod, float dt) { //makevectors(this.v_angle.y * '0 1 0'); makevectors(this.v_angle); - vector wishvel = v_forward * this.movement_x - + v_right * this.movement_y; + vector wishvel = v_forward * PHYS_CS(this).movement_x + + v_right * PHYS_CS(this).movement_y; // add remaining speed as Z component float maxairspd = PHYS_MAXAIRSPEED(this) * max(1, maxspd_mod); // fix speedhacks :P diff --git a/qcsrc/common/physics/player.qh b/qcsrc/common/physics/player.qh index 137da56b4..a9fbde9b0 100644 --- a/qcsrc/common/physics/player.qh +++ b/qcsrc/common/physics/player.qh @@ -206,6 +206,7 @@ STATIC_INIT(PHYS_INPUT_BUTTON_DODGE) #define PHYS_INPUT_FRAMETIME serverdeltatime #define PHYS_INPUT_MOVEVALUES(s) input_movevalues + #define PHYS_CS(s) (s) #define PHYS_INPUT_BUTTON_BUTTON1(s) boolean(input_buttons & BIT(0)) #define PHYS_INPUT_BUTTON_BUTTON2(s) boolean(input_buttons & BIT(1)) @@ -259,7 +260,8 @@ STATIC_INIT(PHYS_INPUT_BUTTON_DODGE) #define PHYS_INPUT_TIMELENGTH frametime #define PHYS_INPUT_FRAMETIME sys_frametime - #define PHYS_INPUT_MOVEVALUES(s) ((s).movement) + #define PHYS_INPUT_MOVEVALUES(s) CS(s).movement + #define PHYS_CS(s) CS(s) #define PHYS_INPUT_BUTTON_BUTTON1(s) (CS(s).button0) #define PHYS_INPUT_BUTTON_BUTTON2(s) (CS(s).button2) diff --git a/qcsrc/common/vehicles/vehicle/bumblebee.qc b/qcsrc/common/vehicles/vehicle/bumblebee.qc index 1c9e6e1a4..d3f802791 100644 --- a/qcsrc/common/vehicles/vehicle/bumblebee.qc +++ b/qcsrc/common/vehicles/vehicle/bumblebee.qc @@ -439,9 +439,9 @@ bool bumblebee_pilot_frame(entity this, float dt) // Pitch ftmp = 0; - if(this.movement.x > 0 && vang.x < autocvar_g_vehicle_bumblebee_pitchlimit) + if(CS(this).movement.x > 0 && vang.x < autocvar_g_vehicle_bumblebee_pitchlimit) ftmp = 4; - else if(this.movement.x < 0 && vang.x > -autocvar_g_vehicle_bumblebee_pitchlimit) + else if(CS(this).movement.x < 0 && vang.x > -autocvar_g_vehicle_bumblebee_pitchlimit) ftmp = -8; newvel.x = bound(-autocvar_g_vehicle_bumblebee_pitchlimit, newvel.x , autocvar_g_vehicle_bumblebee_pitchlimit); @@ -455,19 +455,19 @@ bool bumblebee_pilot_frame(entity this, float dt) makevectors('0 1 0' * vehic.angles.y); newvel = vehic.velocity * -autocvar_g_vehicle_bumblebee_friction; - if(this.movement.x != 0) + if(CS(this).movement.x != 0) { - if(this.movement.x > 0) + if(CS(this).movement.x > 0) newvel += v_forward * autocvar_g_vehicle_bumblebee_speed_forward; - else if(this.movement.x < 0) + else if(CS(this).movement.x < 0) newvel -= v_forward * autocvar_g_vehicle_bumblebee_speed_forward; } - if(this.movement.y != 0) + if(CS(this).movement.y != 0) { - if(this.movement.y < 0) + if(CS(this).movement.y < 0) newvel -= v_right * autocvar_g_vehicle_bumblebee_speed_strafe; - else if(this.movement.y > 0) + else if(CS(this).movement.y > 0) newvel += v_right * autocvar_g_vehicle_bumblebee_speed_strafe; ftmp = newvel * v_right; ftmp *= dt * 0.1; @@ -486,7 +486,7 @@ bool bumblebee_pilot_frame(entity this, float dt) newvel += v_up * autocvar_g_vehicle_bumblebee_speed_up; vehic.velocity += newvel * dt; - this.velocity = this.movement = vehic.velocity; + this.velocity = CS(this).movement = vehic.velocity; if(autocvar_g_vehicle_bumblebee_healgun_locktime) diff --git a/qcsrc/common/vehicles/vehicle/racer.qc b/qcsrc/common/vehicles/vehicle/racer.qc index 01488e624..a648a005e 100644 --- a/qcsrc/common/vehicles/vehicle/racer.qc +++ b/qcsrc/common/vehicles/vehicle/racer.qc @@ -198,17 +198,17 @@ bool racer_frame(entity this, float dt) vector df = vehic.velocity * -autocvar_g_vehicle_racer_friction; //vehic.velocity_z = ftmp; - if(this.movement) + if(CS(this).movement) { if(cont & DPCONTENTS_LIQUIDSMASK) { - if(this.movement_x) { df += v_forward * ((this.movement_x > 0) ? autocvar_g_vehicle_racer_water_speed_forward : -autocvar_g_vehicle_racer_water_speed_forward); } - if(this.movement_y) { df += v_right * ((this.movement_y > 0) ? autocvar_g_vehicle_racer_water_speed_strafe : -autocvar_g_vehicle_racer_water_speed_strafe); } + if(CS(this).movement_x) { df += v_forward * ((CS(this).movement_x > 0) ? autocvar_g_vehicle_racer_water_speed_forward : -autocvar_g_vehicle_racer_water_speed_forward); } + if(CS(this).movement_y) { df += v_right * ((CS(this).movement_y > 0) ? autocvar_g_vehicle_racer_water_speed_strafe : -autocvar_g_vehicle_racer_water_speed_strafe); } } else { - if(this.movement_x) { df += v_forward * ((this.movement_x > 0) ? autocvar_g_vehicle_racer_speed_forward : -autocvar_g_vehicle_racer_speed_forward); } - if(this.movement_y) { df += v_right * ((this.movement_y > 0) ? autocvar_g_vehicle_racer_speed_strafe : -autocvar_g_vehicle_racer_speed_strafe); } + if(CS(this).movement_x) { df += v_forward * ((CS(this).movement_x > 0) ? autocvar_g_vehicle_racer_speed_forward : -autocvar_g_vehicle_racer_speed_forward); } + if(CS(this).movement_y) { df += v_right * ((CS(this).movement_y > 0) ? autocvar_g_vehicle_racer_speed_strafe : -autocvar_g_vehicle_racer_speed_strafe); } } #ifdef SVQC @@ -284,7 +284,7 @@ bool racer_frame(entity this, float dt) dforce = autocvar_g_vehicle_racer_water_downforce; df -= v_up * (vlen(vehic.velocity) * dforce); - this.movement = vehic.velocity += df * dt; + CS(this).movement = vehic.velocity += df * dt; #ifdef SVQC diff --git a/qcsrc/common/vehicles/vehicle/raptor.qc b/qcsrc/common/vehicles/vehicle/raptor.qc index da556c4fc..e48600c47 100644 --- a/qcsrc/common/vehicles/vehicle/raptor.qc +++ b/qcsrc/common/vehicles/vehicle/raptor.qc @@ -204,8 +204,8 @@ bool raptor_frame(entity this, float dt) // Pitch ftmp = 0; - if(this.movement_x > 0 && vang_x < autocvar_g_vehicle_raptor_pitchlimit) ftmp = 5; - else if(this.movement_x < 0 && vang_x > -autocvar_g_vehicle_raptor_pitchlimit) ftmp = -20; + if(CS(this).movement_x > 0 && vang_x < autocvar_g_vehicle_raptor_pitchlimit) ftmp = 5; + else if(CS(this).movement_x < 0 && vang_x > -autocvar_g_vehicle_raptor_pitchlimit) ftmp = -20; df_x = bound(-autocvar_g_vehicle_raptor_pitchlimit, df_x , autocvar_g_vehicle_raptor_pitchlimit); ftmp = vang_x - bound(-autocvar_g_vehicle_raptor_pitchlimit, df_x + ftmp, autocvar_g_vehicle_raptor_pitchlimit); @@ -222,22 +222,22 @@ bool raptor_frame(entity this, float dt) df = vehic.velocity * -autocvar_g_vehicle_raptor_friction; - if(this.movement_x != 0) + if(CS(this).movement_x != 0) { - if(this.movement_x > 0) + if(CS(this).movement_x > 0) df += v_forward * autocvar_g_vehicle_raptor_speed_forward; - else if(this.movement_x < 0) + else if(CS(this).movement_x < 0) df -= v_forward * autocvar_g_vehicle_raptor_speed_forward; } - if(this.movement_y != 0) + if(CS(this).movement_y != 0) { - if(this.movement_y < 0) + if(CS(this).movement_y < 0) df -= v_right * autocvar_g_vehicle_raptor_speed_strafe; - else if(this.movement_y > 0) + else if(CS(this).movement_y > 0) df += v_right * autocvar_g_vehicle_raptor_speed_strafe; - vehic.angles_z = bound(-30,vehic.angles_z + (this.movement_y / autocvar_g_vehicle_raptor_speed_strafe),30); + vehic.angles_z = bound(-30,vehic.angles_z + (CS(this).movement_y / autocvar_g_vehicle_raptor_speed_strafe),30); } else { @@ -252,7 +252,7 @@ bool raptor_frame(entity this, float dt) df += v_up * autocvar_g_vehicle_raptor_speed_up; vehic.velocity += df * dt; - this.velocity = this.movement = vehic.velocity; + this.velocity = CS(this).movement = vehic.velocity; setorigin(this, vehic.origin + '0 0 32'); this.oldorigin = this.origin; // negate fall damage diff --git a/qcsrc/common/vehicles/vehicle/spiderbot.qc b/qcsrc/common/vehicles/vehicle/spiderbot.qc index 164371e13..79d938d2e 100644 --- a/qcsrc/common/vehicles/vehicle/spiderbot.qc +++ b/qcsrc/common/vehicles/vehicle/spiderbot.qc @@ -137,10 +137,10 @@ bool spiderbot_frame(entity this, float dt) //PHYS_INPUT_BUTTON_JUMP(this) = false; vector movefix = '0 0 0'; - if(this.movement_x > 0) movefix_x = 1; - if(this.movement_x < 0) movefix_x = -1; - if(this.movement_y > 0) movefix_y = 1; - if(this.movement_y < 0) movefix_y = -1; + if(CS(this).movement_x > 0) movefix_x = 1; + if(CS(this).movement_x < 0) movefix_x = -1; + if(CS(this).movement_y > 0) movefix_y = 1; + if(CS(this).movement_y < 0) movefix_y = -1; vector rt = movefix_y * v_right; vector sd = movefix_x * v_forward; @@ -154,7 +154,7 @@ bool spiderbot_frame(entity this, float dt) } else if(time >= vehic.jump_delay) { - if(!this.movement) + if(!CS(this).movement) { if(IS_ONGROUND(vehic)) { @@ -172,7 +172,7 @@ bool spiderbot_frame(entity this, float dt) else { // Turn Body - if(this.movement_x == 0 && this.movement_y != 0) + if(CS(this).movement_x == 0 && CS(this).movement_y != 0) ftmp = autocvar_g_vehicle_spiderbot_turnspeed_strafe * PHYS_INPUT_FRAMETIME; else ftmp = autocvar_g_vehicle_spiderbot_turnspeed * PHYS_INPUT_FRAMETIME; @@ -181,23 +181,23 @@ bool spiderbot_frame(entity this, float dt) vehic.angles_y = anglemods(vehic.angles_y + ftmp); vehic.tur_head.angles_y -= ftmp; - if(this.movement_x != 0) + if(CS(this).movement_x != 0) { - if(this.movement_x > 0) + if(CS(this).movement_x > 0) { - this.movement_x = 1; + CS(this).movement_x = 1; if(IS_ONGROUND(vehic)) vehic.frame = 0; } - else if(this.movement_x < 0) + else if(CS(this).movement_x < 0) { - this.movement_x = -1; + CS(this).movement_x = -1; if(IS_ONGROUND(vehic)) vehic.frame = 1; } - this.movement_y = 0; + CS(this).movement_y = 0; float oldvelz = vehic.velocity_z; - movelib_move_simple(vehic, normalize(v_forward * this.movement_x),((PHYS_INPUT_BUTTON_JUMP(this)) ? autocvar_g_vehicle_spiderbot_speed_run : autocvar_g_vehicle_spiderbot_speed_walk),autocvar_g_vehicle_spiderbot_movement_inertia); + movelib_move_simple(vehic, normalize(v_forward * CS(this).movement_x),((PHYS_INPUT_BUTTON_JUMP(this)) ? autocvar_g_vehicle_spiderbot_speed_run : autocvar_g_vehicle_spiderbot_speed_walk),autocvar_g_vehicle_spiderbot_movement_inertia); vehic.velocity_z = oldvelz; float g = ((autocvar_sv_gameplayfix_gravityunaffectedbyticrate) ? 0.5 : 1); if(vehic.velocity_z <= 20) // not while jumping @@ -211,23 +211,23 @@ bool spiderbot_frame(entity this, float dt) //dprint("spiderbot_walk:", ftos(soundlength("vehicles/spiderbot_walk.wav")), "\n"); } } - else if(this.movement_y != 0) + else if(CS(this).movement_y != 0) { - if(this.movement_y < 0) + if(CS(this).movement_y < 0) { - this.movement_y = -1; + CS(this).movement_y = -1; if(IS_ONGROUND(vehic)) vehic.frame = 2; } - else if(this.movement_y > 0) + else if(CS(this).movement_y > 0) { - this.movement_y = 1; + CS(this).movement_y = 1; if(IS_ONGROUND(vehic)) vehic.frame = 3; } float oldvelz = vehic.velocity_z; - movelib_move_simple(vehic, normalize(v_right * this.movement_y),autocvar_g_vehicle_spiderbot_speed_strafe,autocvar_g_vehicle_spiderbot_movement_inertia); + movelib_move_simple(vehic, normalize(v_right * CS(this).movement_y),autocvar_g_vehicle_spiderbot_speed_strafe,autocvar_g_vehicle_spiderbot_movement_inertia); vehic.velocity_z = oldvelz; float g = ((autocvar_sv_gameplayfix_gravityunaffectedbyticrate) ? 0.5 : 1); if(vehic.velocity_z <= 20) // not while jumping diff --git a/qcsrc/common/viewloc.qc b/qcsrc/common/viewloc.qc index 90da2662f..d6d7d9fac 100644 --- a/qcsrc/common/viewloc.qc +++ b/qcsrc/common/viewloc.qc @@ -17,12 +17,12 @@ void viewloc_PlayerPhysics(entity this) if(this.viewloc.goalentity == this.viewloc.enemy) return; // we can't side-scroll in this case - vector old_movement = this.movement; - this.movement_x = old_movement_y; - this.movement_y = 0; + vector old_movement = PHYS_CS(this).movement; + PHYS_CS(this).movement_x = old_movement_y; + PHYS_CS(this).movement_y = 0; - if(this.movement_x < 0) - this.movement_x = -this.movement_x; + if(PHYS_CS(this).movement_x < 0) + PHYS_CS(this).movement_x = -PHYS_CS(this).movement_x; vector level_start, level_end; level_start = this.viewloc.enemy.origin; @@ -31,9 +31,9 @@ void viewloc_PlayerPhysics(entity this) forward = vectoangles(normalize(level_end - level_start)); backward = vectoangles(normalize(level_start - level_end)); - if(this.movement_x < 0) // left + if(PHYS_CS(this).movement_x < 0) // left this.angles_y = backward_y; - if(this.movement_x > 0) // right + if(PHYS_CS(this).movement_x > 0) // right this.angles_y = forward_y; if(old_movement_x > 0) diff --git a/qcsrc/common/weapons/weapon/tuba.qc b/qcsrc/common/weapons/weapon/tuba.qc index ef3c4dc83..0b43a24c1 100644 --- a/qcsrc/common/weapons/weapon/tuba.qc +++ b/qcsrc/common/weapons/weapon/tuba.qc @@ -186,10 +186,10 @@ void W_Tuba_NoteOff(entity this) int W_Tuba_GetNote(entity pl, int hittype) { float movestate = 5; - if (pl.movement.x < 0) movestate -= 3; - else if (pl.movement.x > 0) movestate += 3; - if (pl.movement.y < 0) movestate -= 1; - else if (pl.movement.y > 0) movestate += 1; + if (CS(pl).movement.x < 0) movestate -= 3; + else if (CS(pl).movement.x > 0) movestate += 3; + if (CS(pl).movement.y < 0) movestate -= 1; + else if (CS(pl).movement.y > 0) movestate += 1; int note = 0; switch (movestate) diff --git a/qcsrc/ecs/systems/physics.qc b/qcsrc/ecs/systems/physics.qc index db59359b3..f4fa0e609 100644 --- a/qcsrc/ecs/systems/physics.qc +++ b/qcsrc/ecs/systems/physics.qc @@ -18,7 +18,7 @@ void sys_phys_update(entity this, float dt) if (sys_phys_override(this, dt)) { return; } sys_phys_monitor(this, dt); this.buttons_old = PHYS_INPUT_BUTTON_MASK(this); - this.movement_old = this.movement; + PHYS_CS(this).movement_old = PHYS_CS(this).movement; this.v_angle_old = this.v_angle; sys_phys_ai(this); @@ -200,10 +200,10 @@ void sys_phys_simulate(entity this, float dt) } } makevectors(vmul(this.v_angle, (this.com_phys_vel_2d ? '0 1 0' : '1 1 1'))); - // wishvel = v_forward * this.movement.x + v_right * this.movement.y + v_up * this.movement.z; - vector wishvel = v_forward * this.movement.x - + v_right * this.movement.y - + '0 0 1' * this.movement.z * (this.com_phys_vel_2d ? 0 : 1); + // wishvel = v_forward * PHYS_CS(this).movement.x + v_right * PHYS_CS(this).movement.y + v_up * PHYS_CS(this).movement.z; + vector wishvel = v_forward * PHYS_CS(this).movement.x + + v_right * PHYS_CS(this).movement.y + + '0 0 1' * PHYS_CS(this).movement.z * (this.com_phys_vel_2d ? 0 : 1); if (this.com_phys_water) { if (PHYS_INPUT_BUTTON_CROUCH(this)) { wishvel.z = -PHYS_MAXSPEED(this); @@ -216,7 +216,7 @@ void sys_phys_simulate(entity this, float dt) } if (this.com_phys_ladder) { if (this.viewloc) { - wishvel.z = this.movement_old.x; + wishvel.z = PHYS_CS(this).movement_old.x; } if (this.ladder_entity.classname == "func_water") { float f = vlen(wishvel); @@ -271,7 +271,7 @@ void sys_phys_simulate(entity this, float dt) // dv/dt = accel * maxspeed * (1 - accelqw) (when fast) // log dv/dt = logaccel + logmaxspeed (when slow) // log dv/dt = logaccel + logmaxspeed + log(1 - accelqw) (when fast) - float strafity = IsMoveInDirection(this.movement, -90) + IsMoveInDirection(this.movement, +90); // if one is nonzero, other is always zero + float strafity = IsMoveInDirection(PHYS_CS(this).movement, -90) + IsMoveInDirection(PHYS_CS(this).movement, +90); // if one is nonzero, other is always zero if (PHYS_MAXAIRSTRAFESPEED(this)) { wishspeed = min(wishspeed, @@ -288,7 +288,7 @@ void sys_phys_simulate(entity this, float dt) } // !CPM - if (PHYS_WARSOWBUNNY_TURNACCEL(this) && accelerating && this.movement.y == 0 && this.movement.x != 0) { + if (PHYS_WARSOWBUNNY_TURNACCEL(this) && accelerating && PHYS_CS(this).movement.y == 0 && PHYS_CS(this).movement.x != 0) { PM_AirAccelerate(this, dt, wishdir, wishspeed2); } else { float sidefric = maxairspd ? (PHYS_AIRACCEL_SIDEWAYS_FRICTION(this) / maxairspd) : 0; diff --git a/qcsrc/ecs/systems/sv_physics.qc b/qcsrc/ecs/systems/sv_physics.qc index fc065b2ad..ed3d3eaa8 100644 --- a/qcsrc/ecs/systems/sv_physics.qc +++ b/qcsrc/ecs/systems/sv_physics.qc @@ -25,7 +25,7 @@ void sys_phys_monitor(entity this, float dt) anticheat_physics(this); if (sv_maxidle > 0) { if (buttons != this.buttons_old - || this.movement != this.movement_old + || CS(this).movement != CS(this).movement_old || this.v_angle != this.v_angle_old) { CS(this).parm_idlesince = time; } } PM_check_nickspam(this); diff --git a/qcsrc/server/anticheat.qc b/qcsrc/server/anticheat.qc index 4e794cb3f..7173ae597 100644 --- a/qcsrc/server/anticheat.qc +++ b/qcsrc/server/anticheat.qc @@ -81,8 +81,8 @@ void anticheat_physics(entity this) MEAN_ACCUMULATE(CS(this), anticheat_div0_evade, 0.5 - 0.5 * (CS(this).anticheat_div0_evade_forward_initial * v_forward), 1); } - MEAN_ACCUMULATE(CS(this), anticheat_div0_strafebot_old, movement_oddity(this.movement, CS(this).anticheat_div0_strafebot_movement_prev), 1); - CS(this).anticheat_div0_strafebot_movement_prev = this.movement; + MEAN_ACCUMULATE(CS(this), anticheat_div0_strafebot_old, movement_oddity(CS(this).movement, CS(this).anticheat_div0_strafebot_movement_prev), 1); + CS(this).anticheat_div0_strafebot_movement_prev = CS(this).movement; // Note: this actually tries to detect snap-aim. if(CS(this).anticheat_div0_strafebot_forward_prev && time > CS(this).anticheat_fixangle_endtime) { diff --git a/qcsrc/server/bot/default/bot.qc b/qcsrc/server/bot/default/bot.qc index 6e8e5e468..a1d7b10a4 100644 --- a/qcsrc/server/bot/default/bot.qc +++ b/qcsrc/server/bot/default/bot.qc @@ -74,7 +74,7 @@ void bot_think(entity this) if (!IS_PLAYER(this) || (autocvar_g_campaign && !campaign_bots_may_start)) { - this.movement = '0 0 0'; + CS(this).movement = '0 0 0'; this.bot_nextthink = time + 0.5; return; } @@ -113,7 +113,7 @@ void bot_think(entity this) if (time < game_starttime) { // block the bot during the countdown to game start - this.movement = '0 0 0'; + CS(this).movement = '0 0 0'; this.bot_nextthink = game_starttime; return; } @@ -121,7 +121,7 @@ void bot_think(entity this) // if dead, just wait until we can respawn if (IS_DEAD(this)) { - this.movement = '0 0 0'; + CS(this).movement = '0 0 0'; if (this.deadflag == DEAD_DEAD) { PHYS_INPUT_BUTTON_JUMP(this) = true; // press jump to respawn diff --git a/qcsrc/server/bot/default/havocbot/havocbot.qc b/qcsrc/server/bot/default/havocbot/havocbot.qc index 695fabb57..cede62366 100644 --- a/qcsrc/server/bot/default/havocbot/havocbot.qc +++ b/qcsrc/server/bot/default/havocbot/havocbot.qc @@ -212,7 +212,7 @@ void havocbot_keyboard_movement(entity this, vector destorg) + 0.05 / max(1, sk + this.havocbot_keyboardskill) + random() * 0.025 / max(0.00025, skill + this.havocbot_keyboardskill) , time); - keyboard = this.movement / autocvar_sv_maxspeed; + keyboard = CS(this).movement / autocvar_sv_maxspeed; float trigger = autocvar_bot_ai_keyboard_threshold; float trigger1 = -trigger; @@ -264,8 +264,8 @@ void havocbot_keyboard_movement(entity this, vector destorg) keyboard = this.havocbot_keyboard; float blend = bound(0, vlen(destorg - this.origin) / autocvar_bot_ai_keyboard_distance, 1); // When getting close move with 360 degree - //dprint("movement ", vtos(this.movement), " keyboard ", vtos(keyboard), " blend ", ftos(blend), "\n"); - this.movement = this.movement + (keyboard - this.movement) * blend; + //dprint("movement ", vtos(CS(this).movement), " keyboard ", vtos(keyboard), " blend ", ftos(blend), "\n"); + CS(this).movement = CS(this).movement + (keyboard - CS(this).movement) * blend; } void havocbot_bunnyhop(entity this, vector dir) @@ -401,12 +401,12 @@ void havocbot_bunnyhop(entity this, vector dir) while (deviation.y > 180) deviation.y = deviation.y - 360; if(fabs(deviation.y)>10) - this.movement_x = 0; + CS(this).movement_x = 0; if(deviation.y>10) - this.movement_y = maxspeed * -1; + CS(this).movement_y = maxspeed * -1; else if(deviation.y<10) - this.movement_y = maxspeed; + CS(this).movement_y = maxspeed; } } @@ -432,7 +432,7 @@ void havocbot_movetogoal(entity this) vector dodge; //if (this.goalentity) // te_lightning2(this, this.origin, (this.goalentity.absmin + this.goalentity.absmax) * 0.5); - this.movement = '0 0 0'; + CS(this).movement = '0 0 0'; maxspeed = autocvar_sv_maxspeed; // Jetpack navigation @@ -476,7 +476,7 @@ void havocbot_movetogoal(entity this) // Brake if(fabs(this.velocity.x)>maxspeed*0.3) { - this.movement_x = dir * v_forward * -maxspeed; + CS(this).movement_x = dir * v_forward * -maxspeed; return; } // Switch to normal mode @@ -498,8 +498,8 @@ void havocbot_movetogoal(entity this) PHYS_INPUT_BUTTON_HOOK(this) = true; if(this.navigation_jetpack_point.z - STAT(PL_MAX, this).z + STAT(PL_MIN, this).z < this.origin.z) { - this.movement_x = dir * v_forward * maxspeed; - this.movement_y = dir * v_right * maxspeed; + CS(this).movement_x = dir * v_forward * maxspeed; + CS(this).movement_y = dir * v_right * maxspeed; } return; } @@ -597,8 +597,8 @@ void havocbot_movetogoal(entity this) tracebox(this.origin, this.mins, this.maxs, this.origin + (dir * maxspeed * 3), MOVE_NOMONSTERS, this); if(trace_fraction==1) { - this.movement_x = dir * v_forward * maxspeed; - this.movement_y = dir * v_right * maxspeed; + CS(this).movement_x = dir * v_forward * maxspeed; + CS(this).movement_y = dir * v_right * maxspeed; if (skill < 10) havocbot_keyboard_movement(this, this.origin + dir * 100); } @@ -621,7 +621,7 @@ void havocbot_movetogoal(entity this) if(client_hasweapon(this, WEP_DEVASTATOR, weaponentity, true, false)) { - this.movement_x = maxspeed; + CS(this).movement_x = maxspeed; if(this.rocketjumptime) { @@ -646,7 +646,7 @@ void havocbot_movetogoal(entity this) { // If there is no goal try to move forward if(this.goalcurrent==NULL) - this.movement_x = maxspeed; + CS(this).movement_x = maxspeed; } } @@ -662,9 +662,9 @@ void havocbot_movetogoal(entity this) else PHYS_INPUT_BUTTON_JUMP(this) = false; makevectors(this.v_angle.y * '0 1 0'); - this.movement_x = dir * v_forward * maxspeed; - this.movement_y = dir * v_right * maxspeed; - this.movement_z = dir * v_up * maxspeed; + CS(this).movement_x = dir * v_forward * maxspeed; + CS(this).movement_y = dir * v_right * maxspeed; + CS(this).movement_z = dir * v_up * maxspeed; } // if there is nowhere to go, exit @@ -912,9 +912,9 @@ void havocbot_movetogoal(entity this) //dir = this.bot_dodgevector; //if (this.bot_dodgevector_jumpbutton) // PHYS_INPUT_BUTTON_JUMP(this) = true; - this.movement_x = dir * v_forward * maxspeed; - this.movement_y = dir * v_right * maxspeed; - this.movement_z = dir * v_up * maxspeed; + CS(this).movement_x = dir * v_forward * maxspeed; + CS(this).movement_y = dir * v_right * maxspeed; + CS(this).movement_z = dir * v_up * maxspeed; // Emulate keyboard interface if (skill < 10) diff --git a/qcsrc/server/bot/default/scripting.qc b/qcsrc/server/bot/default/scripting.qc index da93d9556..9dca0af07 100644 --- a/qcsrc/server/bot/default/scripting.qc +++ b/qcsrc/server/bot/default/scripting.qc @@ -836,7 +836,7 @@ const int BOT_CMD_KEY_CHAT = BIT(10); bool bot_presskeys(entity this) { - this.movement = '0 0 0'; + CS(this).movement = '0 0 0'; PHYS_INPUT_BUTTON_JUMP(this) = false; PHYS_INPUT_BUTTON_CROUCH(this) = false; PHYS_INPUT_BUTTON_ATCK(this) = false; @@ -849,14 +849,14 @@ bool bot_presskeys(entity this) return false; if(this.bot_cmd_keys & BOT_CMD_KEY_FORWARD) - this.movement_x = autocvar_sv_maxspeed; + CS(this).movement_x = autocvar_sv_maxspeed; else if(this.bot_cmd_keys & BOT_CMD_KEY_BACKWARD) - this.movement_x = -autocvar_sv_maxspeed; + CS(this).movement_x = -autocvar_sv_maxspeed; if(this.bot_cmd_keys & BOT_CMD_KEY_RIGHT) - this.movement_y = autocvar_sv_maxspeed; + CS(this).movement_y = autocvar_sv_maxspeed; else if(this.bot_cmd_keys & BOT_CMD_KEY_LEFT) - this.movement_y = -autocvar_sv_maxspeed; + CS(this).movement_y = -autocvar_sv_maxspeed; if(this.bot_cmd_keys & BOT_CMD_KEY_JUMP) PHYS_INPUT_BUTTON_JUMP(this) = true; @@ -1008,7 +1008,7 @@ float bot_cmd_pause(entity this) PHYS_INPUT_BUTTON_ATCK2(this) = false; PHYS_INPUT_BUTTON_CROUCH(this) = false; - this.movement = '0 0 0'; + CS(this).movement = '0 0 0'; this.bot_cmd_keys = BOT_CMD_KEY_NONE; bot_clear(this); diff --git a/qcsrc/server/client.qc b/qcsrc/server/client.qc index f3da3ca01..f8d51eb00 100644 --- a/qcsrc/server/client.qc +++ b/qcsrc/server/client.qc @@ -1673,10 +1673,10 @@ void GetPressedKeys(entity this) { MUTATOR_CALLHOOK(GetPressedKeys, this); int keys = STAT(PRESSED_KEYS, this); - keys = BITSET(keys, KEY_FORWARD, this.movement.x > 0); - keys = BITSET(keys, KEY_BACKWARD, this.movement.x < 0); - keys = BITSET(keys, KEY_RIGHT, this.movement.y > 0); - keys = BITSET(keys, KEY_LEFT, this.movement.y < 0); + keys = BITSET(keys, KEY_FORWARD, CS(this).movement.x > 0); + keys = BITSET(keys, KEY_BACKWARD, CS(this).movement.x < 0); + keys = BITSET(keys, KEY_RIGHT, CS(this).movement.y > 0); + keys = BITSET(keys, KEY_LEFT, CS(this).movement.y < 0); keys = BITSET(keys, KEY_JUMP, PHYS_INPUT_BUTTON_JUMP(this)); keys = BITSET(keys, KEY_CROUCH, PHYS_INPUT_BUTTON_CROUCH(this)); diff --git a/qcsrc/server/client.qh b/qcsrc/server/client.qh index 53f562d86..fa1529818 100644 --- a/qcsrc/server/client.qh +++ b/qcsrc/server/client.qh @@ -74,6 +74,7 @@ CLASS(Client, Object) ATTRIB(Client, idlekick_lasttimeleft, float, this.idlekick_lasttimeleft); ATTRIB(Client, pm_frametime, float, this.pm_frametime); ATTRIB(Client, pressedkeys, int, this.pressedkeys); + ATTRIB(Client, movement_old, vector, this.movement_old); METHOD(Client, m_unwind, bool(Client this)); diff --git a/qcsrc/server/command/vote.qc b/qcsrc/server/command/vote.qc index bc75fd145..f8ab3a440 100644 --- a/qcsrc/server/command/vote.qc +++ b/qcsrc/server/command/vote.qc @@ -386,7 +386,7 @@ void reset_map(bool dorespawn) // stop the player from moving so that he stands still once he gets respawned it.velocity = '0 0 0'; it.avelocity = '0 0 0'; - it.movement = '0 0 0'; + CS(it).movement = '0 0 0'; PutClientInServer(it); }); } diff --git a/qcsrc/server/mutators/mutator/gamemode_cts.qc b/qcsrc/server/mutators/mutator/gamemode_cts.qc index ee8c221e5..b08436354 100644 --- a/qcsrc/server/mutators/mutator/gamemode_cts.qc +++ b/qcsrc/server/mutators/mutator/gamemode_cts.qc @@ -98,8 +98,8 @@ MUTATOR_HOOKFUNCTION(cts, PlayerPhysics) // ensure nothing EVIL is being done (i.e. div0_evade) // this hinders joystick users though // but it still gives SOME analog control - wishvel.x = fabs(player.movement.x); - wishvel.y = fabs(player.movement.y); + wishvel.x = fabs(CS(player).movement.x); + wishvel.y = fabs(CS(player).movement.y); if(wishvel.x != 0 && wishvel.y != 0 && wishvel.x != wishvel.y) { wishvel.z = 0; @@ -107,32 +107,32 @@ MUTATOR_HOOKFUNCTION(cts, PlayerPhysics) if(wishvel.x >= 2 * wishvel.y) { // pure X motion - if(player.movement.x > 0) - player.movement_x = wishspeed; + if(CS(player).movement.x > 0) + CS(player).movement_x = wishspeed; else - player.movement_x = -wishspeed; - player.movement_y = 0; + CS(player).movement_x = -wishspeed; + CS(player).movement_y = 0; } else if(wishvel.y >= 2 * wishvel.x) { // pure Y motion - player.movement_x = 0; - if(player.movement.y > 0) - player.movement_y = wishspeed; + CS(player).movement_x = 0; + if(CS(player).movement.y > 0) + CS(player).movement_y = wishspeed; else - player.movement_y = -wishspeed; + CS(player).movement_y = -wishspeed; } else { // diagonal - if(player.movement.x > 0) - player.movement_x = M_SQRT1_2 * wishspeed; + if(CS(player).movement.x > 0) + CS(player).movement_x = M_SQRT1_2 * wishspeed; else - player.movement_x = -M_SQRT1_2 * wishspeed; - if(player.movement.y > 0) - player.movement_y = M_SQRT1_2 * wishspeed; + CS(player).movement_x = -M_SQRT1_2 * wishspeed; + if(CS(player).movement.y > 0) + CS(player).movement_y = M_SQRT1_2 * wishspeed; else - player.movement_y = -M_SQRT1_2 * wishspeed; + CS(player).movement_y = -M_SQRT1_2 * wishspeed; } } } diff --git a/qcsrc/server/mutators/mutator/gamemode_race.qc b/qcsrc/server/mutators/mutator/gamemode_race.qc index c4c8f087e..1fa07d7cc 100644 --- a/qcsrc/server/mutators/mutator/gamemode_race.qc +++ b/qcsrc/server/mutators/mutator/gamemode_race.qc @@ -150,8 +150,8 @@ MUTATOR_HOOKFUNCTION(rc, PlayerPhysics) // ensure nothing EVIL is being done (i.e. div0_evade) // this hinders joystick users though // but it still gives SOME analog control - wishvel.x = fabs(player.movement.x); - wishvel.y = fabs(player.movement.y); + wishvel.x = fabs(CS(player).movement.x); + wishvel.y = fabs(CS(player).movement.y); if(wishvel.x != 0 && wishvel.y != 0 && wishvel.x != wishvel.y) { wishvel.z = 0; @@ -159,32 +159,32 @@ MUTATOR_HOOKFUNCTION(rc, PlayerPhysics) if(wishvel.x >= 2 * wishvel.y) { // pure X motion - if(player.movement.x > 0) - player.movement_x = wishspeed; + if(CS(player).movement.x > 0) + CS(player).movement_x = wishspeed; else - player.movement_x = -wishspeed; - player.movement_y = 0; + CS(player).movement_x = -wishspeed; + CS(player).movement_y = 0; } else if(wishvel.y >= 2 * wishvel.x) { // pure Y motion - player.movement_x = 0; - if(player.movement.y > 0) - player.movement_y = wishspeed; + CS(player).movement_x = 0; + if(CS(player).movement.y > 0) + CS(player).movement_y = wishspeed; else - player.movement_y = -wishspeed; + CS(player).movement_y = -wishspeed; } else { // diagonal - if(player.movement.x > 0) - player.movement_x = M_SQRT1_2 * wishspeed; + if(CS(player).movement.x > 0) + CS(player).movement_x = M_SQRT1_2 * wishspeed; else - player.movement_x = -M_SQRT1_2 * wishspeed; - if(player.movement.y > 0) - player.movement_y = M_SQRT1_2 * wishspeed; + CS(player).movement_x = -M_SQRT1_2 * wishspeed; + if(CS(player).movement.y > 0) + CS(player).movement_y = M_SQRT1_2 * wishspeed; else - player.movement_y = -M_SQRT1_2 * wishspeed; + CS(player).movement_y = -M_SQRT1_2 * wishspeed; } } } diff --git a/qcsrc/server/playerdemo.qc b/qcsrc/server/playerdemo.qc index 427e5c32d..90de79b8a 100644 --- a/qcsrc/server/playerdemo.qc +++ b/qcsrc/server/playerdemo.qc @@ -160,7 +160,7 @@ float playerdemo_read(entity this) this.playerdemo_time += this.playerdemo_starttime; } this.velocity = '0 0 0'; - this.movement = '0 0 0'; + CS(this).movement = '0 0 0'; this.dmg_take = 0; // so screen doesn't stay blurry this.dmg_save = 0; this.dmg_inflictor = NULL; -- 2.39.2