diff --git a/source/build/include/build.h b/source/build/include/build.h index 9ff83de6c..d1723f35f 100644 --- a/source/build/include/build.h +++ b/source/build/include/build.h @@ -454,6 +454,10 @@ inline int32_t ksqrt(uint64_t num) } int32_t getangle(int32_t xvect, int32_t yvect); +inline int32_t getangle(const vec2_t& vec) +{ + return getangle(vec.x, vec.y); +} inline constexpr uint32_t uhypsq(int32_t const dx, int32_t const dy) { diff --git a/source/games/duke/src/actors.cpp b/source/games/duke/src/actors.cpp index 2a4534a2f..020449590 100644 --- a/source/games/duke/src/actors.cpp +++ b/source/games/duke/src/actors.cpp @@ -1299,8 +1299,7 @@ void bounce(DDukeActor* actor) auto sectp = s->sector(); - auto delta = sectp->firstWall()->delta(); - int daang = getangle(delta.x, delta.y); + int daang = getangle(sectp->firstWall()->delta()); int k, l; if (s->z < (actor->floorz + actor->ceilingz) >> 1) @@ -1513,8 +1512,7 @@ bool queball(DDukeActor *actor, int pocket, int queball, int stripeball) if (j == kHitWall) { - auto delta = coll.wall()->delta(); - int k = getangle(delta.x, delta.y); + int k = getangle(coll.wall()->delta()); s->ang = ((k << 1) - s->ang) & 2047; } else if (j == kHitSprite) diff --git a/source/games/duke/src/actors_d.cpp b/source/games/duke/src/actors_d.cpp index c68db427d..a8576e842 100644 --- a/source/games/duke/src/actors_d.cpp +++ b/source/games/duke/src/actors_d.cpp @@ -1657,8 +1657,7 @@ static bool weaponhitwall(DDukeActor *proj, walltype* wal, const vec3_t &oldpos) (!isWorldTour() || s->picnum != FIREBALL) && (wal->overpicnum == MIRROR || wal->picnum == MIRROR)) { - auto delta = wal->delta(); - int k = getangle(delta.x, delta.y); + int k = getangle(wal->delta()); s->ang = ((k << 1) - s->ang) & 2047; proj->SetOwner(proj); spawn(proj, TRANSPORTERSTAR); @@ -1677,8 +1676,7 @@ static bool weaponhitwall(DDukeActor *proj, walltype* wal, const vec3_t &oldpos) s->yvel--; } - auto delta = wal->delta(); - int k = getangle(delta.x, delta.y); + int k = getangle(wal->delta()); s->ang = ((k << 1) - s->ang) & 2047; return true; } @@ -2917,8 +2915,7 @@ static void heavyhbomb(DDukeActor *actor) auto wal = coll.wall(); fi.checkhitwall(actor, wal, s->x, s->y, s->z, s->picnum); - auto delta = wal->delta(); - int k = getangle(delta.x, delta.y); + int k = getangle(wal->delta()); s->ang = ((k << 1) - s->ang) & 2047; s->xvel >>= 1; diff --git a/source/games/duke/src/actors_r.cpp b/source/games/duke/src/actors_r.cpp index e9c09ac2d..c3d7e088f 100644 --- a/source/games/duke/src/actors_r.cpp +++ b/source/games/duke/src/actors_r.cpp @@ -1215,8 +1215,7 @@ static bool weaponhitwall(DDukeActor *proj, walltype* wal, const vec3_t& oldpos) if (s->picnum != RPG && (!isRRRA() || s->picnum != RPG2) && s->picnum != FREEZEBLAST && s->picnum != SPIT && s->picnum != SHRINKSPARK && (wal->overpicnum == MIRROR || wal->picnum == MIRROR)) { - auto delta = wal->delta(); - int k = getangle(delta.x, delta.y); + int k = getangle(wal->delta()); s->ang = ((k << 1) - s->ang) & 2047; proj->SetOwner(proj); spawn(proj, TRANSPORTERSTAR); @@ -1239,8 +1238,7 @@ static bool weaponhitwall(DDukeActor *proj, walltype* wal, const vec3_t& oldpos) s->yvel--; } - auto delta = wal->delta(); - int k = getangle(delta.x, delta.y); + int k = getangle(wal->delta()); s->ang = ((k << 1) - s->ang) & 2047; return true; } @@ -1276,8 +1274,7 @@ static bool weaponhitwall(DDukeActor *proj, walltype* wal, const vec3_t& oldpos) s->yvel--; } - auto delta = wal->delta(); - int k = getangle(delta.x, delta.y); + int k = getangle(wal->delta()); s->ang = ((k << 1) - s->ang) & 2047; return true; } @@ -2625,8 +2622,7 @@ static void heavyhbomb(DDukeActor *actor) auto wal = coll.wall(); fi.checkhitwall(actor, wal, s->x, s->y, s->z, s->picnum); - auto delta = wal->delta(); - int k = getangle(delta.x, delta.y); + int k = getangle(wal->delta()); if (s->picnum == CHEERBOMB) { @@ -2768,9 +2764,7 @@ static int henstand(DDukeActor *actor) { if (coll.type == kHitWall) { - auto wal = coll.wall(); - auto delta = wal->delta(); - int k = getangle(delta.x, delta.y); + int k = getangle(coll.wall()->delta()); s->ang = ((k << 1) - s->ang) & 2047; } else if (coll.type == kHitSprite) diff --git a/source/games/duke/src/player_r.cpp b/source/games/duke/src/player_r.cpp index 1427ce44a..a83a0e84c 100644 --- a/source/games/duke/src/player_r.cpp +++ b/source/games/duke/src/player_r.cpp @@ -2388,8 +2388,7 @@ void onMotorcycleMove(int snum, walltype* wal) auto p = &ps[snum]; auto pact = p->GetActor(); auto s = pact->s; - auto delta = wal->delta(); - int angleDelta = abs(p->angle.ang.asbuild() - getangle(delta.x, delta.y)); + int angleDelta = abs(p->angle.ang.asbuild() - getangle(wal->delta())); int damageAmount; p->angle.addadjustment(p->MotoSpeed / (krand() & 1 ? -2 : 2)); @@ -2444,7 +2443,7 @@ void onBoatMove(int snum, int psectlotag, walltype* wal) auto p = &ps[snum]; auto pact = p->GetActor(); auto delta = wal->delta(); - int angleDelta = abs(p->angle.ang.asbuild() - getangle(delta.x, delta.y)); + int angleDelta = abs(p->angle.ang.asbuild() - getangle(wal->delta())); p->angle.addadjustment(p->MotoSpeed / (krand() & 1 ? -4 : 4));