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

This commit is contained in:
Christoph Oelckers 2022-02-04 00:55:12 +01:00
parent 6eabe4e152
commit 665ee69eba
7 changed files with 26 additions and 24 deletions

View file

@ -44,6 +44,8 @@ static constexpr double zmaptoworld = (1 / 256.); // this for necessary conversi
static constexpr double zinttoworld = (1 / 256.); // this is for conversions needed to make floats coexist with existing code.
static constexpr double zworldtoint = 256.;
static constexpr double REPEAT_SCALE = (1 / 64.); // map's 'repeat' values use 2.6 fixed point.
//=============================================================================
//
// Constants

View file

@ -5122,7 +5122,7 @@ void fall_common(DDukeActor *actor, int playernum, int JIBS6, int DRONE, int BLO
}
else
{
actor->set_int_z(actor->actor_int_floorz() - FOURSLEIGHT);
actor->spr.pos.Z = actor->floorz - FOURSLEIGHT_F;
if (badguy(actor) || (actor->isPlayer() && actor->GetOwner()))
{

View file

@ -1552,7 +1552,7 @@ static void weaponcommon_d(DDukeActor* proj)
if (coll.type != kHitSprite && proj->spr.picnum != FREEZEBLAST)
{
if (proj->int_pos().Z < proj->actor_int_ceilingz())
if (proj->spr.pos.Z < proj->ceilingz)
{
coll.setSector(proj->sector());
proj->spr.zvel = -1;
@ -2356,9 +2356,9 @@ static void greenslime(DDukeActor *actor)
actor->spr.zvel = 0;
actor->spr.cstat &= ~CSTAT_SPRITE_YFLIP;
if ((sectp->ceilingstat & CSTAT_SECTOR_SKY) || (actor->actor_int_ceilingz() + 6144) < actor->int_pos().Z)
if ((sectp->ceilingstat & CSTAT_SECTOR_SKY) || (actor->ceilingz + 24) < actor->spr.pos.Z)
{
actor->add_int_z(2048);
actor->spr.pos.Z += 8;
actor->temp_data[0] = 3;
return;
}
@ -2406,9 +2406,9 @@ static void greenslime(DDukeActor *actor)
if (actor->spr.zvel > -(2048 + 1024))
actor->spr.zvel -= 348;
actor->add_int_z(actor->spr.zvel);
if (actor->int_pos().Z < actor->actor_int_ceilingz() + 4096)
if (actor->spr.pos.Z < actor->ceilingz + 16)
{
actor->set_int_z(actor->actor_int_ceilingz() + 4096);
actor->spr.pos.Z = actor->ceilingz + 16;
actor->spr.xvel = 0;
actor->temp_data[0] = 2;
}
@ -2492,7 +2492,7 @@ static void flamethrowerflame(DDukeActor *actor)
if (coll.type != kHitSprite)
{
if (actor->int_pos().Z < actor->actor_int_ceilingz())
if (actor->spr.pos.Z < actor->ceilingz)
{
coll.setSector(actor->sector());
actor->spr.zvel = -1;

View file

@ -1244,13 +1244,13 @@ static void weaponcommon_r(DDukeActor *proj)
if (coll.type != kHitSprite && proj->spr.picnum != FREEZEBLAST)
{
if (proj->int_pos().Z < proj->actor_int_ceilingz())
if (proj->spr.pos.Z < proj->ceilingz)
{
coll.setSector(proj->sector());
proj->spr.zvel = -1;
}
else
if (proj->int_pos().Z > proj->actor_int_floorz())
if (proj->spr.pos.Z > proj->floorz)
{
coll.setSector(proj->sector());
if (proj->sector()->lotag != 1)
@ -2348,9 +2348,9 @@ static void heavyhbomb(DDukeActor *actor)
makeitfall(actor);
if (sectp->lotag != 1 && (!isRRRA() || sectp->lotag != 160) && actor->int_pos().Z >= actor->actor_int_floorz() - (FOURSLEIGHT) && actor->spr.yvel < 3)
if (sectp->lotag != 1 && (!isRRRA() || sectp->lotag != 160) && 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))
{
if (actor->spr.picnum != CHEERBOMB)
S_PlayActorSound(PIPEBOMB_BOUNCE, actor);
@ -2367,9 +2367,9 @@ static void heavyhbomb(DDukeActor *actor)
actor->spr.zvel >>= 2;
actor->spr.yvel++;
}
if (actor->spr.picnum != CHEERBOMB && actor->int_pos().Z < actor->actor_int_ceilingz() + (16 << 8) && sectp->lotag != 2)
if (actor->spr.picnum != CHEERBOMB && actor->spr.pos.Z < actor->ceilingz + 16 && sectp->lotag != 2)
{
actor->set_int_z(actor->actor_int_ceilingz() + (16 << 8));
actor->spr.pos.Z = actor->ceilingz + 16;
actor->spr.zvel = 0;
}
@ -2381,7 +2381,7 @@ static void heavyhbomb(DDukeActor *actor)
if (actor->sector()->lotag == 1 && actor->spr.zvel == 0)
{
actor->add_int_z(32 << 8);
actor->spr.pos.Z += 32;
if (actor->temp_data[5] == 0)
{
actor->temp_data[5] = 1;
@ -3815,7 +3815,7 @@ static int fallspecial(DDukeActor *actor, int playernum)
}
else if (actor->sector()->lotag == 802)
{
if (actor->spr.picnum != APLAYER && badguy(actor) && actor->int_pos().Z == actor->actor_int_floorz() - FOURSLEIGHT)
if (actor->spr.picnum != APLAYER && badguy(actor) && actor->spr.pos.Z == actor->floorz - FOURSLEIGHT_F)
{
fi.guts(actor, JIBS6, 5, playernum);
S_PlayActorSound(SQUISHED, actor);
@ -3839,7 +3839,7 @@ static int fallspecial(DDukeActor *actor, int playernum)
}
if (actor->spr.picnum != APLAYER && (badguy(actor) || actor->spr.picnum == HEN || actor->spr.picnum == COW || actor->spr.picnum == PIG || actor->spr.picnum == DOGRUN || actor->spr.picnum == RABBIT) && (!isRRRA() || actor->spriteextra < 128))
{
actor->set_int_z(actor->actor_int_floorz() - FOURSLEIGHT);
actor->spr.pos.Z = actor->floorz - FOURSLEIGHT_F;
actor->spr.zvel = 8000;
actor->spr.extra = 0;
actor->spriteextra++;

View file

@ -1307,11 +1307,11 @@ void DoActor(bool bSet, int lVar1, int lLabelID, int lVar2, DDukeActor* sActor,
break;
case ACTOR_HTFLOORZ:
if (bSet) act->floorz = lValue * zmaptoworld;
else SetGameVarID(lVar2, act->actor_int_floorz(), sActor, sPlayer);
else SetGameVarID(lVar2, act->floorz * (1/zmaptoworld), sActor, sPlayer);
break;
case ACTOR_HTCEILINGZ:
if (bSet) act->ceilingz = lValue * zmaptoworld;
else SetGameVarID(lVar2, act->actor_int_ceilingz(), sActor, sPlayer);
else SetGameVarID(lVar2, act->ceilingz * (1/zmaptoworld), sActor, sPlayer);
break;
case ACTOR_HTLASTVX:
if (bSet) act->ovel.X = lValue;
@ -1738,7 +1738,7 @@ int ParseState::parse(void)
insptr++;
if ((g_ac->isPlayer() && g_ac->spr.yrepeat < 36) || *insptr < g_ac->spr.yrepeat || ((g_ac->spr.yrepeat * (tileHeight(g_ac->spr.picnum) + 8)) << 2) < (g_ac->actor_int_floorz() - g_ac->actor_int_ceilingz()))
if ((g_ac->isPlayer() && g_ac->spr.yrepeat < 36) || *insptr < g_ac->spr.yrepeat || (g_ac->spr.yrepeat * (tileHeight(g_ac->spr.picnum) + 8) * REPEAT_SCALE) < g_ac->floorz - g_ac->ceilingz)
{
j = ((*insptr) - g_ac->spr.yrepeat) << 1;
if (abs(j)) g_ac->spr.yrepeat += Sgn(j);
@ -2469,7 +2469,7 @@ int ParseState::parse(void)
return 0;
case concmd_ifgapzl:
insptr++;
parseifelse( (( g_ac->actor_int_floorz() - g_ac->actor_int_ceilingz() ) >> 8 ) < *insptr);
parseifelse(int(g_ac->floorz - g_ac->ceilingz) < *insptr); // Note: int cast here is needed to use the same truncation behavior as the old fixed point code.
break;
case concmd_ifhitspace:
parseifelse(PlayerInput(g_p, SB_OPEN));
@ -2537,11 +2537,11 @@ int ParseState::parse(void)
break;
case concmd_iffloordistl:
insptr++;
parseifelse( (g_ac->actor_int_floorz() - g_ac->int_pos().Z) <= ((*insptr)<<8));
parseifelse(g_ac->floorz - g_ac->spr.pos.Z <= *insptr);
break;
case concmd_ifceilingdistl:
insptr++;
parseifelse( ( g_ac->int_pos().Z - g_ac->actor_int_ceilingz() ) <= ((*insptr)<<8));
parseifelse(g_ac->spr.pos.Z - g_ac->ceilingz <= *insptr);
break;
case concmd_palfrom:
insptr++;

View file

@ -3085,7 +3085,7 @@ HORIZONLY:
int blocked;
blocked = (pushmove(&p->pos, &p->cursector, 164, (4 << 8), (4 << 8), CLIPMASK0) < 0 && furthestangle(p->GetActor(), 8) < 512);
if (abs(pact->actor_int_floorz() - pact->actor_int_ceilingz()) < (48 << 8) || blocked)
if (fabs(pact->floorz - pact->ceilingz) < 48 || blocked)
{
if (!(pact->sector()->lotag & 0x8000) && (isanunderoperator(pact->sector()->lotag) ||
isanearoperator(pact->sector()->lotag)))

View file

@ -3938,7 +3938,7 @@ HORIZONLY:
else
blocked = (pushmove(&p->pos, &p->cursector, 16, (4 << 8), (4 << 8), CLIPMASK0) < 0 && furthestangle(p->GetActor(), 8) < 512);
if (abs(pact->actor_int_floorz() - pact->actor_int_ceilingz()) < (48 << 8) || blocked)
if (fabs(pact->floorz - pact->ceilingz) < 48 || blocked)
{
if (!(pact->sector()->lotag & 0x8000) && (isanunderoperator(pact->sector()->lotag) ||
isanearoperator(pact->sector()->lotag)))