- addressed the updatesector related deprecation warnings with Duke.

This commit is contained in:
Christoph Oelckers 2021-11-06 20:46:08 +01:00
parent d20aa47adf
commit 1c0e3d849b
11 changed files with 53 additions and 28 deletions

View file

@ -49,6 +49,7 @@ int32_t clipmovex(vec3_t *const pos, int16_t *const sectnum, int32_t xvect, int3
int pushmove(vec3_t *const vect, int16_t *const sectnum, int32_t const walldist, int32_t const ceildist, int32_t const flordist,
uint32_t const cliptype, bool clear = true) ATTRIBUTE((nonnull(1, 2)));
[[deprecated]]
inline int pushmove(int* x, int* y, int* z, int16_t* const sectnum, int32_t const walldist, int32_t const ceildist, int32_t const flordist,
uint32_t const cliptype, bool clear = true)
{
@ -60,4 +61,17 @@ inline int pushmove(int* x, int* y, int* z, int16_t* const sectnum, int32_t cons
return r;
}
inline int pushmove(int* x, int* y, int* z, int* const sectnum, int32_t const walldist, int32_t const ceildist, int32_t const flordist,
uint32_t const cliptype, bool clear = true)
{
short sect16 = *sectnum;
vec3_t v = { *x,*y,*z };
auto r = pushmove(&v, &sect16, walldist, ceildist, flordist, cliptype, clear);
*sectnum = sect16;
*x = v.x;
*y = v.y;
*z = v.z;
return r;
}
#endif

View file

@ -878,7 +878,7 @@ int32_t spriteheightofsptr(uspriteptr_t spr, int32_t *height, int32_t alsotileyo
//
int32_t setsprite(int16_t spritenum, const vec3_t *newpos)
{
int16_t tempsectnum = sprite[spritenum].sectnum;
int tempsectnum = sprite[spritenum].sectnum;
if (newpos != &sprite[spritenum].pos)
sprite[spritenum].pos = *newpos;

View file

@ -1503,10 +1503,13 @@ bool queball(DDukeActor *actor, int pocket, int queball, int stripeball)
}
Collision coll;
int j = clipmove_ex(&s->x, &s->y, &s->z, &s->sectnum,
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,
(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);
s->sectnum = sect;
if (j == kHitWall)
{
@ -5314,7 +5317,7 @@ void fall_common(DDukeActor *actor, int playernum, int JIBS6, int DRONE, int BLO
else if (s->zvel > 2048 && s->sector()->lotag != 1)
{
short j = s->sectnum;
int j = s->sectnum;
int x = s->x, y = s->y, z = s->z;
pushmove(&x, &y, &z, &j, 128, (4 << 8), (4 << 8), CLIPMASK0);
s->x = x; s->y = y; s->z = z;

View file

@ -540,7 +540,8 @@ SKIPWALLCHECK:
int movesprite_ex_d(DDukeActor* actor, int xchange, int ychange, int zchange, unsigned int cliptype, Collision &result)
{
int daz, h, oldx, oldy;
short retval, dasectnum, cd;
short cd;
int dasectnum;
auto spri = actor->s;
int bg = badguy(actor);
@ -567,7 +568,7 @@ int movesprite_ex_d(DDukeActor* actor, int xchange, int ychange, int zchange, un
oldy = spri->y;
if (spri->xrepeat > 60)
retval = clipmove(&spri->x, &spri->y, &daz, &dasectnum, ((xchange * TICSPERFRAME) << 11), ((ychange * TICSPERFRAME) << 11), 1024L, (4 << 8), (4 << 8), cliptype);
clipmove_ex(&spri->x, &spri->y, &daz, &dasectnum, ((xchange * TICSPERFRAME) << 11), ((ychange * TICSPERFRAME) << 11), 1024L, (4 << 8), (4 << 8), cliptype, result);
else
{
if (spri->picnum == LIZMAN)
@ -577,7 +578,7 @@ int movesprite_ex_d(DDukeActor* actor, int xchange, int ychange, int zchange, un
else
cd = 192;
retval = clipmove(&spri->x, &spri->y, &daz, &dasectnum, ((xchange * TICSPERFRAME) << 11), ((ychange * TICSPERFRAME) << 11), cd, (4 << 8), (4 << 8), cliptype);
clipmove_ex(&spri->x, &spri->y, &daz, &dasectnum, ((xchange * TICSPERFRAME) << 11), ((ychange * TICSPERFRAME) << 11), cd, (4 << 8), (4 << 8), cliptype, result);
}
// conditional code from hell...
@ -599,15 +600,13 @@ int movesprite_ex_d(DDukeActor* actor, int xchange, int ychange, int zchange, un
if (dasectnum < 0) dasectnum = 0;
return result.setSector(dasectnum);
}
if ((retval & kHitTypeMask) > kHitSector && (actor->cgg == 0)) spri->ang += 768;
if ((result.type == kHitWall || result.type == kHitSprite) && (actor->cgg == 0)) spri->ang += 768;
}
else
{
if (spri->statnum == STAT_PROJECTILE)
retval =
clipmove_ex(&spri->x, &spri->y, &daz, &dasectnum, ((xchange * TICSPERFRAME) << 11), ((ychange * TICSPERFRAME) << 11), 8L, (4 << 8), (4 << 8), cliptype, result);
else
retval =
clipmove_ex(&spri->x, &spri->y, &daz, &dasectnum, ((xchange * TICSPERFRAME) << 11), ((ychange * TICSPERFRAME) << 11), (int)(spri->clipdist << 2), (4 << 8), (4 << 8), cliptype, result);
}
@ -617,10 +616,10 @@ int movesprite_ex_d(DDukeActor* actor, int xchange, int ychange, int zchange, un
daz = spri->z + ((zchange * TICSPERFRAME) >> 3);
if ((daz > actor->ceilingz) && (daz <= actor->floorz))
spri->z = daz;
else if (retval == kHitNone)
else if (result.type == kHitNone)
return result.setSector(dasectnum);
return retval;
return result.type;
}
//---------------------------------------------------------------------------
//

View file

@ -383,7 +383,8 @@ SKIPWALLCHECK:
int movesprite_ex_r(DDukeActor* actor, int xchange, int ychange, int zchange, unsigned int cliptype, Collision &result)
{
int daz, h, oldx, oldy;
short retval, dasectnum, cd;
int dasectnum;
short cd;
auto spri = actor->s;
int bg = badguy(actor);
@ -409,11 +410,11 @@ int movesprite_ex_r(DDukeActor* actor, int xchange, int ychange, int zchange, un
oldy = spri->y;
if (spri->xrepeat > 60)
retval = clipmove(&spri->x, &spri->y, &daz, &dasectnum, ((xchange * TICSPERFRAME) << 11), ((ychange * TICSPERFRAME) << 11), 1024L, (4 << 8), (4 << 8), cliptype);
clipmove_ex(&spri->x, &spri->y, &daz, &dasectnum, ((xchange * TICSPERFRAME) << 11), ((ychange * TICSPERFRAME) << 11), 1024L, (4 << 8), (4 << 8), cliptype, result);
else
{
cd = 192;
retval = clipmove(&spri->x, &spri->y, &daz, &dasectnum, ((xchange * TICSPERFRAME) << 11), ((ychange * TICSPERFRAME) << 11), cd, (4 << 8), (4 << 8), cliptype);
clipmove_ex(&spri->x, &spri->y, &daz, &dasectnum, ((xchange * TICSPERFRAME) << 11), ((ychange * TICSPERFRAME) << 11), cd, (4 << 8), (4 << 8), cliptype, result);
}
if (dasectnum < 0 || (dasectnum >= 0 && actor->actorstayput >= 0 && actor->actorstayput != dasectnum))
@ -428,15 +429,13 @@ int movesprite_ex_r(DDukeActor* actor, int xchange, int ychange, int zchange, un
if (dasectnum < 0) dasectnum = 0;
return result.setSector(dasectnum);
}
if ((retval & kHitTypeMask) > kHitSector && (actor->cgg == 0)) spri->ang += 768;
if ((result.type == kHitSector || result.type == kHitSprite) && (actor->cgg == 0)) spri->ang += 768;
}
else
{
if (spri->statnum == STAT_PROJECTILE)
retval =
clipmove_ex(&spri->x, &spri->y, &daz, &dasectnum, ((xchange * TICSPERFRAME) << 11), ((ychange * TICSPERFRAME) << 11), 8L, (4 << 8), (4 << 8), cliptype, result);
else
retval =
clipmove_ex(&spri->x, &spri->y, &daz, &dasectnum, ((xchange * TICSPERFRAME) << 11), ((ychange * TICSPERFRAME) << 11), 128, (4 << 8), (4 << 8), cliptype, result);
}
@ -446,10 +445,10 @@ int movesprite_ex_r(DDukeActor* actor, int xchange, int ychange, int zchange, un
daz = spri->z + ((zchange * TICSPERFRAME) >> 3);
if ((daz > actor->ceilingz) && (daz <= actor->floorz))
spri->z = daz;
else if (retval == 0)
else if (result.type == kHitNone)
return result.setSector(dasectnum);
return retval;
return result.type;
}
//---------------------------------------------------------------------------

View file

@ -179,9 +179,11 @@ 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, short* sect, int xv, int yv, int wal, int ceil, int flor, int ct, Collision& 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)
{
int res = clipmove(x, y, z, sect, xv, yv, wal, ceil, flor, ct);
short sect16 = *sect;
int res = clipmove(x, y, z, &sect16, xv, yv, wal, ceil, flor, ct);
*sect = sect16;
return result.setFromEngine(res);
}

View file

@ -618,8 +618,8 @@ void playerisdead(int snum, int psectlotag, int fz, int cz)
s->zvel = -348;
}
clipmove(&p->pos.x, &p->pos.y, &p->pos.z, &p->cursectnum, 0, 0, 164, (4 << 8), (4 << 8), CLIPMASK0);
// p->bobcounter += 32;
Collision coll;
clipmove_ex(&p->pos.x, &p->pos.y, &p->pos.z, &p->cursectnum, 0, 0, 164, (4 << 8), (4 << 8), CLIPMASK0, coll);
}
backupplayer(p);

View file

@ -945,7 +945,9 @@ static int LoadTheMap(MapRecord *mi, struct player_struct *p, int gamemode)
}
currentLevel = mi;
engineLoadBoard(mi->fileName, isShareware(), &p->pos, &lbang, &p->cursectnum);
short sect;
engineLoadBoard(mi->fileName, isShareware(), &p->pos, &lbang, &sect);// &p->cursectnum);
p->cursectnum = sect;
SECRET_SetMapName(mi->DisplayName(), mi->name);
STAT_NewLevel(mi->fileName);

View file

@ -1410,7 +1410,7 @@ void checkhitsprite_d(DDukeActor* targ, DDukeActor* proj)
if ((s->cstat & 48) == 0)
s->ang = (pspr->ang + 1024) & 2047;
s->xvel = -(pspr->extra << 2);
short j = s->sectnum;
j = s->sectnum;
pushmove(&s->x, &s->y, &s->z, &j, 128L, (4 << 8), (4 << 8), CLIPMASK0);
if (j != s->sectnum && j >= 0 && j < MAXSECTORS)
changeactorsect(targ, j);

View file

@ -198,7 +198,8 @@ struct player_struct
int aim_mode, ftt;
short cursectnum, last_extra, subweapon;
int cursectnum;
short last_extra, subweapon;
short ammo_amount[MAX_WEAPONS], frag, fraggedself;
short curr_weapon, last_weapon, tipincs, wantweaponfire;
@ -302,6 +303,11 @@ struct Collision
int legacyVal; // should be removed later, but needed for converting back for unadjusted code.
DDukeActor* actor;
Collision() = default;
explicit Collision(int v)
{
setFromEngine(v);
}
int setNone()
{
type = kHitNone;

View file

@ -158,9 +158,9 @@ struct DukePlayer
native int bobcounter;
native int randomflamex, crack_time;
native int aim_mode, ftt;
native int cursectnum, aim_mode, ftt;
native int16 cursectnum, last_extra, subweapon;
native int16 last_extra, subweapon;
native int16 ammo_amount[DukeWpn.MAX_WEAPONS], frag, fraggedself;
native int16 curr_weapon, last_weapon, tipincs, wantweaponfire;