diff --git a/source/games/duke/src/actors.cpp b/source/games/duke/src/actors.cpp index 32d561688..bc122c122 100644 --- a/source/games/duke/src/actors.cpp +++ b/source/games/duke/src/actors.cpp @@ -5230,15 +5230,16 @@ void movefta(void) { if (badguy(act)) { - double px = ps[p].opos.X - xyrand(64); - double py = ps[p].opos.Y - xyrand(64); + auto xyrand = []() -> double { return (64 - (krand() & 127)) * maptoworld; }; + double px = ps[p].opos.X - xyrand(); + double py = ps[p].opos.Y - xyrand(); updatesector(DVector3(px, py, 0), &psect); if (psect == nullptr) { continue; } - double sx = act->spr.pos.X - xyrand(64); - double sy = act->spr.pos.Y - xyrand(64); + double sx = act->spr.pos.X - xyrand(); + double sy = act->spr.pos.Y - xyrand(); // The second updatesector call here used px and py again and was redundant as coded. // SFLAG_MOVEFTA_CHECKSEE is set for all actors in Duke. diff --git a/source/games/duke/src/funct.h b/source/games/duke/src/funct.h index b7b752f62..abf1c48e3 100644 --- a/source/games/duke/src/funct.h +++ b/source/games/duke/src/funct.h @@ -251,9 +251,4 @@ inline double zrand(int spread) return r * zmaptoworld; } -inline double xyrand(int mask) -{ - return ((krand() % mask) - (mask << 1) - 1) * maptoworld; -} - END_DUKE_NS