From a1570c185f928a457ec13d8ea0db0af52112f863 Mon Sep 17 00:00:00 2001 From: Mitch Richters Date: Sun, 31 Oct 2021 17:52:52 +1100 Subject: [PATCH] - Duke: Remove `posx`/`posy`/`posz` variables and replace with points in the previously unionised `pos` `vec3_t` variable. --- source/games/duke/src/actors.cpp | 182 ++++++++++----------- source/games/duke/src/actors_d.cpp | 66 ++++---- source/games/duke/src/actors_r.cpp | 62 +++---- source/games/duke/src/animatesprites_d.cpp | 16 +- source/games/duke/src/animatesprites_r.cpp | 16 +- source/games/duke/src/ccmds.cpp | 6 +- source/games/duke/src/game_misc.cpp | 8 +- source/games/duke/src/gameexec.cpp | 40 ++--- source/games/duke/src/input.cpp | 6 +- source/games/duke/src/noise.cpp | 4 +- source/games/duke/src/player.cpp | 38 ++--- source/games/duke/src/player_d.cpp | 104 ++++++------ source/games/duke/src/player_r.cpp | 108 ++++++------ source/games/duke/src/player_w.cpp | 8 +- source/games/duke/src/prediction.cpp | 14 +- source/games/duke/src/premap.cpp | 18 +- source/games/duke/src/render.cpp | 6 +- source/games/duke/src/savegame.cpp | 12 +- source/games/duke/src/sectors.cpp | 6 +- source/games/duke/src/sectors_d.cpp | 38 ++--- source/games/duke/src/sectors_r.cpp | 26 +-- source/games/duke/src/spawn.cpp | 4 +- source/games/duke/src/types.h | 6 +- 23 files changed, 395 insertions(+), 399 deletions(-) diff --git a/source/games/duke/src/actors.cpp b/source/games/duke/src/actors.cpp index f8cfbdef6..acf14f7fc 100644 --- a/source/games/duke/src/actors.cpp +++ b/source/games/duke/src/actors.cpp @@ -203,11 +203,11 @@ void checkavailweapon(struct player_struct* player) void clearcamera(player_struct* ps) { ps->newOwner = nullptr; - ps->posx = ps->oposx; - ps->posy = ps->oposy; - ps->posz = ps->oposz; + ps->pos.x = ps->oposx; + ps->pos.y = ps->oposy; + ps->pos.z = ps->oposz; ps->angle.restore(); - updatesector(ps->posx, ps->posy, &ps->cursectnum); + updatesector(ps->pos.x, ps->pos.y, &ps->cursectnum); DukeStatIterator it(STAT_ACTOR); while (auto k = it.Next()) @@ -387,8 +387,8 @@ void movedummyplayers(void) } } - spri->x += (ps[p].posx - ps[p].oposx); - spri->y += (ps[p].posy - ps[p].oposy); + spri->x += (ps[p].pos.x - ps[p].oposx); + spri->y += (ps[p].pos.y - ps[p].oposy); setsprite(act, spri->pos); } } @@ -459,7 +459,7 @@ void moveplayers(void) if (p->actorsqu != nullptr) { - p->angle.addadjustment(getincanglebam(p->angle.ang, bvectangbam(p->actorsqu->s->x - p->posx, p->actorsqu->s->y - p->posy)).signedbuild() >> 2); + p->angle.addadjustment(getincanglebam(p->angle.ang, bvectangbam(p->actorsqu->s->x - p->pos.x, p->actorsqu->s->y - p->pos.y)).signedbuild() >> 2); } if (spri->extra > 0) @@ -474,15 +474,15 @@ void moveplayers(void) } else { - p->posx = spri->x; - p->posy = spri->y; - p->posz = spri->z - (20 << 8); + p->pos.x = spri->x; + p->pos.y = spri->y; + p->pos.z = spri->z - (20 << 8); p->newOwner = nullptr; if (p->wackedbyactor != nullptr && p->wackedbyactor->s->statnum < MAXSTATUS) { - p->angle.addadjustment(getincanglebam(p->angle.ang, bvectangbam(p->wackedbyactor->s->x - p->posx, p->wackedbyactor->s->y - p->posy)).signedbuild() >> 1); + p->angle.addadjustment(getincanglebam(p->angle.ang, bvectangbam(p->wackedbyactor->s->x - p->pos.x, p->wackedbyactor->s->y - p->pos.y)).signedbuild() >> 1); } } spri->ang = p->angle.ang.asbuild(); @@ -807,13 +807,13 @@ void movecrane(DDukeActor *actor, int crane) else if (actor->IsActiveCrane()) { auto ang = ps[p].angle.ang.asbuild(); - ps[p].oposx = ps[p].posx; - ps[p].oposy = ps[p].posy; - ps[p].oposz = ps[p].posz; - ps[p].posx = spri->x - bcos(ang, -6); - ps[p].posy = spri->y - bsin(ang, -6); - ps[p].posz = spri->z + (2 << 8); - setsprite(ps[p].GetActor(), ps[p].posx, ps[p].posy, ps[p].posz); + ps[p].oposx = ps[p].pos.x; + ps[p].oposy = ps[p].pos.y; + ps[p].oposz = ps[p].pos.z; + ps[p].pos.x = spri->x - bcos(ang, -6); + ps[p].pos.y = spri->y - bsin(ang, -6); + ps[p].pos.z = spri->z + (2 << 8); + setsprite(ps[p].GetActor(), ps[p].pos.x, ps[p].pos.y, ps[p].pos.z); ps[p].cursectnum = ps[p].GetActor()->s->sectnum; } } @@ -1127,7 +1127,7 @@ void movetouchplate(DDukeActor* actor, int plate) { sector[sect].floorz += sector[sect].extra; p = checkcursectnums(sect); - if (p >= 0) ps[p].posz += sector[sect].extra; + if (p >= 0) ps[p].pos.z += sector[sect].extra; } } else @@ -1142,7 +1142,7 @@ void movetouchplate(DDukeActor* actor, int plate) sector[sect].floorz -= sector[sect].extra; p = checkcursectnums(sect); if (p >= 0) - ps[p].posz -= sector[sect].extra; + ps[p].pos.z -= sector[sect].extra; } } return; @@ -1539,7 +1539,7 @@ bool queball(DDukeActor *actor, int pocket, int queball, int stripeball) { // if(s->pal == 12) { - int j = getincangle(ps[p].angle.ang.asbuild(), getangle(s->x - ps[p].posx, s->y - ps[p].posy)); + int j = getincangle(ps[p].angle.ang.asbuild(), getangle(s->x - ps[p].pos.x, s->y - ps[p].pos.y)); if (j > -64 && j < 64 && PlayerInput(p, SB_OPEN)) if (ps[p].toggle_key_flag == 1) { @@ -1550,7 +1550,7 @@ bool queball(DDukeActor *actor, int pocket, int queball, int stripeball) auto sa = act2->s; if (sa->picnum == queball || sa->picnum == stripeball) { - j = getincangle(ps[p].angle.ang.asbuild(), getangle(sa->x - ps[p].posx, sa->y - ps[p].posy)); + j = getincangle(ps[p].angle.ang.asbuild(), getangle(sa->x - ps[p].pos.x, sa->y - ps[p].pos.y)); if (j > -64 && j < 64) { int l; @@ -1572,7 +1572,7 @@ bool queball(DDukeActor *actor, int pocket, int queball, int stripeball) } if (x < 512 && s->sectnum == ps[p].cursectnum) { - s->ang = getangle(s->x - ps[p].posx, s->y - ps[p].posy); + s->ang = getangle(s->x - ps[p].pos.x, s->y - ps[p].pos.y); s->xvel = 48; } } @@ -1719,13 +1719,13 @@ void recon(DDukeActor *actor, int explosion, int firelaser, int attacksnd, int p fi.shoot(actor, firelaser); s->ang = a; } - if (t[2] > (26 * 3) || !cansee(s->x, s->y, s->z - (16 << 8), s->sectnum, ps[p].posx, ps[p].posy, ps[p].posz, ps[p].cursectnum)) + if (t[2] > (26 * 3) || !cansee(s->x, s->y, s->z - (16 << 8), s->sectnum, ps[p].pos.x, ps[p].pos.y, ps[p].pos.z, ps[p].cursectnum)) { t[0] = 0; t[2] = 0; } else actor->tempang += - getincangle(actor->tempang, getangle(ps[p].posx - s->x, ps[p].posy - s->y)) / 3; + getincangle(actor->tempang, getangle(ps[p].pos.x - s->x, ps[p].pos.y - s->y)) / 3; } else if (t[0] == 2 || t[0] == 3) { @@ -1735,14 +1735,14 @@ void recon(DDukeActor *actor, int explosion, int firelaser, int attacksnd, int p if (t[0] == 2) { - int l = ps[p].posz - s->z; + int l = ps[p].pos.z - s->z; if (abs(l) < (48 << 8)) t[0] = 3; - else s->z += Sgn(ps[p].posz - s->z) << shift; // The shift here differs between Duke and RR. + else s->z += Sgn(ps[p].pos.z - s->z) << shift; // The shift here differs between Duke and RR. } else { t[2]++; - if (t[2] > (26 * 3) || !cansee(s->x, s->y, s->z - (16 << 8), s->sectnum, ps[p].posx, ps[p].posy, ps[p].posz, ps[p].cursectnum)) + if (t[2] > (26 * 3) || !cansee(s->x, s->y, s->z - (16 << 8), s->sectnum, ps[p].pos.x, ps[p].pos.y, ps[p].pos.z, ps[p].cursectnum)) { t[0] = 1; t[2] = 0; @@ -1753,7 +1753,7 @@ void recon(DDukeActor *actor, int explosion, int firelaser, int attacksnd, int p fi.shoot(actor, firelaser); } } - s->ang += getincangle(s->ang, getangle(ps[p].posx - s->x, ps[p].posy - s->y)) >> 2; + s->ang += getincangle(s->ang, getangle(ps[p].pos.x - s->x, ps[p].pos.y - s->y)) >> 2; } if (t[0] != 2 && t[0] != 3 && Owner) @@ -2741,16 +2741,16 @@ void handle_se00(DDukeActor* actor, int LASERLINE) { ps[p].angle.addadjustment(l * q); - ps[p].posz += zchange; + ps[p].pos.z += zchange; int m, x; - rotatepoint(Owner->s->x, Owner->s->y, ps[p].posx, ps[p].posy, (q * l), &m, &x); + rotatepoint(Owner->s->x, Owner->s->y, ps[p].pos.x, ps[p].pos.y, (q * l), &m, &x); - ps[p].bobposx += m - ps[p].posx; - ps[p].bobposy += x - ps[p].posy; + ps[p].bobposx += m - ps[p].pos.x; + ps[p].bobposy += x - ps[p].pos.y; - ps[p].posx = m; - ps[p].posy = x; + ps[p].pos.x = m; + ps[p].pos.y = x; auto psp = ps[p].GetActor(); if (psp->s->extra <= 0) @@ -2876,7 +2876,7 @@ void handle_se14(DDukeActor* actor, bool checkstat, int RPG, int JIBS6) if (x < 20480) { j = s->ang; - s->ang = getangle(s->x - ps[p].posx, s->y - ps[p].posy); + s->ang = getangle(s->x - ps[p].pos.x, s->y - ps[p].pos.y); fi.shoot(actor, RPG); s->ang = j; } @@ -2895,11 +2895,11 @@ void handle_se14(DDukeActor* actor, bool checkstat, int RPG, int JIBS6) if (psp->s->extra > 0) { short k = ps[p].cursectnum; - updatesector(ps[p].posx, ps[p].posy, &k); + updatesector(ps[p].pos.x, ps[p].pos.y, &k); if ((k == -1 && ud.clipping == 0) || (k == s->sectnum && ps[p].cursectnum != s->sectnum)) { - ps[p].posx = s->x; - ps[p].posy = s->y; + ps[p].pos.x = s->x; + ps[p].pos.y = s->y; ps[p].cursectnum = s->sectnum; setsprite(ps[p].GetActor(), s->pos); @@ -2925,10 +2925,10 @@ void handle_se14(DDukeActor* actor, bool checkstat, int RPG, int JIBS6) if (s->sectnum == psp->s->sectnum) { - rotatepoint(s->x, s->y, ps[p].posx, ps[p].posy, q, &ps[p].posx, &ps[p].posy); + rotatepoint(s->x, s->y, ps[p].pos.x, ps[p].pos.y, q, &ps[p].pos.x, &ps[p].pos.y); - ps[p].posx += m; - ps[p].posy += x; + ps[p].pos.x += m; + ps[p].pos.y += x; ps[p].bobposx += m; ps[p].bobposy += x; @@ -2937,13 +2937,13 @@ void handle_se14(DDukeActor* actor, bool checkstat, int RPG, int JIBS6) if (numplayers > 1) { - ps[p].oposx = ps[p].posx; - ps[p].oposy = ps[p].posy; + ps[p].oposx = ps[p].pos.x; + ps[p].oposy = ps[p].pos.y; } if (psp->s->extra <= 0) { - psp->s->x = ps[p].posx; - psp->s->y = ps[p].posy; + psp->s->x = ps[p].pos.x; + psp->s->y = ps[p].pos.y; } } } @@ -2979,11 +2979,11 @@ void handle_se14(DDukeActor* actor, bool checkstat, int RPG, int JIBS6) if (ps[p].GetActor()->s->extra > 0) { short k = ps[p].cursectnum; - updatesector(ps[p].posx, ps[p].posy, &k); + updatesector(ps[p].pos.x, ps[p].pos.y, &k); if ((k == -1 && ud.clipping == 0) || (k == s->sectnum && ps[p].cursectnum != s->sectnum)) { - ps[p].oposx = ps[p].posx = s->x; - ps[p].oposy = ps[p].posy = s->y; + ps[p].oposx = ps[p].pos.x = s->x; + ps[p].oposy = ps[p].pos.y = s->y; ps[p].cursectnum = s->sectnum; setsprite(ps[p].GetActor(), s->pos); @@ -3084,11 +3084,11 @@ void handle_se30(DDukeActor *actor, int JIBS6) if (psp->s->extra > 0) { short k = ps[p].cursectnum; - updatesector(ps[p].posx, ps[p].posy, &k); + updatesector(ps[p].pos.x, ps[p].pos.y, &k); if ((k == -1 && ud.clipping == 0) || (k == s->sectnum && ps[p].cursectnum != s->sectnum)) { - ps[p].posx = s->x; - ps[p].posy = s->y; + ps[p].pos.x = s->x; + ps[p].pos.y = s->y; ps[p].cursectnum = s->sectnum; setsprite(ps[p].GetActor(), s->pos); @@ -3101,13 +3101,13 @@ void handle_se30(DDukeActor *actor, int JIBS6) auto psp = ps[p].GetActor(); if (psp->s->sectnum == s->sectnum) { - ps[p].posx += l; - ps[p].posy += x; + ps[p].pos.x += l; + ps[p].pos.y += x; if (numplayers > 1) { - ps[p].oposx = ps[p].posx; - ps[p].oposy = ps[p].posy; + ps[p].oposx = ps[p].pos.x; + ps[p].oposy = ps[p].pos.y; } ps[p].bobposx += l; @@ -3147,14 +3147,14 @@ void handle_se30(DDukeActor *actor, int JIBS6) if (ps[p].GetActor()->s->extra > 0) { short k = ps[p].cursectnum; - updatesector(ps[p].posx, ps[p].posy, &k); + updatesector(ps[p].pos.x, ps[p].pos.y, &k); if ((k == -1 && ud.clipping == 0) || (k == s->sectnum && ps[p].cursectnum != s->sectnum)) { - ps[p].posx = s->x; - ps[p].posy = s->y; + ps[p].pos.x = s->x; + ps[p].pos.y = s->y; - ps[p].oposx = ps[p].posx; - ps[p].oposy = ps[p].posy; + ps[p].oposx = ps[p].pos.x; + ps[p].oposy = ps[p].pos.y; ps[p].cursectnum = s->sectnum; @@ -3242,8 +3242,8 @@ void handle_se02(DDukeActor *actor) for (int p = connecthead; p >= 0; p = connectpoint2[p]) if (ps[p].cursectnum == s->sectnum && ps[p].on_ground) { - ps[p].posx += m; - ps[p].posy += x; + ps[p].pos.x += m; + ps[p].pos.y += x; ps[p].bobposx += m; ps[p].bobposy += x; @@ -3409,7 +3409,7 @@ void handle_se05(DDukeActor* actor, int FIRELASER) if (x < 8192) { j = s->ang; - s->ang = getangle(s->x - ps[p].posx, s->y - ps[p].posy); + s->ang = getangle(s->x - ps[p].pos.x, s->y - ps[p].pos.y); fi.shoot(actor, FIRELASER); s->ang = j; } @@ -3444,7 +3444,7 @@ void handle_se05(DDukeActor* actor, int FIRELASER) { short ta; ta = s->ang; - s->ang = getangle(ps[p].posx - s->x, ps[p].posy - s->y); + s->ang = getangle(ps[p].pos.x - s->x, ps[p].pos.y - s->y); s->ang = ta; actor->SetOwner(nullptr); return; @@ -3464,7 +3464,7 @@ void handle_se05(DDukeActor* actor, int FIRELASER) else { t[2] += - getincangle(t[2] + 512, getangle(ps[p].posx - s->x, ps[p].posy - s->y)) >> 2; + getincangle(t[2] + 512, getangle(ps[p].pos.x - s->x, ps[p].pos.y - s->y)) >> 2; sc->ceilingshade = 0; } j = fi.ifhitbyweapon(actor); @@ -3959,11 +3959,11 @@ void handle_se17(DDukeActor* actor) if (act1->s->statnum == STAT_PLAYER && act1->GetOwner()) { int p = act1->s->yvel; - if (numplayers < 2) ps[p].oposz = ps[p].posz; - ps[p].posz += q; + if (numplayers < 2) ps[p].oposz = ps[p].pos.z; + ps[p].pos.z += q; ps[p].truefz += q; ps[p].truecz += q; - if (numplayers > 1) ps[p].oposz = ps[p].posz; + if (numplayers > 1) ps[p].oposz = ps[p].pos.z; } if (act1->s->statnum != STAT_EFFECTOR) { @@ -4013,16 +4013,16 @@ void handle_se17(DDukeActor* actor) { int p = spr3->yvel; - ps[p].posx += spr2->x - s->x; - ps[p].posy += spr2->y - s->y; - ps[p].posz = sector[spr2->sectnum].floorz - (sc->floorz - ps[p].posz); + ps[p].pos.x += spr2->x - s->x; + ps[p].pos.y += spr2->y - s->y; + ps[p].pos.z = sector[spr2->sectnum].floorz - (sc->floorz - ps[p].pos.z); act3->floorz = sector[spr2->sectnum].floorz; act3->ceilingz = sector[spr2->sectnum].ceilingz; - ps[p].bobposx = ps[p].oposx = ps[p].posx; - ps[p].bobposy = ps[p].oposy = ps[p].posy; - ps[p].oposz = ps[p].posz; + ps[p].bobposx = ps[p].oposx = ps[p].pos.x; + ps[p].bobposy = ps[p].oposy = ps[p].pos.y; + ps[p].oposz = ps[p].pos.z; ps[p].truefz = act3->floorz; ps[p].truecz = act3->ceilingz; @@ -4086,7 +4086,7 @@ void handle_se18(DDukeActor *actor, bool morecheck) while (auto a2 = it.Next()) { if (a2->s->picnum == TILE_APLAYER && a2->GetOwner()) - if (ps[a2->PlayerIndex()].on_ground == 1) ps[a2->PlayerIndex()].posz += sc->extra; + if (ps[a2->PlayerIndex()].on_ground == 1) ps[a2->PlayerIndex()].pos.z += sc->extra; if (a2->s->zvel == 0 && a2->s->statnum != STAT_EFFECTOR && a2->s->statnum != STAT_PROJECTILE) { a2->s->z += sc->extra; @@ -4123,7 +4123,7 @@ void handle_se18(DDukeActor *actor, bool morecheck) while (auto a2 = it.Next()) { if (a2->s->picnum == TILE_APLAYER && a2->GetOwner()) - if (ps[a2->PlayerIndex()].on_ground == 1) ps[a2->PlayerIndex()].posz -= sc->extra; + if (ps[a2->PlayerIndex()].on_ground == 1) ps[a2->PlayerIndex()].pos.z -= sc->extra; if (a2->s->zvel == 0 && a2->s->statnum != STAT_EFFECTOR && a2->s->statnum != STAT_PROJECTILE) { a2->s->z -= sc->extra; @@ -4303,13 +4303,13 @@ void handle_se20(DDukeActor* actor) for (int p = connecthead; p >= 0; p = connectpoint2[p]) if (ps[p].cursectnum == s->sectnum && ps[p].on_ground) { - ps[p].posx += x; - ps[p].posy += l; + ps[p].pos.x += x; + ps[p].pos.y += l; - ps[p].oposx = ps[p].posx; - ps[p].oposy = ps[p].posy; + ps[p].oposx = ps[p].pos.x; + ps[p].oposy = ps[p].pos.y; - setsprite(ps[p].GetActor(), ps[p].posx, ps[p].posy, ps[p].posz + gs.playerheight); + setsprite(ps[p].GetActor(), ps[p].pos.x, ps[p].pos.y, ps[p].pos.z + gs.playerheight); } sc->addfloorxpan(-x / 8.f); @@ -4424,7 +4424,7 @@ void handle_se26(DDukeActor* actor) { ps[p].fric.x += l << 5; ps[p].fric.y += x << 5; - ps[p].posz += s->zvel; + ps[p].pos.z += s->zvel; } ms(actor); @@ -4460,14 +4460,14 @@ void handle_se27(DDukeActor* actor) } else if (ud.recstat == 2 && ps[p].newOwner == nullptr) { - if (cansee(s->x, s->y, s->z, s->sectnum, ps[p].posx, ps[p].posy, ps[p].posz, ps[p].cursectnum)) + if (cansee(s->x, s->y, s->z, s->sectnum, ps[p].pos.x, ps[p].pos.y, ps[p].pos.z, ps[p].cursectnum)) { if (x < sh) { ud.cameraactor = actor; t[0] = 999; - s->ang += getincangle(s->ang, getangle(ps[p].posx - s->x, ps[p].posy - s->y)) >> 3; - s->yvel = 100 + ((s->z - ps[p].posz) / 257); + s->ang += getincangle(s->ang, getangle(ps[p].pos.x - s->x, ps[p].pos.y - s->y)) >> 3; + s->yvel = 100 + ((s->z - ps[p].pos.z) / 257); } else if (t[0] == 999) @@ -4481,7 +4481,7 @@ void handle_se27(DDukeActor* actor) } else { - s->ang = getangle(ps[p].posx - s->x, ps[p].posy - s->y); + s->ang = getangle(ps[p].pos.x - s->x, ps[p].pos.y - s->y); if (t[0] == 999) { @@ -4838,7 +4838,7 @@ void handle_se31(DDukeActor* actor, bool choosedir) { if (a2->s->picnum == TILE_APLAYER && a2->GetOwner()) if (ps[a2->PlayerIndex()].on_ground == 1) - ps[a2->PlayerIndex()].posz += l; + ps[a2->PlayerIndex()].pos.z += l; if (a2->s->zvel == 0 && a2->s->statnum != STAT_EFFECTOR && (!choosedir || a2->s->statnum != STAT_PROJECTILE)) { a2->s->z += l; @@ -4867,7 +4867,7 @@ void handle_se31(DDukeActor* actor, bool choosedir) { if (a2->s->picnum == TILE_APLAYER && a2->GetOwner()) if (ps[a2->PlayerIndex()].on_ground == 1) - ps[a2->PlayerIndex()].posz += l; + ps[a2->PlayerIndex()].pos.z += l; if (a2->s->zvel == 0 && a2->s->statnum != STAT_EFFECTOR && (!choosedir || a2->s->statnum != STAT_PROJECTILE)) { a2->s->z += l; @@ -4898,7 +4898,7 @@ void handle_se31(DDukeActor* actor, bool choosedir) { if (a2->s->picnum == TILE_APLAYER && a2->GetOwner()) if (ps[a2->PlayerIndex()].on_ground == 1) - ps[a2->PlayerIndex()].posz += l; + ps[a2->PlayerIndex()].pos.z += l; if (a2->s->zvel == 0 && a2->s->statnum != STAT_EFFECTOR && (!choosedir || a2->s->statnum != STAT_PROJECTILE)) { a2->s->z += l; @@ -4926,7 +4926,7 @@ void handle_se31(DDukeActor* actor, bool choosedir) { if (a2->s->picnum ==TILE_APLAYER && a2->GetOwner()) if (ps[a2->PlayerIndex()].on_ground == 1) - ps[a2->PlayerIndex()].posz -= l; + ps[a2->PlayerIndex()].pos.z -= l; if (a2->s->zvel == 0 && a2->s->statnum != STAT_EFFECTOR && (!choosedir || a2->s->statnum != STAT_PROJECTILE)) { a2->s->z -= l; diff --git a/source/games/duke/src/actors_d.cpp b/source/games/duke/src/actors_d.cpp index a84cefff8..a18401430 100644 --- a/source/games/duke/src/actors_d.cpp +++ b/source/games/duke/src/actors_d.cpp @@ -2045,9 +2045,9 @@ void movetransports_d(void) ps[p].transporter_hold = 13; } - ps[p].bobposx = ps[p].oposx = ps[p].posx = Owner->s->x; - ps[p].bobposy = ps[p].oposy = ps[p].posy = Owner->s->y; - ps[p].oposz = ps[p].posz = Owner->s->z - gs.playerheight; + ps[p].bobposx = ps[p].oposx = ps[p].pos.x = Owner->s->x; + ps[p].bobposy = ps[p].oposy = ps[p].pos.y = Owner->s->y; + ps[p].oposz = ps[p].pos.z = Owner->s->z - gs.playerheight; changeactorsect(act2, Owner->s->sectnum); ps[p].cursectnum = spr2->sectnum; @@ -2063,17 +2063,17 @@ void movetransports_d(void) } else if (!(sectlotag == 1 && ps[p].on_ground == 1)) break; - if (onfloorz == 0 && abs(spr->z - ps[p].posz) < 6144) + if (onfloorz == 0 && abs(spr->z - ps[p].pos.z) < 6144) if ((ps[p].jetpack_on == 0) || (ps[p].jetpack_on && (PlayerInput(p, SB_JUMP))) || (ps[p].jetpack_on && PlayerInput(p, SB_CROUCH))) { - ps[p].oposx = ps[p].posx += Owner->s->x - spr->x; - ps[p].oposy = ps[p].posy += Owner->s->y - spr->y; + ps[p].oposx = ps[p].pos.x += Owner->s->x - spr->x; + ps[p].oposy = ps[p].pos.y += Owner->s->y - spr->y; if (ps[p].jetpack_on && (PlayerInput(p, SB_JUMP) || ps[p].jetpack_on < 11)) - ps[p].posz = Owner->s->z - 6144; - else ps[p].posz = Owner->s->z + 6144; - ps[p].oposz = ps[p].posz; + ps[p].pos.z = Owner->s->z - 6144; + else ps[p].pos.z = Owner->s->z + 6144; + ps[p].oposz = ps[p].pos.z; auto pa = ps[p].GetActor(); pa->s->opos = ps[p].pos; @@ -2086,8 +2086,8 @@ void movetransports_d(void) int k = 0; - if (onfloorz && sectlotag == ST_1_ABOVE_WATER && ps[p].on_ground && ps[p].posz > (sector[sect].floorz - (16 << 8)) && (PlayerInput(p, SB_CROUCH) || ps[p].poszv > 2048)) - // if( onfloorz && sectlotag == 1 && ps[p].posz > (sector[sect].floorz-(6<<8)) ) + if (onfloorz && sectlotag == ST_1_ABOVE_WATER && ps[p].on_ground && ps[p].pos.z > (sector[sect].floorz - (16 << 8)) && (PlayerInput(p, SB_CROUCH) || ps[p].poszv > 2048)) + // if( onfloorz && sectlotag == 1 && ps[p].pos.z > (sector[sect].floorz-(6<<8)) ) { k = 1; if (screenpeek == p) @@ -2096,7 +2096,7 @@ void movetransports_d(void) } if (ps[p].GetActor()->s->extra > 0) S_PlayActorSound(DUKE_UNDERWATER, act2); - ps[p].oposz = ps[p].posz = + ps[p].oposz = ps[p].pos.z = sector[Owner->s->sectnum].ceilingz + (7 << 8); ps[p].posxv = 4096 - (krand() & 8192); @@ -2104,7 +2104,7 @@ void movetransports_d(void) } - if (onfloorz && sectlotag == ST_2_UNDERWATER && ps[p].posz < (sector[sect].ceilingz + (6 << 8))) + if (onfloorz && sectlotag == ST_2_UNDERWATER && ps[p].pos.z < (sector[sect].ceilingz + (6 << 8))) { k = 1; // if( spr2->extra <= 0) break; @@ -2114,7 +2114,7 @@ void movetransports_d(void) } S_PlayActorSound(DUKE_GASP, act2); - ps[p].oposz = ps[p].posz = + ps[p].oposz = ps[p].pos.z = sector[Owner->s->sectnum].floorz - (7 << 8); ps[p].jumping_toggle = 1; @@ -2123,15 +2123,15 @@ void movetransports_d(void) if (k == 1) { - ps[p].oposx = ps[p].posx += Owner->s->x - spr->x; - ps[p].oposy = ps[p].posy += Owner->s->y - spr->y; + ps[p].oposx = ps[p].pos.x += Owner->s->x - spr->x; + ps[p].oposy = ps[p].pos.y += Owner->s->y - spr->y; if (!Owner || Owner->GetOwner() != Owner) ps[p].transporter_hold = -2; ps[p].cursectnum = Owner->s->sectnum; changeactorsect(act2, Owner->s->sectnum); - setsprite(ps[p].GetActor(), ps[p].posx, ps[p].posy, ps[p].posz + gs.playerheight); + setsprite(ps[p].GetActor(), ps[p].pos.x, ps[p].pos.y, ps[p].pos.z + gs.playerheight); if ((krand() & 255) < 32) spawn(act2, WATERSPLASH2); @@ -2380,7 +2380,7 @@ static void greenslime(DDukeActor *actor) } else if (x < 1024 && ps[p].quick_kick == 0) { - j = getincangle(ps[p].angle.ang.asbuild(), getangle(s->x - ps[p].posx, s->y - ps[p].posy)); + j = getincangle(ps[p].angle.ang.asbuild(), getangle(s->x - ps[p].pos.x, s->y - ps[p].pos.y)); if (j > -128 && j < 128) ps[p].quick_kick = 14; } @@ -2428,7 +2428,7 @@ static void greenslime(DDukeActor *actor) return; } - s->z = ps[p].posz + ps[p].pyoff - t[2] + (8 << 8); + s->z = ps[p].pos.z + ps[p].pyoff - t[2] + (8 << 8); s->z += -ps[p].horizon.horiz.asq16() >> 12; @@ -2441,12 +2441,12 @@ static void greenslime(DDukeActor *actor) if (ps[p].newOwner != nullptr) { ps[p].newOwner = nullptr; - ps[p].posx = ps[p].oposx; - ps[p].posy = ps[p].oposy; - ps[p].posz = ps[p].oposz; + ps[p].pos.x = ps[p].oposx; + ps[p].pos.y = ps[p].oposy; + ps[p].pos.z = ps[p].oposz; ps[p].angle.restore(); - updatesector(ps[p].posx, ps[p].posy, &ps[p].cursectnum); + updatesector(ps[p].pos.x, ps[p].pos.y, &ps[p].cursectnum); DukeStatIterator it(STAT_ACTOR); while (auto ac = it.Next()) @@ -2482,8 +2482,8 @@ static void greenslime(DDukeActor *actor) s->xrepeat = 20 + bsin(t[1], -13); s->yrepeat = 15 + bsin(t[1], -13); - s->x = ps[p].posx + ps[p].angle.ang.bcos(-7); - s->y = ps[p].posy + ps[p].angle.ang.bsin(-7); + s->x = ps[p].pos.x + ps[p].angle.ang.bcos(-7); + s->y = ps[p].pos.y + ps[p].angle.ang.bsin(-7); return; } @@ -2645,7 +2645,7 @@ static void greenslime(DDukeActor *actor) s->xvel = 64 - bcos(t[1], -9); s->ang += getincangle(s->ang, - getangle(ps[p].posx - s->x, ps[p].posy - s->y)) >> 3; + getangle(ps[p].pos.x - s->x, ps[p].pos.y - s->y)) >> 3; // TJR } @@ -2982,7 +2982,7 @@ DETONATEB: } } else if (s->picnum == HEAVYHBOMB && x < 788 && t[0] > 7 && s->xvel == 0) - if (cansee(s->x, s->y, s->z - (8 << 8), s->sectnum, ps[p].posx, ps[p].posy, ps[p].posz, ps[p].cursectnum)) + if (cansee(s->x, s->y, s->z - (8 << 8), s->sectnum, ps[p].pos.x, ps[p].pos.y, ps[p].pos.z, ps[p].cursectnum)) if (ps[p].ammo_amount[HANDBOMB_WEAPON] < gs.max_ammo_amount[HANDBOMB_WEAPON]) { if (ud.coop >= 1 && Owner == actor) @@ -3542,7 +3542,7 @@ static void handle_se28(DDukeActor* actor) } else if (t[2] > (t[1] >> 3) && t[2] < (t[1] >> 2)) { - int j = !!cansee(s->x, s->y, s->z, s->sectnum, ps[screenpeek].posx, ps[screenpeek].posy, ps[screenpeek].posz, ps[screenpeek].cursectnum); + int j = !!cansee(s->x, s->y, s->z, s->sectnum, ps[screenpeek].pos.x, ps[screenpeek].pos.y, ps[screenpeek].pos.z, ps[screenpeek].cursectnum); if (rnd(192) && (t[2] & 1)) { @@ -3799,7 +3799,7 @@ void move_d(DDukeActor *actor, int playernum, int xvel) { if (ps[playernum].newOwner != nullptr) goalang = getangle(ps[playernum].oposx - spr->x, ps[playernum].oposy - spr->y); - else goalang = getangle(ps[playernum].posx - spr->x, ps[playernum].posy - spr->y); + else goalang = getangle(ps[playernum].pos.x - spr->x, ps[playernum].pos.y - spr->y); angdif = getincangle(spr->ang, goalang) >> 2; if (angdif > -8 && angdif < 0) angdif = 0; spr->ang += angdif; @@ -3812,7 +3812,7 @@ void move_d(DDukeActor *actor, int playernum, int xvel) { if (ps[playernum].newOwner != nullptr) goalang = getangle(ps[playernum].oposx - spr->x, ps[playernum].oposy - spr->y); - else goalang = getangle(ps[playernum].posx - spr->x, ps[playernum].posy - spr->y); + else goalang = getangle(ps[playernum].pos.x - spr->x, ps[playernum].pos.y - spr->y); angdif = Sgn(getincangle(spr->ang, goalang)) << 5; if (angdif > -32 && angdif < 0) { @@ -3833,8 +3833,8 @@ void move_d(DDukeActor *actor, int playernum, int xvel) { int newx, newy; - newx = ps[playernum].posx + (ps[playernum].posxv / 768); - newy = ps[playernum].posy + (ps[playernum].posyv / 768); + newx = ps[playernum].pos.x + (ps[playernum].posxv / 768); + newy = ps[playernum].pos.y + (ps[playernum].posyv / 768); goalang = getangle(newx - spr->x, newy - spr->y); angdif = getincangle(spr->ang, goalang) >> 2; if (angdif > -8 && angdif < 0) angdif = 0; @@ -3935,7 +3935,7 @@ void move_d(DDukeActor *actor, int playernum, int xvel) { daxvel = -(1024 - xvel); - angdif = getangle(ps[playernum].posx - spr->x, ps[playernum].posy - spr->y); + angdif = getangle(ps[playernum].pos.x - spr->x, ps[playernum].pos.y - spr->y); if (xvel < 512) { diff --git a/source/games/duke/src/actors_r.cpp b/source/games/duke/src/actors_r.cpp index 070fc2239..51da0c831 100644 --- a/source/games/duke/src/actors_r.cpp +++ b/source/games/duke/src/actors_r.cpp @@ -1628,9 +1628,9 @@ void movetransports_r(void) ps[p].transporter_hold = 13; } - ps[p].bobposx = ps[p].oposx = ps[p].posx = Owner->s->x; - ps[p].bobposy = ps[p].oposy = ps[p].posy = Owner->s->y; - ps[p].oposz = ps[p].posz = Owner->s->z - (gs.playerheight - (4 << 8)); + ps[p].bobposx = ps[p].oposx = ps[p].pos.x = Owner->s->x; + ps[p].bobposy = ps[p].oposy = ps[p].pos.y = Owner->s->y; + ps[p].oposz = ps[p].pos.z = Owner->s->z - (gs.playerheight - (4 << 8)); changeactorsect(act2, Owner->s->sectnum); ps[p].cursectnum = spr2->sectnum; @@ -1643,17 +1643,17 @@ void movetransports_r(void) } else break; - if (onfloorz == 0 && abs(spr->z - ps[p].posz) < 6144) + if (onfloorz == 0 && abs(spr->z - ps[p].pos.z) < 6144) if ((ps[p].jetpack_on == 0) || (ps[p].jetpack_on && PlayerInput(p, SB_JUMP)) || (ps[p].jetpack_on && PlayerInput(p, SB_CROUCH))) { - ps[p].oposx = ps[p].posx += Owner->s->x - spr->x; - ps[p].oposy = ps[p].posy += Owner->s->y - spr->y; + ps[p].oposx = ps[p].pos.x += Owner->s->x - spr->x; + ps[p].oposy = ps[p].pos.y += Owner->s->y - spr->y; if (ps[p].jetpack_on && (PlayerInput(p, SB_JUMP) || ps[p].jetpack_on < 11)) - ps[p].posz = Owner->s->z - 6144; - else ps[p].posz = Owner->s->z + 6144; - ps[p].oposz = ps[p].posz; + ps[p].pos.z = Owner->s->z - 6144; + else ps[p].pos.z = Owner->s->z + 6144; + ps[p].oposz = ps[p].pos.z; changeactorsect(act2, Owner->s->sectnum); ps[p].cursectnum = Owner->s->sectnum; @@ -1665,23 +1665,23 @@ void movetransports_r(void) if (isRRRA()) { - if (onfloorz && sectlotag == 160 && ps[p].posz > (sector[sect].floorz - (48 << 8))) + if (onfloorz && sectlotag == 160 && ps[p].pos.z > (sector[sect].floorz - (48 << 8))) { k = 2; - ps[p].oposz = ps[p].posz = + ps[p].oposz = ps[p].pos.z = sector[Owner->s->sectnum].ceilingz + (7 << 8); } - if (onfloorz && sectlotag == 161 && ps[p].posz < (sector[sect].ceilingz + (6 << 8))) + if (onfloorz && sectlotag == 161 && ps[p].pos.z < (sector[sect].ceilingz + (6 << 8))) { k = 2; if (ps[p].GetActor()->s->extra <= 0) break; - ps[p].oposz = ps[p].posz = + ps[p].oposz = ps[p].pos.z = sector[Owner->s->sectnum].floorz - (49 << 8); } } - if ((onfloorz && sectlotag == ST_1_ABOVE_WATER && ps[p].posz > (sector[sect].floorz - (6 << 8))) || + if ((onfloorz && sectlotag == ST_1_ABOVE_WATER && ps[p].pos.z > (sector[sect].floorz - (6 << 8))) || (onfloorz && sectlotag == ST_1_ABOVE_WATER && ps[p].OnMotorcycle)) { if (ps[p].OnBoat) break; @@ -1691,13 +1691,13 @@ void movetransports_r(void) FX_StopAllSounds(); } S_PlayActorSound(DUKE_UNDERWATER, ps[p].GetActor()); - ps[p].oposz = ps[p].posz = + ps[p].oposz = ps[p].pos.z = sector[Owner->s->sectnum].ceilingz + (7 << 8); if (ps[p].OnMotorcycle) ps[p].moto_underwater = 1; } - if (onfloorz && sectlotag == ST_2_UNDERWATER && ps[p].posz < (sector[sect].ceilingz + (6 << 8))) + if (onfloorz && sectlotag == ST_2_UNDERWATER && ps[p].pos.z < (sector[sect].ceilingz + (6 << 8))) { k = 1; if (ps[p].GetActor()->s->extra <= 0) break; @@ -1707,14 +1707,14 @@ void movetransports_r(void) } S_PlayActorSound(DUKE_GASP, ps[p].GetActor()); - ps[p].oposz = ps[p].posz = + ps[p].oposz = ps[p].pos.z = sector[Owner->s->sectnum].floorz - (7 << 8); } if (k == 1) { - ps[p].oposx = ps[p].posx += Owner->s->x - spr->x; - ps[p].oposy = ps[p].posy += Owner->s->y - spr->y; + ps[p].oposx = ps[p].pos.x += Owner->s->x - spr->x; + ps[p].oposy = ps[p].pos.y += Owner->s->y - spr->y; if (Owner->GetOwner() != Owner) ps[p].transporter_hold = -2; @@ -1727,8 +1727,8 @@ void movetransports_r(void) } else if (isRRRA() && k == 2) { - ps[p].oposx = ps[p].posx += Owner->s->x - spr->x; - ps[p].oposy = ps[p].posy += Owner->s->y - spr->y; + ps[p].oposx = ps[p].pos.x += Owner->s->x - spr->x; + ps[p].oposy = ps[p].pos.y += Owner->s->y - spr->y; if (Owner->GetOwner() != Owner) ps[p].transporter_hold = -2; @@ -2482,9 +2482,9 @@ void rr_specialstats() if (act2->s->picnum == RRTILE297) { ps[p].angle.ang = buildang(act2->s->ang); - ps[p].bobposx = ps[p].oposx = ps[p].posx = act2->s->x; - ps[p].bobposy = ps[p].oposy = ps[p].posy = act2->s->y; - ps[p].oposz = ps[p].posz = act2->s->z - (36 << 8); + ps[p].bobposx = ps[p].oposx = ps[p].pos.x = act2->s->x; + ps[p].bobposy = ps[p].oposy = ps[p].pos.y = act2->s->y; + ps[p].oposz = ps[p].pos.z = act2->s->z - (36 << 8); auto pact = ps[p].GetActor(); changeactorsect(pact, act2->s->sectnum); ps[p].cursectnum = pact->s->sectnum; @@ -2691,7 +2691,7 @@ DETONATEB: } } else if (s->picnum == HEAVYHBOMB && x < 788 && t[0] > 7 && s->xvel == 0) - if (cansee(s->x, s->y, s->z - (8 << 8), s->sectnum, ps[p].posx, ps[p].posy, ps[p].posz, ps[p].cursectnum)) + if (cansee(s->x, s->y, s->z - (8 << 8), s->sectnum, ps[p].pos.x, ps[p].pos.y, ps[p].pos.z, ps[p].cursectnum)) if (ps[p].ammo_amount[DYNAMITE_WEAPON] < gs.max_ammo_amount[DYNAMITE_WEAPON]) if (s->pal == 0) { @@ -3693,7 +3693,7 @@ void move_r(DDukeActor *actor, int pnum, int xvel) { if (ps[pnum].newOwner != nullptr) goalang = getangle(ps[pnum].oposx - spr->x, ps[pnum].oposy - spr->y); - else goalang = getangle(ps[pnum].posx - spr->x, ps[pnum].posy - spr->y); + else goalang = getangle(ps[pnum].pos.x - spr->x, ps[pnum].pos.y - spr->y); angdif = getincangle(spr->ang, goalang) >> 2; if (angdif > -8 && angdif < 0) angdif = 0; spr->ang += angdif; @@ -3706,7 +3706,7 @@ void move_r(DDukeActor *actor, int pnum, int xvel) { if (ps[pnum].newOwner != nullptr) goalang = getangle(ps[pnum].oposx - spr->x, ps[pnum].oposy - spr->y); - else goalang = getangle(ps[pnum].posx - spr->x, ps[pnum].posy - spr->y); + else goalang = getangle(ps[pnum].pos.x - spr->x, ps[pnum].pos.y - spr->y); angdif = Sgn(getincangle(spr->ang, goalang)) << 5; if (angdif > -32 && angdif < 0) { @@ -3722,7 +3722,7 @@ void move_r(DDukeActor *actor, int pnum, int xvel) { if (ps[pnum].newOwner != nullptr) goalang = (getangle(ps[pnum].oposx - spr->x, ps[pnum].oposy - spr->y) + 1024) & 2047; - else goalang = (getangle(ps[pnum].posx - spr->x, ps[pnum].posy - spr->y) + 1024) & 2047; + else goalang = (getangle(ps[pnum].pos.x - spr->x, ps[pnum].pos.y - spr->y) + 1024) & 2047; angdif = Sgn(getincangle(spr->ang, goalang)) << 5; if (angdif > -32 && angdif < 0) { @@ -3788,8 +3788,8 @@ void move_r(DDukeActor *actor, int pnum, int xvel) { int newx, newy; - newx = ps[pnum].posx + (ps[pnum].posxv / 768); - newy = ps[pnum].posy + (ps[pnum].posyv / 768); + newx = ps[pnum].pos.x + (ps[pnum].posxv / 768); + newy = ps[pnum].pos.y + (ps[pnum].posyv / 768); goalang = getangle(newx - spr->x, newy - spr->y); angdif = getincangle(spr->ang, goalang) >> 2; if (angdif > -8 && angdif < 0) angdif = 0; @@ -3894,7 +3894,7 @@ void move_r(DDukeActor *actor, int pnum, int xvel) { daxvel = -(1024 - xvel); - angdif = getangle(ps[pnum].posx - spr->x, ps[pnum].posy - spr->y); + angdif = getangle(ps[pnum].pos.x - spr->x, ps[pnum].pos.y - spr->y); if (xvel < 512) { diff --git a/source/games/duke/src/animatesprites_d.cpp b/source/games/duke/src/animatesprites_d.cpp index 1797ae32f..fe48e4d87 100644 --- a/source/games/duke/src/animatesprites_d.cpp +++ b/source/games/duke/src/animatesprites_d.cpp @@ -176,9 +176,9 @@ void animatesprites_d(spritetype* tsprite, int& spritesortcnt, int x, int y, int if (t->statnum == 99) continue; if (s->statnum != STAT_ACTOR && s->picnum == APLAYER && ps[s->yvel].newOwner == nullptr && h->GetOwner()) { - t->x -= MulScale(MaxSmoothRatio - smoothratio, ps[s->yvel].posx - ps[s->yvel].oposx, 16); - t->y -= MulScale(MaxSmoothRatio - smoothratio, ps[s->yvel].posy - ps[s->yvel].oposy, 16); - t->z = interpolatedvalue(ps[s->yvel].oposz, ps[s->yvel].posz, smoothratio); + t->x -= MulScale(MaxSmoothRatio - smoothratio, ps[s->yvel].pos.x - ps[s->yvel].oposx, 16); + t->y -= MulScale(MaxSmoothRatio - smoothratio, ps[s->yvel].pos.y - ps[s->yvel].oposy, 16); + t->z = interpolatedvalue(ps[s->yvel].oposz, ps[s->yvel].pos.z, smoothratio); t->z += PHEIGHT_DUKE; } else if (s->picnum != CRANEPOLE) @@ -220,8 +220,8 @@ void animatesprites_d(spritetype* tsprite, int& spritesortcnt, int x, int y, int sqa = getangle( - Owner->x - ps[screenpeek].posx, - Owner->y - ps[screenpeek].posy); + Owner->x - ps[screenpeek].pos.x, + Owner->y - ps[screenpeek].pos.y); sqb = getangle( Owner->x - t->x, @@ -369,7 +369,7 @@ void animatesprites_d(spritetype* tsprite, int& spritesortcnt, int x, int y, int } if (h->GetOwner()) - newtspr->z = ps[p].posz - (12 << 8); + newtspr->z = ps[p].pos.z - (12 << 8); else newtspr->z = s->z - (51 << 8); if (ps[p].curr_weapon == HANDBOMB_WEAPON) { @@ -590,7 +590,7 @@ void animatesprites_d(spritetype* tsprite, int& spritesortcnt, int x, int y, int daz = h->floorz; - if ((s->z - daz) < (8 << 8) && ps[screenpeek].posz < daz) + if ((s->z - daz) < (8 << 8) && ps[screenpeek].pos.z < daz) { auto shadowspr = &tsprite[spritesortcnt]; *shadowspr = *t; @@ -616,7 +616,7 @@ void animatesprites_d(spritetype* tsprite, int& spritesortcnt, int x, int y, int else { // Alter the shadow's position so that it appears behind the sprite itself. - int look = getangle(shadowspr->x - ps[screenpeek].posx, shadowspr->y - ps[screenpeek].posy); + int look = getangle(shadowspr->x - ps[screenpeek].pos.x, shadowspr->y - ps[screenpeek].pos.y); shadowspr->x += bcos(look, -9); shadowspr->y += bsin(look, -9); } diff --git a/source/games/duke/src/animatesprites_r.cpp b/source/games/duke/src/animatesprites_r.cpp index dd2d2cb44..0db2e2ccb 100644 --- a/source/games/duke/src/animatesprites_r.cpp +++ b/source/games/duke/src/animatesprites_r.cpp @@ -162,9 +162,9 @@ void animatesprites_r(spritetype* tsprite, int& spritesortcnt, int x, int y, int if (t->statnum == 99) continue; if (s->statnum != STAT_ACTOR && s->picnum == APLAYER && ps[s->yvel].newOwner == nullptr && h->GetOwner()) { - t->x -= MulScale(MaxSmoothRatio - smoothratio, ps[s->yvel].posx - ps[s->yvel].oposx, 16); - t->y -= MulScale(MaxSmoothRatio - smoothratio, ps[s->yvel].posy - ps[s->yvel].oposy, 16); - t->z = interpolatedvalue(ps[s->yvel].oposz, ps[s->yvel].posz, smoothratio); + t->x -= MulScale(MaxSmoothRatio - smoothratio, ps[s->yvel].pos.x - ps[s->yvel].oposx, 16); + t->y -= MulScale(MaxSmoothRatio - smoothratio, ps[s->yvel].pos.y - ps[s->yvel].oposy, 16); + t->z = interpolatedvalue(ps[s->yvel].oposz, ps[s->yvel].pos.z, smoothratio); t->z += PHEIGHT_RR; s->xrepeat = 24; s->yrepeat = 17; @@ -219,8 +219,8 @@ void animatesprites_r(spritetype* tsprite, int& spritesortcnt, int x, int y, int sqa = getangle( - Owner->x - ps[screenpeek].posx, - Owner->y - ps[screenpeek].posy); + Owner->x - ps[screenpeek].pos.x, + Owner->y - ps[screenpeek].pos.y); sqb = getangle( Owner->x - t->x, @@ -414,7 +414,7 @@ void animatesprites_r(spritetype* tsprite, int& spritesortcnt, int x, int y, int } if (h->GetOwner()) - newtspr->z = ps[p].posz - (12 << 8); + newtspr->z = ps[p].pos.z - (12 << 8); else newtspr->z = s->z - (51 << 8); if (ps[p].curr_weapon == HANDBOMB_WEAPON) { @@ -749,7 +749,7 @@ void animatesprites_r(spritetype* tsprite, int& spritesortcnt, int x, int y, int daz = h->floorz; if ((s->z - daz) < (8 << 8)) - if (ps[screenpeek].posz < daz) + if (ps[screenpeek].pos.z < daz) { auto shadowspr = &tsprite[spritesortcnt]; *shadowspr = *t; @@ -775,7 +775,7 @@ void animatesprites_r(spritetype* tsprite, int& spritesortcnt, int x, int y, int else { // Alter the shadow's position so that it appears behind the sprite itself. - int look = getangle(shadowspr->x - ps[screenpeek].posx, shadowspr->y - ps[screenpeek].posy); + int look = getangle(shadowspr->x - ps[screenpeek].pos.x, shadowspr->y - ps[screenpeek].pos.y); shadowspr->x += bcos(look, -9); shadowspr->y += bsin(look, -9); } diff --git a/source/games/duke/src/ccmds.cpp b/source/games/duke/src/ccmds.cpp index f7d04da40..d1484284e 100644 --- a/source/games/duke/src/ccmds.cpp +++ b/source/games/duke/src/ccmds.cpp @@ -107,9 +107,9 @@ void GameInterface::WarpToCoords(int x, int y, int z, int ang, int horz) { player_struct* p = &ps[myconnectindex]; - p->oposx = p->posx = x; - p->oposy = p->posy = y; - p->oposz = p->posz = z; + p->oposx = p->pos.x = x; + p->oposy = p->pos.y = y; + p->oposz = p->pos.z = z; if (ang != INT_MIN) { diff --git a/source/games/duke/src/game_misc.cpp b/source/games/duke/src/game_misc.cpp index 40dca7aaa..a35b73ef1 100644 --- a/source/games/duke/src/game_misc.cpp +++ b/source/games/duke/src/game_misc.cpp @@ -60,7 +60,7 @@ FString GameInterface::GetCoordString() FString out; out.Format("pos= %d, %d, %d - angle = %2.3f - sector = %d, lotag = %d, hitag = %d", - ps[snum].posx, ps[snum].posy, ps[snum].posz, ps[snum].angle.ang.asdeg(), ps[snum].cursectnum, + ps[snum].pos.x, ps[snum].pos.y, ps[snum].pos.z, ps[snum].angle.ang.asdeg(), ps[snum].cursectnum, sector[ps[snum].cursectnum].lotag, sector[ps[snum].cursectnum].hitag); return out; @@ -272,8 +272,8 @@ void drawoverlays(double smoothratio) } else { - cposx = interpolatedvalue(pp->oposx, pp->posx, smoothratio); - cposy = interpolatedvalue(pp->oposy, pp->posy, smoothratio); + cposx = interpolatedvalue(pp->oposx, pp->pos.x, smoothratio); + cposy = interpolatedvalue(pp->oposy, pp->pos.y, smoothratio); cang = (!SyncInput() ? pp->angle.ang : interpolatedangle(pp->angle.oang, pp->angle.ang, smoothratio)).asbuild(); } } @@ -561,7 +561,7 @@ bool GameInterface::DrawAutomapPlayer(int cposx, int cposy, int czoom, int cang, else i = TILE_APLAYERTOP; - j = abs(pp.truefz - pp.posz) >> 8; + j = abs(pp.truefz - pp.pos.z) >> 8; j = czoom * (pspr->yrepeat + j); if (j < 22000) j = 22000; diff --git a/source/games/duke/src/gameexec.cpp b/source/games/duke/src/gameexec.cpp index 095a1ac39..c388585d2 100644 --- a/source/games/duke/src/gameexec.cpp +++ b/source/games/duke/src/gameexec.cpp @@ -307,15 +307,15 @@ void DoPlayer(bool bSet, int lVar1, int lLabelID, int lVar2, DDukeActor* sActor, break; case PLAYER_POSX: // oh, my... :( Writing to these has been disabled until I know how to do it without the engine shitting all over itself. - if (!bSet) SetGameVarID(lVar2, ps[iPlayer].posx, sActor, sPlayer); + if (!bSet) SetGameVarID(lVar2, ps[iPlayer].pos.x, sActor, sPlayer); break; case PLAYER_POSY: - if (!bSet) SetGameVarID(lVar2, ps[iPlayer].posy, sActor, sPlayer); + if (!bSet) SetGameVarID(lVar2, ps[iPlayer].pos.y, sActor, sPlayer); break; case PLAYER_POSZ: - if (!bSet) SetGameVarID(lVar2, ps[iPlayer].posz, sActor, sPlayer); + if (!bSet) SetGameVarID(lVar2, ps[iPlayer].pos.z, sActor, sPlayer); break; case PLAYER_HORIZ: @@ -1523,12 +1523,12 @@ int ParseState::parse(void) parseifelse(ifcanshoottarget(g_ac, g_p, g_x)); break; case concmd_ifcanseetarget: - j = cansee(g_sp->x, g_sp->y, g_sp->z - ((krand() & 41) << 8), g_sp->sectnum, ps[g_p].posx, ps[g_p].posy, ps[g_p].posz/*-((krand()&41)<<8)*/, ps[g_p].GetActor()->s->sectnum); + j = cansee(g_sp->x, g_sp->y, g_sp->z - ((krand() & 41) << 8), g_sp->sectnum, ps[g_p].pos.x, ps[g_p].pos.y, ps[g_p].pos.z/*-((krand()&41)<<8)*/, ps[g_p].GetActor()->s->sectnum); parseifelse(j); if (j) g_ac->timetosleep = SLEEPTIME; break; case concmd_ifnocover: - j = cansee(g_sp->x, g_sp->y, g_sp->z, g_sp->sectnum, ps[g_p].posx, ps[g_p].posy, ps[g_p].posz, ps[g_p].GetActor()->s->sectnum); + j = cansee(g_sp->x, g_sp->y, g_sp->z, g_sp->sectnum, ps[g_p].pos.x, ps[g_p].pos.y, ps[g_p].pos.z, ps[g_p].GetActor()->s->sectnum); parseifelse(j); if (j) g_ac->timetosleep = SLEEPTIME; break; @@ -1982,8 +1982,8 @@ int ParseState::parse(void) break; case concmd_larrybird: insptr++; - ps[g_p].posz = sector[ps[g_p].GetActor()->s->sectnum].ceilingz; - ps[g_p].GetActor()->s->z = ps[g_p].posz; + ps[g_p].pos.z = sector[ps[g_p].GetActor()->s->sectnum].ceilingz; + ps[g_p].GetActor()->s->z = ps[g_p].pos.z; break; case concmd_destroyit: insptr++; @@ -2048,11 +2048,11 @@ int ParseState::parse(void) if(!isRR() && ps[g_p].newOwner != nullptr) { ps[g_p].newOwner = nullptr; - ps[g_p].posx = ps[g_p].oposx; - ps[g_p].posy = ps[g_p].oposy; - ps[g_p].posz = ps[g_p].oposz; + ps[g_p].pos.x = ps[g_p].oposx; + ps[g_p].pos.y = ps[g_p].oposy; + ps[g_p].pos.z = ps[g_p].oposz; ps[g_p].angle.restore(); - updatesector(ps[g_p].posx,ps[g_p].posy,&ps[g_p].cursectnum); + updatesector(ps[g_p].pos.x,ps[g_p].pos.y,&ps[g_p].cursectnum); DukeStatIterator it(STAT_ACTOR); while (auto j = it.Next()) @@ -2224,12 +2224,12 @@ int ParseState::parse(void) { // I am not convinced this is even remotely smart to be executed from here.. pickrandomspot(g_p); - g_sp->x = ps[g_p].bobposx = ps[g_p].oposx = ps[g_p].posx; - g_sp->y = ps[g_p].bobposy = ps[g_p].oposy = ps[g_p].posy; - g_sp->z = ps[g_p].oposz = ps[g_p].posz; + g_sp->x = ps[g_p].bobposx = ps[g_p].oposx = ps[g_p].pos.x; + g_sp->y = ps[g_p].bobposy = ps[g_p].oposy = ps[g_p].pos.y; + g_sp->z = ps[g_p].oposz = ps[g_p].pos.z; g_sp->backuppos(); - updatesector(ps[g_p].posx, ps[g_p].posy, &ps[g_p].cursectnum); - setsprite(ps[g_p].GetActor(), ps[g_p].posx, ps[g_p].posy, ps[g_p].posz + gs.playerheight); + updatesector(ps[g_p].pos.x, ps[g_p].pos.y, &ps[g_p].cursectnum); + setsprite(ps[g_p].GetActor(), ps[g_p].pos.x, ps[g_p].pos.y, ps[g_p].pos.z + gs.playerheight); g_sp->cstat = 257; g_sp->shade = -12; @@ -2403,7 +2403,7 @@ int ParseState::parse(void) j = 1; else if( (l& prunning) && s >= 8 && PlayerInput(g_p, SB_RUN) ) j = 1; - else if( (l& phigher) && ps[g_p].posz < (g_sp->z-(48<<8)) ) + else if( (l& phigher) && ps[g_p].pos.z < (g_sp->z-(48<<8)) ) j = 1; else if( (l& pwalkingback) && s <= -8 && !(PlayerInput(g_p, SB_RUN)) ) j = 1; @@ -2426,9 +2426,9 @@ int ParseState::parse(void) else if( (l& pfacing) ) { if (g_sp->picnum == TILE_APLAYER && ud.multimode > 1) - j = getincangle(ps[otherp].angle.ang.asbuild(), getangle(ps[g_p].posx - ps[otherp].posx, ps[g_p].posy - ps[otherp].posy)); + j = getincangle(ps[otherp].angle.ang.asbuild(), getangle(ps[g_p].pos.x - ps[otherp].pos.x, ps[g_p].pos.y - ps[otherp].pos.y)); else - j = getincangle(ps[g_p].angle.ang.asbuild(), getangle(g_sp->x - ps[g_p].posx, g_sp->y - ps[g_p].posy)); + j = getincangle(ps[g_p].angle.ang.asbuild(), getangle(g_sp->x - ps[g_p].pos.x, g_sp->y - ps[g_p].pos.y)); if( j > -128 && j < 128 ) j = 1; @@ -2766,7 +2766,7 @@ int ParseState::parse(void) case concmd_pstomp: insptr++; if( ps[g_p].knee_incs == 0 && ps[g_p].GetActor()->s->xrepeat >= (isRR()? 9: 40) ) - if( cansee(g_sp->x,g_sp->y,g_sp->z-(4<<8),g_sp->sectnum,ps[g_p].posx,ps[g_p].posy,ps[g_p].posz+(16<<8),ps[g_p].GetActor()->s->sectnum) ) + if( cansee(g_sp->x,g_sp->y,g_sp->z-(4<<8),g_sp->sectnum,ps[g_p].pos.x,ps[g_p].pos.y,ps[g_p].pos.z+(16<<8),ps[g_p].GetActor()->s->sectnum) ) { ps[g_p].knee_incs = 1; if(ps[g_p].weapon_pos == 0) diff --git a/source/games/duke/src/input.cpp b/source/games/duke/src/input.cpp index a76a37452..fc002db31 100644 --- a/source/games/duke/src/input.cpp +++ b/source/games/duke/src/input.cpp @@ -284,9 +284,9 @@ void hud_input(int plnum) auto pactor = EGS(p->cursectnum, - p->posx, - p->posy, - p->posz + (30 << 8), TILE_APLAYER, -64, 0, 0, p->angle.ang.asbuild(), 0, 0, nullptr, 10); + p->pos.x, + p->pos.y, + p->pos.z + (30 << 8), TILE_APLAYER, -64, 0, 0, p->angle.ang.asbuild(), 0, 0, nullptr, 10); pactor->temp_data[3] = pactor->temp_data[4] = 0; p->holoduke_on = pactor; pactor->s->yvel = plnum; diff --git a/source/games/duke/src/noise.cpp b/source/games/duke/src/noise.cpp index 15baa7c49..00f670121 100644 --- a/source/games/duke/src/noise.cpp +++ b/source/games/duke/src/noise.cpp @@ -35,8 +35,8 @@ int madenoise(int snum) player_struct *p; p = &ps[snum]; p->donoise = 1; - p->noise_x = p->posx; - p->noise_y = p->posy; + p->noise_x = p->pos.x; + p->noise_y = p->pos.y; return 1; } diff --git a/source/games/duke/src/player.cpp b/source/games/duke/src/player.cpp index 474c9c9b9..6666ac7e5 100644 --- a/source/games/duke/src/player.cpp +++ b/source/games/duke/src/player.cpp @@ -220,11 +220,11 @@ int hitawall(struct player_struct* p, int* hitw) short sect, hitw1; DDukeActor* d; - hitscan(p->posx, p->posy, p->posz, p->cursectnum, + hitscan(p->pos.x, p->pos.y, p->pos.z, p->cursectnum, p->angle.ang.bcos(), p->angle.ang.bsin(), 0, §, &hitw1, &d, &sx, &sy, &sz, CLIPMASK0); *hitw = hitw1; - return (FindDistance2D(sx - p->posx, sy - p->posy)); + return (FindDistance2D(sx - p->pos.x, sy - p->pos.y)); } @@ -501,8 +501,8 @@ void footprints(int snum) while (auto act = it.Next()) { if (act->s->picnum == TILE_FOOTPRINTS || act->s->picnum == TILE_FOOTPRINTS2 || act->s->picnum == TILE_FOOTPRINTS3 || act->s->picnum == TILE_FOOTPRINTS4) - if (abs(act->s->x - p->posx) < 384) - if (abs(act->s->y - p->posy) < 384) + if (abs(act->s->x - p->pos.x) < 384) + if (abs(act->s->y - p->pos.y) < 384) { j = 1; break; @@ -552,7 +552,7 @@ void playerisdead(int snum, int psectlotag, int fz, int cz) if (s->pal != 1) { SetPlayerPal(p, PalEntry(63, 63, 0, 0)); - p->posz -= (16 << 8); + p->pos.z -= (16 << 8); s->z -= (16 << 8); } #if 0 @@ -609,8 +609,8 @@ void playerisdead(int snum, int psectlotag, int fz, int cz) { if (p->on_warping_sector == 0) { - if (abs(p->posz - fz) > (gs.playerheight >> 1)) - p->posz += 348; + if (abs(p->pos.z - fz) > (gs.playerheight >> 1)) + p->pos.z += 348; } else { @@ -618,7 +618,7 @@ void playerisdead(int snum, int psectlotag, int fz, int cz) s->zvel = -348; } - clipmove(&p->posx, &p->posy, &p->posz, &p->cursectnum, 0, 0, 164, (4 << 8), (4 << 8), CLIPMASK0); + clipmove(&p->pos.x, &p->pos.y, &p->pos.z, &p->cursectnum, 0, 0, 164, (4 << 8), (4 << 8), CLIPMASK0); // p->bobcounter += 32; } @@ -626,12 +626,12 @@ void playerisdead(int snum, int psectlotag, int fz, int cz) p->horizon.horizoff = p->horizon.horiz = q16horiz(0); - updatesector(p->posx, p->posy, &p->cursectnum); + updatesector(p->pos.x, p->pos.y, &p->cursectnum); - pushmove(&p->posx, &p->posy, &p->posz, &p->cursectnum, 128L, (4 << 8), (20 << 8), CLIPMASK0); + pushmove(&p->pos.x, &p->pos.y, &p->pos.z, &p->cursectnum, 128L, (4 << 8), (20 << 8), CLIPMASK0); if (fz > cz + (16 << 8) && s->pal != 1) - p->angle.rotscrnang = buildang(p->dead_flag + ((fz + p->posz) >> 7)); + p->angle.rotscrnang = buildang(p->dead_flag + ((fz + p->pos.z) >> 7)); p->on_warping_sector = 0; @@ -706,7 +706,7 @@ void playerCrouch(int snum) OnEvent(EVENT_CROUCH, snum, p->GetActor(), -1); if (GetGameVarID(g_iReturnVarID, p->GetActor(), snum) == 0) { - p->posz += (2048 + 768); + p->pos.z += (2048 + 768); p->crack_time = CRACK_TIME; } } @@ -765,18 +765,18 @@ void player_struct::backuppos(bool noclipping) { if (!noclipping) { - oposx = posx; - oposy = posy; + oposx = pos.x; + oposy = pos.y; } else { - posx = oposx; - posy = oposy; + pos.x = oposx; + pos.y = oposy; } - oposz = posz; - bobposx = posx; - bobposy = posy; + oposz = pos.z; + bobposx = pos.x; + bobposy = pos.y; opyoff = pyoff; } diff --git a/source/games/duke/src/player_d.cpp b/source/games/duke/src/player_d.cpp index 501b4eb81..bd3dbed80 100644 --- a/source/games/duke/src/player_d.cpp +++ b/source/games/duke/src/player_d.cpp @@ -389,7 +389,7 @@ static void shootweapon(DDukeActor *actor, int p, int sx, int sy, int sz, int sa int x; int j = findplayer(actor, &x); sz -= (4 << 8); - zvel = ((ps[j].posz - sz) << 8) / (ldist(ps[j].GetActor(), actor)); + zvel = ((ps[j].pos.z - sz) << 8) / (ldist(ps[j].GetActor(), actor)); if (s->picnum != BOSS1) { zvel += 128 - (krand() & 255); @@ -398,7 +398,7 @@ static void shootweapon(DDukeActor *actor, int p, int sx, int sy, int sz, int sa else { zvel += 128 - (krand() & 255); - sa = getangle(ps[j].posx - sx, ps[j].posy - sy) + 64 - (krand() & 127); + sa = getangle(ps[j].pos.x - sx, ps[j].pos.y - sy) + 64 - (krand() & 127); } } @@ -952,7 +952,7 @@ static void shootgrowspark(DDukeActor* actor, int p, int sx, int sy, int sz, int int x; int j = findplayer(actor, &x); sz -= (4 << 8); - zvel = ((ps[j].posz - sz) << 8) / (ldist(ps[j].GetActor(), actor)); + zvel = ((ps[j].pos.z - sz) << 8) / (ldist(ps[j].GetActor(), actor)); zvel += 128 - (krand() & 255); sa += 32 - (krand() & 63); } @@ -1020,9 +1020,9 @@ void shoot_d(DDukeActor* actor, int atwith) if (s->picnum == TILE_APLAYER) { - sx = ps[p].posx; - sy = ps[p].posy; - sz = ps[p].posz + ps[p].pyoff + (4 << 8); + sx = ps[p].pos.x; + sy = ps[p].pos.y; + sz = ps[p].pos.z + ps[p].pyoff + (4 << 8); sa = ps[p].angle.ang.asbuild(); ps[p].crack_time = CRACK_TIME; @@ -1680,7 +1680,7 @@ static void operateJetpack(int snum, ESyncBits actions, int psectlotag, int fz, if (p->jetpack_on < 11) { p->jetpack_on++; - p->posz -= (p->jetpack_on << 7); //Goin up + p->pos.z -= (p->jetpack_on << 7); //Goin up } else if (p->jetpack_on == 11 && !S_CheckActorSoundPlaying(pact, DUKE_JETPACK_IDLE)) S_PlayActorSound(DUKE_JETPACK_IDLE, pact); @@ -1695,7 +1695,7 @@ static void operateJetpack(int snum, ESyncBits actions, int psectlotag, int fz, OnEvent(EVENT_SOARUP, snum, p->GetActor(), -1); if (GetGameVarID(g_iReturnVarID, p->GetActor(), snum) == 0) { - p->posz -= j; + p->pos.z -= j; p->crack_time = CRACK_TIME; } } @@ -1707,7 +1707,7 @@ static void operateJetpack(int snum, ESyncBits actions, int psectlotag, int fz, OnEvent(EVENT_SOARDOWN, snum, p->GetActor(), -1); if (GetGameVarID(g_iReturnVarID, p->GetActor(), snum) == 0) { - p->posz += j; + p->pos.z += j; p->crack_time = CRACK_TIME; } } @@ -1719,10 +1719,10 @@ static void operateJetpack(int snum, ESyncBits actions, int psectlotag, int fz, if (psectlotag != 2 && p->scuba_on == 1) p->scuba_on = 0; - if (p->posz > (fz - (k << 8))) - p->posz += ((fz - (k << 8)) - p->posz) >> 1; - if (p->posz < (pact->ceilingz + (18 << 8))) - p->posz = pact->ceilingz + (18 << 8); + if (p->pos.z > (fz - (k << 8))) + p->pos.z += ((fz - (k << 8)) - p->pos.z) >> 1; + if (p->pos.z < (pact->ceilingz + (18 << 8))) + p->pos.z = pact->ceilingz + (18 << 8); } @@ -1776,12 +1776,12 @@ static void movement(int snum, ESyncBits actions, int psect, int fz, int cz, int footprints(snum); } - if (p->posz < (fz - (i << 8))) //falling + if (p->pos.z < (fz - (i << 8))) //falling { // not jumping or crouching - if ((actions & (SB_JUMP|SB_CROUCH)) == 0 && p->on_ground && (sector[psect].floorstat & 2) && p->posz >= (fz - (i << 8) - (16 << 8))) - p->posz = fz - (i << 8); + if ((actions & (SB_JUMP|SB_CROUCH)) == 0 && p->on_ground && (sector[psect].floorstat & 2) && p->pos.z >= (fz - (i << 8) - (16 << 8))) + p->pos.z = fz - (i << 8); else { p->on_ground = 0; @@ -1794,7 +1794,7 @@ static void movement(int snum, ESyncBits actions, int psect, int fz, int cz, int S_PlayActorSound(DUKE_SCREAM, pact); } - if ((p->posz + p->poszv) >= (fz - (i << 8))) // hit the ground + if ((p->pos.z + p->poszv) >= (fz - (i << 8))) // hit the ground { S_StopSound(DUKE_SCREAM, pact); if (sector[p->cursectnum].lotag != 1) @@ -1838,18 +1838,18 @@ static void movement(int snum, ESyncBits actions, int psect, int fz, int cz, int { //Smooth on the ground - int k = ((fz - (i << 8)) - p->posz) >> 1; + int k = ((fz - (i << 8)) - p->pos.z) >> 1; if (abs(k) < 256) k = 0; - p->posz += k; + p->pos.z += k; p->poszv -= 768; if (p->poszv < 0) p->poszv = 0; } else if (p->jumping_counter == 0) { - p->posz += ((fz - (i << 7)) - p->posz) >> 1; //Smooth on the water - if (p->on_warping_sector == 0 && p->posz > fz - (16 << 8)) + p->pos.z += ((fz - (i << 7)) - p->pos.z) >> 1; //Smooth on the water + if (p->on_warping_sector == 0 && p->pos.z > fz - (16 << 8)) { - p->posz = fz - (16 << 8); + p->pos.z = fz - (16 << 8); p->poszv >>= 1; } } @@ -1900,15 +1900,15 @@ static void movement(int snum, ESyncBits actions, int psect, int fz, int cz, int } } - p->posz += p->poszv; + p->pos.z += p->poszv; - if (p->posz < (cz + (4 << 8))) + if (p->pos.z < (cz + (4 << 8))) { p->jumping_counter = 0; if (p->poszv < 0) p->posxv = p->posyv = 0; p->poszv = 128; - p->posz = cz + (4 << 8); + p->pos.z = cz + (4 << 8); } } @@ -1968,14 +1968,14 @@ static void underwater(int snum, ESyncBits actions, int psect, int fz, int cz) if (p->poszv > 2048) p->poszv >>= 1; - p->posz += p->poszv; + p->pos.z += p->poszv; - if (p->posz > (fz - (15 << 8))) - p->posz += ((fz - (15 << 8)) - p->posz) >> 1; + if (p->pos.z > (fz - (15 << 8))) + p->pos.z += ((fz - (15 << 8)) - p->pos.z) >> 1; - if (p->posz < (cz + (4 << 8))) + if (p->pos.z < (cz + (4 << 8))) { - p->posz = cz + (4 << 8); + p->pos.z = cz + (4 << 8); p->poszv = 0; } @@ -1986,7 +1986,7 @@ static void underwater(int snum, ESyncBits actions, int psect, int fz, int cz) j->s->y += bsin(p->angle.ang.asbuild() + 64 - (global_random & 128), -6); j->s->xrepeat = 3; j->s->yrepeat = 2; - j->s->z = p->posz + (8 << 8); + j->s->z = p->pos.z + (8 << 8); } } @@ -2004,7 +2004,7 @@ int operateTripbomb(int snum) short sect, hw; DDukeActor* hitsprt; - hitscan(p->posx, p->posy, p->posz, + hitscan(p->pos.x, p->pos.y, p->pos.z, p->cursectnum, p->angle.ang.bcos(), p->angle.ang.bsin(), -p->horizon.sum().asq16() >> 11, §, &hw, &hitsprt, &sx, &sy, &sz, CLIPMASK1); @@ -2031,9 +2031,9 @@ int operateTripbomb(int snum) if (j == nullptr && hw >= 0 && (wall[hw].cstat & 16) == 0) if ((wall[hw].nextsector >= 0 && sector[wall[hw].nextsector].lotag <= 2) || (wall[hw].nextsector == -1 && sector[sect].lotag <= 2)) - if (((sx - p->posx) * (sx - p->posx) + (sy - p->posy) * (sy - p->posy)) < (290 * 290)) + if (((sx - p->pos.x) * (sx - p->pos.x) + (sy - p->pos.y) * (sy - p->pos.y)) < (290 * 290)) { - p->posz = p->oposz; + p->pos.z = p->oposz; p->poszv = 0; return 1; } @@ -2198,9 +2198,9 @@ static void operateweapon(int snum, ESyncBits actions, int psect) } auto spawned = EGS(p->cursectnum, - p->posx + p->angle.ang.bcos(-6), - p->posy + p->angle.ang.bsin(-6), - p->posz, HEAVYHBOMB, -16, 9, 9, + p->pos.x + p->angle.ang.bcos(-6), + p->pos.y + p->angle.ang.bsin(-6), + p->pos.z, HEAVYHBOMB, -16, 9, 9, p->angle.ang.asbuild(), (k + (p->hbomb_hold_delay << 5)), i, pact, 1); if (isNam()) @@ -2568,7 +2568,7 @@ static void operateweapon(int snum, ESyncBits actions, int psect) case TRIPBOMB_WEAPON: // Claymore in NAM if (p->kickback_pic < 4) { - p->posz = p->oposz; + p->pos.z = p->oposz; p->poszv = 0; if (p->kickback_pic == 3) fi.shoot(pact, HANDHOLDINGLASER); @@ -2735,14 +2735,14 @@ void processinput_d(int snum) p->spritebridge = 0; shrunk = (s->yrepeat < 32); - getzrange_ex(p->posx, p->posy, p->posz, psect, &cz, chz, &fz, clz, 163L, CLIPMASK0); + getzrange_ex(p->pos.x, p->pos.y, p->pos.z, psect, &cz, chz, &fz, clz, 163L, CLIPMASK0); - j = getflorzofslope(psect, p->posx, p->posy); + j = getflorzofslope(psect, p->pos.x, p->pos.y); p->truefz = j; - p->truecz = getceilzofslope(psect, p->posx, p->posy); + p->truecz = getceilzofslope(psect, p->pos.x, p->pos.y); - truefdist = abs(p->posz - j); + truefdist = abs(p->pos.z - j); if (clz.type == kHitSector && psectlotag == 1 && truefdist > gs.playerheight + (16 << 8)) psectlotag = 0; @@ -2775,7 +2775,7 @@ void processinput_d(int snum) } else if (badguy(clz.actor) && clz.actor->s->xrepeat > 24 && abs(s->z - clz.actor->s->z) < (84 << 8)) { - j = getangle(clz.actor->s->x - p->posx, clz.actor->s->y - p->posy); + j = getangle(clz.actor->s->x - p->pos.x, clz.actor->s->y - p->pos.y); p->posxv -= bcos(j, 4); p->posyv -= bsin(j, 4); } @@ -2841,7 +2841,7 @@ void processinput_d(int snum) p->playerweaponsway(s->xvel); - s->xvel = clamp(ksqrt((p->posx - p->bobposx) * (p->posx - p->bobposx) + (p->posy - p->bobposy) * (p->posy - p->bobposy)), 0, 512); + s->xvel = clamp(ksqrt((p->pos.x - p->bobposx) * (p->pos.x - p->bobposx) + (p->pos.y - p->bobposy) * (p->pos.y - p->bobposy)), 0, 512); if (p->on_ground) p->bobcounter += p->GetActor()->s->xvel >> 1; p->backuppos(ud.clipping == 0 && (sector[p->cursectnum].floorpicnum == MIRROR || p->cursectnum < 0 || p->cursectnum >= MAXSECTORS)); @@ -3012,18 +3012,18 @@ HORIZONLY: Collision clip{}; if (ud.clipping) { - p->posx += p->posxv >> 14; - p->posy += p->posyv >> 14; - updatesector(p->posx, p->posy, &p->cursectnum); + p->pos.x += p->posxv >> 14; + p->pos.y += p->posyv >> 14; + updatesector(p->pos.x, p->pos.y, &p->cursectnum); changeactorsect(pact, p->cursectnum); } else - clipmove_ex(&p->posx, &p->posy, - &p->posz, &p->cursectnum, + clipmove_ex(&p->pos.x, &p->pos.y, + &p->pos.z, &p->cursectnum, p->posxv, p->posyv, 164L, (4L << 8), ii, CLIPMASK0, clip); if (p->jetpack_on == 0 && psectlotag != 2 && psectlotag != 1 && shrunk) - p->posz += 32 << 8; + p->pos.z += 32 << 8; if (clip.type != kHitNone) checkplayerhurt_d(p, clip); @@ -3044,7 +3044,7 @@ HORIZONLY: } // RBG*** - setsprite(pact, p->posx, p->posy, p->posz + gs.playerheight); + setsprite(pact, p->pos.x, p->pos.y, p->pos.z + gs.playerheight); if (psectlotag < 3) { @@ -3068,7 +3068,7 @@ HORIZONLY: changeactorsect(pact, p->cursectnum); if (ud.clipping == 0) - j = (pushmove(&p->posx, &p->posy, &p->posz, &p->cursectnum, 164L, (4L << 8), (4L << 8), CLIPMASK0) < 0 && furthestangle(p->GetActor(), 8) < 512); + j = (pushmove(&p->pos.x, &p->pos.y, &p->pos.z, &p->cursectnum, 164L, (4L << 8), (4L << 8), CLIPMASK0) < 0 && furthestangle(p->GetActor(), 8) < 512); else j = 0; if (ud.clipping == 0) diff --git a/source/games/duke/src/player_r.cpp b/source/games/duke/src/player_r.cpp index 886115340..e0abf909e 100644 --- a/source/games/duke/src/player_r.cpp +++ b/source/games/duke/src/player_r.cpp @@ -251,7 +251,7 @@ static void shootweapon(DDukeActor* actor, int p, int sx, int sy, int sz, int sa int x; int j = findplayer(actor, &x); sz -= (4 << 8); - zvel = ((ps[j].posz - sz) << 8) / (ldist(ps[j].GetActor(), actor)); + zvel = ((ps[j].pos.z - sz) << 8) / (ldist(ps[j].GetActor(), actor)); if (s->picnum != BOSS1) { zvel += 128 - (krand() & 255); @@ -260,7 +260,7 @@ static void shootweapon(DDukeActor* actor, int p, int sx, int sy, int sz, int sa else { zvel += 128 - (krand() & 255); - sa = getangle(ps[j].posx - sx, ps[j].posy - sy) + 64 - (krand() & 127); + sa = getangle(ps[j].pos.x - sx, ps[j].pos.y - sy) + 64 - (krand() & 127); } } @@ -840,9 +840,9 @@ void shoot_r(DDukeActor* actor, int atwith) { p = s->yvel; - sx = ps[p].posx; - sy = ps[p].posy; - sz = ps[p].posz + ps[p].pyoff + (4 << 8); + sx = ps[p].pos.x; + sy = ps[p].pos.y; + sz = ps[p].pos.z + ps[p].pyoff + (4 << 8); sa = ps[p].angle.ang.asbuild(); if (isRRRA()) ps[p].crack_time = CRACK_TIME; @@ -2101,15 +2101,15 @@ static void movement(int snum, ESyncBits actions, int psect, int fz, int cz, int footprints(snum); } - if (p->posz < (fz - (i << 8))) //falling + if (p->pos.z < (fz - (i << 8))) //falling { - if ((actions & (SB_JUMP|SB_CROUCH)) == 0 && p->on_ground && (sector[psect].floorstat & 2) && p->posz >= (fz - (i << 8) - (16 << 8))) - p->posz = fz - (i << 8); + if ((actions & (SB_JUMP|SB_CROUCH)) == 0 && p->on_ground && (sector[psect].floorstat & 2) && p->pos.z >= (fz - (i << 8) - (16 << 8))) + p->pos.z = fz - (i << 8); else { p->on_ground = 0; - if ((p->OnMotorcycle || p->OnBoat) && fz - (i << 8) * 2 > p->posz) + if ((p->OnMotorcycle || p->OnBoat) && fz - (i << 8) * 2 > p->pos.z) { if (p->MotoOnGround) { @@ -2139,7 +2139,7 @@ static void movement(int snum, ESyncBits actions, int psect, int fz, int cz, int S_PlayActorSound(DUKE_SCREAM, pact); } - if ((p->posz + p->poszv) >= (fz - (i << 8))) // hit the ground + if ((p->pos.z + p->poszv) >= (fz - (i << 8))) // hit the ground { S_StopSound(DUKE_SCREAM, pact); if (sector[p->cursectnum].lotag != 1) @@ -2199,18 +2199,18 @@ static void movement(int snum, ESyncBits actions, int psect, int fz, int cz, int { //Smooth on the ground - int k = ((fz - (i << 8)) - p->posz) >> 1; + int k = ((fz - (i << 8)) - p->pos.z) >> 1; if (abs(k) < 256) k = 0; - p->posz += k; + p->pos.z += k; p->poszv -= 768; if (p->poszv < 0) p->poszv = 0; } else if (p->jumping_counter == 0) { - p->posz += ((fz - (i << 7)) - p->posz) >> 1; //Smooth on the water - if (p->on_warping_sector == 0 && p->posz > fz - (16 << 8)) + p->pos.z += ((fz - (i << 7)) - p->pos.z) >> 1; //Smooth on the water + if (p->on_warping_sector == 0 && p->pos.z > fz - (16 << 8)) { - p->posz = fz - (16 << 8); + p->pos.z = fz - (16 << 8); p->poszv >>= 1; } } @@ -2257,15 +2257,15 @@ static void movement(int snum, ESyncBits actions, int psect, int fz, int cz, int } } - p->posz += p->poszv; + p->pos.z += p->poszv; - if (p->posz < (cz + (4 << 8))) + if (p->pos.z < (cz + (4 << 8))) { p->jumping_counter = 0; if (p->poszv < 0) p->posxv = p->posyv = 0; p->poszv = 128; - p->posz = cz + (4 << 8); + p->pos.z = cz + (4 << 8); } } @@ -2321,14 +2321,14 @@ static void underwater(int snum, ESyncBits actions, int psect, int fz, int cz) if (p->poszv > 2048) p->poszv >>= 1; - p->posz += p->poszv; + p->pos.z += p->poszv; - if (p->posz > (fz - (15 << 8))) - p->posz += ((fz - (15 << 8)) - p->posz) >> 1; + if (p->pos.z > (fz - (15 << 8))) + p->pos.z += ((fz - (15 << 8)) - p->pos.z) >> 1; - if (p->posz < (cz + (4 << 8))) + if (p->pos.z < (cz + (4 << 8))) { - p->posz = cz + (4 << 8); + p->pos.z = cz + (4 << 8); p->poszv = 0; } @@ -2339,7 +2339,7 @@ static void underwater(int snum, ESyncBits actions, int psect, int fz, int cz) j->s->y += bsin(p->angle.ang.asbuild() + 64 - (global_random & 128) + 128, -6); j->s->xrepeat = 3; j->s->yrepeat = 2; - j->s->z = p->posz + (8 << 8); + j->s->z = p->pos.z + (8 << 8); j->s->cstat = 514; } } @@ -2735,9 +2735,9 @@ static void operateweapon(int snum, ESyncBits actions, int psect) } auto spawned = EGS(p->cursectnum, - p->posx + p->angle.ang.bcos(-6), - p->posy + p->angle.ang.bsin(-6), - p->posz, HEAVYHBOMB, -16, 9, 9, + p->pos.x + p->angle.ang.bcos(-6), + p->pos.y + p->angle.ang.bsin(-6), + p->pos.z, HEAVYHBOMB, -16, 9, 9, p->angle.ang.asbuild(), (k + (p->hbomb_hold_delay << 5)) * 2, i, pact, 1); if (k == 15) @@ -3145,9 +3145,9 @@ static void operateweapon(int snum, ESyncBits actions, int psect) } EGS(p->cursectnum, - p->posx + p->angle.ang.bcos(-6), - p->posy + p->angle.ang.bsin(-6), - p->posz, TRIPBOMBSPRITE, -16, 9, 9, + p->pos.x + p->angle.ang.bcos(-6), + p->pos.y + p->angle.ang.bsin(-6), + p->pos.z, TRIPBOMBSPRITE, -16, 9, 9, p->angle.ang.asbuild(), k * 2, i, pact, 1); } p->kickback_pic++; @@ -3372,7 +3372,7 @@ void processinput_r(int snum) while (auto act2 = it.Next()) { if (act2->s->picnum == RRTILE380) - if (act2->s->z - (8 << 8) < p->posz) + if (act2->s->z - (8 << 8) < p->pos.z) psectlotag = 2; } } @@ -3393,19 +3393,19 @@ void processinput_r(int snum) int tempfz; if (s->clipdist == 64) { - getzrange_ex(p->posx, p->posy, p->posz, psect, &cz, chz, &fz, clz, 163L, CLIPMASK0); - tempfz = getflorzofslope(psect, p->posx, p->posy); + getzrange_ex(p->pos.x, p->pos.y, p->pos.z, psect, &cz, chz, &fz, clz, 163L, CLIPMASK0); + tempfz = getflorzofslope(psect, p->pos.x, p->pos.y); } else { - getzrange_ex(p->posx, p->posy, p->posz, psect, &cz, chz, &fz, clz, 4L, CLIPMASK0); - tempfz = getflorzofslope(psect, p->posx, p->posy); + getzrange_ex(p->pos.x, p->pos.y, p->pos.z, psect, &cz, chz, &fz, clz, 4L, CLIPMASK0); + tempfz = getflorzofslope(psect, p->pos.x, p->pos.y); } p->truefz = tempfz; - p->truecz = getceilzofslope(psect, p->posx, p->posy); + p->truecz = getceilzofslope(psect, p->pos.x, p->pos.y); - truefdist = abs(p->posz - tempfz); + truefdist = abs(p->pos.z - tempfz); if (clz.type == kHitSector && psectlotag == 1 && truefdist > gs.playerheight + (16 << 8)) psectlotag = 0; @@ -3469,7 +3469,7 @@ void processinput_r(int snum) } else if (badguy(clz.actor) && clz.actor->s->xrepeat > 24 && abs(s->z - clz.actor->s->z) < (84 << 8)) { - int j = getangle(clz.actor->s->x - p->posx, clz.actor->s->y - p->posy); + int j = getangle(clz.actor->s->x - p->pos.x, clz.actor->s->y - p->pos.y); p->posxv -= bcos(j, 4); p->posyv -= bsin(j, 4); } @@ -3560,7 +3560,7 @@ void processinput_r(int snum) p->playerweaponsway(s->xvel); - s->xvel = clamp(ksqrt((p->posx - p->bobposx) * (p->posx - p->bobposx) + (p->posy - p->bobposy) * (p->posy - p->bobposy)), 0, 512); + s->xvel = clamp(ksqrt((p->pos.x - p->bobposx) * (p->pos.x - p->bobposx) + (p->pos.y - p->bobposy) * (p->pos.y - p->bobposy)), 0, 512); if (p->on_ground) p->bobcounter += p->GetActor()->s->xvel >> 1; p->backuppos(ud.clipping == 0 && (sector[p->cursectnum].floorpicnum == MIRROR || p->cursectnum < 0 || p->cursectnum >= MAXSECTORS)); @@ -3775,18 +3775,18 @@ HORIZONLY: Collision clip{}; if (ud.clipping) { - p->posx += p->posxv >> 14; - p->posy += p->posyv >> 14; - updatesector(p->posx, p->posy, &p->cursectnum); + p->pos.x += p->posxv >> 14; + p->pos.y += p->posyv >> 14; + updatesector(p->pos.x, p->pos.y, &p->cursectnum); changeactorsect(pact, p->cursectnum); } else - clipmove_ex(&p->posx, &p->posy, - &p->posz, &p->cursectnum, + clipmove_ex(&p->pos.x, &p->pos.y, + &p->pos.z, &p->cursectnum, p->posxv, p->posyv, 164L, (4L << 8), i, CLIPMASK0, clip); if (p->jetpack_on == 0 && psectlotag != 2 && psectlotag != 1 && shrunk) - p->posz += 32 << 8; + p->pos.z += 32 << 8; if (clip.type != kHitNone) checkplayerhurt_r(p, clip); @@ -3813,10 +3813,10 @@ HORIZONLY: if (wall[clip.index].lotag < 44) { dofurniture(clip.index, p->cursectnum, snum); - pushmove(&p->posx, &p->posy, &p->posz, &p->cursectnum, 172L, (4L << 8), (4L << 8), CLIPMASK0); + pushmove(&p->pos.x, &p->pos.y, &p->pos.z, &p->cursectnum, 172L, (4L << 8), (4L << 8), CLIPMASK0); } else - pushmove(&p->posx, &p->posy, &p->posz, &p->cursectnum, 172L, (4L << 8), (4L << 8), CLIPMASK0); + pushmove(&p->pos.x, &p->pos.y, &p->pos.z, &p->cursectnum, 172L, (4L << 8), (4L << 8), CLIPMASK0); } } } @@ -3881,7 +3881,7 @@ HORIZONLY: } // RBG*** - setsprite(pact, p->posx, p->posy, p->posz + gs.playerheight); + setsprite(pact, p->pos.x, p->pos.y, p->pos.z + gs.playerheight); if (psectlotag == 800 && (!isRRRA() || !p->lotag800kill)) { @@ -3916,9 +3916,9 @@ HORIZONLY: if (ud.clipping == 0) { if (s->clipdist == 64) - j = (pushmove(&p->posx, &p->posy, &p->posz, &p->cursectnum, 128L, (4L << 8), (4L << 8), CLIPMASK0) < 0 && furthestangle(p->GetActor(), 8) < 512); + j = (pushmove(&p->pos.x, &p->pos.y, &p->pos.z, &p->cursectnum, 128L, (4L << 8), (4L << 8), CLIPMASK0) < 0 && furthestangle(p->GetActor(), 8) < 512); else - j = (pushmove(&p->posx, &p->posy, &p->posz, &p->cursectnum, 16L, (4L << 8), (4L << 8), CLIPMASK0) < 0 && furthestangle(p->GetActor(), 8) < 512); + j = (pushmove(&p->pos.x, &p->pos.y, &p->pos.z, &p->cursectnum, 16L, (4L << 8), (4L << 8), CLIPMASK0) < 0 && furthestangle(p->GetActor(), 8) < 512); } else j = 0; @@ -4047,8 +4047,8 @@ void OnMotorcycle(struct player_struct *p, DDukeActor* motosprite) { if (motosprite) { - p->posx = motosprite->s->x; - p->posy = motosprite->s->y; + p->pos.x = motosprite->s->x; + p->pos.y = motosprite->s->y; p->angle.ang = buildang(motosprite->s->ang); p->ammo_amount[MOTORCYCLE_WEAPON] = motosprite->saved_ammo; deletesprite(motosprite); @@ -4124,8 +4124,8 @@ void OnBoat(struct player_struct *p, DDukeActor* boat) { if (boat) { - p->posx = boat->s->x; - p->posy = boat->s->y; + p->pos.x = boat->s->x; + p->pos.y = boat->s->y; p->angle.ang = buildang(boat->s->ang); p->ammo_amount[BOAT_WEAPON] = boat->saved_ammo; deletesprite(boat); diff --git a/source/games/duke/src/player_w.cpp b/source/games/duke/src/player_w.cpp index f34758efa..73ba08542 100644 --- a/source/games/duke/src/player_w.cpp +++ b/source/games/duke/src/player_w.cpp @@ -342,9 +342,9 @@ void operateweapon_ww(int snum, ESyncBits actions, int psect) } auto j = EGS(p->cursectnum, - p->posx + p->angle.ang.bcos(-6), - p->posy + p->angle.ang.bsin(-6), - p->posz, HEAVYHBOMB, -16, 9, 9, + p->pos.x + p->angle.ang.bcos(-6), + p->pos.y + p->angle.ang.bsin(-6), + p->pos.z, HEAVYHBOMB, -16, 9, 9, p->angle.ang.asbuild(), (k + (p->hbomb_hold_delay << 5)), i, p->GetActor(), 1); { @@ -436,7 +436,7 @@ void operateweapon_ww(int snum, ESyncBits actions, int psect) if (aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FLAG_STANDSTILL && p->kickback_pic < (aplWeaponFireDelay[p->curr_weapon][snum] + 1)) { - p->posz = p->oposz; + p->pos.z = p->oposz; p->poszv = 0; } if (p->kickback_pic == aplWeaponSound2Time[p->curr_weapon][snum]) diff --git a/source/games/duke/src/prediction.cpp b/source/games/duke/src/prediction.cpp index 799ed9aa8..02cfa563a 100644 --- a/source/games/duke/src/prediction.cpp +++ b/source/games/duke/src/prediction.cpp @@ -50,9 +50,9 @@ short myangbak[MOVEFIFOSIZ]; void resetmys() { - myx = omyx = ps[myconnectindex].posx; - myy = omyy = ps[myconnectindex].posy; - myz = omyz = ps[myconnectindex].posz; + myx = omyx = ps[myconnectindex].pos.x; + myy = omyy = ps[myconnectindex].pos.y; + myz = omyz = ps[myconnectindex].pos.z; myxvel = myyvel = myzvel = 0; myang = myang = ps[myconnectindex].angle.ang; myhoriz = omyhoriz = ps[myconnectindex].horizon.horiz; @@ -75,12 +75,12 @@ void fakedomovethingscorrect(void) i = ((movefifoplc-1)&(MOVEFIFOSIZ-1)); p = &ps[myconnectindex]; - if (p->posx == myxbak[i] && p->posy == myybak[i] && p->posz == myzbak[i] + if (p->pos.x == myxbak[i] && p->pos.y == myybak[i] && p->pos.z == myzbak[i] && p->horiz == myhorizbak[i] && p->ang == myangbak[i]) return; - myx = p->posx; omyx = p->oposx; myxvel = p->posxv; - myy = p->posy; omyy = p->oposy; myyvel = p->posyv; - myz = p->posz; omyz = p->oposz; myzvel = p->poszv; + myx = p->pos.x; omyx = p->oposx; myxvel = p->posxv; + myy = p->pos.y; omyy = p->oposy; myyvel = p->posyv; + myz = p->pos.z; omyz = p->oposz; myzvel = p->poszv; myang = p->ang; omyang = p->oang; mycursectnum = p->cursectnum; myhoriz = p->horiz; omyhoriz = p->ohoriz; diff --git a/source/games/duke/src/premap.cpp b/source/games/duke/src/premap.cpp index 2ab4edd2b..4a099c5f3 100644 --- a/source/games/duke/src/premap.cpp +++ b/source/games/duke/src/premap.cpp @@ -60,9 +60,9 @@ void pickrandomspot(int snum) i = krand()%numplayersprites; else i = snum; - p->bobposx = p->oposx = p->posx = po[i].ox; - p->bobposy = p->oposy = p->posy = po[i].oy; - p->oposz = p->posz = po[i].oz; + p->bobposx = p->oposx = p->pos.x = po[i].ox; + p->bobposy = p->oposy = p->pos.y = po[i].oy; + p->oposz = p->pos.z = po[i].oz; p->angle.oang = p->angle.ang = buildang(po[i].oa); p->cursectnum = po[i].os; } @@ -507,7 +507,7 @@ void resetpspritevars(int g) int aimmode[MAXPLAYERS]; STATUSBARTYPE tsbar[MAXPLAYERS]; - EGS(ps[0].cursectnum, ps[0].posx, ps[0].posy, ps[0].posz, + EGS(ps[0].cursectnum, ps[0].pos.x, ps[0].pos.y, ps[0].pos.z, TILE_APLAYER, 0, 0, 0, ps[0].angle.ang.asbuild(), 0, 0, nullptr, 10); if (ud.recstat != 2) for (i = 0; i < MAXPLAYERS; i++) @@ -579,8 +579,8 @@ void resetpspritevars(int g) if (numplayersprites == 0) { - firstx = ps[0].posx; - firsty = ps[0].posy; + firstx = ps[0].pos.x; + firsty = ps[0].pos.y; } po[numplayersprites].ox = s->x; @@ -627,9 +627,9 @@ void resetpspritevars(int g) ps[j].frag_ps = j; act->SetOwner(act); - ps[j].bobposx = ps[j].oposx = ps[j].posx = s->x; - ps[j].bobposy = ps[j].oposy = ps[j].posy = s->y; - ps[j].oposz = ps[j].posz = s->z; + ps[j].bobposx = ps[j].oposx = ps[j].pos.x = s->x; + ps[j].bobposy = ps[j].oposy = ps[j].pos.y = s->y; + ps[j].oposz = ps[j].pos.z = s->z; s->backuppos(); ps[j].angle.oang = ps[j].angle.ang = buildang(s->ang); diff --git a/source/games/duke/src/render.cpp b/source/games/duke/src/render.cpp index b3f170c86..0aae20676 100644 --- a/source/games/duke/src/render.cpp +++ b/source/games/duke/src/render.cpp @@ -334,9 +334,9 @@ void displayrooms(int snum, double smoothratio) } else { - cposx = interpolatedvalue(p->oposx, p->posx, smoothratio); - cposy = interpolatedvalue(p->oposy, p->posy, smoothratio); - cposz = interpolatedvalue(p->oposz, p->posz, smoothratio);; + cposx = interpolatedvalue(p->oposx, p->pos.x, smoothratio); + cposy = interpolatedvalue(p->oposy, p->pos.y, smoothratio); + cposz = interpolatedvalue(p->oposz, p->pos.z, smoothratio);; if (SyncInput()) { // Original code for when the values are passed through the sync struct diff --git a/source/games/duke/src/savegame.cpp b/source/games/duke/src/savegame.cpp index f99f049db..7eef2795b 100644 --- a/source/games/duke/src/savegame.cpp +++ b/source/games/duke/src/savegame.cpp @@ -84,9 +84,9 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, player_struct& w, { if (arc.BeginObject(keyname)) { - arc("posx", w.posx) - ("posy", w.posy) - ("posz", w.posz) + arc("posx", w.pos.x) + ("posy", w.pos.y) + ("posz", w.pos.z) ("angle", w.angle) ("horizon", w.horizon) .Array("gotweapon", w.gotweapon, MAX_WEAPONS) @@ -253,9 +253,9 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, player_struct& w, .EndObject(); w.invdisptime = 0; - w.oposx = w.posx; - w.oposy = w.posy; - w.oposz = w.posz; + w.oposx = w.pos.x; + w.oposy = w.pos.y; + w.oposz = w.pos.z; w.opyoff = w.pyoff; w.oweapon_sway = w.weapon_sway; w.oweapon_pos = w.weapon_pos; diff --git a/source/games/duke/src/sectors.cpp b/source/games/duke/src/sectors.cpp index 844e63ce3..60bb6ce33 100644 --- a/source/games/duke/src/sectors.cpp +++ b/source/games/duke/src/sectors.cpp @@ -258,7 +258,7 @@ int findotherplayer(int p, int* d) for (j = connecthead; j >= 0; j = connectpoint2[j]) if (p != j && ps[j].GetActor()->s->extra > 0) { - x = abs(ps[j].oposx - ps[p].posx) + abs(ps[j].oposy - ps[p].posy) + (abs(ps[j].oposz - ps[p].posz) >> 4); + x = abs(ps[j].oposx - ps[p].pos.x) + abs(ps[j].oposy - ps[p].pos.y) + (abs(ps[j].oposz - ps[p].pos.z) >> 4); if (x < closest) { @@ -344,10 +344,10 @@ void doanimations(void) { for (p = connecthead; p >= 0; p = connectpoint2[p]) if (ps[p].cursectnum == dasect) - if ((sector[dasect].floorz - ps[p].posz) < (64 << 8)) + if ((sector[dasect].floorz - ps[p].pos.z) < (64 << 8)) if (ps[p].GetActor()->GetOwner() != nullptr) { - ps[p].posz += v; + ps[p].pos.z += v; ps[p].poszv = 0; } diff --git a/source/games/duke/src/sectors_d.cpp b/source/games/duke/src/sectors_d.cpp index 520d9f25c..ab34828d9 100644 --- a/source/games/duke/src/sectors_d.cpp +++ b/source/games/duke/src/sectors_d.cpp @@ -481,7 +481,7 @@ bool checkhitswitch_d(int snum, int ww, DDukeActor *act) return 1; } - vec3_t v = { sx, sy, ps[snum].posz }; + vec3_t v = { sx, sy, ps[snum].pos.z }; switch (picnum) { default: @@ -925,18 +925,18 @@ void checkplayerhurt_d(struct player_struct* p, const Collision& coll) S_PlayActorSound(DUKE_LONGTERM_PAIN, p->GetActor()); fi.checkhitwall(p->GetActor(), j, - p->posx + p->angle.ang.bcos(-9), - p->posy + p->angle.ang.bsin(-9), - p->posz, -1); + p->pos.x + p->angle.ang.bcos(-9), + p->pos.y + p->angle.ang.bsin(-9), + p->pos.z, -1); break; case BIGFORCE: p->hurt_delay = 26; fi.checkhitwall(p->GetActor(), j, - p->posx + p->angle.ang.bcos(-9), - p->posy + p->angle.ang.bsin(-9), - p->posz, -1); + p->pos.x + p->angle.ang.bcos(-9), + p->pos.y + p->angle.ang.bsin(-9), + p->pos.z, -1); break; } @@ -1454,12 +1454,12 @@ void checkhitsprite_d(DDukeActor* targ, DDukeActor* proj) if (ps[p].newOwner != nullptr) { ps[p].newOwner = nullptr; - ps[p].posx = ps[p].oposx; - ps[p].posy = ps[p].oposy; - ps[p].posz = ps[p].oposz; + ps[p].pos.x = ps[p].oposx; + ps[p].pos.y = ps[p].oposy; + ps[p].pos.z = ps[p].oposz; ps[p].angle.restore(); - updatesector(ps[p].posx, ps[p].posy, &ps[p].cursectnum); + updatesector(ps[p].pos.x, ps[p].pos.y, &ps[p].cursectnum); DukeStatIterator it(STAT_ACTOR); while (auto j = it.Next()) @@ -1582,14 +1582,14 @@ void checksectors_d(int snum) neartag(p->oposx, p->oposy, p->oposz, p->GetActor()->s->sectnum, p->angle.oang.asbuild(), &neartagsector, &neartagwall, &neartagsprite, &neartaghitdist, 1280L, 1); else { - neartag(p->posx, p->posy, p->posz, p->GetActor()->s->sectnum, p->angle.oang.asbuild(), &neartagsector, &neartagwall, &neartagsprite, &neartaghitdist, 1280L, 1); + neartag(p->pos.x, p->pos.y, p->pos.z, p->GetActor()->s->sectnum, p->angle.oang.asbuild(), &neartagsector, &neartagwall, &neartagsprite, &neartaghitdist, 1280L, 1); if (neartagsprite == nullptr && neartagwall == -1 && neartagsector == -1) - neartag(p->posx, p->posy, p->posz + (8 << 8), p->GetActor()->s->sectnum, p->angle.oang.asbuild(), &neartagsector, &neartagwall, &neartagsprite, &neartaghitdist, 1280L, 1); + neartag(p->pos.x, p->pos.y, p->pos.z + (8 << 8), p->GetActor()->s->sectnum, p->angle.oang.asbuild(), &neartagsector, &neartagwall, &neartagsprite, &neartaghitdist, 1280L, 1); if (neartagsprite == nullptr && neartagwall == -1 && neartagsector == -1) - neartag(p->posx, p->posy, p->posz + (16 << 8), p->GetActor()->s->sectnum, p->angle.oang.asbuild(), &neartagsector, &neartagwall, &neartagsprite, &neartaghitdist, 1280L, 1); + neartag(p->pos.x, p->pos.y, p->pos.z + (16 << 8), p->GetActor()->s->sectnum, p->angle.oang.asbuild(), &neartagsector, &neartagwall, &neartagsprite, &neartaghitdist, 1280L, 1); if (neartagsprite == nullptr && neartagwall == -1 && neartagsector == -1) { - neartag(p->posx, p->posy, p->posz + (16 << 8), p->GetActor()->s->sectnum, p->angle.oang.asbuild(), &neartagsector, &neartagwall, &neartagsprite, &neartaghitdist, 1280L, 3); + neartag(p->pos.x, p->pos.y, p->pos.z + (16 << 8), p->GetActor()->s->sectnum, p->angle.oang.asbuild(), &neartagsector, &neartagwall, &neartagsprite, &neartaghitdist, 1280L, 3); if (neartagsprite != nullptr) { switch (neartagsprite->s->picnum) @@ -1731,12 +1731,12 @@ void checksectors_d(int snum) if (i < 0) { - p->posx = p->oposx; - p->posy = p->oposy; - p->posz = p->oposz; + p->pos.x = p->oposx; + p->pos.y = p->oposy; + p->pos.z = p->oposz; p->newOwner = nullptr; - updatesector(p->posx, p->posy, &p->cursectnum); + updatesector(p->pos.x, p->pos.y, &p->cursectnum); DukeStatIterator it(STAT_ACTOR); while (auto act = it.Next()) diff --git a/source/games/duke/src/sectors_r.cpp b/source/games/duke/src/sectors_r.cpp index 67eec8369..68a8ade0e 100644 --- a/source/games/duke/src/sectors_r.cpp +++ b/source/games/duke/src/sectors_r.cpp @@ -681,7 +681,7 @@ bool checkhitswitch_r(int snum, int ww, DDukeActor* act) setnextmap(false); } - vec3_t v = { sx, sy, ps[snum].posz }; + vec3_t v = { sx, sy, ps[snum].pos.z }; switch (picnum) { default: @@ -1416,9 +1416,9 @@ void checkplayerhurt_r(struct player_struct* p, const Collision &coll) case BIGFORCE: p->hurt_delay = 26; fi.checkhitwall(p->GetActor(), j, - p->posx + p->angle.ang.bcos(-9), - p->posy + p->angle.ang.bsin(-9), - p->posz, -1); + p->pos.x + p->angle.ang.bcos(-9), + p->pos.y + p->angle.ang.bsin(-9), + p->pos.z, -1); break; } @@ -2403,11 +2403,11 @@ void checkhitsprite_r(DDukeActor* targ, DDukeActor* proj) if (ps[p].newOwner != nullptr) { ps[p].newOwner = nullptr; - ps[p].posx = ps[p].oposx; - ps[p].posy = ps[p].oposy; - ps[p].posz = ps[p].oposz; + ps[p].pos.x = ps[p].oposx; + ps[p].pos.y = ps[p].oposy; + ps[p].pos.z = ps[p].oposz; - updatesector(ps[p].posx, ps[p].posy, &ps[p].cursectnum); + updatesector(ps[p].pos.x, ps[p].pos.y, &ps[p].cursectnum); DukeStatIterator it(STAT_EFFECTOR); while (auto act = it.Next()) @@ -2553,21 +2553,21 @@ void checksectors_r(int snum) } return; } - neartag(p->posx, p->posy, p->posz, p->GetActor()->s->sectnum, p->angle.oang.asbuild(), &neartagsector, &neartagwall, &neartagsprite, &neartaghitdist, 1280L, 3); + neartag(p->pos.x, p->pos.y, p->pos.z, p->GetActor()->s->sectnum, p->angle.oang.asbuild(), &neartagsector, &neartagwall, &neartagsprite, &neartaghitdist, 1280L, 3); } if (p->newOwner != nullptr) neartag(p->oposx, p->oposy, p->oposz, p->GetActor()->s->sectnum, p->angle.oang.asbuild(), &neartagsector, &neartagwall, &neartagsprite, &neartaghitdist, 1280L, 1); else { - neartag(p->posx, p->posy, p->posz, p->GetActor()->s->sectnum, p->angle.oang.asbuild(), &neartagsector, &neartagwall, &neartagsprite, &neartaghitdist, 1280L, 1); + neartag(p->pos.x, p->pos.y, p->pos.z, p->GetActor()->s->sectnum, p->angle.oang.asbuild(), &neartagsector, &neartagwall, &neartagsprite, &neartaghitdist, 1280L, 1); if (neartagsprite == nullptr && neartagwall == -1 && neartagsector == -1) - neartag(p->posx, p->posy, p->posz + (8 << 8), p->GetActor()->s->sectnum, p->angle.oang.asbuild(), &neartagsector, &neartagwall, &neartagsprite, &neartaghitdist, 1280L, 1); + neartag(p->pos.x, p->pos.y, p->pos.z + (8 << 8), p->GetActor()->s->sectnum, p->angle.oang.asbuild(), &neartagsector, &neartagwall, &neartagsprite, &neartaghitdist, 1280L, 1); if (neartagsprite == nullptr && neartagwall == -1 && neartagsector == -1) - neartag(p->posx, p->posy, p->posz + (16 << 8), p->GetActor()->s->sectnum, p->angle.oang.asbuild(), &neartagsector, &neartagwall, &neartagsprite, &neartaghitdist, 1280L, 1); + neartag(p->pos.x, p->pos.y, p->pos.z + (16 << 8), p->GetActor()->s->sectnum, p->angle.oang.asbuild(), &neartagsector, &neartagwall, &neartagsprite, &neartaghitdist, 1280L, 1); if (neartagsprite == nullptr && neartagwall == -1 && neartagsector == -1) { - neartag(p->posx, p->posy, p->posz + (16 << 8), p->GetActor()->s->sectnum, p->angle.oang.asbuild(), &neartagsector, &neartagwall, &neartagsprite, &neartaghitdist, 1280L, 3); + neartag(p->pos.x, p->pos.y, p->pos.z + (16 << 8), p->GetActor()->s->sectnum, p->angle.oang.asbuild(), &neartagsector, &neartagwall, &neartagsprite, &neartaghitdist, 1280L, 3); if (neartagsprite != nullptr) { switch (neartagsprite->s->picnum) diff --git a/source/games/duke/src/spawn.cpp b/source/games/duke/src/spawn.cpp index 1c909aaa7..e8206d2af 100644 --- a/source/games/duke/src/spawn.cpp +++ b/source/games/duke/src/spawn.cpp @@ -444,7 +444,7 @@ void initshell(DDukeActor* actj, DDukeActor* acti, bool isshell) a = ps[snum].angle.ang.asbuild() - (krand() & 63) + 8; //Fine tune t[0] = krand() & 1; - sp->z = (3 << 8) + ps[snum].pyoff + ps[snum].posz - (ps[snum].horizon.sum().asq16() >> 12) + (!isshell ? (3 << 8) : 0); + sp->z = (3 << 8) + ps[snum].pyoff + ps[snum].pos.z - (ps[snum].horizon.sum().asq16() >> 12) + (!isshell ? (3 << 8) : 0); sp->zvel = -(krand() & 255); } else @@ -549,7 +549,7 @@ void initwaterdrip(DDukeActor* actj, DDukeActor* actor) sp->z -= (18 << 8); } else sp->z -= (13 << 8); - sp->ang = getangle(ps[connecthead].posx - sp->x, ps[connecthead].posy - sp->y); + sp->ang = getangle(ps[connecthead].pos.x - sp->x, ps[connecthead].pos.y - sp->y); sp->xvel = 48 - (krand() & 31); ssp(actor, CLIPMASK0); } diff --git a/source/games/duke/src/types.h b/source/games/duke/src/types.h index 9256a53e5..d9e110d8c 100644 --- a/source/games/duke/src/types.h +++ b/source/games/duke/src/types.h @@ -156,11 +156,7 @@ struct player_struct // This is basically the version from JFDuke but this first block contains a few changes to make it work with other parts of Raze. // The sound code wants to read a vector out of this so we need to define one for the main coordinate. - union - { - vec3_t pos; - struct { int32_t posx, posy, posz; }; - }; + vec3_t pos; // player's horizon and angle structs. PlayerHorizon horizon;