From f9fb48b9302b610c9e5ba3a8bab048712865d833 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 4 Sep 2022 20:43:12 +0200 Subject: [PATCH] - handle DoActorSetSpeed --- source/games/sw/src/ai.cpp | 31 ++++++++++--------------------- source/games/sw/src/game.h | 27 +++++++++++++++++++-------- 2 files changed, 29 insertions(+), 29 deletions(-) diff --git a/source/games/sw/src/ai.cpp b/source/games/sw/src/ai.cpp index 3f090813b..8896242fb 100644 --- a/source/games/sw/src/ai.cpp +++ b/source/games/sw/src/ai.cpp @@ -48,25 +48,11 @@ ANIMATOR* ChooseAction(DECISION decision[]); #define CHOOSE2(value) (RANDOM_P2(1024) < (value)) -int Distance(int x1, int y1, int x2, int y2) -{ - int min; - - if ((x2 = x2 - x1) < 0) - x2 = -x2; - - if ((y2 = y2 - y1) < 0) - y2 = -y2; - - if (x2 > y2) - min = y2; - else - min = x2; - - return x2 + y2 - (min >> 1); -} - - +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- bool ActorMoveHitReact(DSWActor* actor) { @@ -114,10 +100,13 @@ void DoActorSetSpeed(DSWActor* actor, uint8_t speed) actor->user.speed = speed; + int vel; if (ActorFlaming(actor)) - actor->set_int_xvel(actor->user.Attrib->Speed[speed] + (actor->user.Attrib->Speed[speed] >> 1)); + vel = actor->user.Attrib->Speed[speed] + (actor->user.Attrib->Speed[speed] >> 1); else - actor->set_int_xvel(actor->user.Attrib->Speed[speed]); + vel = actor->user.Attrib->Speed[speed]; + + actor->vel.X = vel * maptoworld; } /* diff --git a/source/games/sw/src/game.h b/source/games/sw/src/game.h index 21d9d09f1..b49053a6a 100644 --- a/source/games/sw/src/game.h +++ b/source/games/sw/src/game.h @@ -1628,17 +1628,28 @@ extern SECTOR_OBJECT SectorObject[MAX_SECTOR_OBJECTS]; ANIMATOR NullAnimator; -int Distance(int x1, int y1, int x2, int y2); -int DistanceI(const DVector2& pos1, const DVector2& pos2) +inline int Distance(int x1, int y1, int x2, int y2) +{ + int min; + + if ((x2 = x2 - x1) < 0) + x2 = -x2; + + if ((y2 = y2 - y1) < 0) + y2 = -y2; + + if (x2 > y2) + min = y2; + else + min = x2; + + return x2 + y2 - (min >> 1); +} + +inline int DistanceI(const DVector2& pos1, const DVector2& pos2) { return Distance(int(pos1.X * worldtoint), int(pos1.Y * worldtoint), int(pos2.X * worldtoint), int(pos2.Y * worldtoint)); } -/* -double Distance(const DVector2& pos1, const DVector2& pos2) -{ - return (pos2 - pos1).Length(); -} - */ int NewStateGroup(DSWActor* actor, STATE* SpriteGroup[]); void SectorMidPoint(sectortype* sect, int *xmid, int *ymid, int *zmid);