From 6eb18eb3f60ebd82c60edf13054666373c13ee74 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 3 Sep 2022 12:01:37 +0200 Subject: [PATCH] - floatified all move_actor calls in SW --- source/games/sw/src/actor.cpp | 17 ++++------------- source/games/sw/src/ai.cpp | 23 +++-------------------- source/games/sw/src/bunny.cpp | 8 +------- source/games/sw/src/coolg.cpp | 6 +----- source/games/sw/src/girlninj.cpp | 8 +------- source/games/sw/src/hornet.cpp | 10 ++-------- source/games/sw/src/ninja.cpp | 8 +------- source/games/sw/src/ripper.cpp | 8 +------- source/games/sw/src/ripper2.cpp | 8 +------- source/games/sw/src/sprite.cpp | 4 +--- source/games/sw/src/sprite.h | 2 +- 11 files changed, 17 insertions(+), 85 deletions(-) diff --git a/source/games/sw/src/actor.cpp b/source/games/sw/src/actor.cpp index bd7b202d2..78ea1bd7d 100644 --- a/source/games/sw/src/actor.cpp +++ b/source/games/sw/src/actor.cpp @@ -435,13 +435,8 @@ int DoActorDebris(DSWActor* actor) int DoFireFly(DSWActor* actor) { - int nx, ny; - - nx = 4 * ACTORMOVETICS * bcos(actor->int_ang()) >> 14; - ny = 4 * ACTORMOVETICS * bsin(actor->int_ang()) >> 14; - actor->spr.clipdist = 256>>2; - if (!move_actor(actor, nx, ny, 0L)) + if (!move_actor(actor, DVector3(actor->spr.angle.ToVector() * (0.25 * ACTORMOVETICS), 0))) { actor->spr.angle += DAngle180; } @@ -590,7 +585,7 @@ int DoActorSlide(DSWActor* actor) nx = MulScale(actor->user.slide_vel, bcos(actor->user.slide_ang), 14); ny = MulScale(actor->user.slide_vel, bsin(actor->user.slide_ang), 14); - if (!move_actor(actor, nx, ny, 0L)) + if (!move_actor(actor, DVector3(nx * inttoworld, ny * inttoworld, 0))) { actor->user.Flags &= ~(SPR_SLIDING); return false; @@ -763,8 +758,6 @@ int DoActorStopFall(DSWActor* actor) int DoActorDeathMove(DSWActor* actor) { - int nx, ny; - if (actor->user.Flags & (SPR_JUMPING | SPR_FALLING)) { if (actor->user.Flags & (SPR_JUMPING)) @@ -773,11 +766,9 @@ int DoActorDeathMove(DSWActor* actor) DoActorFall(actor); } - nx = MulScale(actor->int_xvel(), bcos(actor->int_ang()), 14); - ny = MulScale(actor->int_xvel(), bsin(actor->int_ang()), 14); - actor->spr.clipdist = (128+64)>>2; - move_actor(actor, nx, ny, 0); + move_actor(actor, DVector3(actor->spr.angle.ToVector() * actor->vel.X, 0)); + // only fall on top of floor sprite or sector DoFindGroundPoint(actor); diff --git a/source/games/sw/src/ai.cpp b/source/games/sw/src/ai.cpp index 2d073b9e1..564295e5b 100644 --- a/source/games/sw/src/ai.cpp +++ b/source/games/sw/src/ai.cpp @@ -803,13 +803,8 @@ int DoActorCantMoveCloser(DSWActor* actor) int DoActorMoveCloser(DSWActor* actor) { - int nx, ny; - - nx = MulScale(actor->int_xvel(), bcos(actor->int_ang()), 14); - ny = MulScale(actor->int_xvel(), bsin(actor->int_ang()), 14); - // if cannot move the sprite - if (!move_actor(actor, nx, ny, 0)) + if (!move_actor(actor, DVector3(actor->spr.angle.ToVector() * actor->vel.X, 0))) { if (ActorMoveHitReact(actor)) return 0; @@ -1278,14 +1273,7 @@ int DoActorDuck(DSWActor* actor) int DoActorMoveJump(DSWActor* actor) { - int nx, ny; - - // Move while jumping - - nx = MulScale(actor->int_xvel(), bcos(actor->int_ang()), 14); - ny = MulScale(actor->int_xvel(), bsin(actor->int_ang()), 14); - - move_actor(actor, nx, ny, 0L); + move_actor(actor, DVector3(actor->spr.angle.ToVector() * actor->vel.X, 0)); if (!(actor->user.Flags & (SPR_JUMPING|SPR_FALLING))) { @@ -1588,13 +1576,8 @@ int InitActorReposition(DSWActor* actor) int DoActorReposition(DSWActor* actor) { - int nx, ny; - - nx = MulScale(actor->int_xvel(), bcos(actor->int_ang()), 14); - ny = MulScale(actor->int_xvel(), bsin(actor->int_ang()), 14); - // still might hit something and have to handle it. - if (!move_actor(actor, nx, ny, 0L)) + if (!move_actor(actor, DVector3(actor->spr.angle.ToVector() * actor->vel.X, 0))) { if (ActorMoveHitReact(actor)) return 0; diff --git a/source/games/sw/src/bunny.cpp b/source/games/sw/src/bunny.cpp index f2e772266..d20f91bc5 100644 --- a/source/games/sw/src/bunny.cpp +++ b/source/games/sw/src/bunny.cpp @@ -863,13 +863,7 @@ int DoBunnyMoveJump(DSWActor* actor) { if (actor->user.Flags & (SPR_JUMPING | SPR_FALLING)) { - int nx, ny; - - // Move while jumping - nx = MulScale(actor->int_xvel(), bcos(actor->int_ang()), 14); - ny = MulScale(actor->int_xvel(), bsin(actor->int_ang()), 14); - - move_actor(actor, nx, ny, 0L); + move_actor(actor, DVector3(actor->spr.angle.ToVector() * actor->vel.X, 0)); if (actor->user.Flags & (SPR_JUMPING)) DoActorJump(actor); diff --git a/source/games/sw/src/coolg.cpp b/source/games/sw/src/coolg.cpp index ef8acfd0b..ba785a2cf 100644 --- a/source/games/sw/src/coolg.cpp +++ b/source/games/sw/src/coolg.cpp @@ -702,14 +702,10 @@ int InitCoolgCircle(DSWActor* actor) int DoCoolgCircle(DSWActor* actor) { double bound; - int nx,ny; actor->set_int_ang(NORM_ANGLE(actor->int_ang() + actor->user.Counter2)); - nx = MulScale(actor->int_xvel(), bcos(actor->int_ang()), 14); - ny = MulScale(actor->int_xvel(), bsin(actor->int_ang()), 14); - - if (!move_actor(actor, nx, ny, 0L)) + if (!move_actor(actor, DVector3(actor->spr.angle.ToVector() * actor->vel.X, 0))) { InitActorReposition(actor); return 0; diff --git a/source/games/sw/src/girlninj.cpp b/source/games/sw/src/girlninj.cpp index 1e6cee5a8..7af3d073b 100644 --- a/source/games/sw/src/girlninj.cpp +++ b/source/games/sw/src/girlninj.cpp @@ -776,14 +776,8 @@ int DoGirlNinjaMove(DSWActor* actor) int GirlNinjaJumpActionFunc(DSWActor* actor) { - int nx, ny; - - // Move while jumping - nx = MulScale(actor->int_xvel(), bcos(actor->int_ang()), 14); - ny = MulScale(actor->int_xvel(), bsin(actor->int_ang()), 14); - // if cannot move the sprite - if (!move_actor(actor, nx, ny, 0L)) + if (!move_actor(actor, DVector3(actor->spr.angle.ToVector() * actor->vel.X, 0))) { return 0; } diff --git a/source/games/sw/src/hornet.cpp b/source/games/sw/src/hornet.cpp index 4291757a7..2e07279b2 100644 --- a/source/games/sw/src/hornet.cpp +++ b/source/games/sw/src/hornet.cpp @@ -434,25 +434,19 @@ int InitHornetCircle(DSWActor* actor) int DoHornetCircle(DSWActor* actor) { - int nx,ny; double bound; actor->set_int_ang(NORM_ANGLE(actor->int_ang() + actor->user.Counter2)); - nx = MulScale(actor->int_xvel(), bcos(actor->int_ang()), 14); - ny = MulScale(actor->int_xvel(), bsin(actor->int_ang()), 14); - - if (!move_actor(actor, nx, ny, 0L)) + if (!move_actor(actor, DVector3(actor->spr.angle.ToVector() * actor->vel.X, 0))) { //ActorMoveHitReact(actor); // try moving in the opposite direction actor->user.Counter2 = -actor->user.Counter2; actor->spr.angle += DAngle180; - nx = MulScale(actor->int_xvel(), bcos(actor->int_ang()), 14); - ny = MulScale(actor->int_xvel(), bsin(actor->int_ang()), 14); - if (!move_actor(actor, nx, ny, 0)) + if (!move_actor(actor, DVector3(actor->spr.angle.ToVector() * actor->vel.X, 0))) { InitActorReposition(actor); return 0; diff --git a/source/games/sw/src/ninja.cpp b/source/games/sw/src/ninja.cpp index 1d724dab8..38011c199 100644 --- a/source/games/sw/src/ninja.cpp +++ b/source/games/sw/src/ninja.cpp @@ -2033,14 +2033,8 @@ int DoNinjaMove(DSWActor* actor) int NinjaJumpActionFunc(DSWActor* actor) { - int nx, ny; - - // Move while jumping - nx = MulScale(actor->int_xvel(), bcos(actor->int_ang()), 14); - ny = MulScale(actor->int_xvel(), bsin(actor->int_ang()), 14); - // if cannot move the sprite - if (!move_actor(actor, nx, ny, 0L)) + if (!move_actor(actor, DVector3(actor->spr.angle.ToVector() * actor->vel.X, 0))) { return 0; } diff --git a/source/games/sw/src/ripper.cpp b/source/games/sw/src/ripper.cpp index da93c6c67..4c952fe23 100644 --- a/source/games/sw/src/ripper.cpp +++ b/source/games/sw/src/ripper.cpp @@ -976,14 +976,8 @@ int DoRipperHang(DSWActor* actor) int DoRipperMoveHang(DSWActor* actor) { - int nx, ny; - - // Move while jumping - nx = MulScale(actor->int_xvel(), bcos(actor->int_ang()), 14); - ny = MulScale(actor->int_xvel(), bsin(actor->int_ang()), 14); - // if cannot move the sprite - if (!move_actor(actor, nx, ny, 0L)) + if (!move_actor(actor, DVector3(actor->spr.angle.ToVector() * actor->vel.X, 0))) { if (actor->user.coll.type == kHitWall) { diff --git a/source/games/sw/src/ripper2.cpp b/source/games/sw/src/ripper2.cpp index a7137ed49..0cf1f694a 100644 --- a/source/games/sw/src/ripper2.cpp +++ b/source/games/sw/src/ripper2.cpp @@ -990,14 +990,8 @@ int DoRipper2Hang(DSWActor* actor) int DoRipper2MoveHang(DSWActor* actor) { - int nx, ny; - - // Move while jumping - nx = MulScale(actor->int_xvel(), bcos(actor->int_ang()), 14); - ny = MulScale(actor->int_xvel(), bsin(actor->int_ang()), 14); - // if cannot move the sprite - if (!move_actor(actor, nx, ny, 0L)) + if (!move_actor(actor, DVector3(actor->spr.angle.ToVector() * actor->vel.X, 0))) { if (actor->user.coll.type == kHitWall) { diff --git a/source/games/sw/src/sprite.cpp b/source/games/sw/src/sprite.cpp index 05ca98039..30ee1ff51 100644 --- a/source/games/sw/src/sprite.cpp +++ b/source/games/sw/src/sprite.cpp @@ -4566,9 +4566,8 @@ bool DropAhead(DSWActor* actor, double min_height) */ -int move_actor(DSWActor* actor, int xchange, int ychange, int zchange) +int move_actor(DSWActor* actor, const DVector3& change) { - DVector3 change(xchange * inttoworld, ychange * inttoworld, zchange * zinttoworld); DSWActor* highActor; DSWActor* lowActor; sectortype* lo_sectp,* hi_sectp; @@ -4648,7 +4647,6 @@ int move_actor(DSWActor* actor, int xchange, int ychange, int zchange) { return false; } - } int DoStayOnFloor(DSWActor* actor) diff --git a/source/games/sw/src/sprite.h b/source/games/sw/src/sprite.h index b5b849485..ab8c640f3 100644 --- a/source/games/sw/src/sprite.h +++ b/source/games/sw/src/sprite.h @@ -39,7 +39,7 @@ inline DSWActor* SpawnActor(int stat, int id, STATE* state, sectortype* sect, in } void SpriteSetup(void); -int move_actor(DSWActor* actor, int xchange, int ychange, int zchange); +int move_actor(DSWActor* actor, const DVector3& change); short GetSpriteDir(short sn); short GetDirToPlayer(short sn); short PlayerInVision(short sn, short view_deg);