From 94b676bd7cd163519a98daf0d16ff8524a2a3e3e Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 17 Dec 2022 09:49:11 +0100 Subject: [PATCH] - wrapped access to the current 'move' values read from CON. --- source/games/duke/src/actors.cpp | 4 ++-- source/games/duke/src/actors_d.cpp | 8 +++----- source/games/duke/src/actors_r.cpp | 8 +++----- source/games/duke/src/inlines.h | 12 ++++++++++++ source/games/duke/src/types.h | 4 ++++ 5 files changed, 24 insertions(+), 12 deletions(-) diff --git a/source/games/duke/src/actors.cpp b/source/games/duke/src/actors.cpp index 470ef0db1..cfcdc03db 100644 --- a/source/games/duke/src/actors.cpp +++ b/source/games/duke/src/actors.cpp @@ -3256,10 +3256,10 @@ void alterang(int ang, DDukeActor* actor, int playernum) aang = actor->spr.Angles.Yaw; - actor->vel.X += (moveptr[0] / 16 - actor->vel.X) / 5; + actor->vel.X += (actor->GetMoveX() - actor->vel.X) / 5; if (actor->vel.Z < (648 / 256.)) { - actor->vel.Z += (moveptr[1] / 16 - actor->vel.Z) / 5; + actor->vel.Z += (actor->GetMoveZ() - actor->vel.Z) / 5; } if (isRRRA() && (ang & windang)) diff --git a/source/games/duke/src/actors_d.cpp b/source/games/duke/src/actors_d.cpp index 7e927d247..3a5e03801 100644 --- a/source/games/duke/src/actors_d.cpp +++ b/source/games/duke/src/actors_d.cpp @@ -1195,10 +1195,8 @@ void move_d(DDukeActor *actor, int playernum, int xvel) return; } - auto moveptr = &ScriptCode[actor->temp_data[1]]; - - if (a & geth) actor->vel.X += (moveptr[0] / 16. - actor->vel.X) * 0.5; - if (a & getv) actor->vel.Z += (moveptr[1] / 16. - actor->vel.Z) * 0.5; + if (a & geth) actor->vel.X += (actor->GetMoveX() - actor->vel.X) * 0.5; + if (a & getv) actor->vel.Z += (actor->GetMoveZ() - actor->vel.Z) * 0.5; if (a & dodgebullet) dodge(actor); @@ -1295,7 +1293,7 @@ void move_d(DDukeActor *actor, int playernum, int xvel) } else if (!(actor->flags2 & SFLAG2_FLOATING)) { - if (!*(moveptr + 1)) + if (actor->GetMoveZ() == 0) { if (actor->opos.Z != actor->spr.pos.Z || (ud.multimode < 2 && ud.player_skill < 2)) { diff --git a/source/games/duke/src/actors_r.cpp b/source/games/duke/src/actors_r.cpp index e036c224f..4cf3b567f 100644 --- a/source/games/duke/src/actors_r.cpp +++ b/source/games/duke/src/actors_r.cpp @@ -1346,10 +1346,8 @@ void move_r(DDukeActor *actor, int pnum, int xvel) return; } - auto moveptr = &ScriptCode[actor->temp_data[1]]; - - if (a & geth) actor->vel.X += (moveptr[0] / 16. - actor->vel.X) * 0.5; - if (a & getv) actor->vel.Z += (moveptr[1] / 16. - actor->vel.Z) * 0.5; + if (a & geth) actor->vel.X += (actor->GetMoveX() - actor->vel.X) * 0.5; + if (a & getv) actor->vel.Z += (actor->GetMoveZ() - actor->vel.Z) * 0.5; if (a & dodgebullet) dodge(actor); @@ -1422,7 +1420,7 @@ void move_r(DDukeActor *actor, int pnum, int xvel) } else if (!(actor->flags2 & SFLAG2_FLOATING)) { - if (!*(moveptr + 1)) + if (actor->GetMoveZ() == 0) { if (actor->opos.Z != actor->spr.pos.Z || (ud.multimode < 2 && ud.player_skill < 2)) { diff --git a/source/games/duke/src/inlines.h b/source/games/duke/src/inlines.h index c5c2dc59e..d9e638a28 100644 --- a/source/games/duke/src/inlines.h +++ b/source/games/duke/src/inlines.h @@ -314,6 +314,18 @@ inline void processinputvel(int snum) p->sync.svel = (float)velvect.Y; } +inline double DDukeActor::GetMoveX() const +{ + auto moveptr = &ScriptCode[temp_data[1]]; + return moveptr[0] / 16.; +} + +inline double DDukeActor::GetMoveZ() const +{ + auto moveptr = &ScriptCode[temp_data[1]]; + return moveptr[1] / 16.; +} + inline void setPlayerActorViewZOffset(DDukeActor* const pact) { if (!PlayClock) diff --git a/source/games/duke/src/types.h b/source/games/duke/src/types.h index b29202666..2f6576cf9 100644 --- a/source/games/duke/src/types.h +++ b/source/games/duke/src/types.h @@ -135,6 +135,10 @@ public: clipdist = spr.scale.X * tex->GetDisplayWidth() * 0.125; } + // Wrappers around CON data. + + double GetMoveX() const; + double GetMoveZ() const; }; // subclassed to add a game specific actor() method