diff --git a/source/build/include/build.h b/source/build/include/build.h index d1c7c05cc..ed6387c82 100644 --- a/source/build/include/build.h +++ b/source/build/include/build.h @@ -627,23 +627,6 @@ static inline int64_t compat_maybe_truncate_to_int32(int64_t val) return enginecompatibility_mode != ENGINECOMPATIBILITY_NONE ? (int32_t)val : val; } -static inline int32_t clipmove_old(int32_t *x, int32_t *y, int32_t *z, int16_t *sectnum, int32_t xvect, int32_t yvect, int32_t walldist, - int32_t ceildist, int32_t flordist, uint32_t cliptype) ATTRIBUTE((nonnull(1,2,3,4))); - -static inline int32_t clipmove_old(int32_t *x, int32_t *y, int32_t *z, int16_t *sectnum, int32_t xvect, int32_t yvect, int32_t walldist, - int32_t ceildist, int32_t flordist, uint32_t cliptype) -{ - vec3_t vector = { *x, *y, *z }; - - int32_t result = clipmove(&vector, sectnum, xvect, yvect, walldist, ceildist, flordist, cliptype); - - *x = vector.x; - *y = vector.y; - *z = vector.z; - - return result; -} - static inline int32_t pushmove_old(int32_t *x, int32_t *y, int32_t *z, int16_t *sectnum, int32_t walldist, int32_t ceildist, int32_t flordist, uint32_t cliptype) ATTRIBUTE((nonnull(1,2,3,4))); diff --git a/source/games/sw/src/mclip.cpp b/source/games/sw/src/mclip.cpp index 97f797028..97537ae1c 100644 --- a/source/games/sw/src/mclip.cpp +++ b/source/games/sw/src/mclip.cpp @@ -41,7 +41,7 @@ BEGIN_SW_NS int MultiClipMove(PLAYERp pp, int z, int floor_dist) { int i; - int ox[MAX_CLIPBOX],oy[MAX_CLIPBOX]; + vec3_t opos[MAX_CLIPBOX], pos[MAX_CLIPBOX]; SECTOR_OBJECTp sop = pp->sop; short ang; short min_ndx = 0; @@ -51,10 +51,8 @@ int MultiClipMove(PLAYERp pp, int z, int floor_dist) int ret_start; int ret; int min_ret=0; - int x[MAX_CLIPBOX],y[MAX_CLIPBOX]; int xvect,yvect; - int xs,ys; for (i = 0; i < sop->clipbox_num; i++) { @@ -62,13 +60,12 @@ int MultiClipMove(PLAYERp pp, int z, int floor_dist) // allowing you to move through wall ang = NORM_ANGLE(pp->angle.ang.asbuild() + sop->clipbox_ang[i]); - xs = pp->posx; - ys = pp->posy; + vec3_t spos = { pp->posx, pp->posy, z }; xvect = sop->clipbox_vdist[i] * bcos(ang); yvect = sop->clipbox_vdist[i] * bsin(ang); clipmoveboxtracenum = 1; - ret_start = clipmove_old(&xs, &ys, &z, &pp->cursectnum, xvect, yvect, (int)sop->clipbox_dist[i], Z(4), floor_dist, CLIPMASK_PLAYER); + ret_start = clipmove(&spos, &pp->cursectnum, xvect, yvect, (int)sop->clipbox_dist[i], Z(4), floor_dist, CLIPMASK_PLAYER); clipmoveboxtracenum = 3; if (ret_start) @@ -77,15 +74,15 @@ int MultiClipMove(PLAYERp pp, int z, int floor_dist) min_dist = 0; min_ndx = i; // ox is where it should be - ox[i] = x[i] = pp->posx + MulScale(sop->clipbox_vdist[i], bcos(ang), 14); - oy[i] = y[i] = pp->posy + MulScale(sop->clipbox_vdist[i], bsin(ang), 14); + opos[i].x = pos[i].x = pp->posx + MulScale(sop->clipbox_vdist[i], bcos(ang), 14); + opos[i].y = pos[i].y = pp->posy + MulScale(sop->clipbox_vdist[i], bsin(ang), 14); - // xs is where it hit - x[i] = xs; - y[i] = ys; + // spos.x is where it hit + pos[i].x = spos.x; + pos[i].y = spos.y; // see the dist moved - dist = ksqrt(SQ(x[i] - ox[i]) + SQ(y[i] - oy[i])); + dist = ksqrt(SQ(pos[i].x - opos[i].x) + SQ(pos[i].y - opos[i].y)); // save it off if (dist < min_dist) @@ -98,14 +95,14 @@ int MultiClipMove(PLAYERp pp, int z, int floor_dist) else { // save off the start position - ox[i] = x[i] = xs; - oy[i] = y[i] = ys; + opos[i] = pos[i] = spos; + pos[i].z = z; // move the box - ret = clipmove_old(&x[i], &y[i], &z, &pp->cursectnum, pp->xvect, pp->yvect, (int)sop->clipbox_dist[i], Z(4), floor_dist, CLIPMASK_PLAYER); + ret = clipmove(&pos[i], &pp->cursectnum, pp->xvect, pp->yvect, (int)sop->clipbox_dist[i], Z(4), floor_dist, CLIPMASK_PLAYER); // save the dist moved - dist = ksqrt(SQ(x[i] - ox[i]) + SQ(y[i] - oy[i])); + dist = ksqrt(SQ(pos[i].x - opos[i].x) + SQ(pos[i].y - opos[i].y)); if (ret) { @@ -121,8 +118,8 @@ int MultiClipMove(PLAYERp pp, int z, int floor_dist) } // put posx and y off from offset - pp->posx += x[min_ndx] - ox[min_ndx]; - pp->posy += y[min_ndx] - oy[min_ndx]; + pp->posx += pos[min_ndx].x - opos[min_ndx].x; + pp->posy += pos[min_ndx].y - opos[min_ndx].y; return min_ret; } @@ -141,14 +138,13 @@ short MultiClipTurn(PLAYERp pp, short new_ang, int z, int floor_dist) { ang = NORM_ANGLE(new_ang + sop->clipbox_ang[i]); - x = pp->posx; - y = pp->posy; + vec3_t pos = { pp->posx, pp->posy, z }; xvect = sop->clipbox_vdist[i] * bcos(ang); yvect = sop->clipbox_vdist[i] * bsin(ang); // move the box - ret = clipmove_old(&x, &y, &z, &cursectnum, xvect, yvect, (int)sop->clipbox_dist[i], Z(4), floor_dist, CLIPMASK_PLAYER); + ret = clipmove(&pos, &cursectnum, xvect, yvect, (int)sop->clipbox_dist[i], Z(4), floor_dist, CLIPMASK_PLAYER); ASSERT(cursectnum >= 0); diff --git a/source/games/sw/src/player.cpp b/source/games/sw/src/player.cpp index c6d4d51dd..b2f7629d4 100644 --- a/source/games/sw/src/player.cpp +++ b/source/games/sw/src/player.cpp @@ -2424,7 +2424,9 @@ DoPlayerMoveBoat(PLAYERp pp) pp->cursectnum = pp->sop->op_main_sector; // for speed floor_dist = labs(z - pp->sop->floor_loz); - clipmove_old(&pp->posx, &pp->posy, &z, &pp->cursectnum, pp->xvect, pp->yvect, (int)pp->sop->clipdist, Z(4), floor_dist, CLIPMASK_PLAYER); + vec3_t clippos = { pp->posx, pp->posy, z }; + clipmove_old(&clippos, &pp->cursectnum, pp->xvect, pp->yvect, (int)pp->sop->clipdist, Z(4), floor_dist, CLIPMASK_PLAYER); + pp->pos.vec2 = clippos.vec2; OperateSectorObject(pp->sop, pp->angle.ang.asbuild(), pp->posx, pp->posy); pp->cursectnum = save_sectnum; // for speed @@ -2894,9 +2896,15 @@ DoPlayerMoveVehicle(PLAYERp pp) save_cstat = pp->SpriteP->cstat; RESET(pp->SpriteP->cstat, CSTAT_SPRITE_BLOCK); if (pp->sop->clipdist) - u->ret = clipmove_old(&pp->posx, &pp->posy, &z, &pp->cursectnum, pp->xvect, pp->yvect, (int)pp->sop->clipdist, Z(4), floor_dist, CLIPMASK_PLAYER); + { + vec3_t clippos = { pp->posx, pp->posy, z }; + u->ret = clipmove(&clippos, &pp->cursectnum, pp->xvect, pp->yvect, (int)pp->sop->clipdist, Z(4), floor_dist, CLIPMASK_PLAYER); + pp->pos.vec2 = clippos.vec2; + } else + { u->ret = MultiClipMove(pp, z, floor_dist); + } pp->SpriteP->cstat = save_cstat; //SetupDriveCrush(pp, x, y); diff --git a/source/games/sw/src/sprite.cpp b/source/games/sw/src/sprite.cpp index 6e059d77e..a245b472a 100644 --- a/source/games/sw/src/sprite.cpp +++ b/source/games/sw/src/sprite.cpp @@ -6828,7 +6828,6 @@ SpriteControl(void) int move_sprite(int spritenum, int xchange, int ychange, int zchange, int ceildist, int flordist, uint32_t cliptype, int numtics) { - int daz; int retval=0, zh; short dasectnum, tempshort; SPRITEp spr; @@ -6839,14 +6838,12 @@ move_sprite(int spritenum, int xchange, int ychange, int zchange, int ceildist, ASSERT(u); + vec3_t clippos = spr->pos; + // Can't modify sprite sectors // directly becuase of linked lists dasectnum = lastsectnum = spr->sectnum; - // Must do this if not using the new - // centered centering (of course) - daz = spr->z; - if (TEST(spr->cstat, CSTAT_SPRITE_YCENTER)) { zh = 0; @@ -6855,16 +6852,17 @@ move_sprite(int spritenum, int xchange, int ychange, int zchange, int ceildist, { // move the center point up for moving zh = u->zclip; - daz -= zh; + clippos.z -= zh; } // ASSERT(inside(spr->x,spr->y,dasectnum)); clipmoveboxtracenum = 1; - retval = clipmove_old(&spr->x, &spr->y, &daz, &dasectnum, + retval = clipmove(&clippos, &dasectnum, ((xchange * numtics) << 11), ((ychange * numtics) << 11), (((int) spr->clipdist) << 2), ceildist, flordist, cliptype); + spr->pos.vec2 = clippos.vec2; clipmoveboxtracenum = 3; //if (TEST(retval, HIT_MASK) == HIT_WALL) @@ -6905,16 +6903,16 @@ move_sprite(int spritenum, int xchange, int ychange, int zchange, int ceildist, // Takes info from global variables DoActorGlobZ(spritenum); - daz = spr->z + ((zchange * numtics) >> 3); + clippos.z = spr->z + ((zchange * numtics) >> 3); // test for hitting ceiling or floor - if ((daz - zh <= globhiz) || (daz - zh > globloz)) + if ((clippos.z - zh <= globhiz) || (clippos.z - zh > globloz)) { if (retval == 0) { if (TEST(u->Flags, SPR_CLIMBING)) { - spr->z = daz; + spr->z = clippos.z; return 0; } @@ -6923,7 +6921,7 @@ move_sprite(int spritenum, int xchange, int ychange, int zchange, int ceildist, } else { - spr->z = daz; + spr->z = clippos.z; } // extra processing for Stacks and warping @@ -7076,7 +7074,6 @@ MissileZrange(short SpriteNum) int move_missile(int spritenum, int xchange, int ychange, int zchange, int ceildist, int flordist, uint32_t cliptype, int numtics) { - int daz; int retval, zh; short dasectnum, tempshort; SPRITEp sp; @@ -7087,13 +7084,11 @@ move_missile(int spritenum, int xchange, int ychange, int zchange, int ceildist, ASSERT(u); - // Can't modify sprite sectors - // directly becuase of linked lists - dasectnum = lastsectnum = sp->sectnum; + vec3_t clippos = sp->pos; // Can't modify sprite sectors // directly becuase of linked lists - daz = sp->z; + dasectnum = lastsectnum = sp->sectnum; if (TEST(sp->cstat, CSTAT_SPRITE_YCENTER)) { @@ -7102,15 +7097,16 @@ move_missile(int spritenum, int xchange, int ychange, int zchange, int ceildist, else { zh = u->zclip; - daz -= zh; + clippos.z -= zh; } // ASSERT(inside(sp->x,sp->y,dasectnum)); clipmoveboxtracenum = 1; - retval = clipmove_old(&sp->x, &sp->y, &daz, &dasectnum, + retval = clipmove(&clippos, &dasectnum, ((xchange * numtics) << 11), ((ychange * numtics) << 11), (((int) sp->clipdist) << 2), ceildist, flordist, cliptype); + sp->pos.vec2 = clippos.vec2; clipmoveboxtracenum = 3; if (dasectnum < 0) @@ -7143,20 +7139,20 @@ move_missile(int spritenum, int xchange, int ychange, int zchange, int ceildist, // missiles don't need the water to be down MissileWaterAdjust(spritenum); - daz = sp->z + ((zchange * numtics) >> 3); + clippos.z = sp->z + ((zchange * numtics) >> 3); // NOTE: this does not tell you when you hit a floor sprite // this case is currently treated like it hit a sector // test for hitting ceiling or floor - if (daz - zh <= u->hiz + ceildist) + if (clippos.z - zh <= u->hiz + ceildist) { // normal code sp->z = u->hiz + zh + ceildist; if (retval == 0) retval = dasectnum|HIT_SECTOR; } - else if (daz - zh > u->loz - flordist) + else if (clippos.z - zh > u->loz - flordist) { sp->z = u->loz + zh - flordist; if (retval == 0) @@ -7164,7 +7160,7 @@ move_missile(int spritenum, int xchange, int ychange, int zchange, int ceildist, } else { - sp->z = daz; + sp->z = clippos.z; } if (FAF_ConnectArea(sp->sectnum)) @@ -7231,6 +7227,7 @@ move_ground_missile(short spritenum, int xchange, int ychange, int ceildist, int // directly becuase of linked lists dasectnum = lastsectnum = sp->sectnum; + vec3_t opos = sp->pos; daz = sp->z; // climbing a wall @@ -7253,8 +7250,6 @@ move_ground_missile(short spritenum, int xchange, int ychange, int ceildist, int u->z_tgt = 0; } - ox = sp->x; - oy = sp->y; sp->x += xchange/2; sp->y += ychange/2; @@ -7264,12 +7259,13 @@ move_ground_missile(short spritenum, int xchange, int ychange, int ceildist, int { // back up and try again dasectnum = lastsectnum = sp->sectnum; - sp->x = ox; - sp->y = oy; + opos = sp->pos; + opos.z = daz; clipmoveboxtracenum = 1; - retval = clipmove_old(&sp->x, &sp->y, &daz, &dasectnum, + retval = clipmove(&opos, &dasectnum, ((xchange * numtics) << 11), ((ychange * numtics) << 11), (((int) sp->clipdist) << 2), ceildist, flordist, cliptype); + sp->pos.vec2 = opos.vec2; clipmoveboxtracenum = 3; }