- Duke: only use the main clipmove function and match clipmove_ex’s interface

This commit is contained in:
Christoph Oelckers 2021-11-07 18:46:28 +01:00
parent 567d054d42
commit 2e1ff313b0
8 changed files with 27 additions and 43 deletions

View file

@ -35,7 +35,7 @@ int32_t clipmove(vec3_t *const pos, int *const sectnum, int32_t xvect, int32_t y
int32_t const flordist, uint32_t const cliptype) ATTRIBUTE((nonnull(1, 2)));
[[deprecated]]
int32_t clipmove(vec3_t *const pos, int16_t *const sectnum, int32_t xvect, int32_t yvect, int32_t const walldist, int32_t const ceildist,
inline int32_t clipmove(vec3_t *const pos, int16_t *const sectnum, int32_t xvect, int32_t yvect, int32_t const walldist, int32_t const ceildist,
int32_t const flordist, uint32_t const cliptype)
{
int sect32 = *sectnum;

View file

@ -1506,7 +1506,7 @@ bool queball(DDukeActor *actor, int pocket, int queball, int stripeball)
Collision coll;
static_assert(sizeof(s->sectnum) != sizeof(int)); // this will error out when sectnum gets expanded.
int sect = s->sectnum;
int j = clipmove_ex(&s->x, &s->y, &s->z, &sect,
int j = clipmove_ex(&s->pos, &sect,
(MulScale(s->xvel, bcos(s->ang), 14) * TICSPERFRAME) << 11,
(MulScale(s->xvel, bsin(s->ang), 14) * TICSPERFRAME) << 11,
24L, (4 << 8), (4 << 8), CLIPMASK1, coll);

View file

@ -540,7 +540,6 @@ SKIPWALLCHECK:
int movesprite_ex_d(DDukeActor* actor, int xchange, int ychange, int zchange, unsigned int cliptype, Collision &result)
{
int daz, h, oldx, oldy;
int clipdist;
int dasectnum;
@ -560,17 +559,13 @@ int movesprite_ex_d(DDukeActor* actor, int xchange, int ychange, int zchange, un
dasectnum = spri->sectnum;
auto dasectp = spri->sector();
daz = spri->z;
h = ((tileHeight(spri->picnum) * spri->yrepeat) << 1);
daz -= h;
vec3_t pos = spri->pos;
pos.z -= ((tileHeight(spri->picnum) * spri->yrepeat) << 1);
if (bg)
{
oldx = spri->x;
oldy = spri->y;
if (spri->xrepeat > 60)
clipmove_ex(&spri->x, &spri->y, &daz, &dasectnum, ((xchange * TICSPERFRAME) << 11), ((ychange * TICSPERFRAME) << 11), 1024L, (4 << 8), (4 << 8), cliptype, result);
clipmove_ex(&pos, &dasectnum, ((xchange * TICSPERFRAME) << 11), ((ychange * TICSPERFRAME) << 11), 1024, (4 << 8), (4 << 8), cliptype, result);
else
{
if (spri->picnum == LIZMAN)
@ -580,7 +575,7 @@ int movesprite_ex_d(DDukeActor* actor, int xchange, int ychange, int zchange, un
else
clipdist = 192;
clipmove_ex(&spri->x, &spri->y, &daz, &dasectnum, ((xchange * TICSPERFRAME) << 11), ((ychange * TICSPERFRAME) << 11), clipdist, (4 << 8), (4 << 8), cliptype, result);
clipmove_ex(&pos, &dasectnum, ((xchange * TICSPERFRAME) << 11), ((ychange * TICSPERFRAME) << 11), clipdist, (4 << 8), (4 << 8), cliptype, result);
}
// conditional code from hell...
@ -592,13 +587,11 @@ int movesprite_ex_d(DDukeActor* actor, int xchange, int ychange, int zchange, un
))
)
{
spri->x = oldx;
spri->y = oldy;
if (dasectp->lotag == ST_1_ABOVE_WATER && spri->picnum == LIZMAN)
spri->ang = (krand()&2047);
else if ((actor->temp_data[0]&3) == 1 && spri->picnum != COMMANDER)
spri->ang = (krand()&2047);
setsprite(actor,oldx,oldy,spri->z);
setsprite(actor,spri->pos);
if (dasectnum < 0) dasectnum = 0;
return result.setSector(dasectnum);
}
@ -607,15 +600,17 @@ int movesprite_ex_d(DDukeActor* actor, int xchange, int ychange, int zchange, un
else
{
if (spri->statnum == STAT_PROJECTILE)
clipmove_ex(&spri->x, &spri->y, &daz, &dasectnum, ((xchange * TICSPERFRAME) << 11), ((ychange * TICSPERFRAME) << 11), 8L, (4 << 8), (4 << 8), cliptype, result);
clipmove_ex(&pos, &dasectnum, ((xchange * TICSPERFRAME) << 11), ((ychange * TICSPERFRAME) << 11), 8, (4 << 8), (4 << 8), cliptype, result);
else
clipmove_ex(&spri->x, &spri->y, &daz, &dasectnum, ((xchange * TICSPERFRAME) << 11), ((ychange * TICSPERFRAME) << 11), (int)(spri->clipdist << 2), (4 << 8), (4 << 8), cliptype, result);
clipmove_ex(&pos, &dasectnum, ((xchange * TICSPERFRAME) << 11), ((ychange * TICSPERFRAME) << 11), (int)(spri->clipdist << 2), (4 << 8), (4 << 8), cliptype, result);
}
spri->x = pos.x;
spri->y = pos.y;
if (dasectnum >= 0)
if ((dasectnum != spri->sectnum))
changeactorsect(actor, dasectnum);
daz = spri->z + ((zchange * TICSPERFRAME) >> 3);
int daz = spri->z + ((zchange * TICSPERFRAME) >> 3);
if ((daz > actor->ceilingz) && (daz <= actor->floorz))
spri->z = daz;
else if (result.type == kHitNone)

View file

@ -385,7 +385,6 @@ SKIPWALLCHECK:
int movesprite_ex_r(DDukeActor* actor, int xchange, int ychange, int zchange, unsigned int cliptype, Collision &result)
{
int daz, h, oldx, oldy;
int dasectnum;
int clipdist;
auto spri = actor->s;
@ -404,32 +403,26 @@ int movesprite_ex_r(DDukeActor* actor, int xchange, int ychange, int zchange, un
dasectnum = spri->sectnum;
auto dasectp = spri->sector();
daz = spri->z;
h = ((tileHeight(spri->picnum) * spri->yrepeat) << 1);
daz -= h;
vec3_t pos = spri->pos;
pos.z -= ((tileHeight(spri->picnum) * spri->yrepeat) << 1);
if (bg)
{
oldx = spri->x;
oldy = spri->y;
if (spri->xrepeat > 60)
clipmove_ex(&spri->x, &spri->y, &daz, &dasectnum, ((xchange * TICSPERFRAME) << 11), ((ychange * TICSPERFRAME) << 11), 1024L, (4 << 8), (4 << 8), cliptype, result);
clipmove_ex(&pos, &dasectnum, ((xchange * TICSPERFRAME) << 11), ((ychange * TICSPERFRAME) << 11), 1024, (4 << 8), (4 << 8), cliptype, result);
else
{
clipdist = 192;
clipmove_ex(&spri->x, &spri->y, &daz, &dasectnum, ((xchange * TICSPERFRAME) << 11), ((ychange * TICSPERFRAME) << 11), clipdist, (4 << 8), (4 << 8), cliptype, result);
clipmove_ex(&pos, &dasectnum, ((xchange * TICSPERFRAME) << 11), ((ychange * TICSPERFRAME) << 11), clipdist, (4 << 8), (4 << 8), cliptype, result);
}
if (dasectnum < 0 || (dasectnum >= 0 && actor->actorstayput >= 0 && actor->actorstayput != dasectnum))
{
spri->x = oldx;
spri->y = oldy;
if (dasectp->lotag == ST_1_ABOVE_WATER)
spri->ang = (krand() & 2047);
else if ((actor->temp_data[0] & 3) == 1)
spri->ang = (krand() & 2047);
setsprite(actor, oldx, oldy, spri->z);
setsprite(actor, spri->pos);
if (dasectnum < 0) dasectnum = 0;
return result.setSector(dasectnum);
}
@ -438,15 +431,17 @@ int movesprite_ex_r(DDukeActor* actor, int xchange, int ychange, int zchange, un
else
{
if (spri->statnum == STAT_PROJECTILE)
clipmove_ex(&spri->x, &spri->y, &daz, &dasectnum, ((xchange * TICSPERFRAME) << 11), ((ychange * TICSPERFRAME) << 11), 8L, (4 << 8), (4 << 8), cliptype, result);
clipmove_ex(&pos, &dasectnum, ((xchange * TICSPERFRAME) << 11), ((ychange * TICSPERFRAME) << 11), 8, (4 << 8), (4 << 8), cliptype, result);
else
clipmove_ex(&spri->x, &spri->y, &daz, &dasectnum, ((xchange * TICSPERFRAME) << 11), ((ychange * TICSPERFRAME) << 11), 128, (4 << 8), (4 << 8), cliptype, result);
clipmove_ex(&pos, &dasectnum, ((xchange * TICSPERFRAME) << 11), ((ychange * TICSPERFRAME) << 11), 128, (4 << 8), (4 << 8), cliptype, result);
}
spri->x = pos.x;
spri->y = pos.y;
if (dasectnum >= 0)
if ((dasectnum != spri->sectnum))
changeactorsect(actor, dasectnum);
daz = spri->z + ((zchange * TICSPERFRAME) >> 3);
int daz = spri->z + ((zchange * TICSPERFRAME) >> 3);
if ((daz > actor->ceilingz) && (daz <= actor->floorz))
spri->z = daz;
else if (result.type == kHitNone)

View file

@ -179,11 +179,9 @@ inline int movesprite_ex(DDukeActor* actor, int xchange, int ychange, int zchang
return f(actor, xchange, ychange, zchange, cliptype, result);
}
inline int clipmove_ex(int* x, int* y, int* z, int* sect, int xv, int yv, int wal, int ceil, int flor, int ct, Collision& result)
inline int clipmove_ex(vec3_t* pos, int* sect, int xv, int yv, int wal, int ceil, int flor, int ct, Collision& result)
{
short sect16 = *sect;
int res = clipmove(x, y, z, &sect16, xv, yv, wal, ceil, flor, ct);
*sect = sect16;
int res = clipmove(pos, sect, xv, yv, wal, ceil, flor, ct);
return result.setFromEngine(res);
}

View file

@ -619,7 +619,7 @@ void playerisdead(int snum, int psectlotag, int fz, int cz)
}
Collision coll;
clipmove_ex(&p->pos.x, &p->pos.y, &p->pos.z, &p->cursectnum, 0, 0, 164, (4 << 8), (4 << 8), CLIPMASK0, coll);
clipmove_ex(&p->pos, &p->cursectnum, 0, 0, 164, (4 << 8), (4 << 8), CLIPMASK0, coll);
}
backupplayer(p);

View file

@ -3019,9 +3019,7 @@ HORIZONLY:
changeactorsect(pact, p->cursectnum);
}
else
clipmove_ex(&p->pos.x, &p->pos.y,
&p->pos.z, &p->cursectnum,
p->posxv, p->posyv, 164L, (4L << 8), ii, CLIPMASK0, clip);
clipmove_ex(&p->pos, &p->cursectnum, p->posxv, p->posyv, 164, (4 << 8), ii, CLIPMASK0, clip);
if (p->jetpack_on == 0 && psectlotag != 2 && psectlotag != 1 && shrunk)
p->pos.z += 32 << 8;

View file

@ -3782,9 +3782,7 @@ HORIZONLY:
changeactorsect(pact, p->cursectnum);
}
else
clipmove_ex(&p->pos.x, &p->pos.y,
&p->pos.z, &p->cursectnum,
p->posxv, p->posyv, 164L, (4L << 8), i, CLIPMASK0, clip);
clipmove_ex(&p->pos, &p->cursectnum, p->posxv, p->posyv, 164, (4 << 8), i, CLIPMASK0, clip);
if (p->jetpack_on == 0 && psectlotag != 2 && psectlotag != 1 && shrunk)
p->pos.z += 32 << 8;