- buildutils: Replace `sintable[]` use within Duke's actors_r.cpp with `bsin()`/`bcos()`.

This commit is contained in:
Mitchell Richters 2020-11-15 18:08:44 +11:00 committed by Christoph Oelckers
parent abc49fed62
commit b6e8030307
1 changed files with 41 additions and 45 deletions

View File

@ -565,7 +565,7 @@ void movefta_r(void)
(isRRRA() && (isIn(s->picnum, COOT, COOTSTAYPUT, BIKER, BIKERB, BIKERBV2, CHEER, CHEERB, (isRRRA() && (isIn(s->picnum, COOT, COOTSTAYPUT, BIKER, BIKERB, BIKERBV2, CHEER, CHEERB,
CHEERSTAYPUT, MINIONBOAT, HULKBOAT, CHEERBOAT, RABBIT, COOTPLAY, BILLYPLAY, MAKEOUT, MAMA) CHEERSTAYPUT, MINIONBOAT, HULKBOAT, CHEERBOAT, RABBIT, COOTPLAY, BILLYPLAY, MAKEOUT, MAMA)
|| (s->picnum == MINION && s->pal == 8))) || (s->picnum == MINION && s->pal == 8)))
|| (sintable[(s->ang + 512) & 2047] * (px - sx) + sintable[s->ang & 2047] * (py - sy) >= 0)) || (bcos(s->ang) * (px - sx) + bsin(s->ang) * (py - sy) >= 0))
{ {
int r1 = krand(); int r1 = krand();
int r2 = krand(); int r2 = krand();
@ -708,16 +708,12 @@ int ifhitbyweapon_r(DDukeActor *actor)
case EXPLODINGBARREL: case EXPLODINGBARREL:
case TRIPBOMBSPRITE: case TRIPBOMBSPRITE:
case RPG2: case RPG2:
ps[p].posxv += ps[p].posxv += actor->extra * bcos(actor->ang, 2);
actor->extra * (sintable[(actor->ang + 512) & 2047]) << 2; ps[p].posyv += actor->extra * bsin(actor->ang, 2);
ps[p].posyv +=
actor->extra * (sintable[actor->ang & 2047]) << 2;
break; break;
default: default:
ps[p].posxv += ps[p].posxv += actor->extra * bcos(actor->ang, 1);
actor->extra * (sintable[(actor->ang + 512) & 2047]) << 1; ps[p].posyv += actor->extra * bsin(actor->ang, 1);
ps[p].posyv +=
actor->extra * (sintable[actor->ang & 2047]) << 1;
break; break;
} }
} }
@ -1277,8 +1273,8 @@ static bool weaponhitwall(DDukeActor *proj, int wal, const vec3_t& oldpos)
} }
if (s->extra <= 0) if (s->extra <= 0)
{ {
s->x += sintable[(s->ang + 512) & 2047] >> 7; s->x += bcos(s->ang, -7);
s->y += sintable[s->ang & 2047] >> 7; s->y += bsin(s->ang, -7);
auto Owner = proj->GetOwner(); auto Owner = proj->GetOwner();
if (!isRRRA() || !Owner || (Owner->s.picnum != CHEER && Owner->s.picnum != CHEERSTAYPUT)) if (!isRRRA() || !Owner || (Owner->s.picnum != CHEER && Owner->s.picnum != CHEERSTAYPUT))
{ {
@ -1419,8 +1415,8 @@ static void weaponcommon_r(DDukeActor *proj)
Collision coll; Collision coll;
movesprite_ex(proj, movesprite_ex(proj,
(k * (sintable[(s->ang + 512) & 2047])) >> 14, mulscale14(k, bcos(s->ang)),
(k * (sintable[s->ang & 2047])) >> 14, ll, CLIPMASK1, coll); mulscale14(k, bsin(s->ang)), ll, CLIPMASK1, coll);
if ((s->picnum == RPG || (isRRRA() && isIn(s->picnum, RPG2, RRTILE1790))) && proj->temp_actor != nullptr) if ((s->picnum == RPG || (isRRRA() && isIn(s->picnum, RPG2, RRTILE1790))) && proj->temp_actor != nullptr)
if (FindDistance2D(s->x - proj->temp_actor->s.x, s->y - proj->temp_actor->s.y) < 256) if (FindDistance2D(s->x - proj->temp_actor->s.x, s->y - proj->temp_actor->s.y) < 256)
@ -1453,8 +1449,8 @@ static void weaponcommon_r(DDukeActor *proj)
for (k = -3; k < 2; k++) for (k = -3; k < 2; k++)
{ {
auto x = EGS(s->sectnum, auto x = EGS(s->sectnum,
s->x + ((k * sintable[(s->ang + 512) & 2047]) >> 9), s->x + mulscale9(k, bcos(s->ang)),
s->y + ((k * sintable[s->ang & 2047]) >> 9), s->y + mulscale9(k, bsin(s->ang)),
s->z + ((k * ksgn(s->zvel)) * abs(s->zvel / 24)), FIRELASER, -40 + (k << 2), s->z + ((k * ksgn(s->zvel)) * abs(s->zvel / 24)), FIRELASER, -40 + (k << 2),
s->xrepeat, s->yrepeat, 0, 0, 0, proj->GetOwner(), 5); s->xrepeat, s->yrepeat, 0, 0, 0, proj->GetOwner(), 5);
@ -1928,8 +1924,8 @@ void movetransports_r(void)
changespritesect(act2, Owner->s.sectnum); changespritesect(act2, Owner->s.sectnum);
movesprite_ex(act2, (spr2->xvel * sintable[(spr2->ang + 512) & 2047]) >> 14, movesprite_ex(act2, mulscale14(spr2->xvel, bcos(spr2->ang)),
(spr2->xvel * sintable[spr2->ang & 2047]) >> 14, 0, CLIPMASK1, coll); mulscale14(spr2->xvel, bsin(spr2->ang)), 0, CLIPMASK1, coll);
break; break;
case 161: case 161:
@ -1944,8 +1940,8 @@ void movetransports_r(void)
changespritesect(act2, Owner->s.sectnum); changespritesect(act2, Owner->s.sectnum);
movesprite_ex(act2, (spr2->xvel * sintable[(spr2->ang + 512) & 2047]) >> 14, movesprite_ex(act2, mulscale14(spr2->xvel, bcos(spr2->ang)),
(spr2->xvel * sintable[spr2->ang & 2047]) >> 14, 0, CLIPMASK1, coll); mulscale14(spr2->xvel, bsin(spr2->ang)), 0, CLIPMASK1, coll);
break; break;
} }
@ -2155,8 +2151,8 @@ static void rrra_specialstats()
S_PlaySound(183); S_PlaySound(183);
s->extra--; s->extra--;
int j = movesprite_ex(act, int j = movesprite_ex(act,
(s->hitag * sintable[(s->ang + 512) & 2047]) >> 14, mulscale14(s->hitag, bcos(s->ang)),
(s->hitag * sintable[s->ang & 2047]) >> 14, mulscale14(s->hitag, bsin(s->ang)),
s->hitag << 1, CLIPMASK0, coll); s->hitag << 1, CLIPMASK0, coll);
if (j > 0) if (j > 0)
{ {
@ -2595,8 +2591,8 @@ static void heavyhbomb(DDukeActor *actor)
Collision coll; Collision coll;
movesprite_ex(actor, movesprite_ex(actor,
(s->xvel * (sintable[(s->ang + 512) & 2047])) >> 14, mulscale14(s->xvel, bcos(s->ang)),
(s->xvel * (sintable[s->ang & 2047])) >> 14, mulscale14(s->xvel, bsin(s->ang)),
s->zvel, CLIPMASK0, coll); s->zvel, CLIPMASK0, coll);
if (sector[s->sectnum].lotag == 1 && s->zvel == 0) if (sector[s->sectnum].lotag == 1 && s->zvel == 0)
@ -2789,8 +2785,8 @@ static int henstand(DDukeActor *actor)
makeitfall(actor); makeitfall(actor);
Collision coll; Collision coll;
movesprite_ex(actor, movesprite_ex(actor,
(sintable[(s->ang + 512) & 2047] * s->xvel) >> 14, mulscale14(bcos(s->ang), s->xvel),
(sintable[s->ang & 2047] * s->xvel) >> 14, mulscale14(bsin(s->ang), s->xvel),
s->zvel, CLIPMASK0, coll); s->zvel, CLIPMASK0, coll);
if (coll.type) if (coll.type)
{ {
@ -2912,8 +2908,8 @@ void moveactors_r(void)
if (sector[sect].lotag == 903) if (sector[sect].lotag == 903)
makeitfall(act); makeitfall(act);
movesprite_ex(act, movesprite_ex(act,
(s->xvel*sintable[(s->ang+512)&2047])>>14, mulscale14(s->xvel, bcos(s->ang)),
(s->xvel*sintable[s->ang&2047])>>14, mulscale14(s->xvel, bsin(s->ang)),
s->zvel,CLIPMASK0, coll); s->zvel,CLIPMASK0, coll);
switch (sector[sect].lotag) switch (sector[sect].lotag)
{ {
@ -2953,8 +2949,8 @@ void moveactors_r(void)
} }
makeitfall(act); makeitfall(act);
movesprite_ex(act, movesprite_ex(act,
(s->xvel*(sintable[(s->ang+512)&2047]))>>14, mulscale14(s->xvel, bcos(s->ang)),
(s->xvel*(sintable[s->ang&2047]))>>14, mulscale14(s->xvel, bsin(s->ang)),
s->zvel,CLIPMASK0, coll); s->zvel,CLIPMASK0, coll);
if (coll.type > kHitSector) if (coll.type > kHitSector)
{ {
@ -2984,8 +2980,8 @@ void moveactors_r(void)
} }
makeitfall(act); makeitfall(act);
movesprite_ex(act, movesprite_ex(act,
(s->xvel*sintable[(s->ang+512)&2047])>>14, mulscale14(s->xvel, bcos(s->ang)),
(s->xvel*sintable[s->ang&2047])>>14, mulscale14(s->xvel, bsin(s->ang)),
s->zvel,CLIPMASK0, coll); s->zvel,CLIPMASK0, coll);
if (s->z >= sector[sect].floorz - (8<<8)) if (s->z >= sector[sect].floorz - (8<<8))
{ {
@ -3083,8 +3079,8 @@ void moveactors_r(void)
if (s->xvel) if (s->xvel)
{ {
movesprite_ex(act, movesprite_ex(act,
(s->xvel*sintable[(s->ang+512)&2047])>>14, mulscale14(s->xvel, bcos(s->ang)),
(s->xvel*sintable[s->ang&2047])>>14, mulscale14(s->xvel, bsin(s->ang)),
s->zvel,CLIPMASK0, coll); s->zvel,CLIPMASK0, coll);
s->xvel--; s->xvel--;
} }
@ -3633,7 +3629,7 @@ void moveeffectors_r(void) //STATNUM 3
case 29: case 29:
act->s.hitag += 64; act->s.hitag += 64;
l = mulscale12((int)act->s.yvel, sintable[act->s.hitag & 2047]); l = mulscale12(act->s.yvel, bsin(act->s.hitag));
sc->floorz = act->s.z + l; sc->floorz = act->s.z + l;
break; break;
@ -3734,7 +3730,7 @@ void move_r(DDukeActor *actor, int pnum, int xvel)
} }
if (a & spin) if (a & spin)
spr->ang += sintable[((t[0] << 3) & 2047)] >> 6; spr->ang += bsin(t[0] << 3, -6);
if (a & face_player_slow) if (a & face_player_slow)
{ {
@ -3771,12 +3767,12 @@ void move_r(DDukeActor *actor, int pnum, int xvel)
if (spr->picnum == CHEER) if (spr->picnum == CHEER)
{ {
if (t[0] < 16) if (t[0] < 16)
spr->zvel -= (sintable[(512 + (t[0] << 4)) & 2047] / 40); spr->zvel -= bcos(t[0] << 4) / 40;
} }
else else
{ {
if (t[0] < 16) if (t[0] < 16)
spr->zvel -= (sintable[(512 + (t[0] << 4)) & 2047] >> 5); spr->zvel -= bcos(t[0] << 4, -5);
} }
} }
if (a & justjump1) if (a & justjump1)
@ -3784,12 +3780,12 @@ void move_r(DDukeActor *actor, int pnum, int xvel)
if (spr->picnum == RABBIT) if (spr->picnum == RABBIT)
{ {
if (t[0] < 8) if (t[0] < 8)
spr->zvel -= (sintable[(512 + (t[0] << 4)) & 2047] / 30); spr->zvel -= bcos(t[0] << 4) / 30;
} }
else if (spr->picnum == MAMA) else if (spr->picnum == MAMA)
{ {
if (t[0] < 8) if (t[0] < 8)
spr->zvel -= (sintable[(512 + (t[0] << 4)) & 2047] / 35); spr->zvel -= bcos(t[0] << 4) / 35;
} }
} }
if (a & justjump2) if (a & justjump2)
@ -3797,24 +3793,24 @@ void move_r(DDukeActor *actor, int pnum, int xvel)
if (spr->picnum == RABBIT) if (spr->picnum == RABBIT)
{ {
if (t[0] < 8) if (t[0] < 8)
spr->zvel -= (sintable[(512 + (t[0] << 4)) & 2047] / 24); spr->zvel -= bcos(t[0] << 4) / 24;
} }
else if (spr->picnum == MAMA) else if (spr->picnum == MAMA)
{ {
if (t[0] < 8) if (t[0] < 8)
spr->zvel -= (sintable[(512 + (t[0] << 4)) & 2047] / 28); spr->zvel -= bcos(t[0] << 4) / 28;
} }
} }
if (a & windang) if (a & windang)
{ {
if (t[0] < 8) if (t[0] < 8)
spr->zvel -= (sintable[(512 + (t[0] << 4)) & 2047] / 24); spr->zvel -= bcos(t[0] << 4) / 24;
} }
} }
else if ((a & jumptoplayer) == jumptoplayer) else if ((a & jumptoplayer) == jumptoplayer)
{ {
if (t[0] < 16) if (t[0] < 16)
spr->zvel -= (sintable[(512 + (t[0] << 4)) & 2047] >> 5); spr->zvel -= bcos(t[0] << 4, -5);
} }
@ -3986,8 +3982,8 @@ void move_r(DDukeActor *actor, int pnum, int xvel)
Collision coll; Collision coll;
actor->movflag = movesprite_ex(actor, actor->movflag = movesprite_ex(actor,
(daxvel * (sintable[(angdif + 512) & 2047])) >> 14, mulscale14(daxvel, bcos(angdif)),
(daxvel * (sintable[angdif & 2047])) >> 14, spr->zvel, CLIPMASK0, coll); mulscale14(daxvel, bsin(angdif)), spr->zvel, CLIPMASK0, coll);
} }
if (a) if (a)