From 66474142a4fbb9455adacbe1eb34aab628ac3f27 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 13 Oct 2022 00:21:09 +0200 Subject: [PATCH] - wrapped as much of _slide_vect as possible. --- source/games/sw/src/game.h | 2 ++ source/games/sw/src/player.cpp | 16 ++++++++-------- source/games/sw/src/weapon.cpp | 12 ++++++------ 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/source/games/sw/src/game.h b/source/games/sw/src/game.h index 14b1743ea..b89bb8361 100644 --- a/source/games/sw/src/game.h +++ b/source/games/sw/src/game.h @@ -642,6 +642,8 @@ struct PLAYER void set_int_vect_y(int v) { _vect.Y = v; } void add_int_vect_x(int v) { _vect.X += v; } void add_int_vect_y(int v) { _vect.Y += v; } + void set_int_slide_vect_x(int v) { _slide_vect.X = v; } + void set_int_slide_vect_y(int v) { _slide_vect.Y = v; } int friction; int16_t slide_ang; // todo: floatify diff --git a/source/games/sw/src/player.cpp b/source/games/sw/src/player.cpp index dd3176ebd..35f5e892d 100644 --- a/source/games/sw/src/player.cpp +++ b/source/games/sw/src/player.cpp @@ -1845,17 +1845,17 @@ void DoPlayerSlide(PLAYER* pp) int push_ret; - if ((pp->_slide_vect.X|pp->_slide_vect.Y) == 0) + if ((pp->int_slide_vect().X|pp->int_slide_vect().Y) == 0) return; if (pp->sop) return; - pp->_slide_vect.X = MulScale(pp->_slide_vect.X, PLAYER_SLIDE_FRICTION, 16); - pp->_slide_vect.Y = MulScale(pp->_slide_vect.Y, PLAYER_SLIDE_FRICTION, 16); + pp->set_int_slide_vect_x(MulScale(pp->int_slide_vect().X, PLAYER_SLIDE_FRICTION, 16)); + pp->set_int_slide_vect_y(MulScale(pp->int_slide_vect().Y, PLAYER_SLIDE_FRICTION, 16)); - if (abs(pp->_slide_vect.X) < 12800 && abs(pp->_slide_vect.Y) < 12800) - pp->_slide_vect.X = pp->_slide_vect.Y = 0; + if (abs(pp->int_slide_vect().X) < 12800 && abs(pp->int_slide_vect().Y) < 12800) + pp->_slide_vect = { 0, 0 }; push_ret = pushmove(pp->pos, &pp->cursector, ((int)actor->spr.clipdist<<2), pp->p_ceiling_dist, pp->p_floor_dist, CLIPMASK_PLAYER); if (push_ret < 0) @@ -1871,7 +1871,7 @@ void DoPlayerSlide(PLAYER* pp) return; } Collision coll; - clipmove(pp->pos, &pp->cursector, pp->_slide_vect.X, pp->_slide_vect.Y, ((int)actor->spr.clipdist<<2), pp->p_ceiling_dist, pp->p_floor_dist, CLIPMASK_PLAYER, coll); + clipmove(pp->pos, &pp->cursector, pp->int_slide_vect().X, pp->int_slide_vect().Y, ((int)actor->spr.clipdist<<2), pp->p_ceiling_dist, pp->p_floor_dist, CLIPMASK_PLAYER, coll); PlayerCheckValidMove(pp); push_ret = pushmove(pp->pos, &pp->cursector, ((int)actor->spr.clipdist<<2), pp->p_ceiling_dist, pp->p_floor_dist, CLIPMASK_PLAYER); @@ -2618,8 +2618,8 @@ void DoPlayerMoveVehicle(PLAYER* pp) if (vel > 13000) { VehicleMoveHit(actor); - pp->_slide_vect.X = -pp->int_vect().X<<1; - pp->_slide_vect.Y = -pp->int_vect().Y<<1; + pp->set_int_slide_vect_x(-pp->int_vect().X<<1); + pp->set_int_slide_vect_y(-pp->int_vect().Y<<1); if (!(sop->flags & SOBJ_NO_QUAKE)) SetPlayerQuake(pp); } diff --git a/source/games/sw/src/weapon.cpp b/source/games/sw/src/weapon.cpp index 33c5da554..fde1c7aa7 100644 --- a/source/games/sw/src/weapon.cpp +++ b/source/games/sw/src/weapon.cpp @@ -5250,23 +5250,23 @@ int PlayerDamageSlide(PLAYER* pp, int damage, short ang) else if (damage <= 10) { //nudge - pp->_slide_vect.X = MOVEx(16, ang)<<15; - pp->_slide_vect.Y = MOVEy(16, ang)<<15; + pp->set_int_slide_vect_x(MOVEx(16, ang)<<15); + pp->set_int_slide_vect_y(MOVEy(16, ang)<<15); return true; } else if (damage <= 20) { //bigger nudge - pp->_slide_vect.X = MOVEx(64, ang)<<15; - pp->_slide_vect.Y = MOVEy(64, ang)<<15; + pp->set_int_slide_vect_x(MOVEx(64, ang)<<15); + pp->set_int_slide_vect_y(MOVEy(64, ang)<<15); return true; } else { slide_vel = (damage * 6); - pp->_slide_vect.X = MOVEx(slide_vel, ang)<<15; - pp->_slide_vect.Y = MOVEy(slide_vel, ang)<<15; + pp->set_int_slide_vect_x(MOVEx(slide_vel, ang)<<15); + pp->set_int_slide_vect_y(MOVEy(slide_vel, ang)<<15); return true; }