From a6e35edc6c8d078050de2c182f1713a8befb35e1 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 4 Oct 2022 19:22:46 +0200 Subject: [PATCH] - replaced all set_native_clipdist Note that truncation has to be preserved here to ensure the size stays the same as before so the MulScales were not resolved into their factors. --- source/core/coreactor.h | 5 ----- source/games/duke/src/actors_r.cpp | 4 ++-- source/games/duke/src/bowling.cpp | 9 +-------- source/games/duke/src/gameexec.cpp | 6 +++--- source/games/duke/src/types.h | 2 +- source/games/exhumed/src/move.cpp | 2 +- source/games/sw/src/game.h | 2 +- source/games/sw/src/jweapon.cpp | 2 +- 8 files changed, 10 insertions(+), 22 deletions(-) diff --git a/source/core/coreactor.h b/source/core/coreactor.h index f986435fc..04c57786f 100644 --- a/source/core/coreactor.h +++ b/source/core/coreactor.h @@ -167,11 +167,6 @@ public: return static_cast(GetClass())->ActorInfo()->SpriteSet; } - void set_native_clipdist(int val) - { - clipdist = val * 0.25; - } - int native_clipdist() { return clipdist * 4; diff --git a/source/games/duke/src/actors_r.cpp b/source/games/duke/src/actors_r.cpp index 48ff819f6..bab54957c 100644 --- a/source/games/duke/src/actors_r.cpp +++ b/source/games/duke/src/actors_r.cpp @@ -1089,7 +1089,7 @@ static bool weaponhitwall(DDukeActor *proj, walltype* wal, const DVector3& oldpo j->spr.yrepeat = 8; j->spr.cstat = CSTAT_SPRITE_ALIGNMENT_WALL; j->spr.angle += DAngle90; - j->set_native_clipdist(MulScale(proj->spr.xrepeat, tileWidth(proj->spr.picnum), 7)); + j->clipdist = MulScale(proj->spr.xrepeat, tileWidth(proj->spr.picnum), 7) * 0.25; } } deletesprite(proj); @@ -1863,7 +1863,7 @@ static void rrra_specialstats() { act->spr.xrepeat >>= 1; act->spr.yrepeat >>= 1; - act->set_native_clipdist(MulScale(act->spr.xrepeat, tileHeight(act->spr.picnum), 7)); + act->clipdist = MulScale(act->spr.xrepeat, tileHeight(act->spr.picnum), 7) * 0.25; } break; } diff --git a/source/games/duke/src/bowling.cpp b/source/games/duke/src/bowling.cpp index 0b055af88..80824cb97 100644 --- a/source/games/duke/src/bowling.cpp +++ b/source/games/duke/src/bowling.cpp @@ -181,14 +181,7 @@ void resetpins(sectortype* sect) if (spawned) { spawned->spr.lotag = a2->spr.lotag; - if (spawned->spr.lotag == 3 || spawned->spr.lotag == 5) - { - spawned->set_native_clipdist((1 + (krand() % 1)) * 16 + 32); - } - else - { - spawned->set_native_clipdist((1 + (krand() % 1)) * 16 + 32); - } + spawned->clipdist = 12; // random formula here was bogus and always produced 48. spawned->spr.angle -= DAngle22_5 * 0.125 * (((krand() & 32) - (krand() & 64)) >> 5); // weird formula to preserve number of krand calls. } } diff --git a/source/games/duke/src/gameexec.cpp b/source/games/duke/src/gameexec.cpp index d7f58e7a4..b6a227cbf 100644 --- a/source/games/duke/src/gameexec.cpp +++ b/source/games/duke/src/gameexec.cpp @@ -1193,8 +1193,8 @@ void DoActor(bool bSet, int lVar1, int lLabelID, int lVar2, DDukeActor* sActor, else SetGameVarID(lVar2, act->spr.pal, sActor, sPlayer); break; case ACTOR_CLIPDIST: - if (bSet) act->set_native_clipdist(lValue); - else SetGameVarID(lVar2, act->native_clipdist(), sActor, sPlayer); + if (bSet) act->clipdist = lValue * 0.25; + else SetGameVarID(lVar2, int(act->clipdist * 4), sActor, sPlayer); break; case ACTOR_DETAIL: if (bSet) act->spriteextra = lValue; @@ -2196,7 +2196,7 @@ int ParseState::parse(void) break; case concmd_clipdist: insptr++; - g_ac->set_native_clipdist( (uint8_t) *insptr); + g_ac->clipdist = ((uint8_t) *insptr) * 0.25; insptr++; break; case concmd_cstat: diff --git a/source/games/duke/src/types.h b/source/games/duke/src/types.h index ead01f180..92ae7b3eb 100644 --- a/source/games/duke/src/types.h +++ b/source/games/duke/src/types.h @@ -129,7 +129,7 @@ public: void setClipDistFromTile() { - set_native_clipdist(MulScale(spr.xrepeat, tileWidth(spr.picnum), 7)); + clipdist = MulScale(spr.xrepeat, tileWidth(spr.picnum), 7) * 0.25; } }; diff --git a/source/games/exhumed/src/move.cpp b/source/games/exhumed/src/move.cpp index 3d68295f7..eb91f5a1f 100644 --- a/source/games/exhumed/src/move.cpp +++ b/source/games/exhumed/src/move.cpp @@ -747,7 +747,7 @@ void CreatePushBlock(sectortype* pSector) sBlockInfo[nBlock].mindist = mindist; - pActor->set_native_clipdist( (int(mindist * worldtoint) & 0xFF) << 2); + pActor->clipdist = int(mindist * 16); // looks weird, but that's what the old code did. pSector->extra = nBlock; } diff --git a/source/games/sw/src/game.h b/source/games/sw/src/game.h index 9bf2f241e..c16bca224 100644 --- a/source/games/sw/src/game.h +++ b/source/games/sw/src/game.h @@ -2020,7 +2020,7 @@ inline double ActorSizeToTop(DSWActor* a) inline void SetActorSizeX(DSWActor* sp) { - sp->set_native_clipdist(MulScale(tileWidth(sp->spr.picnum), sp->spr.xrepeat, 6)); + sp->clipdist = MulScale(tileWidth(sp->spr.picnum), sp->spr.xrepeat, 6) * 0.25; // ensure proper truncation for this. } inline bool Facing(DSWActor* actor1, DSWActor* actor2) diff --git a/source/games/sw/src/jweapon.cpp b/source/games/sw/src/jweapon.cpp index 655b281a9..fd0c0569a 100644 --- a/source/games/sw/src/jweapon.cpp +++ b/source/games/sw/src/jweapon.cpp @@ -1745,7 +1745,7 @@ int InitPhosphorus(DSWActor* actor) actorNew->spr.shade = -15; // !FRANK - clipbox must be <= weapon otherwise can clip thru walls if (actor->native_clipdist() > 0) - actorNew->set_native_clipdist(actor->native_clipdist() - 1); + actorNew->clipdist -= 0.25; else actorNew->copy_clipdist(actor); actorNew->user.WeaponNum = actor->user.WeaponNum;