From c3510091b0c1d8a742b6a006e604b0aae2dce10a Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 13 Oct 2022 00:55:40 +0200 Subject: [PATCH] - unwrapped PlayerDamageSlide and removed the wrappers. --- source/games/sw/src/game.h | 12 +----------- source/games/sw/src/weapon.cpp | 17 +++++------------ 2 files changed, 6 insertions(+), 23 deletions(-) diff --git a/source/games/sw/src/game.h b/source/games/sw/src/game.h index 59926c9d0..27248a21a 100644 --- a/source/games/sw/src/game.h +++ b/source/games/sw/src/game.h @@ -630,16 +630,6 @@ struct PLAYER DAngle siang; DVector2 vect, ovect, slide_vect; // these need floatification, but must be done together. vect is in 14.18 format! - vec2_t int_vect() const { return vec2_t(FloatToFixed<18>(vect.X), FloatToFixed<18>(vect.Y)); } - vec2_t int_ovect() const { return vec2_t(FloatToFixed<18>(ovect.X), FloatToFixed<18>(ovect.Y)); } - vec2_t int_slide_vect() const { return vec2_t(FloatToFixed<18>(slide_vect.X), FloatToFixed<18>(slide_vect.Y)); } - - void set_int_vect_x(int v) { vect.X = FixedToFloat<18>(v); } - void set_int_vect_y(int v) { vect.Y = FixedToFloat<18>(v); } - void add_int_vect_x(int v) { vect.X += FixedToFloat<18>(v); } - void add_int_vect_y(int v) { vect.Y += FixedToFloat<18>(v); } - void set_int_slide_vect_x(int v) { slide_vect.X = FixedToFloat<18>(v); } - void set_int_slide_vect_y(int v) { slide_vect.Y = FixedToFloat<18>(v); } int friction; int16_t slide_ang; // todo: floatify @@ -2251,7 +2241,7 @@ inline bool SpriteInUnderwaterArea(DSWActor* a) // just determine if the player is moving inline bool PLAYER_MOVING(PLAYER* pp) { - return (pp->int_vect().X | pp->int_vect().Y); + return !pp->vect.isZero(); } inline void PlaySound(int num, DSWActor* actor, int flags, int channel = 8, EChanFlags sndflags = CHANF_NONE) diff --git a/source/games/sw/src/weapon.cpp b/source/games/sw/src/weapon.cpp index d51c2d35b..c3bae4f51 100644 --- a/source/games/sw/src/weapon.cpp +++ b/source/games/sw/src/weapon.cpp @@ -5232,7 +5232,7 @@ int ActorDamageSlide(DSWActor* actor, int damage, int ang) int PlayerDamageSlide(PLAYER* pp, int damage, short ang) { - int slide_vel; + DAngle angle = DAngle::fromBuild(ang); damage = abs(damage); @@ -5242,32 +5242,25 @@ int PlayerDamageSlide(PLAYER* pp, int damage, short ang) if (damage <= 5) { //nudge - //pp->slide_xvect = MOVEx(4, ang)<<15; - //pp->slide_yvect = MOVEy(4, ang)<<15; + //pp->slide_xvect = angle.ToVector() * 0.5; //return(true); return false; } else if (damage <= 10) { //nudge - pp->set_int_slide_vect_x(MOVEx(16, ang)<<15); - pp->set_int_slide_vect_y(MOVEy(16, ang)<<15); + pp->slide_vect = angle.ToVector() * 2; return true; } else if (damage <= 20) { //bigger nudge - pp->set_int_slide_vect_x(MOVEx(64, ang)<<15); - pp->set_int_slide_vect_y(MOVEy(64, ang)<<15); + pp->slide_vect = angle.ToVector() * 8; return true; } else { - slide_vel = (damage * 6); - - pp->set_int_slide_vect_x(MOVEx(slide_vel, ang)<<15); - pp->set_int_slide_vect_y(MOVEy(slide_vel, ang)<<15); - + pp->slide_vect = angle.ToVector() * damage * 0.75; return true; } }