From 99b9b01d6a09e34427a4e4ed2ca4f946de544c30 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 30 Jan 2022 18:33:11 +0100 Subject: [PATCH] - Duke: sixth batch of refactoring writes to spr.pos. --- source/games/duke/src/player_d.cpp | 39 +++++++++++------------------- source/games/duke/src/player_r.cpp | 26 +++++++++----------- 2 files changed, 25 insertions(+), 40 deletions(-) diff --git a/source/games/duke/src/player_d.cpp b/source/games/duke/src/player_d.cpp index ab009722f..5973d47e8 100644 --- a/source/games/duke/src/player_d.cpp +++ b/source/games/duke/src/player_d.cpp @@ -198,9 +198,7 @@ static void shootflamethrowerflame(DDukeActor* actor, int p, int sx, int sy, int spawned->spr.zvel = (short)zvel; } - spawned->spr.pos.X = sx + bsin(sa + 630) / 448; - spawned->spr.pos.Y = sy + bsin(sa + 112) / 448; - spawned->spr.pos.Z = sz - 256; + spawned->set_int_pos({ sx + bsin(sa + 630) / 448, sy + bsin(sa + 112) / 448, sz - 256 }); spawned->setsector(actor->sector()); spawned->spr.cstat = CSTAT_SPRITE_YCENTER; spawned->spr.ang = sa; @@ -214,8 +212,7 @@ static void shootflamethrowerflame(DDukeActor* actor, int p, int sx, int sy, int { if (actor->spr.picnum == BOSS5) { - spawned->spr.pos.X -= bsin(sa) / 56; - spawned->spr.pos.Y += bcos(sa) / 56; + spawned->add_int_pos({ -bsin(sa) / 56, bcos(sa) / 56, 0 }); spawned->spr.xrepeat = 10; spawned->spr.yrepeat = 10; } @@ -264,7 +261,7 @@ static void shootknee(DDukeActor* actor, int p, int sx, int sy, int sz, int sa) if (p >= 0) { auto k = spawn(knee, SMALLSMOKE); - if (k) k->spr.pos.Z -= (8 << 8); + if (k) k->add_int_z(-(8 << 8)); S_PlayActorSound(KICK_HIT, knee); } @@ -296,8 +293,7 @@ static void shootknee(DDukeActor* actor, int p, int sx, int sy, int sz, int sa) auto splash = spawn(ps[p].GetActor(), WATERSPLASH2); if (splash) { - splash->spr.pos.X = hit.hitpos.X; - splash->spr.pos.Y = hit.hitpos.Y; + splash->set_int_xy(hit.hitpos.X, hit.hitpos.Y); splash->spr.ang = ps[p].angle.ang.asbuild(); // Total tweek splash->spr.xvel = 32; ssp(actor, CLIPMASK0); @@ -443,7 +439,7 @@ static void shootweapon(DDukeActor *actor, int p, int sx, int sy, int sz, int sa auto jib = spawn(spark, JIBS6); if (jib) { - jib->spr.pos.Z += (4 << 8); + jib->add_int_z(4 << 8); jib->spr.xvel = 16; jib->spr.xrepeat = jib->spr.yrepeat = 24; jib->spr.ang += 64 - (krand() & 127); @@ -773,8 +769,7 @@ static void shootrpg(DDukeActor *actor, int p, int sx, int sy, int sz, int sa, i aoffs = int(aoffs * siz); } - spawned->spr.pos.X += xoffs; - spawned->spr.pos.Y += yoffs; + spawned->add_int_pos({ xoffs, yoffs, 0 }); spawned->spr.ang += aoffs; spawned->spr.xrepeat = 42; @@ -793,8 +788,7 @@ static void shootrpg(DDukeActor *actor, int p, int sx, int sy, int sz, int sa, i aoffs = Scale(aoffs, siz, 80); } - spawned->spr.pos.X -= xoffs; - spawned->spr.pos.Y -= yoffs; + spawned->add_int_pos({ -xoffs, -yoffs, 0 }); spawned->spr.ang -= aoffs; spawned->spr.xrepeat = 24; @@ -815,13 +809,11 @@ static void shootrpg(DDukeActor *actor, int p, int sx, int sy, int sz, int sa, i if (ps[p].hbomb_hold_delay) { - spawned->spr.pos.X -= bsin(sa) / 644; - spawned->spr.pos.Y += bcos(sa) / 644; + spawned->add_int_pos({ -bsin(sa) / 644, bcos(sa) / 644, 0 }); } else { - spawned->spr.pos.X += bsin(sa, -8); - spawned->spr.pos.Y -= bcos(sa, -8); + spawned->add_int_pos({ bsin(sa, -8), -bcos(sa, -8), 0 }); } spawned->spr.xrepeat >>= 1; spawned->spr.yrepeat >>= 1; @@ -1067,9 +1059,7 @@ void shoot_d(DDukeActor* actor, int atwith) if (k) { k->setsector(sect); - k->spr.pos.X = sx; - k->spr.pos.Y = sy; - k->spr.pos.Z = sz; + k->set_int_pos({ sx, sy, sz }); k->spr.ang = sa; k->spr.xvel = 500; k->spr.zvel = 0; @@ -2000,11 +1990,10 @@ static void underwater(int snum, ESyncBits actions, int fz, int cz) auto j = spawn(pact, WATERBUBBLE); if (j) { - j->spr.pos.X += bcos(p->angle.ang.asbuild() + 64 - (global_random & 128), -6); - j->spr.pos.Y += bsin(p->angle.ang.asbuild() + 64 - (global_random & 128), -6); + j->add_int_pos({ bcos(p->angle.ang.asbuild() + 64 - (global_random & 128), -6), bsin(p->angle.ang.asbuild() + 64 - (global_random & 128), -6), 0 }); j->spr.xrepeat = 3; j->spr.yrepeat = 2; - j->spr.pos.Z = p->pos.Z + (8 << 8); + j->set_int_z(p->pos.Z + (8 << 8)); } } } @@ -2223,7 +2212,7 @@ static void operateweapon(int snum, ESyncBits actions) if (k == 15) { spawned->spr.yvel = 3; - spawned->spr.pos.Z += (8 << 8); + spawned->add_int_z(8 << 8); } k = hits(pact); @@ -2388,7 +2377,7 @@ static void operateweapon(int snum, ESyncBits actions) j->spr.ang += 1024; j->spr.ang &= 2047; j->spr.xvel += 32; - j->spr.pos.Z += (3 << 8); + j->add_int_z(3 << 8); ssp(j, CLIPMASK0); } } diff --git a/source/games/duke/src/player_r.cpp b/source/games/duke/src/player_r.cpp index a4a299053..09aeb1612 100644 --- a/source/games/duke/src/player_r.cpp +++ b/source/games/duke/src/player_r.cpp @@ -153,7 +153,7 @@ static void shootmelee(DDukeActor *actor, int p, int sx, int sy, int sz, int sa, if (p >= 0) { auto k = spawn(wpn, SMALLSMOKE); - if (k) k->spr.pos.Z -= (8 << 8); + if (k) k->add_int_z(-(8 << 8)); if (atwith == KNEE) S_PlayActorSound(KICK_HIT, wpn); else if (isRRRA() && atwith == SLINGBLADE) S_PlayActorSound(260, wpn); } @@ -185,8 +185,7 @@ static void shootmelee(DDukeActor *actor, int p, int sx, int sy, int sz, int sa, auto splash = spawn(ps[p].GetActor(), WATERSPLASH2); if (splash) { - splash->spr.pos.X = hit.hitpos.X; - splash->spr.pos.Y = hit.hitpos.Y; + splash->set_int_xy(hit.hitpos.X, hit.hitpos.Y); splash->spr.ang = ps[p].angle.ang.asbuild(); // Total tweek splash->spr.xvel = 32; ssp(actor, 0); @@ -335,7 +334,7 @@ static void shootweapon(DDukeActor* actor, int p, int sx, int sy, int sz, int sa spark->spr.xrepeat = spark->spr.yrepeat = 0; if (l) { - l->spr.pos.Z += (4 << 8); + l->add_int_z(4 << 8); l->spr.xvel = 16; l->spr.xrepeat = l->spr.yrepeat = 24; l->spr.ang += 64 - (krand() & 127); @@ -723,13 +722,11 @@ static void shootrpg(DDukeActor* actor, int p, int sx, int sy, int sz, int sa, i if (ps[p].hbomb_hold_delay) { - spawned->spr.pos.X -= bsin(sa) / 644; - spawned->spr.pos.Y += bcos(sa) / 644; + spawned->add_int_pos({ -bsin(sa) / 644, bcos(sa) / 644, 0 }); } else { - spawned->spr.pos.X += bsin(sa, -8); - spawned->spr.pos.Y -= bcos(sa, -8); + spawned->add_int_pos({ bsin(sa, -8), -bcos(sa, -8), 0 }); } spawned->spr.xrepeat >>= 1; spawned->spr.yrepeat >>= 1; @@ -898,7 +895,7 @@ void shoot_r(DDukeActor* actor, int atwith) { j->spr.xvel = 32; j->spr.ang = actor->spr.ang; - j->spr.pos.Z -= (5 << 8); + j->add_int_z(-(5 << 8)); } break; } @@ -909,7 +906,7 @@ void shoot_r(DDukeActor* actor, int atwith) { j->spr.xvel = 250; j->spr.ang = actor->spr.ang; - j->spr.pos.Z -= (15 << 8); + j->add_int_z(-(15 << 8)); } break; } @@ -2353,11 +2350,10 @@ static void underwater(int snum, ESyncBits actions, int fz, int cz) auto j = spawn(pact, WATERBUBBLE); if (j) { - j->spr.pos.X += bcos(p->angle.ang.asbuild() + 64 - (global_random & 128) + 128, -6); - j->spr.pos.Y += bsin(p->angle.ang.asbuild() + 64 - (global_random & 128) + 128, -6); + j->add_int_pos({ bcos(p->angle.ang.asbuild() + 64 - (global_random & 128) + 128, -6), bsin(p->angle.ang.asbuild() + 64 - (global_random & 128) + 128, -6), 0 }); j->spr.xrepeat = 3; j->spr.yrepeat = 2; - j->spr.pos.Z = p->pos.Z + (8 << 8); + j->set_int_z(p->pos.Z + (8 << 8)); j->spr.cstat = CSTAT_SPRITE_TRANS_FLIP | CSTAT_SPRITE_TRANSLUCENT; } } @@ -2759,7 +2755,7 @@ static void operateweapon(int snum, ESyncBits actions, sectortype* psectp) if (k == 15) { spawned->spr.yvel = 3; - spawned->spr.pos.Z += (8 << 8); + spawned->add_int_z(8 << 8); } k = hits(p->GetActor()); @@ -2984,7 +2980,7 @@ static void operateweapon(int snum, ESyncBits actions, sectortype* psectp) j->spr.ang += 1024; j->spr.ang &= 2047; j->spr.xvel += 32; - j->spr.pos.Z += (3 << 8); + j->add_int_z(3 << 8); ssp(j, CLIPMASK0); } }