- wrapped user.hiz reads.

This commit is contained in:
Christoph Oelckers 2022-08-20 21:48:57 +02:00
parent ac3f6d73e3
commit d117544da8
11 changed files with 44 additions and 53 deletions

View file

@ -349,7 +349,7 @@ int DoActorSectorDamage(DSWActor* actor)
}
// note that most squishing is done in vator.c
if (actor->user.lo_sectp && actor->user.hi_sectp && labs(actor->user.int_loz() - actor->user.hiz) < (ActorSizeZ(actor) >> 1))
if (actor->user.lo_sectp && actor->user.hi_sectp && labs(actor->user.int_loz() - actor->user.int_hiz()) < (ActorSizeZ(actor) >> 1))
{
actor->user.Health = 0;
if (SpawnShrap(actor, nullptr, WPN_NM_SECTOR_SQUISH))
@ -663,7 +663,7 @@ int DoActorJump(DSWActor* actor)
actor->add_int_z(actor->user.jump_speed * ACTORMOVETICS);
// if player gets to close the ceiling while jumping
int minh = actor->user.hiz + (tileHeight(actor->spr.picnum) << 8);
int minh = actor->user.int_hiz() + (tileHeight(actor->spr.picnum) << 8);
if (actor->int_pos().Z < minh)
{
// put player at the ceiling
@ -829,7 +829,7 @@ int DoJump(DSWActor* actor)
actor->add_int_z(actor->user.jump_speed * ACTORMOVETICS);
// if player gets to close the ceiling while jumping
int minh = actor->user.hiz + (tileHeight(actor->spr.picnum) << 8);
int minh = actor->user.int_hiz() + (tileHeight(actor->spr.picnum) << 8);
if (actor->int_pos().Z < minh)
{
// put player at the ceiling

View file

@ -1341,7 +1341,7 @@ Collision move_scan(DSWActor* actor, int ang, int dist, int *stopx, int *stopy,
auto pos = actor->spr.pos;
sang = actor->int_ang();
loz = actor->user.int_loz();
hiz = actor->user.hiz;
hiz = actor->user.int_hiz();
lowActor = actor->user.lowActor;
highActor = actor->user.highActor;
lo_sectp = actor->user.lo_sectp;

View file

@ -630,7 +630,7 @@ int DoCoolgMatchPlayerZ(DSWActor* actor)
// save off lo and hi z
loz = actor->user.int_loz();
hiz = actor->user.hiz;
hiz = actor->user.int_hiz();
// adjust loz/hiz for water depth
if (actor->user.lo_sectp && actor->user.lo_sectp->hasU() && FixedToInt(actor->user.lo_sectp->depth_fixed))
@ -664,7 +664,7 @@ int DoCoolgMatchPlayerZ(DSWActor* actor)
actor->user.Counter = (actor->user.Counter + (ACTORMOVETICS<<3)) & 2047;
actor->set_int_z(actor->user.pos.Z + MulScale(COOLG_BOB_AMT, bsin(actor->user.Counter), 14));
bound = actor->user.hiz + actor->user.ceiling_dist + COOLG_BOB_AMT;
bound = actor->user.int_hiz() + actor->user.ceiling_dist + COOLG_BOB_AMT;
if (actor->int_pos().Z < bound)
{
// bumped something
@ -693,7 +693,7 @@ int InitCoolgCircle(DSWActor* actor)
// z velocity
actor->user.jump_speed = 400 + RANDOM_P2(256);
if (labs(actor->user.pos.Z - actor->user.hiz) < labs(actor->user.pos.Z - actor->user.int_loz()))
if (labs(actor->user.pos.Z - actor->user.int_hiz()) < abs(actor->user.pos.Z - actor->user.int_loz()))
actor->user.jump_speed = -actor->user.jump_speed;
actor->user.WaitTics = (RandomRange(3)+1) * 120;
@ -721,7 +721,7 @@ int DoCoolgCircle(DSWActor* actor)
// move in the z direction
actor->user.pos.Z -= actor->user.jump_speed * ACTORMOVETICS;
bound = actor->user.hiz + actor->user.ceiling_dist + COOLG_BOB_AMT;
bound = actor->user.int_hiz() + actor->user.ceiling_dist + COOLG_BOB_AMT;
if (actor->user.pos.Z < bound)
{
// bumped something

View file

@ -453,7 +453,7 @@ int DoEelMatchPlayerZ(DSWActor* actor)
// save off lo and hi z
loz = actor->user.int_loz();
hiz = actor->user.hiz;
hiz = actor->user.int_hiz();
// adjust loz/hiz for water depth
if (actor->user.lo_sectp && actor->user.lo_sectp->hasU() && FixedToInt(actor->user.lo_sectp->depth_fixed))
@ -499,7 +499,7 @@ int DoEelMatchPlayerZ(DSWActor* actor)
actor->user.Counter = (actor->user.Counter + (ACTORMOVETICS << 3) + (ACTORMOVETICS << 1)) & 2047;
actor->set_int_z(actor->user.pos.Z + MulScale(EEL_BOB_AMT, bsin(actor->user.Counter), 14));
bound = actor->user.hiz + actor->user.ceiling_dist + EEL_BOB_AMT;
bound = actor->user.int_hiz() + actor->user.ceiling_dist + EEL_BOB_AMT;
if (actor->int_pos().Z < bound)
{
// bumped something

View file

@ -931,6 +931,7 @@ struct USER
}
int int_loz() const { return loz; }
int int_hiz() const { return hiz; }
//
// Variables that can be used by actors and Player

View file

@ -361,7 +361,7 @@ int DoHornetMatchPlayerZ(DSWActor* actor)
// save off lo and hi z
loz = actor->user.int_loz();
hiz = actor->user.hiz;
hiz = actor->user.int_hiz();
// adjust loz/hiz for water depth
if (actor->user.lo_sectp && actor->user.lo_sectp->hasU() && FixedToInt(actor->user.lo_sectp->depth_fixed))
@ -395,7 +395,7 @@ int DoHornetMatchPlayerZ(DSWActor* actor)
actor->user.Counter = (actor->user.Counter + (ACTORMOVETICS << 3) + (ACTORMOVETICS << 1)) & 2047;
actor->set_int_z(actor->user.pos.Z + MulScale(HORNET_BOB_AMT, bsin(actor->user.Counter), 14));
bound = actor->user.hiz + actor->user.ceiling_dist + HORNET_BOB_AMT;
bound = actor->user.int_hiz() + actor->user.ceiling_dist + HORNET_BOB_AMT;
if (actor->int_pos().Z < bound)
{
// bumped something
@ -424,7 +424,7 @@ int InitHornetCircle(DSWActor* actor)
// z velocity
actor->user.jump_speed = 200 + RANDOM_P2(128);
if (labs(actor->user.pos.Z - actor->user.hiz) < labs(actor->user.pos.Z - actor->user.int_loz()))
if (labs(actor->user.pos.Z - actor->user.int_hiz()) < abs(actor->user.pos.Z - actor->user.int_loz()))
actor->user.jump_speed = -actor->user.jump_speed;
actor->user.WaitTics = (RandomRange(3)+1) * 60;
@ -463,7 +463,7 @@ int DoHornetCircle(DSWActor* actor)
// move in the z direction
actor->user.pos.Z -= actor->user.jump_speed * ACTORMOVETICS;
bound = actor->user.hiz + actor->user.ceiling_dist + HORNET_BOB_AMT;
bound = actor->user.int_hiz() + actor->user.ceiling_dist + HORNET_BOB_AMT;
if (actor->user.pos.Z < bound)
{
// bumped something

View file

@ -468,7 +468,7 @@ int DoBloodSpray(DSWActor* actor)
case kHitSector:
{
// hit floor
if (actor->int_pos().Z > ((actor->user.hiz + actor->user.int_loz()) >> 1))
if (actor->int_pos().Z > ((actor->user.int_hiz() + actor->user.int_loz()) >> 1))
{
if (actor->user.Flags & (SPR_UNDERWATER))
actor->user.Flags |= (SPR_BOUNCE); // no bouncing
@ -643,7 +643,7 @@ int DoPhosphorus(DSWActor* actor)
else
{
// hit a sector
if (actor->int_pos().Z > ((actor->user.hiz + actor->user.int_loz()) >> 1))
if (actor->int_pos().Z > ((actor->user.int_hiz() + actor->user.int_loz()) >> 1))
{
// hit a floor
if (!(actor->user.Flags & SPR_BOUNCE))
@ -672,7 +672,7 @@ int DoPhosphorus(DSWActor* actor)
else
{
// hit floor
if (actor->int_pos().Z > ((actor->user.hiz + actor->user.int_loz()) >> 1))
if (actor->int_pos().Z > ((actor->user.int_hiz() + actor->user.int_loz()) >> 1))
{
if (actor->user.Flags & (SPR_UNDERWATER))
actor->user.Flags |= (SPR_BOUNCE); // no bouncing
@ -849,7 +849,7 @@ int DoChemBomb(DSWActor* actor)
else
{
// hit a sector
if (actor->int_pos().Z > ((actor->user.hiz + actor->user.int_loz()) >> 1))
if (actor->int_pos().Z > ((actor->user.int_hiz() + actor->user.int_loz()) >> 1))
{
// hit a floor
if (!(actor->user.Flags & SPR_BOUNCE))
@ -888,7 +888,7 @@ int DoChemBomb(DSWActor* actor)
else
{
// hit floor
if (actor->int_pos().Z > ((actor->user.hiz + actor->user.int_loz()) >> 1))
if (actor->int_pos().Z > ((actor->user.int_hiz() + actor->user.int_loz()) >> 1))
{
if (actor->user.Flags & (SPR_UNDERWATER))
actor->user.Flags |= (SPR_BOUNCE); // no bouncing
@ -1064,7 +1064,7 @@ int DoCaltrops(DSWActor* actor)
else
{
// hit a sector
if (actor->int_pos().Z > ((actor->user.hiz + actor->user.int_loz()) >> 1))
if (actor->int_pos().Z > ((actor->user.int_hiz() + actor->user.int_loz()) >> 1))
{
// hit a floor
if (!(actor->user.Flags & SPR_BOUNCE))
@ -1094,7 +1094,7 @@ int DoCaltrops(DSWActor* actor)
else
{
// hit floor
if (actor->int_pos().Z > ((actor->user.hiz + actor->user.int_loz()) >> 1))
if (actor->int_pos().Z > ((actor->user.int_hiz() + actor->user.int_loz()) >> 1))
{
if (actor->user.Flags & (SPR_UNDERWATER))
actor->user.Flags |= (SPR_BOUNCE); // no bouncing

View file

@ -899,7 +899,7 @@ int PickJumpMaxSpeed(DSWActor* actor, short max_speed)
while (true)
{
if (zh - Z(GetJumpHeight(actor->user.jump_speed, actor->user.jump_grav)) - Z(16) > actor->user.hiz)
if (zh - Z(GetJumpHeight(actor->user.jump_speed, actor->user.jump_grav)) - Z(16) > actor->user.int_hiz())
break;
actor->user.jump_speed += 100;

View file

@ -4619,7 +4619,7 @@ int move_actor(DSWActor* actor, int xchange, int ychange, int zchange)
// save off x,y values
auto apos = actor->spr.pos;
loz = actor->user.int_loz();
hiz = actor->user.hiz;
hiz = actor->user.int_hiz();
lowActor = actor->user.lowActor;
highActor = actor->user.highActor;
lo_sectp = actor->user.lo_sectp;
@ -6469,10 +6469,10 @@ Collision move_missile(DSWActor* actor, int xchange, int ychange, int zchange, i
// this case is currently treated like it hit a sector
// test for hitting ceiling or floor
if (clippos.Z - zh <= actor->user.hiz + ceildist)
if (clippos.Z - zh <= actor->user.int_hiz() + ceildist)
{
// normal code
actor->set_int_z(actor->user.hiz + zh + ceildist);
actor->set_int_z(actor->user.int_hiz() + zh + ceildist);
if (retval.type == kHitNone)
retval.setSector(dasect);
}
@ -6616,7 +6616,7 @@ Collision move_ground_missile(DSWActor* actor, int xchange, int ychange, int cei
actor->user.highActor = nullptr; actor->user.lowActor = nullptr;
actor->set_int_z(actor->user.int_loz() - Z(8));
if (labs(actor->user.hiz - actor->user.int_loz()) < Z(12))
if (labs(actor->user.int_hiz() - actor->user.int_loz()) < Z(12))
{
// we've gone into a very small place - kill it
retval.setVoid();

View file

@ -4263,7 +4263,7 @@ bool WeaponMoveHit(DSWActor* actor)
ASSERT(sectp->extra != -1);
// hit floor - closer to floor than ceiling
if (actor->int_pos().Z > ((actor->user.hiz + actor->user.int_loz()) >> 1))
if (actor->int_pos().Z > ((actor->user.int_hiz() + actor->user.int_loz()) >> 1))
{
// hit a floor sprite
if (actor->user.lowActor)
@ -7481,7 +7481,7 @@ int DoStar(DSWActor* actor)
bool did_hit_wall;
auto hit_sect = actor->user.coll.hitSector;
if (actor->int_pos().Z > ((actor->user.hiz + actor->user.int_loz()) >> 1))
if (actor->int_pos().Z > ((actor->user.int_hiz() + actor->user.int_loz()) >> 1))
{
if (hit_sect->hasU() && FixedToInt(hit_sect->depth_fixed) > 0)
{
@ -7511,7 +7511,7 @@ int DoStar(DSWActor* actor)
actor->user.change.X = MulScale(actor->user.change.X, 64000 + (RandomRange(64000) - 32000), 16);
actor->user.change.Y = MulScale(actor->user.change.Y, 64000 + (RandomRange(64000) - 32000), 16);
if (actor->int_pos().Z > ((actor->user.hiz + actor->user.int_loz()) >> 1))
if (actor->int_pos().Z > ((actor->user.int_hiz() + actor->user.int_loz()) >> 1))
actor->user.change.Z = MulScale(actor->user.change.Z, 50000, 16); // floor
else
actor->user.change.Z = MulScale(actor->user.change.Z, 40000, 16); // ceiling
@ -7553,7 +7553,7 @@ int DoStar(DSWActor* actor)
// 32000 to 96000
actor->user.change.X = MulScale(actor->user.change.X, 64000 + (RandomRange(64000) - 32000), 16);
actor->user.change.Y = MulScale(actor->user.change.Y, 64000 + (RandomRange(64000) - 32000), 16);
if (actor->int_pos().Z > ((actor->user.hiz + actor->user.int_loz()) >> 1))
if (actor->int_pos().Z > ((actor->user.int_hiz() + actor->user.int_loz()) >> 1))
actor->user.change.Z = MulScale(actor->user.change.Z, 50000, 16); // floor
else
actor->user.change.Z = MulScale(actor->user.change.Z, 40000, 16); // ceiling
@ -8303,7 +8303,7 @@ int DoGrenade(DSWActor* actor)
else
{
// hit a sector
if (actor->int_pos().Z > ((actor->user.hiz + actor->user.int_loz()) >> 1))
if (actor->int_pos().Z > ((actor->user.int_hiz() + actor->user.int_loz()) >> 1))
{
// hit a floor
if (!(actor->user.Flags & SPR_BOUNCE))
@ -8339,7 +8339,7 @@ int DoGrenade(DSWActor* actor)
else
{
// hit floor
if (actor->int_pos().Z > ((actor->user.hiz + actor->user.int_loz()) >> 1))
if (actor->int_pos().Z > ((actor->user.int_hiz() + actor->user.int_loz()) >> 1))
{
if (actor->user.Flags & (SPR_UNDERWATER))
actor->user.Flags |= (SPR_BOUNCE); // no bouncing underwater
@ -8502,7 +8502,7 @@ int DoVulcanBoulder(DSWActor* actor)
else
{
// hit a sloped sector
if (actor->int_pos().Z > ((actor->user.hiz + actor->user.int_loz()) >> 1))
if (actor->int_pos().Z > ((actor->user.int_hiz() + actor->user.int_loz()) >> 1))
{
// hit a floor
actor->user.change.X = MulScale(actor->user.change.X, 30000, 16);
@ -8527,7 +8527,7 @@ int DoVulcanBoulder(DSWActor* actor)
else
{
// hit unsloped floor
if (actor->int_pos().Z > ((actor->user.hiz + actor->user.int_loz()) >> 1))
if (actor->int_pos().Z > ((actor->user.int_hiz() + actor->user.int_loz()) >> 1))
{
actor->user.coll.setNone();
actor->user.Counter = 0;
@ -8855,7 +8855,7 @@ int DoMine(DSWActor* actor)
else if ((hitActor->spr.cstat & CSTAT_SPRITE_ALIGNMENT_FLOOR))
{
// hit floor
if (actor->int_pos().Z > ((actor->user.hiz + actor->user.int_loz()) >> 1))
if (actor->int_pos().Z > ((actor->user.int_hiz() + actor->user.int_loz()) >> 1))
actor->user.Flags2 |= (SPR2_ATTACH_FLOOR);
else
actor->user.Flags2 |= (SPR2_ATTACH_CEILING);
@ -8907,7 +8907,7 @@ int DoMine(DSWActor* actor)
SetMineStuck(actor);
// hit floor
if (actor->int_pos().Z > ((actor->user.hiz + actor->user.int_loz()) >> 1))
if (actor->int_pos().Z > ((actor->user.int_hiz() + actor->user.int_loz()) >> 1))
actor->user.Flags2 |= (SPR2_ATTACH_FLOOR);
else
actor->user.Flags2 |= (SPR2_ATTACH_CEILING);
@ -10389,9 +10389,9 @@ void SpawnExpZadjust(DSWActor* actor, DSWActor* expActor, int upper_zsize, int l
tos_z = expActor->int_pos().Z - upper_zsize;
bos_z = expActor->int_pos().Z + lower_zsize;
if (tos_z <= actor->user.hiz + Z(4))
if (tos_z <= actor->user.int_hiz() + Z(4))
{
expActor->set_int_z(actor->user.hiz + upper_zsize);
expActor->set_int_z(actor->user.int_hiz() + upper_zsize);
expActor->spr.cstat |= (CSTAT_SPRITE_YFLIP);
}
else if (bos_z > actor->user.int_loz())
@ -17043,7 +17043,7 @@ bool MissileHitDiveArea(DSWActor* actor)
if (SpriteInDiveArea(actor))
{
// make sure you are close to the floor
if (actor->int_pos().Z < ((actor->user.hiz + actor->user.int_loz()) >> 1))
if (actor->int_pos().Z < ((actor->user.int_hiz() + actor->user.int_loz()) >> 1))
return false;
// Check added by Jim because of sprite bridge over water
@ -17060,7 +17060,7 @@ bool MissileHitDiveArea(DSWActor* actor)
else if (SpriteInUnderwaterArea(actor))
{
// make sure you are close to the ceiling
if (actor->int_pos().Z > ((actor->user.hiz + actor->user.int_loz()) >> 1))
if (actor->int_pos().Z > ((actor->user.int_hiz() + actor->user.int_loz()) >> 1))
return false;
actor->user.Flags &= ~(SPR_UNDERWATER);
@ -17952,7 +17952,7 @@ int DoShrapVelocity(DSWActor* actor)
else
{
// hit a sector
if (actor->int_pos().Z > ((actor->user.hiz + actor->user.int_loz()) >> 1))
if (actor->int_pos().Z > ((actor->user.int_hiz() + actor->user.int_loz()) >> 1))
{
// hit a floor
if (!(actor->user.Flags & SPR_BOUNCE))
@ -17981,7 +17981,7 @@ int DoShrapVelocity(DSWActor* actor)
else
{
// hit floor
if (actor->int_pos().Z > ((actor->user.hiz + actor->user.int_loz()) >> 1))
if (actor->int_pos().Z > ((actor->user.int_hiz() + actor->user.int_loz()) >> 1))
{
actor->set_int_z(actor->user.int_loz());
if (actor->user.Flags & (SPR_UNDERWATER))
@ -18254,7 +18254,7 @@ int DoItemFly(DSWActor* actor)
case kHitSector:
{
// hit floor
if (actor->int_pos().Z > ((actor->user.hiz + actor->user.int_loz()) >> 1))
if (actor->int_pos().Z > ((actor->user.int_hiz() + actor->user.int_loz()) >> 1))
{
actor->set_int_z(actor->user.int_loz());
actor->user.Counter = 0;

View file

@ -633,16 +633,6 @@ int SetupZilla(DSWActor* actor)
int NullZilla(DSWActor* actor)
{
#if 0
if (actor->user.State == s_ZillaDie)
{
getzsofslopeptr(actor->sector(), actor->int_pos().X, actor->spr.y, &actor->user.hiz, &actor->user.int_loz());
actor->user.lo_sectp = actor->sector();
actor->user.hi_sectp = actor->sector();
actor->spr.z = actor->user.int_loz();
}
#endif
getzsofslopeptr(actor->sector(), actor->int_pos().X, actor->int_pos().Y, &actor->user.hiz, &actor->user.loz);
actor->user.lo_sectp = actor->sector();
actor->user.hi_sectp = actor->sector();