From 4af4983d3ed0bdeb50a177abea35879fe0fdd359 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 4 Oct 2022 19:06:49 +0200 Subject: [PATCH] - floatified clipdist and replaced fClipdist wrapper. This uses a new variable because a few things use clipdist as a flag byte --- source/build/src/clip.cpp | 2 +- source/core/actorlist.cpp | 3 +- source/core/coreactor.h | 22 ++--- source/core/gamefuncs.cpp | 2 +- source/core/maploader.cpp | 6 +- source/core/savegamehelp.cpp | 1 + source/games/blood/src/actor.cpp | 24 ++--- source/games/blood/src/ai.cpp | 4 +- source/games/blood/src/aispid.cpp | 6 +- source/games/blood/src/aiunicult.cpp | 6 +- source/games/blood/src/blood.cpp | 2 +- source/games/blood/src/callback.cpp | 6 +- source/games/blood/src/fx.cpp | 4 +- source/games/blood/src/gib.cpp | 4 +- source/games/blood/src/nnexts.cpp | 14 +-- source/games/blood/src/player.cpp | 4 +- source/games/duke/src/actors.cpp | 4 +- source/games/duke/src/actors_d.cpp | 6 +- source/games/duke/src/actors_r.cpp | 2 +- source/games/duke/src/premap.cpp | 2 +- source/games/duke/src/spawn.cpp | 20 +---- source/games/duke/src/spawn_r.cpp | 20 ++--- source/games/exhumed/src/bullet.cpp | 4 +- source/games/exhumed/src/fish.cpp | 2 +- source/games/exhumed/src/grenade.cpp | 4 +- source/games/exhumed/src/init.cpp | 2 +- source/games/exhumed/src/lavadude.cpp | 2 +- source/games/exhumed/src/move.cpp | 14 +-- source/games/exhumed/src/player.cpp | 2 +- source/games/exhumed/src/set.cpp | 2 +- source/games/sw/src/game.cpp | 2 +- source/games/sw/src/jweapon.cpp | 10 +-- source/games/sw/src/player.cpp | 22 ++--- source/games/sw/src/quake.cpp | 1 + source/games/sw/src/ripper.cpp | 2 +- source/games/sw/src/ripper2.cpp | 2 +- source/games/sw/src/sector.cpp | 2 +- source/games/sw/src/sprite.cpp | 11 +-- source/games/sw/src/track.cpp | 2 +- source/games/sw/src/weapon.cpp | 123 +++++++++++++------------- source/games/sw/src/weapon.h | 2 +- wadsrc/static/zscript/coreactor.zs | 3 +- 42 files changed, 183 insertions(+), 195 deletions(-) diff --git a/source/build/src/clip.cpp b/source/build/src/clip.cpp index 229bbb70a..93708594c 100644 --- a/source/build/src/clip.cpp +++ b/source/build/src/clip.cpp @@ -417,7 +417,7 @@ CollisionBase clipmove_(vec3_t * const pos, int * const sectnum, int32_t xvect, if (pos->Z > daz-height-flordist && pos->Z < daz+ceildist) { - int cd = actor->fClipdist() * worldtoint; + int cd = actor->clipdist * worldtoint; int32_t bsz = cd + walldist; if (diff.X < 0) bsz = -bsz; addclipline(p1.X-bsz, p1.Y-bsz, p1.X-bsz, p1.Y+bsz, obj, false); diff --git a/source/core/actorlist.cpp b/source/core/actorlist.cpp index 256b8deef..c124e91e5 100644 --- a/source/core/actorlist.cpp +++ b/source/core/actorlist.cpp @@ -515,7 +515,8 @@ DEFINE_FIELD_NAMED(DCoreActor, spr.extra, extra) DEFINE_FIELD_NAMED(DCoreActor, spr.detail, detail) DEFINE_FIELD_NAMED(DCoreActor, spr.shade, shade) DEFINE_FIELD_NAMED(DCoreActor, spr.pal, pal) -DEFINE_FIELD_NAMED(DCoreActor, spr. clipdist, clipdist) +DEFINE_FIELD_NAMED(DCoreActor, spr.clipdist, intclipdist) +DEFINE_FIELD_NAMED(DCoreActor, clipdist, clipdist) DEFINE_FIELD_NAMED(DCoreActor, spr.blend, blend) DEFINE_FIELD_NAMED(DCoreActor, spr.xrepeat, xrepeat) DEFINE_FIELD_NAMED(DCoreActor, spr.yrepeat, yrepeat) diff --git a/source/core/coreactor.h b/source/core/coreactor.h index 5c6c024ad..5fa9eeba1 100644 --- a/source/core/coreactor.h +++ b/source/core/coreactor.h @@ -42,10 +42,11 @@ public: spritesmooth_t spsmooth; DVector3 opos; - int time; DAngle oang; DVector3 vel; + double clipdist; + int time; int16_t spritesetindex; @@ -61,6 +62,12 @@ public: size_t PropagateMark() override; int GetOffsetAndHeight(int& height); double GetOffsetAndHeight(double& height); + + void initFromSprite(spritetype* pspr) + { + spr = *pspr; + clipdist = pspr->clipdist * 0.25; + } bool exists() const { @@ -160,29 +167,24 @@ public: return static_cast(GetClass())->ActorInfo()->SpriteSet; } - double fClipdist() const - { - return spr. clipdist * 0.25; - } - void set_native_clipdist(int val) { - spr. clipdist = val; + clipdist = val * 0.25; } int native_clipdist() { - return spr. clipdist; + return clipdist * 4; } void set_const_clipdist(int val) // only for searching purposes { - spr. clipdist = val; + clipdist = val * 0.25; } void copy_clipdist(DCoreActor* other) { - spr. clipdist = other->spr. clipdist; + clipdist = other->clipdist; } }; diff --git a/source/core/gamefuncs.cpp b/source/core/gamefuncs.cpp index fe03013b3..c93cb36b0 100644 --- a/source/core/gamefuncs.cpp +++ b/source/core/gamefuncs.cpp @@ -912,7 +912,7 @@ bool checkRangeOfWall(walltype* wal, EWallFlags flagmask, const DVector3& pos, d bool checkRangeOfFaceSprite(DCoreActor* itActor, const DVector3& pos, double maxdist, double* theZs) { - double dist = maxdist + itActor->fClipdist(); + double dist = maxdist + itActor->clipdist; if (abs(pos.X - itActor->spr.pos.X) > dist || abs(pos.Y - itActor->spr.pos.Y) > dist) return false; // Just like Doom: actors are square... double h; theZs[0] = itActor->spr.pos.Z + itActor->GetOffsetAndHeight(h); diff --git a/source/core/maploader.cpp b/source/core/maploader.cpp index b7df223b1..6d2a58559 100644 --- a/source/core/maploader.cpp +++ b/source/core/maploader.cpp @@ -305,7 +305,7 @@ static void ReadSpriteV7(FileReader& fr, spritetype& spr, int& secno) spr.picnum = fr.ReadInt16(); spr.shade = fr.ReadInt8(); spr.pal = fr.ReadUInt8(); - spr. clipdist = fr.ReadUInt8(); + spr.clipdist = fr.ReadUInt8(); spr.blend = fr.ReadUInt8(); spr.xrepeat = fr.ReadUInt8(); spr.yrepeat = fr.ReadUInt8(); @@ -334,7 +334,7 @@ static void ReadSpriteV6(FileReader& fr, spritetype& spr, int& secno) spr.cstat = ESpriteFlags::FromInt(fr.ReadUInt16()); spr.shade = fr.ReadInt8(); spr.pal = fr.ReadUInt8(); - spr. clipdist = fr.ReadUInt8(); + spr.clipdist = fr.ReadUInt8(); spr.xrepeat = fr.ReadUInt8(); spr.yrepeat = fr.ReadUInt8(); spr.xoffset = fr.ReadInt8(); @@ -389,7 +389,7 @@ static void ReadSpriteV5(FileReader& fr, spritetype& spr, int& secno) spr.pal = sec->floorpal; spr.blend = 0; - spr. clipdist = 32; + spr.clipdist = 32; spr.xoffset = 0; spr.yoffset = 0; spr.detail = 0; diff --git a/source/core/savegamehelp.cpp b/source/core/savegamehelp.cpp index afdece8ca..09444f8a3 100644 --- a/source/core/savegamehelp.cpp +++ b/source/core/savegamehelp.cpp @@ -666,6 +666,7 @@ void DCoreActor::Serialize(FSerializer& arc) ("prevsect", prevSect) ("nextsect", nextSect) ("sprite", spr) + ("clipdist", clipdist) ("time", time) ("spritesetindex", spritesetindex) ("spriteext", sprext) diff --git a/source/games/blood/src/actor.cpp b/source/games/blood/src/actor.cpp index 7ba20e4b2..496dfd4bd 100644 --- a/source/games/blood/src/actor.cpp +++ b/source/games/blood/src/actor.cpp @@ -4511,7 +4511,7 @@ static Collision MoveThing(DBloodActor* actor) actor->spr.cstat &= ~CSTAT_SPRITE_BLOCK_ALL; if ((actor->GetOwner()) && !cl_bloodvanillaexplosions && !VanillaMode()) enginecompatibility_mode = ENGINECOMPATIBILITY_NONE; // improved clipmove accuracy - ClipMove(actor->spr.pos, &pSector, actor->vel.XY(), actor->fClipdist(), (actor->spr.pos.Z - top) * 0.25, (bottom - actor->spr.pos.Z) * 0.25, CLIPMASK0, lhit); + ClipMove(actor->spr.pos, &pSector, actor->vel.XY(), actor->clipdist, (actor->spr.pos.Z - top) * 0.25, (bottom - actor->spr.pos.Z) * 0.25, CLIPMASK0, lhit); actor->hit.hit = lhit; enginecompatibility_mode = bakCompat; // restore actor->spr.cstat = bakCstat; @@ -4551,7 +4551,7 @@ static Collision MoveThing(DBloodActor* actor) double ceilZ, floorZ; Collision ceilColl, floorColl; - GetZRange(actor, &ceilZ, &ceilColl, &floorZ, &floorColl, actor->fClipdist(), CLIPMASK0); + GetZRange(actor, &ceilZ, &ceilColl, &floorZ, &floorColl, actor->clipdist, CLIPMASK0); GetActorExtents(actor, &top, &bottom); if ((actor->spr.flags & 2) && bottom < floorZ) @@ -4570,7 +4570,7 @@ static Collision MoveThing(DBloodActor* actor) } } } - if (CheckLink(actor)) GetZRange(actor, &ceilZ, &ceilColl, &floorZ, &floorColl, actor->fClipdist(), CLIPMASK0); + if (CheckLink(actor)) GetZRange(actor, &ceilZ, &ceilColl, &floorZ, &floorColl, actor->clipdist, CLIPMASK0); GetActorExtents(actor, &top, &bottom); if (bottom >= floorZ) @@ -4706,7 +4706,7 @@ void MoveDude(DBloodActor* actor) GetActorExtents(actor, &top, &bottom); double bz = (bottom - actor->spr.pos.Z) / 4; double tz = (actor->spr.pos.Z - top) / 4; - double wdf = actor->fClipdist(); + double wdf = actor->clipdist; auto pSector = actor->sector(); int nAiStateType = (actor->xspr.aiState) ? actor->xspr.aiState->stateType : -1; @@ -5052,7 +5052,7 @@ void MoveDude(DBloodActor* actor) { double floorZ2 = floorZ; auto floorColl2 = floorColl; - GetZRange(actor, &ceilZ, &ceilColl, &floorZ, &floorColl, actor->fClipdist(), CLIPMASK0, PARALLAXCLIP_CEILING | PARALLAXCLIP_FLOOR); + GetZRange(actor, &ceilZ, &ceilColl, &floorZ, &floorColl, actor->clipdist, CLIPMASK0, PARALLAXCLIP_CEILING | PARALLAXCLIP_FLOOR); if (bottom <= floorZ && actor->spr.pos.Z - floorZ2 < bz) { floorZ = floorZ2; @@ -5224,7 +5224,7 @@ int MoveMissile(DBloodActor* actor) actor->spr.cstat &= ~CSTAT_SPRITE_BLOCK_ALL; // remove self collisions for accurate clipmove } Collision clipmoveresult; - ClipMove(ppos, &pSector2, vel.XY(), actor->fClipdist(), (ppos.Z - top) / 4, (bottom - ppos.Z) / 4, CLIPMASK0, clipmoveresult, 1); + ClipMove(ppos, &pSector2, vel.XY(), actor->clipdist, (ppos.Z - top) / 4, (bottom - ppos.Z) / 4, CLIPMASK0, clipmoveresult, 1); enginecompatibility_mode = bakCompat; // restore actor->spr.cstat = bakSpriteCstat; auto pSector = pSector2; @@ -5280,7 +5280,7 @@ int MoveMissile(DBloodActor* actor) } double ceilZ, floorZ; Collision ceilColl, floorColl; - GetZRangeAtXYZ(ppos, pSector2, &ceilZ, &ceilColl, &floorZ, &floorColl, actor->fClipdist(), CLIPMASK0); + GetZRangeAtXYZ(ppos, pSector2, &ceilZ, &ceilColl, &floorZ, &floorColl, actor->clipdist, CLIPMASK0); GetActorExtents(actor, &top, &bottom); top += vel.Z; bottom += vel.Z; @@ -6086,7 +6086,7 @@ void actCheckFlares() if (target->hasX() && target->xspr.health > 0) { DVector3 pos = target->spr.pos; - pos.XY() += (actor->xspr.goalAng + target->spr.angle).ToVector() * target->fClipdist() * 0.5; + pos.XY() += (actor->xspr.goalAng + target->spr.angle).ToVector() * target->clipdist * 0.5; pos.Z += actor->xspr.TargetPos.Z; SetActor(actor, pos); actor->vel = target->vel; @@ -6334,11 +6334,11 @@ DBloodActor* actFireThing(DBloodActor* actor, double xyoff, double zoff, double { assert(thingType >= kThingBase && thingType < kThingMax); - DVector3 vect = actor->spr.pos.plusZ(zoff) + (actor->spr.angle + DAngle90).ToVector() * xyoff + actor->spr.angle.ToVector() * actor->fClipdist(); + DVector3 vect = actor->spr.pos.plusZ(zoff) + (actor->spr.angle + DAngle90).ToVector() * xyoff + actor->spr.angle.ToVector() * actor->clipdist; - if (HitScan(actor, vect.Z, DVector3(vect.XY() - actor->spr.pos.XY(), 0), CLIPMASK0, actor->fClipdist() * 0.25) != -1) + if (HitScan(actor, vect.Z, DVector3(vect.XY() - actor->spr.pos.XY(), 0), CLIPMASK0, actor->clipdist * 0.25) != -1) { - vect.XY() = gHitInfo.hitpos.XY() - actor->spr.angle.ToVector() * actor->fClipdist() * 2; + vect.XY() = gHitInfo.hitpos.XY() - actor->spr.angle.ToVector() * actor->clipdist * 2; } auto fired = actSpawnThing(actor->sector(), vect, thingType); fired->SetOwner(actor); @@ -6444,7 +6444,7 @@ DBloodActor* actFireMissile(DBloodActor* actor, double xyoff, double zoff, DVect auto vect = actor->spr.pos.plusZ(zoff) + (actor->spr.angle + DAngle90).ToVector() * xyoff; - double clipdist = pMissileInfo->fClipDist() + actor->fClipdist(); + double clipdist = pMissileInfo->fClipDist() + actor->clipdist; vect += actor->spr.angle.ToVector() * clipdist; int hit = HitScan(actor, vect.Z, DVector3(vect.XY() - actor->spr.pos.XY(), 0), CLIPMASK0, clipdist * 4); diff --git a/source/games/blood/src/ai.cpp b/source/games/blood/src/ai.cpp index eb2fd2f8f..66735e61d 100644 --- a/source/games/blood/src/ai.cpp +++ b/source/games/blood/src/ai.cpp @@ -135,7 +135,7 @@ bool CanMove(DBloodActor* actor, DBloodActor* target, DAngle nAngle, double nRan DVector2 nAngVect = nAngle.ToVector(); HitScan(actor, pos.Z, DVector3(nAngVect, 0) * 1024, CLIPMASK0, nRange); double nDist = (actor->spr.pos.XY() - gHitInfo.hitpos.XY()).Length(); - if (nDist - (actor->fClipdist()) < nRange / 16.) // this was actually comparing a Build unit value with a texel unit value! + if (nDist - (actor->clipdist) < nRange / 16.) // this was actually comparing a Build unit value with a texel unit value! { if (gHitInfo.actor() == nullptr || target == nullptr || target != gHitInfo.actor()) return false; @@ -178,7 +178,7 @@ bool CanMove(DBloodActor* actor, DBloodActor* target, DAngle nAngle, double nRan case kDudeGargoyleFlesh: case kDudeGargoyleStone: case kDudeBat: - if (actor->fClipdist() > nDist * 4) + if (actor->clipdist > nDist * 4) return 0; if (Depth) { diff --git a/source/games/blood/src/aispid.cpp b/source/games/blood/src/aispid.cpp index e81a7c2eb..d126ad69b 100644 --- a/source/games/blood/src/aispid.cpp +++ b/source/games/blood/src/aispid.cpp @@ -145,11 +145,11 @@ void SpidBirthSeqCallback(int, DBloodActor* actor) { DAngle nDeltaAngle = absangle(actor->spr.angle, nAngle); if (nDist < 0x1a0 && nDist > 0x140 && nDeltaAngle < pDudeInfo->Periphery()) - spawned = actSpawnDude(actor, kDudeSpiderRed, actor->fClipdist() * 0.25); + spawned = actSpawnDude(actor, kDudeSpiderRed, actor->clipdist * 0.25); else if (nDist < 0x140 && nDist > 0xc0 && nDeltaAngle < pDudeInfo->Periphery()) - spawned = actSpawnDude(actor, kDudeSpiderBrown, actor->fClipdist() * 0.25); + spawned = actSpawnDude(actor, kDudeSpiderBrown, actor->clipdist * 0.25); else if (nDist < 0xc0 && nDeltaAngle < pDudeInfo->Periphery()) - spawned = actSpawnDude(actor, kDudeSpiderBrown, actor->fClipdist() * 0.25); + spawned = actSpawnDude(actor, kDudeSpiderBrown, actor->clipdist * 0.25); if (spawned) { diff --git a/source/games/blood/src/aiunicult.cpp b/source/games/blood/src/aiunicult.cpp index 38626c5fc..455dc6d72 100644 --- a/source/games/blood/src/aiunicult.cpp +++ b/source/games/blood/src/aiunicult.cpp @@ -242,7 +242,7 @@ void genDudeAttack1(int, DBloodActor* actor) else if (pExtra->weaponType == kGenDudeWeaponSummon) { DBloodActor* spawned = nullptr; - double dist = actor->fClipdist() * 4; + double dist = actor->clipdist * 4; if (pExtra->slaveCount <= gGameOptions.nDifficulty) { if ((spawned = actSpawnDude(actor, pExtra->curWeapon, dist + RandomD(dist, 4))) != NULL) @@ -373,7 +373,7 @@ static void ThrowThing(DBloodActor* actor, bool impact) spawned->xspr.data3 = 512 / (gGameOptions.nDifficulty + 1); spawned->spr.cstat &= ~CSTAT_SPRITE_BLOCK; spawned->spr.pal = 6; - spawned->set_const_clipdist(0); + spawned->clipdist = 0; spawned->SetTarget(actor->GetTarget()); spawned->xspr.Proximity = true; spawned->xspr.stateTimer = 1; @@ -753,7 +753,7 @@ static void unicultThinkChase(DBloodActor* actor) if (hit >= 0) { - targetDist = dist - (target->fClipdist()); + targetDist = dist - (target->clipdist); objDist = (gHitInfo.hitpos.XY() - actor->spr.pos.XY()).Length(); } diff --git a/source/games/blood/src/blood.cpp b/source/games/blood/src/blood.cpp index 5fea9e22f..8ed06dcbe 100644 --- a/source/games/blood/src/blood.cpp +++ b/source/games/blood/src/blood.cpp @@ -159,7 +159,7 @@ TArray SpawnActors(BloodSpawnSpriteDef& sprites) auto actor = InsertSprite(sprt->sectp, sprt->statnum); spawns[j++] = actor; actor->time = i; - actor->spr = sprites.sprites[i]; + actor->initFromSprite(&sprites.sprites[i]); if (sprites.sprext.Size()) actor->sprext = sprites.sprext[i]; else actor->sprext = {}; actor->spsmooth = {}; diff --git a/source/games/blood/src/callback.cpp b/source/games/blood/src/callback.cpp index e13b7eb84..91e1c1c5b 100644 --- a/source/games/blood/src/callback.cpp +++ b/source/games/blood/src/callback.cpp @@ -439,7 +439,7 @@ void fxBloodBits(DBloodActor* actor, sectortype*) // 14 if (!actor) return; double ceilZ, floorZ; Collision floorColl, ceilColl; - GetZRange(actor, &ceilZ, &ceilColl, &floorZ, &floorColl, actor->fClipdist() * 0.25, CLIPMASK0); + GetZRange(actor, &ceilZ, &ceilColl, &floorZ, &floorColl, actor->clipdist * 0.25, CLIPMASK0); double top, bottom; GetActorExtents(actor, &top, &bottom); actor->spr.pos.Z += floorZ - bottom; @@ -497,7 +497,7 @@ void fxBouncingSleeve(DBloodActor* actor, sectortype*) // 16 double ceilZ, floorZ; Collision floorColl, ceilColl; - GetZRange(actor, &ceilZ, &ceilColl, &floorZ, &floorColl, actor->fClipdist() * 0.25, CLIPMASK0); + GetZRange(actor, &ceilZ, &ceilColl, &floorZ, &floorColl, actor->clipdist * 0.25, CLIPMASK0); double top, bottom; GetActorExtents(actor, &top, &bottom); actor->spr.pos.Z += floorZ - bottom; @@ -629,7 +629,7 @@ void fxPodBloodSplat(DBloodActor* actor, sectortype*) // 19 double ceilZ, floorZ; Collision floorColl, ceilColl; - GetZRange(actor, &ceilZ, &ceilColl, &floorZ, &floorColl, actor->fClipdist() * 0.25, CLIPMASK0); + GetZRange(actor, &ceilZ, &ceilColl, &floorZ, &floorColl, actor->clipdist * 0.25, CLIPMASK0); double top, bottom; GetActorExtents(actor, &top, &bottom); actor->spr.pos.Z += floorZ - bottom; diff --git a/source/games/blood/src/fx.cpp b/source/games/blood/src/fx.cpp index aace97313..943f7d6eb 100644 --- a/source/games/blood/src/fx.cpp +++ b/source/games/blood/src/fx.cpp @@ -322,7 +322,7 @@ void fxSpawnPodStuff(DBloodActor* actor, int) void fxSpawnEjectingBrass(DBloodActor* actor, double z, double dist, int rdist) { - DVector3 pos(actor->spr.pos.XY() + actor->fClipdist() * actor->spr.angle.ToVector() + (actor->spr.angle + DAngle90).ToVector() * dist, z); + DVector3 pos(actor->spr.pos.XY() + actor->clipdist * actor->spr.angle.ToVector() + (actor->spr.angle + DAngle90).ToVector() * dist, z); auto pBrass = gFX.fxSpawnActor((FX_ID)(FX_37 + Random(3)), actor->sector(), pos); if (pBrass) @@ -344,7 +344,7 @@ void fxSpawnEjectingBrass(DBloodActor* actor, double z, double dist, int rdist) void fxSpawnEjectingShell(DBloodActor* actor, double z, double dist, int rdist) { - DVector3 pos(actor->spr.pos.XY() + actor->fClipdist() * actor->spr.angle.ToVector() + (actor->spr.angle + DAngle90).ToVector() * dist, z); + DVector3 pos(actor->spr.pos.XY() + actor->clipdist * actor->spr.angle.ToVector() + (actor->spr.angle + DAngle90).ToVector() * dist, z); auto pShell = gFX.fxSpawnActor((FX_ID)(FX_40 + Random(3)), actor->sector(), pos); if (pShell) diff --git a/source/games/blood/src/gib.cpp b/source/games/blood/src/gib.cpp index 4656d621f..8051bcde6 100644 --- a/source/games/blood/src/gib.cpp +++ b/source/games/blood/src/gib.cpp @@ -289,7 +289,7 @@ void GibFX(DBloodActor* actor, GIBFX* pGFX, DVector3* pPos, DVector3* pVel) if (!pPos && (actor->spr.cstat & CSTAT_SPRITE_ALIGNMENT_MASK) == 0) { DAngle nAngle = RandomAngle(); - gPos = DVector3(actor->spr.pos.XY() + actor->fClipdist() * nAngle.ToVector(), bottom - RandomD(bottom - top, 8)); + gPos = DVector3(actor->spr.pos.XY() + actor->clipdist * nAngle.ToVector(), bottom - RandomD(bottom - top, 8)); } auto pFX = gFX.fxSpawnActor(pGFX->fxId, pSector, gPos); if (pFX) @@ -356,7 +356,7 @@ void GibThing(DBloodActor* actor, GIBTHING* pGThing, DVector3* pPos, DVector3* p if (!pPos) { DAngle nAngle = RandomAngle(); - gPos = DVector3(actor->spr.pos.XY() + actor->fClipdist() * nAngle.ToVector(), bottom - RandomD(bottom - top, 8)); + gPos = DVector3(actor->spr.pos.XY() + actor->clipdist * nAngle.ToVector(), bottom - RandomD(bottom - top, 8)); } else { diff --git a/source/games/blood/src/nnexts.cpp b/source/games/blood/src/nnexts.cpp index 7c50c1655..8b71b28f1 100644 --- a/source/games/blood/src/nnexts.cpp +++ b/source/games/blood/src/nnexts.cpp @@ -1645,7 +1645,7 @@ void debrisMove(int listIndex) moveHit.setNone(); double floorDist = (bottom - actor->spr.pos.Z) * 0.25; double ceilDist = (actor->spr.pos.Z - top) * 0.25; - double clipDistf = actor->fClipdist(); + double clipDistf = actor->clipdist; int mass = actor->spriteMass.mass; bool uwater = false; @@ -5565,13 +5565,13 @@ bool modernTypeOperateSector(sectortype* pSector, const EVENT& event) void useCustomDudeSpawn(DBloodActor* pSource, DBloodActor* pActor) { - genDudeSpawn(pSource, pActor, pActor->fClipdist() * 0.5); + genDudeSpawn(pSource, pActor, pActor->clipdist * 0.5); } void useDudeSpawn(DBloodActor* pSource, DBloodActor* pActor) { - if (randomSpawnDude(pSource, pActor, pActor->fClipdist() * 0.5, 0) == nullptr) - nnExtSpawnDude(pSource, pActor, pActor->xspr.data1, pActor->fClipdist() * 0.5, 0); + if (randomSpawnDude(pSource, pActor, pActor->clipdist * 0.5, 0) == nullptr) + nnExtSpawnDude(pSource, pActor, pActor->xspr.data1, pActor->clipdist * 0.5, 0); } //--------------------------------------------------------------------------- @@ -7670,7 +7670,7 @@ bool nnExtCanMove(DBloodActor* actor, DBloodActor* target, DAngle nAngle, double HitScan(actor, pos.Z, nAngVect, CLIPMASK0, nRange); double nDist = (actor->spr.pos.XY() - gHitInfo.hitpos.XY()).Length(); - if (target != nullptr && nDist - actor->fClipdist() < nRange) + if (target != nullptr && nDist - actor->clipdist < nRange) return (target == gHitInfo.actor()); pos += nAngVect * nRange; @@ -7858,14 +7858,14 @@ bool aiPatrolMarkerReached(DBloodActor* actor) auto markeractor = actor->GetTarget(); if (markeractor && markeractor->spr.type == kMarkerPath) { - double okDist = max(markeractor->fClipdist() * 8, 4.); + double okDist = max(markeractor->clipdist * 8, 4.); auto ov = markeractor->spr.pos.XY() - actor->spr.pos.XY(); // this was already shifted right by 4 in the old code. if (ov.Length() <= okDist) { if (spriteIsUnderwater(actor) || pExtra->flying) { - okDist = markeractor->fClipdist() * 16; + okDist = markeractor->clipdist * 16; double ztop, zbot, ztop2, zbot2; GetActorExtents(actor, &ztop, &zbot); GetActorExtents(markeractor, &ztop2, &zbot2); diff --git a/source/games/blood/src/player.cpp b/source/games/blood/src/player.cpp index 273db304f..d24e0f077 100644 --- a/source/games/blood/src/player.cpp +++ b/source/games/blood/src/player.cpp @@ -1710,7 +1710,7 @@ void ProcessInput(PLAYER* pPlayer) if (pPlayer->handTime <= 0 && pPlayer->hand) { DBloodActor* pactor = pPlayer->actor; - auto spawned = actSpawnDude(pactor, kDudeHand, pPlayer->actor->fClipdist() * 0.5); + auto spawned = actSpawnDude(pactor, kDudeHand, pPlayer->actor->clipdist * 0.5); if (spawned) { spawned->spr.angle += DAngle180; @@ -1797,7 +1797,7 @@ void playerProcess(PLAYER* pPlayer) if (!gNoClip) { auto pSector = actor->sector(); - if (pushmove(actor->spr.pos, &pSector, actor->fClipdist(), dzceil, dzflor, CLIPMASK0) == -1) + if (pushmove(actor->spr.pos, &pSector, actor->clipdist, dzceil, dzflor, CLIPMASK0) == -1) actDamageSprite(actor, actor, kDamageFall, 500 << 4); if (actor->sector() != pSector) { diff --git a/source/games/duke/src/actors.cpp b/source/games/duke/src/actors.cpp index 47aadc26d..94ca2b36a 100644 --- a/source/games/duke/src/actors.cpp +++ b/source/games/duke/src/actors.cpp @@ -2580,7 +2580,7 @@ void handle_se00(DDukeActor* actor) actor->tempval += 4; if (actor->tempval >= 256) callsound(actor->sector(), actor, true); - if (actor->native_clipdist()) direction = 1; // notreallyclipdist + if (actor->spr.clipdist) direction = 1; // notreallyclipdist else direction = -1; } else actor->tempval = 256; @@ -2608,7 +2608,7 @@ void handle_se00(DDukeActor* actor) actor->tempval -= 4; if (actor->tempval <= 0) callsound(actor->sector(), actor, true); - if (actor->native_clipdist()) direction = -1; // notreallyclipdist + if (actor->spr.clipdist) direction = -1; // notreallyclipdist else direction = 1; } else actor->tempval = 0; diff --git a/source/games/duke/src/actors_d.cpp b/source/games/duke/src/actors_d.cpp index 988a33556..872e2632d 100644 --- a/source/games/duke/src/actors_d.cpp +++ b/source/games/duke/src/actors_d.cpp @@ -462,7 +462,7 @@ int movesprite_ex_d(DDukeActor* actor, const DVector3& change, unsigned int clip if (actor->spr.picnum == LIZMAN) clipdist = 18.25; else if (actorflag(actor, SFLAG_BADGUY)) - clipdist = actor->fClipdist(); + clipdist = actor->clipdist; else clipdist = 12; @@ -493,7 +493,7 @@ int movesprite_ex_d(DDukeActor* actor, const DVector3& change, unsigned int clip if (actor->spr.statnum == STAT_PROJECTILE) clipmove(ppos, &dasectp, change * 0.5, 0.5, 4., 4., cliptype, result); else - clipmove(ppos, &dasectp, change * 0.5, actor->fClipdist(), 4., 4., cliptype, result); + clipmove(ppos, &dasectp, change * 0.5, actor->clipdist, 4., 4., cliptype, result); } actor->spr.pos.XY() = ppos.XY(); @@ -2464,7 +2464,7 @@ static void flamethrowerflame(DDukeActor *actor) int ds = actor->temp_data[0] / 6; if (actor->spr.xrepeat < 80) actor->spr.yrepeat = actor->spr.xrepeat += ds; - actor->spr.clipdist += ds; + actor->clipdist += ds * 0.25; if (actor->temp_data[0] <= 2) actor->temp_data[3] = krand() % 10; if (actor->temp_data[0] > 30) diff --git a/source/games/duke/src/actors_r.cpp b/source/games/duke/src/actors_r.cpp index 063a98835..dedd82aa5 100644 --- a/source/games/duke/src/actors_r.cpp +++ b/source/games/duke/src/actors_r.cpp @@ -406,7 +406,7 @@ int movesprite_ex_r(DDukeActor* actor, const DVector3& change, unsigned int clip if (actor->spr.statnum == STAT_PROJECTILE) clipmove(ppos, &dasectp, change * 0.5, 0.5, 4., 4., cliptype, result); else - clipmove(ppos, &dasectp, change * 0.5, actor->fClipdist(), 4., 4., cliptype, result); + clipmove(ppos, &dasectp, change * 0.5, actor->clipdist, 4., 4., cliptype, result); } actor->spr.pos.XY() = ppos.XY(); diff --git a/source/games/duke/src/premap.cpp b/source/games/duke/src/premap.cpp index 866f345cf..54b08dc00 100644 --- a/source/games/duke/src/premap.cpp +++ b/source/games/duke/src/premap.cpp @@ -969,7 +969,7 @@ static TArray spawnactors(SpawnSpriteDef& sprites) auto sprt = &sprites.sprites[i]; auto actor = static_cast(InsertActor(RUNTIME_CLASS(DDukeActor), sprt->sectp, sprt->statnum)); spawns[j++] = actor; - actor->spr = sprites.sprites[i]; + actor->initFromSprite(&sprites.sprites[i]); actor->time = i; if (sprites.sprext.Size()) actor->sprext = sprites.sprext[i]; else actor->sprext = {}; diff --git a/source/games/duke/src/spawn.cpp b/source/games/duke/src/spawn.cpp index 45e4582d6..4c63f889a 100644 --- a/source/games/duke/src/spawn.cpp +++ b/source/games/duke/src/spawn.cpp @@ -63,33 +63,17 @@ DDukeActor* CreateActor(sectortype* whatsectp, const DVector3& pos, int s_pn, in act->spr.pos = pos; - act->spr.cstat = 0; act->spr.picnum = s_pn; act->spr.shade = s_shd; act->spr.xrepeat = s_xr; act->spr.yrepeat = s_yr; - act->spr.pal = 0; act->spr.angle = s_ang; act->vel.X = s_vel; act->vel.Z = s_zvel; - act->spr.xoffset = 0; - act->spr.yoffset = 0; - act->spr.yint = 0; - act->set_const_clipdist(0); - act->spr.pal = 0; - act->spr.lotag = 0; act->backuploc(); - act->ovel.Zero(); - - act->timetosleep = 0; - act->actorstayput = nullptr; act->hitextra = -1; - act->cgg = 0; - act->movflag = 0; - act->tempval = 0; - act->dispicnum = 0; act->SetHitOwner(s_ow); act->SetOwner(s_ow); @@ -879,8 +863,8 @@ void spawneffector(DDukeActor* actor, TArray* actors) { if (sectp->lotag == 30) { - if (actor->spr.pal) actor->set_const_clipdist(1); - else actor->set_const_clipdist(0); + if (actor->spr.pal) actor->spr.clipdist = 1; // notreallyclipdist + else actor->spr.clipdist = 0; actor->temp_pos.Z = sectp->floorz; sectp->hitagactor = actor; } diff --git a/source/games/duke/src/spawn_r.cpp b/source/games/duke/src/spawn_r.cpp index 79f37d127..436c4bda9 100644 --- a/source/games/duke/src/spawn_r.cpp +++ b/source/games/duke/src/spawn_r.cpp @@ -57,7 +57,7 @@ DDukeActor* spawninit_r(DDukeActor* actj, DDukeActor* act, TArray* act->spr.cstat |= CSTAT_SPRITE_INVISIBLE; act->spr.xrepeat = 0; act->spr.yrepeat = 0; - act->set_const_clipdist(0); + act->clipdist = 0; act->spr.extra = 0; ChangeActorStat(act, STAT_BOWLING); break; @@ -77,7 +77,7 @@ DDukeActor* spawninit_r(DDukeActor* actj, DDukeActor* act, TArray* if (!isRRRA()) goto default_case; act->spr.xrepeat = 16; act->spr.yrepeat = 16; - act->set_const_clipdist(0); + act->clipdist = 0; act->spr.extra = 0; act->spr.cstat = 0; ChangeActorStat(act, 121); @@ -114,18 +114,18 @@ DDukeActor* spawninit_r(DDukeActor* actj, DDukeActor* act, TArray* case RRTILE8448: if (!isRRRA()) goto default_case; act->spr.lotag = 1; - act->set_const_clipdist(0); + act->clipdist = 0; break; case RRTILE8099: if (!isRRRA()) goto default_case; act->spr.lotag = 5; - act->set_const_clipdist(0); + act->clipdist = 0; ChangeActorStat(act, 123); break; case RRTILE8704: if (!isRRRA()) goto default_case; act->spr.lotag = 1; - act->set_const_clipdist(0); + act->clipdist = 0; break; case RRTILE8192: if (!isRRRA()) goto default_case; @@ -142,7 +142,7 @@ DDukeActor* spawninit_r(DDukeActor* actj, DDukeActor* act, TArray* case RRTILE8165: if (!isRRRA()) goto default_case; act->spr.lotag = 1; - act->set_const_clipdist(0); + act->clipdist = 0; act->SetOwner(act); act->spr.extra = 0; ChangeActorStat(act, 115); @@ -150,7 +150,7 @@ DDukeActor* spawninit_r(DDukeActor* actj, DDukeActor* act, TArray* case RRTILE8593: if (!isRRRA()) goto default_case; act->spr.lotag = 1; - act->set_const_clipdist(0); + act->clipdist = 0; act->SetOwner(act); act->spr.extra = 0; ChangeActorStat(act, 122); @@ -168,7 +168,7 @@ DDukeActor* spawninit_r(DDukeActor* actj, DDukeActor* act, TArray* act->spr.cstat |= CSTAT_SPRITE_INVISIBLE; act->spr.xrepeat = 0; act->spr.yrepeat = 0; - act->set_const_clipdist(0); + act->clipdist = 0; act->spr.lotag = 0; ChangeActorStat(act, 106); break; @@ -840,7 +840,7 @@ DDukeActor* spawninit_r(DDukeActor* actj, DDukeActor* act, TArray* act->spr.xrepeat = 24; act->spr.yrepeat = 18; act->setClipDistFromTile(); - act->spr.clipdist <<= 2; + act->clipdist *= 4; break; case DRONE: act->spr.xrepeat = 14; @@ -984,7 +984,7 @@ DDukeActor* spawninit_r(DDukeActor* actj, DDukeActor* act, TArray* act->spr.xrepeat = 64; act->spr.yrepeat = 128; act->setClipDistFromTile(); - act->spr.clipdist >>= 2; + act->clipdist *= 0.25; act->spr.cstat = CSTAT_SPRITE_TRANSLUCENT; break; case LTH: diff --git a/source/games/exhumed/src/bullet.cpp b/source/games/exhumed/src/bullet.cpp index b21b8f52f..6d446662e 100644 --- a/source/games/exhumed/src/bullet.cpp +++ b/source/games/exhumed/src/bullet.cpp @@ -373,7 +373,7 @@ int MoveBullet(int nBullet) } } - coll = movesprite(pActor, pBullet->vect.XY(), pBullet->vect.Z, pActor->fClipdist() / 128., CLIPMASK1); + coll = movesprite(pActor, pBullet->vect.XY(), pBullet->vect.Z, pActor->clipdist / 128., CLIPMASK1); MOVEEND: if (coll.type || coll.exbits) @@ -771,7 +771,7 @@ DExhumedActor* BuildBullet(DExhumedActor* pActor, int nType, double fZOffset, DA } pBullet->vect.Z = 0; - pBullet->vect.XY() = nAngle.ToVector() * pActor->fClipdist(); + pBullet->vect.XY() = nAngle.ToVector() * pActor->clipdist; BulletList[nBullet].pEnemy = nullptr; diff --git a/source/games/exhumed/src/fish.cpp b/source/games/exhumed/src/fish.cpp index 3f0c5ccbc..47c4a8a43 100644 --- a/source/games/exhumed/src/fish.cpp +++ b/source/games/exhumed/src/fish.cpp @@ -68,7 +68,7 @@ void BuildFishLimb(DExhumedActor* pActor, int anim) pChunkActor->spr.picnum = anim; pChunkActor->spr.lotag = runlist_HeadRun() + 1; - pChunkActor->set_const_clipdist(0); + pChunkActor->clipdist = 0; // GrabTimeSlot(3); diff --git a/source/games/exhumed/src/grenade.cpp b/source/games/exhumed/src/grenade.cpp index cb98b600a..2c6b2649a 100644 --- a/source/games/exhumed/src/grenade.cpp +++ b/source/games/exhumed/src/grenade.cpp @@ -92,7 +92,7 @@ void ThrowGrenade(int nPlayer, double dz, double push1) pActor->vel.Z = ((32. * push1) - 17); - DVector2 vec = nAngle.ToVector() * pPlayerActor->fClipdist() *2; // == << 14 + 3 + 2 - 18 + DVector2 vec = nAngle.ToVector() * pPlayerActor->clipdist *2; // == << 14 + 3 + 2 - 18 auto nMov = movesprite(pActor, vec, dz, 0, CLIPMASK1); if (nMov.type == kHitWall) { @@ -321,7 +321,7 @@ void AIGrenade::Tick(RunListEvent* ev) double zVel = pActor->vel.Z; Gravity(pActor); - auto nMov = movesprite(pActor, pActor->vec, pActor->vel.Z, pActor->fClipdist() / 128., CLIPMASK1); + auto nMov = movesprite(pActor, pActor->vec, pActor->vel.Z, pActor->clipdist / 128., CLIPMASK1); if (!nMov.type && !nMov.exbits) return; diff --git a/source/games/exhumed/src/init.cpp b/source/games/exhumed/src/init.cpp index b90a6dd32..2e94526df 100644 --- a/source/games/exhumed/src/init.cpp +++ b/source/games/exhumed/src/init.cpp @@ -72,7 +72,7 @@ static TArray spawnactors(SpawnSpriteDef& sprites) auto sprt = &sprites.sprites[i]; auto actor = insertActor(sprt->sectp, sprt->statnum); spawns[j++] = actor; - actor->spr = sprites.sprites[i]; + actor->initFromSprite(&sprites.sprites[i]); actor->time = i; if (sprites.sprext.Size()) actor->sprext = sprites.sprext[i]; else actor->sprext = {}; diff --git a/source/games/exhumed/src/lavadude.cpp b/source/games/exhumed/src/lavadude.cpp index 76e427470..9d191deda 100644 --- a/source/games/exhumed/src/lavadude.cpp +++ b/source/games/exhumed/src/lavadude.cpp @@ -55,7 +55,7 @@ DExhumedActor* BuildLavaLimb(DExhumedActor* pActor, int move, double height) pLimbActor->spr.picnum = (move & 3) % 3; pLimbActor->spr.hitag = 0; pLimbActor->spr.lotag = runlist_HeadRun() + 1; - pLimbActor->set_const_clipdist(0); + pLimbActor->clipdist = 0; // GrabTimeSlot(3); diff --git a/source/games/exhumed/src/move.cpp b/source/games/exhumed/src/move.cpp index ffac0111b..d07f96d91 100644 --- a/source/games/exhumed/src/move.cpp +++ b/source/games/exhumed/src/move.cpp @@ -433,7 +433,7 @@ Collision movesprite(DExhumedActor* pActor, DVector2 vect, double dz, double flo vect *= 0.5; } - Collision nRet = movespritez(pActor, dz, nSpriteHeight, pActor->fClipdist()); + Collision nRet = movespritez(pActor, dz, nSpriteHeight, pActor->clipdist); pSector = pActor->sector(); // modified in movespritez so re-grab this variable @@ -456,7 +456,7 @@ Collision movesprite(DExhumedActor* pActor, DVector2 vect, double dz, double flo } Collision coll; - clipmove(pActor->spr.pos, &pSector, vect, pActor->fClipdist(), nSpriteHeight, flordist, clipmask, coll); + clipmove(pActor->spr.pos, &pSector, vect, pActor->clipdist, nSpriteHeight, flordist, clipmask, coll); if (coll.type != kHitNone) // originally this or'ed the two values which can create unpredictable bad values in some edge cases. { coll.exbits = nRet.exbits; @@ -864,7 +864,7 @@ void MoveSector(sectortype* pSector, DAngle nAngle, DVector2& nVel) // The vector that got passed in here originally was Q28.4, while clipmove expects Q14.18, effectively resulting in actual zero movement // because the resulting offset would be far below the coordinate's precision. - clipmove(pos, &pSectorB, -vect / 16384., pActor->fClipdist(), 0., 0., CLIPMASK0, scratch); + clipmove(pos, &pSectorB, -vect / 16384., pActor->clipdist, 0., 0., CLIPMASK0, scratch); if (pSectorB) { ChangeActorSect(pActor, pSectorB); @@ -882,9 +882,9 @@ void MoveSector(sectortype* pSector, DAngle nAngle, DVector2& nVel) // Original used 14 bits of scale from the sine table and 4 bits from clipdist. // vect was added unscaled, essentially nullifying its effect entirely. - auto vect2 = -nAngle.ToVector() * pActor->fClipdist()/* - vect*/; + auto vect2 = -nAngle.ToVector() * pActor->clipdist/* - vect*/; - clipmove(pos, &pSectorB, -vect / 16384., pActor->fClipdist(), 0., 0., CLIPMASK0, scratch); + clipmove(pos, &pSectorB, -vect / 16384., pActor->clipdist, 0., 0., CLIPMASK0, scratch); if (pSectorB != pNextSector && (pSectorB == pSector || pNextSector == pSector)) { @@ -897,7 +897,7 @@ void MoveSector(sectortype* pSector, DAngle nAngle, DVector2& nVel) else { // Unlike the above, this one *did* scale vect - vect2 = nAngle.ToVector() * pActor->fClipdist() * 0.25 + vect; + vect2 = nAngle.ToVector() * pActor->clipdist * 0.25 + vect; movesprite(pActor, vect2, 0, 0, CLIPMASK0); } } @@ -922,7 +922,7 @@ void MoveSector(sectortype* pSector, DAngle nAngle, DVector2& nVel) if (pActor->spr.statnum >= 99 && nZVal == pActor->spr.pos.Z && !(pActor->spr.cstat & CSTAT_SPRITE_INVISIBLE)) { pSectorB = pSector; - clipmove(pActor->spr.pos, &pSectorB, vect, pActor->fClipdist(), 20, -20, CLIPMASK0, scratch); + clipmove(pActor->spr.pos, &pSectorB, vect, pActor->clipdist, 20, -20, CLIPMASK0, scratch); } } } diff --git a/source/games/exhumed/src/player.cpp b/source/games/exhumed/src/player.cpp index 11d9a660d..7c6155b8a 100644 --- a/source/games/exhumed/src/player.cpp +++ b/source/games/exhumed/src/player.cpp @@ -1044,7 +1044,7 @@ void AIPlayer::Tick(RunListEvent* ev) auto pPlayerSect = pPlayerActor->sector(); - pushmove(pPlayerActor->spr.pos, &pPlayerSect, pPlayerActor->fClipdist(), 20, -20, CLIPMASK0); + pushmove(pPlayerActor->spr.pos, &pPlayerSect, pPlayerActor->clipdist, 20, -20, CLIPMASK0); if (pPlayerSect != pPlayerActor->sector()) { ChangeActorSect(pPlayerActor, pPlayerSect); } diff --git a/source/games/exhumed/src/set.cpp b/source/games/exhumed/src/set.cpp index 3359b28bd..05081b7be 100644 --- a/source/games/exhumed/src/set.cpp +++ b/source/games/exhumed/src/set.cpp @@ -307,7 +307,7 @@ void AISet::Tick(RunListEvent* ev) auto nMov = MoveCreature(pActor); auto sect = pActor->sector(); - pushmove(pActor->spr.pos, §, pActor->fClipdist(), 20, -20, CLIPMASK0); + pushmove(pActor->spr.pos, §, pActor->clipdist, 20, -20, CLIPMASK0); pActor->setsector(sect); if (pActor->vel.Z > 4000/256.) diff --git a/source/games/sw/src/game.cpp b/source/games/sw/src/game.cpp index b9a367a23..9fbbeb66a 100644 --- a/source/games/sw/src/game.cpp +++ b/source/games/sw/src/game.cpp @@ -355,7 +355,7 @@ void spawnactors(SpawnSpriteDef& sprites) } auto sprt = &sprites.sprites[i]; auto actor = insertActor(sprt->sectp, sprt->statnum); - actor->spr = sprites.sprites[i]; + actor->initFromSprite(&sprites.sprites[i]); actor->time = i; if (sprites.sprext.Size()) actor->sprext = sprites.sprext[i]; else actor->sprext = {}; diff --git a/source/games/sw/src/jweapon.cpp b/source/games/sw/src/jweapon.cpp index 352ad8c35..e6a4081c1 100644 --- a/source/games/sw/src/jweapon.cpp +++ b/source/games/sw/src/jweapon.cpp @@ -1292,8 +1292,8 @@ int PlayerInitChemBomb(PLAYER* pp) actorNew->vel.Z += pp->horizon.horiz.Tan() * HORIZ_MULTF; oclipdist = plActor->native_clipdist(); - plActor->set_const_clipdist(0); - actorNew->set_const_clipdist(0); + plActor->clipdist = 0; + actorNew->clipdist = 0; MissileSetPos(actorNew, DoChemBomb, 1000); @@ -1393,7 +1393,7 @@ int InitChemBomb(DSWActor* actor) actorNew->user.Flags |= (SPR_UNDERWATER); actorNew->vel.Z = RandomZVel(); - actorNew->set_const_clipdist(0); + actorNew->clipdist = 0; if (actor->user.ID == MUSHROOM_CLOUD || actor->user.ID == 3121 || actor->user.ID == SUMO_RUN_R0) // 3121 == GRENADE_EXP { @@ -1667,8 +1667,8 @@ int PlayerInitCaltrops(PLAYER* pp) actorNew->vel.Z += pp->horizon.horiz.Tan() * HORIZ_MULTF; oclipdist = plActor->native_clipdist(); - plActor->set_const_clipdist(0); - actorNew->set_const_clipdist(0); + plActor->clipdist = 0; + actorNew->clipdist = 0; MissileSetPos(actorNew, DoCaltrops, 1000); diff --git a/source/games/sw/src/player.cpp b/source/games/sw/src/player.cpp index 2e5cc67ea..314276440 100644 --- a/source/games/sw/src/player.cpp +++ b/source/games/sw/src/player.cpp @@ -1945,7 +1945,7 @@ void DoPlayerZrange(PLAYER* pp) auto bakcstat = actor->spr.cstat; actor->spr.cstat &= ~(CSTAT_SPRITE_BLOCK); - FAFgetzrange(pp->pos.plusZ(8), pp->cursector, &pp->hiz, &ceilhit, &pp->loz, &florhit, actor->fClipdist() - GETZRANGE_CLIP_ADJ, CLIPMASK_PLAYER); + FAFgetzrange(pp->pos.plusZ(8), pp->cursector, &pp->hiz, &ceilhit, &pp->loz, &florhit, actor->clipdist - GETZRANGE_CLIP_ADJ, CLIPMASK_PLAYER); actor->spr.cstat = bakcstat; Collision ceilColl(ceilhit); @@ -2009,7 +2009,7 @@ void DoPlayerSlide(PLAYER* pp) if (abs(pp->slide_vect.X) < 0.05 && abs(pp->slide_vect.Y) < 0.05) pp->slide_vect.Zero(); - push_ret = pushmove(pp->pos, &pp->cursector, actor->fClipdist(), pp->p_ceiling_dist, pp->p_floor_dist, CLIPMASK_PLAYER); + push_ret = pushmove(pp->pos, &pp->cursector, actor->clipdist, pp->p_ceiling_dist, pp->p_floor_dist, CLIPMASK_PLAYER); if (push_ret < 0) { if (!(pp->Flags & PF_DEAD)) @@ -2023,10 +2023,10 @@ void DoPlayerSlide(PLAYER* pp) return; } Collision coll; - clipmove(pp->pos, &pp->cursector, pp->slide_vect, actor->fClipdist(), pp->p_ceiling_dist, pp->p_floor_dist, CLIPMASK_PLAYER, coll); + clipmove(pp->pos, &pp->cursector, pp->slide_vect, actor->clipdist, pp->p_ceiling_dist, pp->p_floor_dist, CLIPMASK_PLAYER, coll); PlayerCheckValidMove(pp); - push_ret = pushmove(pp->pos, &pp->cursector, actor->fClipdist(), pp->p_ceiling_dist, pp->p_floor_dist, CLIPMASK_PLAYER); + push_ret = pushmove(pp->pos, &pp->cursector, actor->clipdist, pp->p_ceiling_dist, pp->p_floor_dist, CLIPMASK_PLAYER); if (push_ret < 0) { if (!(pp->Flags & PF_DEAD)) @@ -2172,7 +2172,7 @@ void DoPlayerMove(PLAYER* pp) } else { - push_ret = pushmove(pp->pos, &pp->cursector, actor->fClipdist(), pp->p_ceiling_dist, pp->p_floor_dist - Z(16), CLIPMASK_PLAYER); + push_ret = pushmove(pp->pos, &pp->cursector, actor->clipdist, pp->p_ceiling_dist, pp->p_floor_dist - Z(16), CLIPMASK_PLAYER); if (push_ret < 0) { @@ -2195,12 +2195,12 @@ void DoPlayerMove(PLAYER* pp) actor->spr.cstat &= ~(CSTAT_SPRITE_BLOCK); Collision coll; updatesector(pp->pos, &pp->cursector); - clipmove(pp->pos, &pp->cursector, pp->vect, actor->fClipdist(), pp->p_ceiling_dist, pp->p_floor_dist, CLIPMASK_PLAYER, coll); + clipmove(pp->pos, &pp->cursector, pp->vect, actor->clipdist, pp->p_ceiling_dist, pp->p_floor_dist, CLIPMASK_PLAYER, coll); actor->spr.cstat = save_cstat; PlayerCheckValidMove(pp); - push_ret = pushmove(pp->pos, &pp->cursector, actor->fClipdist(), pp->p_ceiling_dist, pp->p_floor_dist - Z(16), CLIPMASK_PLAYER); + push_ret = pushmove(pp->pos, &pp->cursector, actor->clipdist, pp->p_ceiling_dist, pp->p_floor_dist - Z(16), CLIPMASK_PLAYER); if (push_ret < 0) { @@ -3559,7 +3559,7 @@ int DoPlayerWadeSuperJump(PLAYER* pp) if (hit.hitSector != nullptr && abs(hit.hitSector->floorz - pp->pos.Z) < 50) { double dist = (pp->pos.XY() - hit.hitpos.XY()).Length(); - double comp = (pp->actor->fClipdist() + 16); + double comp = (pp->actor->clipdist + 16); if (dist < comp) return true; } @@ -4830,7 +4830,7 @@ void DoPlayerCurrent(PLAYER* pp) auto vect = sectu->angle.ToVector() / 256. * sectu->speed * synctics; // 16384 >> 4 - Beware of clipmove's odd format for vect! - push_ret = pushmove(pp->pos, &pp->cursector, pp->actor->fClipdist(), pp->p_ceiling_dist, pp->p_floor_dist, CLIPMASK_PLAYER); + push_ret = pushmove(pp->pos, &pp->cursector, pp->actor->clipdist, pp->p_ceiling_dist, pp->p_floor_dist, CLIPMASK_PLAYER); if (push_ret < 0) { if (!(pp->Flags & PF_DEAD)) @@ -4846,10 +4846,10 @@ void DoPlayerCurrent(PLAYER* pp) return; } Collision coll; - clipmove(pp->pos, &pp->cursector, vect, pp->actor->fClipdist(), pp->p_ceiling_dist, pp->p_floor_dist, CLIPMASK_PLAYER, coll); + clipmove(pp->pos, &pp->cursector, vect, pp->actor->clipdist, pp->p_ceiling_dist, pp->p_floor_dist, CLIPMASK_PLAYER, coll); PlayerCheckValidMove(pp); - pushmove(pp->pos, &pp->cursector, pp->actor->fClipdist(), pp->p_ceiling_dist, pp->p_floor_dist, CLIPMASK_PLAYER); + pushmove(pp->pos, &pp->cursector, pp->actor->clipdist, pp->p_ceiling_dist, pp->p_floor_dist, CLIPMASK_PLAYER); if (push_ret < 0) { if (!(pp->Flags & PF_DEAD)) diff --git a/source/games/sw/src/quake.cpp b/source/games/sw/src/quake.cpp index cf8ed9620..a28fe3c0c 100644 --- a/source/games/sw/src/quake.cpp +++ b/source/games/sw/src/quake.cpp @@ -63,6 +63,7 @@ void CopyQuakeSpotToOn(DSWActor* actor) auto actorNew = insertActor(actor->sector(), STAT_QUAKE_SPOT); actorNew->spr = actor->spr; + actorNew->clipdist = actor->clipdist; actorNew->spr.cstat = 0; actorNew->spr.extra = 0; diff --git a/source/games/sw/src/ripper.cpp b/source/games/sw/src/ripper.cpp index 52363f0de..aaba2ecd4 100644 --- a/source/games/sw/src/ripper.cpp +++ b/source/games/sw/src/ripper.cpp @@ -847,7 +847,7 @@ int SetupRipper(DSWActor* actor) if (!(actor->spr.cstat & CSTAT_SPRITE_RESTORE)) actor->user.Health = HEALTH_MOMMA_RIPPER; - actor->spr.clipdist += 128 >> 2; + actor->clipdist += 128; } else { diff --git a/source/games/sw/src/ripper2.cpp b/source/games/sw/src/ripper2.cpp index 5a9754691..4e460f42d 100644 --- a/source/games/sw/src/ripper2.cpp +++ b/source/games/sw/src/ripper2.cpp @@ -915,7 +915,7 @@ int SetupRipper2(DSWActor* actor) if (!(actor->spr.cstat & CSTAT_SPRITE_RESTORE)) actor->user.Health = HEALTH_MOMMA_RIPPER; - actor->spr.clipdist += 128 >> 2; + actor->clipdist += 128; } else { diff --git a/source/games/sw/src/sector.cpp b/source/games/sw/src/sector.cpp index b85c57531..cf44c628c 100644 --- a/source/games/sw/src/sector.cpp +++ b/source/games/sw/src/sector.cpp @@ -1272,7 +1272,7 @@ void WeaponExplodeSectorInRange(DSWActor* wActor) if (actor->native_clipdist() == 0) continue; - double radius = actor->fClipdist() * 8; + double radius = actor->clipdist * 8; if (dist > (wActor->user.fRadius()/2) + radius) continue; diff --git a/source/games/sw/src/sprite.cpp b/source/games/sw/src/sprite.cpp index 279ec7df4..d21f28633 100644 --- a/source/games/sw/src/sprite.cpp +++ b/source/games/sw/src/sprite.cpp @@ -983,6 +983,7 @@ bool ActorTestSpawn(DSWActor* actor) { auto actorNew = insertActor(actor->sector(), STAT_DEFAULT); actorNew->spr = actor->spr; + actorNew->clipdist = actor->clipdist; change_actor_stat(actorNew, STAT_SPAWN_TRIGGER); actorNew->spr.cstat &= ~(CSTAT_SPRITE_BLOCK|CSTAT_SPRITE_BLOCK_HITSCAN); return false; @@ -4488,7 +4489,7 @@ void DoActorZrange(DSWActor* actor) actor->spr.cstat &= ~(CSTAT_SPRITE_BLOCK); DVector3 pos = actor->spr.pos.plusZ(-ActorSizeZ(actor) * 0.5); - FAFgetzrange(pos, actor->sector(), &actor->user.hiz, &ceilhit, &actor->user.loz, &florhit, actor->fClipdist() - GETZRANGE_CLIP_ADJ, CLIPMASK_ACTOR); + FAFgetzrange(pos, actor->sector(), &actor->user.hiz, &ceilhit, &actor->user.loz, &florhit, actor->clipdist - GETZRANGE_CLIP_ADJ, CLIPMASK_ACTOR); actor->spr.cstat |= save_cstat; actor->user.lo_sectp = actor->user.hi_sectp = nullptr; @@ -6362,7 +6363,7 @@ Collision move_sprite(DSWActor* actor, const DVector3& change, double ceildist, } - clipmove(clip_pos, &dasect, change * numtics * 0.125, actor->fClipdist(), ceildist, flordist, cliptype, retval, 1); + clipmove(clip_pos, &dasect, change * numtics * 0.125, actor->clipdist, ceildist, flordist, cliptype, retval, 1); actor->spr.pos.XY() = clip_pos.XY(); @@ -6387,7 +6388,7 @@ Collision move_sprite(DSWActor* actor, const DVector3& change, double ceildist, auto pos = actor->spr.pos.plusZ(-zH - maptoworld); FAFgetzrange(pos, actor->sector(), &globhiz, &globhihit, &globloz, &globlohit, - actor->fClipdist() - GETZRANGE_CLIP_ADJ, cliptype); + actor->clipdist - GETZRANGE_CLIP_ADJ, cliptype); actor->spr.cstat = tempstat; @@ -6582,7 +6583,7 @@ Collision move_missile(DSWActor* actor, const DVector3& change, double ceil_dist int xchange = change.X * worldtoint, ychange = change.Y * worldtoint; - clipmove(clip_pos, &dasect, change * numtics * 0.125, actor->fClipdist(), ceil_dist, flor_dist, cliptype, retval, 1); + clipmove(clip_pos, &dasect, change * numtics * 0.125, actor->clipdist, ceil_dist, flor_dist, cliptype, retval, 1); actor->spr.pos.XY() = clip_pos.XY(); if (dasect == nullptr) @@ -6731,7 +6732,7 @@ Collision move_ground_missile(DSWActor* actor, const DVector2& change, double ce lastsect = dasect; opos = actor->spr.pos; opos.Z = daz; - clipmove(opos, &dasect, change * numtics * 0.125, actor->fClipdist(), ceildist, flordist, cliptype, retval, 1); + clipmove(opos, &dasect, change * numtics * 0.125, actor->clipdist, ceildist, flordist, cliptype, retval, 1); actor->spr.pos.XY() = opos.XY(); } diff --git a/source/games/sw/src/track.cpp b/source/games/sw/src/track.cpp index bde6e9578..0c451897a 100644 --- a/source/games/sw/src/track.cpp +++ b/source/games/sw/src/track.cpp @@ -1137,7 +1137,7 @@ void SetupSectorObject(sectortype* sectp, short tag) else sop->max_damage = actorNew->user.MaxHealth; - switch (actor->native_clipdist()) // notreallyclipdist + switch (actor->spr.clipdist) // notreallyclipdist { case 0: break; diff --git a/source/games/sw/src/weapon.cpp b/source/games/sw/src/weapon.cpp index cef112df3..bc89419bf 100644 --- a/source/games/sw/src/weapon.cpp +++ b/source/games/sw/src/weapon.cpp @@ -45,9 +45,6 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms BEGIN_SW_NS -#define RESTORE_CLIP actor->set_native_clipdist(oclipdist) -#define SAVE_CLIP auto oclipdist = actor->native_clipdist() - struct MISSILE_PLACEMENT { int dist_over, dist_out; @@ -11050,7 +11047,7 @@ int DoFindGround(DSWActor* actor) auto save_cstat = actor->spr.cstat; actor->spr.cstat &= ~(CSTAT_SPRITE_BLOCK | CSTAT_SPRITE_BLOCK_HITSCAN); - FAFgetzrange(actor->spr.pos, actor->sector(), &actor->user.hiz, &ceilhit, &actor->user.loz, &florhit, actor->fClipdist() - GETZRANGE_CLIP_ADJ, CLIPMASK_PLAYER); + FAFgetzrange(actor->spr.pos, actor->sector(), &actor->user.hiz, &ceilhit, &actor->user.loz, &florhit, actor->clipdist - GETZRANGE_CLIP_ADJ, CLIPMASK_PLAYER); actor->spr.cstat = save_cstat; switch (florhit.type) @@ -12062,7 +12059,7 @@ void InitSpellNapalm(PLAYER* pp) actor->spr.shade = -40; actor->spr.xrepeat = 32; actor->spr.yrepeat = 32; - actor->set_const_clipdist(0); + actor->clipdist = 0; actor->vel.Z = pp->horizon.horiz.Tan() * HORIZ_MULTF; actor->spr.cstat |= (CSTAT_SPRITE_TRANSLUCENT | CSTAT_SPRITE_YCENTER); actor->spr.cstat &= ~(CSTAT_SPRITE_BLOCK | CSTAT_SPRITE_BLOCK_HITSCAN); @@ -12139,7 +12136,7 @@ int InitEnemyNapalm(DSWActor* actor) actorNew->spr.shade = -40; actorNew->spr.xrepeat = 32; actorNew->spr.yrepeat = 32; - actorNew->set_const_clipdist(0); + actorNew->clipdist = 0; actorNew->spr.cstat |= (CSTAT_SPRITE_TRANSLUCENT | CSTAT_SPRITE_YCENTER); actorNew->spr.cstat &= ~(CSTAT_SPRITE_BLOCK | CSTAT_SPRITE_BLOCK_HITSCAN); actorNew->user.Flags2 |= (SPR2_BLUR_TAPER_FAST); @@ -12148,7 +12145,7 @@ int InitEnemyNapalm(DSWActor* actor) actorNew->user.ceiling_dist = (1); actorNew->user.Dist = 12.5; - SAVE_CLIP; + auto oclipdist = actor->clipdist; actor->set_const_clipdist(1); if (mp[i].dist_over != 0) @@ -12165,7 +12162,7 @@ int InitEnemyNapalm(DSWActor* actor) MissileSetPos(actorNew, DoNapalm, mp[i].dist_out); - RESTORE_CLIP;; + actor->clipdist = oclipdist;; actor->user.Counter = 0; @@ -12205,7 +12202,7 @@ int InitSpellMirv(PLAYER* pp) DSWActor* plActor = pp->actor; auto oclipdist = plActor->native_clipdist(); - plActor->set_const_clipdist(0); + plActor->clipdist = 0; UpdateChange(actorNew); @@ -12653,7 +12650,7 @@ int InitSumoNapalm(DSWActor* actor) actorNew->spr.shade = -40; actorNew->spr.xrepeat = 32; actorNew->spr.yrepeat = 32; - actorNew->set_const_clipdist(0); + actorNew->clipdist = 0; actorNew->spr.cstat |= (CSTAT_SPRITE_TRANSLUCENT | CSTAT_SPRITE_YCENTER); actorNew->spr.cstat &= ~(CSTAT_SPRITE_BLOCK | CSTAT_SPRITE_BLOCK_HITSCAN); actorNew->user.Flags2 |= (SPR2_BLUR_TAPER_FAST); @@ -12662,7 +12659,7 @@ int InitSumoNapalm(DSWActor* actor) actorNew->user.ceiling_dist = (1); actorNew->user.Dist = 12.5; - SAVE_CLIP; + auto oclipdist = actor->clipdist; actor->set_const_clipdist(1); if (mp[i].dist_over != 0) @@ -12677,7 +12674,7 @@ int InitSumoNapalm(DSWActor* actor) MissileSetPos(actorNew, DoNapalm, mp[i].dist_out); - RESTORE_CLIP;; + actor->clipdist = oclipdist;; actor->user.Counter = 0; @@ -13169,7 +13166,7 @@ void InitHeartAttack(PLAYER* pp) actorNew->spr.shade = -10; actorNew->spr.xrepeat = 52; actorNew->spr.yrepeat = 52; - actorNew->set_const_clipdist(0); + actorNew->clipdist = 0; actorNew->vel.Z = pp->horizon.horiz.Tan() * HORIZ_MULTF; actorNew->spr.cstat &= ~(CSTAT_SPRITE_BLOCK | CSTAT_SPRITE_BLOCK_HITSCAN); actorNew->user.Flags2 |= (SPR2_DONT_TARGET_OWNER); @@ -13488,8 +13485,8 @@ int InitLaser(PLAYER* pp) // at certain angles the clipping box was big enough to block the // initial positioning of the fireball. - SAVE_CLIP; - actor->set_const_clipdist(0); + auto oclipdist = actor->clipdist; + actor->clipdist = 0; actorNew->spr.angle += DAngle90; HelpMissileLateral(actorNew, 900); @@ -13502,30 +13499,30 @@ int InitLaser(PLAYER* pp) // move it 1200 dist in increments - works better if (MissileSetPos(actorNew, DoLaserStart, 300)) { - RESTORE_CLIP;; + actor->clipdist = oclipdist;; KillActor(actorNew); return 0; } if (MissileSetPos(actorNew, DoLaserStart, 300)) { - RESTORE_CLIP;; + actor->clipdist = oclipdist;; KillActor(actorNew); return 0; } if (MissileSetPos(actorNew, DoLaserStart, 300)) { - RESTORE_CLIP;; + actor->clipdist = oclipdist;; KillActor(actorNew); return 0; } if (MissileSetPos(actorNew, DoLaserStart, 300)) { - RESTORE_CLIP;; + actor->clipdist = oclipdist;; KillActor(actorNew); return 0; } - RESTORE_CLIP;; + actor->clipdist = oclipdist;; if (WeaponAutoAim(pp->actor, actorNew, DAngle22_5 / 4, false) == -1) { @@ -13587,8 +13584,8 @@ int InitRail(PLAYER* pp) // at certain angles the clipping box was big enough to block the // initial positioning - SAVE_CLIP; - actor->set_const_clipdist(0); + auto oclipdist = actor->clipdist; + actor->clipdist = 0; actorNew->set_const_clipdist(32 >> 2); actorNew->spr.angle += DAngle90; @@ -13600,12 +13597,12 @@ int InitRail(PLAYER* pp) if (TestMissileSetPos(actorNew, DoRailStart, 1200, zvel)) { - RESTORE_CLIP;; + actor->clipdist = oclipdist;; KillActor(actorNew); return 0; } - RESTORE_CLIP;; + actor->clipdist = oclipdist;; actorNew->vel.Z = zvel * 0.5; if (WeaponAutoAim(pp->actor, actorNew, DAngle22_5 / 4, false) == -1) @@ -13661,8 +13658,8 @@ int InitZillaRail(DSWActor* actor) // at certain angles the clipping box was big enough to block the // initial positioning - SAVE_CLIP; - actor->set_const_clipdist(0); + auto oclipdist = actor->clipdist; + actor->clipdist = 0; actorNew->set_const_clipdist(32 >> 2); actorNew->spr.angle += DAngle90; @@ -13674,12 +13671,12 @@ int InitZillaRail(DSWActor* actor) if (TestMissileSetPos(actorNew, DoRailStart, 1200, zvel)) { - RESTORE_CLIP;; + actor->clipdist = oclipdist;; KillActor(actorNew); return 0; } - RESTORE_CLIP;; + actor->clipdist = oclipdist;; actorNew->vel.Z = zvel * 0.5; if (WeaponAutoAim(actor, actorNew, DAngle22_5 / 4, false) == -1) @@ -13769,8 +13766,8 @@ int InitRocket(PLAYER* pp) // at certain angles the clipping box was big enough to block the // initial positioning of the fireball. - SAVE_CLIP; - actor->set_const_clipdist(0); + auto oclipdist = actor->clipdist; + actor->clipdist = 0; actorNew->spr.angle += DAngle90; HelpMissileLateral(actorNew, 900); @@ -13783,14 +13780,14 @@ int InitRocket(PLAYER* pp) actorNew->user.Counter = 1; if (TestMissileSetPos(actorNew, DoRocket, 1200, zvel)) { - RESTORE_CLIP;; + actor->clipdist = oclipdist;; KillActor(actorNew); return 0; } // inable smoke trail actorNew->user.Counter = 0; - RESTORE_CLIP;; + actor->clipdist = oclipdist;; actorNew->vel.Z = zvel * 0.5; if (WeaponAutoAim(pp->actor, actorNew, DAngle22_5 / 4, false) == -1) @@ -13874,8 +13871,8 @@ int InitBunnyRocket(PLAYER* pp) // at certain angles the clipping box was big enough to block the // initial positioning of the fireball. - SAVE_CLIP; - actor->set_const_clipdist(0); + auto oclipdist = actor->clipdist; + actor->clipdist = 0; actorNew->spr.angle += DAngle90; HelpMissileLateral(actorNew, 900); @@ -13888,14 +13885,14 @@ int InitBunnyRocket(PLAYER* pp) actorNew->user.Counter = 1; if (TestMissileSetPos(actorNew, DoRocket, 1200, zvel)) { - RESTORE_CLIP;; + actor->clipdist = oclipdist;; KillActor(actorNew); return 0; } // inable smoke trail actorNew->user.Counter = 0; - RESTORE_CLIP;; + actor->clipdist = oclipdist;; actorNew->vel.Z = zvel * 0.5; if (WeaponAutoAim(pp->actor, actorNew, DAngle22_5 / 4, false) == -1) @@ -13968,8 +13965,8 @@ int InitNuke(PLAYER* pp) // at certain angles the clipping box was big enough to block the // initial positioning of the fireball. - SAVE_CLIP; - actor->set_const_clipdist(0); + auto oclipdist = actor->clipdist; + actor->clipdist = 0; actorNew->spr.angle += DAngle90; HelpMissileLateral(actorNew, 900); @@ -13982,14 +13979,14 @@ int InitNuke(PLAYER* pp) actorNew->user.Counter = 1; if (TestMissileSetPos(actorNew, DoRocket, 1200, zvel)) { - RESTORE_CLIP;; + actor->clipdist = oclipdist;; KillActor(actorNew); return 0; } // inable smoke trail actorNew->user.Counter = 0; - RESTORE_CLIP;; + actor->clipdist = oclipdist;; actorNew->vel.Z = zvel * 0.5; if (WeaponAutoAim(pp->actor, actorNew, DAngle22_5 / 4, false) == -1) @@ -14154,8 +14151,8 @@ int InitMicro(PLAYER* pp) // at certain angles the clipping box was big enough to block the // initial positioning of the fireball. - SAVE_CLIP; - actor->set_const_clipdist(0); + auto oclipdist = actor->clipdist; + actor->clipdist = 0; actorNew->spr.angle += DAngle90; const int MICRO_LATERAL = 5000; @@ -14169,14 +14166,14 @@ int InitMicro(PLAYER* pp) actorNew->user.Counter = 1; if (MissileSetPos(actorNew, DoMicro, 700)) { - RESTORE_CLIP;; + actor->clipdist = oclipdist;; KillActor(actorNew); continue; } // inable smoke trail actorNew->user.Counter = 0; - RESTORE_CLIP;; + actor->clipdist = oclipdist;; const int MICRO_ANG = 400; @@ -14318,7 +14315,7 @@ bool WallSpriteInsideSprite(DSWActor* wactor, DSWActor* actor) { DVector2 out[2]; GetWallSpritePosition(&wactor->spr, wactor->spr.pos, out); - return IsCloseToLine(actor->spr.pos.XY(), out[0], out[1], actor->fClipdist()) != EClose::Outside; + return IsCloseToLine(actor->spr.pos.XY(), out[0], out[1], actor->clipdist) != EClose::Outside; } @@ -14563,7 +14560,7 @@ int InitSerpSpell(DSWActor* actor) actorNew->user.floor_dist = (16); actorNew->user.Dist = 12.5; - SAVE_CLIP; + auto oclipdist = actor->clipdist; actor->set_const_clipdist(1); actorNew->spr.angle += lat_ang[i]; @@ -14578,7 +14575,7 @@ int InitSerpSpell(DSWActor* actor) UpdateChange(actorNew); MissileSetPos(actorNew, DoMirvMissile, 400); - RESTORE_CLIP;; + actor->clipdist = oclipdist;; if (actor->user.Flags & (SPR_UNDERWATER)) actorNew->user.Flags |= (SPR_UNDERWATER); @@ -14667,7 +14664,7 @@ int InitSerpMonstSpell(DSWActor* actor) actorNew->user.Dist = 12.5; - SAVE_CLIP; + auto oclipdist = actor->clipdist; actor->set_const_clipdist(1); actorNew->spr.angle += lat_ang[i]; @@ -14682,7 +14679,7 @@ int InitSerpMonstSpell(DSWActor* actor) UpdateChange(actorNew); MissileSetPos(actorNew, DoMirvMissile, 400); - RESTORE_CLIP;; + actor->clipdist = oclipdist;; if (actor->user.Flags & (SPR_UNDERWATER)) actorNew->user.Flags |= (SPR_UNDERWATER); @@ -15345,7 +15342,7 @@ int InitTracerUzi(PLAYER* pp) DSWActor* plActor = pp->actor; auto oclipdist = plActor->native_clipdist(); - plActor->set_const_clipdist(0); + plActor->clipdist = 0; actorNew->spr.angle += DAngle90; if (pp->Flags & (PF_TWO_UZI) && pp->WpnUziType == 0) @@ -16816,8 +16813,8 @@ int InitGrenade(PLAYER* pp) actorNew->vel.Z = pp->horizon.horiz.Tan() * HORIZ_MULTF; - SAVE_CLIP; - actor->set_const_clipdist(0); + auto oclipdist = actor->clipdist; + actor->clipdist = 0; actorNew->spr.angle += DAngle90; HelpMissileLateral(actorNew, 800); @@ -16828,7 +16825,7 @@ int InitGrenade(PLAYER* pp) MissileSetPos(actorNew, DoGrenade, 1000); actorNew->user.Flags &= ~(SPR_BOUNCE); - RESTORE_CLIP;; + actor->clipdist = oclipdist;; zvel = actorNew->vel.Z; if (WeaponAutoAim(pp->actor, actorNew, DAngle22_5 / 4, false) >= 0) @@ -17014,7 +17011,7 @@ int InitEnemyMine(DSWActor* actor) int HelpMissileLateral(DSWActor* actor, int dist) { auto old_xvel = actor->vel.X; - SAVE_CLIP; + auto oclipdist = actor->clipdist; actor->vel.X = dist * maptoworld; // not worth changing 28 call locations... @@ -17025,7 +17022,7 @@ int HelpMissileLateral(DSWActor* actor, int dist) actor->user.coll = move_missile(actor, DVector3(vec, 0), 16, 16, 0, 1); actor->vel.X = old_xvel; - RESTORE_CLIP; + actor->clipdist = oclipdist; actor->backuppos(); return 0; @@ -17071,8 +17068,8 @@ int InitFireball(PLAYER* pp) // at certain angles the clipping box was big enough to block the // initial positioning of the fireball. - SAVE_CLIP; - actor->set_const_clipdist(0); + auto oclipdist = actor->clipdist; + actor->clipdist = 0; actorNew->spr.angle += DAngle90; HelpMissileLateral(actorNew, 2100); @@ -17083,12 +17080,12 @@ int InitFireball(PLAYER* pp) if (TestMissileSetPos(actorNew, DoFireball, 1200, zvel * (1375. / 2048.))) { - RESTORE_CLIP;; + actor->clipdist = oclipdist;; KillActor(actorNew); return 0; } - RESTORE_CLIP;; + actor->clipdist = oclipdist;; actorNew->vel.Z = 0.5; if (WeaponAutoAimZvel(pp->actor, actorNew, &zvel, DAngle22_5 / 4, false) == -1) @@ -17954,7 +17951,7 @@ void QueueHole(sectortype* hit_sect, walltype* hit_wall, const DVector3& pos) spawnedActor->spr.pal = 0; spawnedActor->spr.shade = 0; spawnedActor->spr.extra = 0; - spawnedActor->set_const_clipdist(0); + spawnedActor->clipdist = 0; spawnedActor->spr.xoffset = spawnedActor->spr.yoffset = 0; spawnedActor->spr.pos = pos; spawnedActor->spr.picnum = 2151; @@ -18041,7 +18038,7 @@ int QueueFloorBlood(DSWActor* actor) spawnedActor->spr.pal = 0; spawnedActor->spr.shade = 0; spawnedActor->spr.extra = 0; - spawnedActor->set_const_clipdist(0); + spawnedActor->clipdist = 0; spawnedActor->spr.xoffset = spawnedActor->spr.yoffset = 0; spawnedActor->spr.pos = actor->spr.pos.plusZ(1); spawnedActor->spr.angle = RandomAngle(); // Just make it any old angle @@ -18156,7 +18153,7 @@ int QueueFootPrint(DSWActor* actor) spawnedActor->spr.pal = 0; spawnedActor->spr.shade = 0; spawnedActor->spr.extra = 0; - spawnedActor->set_const_clipdist(0); + spawnedActor->clipdist = 0; spawnedActor->spr.xoffset = spawnedActor->spr.yoffset = 0; spawnedActor->spr.pos = actor->spr.pos; spawnedActor->spr.angle = actor->spr.angle; @@ -18297,7 +18294,7 @@ DSWActor* QueueWallBlood(DSWActor* actor, DAngle bang) spawnedActor->spr.pal = 0; spawnedActor->spr.shade = 0; spawnedActor->spr.extra = 0; - spawnedActor->set_const_clipdist(0); + spawnedActor->clipdist = 0; spawnedActor->spr.xoffset = spawnedActor->spr.yoffset = 0; spawnedActor->spr.pos = hit.hitpos; spawnedActor->spr.shade -= 5; // Brighten it up just a bit diff --git a/source/games/sw/src/weapon.h b/source/games/sw/src/weapon.h index 792ecd7ff..fdb08c11a 100644 --- a/source/games/sw/src/weapon.h +++ b/source/games/sw/src/weapon.h @@ -158,7 +158,7 @@ extern int WeaponIsAmmo; inline double CloseRangeDist(DSWActor* a1, DSWActor* a2, double fudge = 25) { - return a1->fClipdist() + a2->fClipdist() + fudge; + return a1->clipdist + a2->clipdist + fudge; } extern short target_ang; diff --git a/wadsrc/static/zscript/coreactor.zs b/wadsrc/static/zscript/coreactor.zs index 7c56450b4..a7d4a4f3c 100644 --- a/wadsrc/static/zscript/coreactor.zs +++ b/wadsrc/static/zscript/coreactor.zs @@ -18,7 +18,7 @@ class CoreActor native native int8 shade; native uint8 pal; - native uint8 clipdist; + native uint8 intclipdist; native uint8 blend; native uint8 xrepeat; native uint8 yrepeat; @@ -31,6 +31,7 @@ class CoreActor native native int16 mdanimcur; native uint8 renderflags; native float alpha; + native double clipdist; native readonly sectortype sector; native readonly int16 spritesetpic;