From 8efe6f638b3e5e93bc33f1031395b0b5b88a2202 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 13 Oct 2022 00:47:49 +0200 Subject: [PATCH] - DoTankTreads and DoPlayerMoveVehicle unwrapped --- source/games/sw/src/player.cpp | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/source/games/sw/src/player.cpp b/source/games/sw/src/player.cpp index e2212db11..ac324eb54 100644 --- a/source/games/sw/src/player.cpp +++ b/source/games/sw/src/player.cpp @@ -2179,17 +2179,15 @@ void StopSOsound(sectortype* sect) void DoTankTreads(PLAYER* pp) { int i; - int vel; sectortype* *sectp; int j; - int dot; bool reverse = false; if (Prediction) return; - vel = FindDistance2D(pp->int_vect().X>>8, pp->int_vect().Y>>8); - dot = DOT_PRODUCT_2D(pp->int_vect().X, pp->int_vect().Y, pp->angle.ang.Cos() * (1 << 14), pp->angle.ang.Sin() * (1 << 14)); + int vel = int(pp->vect.Length() * 1024); + double dot = pp->vect.dot(pp->angle.ang.ToVector()); if (dot < 0) reverse = true; @@ -2470,27 +2468,23 @@ void DoPlayerMoveVehicle(PLAYER* pp) if (sop->drive_speed) { - pp->set_int_vect_x(MulScale(pp->input.fvel, sop->drive_speed, 6)); - pp->set_int_vect_y(MulScale(pp->input.svel, sop->drive_speed, 6)); + pp->vect.X = MulScaleF(pp->input.fvel, sop->drive_speed, 24); + pp->vect.Y = MulScaleF(pp->input.svel, sop->drive_speed, 24); // does sliding/momentum - pp->set_int_vect_x((pp->int_vect().X + (pp->int_ovect().X*(sop->drive_slide-1)))/sop->drive_slide); - pp->set_int_vect_y((pp->int_vect().Y + (pp->int_ovect().Y*(sop->drive_slide-1)))/sop->drive_slide); + pp->vect = (pp->vect + (pp->ovect * (sop->drive_slide-1)))/sop->drive_slide; } else { - pp->add_int_vect_x(((pp->input.fvel*synctics*2)<<6)); - pp->add_int_vect_y(((pp->input.svel*synctics*2)<<6)); + pp->vect.X += (pp->input.fvel*synctics*2) * INPUT_SCALE; + pp->vect.Y += (pp->input.svel*synctics*2) * INPUT_SCALE; + pp->vect *= TANK_FRICTION; - pp->set_int_vect_x(MulScale(pp->int_vect().X, TANK_FRICTION, 16)); - pp->set_int_vect_y(MulScale(pp->int_vect().Y, TANK_FRICTION, 16)); - - pp->set_int_vect_x((pp->int_vect().X + (pp->int_ovect().X*1))/2); - pp->set_int_vect_y((pp->int_vect().Y + (pp->int_ovect().Y*1))/2); + pp->vect = (pp->vect + (pp->ovect*1))/2; } - if (abs(pp->int_vect().X) < 12800 && abs(pp->int_vect().Y) < 12800) - pp->vect.Zero(); + if (abs(pp->vect.X) < 0.5 && abs(pp->vect.Y) < 0.5) + pp->vect.X = pp->vect.Y = 0; pp->lastcursector = pp->cursector; z = pp->int_ppos().Z + Z(10);