- Duke: getangle simplification

This commit is contained in:
Christoph Oelckers 2021-11-24 16:34:21 +01:00
parent 5d78b228b7
commit 33c707c708
5 changed files with 16 additions and 24 deletions

View file

@ -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)
{

View file

@ -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)

View file

@ -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;

View file

@ -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)

View file

@ -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));