- Duke: cleanup on z-checks, part 1.

This commit is contained in:
Christoph Oelckers 2022-02-04 00:45:24 +01:00
parent 4506b5cb08
commit b853e9caa0
4 changed files with 35 additions and 34 deletions

View file

@ -1270,7 +1270,7 @@ void bounce(DDukeActor* actor)
int daang = getangle(sectp->firstWall()->delta()); int daang = getangle(sectp->firstWall()->delta());
int k, l; int k, l;
if (actor->int_pos().Z < (actor->actor_int_floorz() + actor->actor_int_ceilingz()) >> 1) if (actor->spr.pos.Z < (actor->floorz + actor->ceilingz) * 0.5)
k = sectp->ceilingheinum; k = sectp->ceilingheinum;
else else
k = sectp->floorheinum; k = sectp->floorheinum;
@ -1645,7 +1645,7 @@ void recon(DDukeActor *actor, int explosion, int firelaser, int attacksnd, int p
actor->spr.ang += 96; actor->spr.ang += 96;
actor->spr.xvel = 128; actor->spr.xvel = 128;
int j = ssp(actor, CLIPMASK0); int j = ssp(actor, CLIPMASK0);
if (j != 1 || actor->int_pos().Z > actor->actor_int_floorz()) if (j != 1 || actor->spr.pos.Z > actor->floorz)
{ {
for (int l = 0; l < 16; l++) for (int l = 0; l < 16; l++)
RANDOMSCRAP(actor); RANDOMSCRAP(actor);
@ -1659,8 +1659,8 @@ void recon(DDukeActor *actor, int explosion, int firelaser, int attacksnd, int p
} }
else else
{ {
if (actor->int_pos().Z > actor->actor_int_floorz() - (48 << 8)) if (actor->spr.pos.Z > actor->floorz - 48)
actor->set_int_z(actor->actor_int_floorz() - (48 << 8)); actor->spr.pos.Z = actor->floorz - 48;
} }
int x; int x;
@ -1808,7 +1808,7 @@ void ooz(DDukeActor *actor)
actor->spr.yrepeat = j; actor->spr.yrepeat = j;
actor->spr.xrepeat = x; actor->spr.xrepeat = x;
actor->set_int_z(actor->actor_int_floorz()); actor->spr.pos.Z = actor->floorz;
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
@ -2320,7 +2320,7 @@ bool bloodpool(DDukeActor* actor, bool puke)
int x; int x;
int p = findplayer(actor, &x); int p = findplayer(actor, &x);
actor->set_int_z(actor->actor_int_floorz() - (FOURSLEIGHT)); actor->spr.pos.Z = actor->floorz - FOURSLEIGHT_F;
if (actor->temp_data[2] < 32) if (actor->temp_data[2] < 32)
{ {
@ -2449,7 +2449,7 @@ void glasspieces(DDukeActor* actor)
return; return;
} }
if (actor->int_pos().Z == actor->actor_int_floorz() - (FOURSLEIGHT) && actor->temp_data[0] < 3) if (actor->spr.pos.Z == actor->floorz - FOURSLEIGHT_F && actor->temp_data[0] < 3)
{ {
actor->spr.zvel = -((3 - actor->temp_data[0]) << 8) - (krand() & 511); actor->spr.zvel = -((3 - actor->temp_data[0]) << 8) - (krand() & 511);
if (sectp->lotag == 2) if (sectp->lotag == 2)
@ -4401,7 +4401,7 @@ void handle_se24(DDukeActor *actor, bool scroll, int shift)
wallswitchcheck(a2)) wallswitchcheck(a2))
continue; continue;
if (a2->int_pos().Z > (a2->actor_int_floorz() - (16 << 8))) if (a2->spr.pos.Z > a2->floorz - 16)
{ {
a2->add_int_pos({ x >> shift , y >> shift, 0 }); a2->add_int_pos({ x >> shift , y >> shift, 0 });
@ -4880,7 +4880,7 @@ void makeitfall(DDukeActor* actor)
actor->floorz = actor->sector()->floorz; actor->floorz = actor->sector()->floorz;
} }
if( actor->int_pos().Z < actor->actor_int_floorz()-(FOURSLEIGHT) ) if( actor->spr.pos.Z < actor->floorz - FOURSLEIGHT_F)
{ {
if( actor->sector()->lotag == 2 && actor->spr.zvel > 3122 ) if( actor->sector()->lotag == 2 && actor->spr.zvel > 3122 )
actor->spr.zvel = 3144; actor->spr.zvel = 3144;
@ -4889,9 +4889,9 @@ void makeitfall(DDukeActor* actor)
else actor->spr.zvel = 6144; else actor->spr.zvel = 6144;
actor->add_int_z(actor->spr.zvel); actor->add_int_z(actor->spr.zvel);
} }
if( actor->int_pos().Z >= actor->actor_int_floorz()-(FOURSLEIGHT) ) if (actor->spr.pos.Z >= actor->floorz - FOURSLEIGHT_F)
{ {
actor->set_int_z(actor->actor_int_floorz() - FOURSLEIGHT); actor->spr.pos.Z = actor->floorz - FOURSLEIGHT_F;
actor->spr.zvel = 0; actor->spr.zvel = 0;
} }
} }
@ -5113,7 +5113,7 @@ void fall_common(DDukeActor *actor, int playernum, int JIBS6, int DRONE, int BLO
} }
else actor->cgg--; else actor->cgg--;
if (actor->int_pos().Z < (actor->actor_int_floorz() - FOURSLEIGHT)) if (actor->spr.pos.Z < actor->floorz - FOURSLEIGHT_F)
{ {
actor->spr.zvel += c; actor->spr.zvel += c;
actor->add_int_z(actor->spr.zvel); actor->add_int_z(actor->spr.zvel);

View file

@ -496,12 +496,12 @@ int movesprite_ex_d(DDukeActor* actor, int xchange, int ychange, int zchange, un
} }
actor->set_int_xy(pos.X, pos.Y); actor->set_int_xy(pos.X, pos.Y);
if (dasectp != nullptr) if (dasectp != nullptr && dasectp != actor->sector())
if (dasectp != actor->sector()) ChangeActorSect(actor, dasectp);
ChangeActorSect(actor, dasectp);
int daz = actor->int_pos().Z + ((zchange * TICSPERFRAME) >> 3); double daz = actor->spr.pos.Z + ((zchange * TICSPERFRAME) >> 3) * zinttoworld;
if ((daz > actor->actor_int_ceilingz()) && (daz <= actor->actor_int_floorz())) if (daz > actor->ceilingz && daz <= actor->floorz)
actor->set_int_z(daz); actor->spr.pos.Z = daz;
else if (result.type == kHitNone) else if (result.type == kHitNone)
return result.setSector(dasectp); return result.setSector(dasectp);
@ -1558,8 +1558,8 @@ static void weaponcommon_d(DDukeActor* proj)
proj->spr.zvel = -1; proj->spr.zvel = -1;
} }
else else
if ((proj->int_pos().Z > proj->actor_int_floorz() && proj->sector()->lotag != 1) || if ((proj->spr.pos.Z > proj->floorz && proj->sector()->lotag != 1) ||
(proj->int_pos().Z > proj->actor_int_floorz() + (16 << 8) && proj->sector()->lotag == 1)) (proj->spr.pos.Z > proj->floorz + 16 && proj->sector()->lotag == 1))
{ {
coll.setSector(proj->sector()); coll.setSector(proj->sector());
if (proj->sector()->lotag != 1) if (proj->sector()->lotag != 1)
@ -2387,8 +2387,7 @@ static void greenslime(DDukeActor *actor)
actor->spr.yrepeat = 16 + bsin(actor->temp_data[1], -13); actor->spr.yrepeat = 16 + bsin(actor->temp_data[1], -13);
if (rnd(4) && (sectp->ceilingstat & CSTAT_SECTOR_SKY) == 0 && if (rnd(4) && (sectp->ceilingstat & CSTAT_SECTOR_SKY) == 0 &&
abs(actor->actor_int_floorz() - actor->actor_int_ceilingz()) fabs(actor->floorz - actor->ceilingz) < 192)
< (192 << 8))
{ {
actor->spr.zvel = 0; actor->spr.zvel = 0;
actor->temp_data[0]++; actor->temp_data[0]++;
@ -2418,7 +2417,7 @@ static void greenslime(DDukeActor *actor)
makeitfall(actor); makeitfall(actor);
if (actor->int_pos().Z > actor->actor_int_floorz() - (8 << 8)) if (actor->spr.pos.Z > actor->floorz - 8)
{ {
actor->spr.yrepeat -= 4; actor->spr.yrepeat -= 4;
actor->spr.xrepeat += 2; actor->spr.xrepeat += 2;
@ -2429,9 +2428,9 @@ static void greenslime(DDukeActor *actor)
if (actor->spr.xrepeat > 8) actor->spr.xrepeat -= 4; if (actor->spr.xrepeat > 8) actor->spr.xrepeat -= 4;
} }
if (actor->int_pos().Z > actor->actor_int_floorz() - 2048) if (actor->spr.pos.Z > actor->floorz - 8)
{ {
actor->set_int_z(actor->actor_int_floorz() - 2048); actor->spr.pos.Z = actor->floorz - 8;
actor->temp_data[0] = 0; actor->temp_data[0] = 0;
actor->spr.xvel = 0; actor->spr.xvel = 0;
} }
@ -2495,8 +2494,8 @@ static void flamethrowerflame(DDukeActor *actor)
coll.setSector(actor->sector()); coll.setSector(actor->sector());
actor->spr.zvel = -1; actor->spr.zvel = -1;
} }
else if ((actor->int_pos().Z > actor->actor_int_floorz() && actor->sector()->lotag != 1) else if ((actor->spr.pos.Z > actor->floorz && actor->sector()->lotag != 1)
|| (actor->int_pos().Z > actor->actor_int_floorz() + (16 << 8) && actor->sector()->lotag == 1)) || (actor->spr.pos.Z > actor->floorz + 16 && actor->sector()->lotag == 1))
{ {
coll.setSector(actor->sector()); coll.setSector(actor->sector());
if (actor->sector()->lotag != 1) if (actor->sector()->lotag != 1)
@ -2583,18 +2582,18 @@ static void heavyhbomb(DDukeActor *actor)
{ {
makeitfall(actor); makeitfall(actor);
if (sectp->lotag != 1 && actor->int_pos().Z >= actor->actor_int_floorz() - (FOURSLEIGHT) && actor->spr.yvel < 3) if (sectp->lotag != 1 && actor->spr.pos.Z >= actor->floorz - FOURSLEIGHT_F && actor->spr.yvel < 3)
{ {
if (actor->spr.yvel > 0 || (actor->spr.yvel == 0 && actor->actor_int_floorz() == sectp->int_floorz())) if (actor->spr.yvel > 0 || (actor->spr.yvel == 0 && actor->floorz == sectp->floorz))
S_PlayActorSound(PIPEBOMB_BOUNCE, actor); S_PlayActorSound(PIPEBOMB_BOUNCE, actor);
actor->spr.zvel = -((4 - actor->spr.yvel) << 8); actor->spr.zvel = -((4 - actor->spr.yvel) << 8);
if (actor->sector()->lotag == 2) if (actor->sector()->lotag == 2)
actor->spr.zvel >>= 2; actor->spr.zvel >>= 2;
actor->spr.yvel++; actor->spr.yvel++;
} }
if (actor->int_pos().Z < actor->actor_int_ceilingz()) // && sectp->lotag != 2 ) if (actor->spr.pos.Z < actor->ceilingz) // && sectp->lotag != 2 )
{ {
actor->set_int_z(actor->actor_int_ceilingz() + (3 << 8)); actor->spr.pos.Z = actor->ceilingz + 3;
actor->spr.zvel = 0; actor->spr.zvel = 0;
} }
} }

View file

@ -415,9 +415,9 @@ int movesprite_ex_r(DDukeActor* actor, int xchange, int ychange, int zchange, un
if (dasectp) if (dasectp)
if ((dasectp != actor->sector())) if ((dasectp != actor->sector()))
ChangeActorSect(actor, dasectp); ChangeActorSect(actor, dasectp);
int daz = actor->int_pos().Z + ((zchange * TICSPERFRAME) >> 3); double daz = actor->spr.pos.Z + ((zchange * TICSPERFRAME) >> 3) * zinttoworld;
if ((daz > actor->actor_int_ceilingz()) && (daz <= actor->actor_int_floorz())) if (daz > actor->ceilingz && daz <= actor->floorz)
actor->set_int_z(daz); actor->spr.pos.Z = daz;
else if (result.type == kHitNone) else if (result.type == kHitNone)
return result.setSector(dasectp); return result.setSector(dasectp);

View file

@ -434,6 +434,8 @@ enum miscConstants
DUKE3D_NO_WIDESCREEN_PINNING = 1 << 0, DUKE3D_NO_WIDESCREEN_PINNING = 1 << 0,
}; };
constexpr double FOURSLEIGHT_F = 1.0;
enum { enum {
MUS_INTRO = 0, MUS_INTRO = 0,
MUS_BRIEFING = 1, MUS_BRIEFING = 1,