diff --git a/source/core/gamefuncs.h b/source/core/gamefuncs.h index b989eff2e..4737c22f7 100644 --- a/source/core/gamefuncs.h +++ b/source/core/gamefuncs.h @@ -336,6 +336,16 @@ inline void dragpoint(walltype* pointhighlight, int32_t dax, int32_t day) dragpoint(wallnum(pointhighlight), dax, day); } +inline int pushmove(vec3_t *const vect, sectortype**const sect, int32_t const walldist, int32_t const ceildist, int32_t const flordist, + uint32_t const cliptype, bool clear = true) +{ + int sectno = *sect? sector.IndexOf(*sect) : -1; + int res = pushmove(vect, §no, walldist, ceildist, flordist, cliptype, clear); + *sect = sectno == -1? nullptr : §or[sectno]; + return res; +} + + inline int findwallbetweensectors(sectortype* sect1, sectortype* sect2) { return findwallbetweensectors(sectnum(sect1), sectnum(sect2)); diff --git a/source/games/duke/src/dukeactor.h b/source/games/duke/src/dukeactor.h index e4b50c648..9d807052e 100644 --- a/source/games/duke/src/dukeactor.h +++ b/source/games/duke/src/dukeactor.h @@ -187,6 +187,14 @@ inline int clipmove_ex(vec3_t* pos, int* sect, int xv, int yv, int wal, int ceil return result.setFromEngine(res); } +inline int clipmove_ex(vec3_t* pos, sectortype** sect, int xv, int yv, int wal, int ceil, int flor, int ct, Collision& result) +{ + int sectno = *sect? sectnum(*sect) : -1; + int res = clipmove(pos, §no, xv, yv, wal, ceil, flor, ct); + *sect = sectno == -1? nullptr : §or[sectno]; + return result.setFromEngine(res); +} + inline void getzrange_ex(int x, int y, int z, int sectnum, int32_t* ceilz, Collision& ceilhit, int32_t* florz, Collision& florhit, int32_t walldist, uint32_t cliptype) { int ch, fh; @@ -195,6 +203,14 @@ inline void getzrange_ex(int x, int y, int z, int sectnum, int32_t* ceilz, Colli florhit.setFromEngine(fh); } +inline void getzrange_ex(int x, int y, int z, sectortype* sect, int32_t* ceilz, Collision& ceilhit, int32_t* florz, Collision& florhit, int32_t walldist, uint32_t cliptype) +{ + int ch, fh; + getzrange(x, y, z, sectnum(sect), ceilz, &ch, florz, &fh, walldist, cliptype); + ceilhit.setFromEngine(ch); + florhit.setFromEngine(fh); +} + inline int hitscan(int x, int y, int z, int sectnum, int32_t vx, int32_t vy, int32_t vz, sectortype** hitsect, walltype** hitwall, DDukeActor** hitspr, int* hitx, int* hity, int* hitz, uint32_t cliptype) { diff --git a/source/games/duke/src/player_d.cpp b/source/games/duke/src/player_d.cpp index d31835419..ec2b12441 100644 --- a/source/games/duke/src/player_d.cpp +++ b/source/games/duke/src/player_d.cpp @@ -42,7 +42,7 @@ source as it is released. BEGIN_DUKE_NS void fireweapon_ww(int snum); -void operateweapon_ww(int snum, ESyncBits actions, int psect); +void operateweapon_ww(int snum, ESyncBits actions); //--------------------------------------------------------------------------- // @@ -2055,7 +2055,7 @@ int operateTripbomb(int snum) walltype* wal; hitscan(p->pos.x, p->pos.y, p->pos.z, - p->cursectnum, p->angle.ang.bcos(), + p->cursector(), p->angle.ang.bcos(), p->angle.ang.bsin(), -p->horizon.sum().asq16() >> 11, &hitsectp, &wal, &hitsprt, &sx, &sy, &sz, CLIPMASK1); @@ -2215,7 +2215,7 @@ static void fireweapon(int snum) // //--------------------------------------------------------------------------- -static void operateweapon(int snum, ESyncBits actions, int psect) +static void operateweapon(int snum, ESyncBits actions) { auto p = &ps[snum]; auto pact = p->GetActor(); @@ -2673,7 +2673,7 @@ static void operateweapon(int snum, ESyncBits actions, int psect) // //--------------------------------------------------------------------------- -static void processweapon(int snum, ESyncBits actions, int psect) +static void processweapon(int snum, ESyncBits actions) { auto p = &ps[snum]; auto pact = p->GetActor(); @@ -2743,8 +2743,8 @@ static void processweapon(int snum, ESyncBits actions, int psect) } else if (p->kickback_pic) { - if (!isWW2GI()) operateweapon(snum, actions, psect); - else operateweapon_ww(snum, actions, psect); + if (!isWW2GI()) operateweapon(snum, actions); + else operateweapon_ww(snum, actions); } } //--------------------------------------------------------------------------- @@ -2758,7 +2758,7 @@ void processinput_d(int snum) int j, k, doubvel, fz, cz, truefdist; Collision chz, clz; bool shrunk; - int psect, psectlotag; + int psectlotag; struct player_struct* p; spritetype* s; @@ -2775,28 +2775,27 @@ void processinput_d(int snum) auto sb_svel = PlayerInputSideVel(snum); auto sb_avel = PlayerInputAngVel(snum); - psect = p->cursectnum; - if (psect == -1) + auto psectp = p->cursector(); + if (psectp == nullptr) { if (s->extra > 0 && ud.clipping == 0) { quickkill(p); S_PlayActorSound(SQUISHED, pact); } - psect = 0; + psectp = §or[0]; } - auto psectp = §or[psect]; psectlotag = psectp->lotag; p->spritebridge = 0; shrunk = (s->yrepeat < 32); - getzrange_ex(p->pos.x, p->pos.y, p->pos.z, psect, &cz, chz, &fz, clz, 163L, CLIPMASK0); + getzrange_ex(p->pos.x, p->pos.y, p->pos.z, psectp, &cz, chz, &fz, clz, 163, CLIPMASK0); - j = getflorzofslope(psect, p->pos.x, p->pos.y); + j = getflorzofslopeptr(psectp, p->pos.x, p->pos.y); p->truefz = j; - p->truecz = getceilzofslope(psect, p->pos.x, p->pos.y); + p->truecz = getceilzofslopeptr(psectp, p->pos.x, p->pos.y); truefdist = abs(p->pos.z - j); if (clz.type == kHitSector && psectlotag == 1 && truefdist > gs.playerheight + (16 << 8)) @@ -2882,8 +2881,8 @@ void processinput_d(int snum) fi.doincrements(p); - if (isWW2GI() && aplWeaponWorksLike[p->curr_weapon][snum] == HANDREMOTE_WEAPON) processweapon(snum, actions, psect); - if (!isWW2GI() && p->curr_weapon == HANDREMOTE_WEAPON) processweapon(snum, actions, psect); + if (isWW2GI() && aplWeaponWorksLike[p->curr_weapon][snum] == HANDREMOTE_WEAPON) processweapon(snum, actions); + if (!isWW2GI() && p->curr_weapon == HANDREMOTE_WEAPON) processweapon(snum, actions); return; } @@ -3102,8 +3101,7 @@ HORIZONLY: if (psectlotag < 3) { - psect = s->sectnum; - psectp = s->sector(); // + psectp = s->sector(); if (ud.clipping == 0 && psectp->lotag == 31) { auto secact = ScriptIndexToActor(psectp->hitag); @@ -3209,7 +3207,7 @@ HORIZONLY: } // HACKS - processweapon(snum, actions, psect); + processweapon(snum, actions); } END_DUKE_NS diff --git a/source/games/duke/src/player_w.cpp b/source/games/duke/src/player_w.cpp index bf6c80867..cd1ca3ae8 100644 --- a/source/games/duke/src/player_w.cpp +++ b/source/games/duke/src/player_w.cpp @@ -307,7 +307,7 @@ void fireweapon_ww(int snum) // //--------------------------------------------------------------------------- -void operateweapon_ww(int snum, ESyncBits actions, int psect) +void operateweapon_ww(int snum, ESyncBits actions) { auto p = &ps[snum]; auto pact = p->GetActor(); diff --git a/source/games/duke/src/sectors_d.cpp b/source/games/duke/src/sectors_d.cpp index 5ae29d98e..ef389d2ea 100644 --- a/source/games/duke/src/sectors_d.cpp +++ b/source/games/duke/src/sectors_d.cpp @@ -1533,7 +1533,6 @@ void checksectors_d(int snum) { int i = -1, oldz; struct player_struct* p; - int j; walltype* hitscanwall; sectortype* ntsector = nullptr; walltype* ntwall = nullptr;