From 9bf94cbc1ce06ff162e2e5b2b89ddbfe37272639 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 31 Jan 2022 00:02:46 +0100 Subject: [PATCH] - Duke: eighth batch --- source/games/duke/src/gameexec.cpp | 18 ++++++++---------- source/games/duke/src/player.cpp | 6 ++---- source/games/duke/src/sectors.cpp | 8 ++++---- source/games/duke/src/spawn.cpp | 30 ++++++++++++------------------ 4 files changed, 26 insertions(+), 36 deletions(-) diff --git a/source/games/duke/src/gameexec.cpp b/source/games/duke/src/gameexec.cpp index b141a2b00..6618f5357 100644 --- a/source/games/duke/src/gameexec.cpp +++ b/source/games/duke/src/gameexec.cpp @@ -1172,16 +1172,16 @@ void DoActor(bool bSet, int lVar1, int lLabelID, int lVar2, DDukeActor* sActor, switch (lLabelID) { case ACTOR_X: - if (bSet) act->spr.pos.X = lValue; - else SetGameVarID(lVar2, act->spr.pos.X, sActor, sPlayer); + /*if (bSet) act->spr.pos.X = lValue; + else*/ SetGameVarID(lVar2, act->spr.pos.X, sActor, sPlayer); break; case ACTOR_Y: - if (bSet) act->spr.pos.Y = lValue; - else SetGameVarID(lVar2, act->spr.pos.Y, sActor, sPlayer); + /*if (bSet) act->spr.pos.Y = lValue; + else*/ SetGameVarID(lVar2, act->spr.pos.Y, sActor, sPlayer); break; case ACTOR_Z: - if (bSet) act->spr.pos.Z = lValue; - else SetGameVarID(lVar2, act->spr.pos.Z, sActor, sPlayer); + /*if (bSet) act->spr.pos.Z = lValue; + else*/ SetGameVarID(lVar2, act->spr.pos.Z, sActor, sPlayer); break; case ACTOR_CSTAT: if (bSet) act->spr.cstat = ESpriteFlags::FromInt(lValue); @@ -1994,7 +1994,7 @@ int ParseState::parse(void) case concmd_larrybird: insptr++; ps[g_p].pos.Z = ps[g_p].GetActor()->sector()->ceilingz; - ps[g_p].GetActor()->spr.pos.Z = ps[g_p].pos.Z; + ps[g_p].GetActor()->set_int_z(ps[g_p].pos.Z); break; case concmd_destroyit: insptr++; @@ -2238,9 +2238,7 @@ int ParseState::parse(void) { // I am not convinced this is even remotely smart to be executed from here.. pickrandomspot(g_p); - g_ac->spr.pos.X = ps[g_p].bobpos.X = ps[g_p].opos.X = ps[g_p].pos.X; - g_ac->spr.pos.Y = ps[g_p].bobpos.Y = ps[g_p].opos.Y = ps[g_p].pos.Y; - g_ac->spr.pos.Z = ps[g_p].opos.Z = ps[g_p].pos.Z; + g_ac->set_int_pos({ ps[g_p].bobpos.X = ps[g_p].opos.X = ps[g_p].pos.X, ps[g_p].bobpos.Y = ps[g_p].opos.Y = ps[g_p].pos.Y, ps[g_p].opos.Z = ps[g_p].pos.Z }); g_ac->backuppos(); updatesector(ps[g_p].pos.X, ps[g_p].pos.Y, &ps[g_p].cursector); SetActor(ps[g_p].GetActor(), { ps[g_p].pos.X, ps[g_p].pos.Y, ps[g_p].pos.Z + gs.playerheight }); diff --git a/source/games/duke/src/player.cpp b/source/games/duke/src/player.cpp index c38b341ed..331b5aa35 100644 --- a/source/games/duke/src/player.cpp +++ b/source/games/duke/src/player.cpp @@ -611,7 +611,7 @@ void playerisdead(int snum, int psectlotag, int fz, int cz) } else { - actor->spr.pos.Z -= 512; + actor->add_int_z(-512); actor->spr.zvel = -348; } @@ -1054,9 +1054,7 @@ void shootbloodsplat(DDukeActor* actor, int p, int sx, int sy, int sz, int sa, i spawned->spr.xvel = -12; auto delta = hit.hitWall->delta(); spawned->spr.ang = getangle(-delta.X, -delta.Y) + 512; // note the '-' sign here! - spawned->spr.pos.X = hit.hitpos.X; - spawned->spr.pos.Y = hit.hitpos.Y; - spawned->spr.pos.Z = hit.hitpos.Z; + spawned->set_int_pos(hit.hitpos); spawned->spr.cstat |= randomXFlip(); ssp(spawned, CLIPMASK0); SetActor(spawned, spawned->spr.pos); diff --git a/source/games/duke/src/sectors.cpp b/source/games/duke/src/sectors.cpp index 54459f449..b77dc53c1 100644 --- a/source/games/duke/src/sectors.cpp +++ b/source/games/duke/src/sectors.cpp @@ -216,11 +216,11 @@ int findplayer(const DDukeActor* actor, int* d) { int j, closest_player; int x, closest; - auto s = &actor->spr.pos; + const auto s = actor->spr.pos; if (ud.multimode < 2) { - if (d) *d = abs(ps[myconnectindex].opos.X - s->X) + abs(ps[myconnectindex].opos.Y - s->Y) + ((abs(ps[myconnectindex].opos.Z - s->Z + (28 << 8))) >> 4); + if (d) *d = abs(ps[myconnectindex].opos.X - s.X) + abs(ps[myconnectindex].opos.Y - s.Y) + ((abs(ps[myconnectindex].opos.Z - s.Z + (28 << 8))) >> 4); return myconnectindex; } @@ -229,7 +229,7 @@ int findplayer(const DDukeActor* actor, int* d) for (j = connecthead; j >= 0; j = connectpoint2[j]) { - x = abs(ps[j].opos.X - s->X) + abs(ps[j].opos.Y - s->Y) + ((abs(ps[j].opos.Z - s->Z + (28 << 8))) >> 4); + x = abs(ps[j].opos.X - s.X) + abs(ps[j].opos.Y - s.Y) + ((abs(ps[j].opos.Z - s.Z + (28 << 8))) >> 4); if (x < closest && ps[j].GetActor()->spr.extra > 0) { closest_player = j; @@ -394,7 +394,7 @@ void doanimations(void) if (act->spr.statnum != STAT_EFFECTOR) { act->backupz(); - act->spr.pos.Z += v; + act->add_int_z(v); act->floorz = dasectp->floorz + v; } } diff --git a/source/games/duke/src/spawn.cpp b/source/games/duke/src/spawn.cpp index b376d430d..086858a1d 100644 --- a/source/games/duke/src/spawn.cpp +++ b/source/games/duke/src/spawn.cpp @@ -59,9 +59,7 @@ DDukeActor* EGS(sectortype* whatsectp, int s_x, int s_y, int s_z, int s_pn, int8 SetupGameVarsForActor(act); - act->spr.pos.X = s_x; - act->spr.pos.Y = s_y; - act->spr.pos.Z = s_z; + act->set_int_pos({ s_x, s_y, s_z }); act->spr.cstat = 0; act->spr.picnum = s_pn; act->spr.shade = s_s; @@ -303,7 +301,7 @@ void spawntransporter(DDukeActor *actj, DDukeActor* act, bool beam) { act->spr.xrepeat = 31; act->spr.yrepeat = 1; - act->spr.pos.Z = actj->sector()->floorz - (isRR() ? PHEIGHT_RR : PHEIGHT_DUKE); + act->set_int_z(actj->sector()->floorz - (isRR() ? PHEIGHT_RR : PHEIGHT_DUKE)); } else { @@ -409,7 +407,7 @@ void initfootprint(DDukeActor* actj, DDukeActor* act) act->spr.ang = actj->spr.ang; } - act->spr.pos.Z = sect->floorz; + act->set_int_z(sect->floorz); if (sect->lotag != 1 && sect->lotag != 2) act->spr.xrepeat = act->spr.yrepeat = 32; @@ -435,17 +433,16 @@ void initshell(DDukeActor* actj, DDukeActor* act, bool isshell) a = ps[snum].angle.ang.asbuild() - (krand() & 63) + 8; //Fine tune act->temp_data[0] = krand() & 1; - act->spr.pos.Z = (3 << 8) + ps[snum].pyoff + ps[snum].pos.Z - (ps[snum].horizon.sum().asq16() >> 12) + (!isshell ? (3 << 8) : 0); + act->set_int_z((3 << 8) + ps[snum].pyoff + ps[snum].pos.Z - (ps[snum].horizon.sum().asq16() >> 12) + (!isshell ? (3 << 8) : 0)); act->spr.zvel = -(krand() & 255); } else { a = act->spr.ang; - act->spr.pos.Z = actj->spr.pos.Z - gs.playerheight + (3 << 8); + act->set_int_z(actj->spr.pos.Z - gs.playerheight + (3 << 8)); } - act->spr.pos.X = actj->spr.pos.X + bcos(a, -7); - act->spr.pos.Y = actj->spr.pos.Y + bsin(a, -7); + act->set_int_xy(actj->spr.pos.X + bcos(a, -7), actj->spr.pos.Y + bsin(a, -7)); act->spr.shade = -8; @@ -479,13 +476,11 @@ void initcrane(DDukeActor* actj, DDukeActor* act, int CRANEPOLE) act->spr.cstat |= CSTAT_SPRITE_BLOCK_ALL | CSTAT_SPRITE_ONE_SIDE; act->spr.picnum += 2; - act->spr.pos.Z = sect->ceilingz + (48 << 8); + act->set_int_z(sect->ceilingz + (48 << 8)); act->temp_data[4] = cranes.Reserve(1); auto& apt = cranes[act->temp_data[4]]; - apt.pos.X = act->spr.pos.X; - apt.pos.Y = act->spr.pos.Y; - apt.pos.Z = act->spr.pos.Z; + apt.pos = act->spr.pos; apt.poleactor = nullptr; DukeStatIterator it(STAT_DEFAULT); @@ -530,16 +525,16 @@ void initwaterdrip(DDukeActor* actj, DDukeActor* actor) if (actj->spr.pal != 1) { actor->spr.pal = 2; - actor->spr.pos.Z -= (18 << 8); + actor->add_int_z(-(18 << 8)); } - else actor->spr.pos.Z -= (13 << 8); + else actor->add_int_z(-(13 << 8)); actor->spr.ang = getangle(ps[connecthead].pos.X - actor->spr.pos.X, ps[connecthead].pos.Y - actor->spr.pos.Y); actor->spr.xvel = 48 - (krand() & 31); ssp(actor, CLIPMASK0); } else if (!actj) { - actor->spr.pos.Z += (4 << 8); + actor->add_int_z(4 << 8); actor->temp_data[0] = actor->spr.pos.Z; if (!isRR()) actor->temp_data[1] = krand() & 127; } @@ -936,8 +931,7 @@ void spawneffector(DDukeActor* actor, TArray* actors) { if (actor->spr.ang == 512) { - actor->spr.pos.X = act2->spr.pos.X; - actor->spr.pos.Y = act2->spr.pos.Y; + actor->set_int_xy(act2->spr.pos.X, act2->spr.pos.Y); } found = true; actor->SetOwner(act2);