diff --git a/source/games/sw/src/actor.cpp b/source/games/sw/src/actor.cpp index 4b876b1c5..3b0a7202e 100644 --- a/source/games/sw/src/actor.cpp +++ b/source/games/sw/src/actor.cpp @@ -397,7 +397,7 @@ int DoActorDebris(DSWActor* actor) KillActor(actor); return 0; case ZILLA_RUN_R0: - getzsofslopeptr(actor->sector(), actor->int_pos().X, actor->int_pos().Y, &actor->user.hiz, &actor->user.loz); + getzsofslopeptr(actor->sector(), actor->spr.pos.X, actor->spr.pos.Y, &actor->user.hiz, &actor->user.loz); actor->user.lo_sectp = actor->sector(); actor->user.hi_sectp = actor->sector(); actor->user.lowActor = nullptr; diff --git a/source/games/sw/src/ai.cpp b/source/games/sw/src/ai.cpp index 9bf425d70..aa70805f1 100644 --- a/source/games/sw/src/ai.cpp +++ b/source/games/sw/src/ai.cpp @@ -1328,8 +1328,6 @@ Collision move_scan(DSWActor* actor, int ang, int dist, int *stopx, int *stopy, int nx,ny; uint32_t cliptype = CLIPMASK_ACTOR; - int sang; - int loz, hiz; DSWActor* highActor; DSWActor* lowActor; sectortype* lo_sectp,* hi_sectp, *ssp; @@ -1339,9 +1337,9 @@ Collision move_scan(DSWActor* actor, int ang, int dist, int *stopx, int *stopy, // save off position info auto pos = actor->spr.pos; - sang = actor->int_ang(); - loz = actor->user.int_loz(); - hiz = actor->user.int_hiz(); + auto sang = actor->spr.angle; + auto loz = actor->user.loz; + auto hiz = actor->user.hiz; lowActor = actor->user.lowActor; highActor = actor->user.highActor; lo_sectp = actor->user.lo_sectp; @@ -1365,7 +1363,7 @@ Collision move_scan(DSWActor* actor, int ang, int dist, int *stopx, int *stopy, // reset position information actor->spr.pos = pos; - actor->set_int_ang(sang); + actor->spr.angle = sang; actor->user.loz = loz; actor->user.hiz = hiz; actor->user.lowActor = lowActor; diff --git a/source/games/sw/src/coolie.cpp b/source/games/sw/src/coolie.cpp index e234e2f16..3d803e57c 100644 --- a/source/games/sw/src/coolie.cpp +++ b/source/games/sw/src/coolie.cpp @@ -453,10 +453,10 @@ void EnemyDefaults(DSWActor* actor, ACTOR_ACTION_SET* action, PERSONALITY* perso } } - if (depth && labs(actor->int_pos().Z - actor->user.int_loz()) < Z(8)) + if (depth && abs(actor->spr.pos.Z - actor->user.loz) < 8) { actor->add_int_z(Z(depth)); - actor->user.loz = actor->int_pos().Z; + actor->user.loz = actor->spr.pos.Z; actor->backupz(); } diff --git a/source/games/sw/src/eel.cpp b/source/games/sw/src/eel.cpp index 7c62c50d2..d34c91792 100644 --- a/source/games/sw/src/eel.cpp +++ b/source/games/sw/src/eel.cpp @@ -424,13 +424,13 @@ int DoEelMatchPlayerZ(DSWActor* actor) { if (actor->user.hi_sectp) { - actor->user.hiz = actor->sector()->int_ceilingz() + Z(16); + actor->user.hiz = actor->sector()->ceilingz + 16; actor->user.hi_sectp = actor->sector(); } else { - if (actor->user.hiz < actor->sector()->int_ceilingz() + Z(16)) - actor->user.hiz = actor->sector()->int_ceilingz() + Z(16); + if (actor->user.hiz < actor->sector()->ceilingz + 16) + actor->user.hiz = actor->sector()->ceilingz + 16; } } diff --git a/source/games/sw/src/game.h b/source/games/sw/src/game.h index 787b81359..93bc0f4a8 100644 --- a/source/games/sw/src/game.h +++ b/source/games/sw/src/game.h @@ -930,8 +930,8 @@ struct USER memset(&WallP, 0, sizeof(USER) - myoffsetof(USER, WallP)); } - int int_loz() const { return loz; } - int int_hiz() const { return hiz; } + int int_loz() const { return loz * zworldtoint; } + int int_hiz() const { return hiz * zworldtoint; } // // Variables that can be used by actors and Player @@ -987,7 +987,7 @@ struct USER int16_t ceiling_dist; int16_t floor_dist; int16_t lo_step; - int hiz,loz; + double hiz, loz; int zclip; // z height to move up for clipmove int active_range; sectortype* hi_sectp, *lo_sectp; @@ -1763,10 +1763,30 @@ void FAFgetzrange(vec3_t pos, sectortype* sect, int32_t* loz, Collision* florhit, int32_t clipdist, int32_t clipmask); +inline void FAFgetzrange(vec3_t pos, sectortype* sect, + double* hiz, Collision* ceilhit, + double* loz, Collision* florhit, + int32_t clipdist, int32_t clipmask) +{ + int32_t hi, lo; + FAFgetzrange(pos, sect, &hi, ceilhit, &lo, florhit, clipdist, clipmask); + *hiz = hi * zinttoworld; + *loz = lo * zinttoworld; +} + void FAFgetzrangepoint(int32_t x, int32_t y, int32_t z, sectortype* sect, int32_t* hiz, Collision* ceilhit, int32_t* loz, Collision* florhit); +inline void FAFgetzrangepoint(int32_t x, int32_t y, int32_t z, sectortype* sect, + double* hiz, Collision* ceilhit, + double* loz, Collision* florhit) +{ + int32_t hi, lo; + FAFgetzrangepoint(x, y, z, sect, &hi, ceilhit, &lo, florhit); + *hiz = hi * zinttoworld; + *loz = lo * zinttoworld; +} enum SoundType { diff --git a/source/games/sw/src/hornet.cpp b/source/games/sw/src/hornet.cpp index 8488659fe..a625da25b 100644 --- a/source/games/sw/src/hornet.cpp +++ b/source/games/sw/src/hornet.cpp @@ -490,7 +490,7 @@ int DoHornetDeath(DSWActor* actor) if (actor->user.Flags & (SPR_FALLING)) { - actor->user.loz = actor->user.zclip; + actor->user.loz = actor->user.zclip * zinttoworld; DoFall(actor); } else diff --git a/source/games/sw/src/lava.cpp b/source/games/sw/src/lava.cpp index c00bec281..e7196da9f 100644 --- a/source/games/sw/src/lava.cpp +++ b/source/games/sw/src/lava.cpp @@ -472,7 +472,7 @@ int SetupLava(DSWActor* actor) actor->spr.clipdist = (512) >> 2; actor->user.Flags |= (SPR_XFLIP_TOGGLE|SPR_ELECTRO_TOLERANT); - actor->user.loz = actor->int_pos().Z; + actor->user.loz = actor->spr.pos.Z; return 0; } diff --git a/source/games/sw/src/sector.cpp b/source/games/sw/src/sector.cpp index e05306aa3..5f06b3241 100644 --- a/source/games/sw/src/sector.cpp +++ b/source/games/sw/src/sector.cpp @@ -851,7 +851,7 @@ void SectorExp(DSWActor* actor, sectortype* sectp, double zh) // setup vars needed by SectorExp ChangeActorSect(actor, sectp); - getzsofslopeptr(actor->sector(), actor->int_pos().X, actor->int_pos().Y, &actor->user.hiz, &actor->user.loz); + getzsofslopeptr(actor->sector(), actor->spr.pos.X, actor->spr.pos.Y, &actor->user.hiz, &actor->user.loz); // spawn explosion auto exp = SpawnSectorExp(actor); diff --git a/source/games/sw/src/serp.cpp b/source/games/sw/src/serp.cpp index 217c1b992..a5c74d259 100644 --- a/source/games/sw/src/serp.cpp +++ b/source/games/sw/src/serp.cpp @@ -730,7 +730,7 @@ int SetupSerp(DSWActor* actor) actor->spr.clipdist = (512) >> 2; actor->user.Flags |= (SPR_XFLIP_TOGGLE|SPR_ELECTRO_TOLERANT); - actor->user.loz = actor->int_pos().Z; + actor->user.loz = actor->spr.pos.Z; // amount to move up for clipmove actor->user.zclip = Z(80); diff --git a/source/games/sw/src/skull.cpp b/source/games/sw/src/skull.cpp index 7d53115a5..cf27e2b3c 100644 --- a/source/games/sw/src/skull.cpp +++ b/source/games/sw/src/skull.cpp @@ -236,7 +236,7 @@ int SetupSkull(DSWActor* actor) { actor->set_int_z(actor->user.int_loz() + Z(tileTopOffset(actor->spr.picnum))); - actor->user.loz = actor->int_pos().Z; + actor->user.loz = actor->spr.pos.Z; // leave 8 pixels above the ground actor->add_int_z(ActorSizeToTop(actor) - Z(3)); } @@ -621,7 +621,7 @@ int SetupBetty(DSWActor* actor) { actor->set_int_z(actor->user.int_loz() + Z(tileTopOffset(actor->spr.picnum))); - actor->user.loz = actor->int_pos().Z; + actor->user.loz = actor->spr.pos.Z; // leave 8 pixels above the ground actor->add_int_z(ActorSizeToTop(actor) - Z(3)); } diff --git a/source/games/sw/src/sprite.cpp b/source/games/sw/src/sprite.cpp index 29f527950..a10b44cdf 100644 --- a/source/games/sw/src/sprite.cpp +++ b/source/games/sw/src/sprite.cpp @@ -863,8 +863,8 @@ void SpawnUser(DSWActor* actor, short id, STATE* state) // Problem with sprites spawned really close to white sector walls // cant do a getzrange there // Just put in some valid starting values - actor->user.loz = actor->sector()->int_floorz(); - actor->user.hiz = actor->sector()->int_ceilingz(); + actor->user.loz = actor->sector()->floorz; + actor->user.hiz = actor->sector()->ceilingz; actor->user.lowActor = nullptr; actor->user.highActor = nullptr; actor->user.lo_sectp = actor->sector(); @@ -4488,8 +4488,8 @@ void DoActorZrange(DSWActor* actor) int DoActorGlobZ(DSWActor* actor) { - actor->user.loz = globloz; - actor->user.hiz = globhiz; + actor->user.loz = globloz * zinttoworld; + actor->user.hiz = globhiz * zinttoworld; actor->user.lo_sectp = actor->user.hi_sectp = nullptr; actor->user.highActor = nullptr; @@ -4601,7 +4601,6 @@ bool DropAhead(DSWActor* actor, int min_height) int move_actor(DSWActor* actor, int xchange, int ychange, int zchange) { - int loz, hiz; DSWActor* highActor; DSWActor* lowActor; sectortype* lo_sectp,* hi_sectp; @@ -4618,8 +4617,8 @@ 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.int_hiz(); + auto loz = actor->user.loz; + auto hiz = actor->user.hiz; lowActor = actor->user.lowActor; highActor = actor->user.highActor; lo_sectp = actor->user.lo_sectp; @@ -6385,7 +6384,7 @@ int MissileWaterAdjust(DSWActor* actor) if (sectp && sectp->hasU()) { if (FixedToInt(sectp->depth_fixed)) - actor->user.loz -= Z(FixedToInt(sectp->depth_fixed)); + actor->user.loz -= FixedToInt(sectp->depth_fixed); } return 0; } diff --git a/source/games/sw/src/zilla.cpp b/source/games/sw/src/zilla.cpp index 6fb19647f..c38f36b77 100644 --- a/source/games/sw/src/zilla.cpp +++ b/source/games/sw/src/zilla.cpp @@ -638,7 +638,7 @@ int NullZilla(DSWActor* actor) actor->user.hi_sectp = actor->sector(); actor->user.lowActor = nullptr; actor->user.highActor = nullptr; - actor->set_int_z(actor->user.int_loz()); + actor->spr.pos.Z = actor->user.loz; DoActorSectorDamage(actor); @@ -707,7 +707,7 @@ int DoZillaDeathMelt(DSWActor* actor) actor->user.hi_sectp = actor->sector(); actor->user.lowActor = nullptr; actor->user.highActor = nullptr; - actor->set_int_z(actor->user.int_loz()); + actor->spr.pos.Z = actor->user.loz; BossSpriteNum[2] = nullptr; return 0;