From e60fafec52fb619b7cb8858350e2c68af5533e42 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 5 Oct 2022 20:18:19 +0200 Subject: [PATCH] - got rid of most REPEAT_SCALE factors. --- source/core/automap.cpp | 4 ++-- source/core/gamefuncs.cpp | 7 ++++--- source/core/maptypes.h | 5 +++++ source/games/blood/src/actor.cpp | 2 +- source/games/blood/src/ai.cpp | 2 +- source/games/blood/src/aibat.cpp | 2 +- source/games/blood/src/aiboneel.cpp | 2 +- source/games/blood/src/aicerber.cpp | 2 +- source/games/blood/src/aigarg.cpp | 2 +- source/games/blood/src/aighost.cpp | 2 +- source/games/blood/src/aitchern.cpp | 4 ++-- source/games/blood/src/aiunicult.cpp | 2 +- source/games/blood/src/callback.cpp | 8 ++++---- source/games/blood/src/gameutil.cpp | 6 +++--- source/games/blood/src/nnexts.cpp | 12 ++++++------ source/games/blood/src/triggers.cpp | 2 +- source/games/blood/src/weapon.cpp | 2 +- source/games/duke/src/actors_d.cpp | 2 +- source/games/duke/src/actors_r.cpp | 2 +- source/games/duke/src/animatesprites_d.cpp | 2 +- source/games/duke/src/animatesprites_r.cpp | 2 +- source/games/duke/src/player_d.cpp | 12 ++++++------ source/games/duke/src/player_r.cpp | 10 +++++----- source/games/exhumed/src/view.cpp | 2 +- source/games/sw/src/game.h | 4 ++-- 25 files changed, 54 insertions(+), 48 deletions(-) diff --git a/source/core/automap.cpp b/source/core/automap.cpp index 8a14d253e..3c6450da7 100644 --- a/source/core/automap.cpp +++ b/source/core/automap.cpp @@ -645,7 +645,7 @@ void DrawAutomapAlignmentFacing(const spritetype& spr, const DVector2& bpos, con void DrawAutomapAlignmentWall(const spritetype& spr, const DVector2& bpos, const DVector2& cangvect, const double czoom, const DVector2& xydim, const PalEntry& col) { - auto xrep = spr.xrepeat * REPEAT_SCALE; + auto xrep = spr.ScaleX(); auto xspan = tileWidth(spr.picnum); auto xoff = tileLeftOffset(spr.picnum) + spr.xoffset; @@ -671,7 +671,7 @@ void DrawAutomapAlignmentWall(const spritetype& spr, const DVector2& bpos, const void DrawAutomapAlignmentFloor(const spritetype& spr, const DVector2& bpos, const DVector2& cangvect, const double czoom, const DVector2& xydim, const PalEntry& col) { - auto xrep = spr.xrepeat * REPEAT_SCALE; + auto xrep = spr.ScaleX(); auto yrep = spr.ScaleY(); auto xspan = tileWidth(spr.picnum); auto yspan = tileHeight(spr.picnum); diff --git a/source/core/gamefuncs.cpp b/source/core/gamefuncs.cpp index 180905d05..2eebe8930 100644 --- a/source/core/gamefuncs.cpp +++ b/source/core/gamefuncs.cpp @@ -227,7 +227,7 @@ void GetWallSpritePosition(const spritetypebase* spr, const DVector2& pos, DVect xoffset = tex->GetDisplayLeftOffset() + spr->xoffset; } - auto p = spr->angle.ToVector().Rotated90CW() * spr->xrepeat * REPEAT_SCALE; + auto p = spr->angle.ToVector().Rotated90CW() * spr->ScaleX(); if (spr->cstat & CSTAT_SPRITE_XFLIP) xoffset = -xoffset; double origin = (width * 0.5) + xoffset; @@ -249,7 +249,7 @@ void TGetFlatSpritePosition(const spritetypebase* spr, const DVector2& pos, DVec double width, height, leftofs, topofs; double sloperatio = sqrt(heinum * heinum + SLOPEVAL_FACTOR * SLOPEVAL_FACTOR) * (1. / SLOPEVAL_FACTOR); - double xrepeat = spr->xrepeat * REPEAT_SCALE; + double xrepeat = spr->ScaleX(); double yrepeat = spr->ScaleY(); int xo = heinum ? 0 : spr->xoffset; @@ -572,7 +572,8 @@ double intersectSprite(DCoreActor* actor, const DVector3& start, const DVector3& double factor = NearestPointOnLineFast(actor->spr.pos.X, actor->spr.pos.Y, start.X, start.Y, end.X, end.Y); if (factor < 0 || factor > maxfactor) return -1; - auto sprwidth = tileWidth(actor->spr.picnum) * actor->spr.xrepeat * (REPEAT_SCALE * 0.5); + + auto sprwidth = tileWidth(actor->spr.picnum) * actor->spr.ScaleX() * 0.5; auto point = start + direction * factor; // Using proper distance here, Build originally used the sum of x- and y-distance diff --git a/source/core/maptypes.h b/source/core/maptypes.h index c75568ba6..2badf4095 100644 --- a/source/core/maptypes.h +++ b/source/core/maptypes.h @@ -480,6 +480,11 @@ struct spritetypebase yrepeat = uint8_t(y * (1 / REPEAT_SCALE)); } + double ScaleX() const + { + return xrepeat * REPEAT_SCALE; + } + double ScaleY() const { return yrepeat * REPEAT_SCALE; diff --git a/source/games/blood/src/actor.cpp b/source/games/blood/src/actor.cpp index 6d1dad8de..f6b890fd7 100644 --- a/source/games/blood/src/actor.cpp +++ b/source/games/blood/src/actor.cpp @@ -2573,7 +2573,7 @@ static void ConcussSprite(DBloodActor* source, DBloodActor* actor, const DVector if (mass > 0) { - double size = (tileWidth(actor->spr.picnum) * actor->spr.xrepeat * REPEAT_SCALE * tileHeight(actor->spr.picnum) * actor->spr.ScaleY()) / 0x20000; + double size = (tileWidth(actor->spr.picnum) * actor->spr.ScaleX() * tileHeight(actor->spr.picnum) * actor->spr.ScaleY()) / 0x20000; actor->vel += vect * Scale(damage, size, mass); } } diff --git a/source/games/blood/src/ai.cpp b/source/games/blood/src/ai.cpp index 6f427788b..33361773f 100644 --- a/source/games/blood/src/ai.cpp +++ b/source/games/blood/src/ai.cpp @@ -921,7 +921,7 @@ void aiSetTarget(DBloodActor* actor, DBloodActor* target) { actor->SetTarget(target); DUDEINFO* pDudeInfo = getDudeInfo(target->spr.type); - double eyeHeight = (pDudeInfo->eyeHeight * target->spr.yrepeat) * REPEAT_SCALE; + double eyeHeight = (pDudeInfo->eyeHeight * target->spr.ScaleY()); actor->xspr.TargetPos = target->spr.pos.plusZ(-eyeHeight); } } diff --git a/source/games/blood/src/aibat.cpp b/source/games/blood/src/aibat.cpp index 2691efb5b..1883a30b4 100644 --- a/source/games/blood/src/aibat.cpp +++ b/source/games/blood/src/aibat.cpp @@ -167,7 +167,7 @@ static void batThinkPonder(DBloodActor* actor) { DAngle nDeltaAngle = absangle(actor->spr.angle, dvec.Angle()); double height = (pDudeInfo->eyeHeight * actor->spr.ScaleY()); - double height2 = (getDudeInfo(pTarget->spr.type)->eyeHeight * pTarget->spr.yrepeat) * REPEAT_SCALE; + double height2 = (getDudeInfo(pTarget->spr.type)->eyeHeight * pTarget->spr.ScaleY()); double top, bottom; GetActorExtents(actor, &top, &bottom); if (cansee(pTarget->spr.pos, pTarget->sector(), actor->spr.pos.plusZ(-height), actor->sector())) diff --git a/source/games/blood/src/aiboneel.cpp b/source/games/blood/src/aiboneel.cpp index 1296916ad..7e0eb7adc 100644 --- a/source/games/blood/src/aiboneel.cpp +++ b/source/games/blood/src/aiboneel.cpp @@ -182,7 +182,7 @@ static void eelThinkPonder(DBloodActor* actor) { DAngle nDeltaAngle = absangle(actor->spr.angle, nAngle); double height = (pDudeInfo->eyeHeight * actor->spr.ScaleY()); - double height2 = (getDudeInfo(target->spr.type)->eyeHeight * target->spr.yrepeat) * REPEAT_SCALE; + double height2 = (getDudeInfo(target->spr.type)->eyeHeight * target->spr.ScaleY()); double top, bottom; GetActorExtents(actor, &top, &bottom); if (cansee(target->spr.pos, target->sector(), actor->spr.pos.plusZ(-height), actor->sector())) diff --git a/source/games/blood/src/aicerber.cpp b/source/games/blood/src/aicerber.cpp index 0f2e2afbe..54c6a7ac7 100644 --- a/source/games/blood/src/aicerber.cpp +++ b/source/games/blood/src/aicerber.cpp @@ -181,7 +181,7 @@ void cerberusBurnSeqCallback2(int, DBloodActor* actor) if (nDeltaAngle <= DAngle45) { DUDEINFO* pDudeInfo2 = getDudeInfo(actor2->spr.type); - double height1 = (pDudeInfo2->aimHeight * actor2->spr.yrepeat) * REPEAT_SCALE; + double height1 = (pDudeInfo2->aimHeight * actor2->spr.ScaleY()); double tz1 = actor2->spr.pos.Z - height - actor->spr.pos.Z; if (cansee(pos, actor->sector(), pos2, actor2->sector())) diff --git a/source/games/blood/src/aigarg.cpp b/source/games/blood/src/aigarg.cpp index 836ea6914..730df32c5 100644 --- a/source/games/blood/src/aigarg.cpp +++ b/source/games/blood/src/aigarg.cpp @@ -104,7 +104,7 @@ void BlastSSeqCallback(int, DBloodActor* actor) wrand(); // ??? if (!actor->ValidateTarget(__FUNCTION__)) return; auto target = actor->GetTarget(); - double height = (actor->spr.yrepeat * getDudeInfo(actor->spr.type)->eyeHeight) * REPEAT_SCALE; + double height = (actor->spr.ScaleY() * getDudeInfo(actor->spr.type)->eyeHeight); DVector3 pos(actor->spr.pos.XY(), height); DVector3 Aim(actor->spr.angle.ToVector(), actor->dudeSlope); diff --git a/source/games/blood/src/aighost.cpp b/source/games/blood/src/aighost.cpp index db4d8eca6..61d04706c 100644 --- a/source/games/blood/src/aighost.cpp +++ b/source/games/blood/src/aighost.cpp @@ -91,7 +91,7 @@ void ghostBlastSeqCallback(int, DBloodActor* actor) wrand(); // ??? if (!actor->ValidateTarget(__FUNCTION__)) return; auto target = actor->GetTarget(); - double height = (actor->spr.yrepeat * getDudeInfo(actor->spr.type)->eyeHeight) * REPEAT_SCALE; + double height = (actor->spr.ScaleY() * getDudeInfo(actor->spr.type)->eyeHeight); DVector3 pos(actor->spr.pos.XY(), height); DVector3 Aim(actor->spr.angle.ToVector(), actor->dudeSlope); diff --git a/source/games/blood/src/aitchern.cpp b/source/games/blood/src/aitchern.cpp index 60541e884..9a3b8fafb 100644 --- a/source/games/blood/src/aitchern.cpp +++ b/source/games/blood/src/aitchern.cpp @@ -61,7 +61,7 @@ void sub_71A90(int, DBloodActor* actor) void tchernobogBurnSeqCallback(int, DBloodActor* actor) { DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type); - double height = actor->spr.yrepeat * pDudeInfo->eyeHeight * REPEAT_SCALE * 0.25; + double height = actor->spr.ScaleY() * pDudeInfo->eyeHeight * 0.25; if (!actor->ValidateTarget(__FUNCTION__)) return; DVector3 pos(actor->spr.pos.XY(), height); @@ -120,7 +120,7 @@ void tchernobogBurnSeqCallback2(int, DBloodActor* actor) if (!actor->ValidateTarget(__FUNCTION__)) return; DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type); - double height = actor->spr.yrepeat * pDudeInfo->eyeHeight * REPEAT_SCALE * 0.25; + double height = actor->spr.ScaleY() * pDudeInfo->eyeHeight * 0.25; DVector3 pos(actor->spr.pos.XY(), height); DVector3 Aim(actor->spr.angle.ToVector(), -actor->dudeSlope); diff --git a/source/games/blood/src/aiunicult.cpp b/source/games/blood/src/aiunicult.cpp index 7d177739c..5c39f9dec 100644 --- a/source/games/blood/src/aiunicult.cpp +++ b/source/games/blood/src/aiunicult.cpp @@ -1797,7 +1797,7 @@ void dudeLeechOperate(DBloodActor* actor, const EVENT& event) actor->spr.angle = (atpos - actor->spr.pos.XY()).Angle(); DVector3 dv; dv.XY() = actor->spr.angle.ToVector() * 64; - double tz = actTarget->spr.pos.Z - (actTarget->spr.yrepeat * pDudeInfo->aimHeight) * REPEAT_SCALE; + double tz = actTarget->spr.pos.Z - (actTarget->spr.ScaleY() * pDudeInfo->aimHeight); double dz = (tz - top - 1) / nDist * 4; int nMissileType = kMissileLifeLeechAltNormal + (actor->xspr.data3 ? 1 : 0); int t2; diff --git a/source/games/blood/src/callback.cpp b/source/games/blood/src/callback.cpp index 4278c5e51..74525bf68 100644 --- a/source/games/blood/src/callback.cpp +++ b/source/games/blood/src/callback.cpp @@ -43,7 +43,7 @@ void fxFlameLick(DBloodActor* actor, sectortype*) // 0 GetActorExtents(actor, &top, &bottom); for (int i = 0; i < 3; i++) { - double nDist = (actor->spr.xrepeat * tileWidth(actor->spr.picnum)) * (REPEAT_SCALE / 4); + double nDist = (actor->spr.ScaleX() * tileWidth(actor->spr.picnum)) * (1. / 4); DAngle nAngle = RandomAngle(); DVector2 dv = nAngle.ToVector() * nDist; DVector2 pos = actor->spr.pos.XY() + dv; @@ -223,7 +223,7 @@ void fxDynPuff(DBloodActor* actor, sectortype*) // 8 if (!actor) return; if (actor->vel.Z) { - double nDist = (actor->spr.xrepeat * tileWidth(actor->spr.picnum)) * (REPEAT_SCALE / 2); + double nDist = (actor->spr.ScaleX() * tileWidth(actor->spr.picnum)) * (1. / 2); DVector3 pos = actor->spr.pos + (actor->spr.angle - DAngle90).ToVector() * nDist; auto pFX = gFX.fxSpawnActor(FX_7, actor->sector(), pos); if (pFX) @@ -342,7 +342,7 @@ void PlayerBubble(DBloodActor* actor, sectortype*) // 10 GetActorExtents(actor, &top, &bottom); for (int i = 0; i < (pPlayer->bubbleTime >> 6); i++) { - double nDist = (actor->spr.xrepeat * tileWidth(actor->spr.picnum)) * (REPEAT_SCALE / 2); + double nDist = (actor->spr.ScaleX() * tileWidth(actor->spr.picnum)) * (1. / 2); DVector2 pos = actor->spr.pos.XY() + actor->spr.angle.ToVector() * nDist; double z = bottom - RandomD(bottom - top, 8); auto pFX = gFX.fxSpawnActor((FX_ID)(FX_23 + Random(3)), actor->sector(), DVector3(pos, z)); @@ -371,7 +371,7 @@ void EnemyBubble(DBloodActor* actor, sectortype*) // 11 for (int i = 0; i < int(abs(actor->vel.Z) * 0.25); i++) { auto nAngle = RandomAngle(); - double nDist = (actor->spr.xrepeat * tileWidth(actor->spr.picnum)) * (REPEAT_SCALE / 2); + double nDist = (actor->spr.ScaleX() * tileWidth(actor->spr.picnum)) * (1. / 2); DVector2 pos = actor->spr.pos.XY() + nAngle.ToVector() * nDist; double z = bottom - RandomD(bottom - top, 8); diff --git a/source/games/blood/src/gameutil.cpp b/source/games/blood/src/gameutil.cpp index d5ca70aae..f01f666c1 100644 --- a/source/games/blood/src/gameutil.cpp +++ b/source/games/blood/src/gameutil.cpp @@ -276,14 +276,14 @@ int VectorScan(DBloodActor* actor, double nOffset, double nZOffset, const DVecto if (tileWidth(nPicnum) == 0 || tileHeight(nPicnum) == 0) return SS_SPRITE; - double height = (tileHeight(nPicnum) * other->spr.yrepeat) * REPEAT_SCALE; + double height = (tileHeight(nPicnum) * other->spr.ScaleY()); double otherZ = other->spr.pos.Z; if (other->spr.cstat & CSTAT_SPRITE_YCENTER) otherZ += height / 2; int nTopOfs = tileTopOffset(nPicnum); if (nTopOfs) - otherZ -= (nTopOfs * other->spr.yrepeat) * REPEAT_SCALE; + otherZ -= (nTopOfs * other->spr.ScaleY()); assert(height > 0); double height2 = (otherZ - gHitInfo.hitpos.Z) * tileHeight(nPicnum) / height; @@ -292,7 +292,7 @@ int VectorScan(DBloodActor* actor, double nOffset, double nZOffset, const DVecto if (height2 >= 0 && height2 < tileHeight(nPicnum)) { - double width = (tileWidth(nPicnum) * other->spr.xrepeat) * REPEAT_SCALE * 0.75; // should actually be 0.8 to match the renderer! + double width = (tileWidth(nPicnum) * other->spr.ScaleX()) * 0.75; // should actually be 0.8 to match the renderer! double check1 = ((pos.Y - other->spr.pos.Y) * vel.X - (pos.X - other->spr.pos.X) * vel.Y) / vel.XY().Length(); assert(width > 0); diff --git a/source/games/blood/src/nnexts.cpp b/source/games/blood/src/nnexts.cpp index db792f9eb..4a51de018 100644 --- a/source/games/blood/src/nnexts.cpp +++ b/source/games/blood/src/nnexts.cpp @@ -1605,7 +1605,7 @@ void debrisBubble(DBloodActor* actor) GetActorExtents(actor, &top, &bottom); for (unsigned int i = 0; i < 1 + Random(5); i++) { - double nDist = actor->spr.xrepeat * tileWidth(actor->spr.picnum) * (REPEAT_SCALE * 0.5); // original code ended with * 8 which is 1/2 map unit. + double nDist = actor->spr.ScaleX() * tileWidth(actor->spr.picnum) * 0.5; // original code ended with * 8 which is 1/2 map unit. DAngle nAngle = RandomAngle(); DVector3 pos; pos.XY() = actor->spr.pos.XY() + nAngle.ToVector() * nDist; @@ -4436,7 +4436,7 @@ bool condCheckDude(DBloodActor* aCond, int cmpOp, bool PUSH) condError(aCond, "Dude #%d has no target!", objActor->GetIndex()); DUDEINFO* pInfo = getDudeInfo(objActor->spr.type); - double height = (pInfo->eyeHeight * objActor->spr.yrepeat) * REPEAT_SCALE; + double height = (pInfo->eyeHeight * objActor->spr.ScaleY()); auto delta = targ->spr.pos.XY() - objActor->spr.pos.XY(); @@ -5154,7 +5154,7 @@ bool aiFightDudeCanSeeTarget(DBloodActor* dudeactor, DUDEINFO* pDudeInfo, DBlood // check target if (dv.Length() < pDudeInfo->SeeDist()) { - double height = (pDudeInfo->eyeHeight * dudeactor->spr.yrepeat) * REPEAT_SCALE; + double height = (pDudeInfo->eyeHeight * dudeactor->spr.ScaleY()); // is there a line of sight to the target? if (cansee(dudeactor->spr.pos, dudeactor->sector(), targetactor->spr.pos.plusZ(-height), targetactor->sector())) @@ -8234,7 +8234,7 @@ void aiPatrolAlarmLite(DBloodActor* actor, DBloodActor* targetactor) if (dudeactor->xspr.health <= 0) continue; - double eaz2 = (getDudeInfo(targetactor->spr.type)->eyeHeight * targetactor->spr.yrepeat) * REPEAT_SCALE; + double eaz2 = (getDudeInfo(targetactor->spr.type)->eyeHeight * targetactor->spr.ScaleY()); double nDist = (dudeactor->spr.pos.XY() - actor->spr.pos.XY()).LengthSquared(); if (nDist >= kPatrolAlarmSeeDistSq || !cansee(DVector3(actor->spr.pos, zt1), actor->sector(), dudeactor->spr.pos.plusZ(-eaz2), dudeactor->sector())) { @@ -8266,7 +8266,7 @@ void aiPatrolAlarmFull(DBloodActor* actor, DBloodActor* targetactor, bool chain) if (actor->xspr.health <= 0) return; - double eaz2 = (getDudeInfo(actor->spr.type)->eyeHeight * actor->spr.yrepeat) * REPEAT_SCALE; + double eaz2 = (getDudeInfo(actor->spr.type)->eyeHeight * actor->spr.ScaleY()); auto pos2 = actor->spr.pos.plusZ(-eaz2); auto pSect2 = actor->sector(); @@ -8286,7 +8286,7 @@ void aiPatrolAlarmFull(DBloodActor* actor, DBloodActor* targetactor, bool chain) if (dudeactor->xspr.health <= 0) continue; - double eaz1 = (getDudeInfo(dudeactor->spr.type)->eyeHeight * dudeactor->spr.yrepeat) * REPEAT_SCALE; + double eaz1 = (getDudeInfo(dudeactor->spr.type)->eyeHeight * dudeactor->spr.ScaleY()); auto pos1 = dudeactor->spr.pos.plusZ(-eaz1); auto pSect1 = dudeactor->sector(); diff --git a/source/games/blood/src/triggers.cpp b/source/games/blood/src/triggers.cpp index 87c92ada9..c313f5a9b 100644 --- a/source/games/blood/src/triggers.cpp +++ b/source/games/blood/src/triggers.cpp @@ -273,7 +273,7 @@ void LifeLeechOperate(DBloodActor* actor, EVENT event) pos.XY() += target->vel.XY() * nDist * (65536. / 0x1aaaaa); auto angBak = actor->spr.angle; actor->spr.angle = (pos.XY() - actor->spr.pos.XY()).Angle(); - double tz = target->spr.pos.Z - (target->spr.yrepeat * pDudeInfo->aimHeight) * REPEAT_SCALE; + double tz = target->spr.pos.Z - (target->spr.ScaleY() * pDudeInfo->aimHeight); auto dvec = DVector3(actor->spr.angle.ToVector(), ((tz - top - 1) / nDist) * (1. / 16.)); int nMissileType = kMissileLifeLeechAltNormal + (actor->xspr.data3 ? 1 : 0); if (auto missile = actFireMissile(actor, 0, (top - actor->spr.pos.Z) - 1, dvec, nMissileType)) diff --git a/source/games/blood/src/weapon.cpp b/source/games/blood/src/weapon.cpp index 64728e905..5507acea5 100644 --- a/source/games/blood/src/weapon.cpp +++ b/source/games/blood/src/weapon.cpp @@ -494,7 +494,7 @@ void UpdateAimVector(PLAYER* pPlayer) DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type); if (cansee(pos, plActor->sector(), pos2, actor->sector())) { - double center = (actor->spr.yrepeat * pDudeInfo->aimHeight) * REPEAT_SCALE; + double center = (actor->spr.ScaleY() * pDudeInfo->aimHeight); double dzCenter = (pos2.Z - center) - pos.Z; nClosest = nDist2; diff --git a/source/games/duke/src/actors_d.cpp b/source/games/duke/src/actors_d.cpp index 5c2ea94de..a072eaa3d 100644 --- a/source/games/duke/src/actors_d.cpp +++ b/source/games/duke/src/actors_d.cpp @@ -450,7 +450,7 @@ int movesprite_ex_d(DDukeActor* actor, const DVector3& change, unsigned int clip auto dasectp = actor->sector(); auto ppos = actor->spr.pos; - ppos.Z -= (tileHeight(actor->spr.picnum) * actor->spr.yrepeat) * REPEAT_SCALE * 0.5; + ppos.Z -= (tileHeight(actor->spr.picnum) * actor->spr.ScaleY()) * 0.5; if (bg) { diff --git a/source/games/duke/src/actors_r.cpp b/source/games/duke/src/actors_r.cpp index e6cedc8e4..4074c059d 100644 --- a/source/games/duke/src/actors_r.cpp +++ b/source/games/duke/src/actors_r.cpp @@ -378,7 +378,7 @@ int movesprite_ex_r(DDukeActor* actor, const DVector3& change, unsigned int clip auto dasectp = actor->sector(); auto ppos = actor->spr.pos; - ppos.Z -= (tileHeight(actor->spr.picnum) * actor->spr.yrepeat) * REPEAT_SCALE * 0.5; + ppos.Z -= (tileHeight(actor->spr.picnum) * actor->spr.ScaleY()) * 0.5; if (bg) { diff --git a/source/games/duke/src/animatesprites_d.cpp b/source/games/duke/src/animatesprites_d.cpp index 2b1213777..c547a0707 100644 --- a/source/games/duke/src/animatesprites_d.cpp +++ b/source/games/duke/src/animatesprites_d.cpp @@ -391,7 +391,7 @@ void animatesprites_d(tspriteArray& tsprites, const DVector2& viewVec, DAngle vi { double v = h->spr.pos.Z - ps[p].GetActor()->floorz + 3; if (v > 4 && h->spr.yrepeat > 32 && h->spr.extra > 0) - h->spr.yoffset = (int8_t)(v * (1/REPEAT_SCALE) / h->spr.yrepeat); + h->spr.yoffset = (int8_t)(v / h->spr.ScaleY()); else h->spr.yoffset = 0; } diff --git a/source/games/duke/src/animatesprites_r.cpp b/source/games/duke/src/animatesprites_r.cpp index ae3425719..073c143fc 100644 --- a/source/games/duke/src/animatesprites_r.cpp +++ b/source/games/duke/src/animatesprites_r.cpp @@ -432,7 +432,7 @@ void animatesprites_r(tspriteArray& tsprites, const DVector2& viewVec, DAngle vi { double v = h->spr.pos.Z - ps[p].GetActor()->floorz + 3; if (v > 4 && h->spr.yrepeat > 32 && h->spr.extra > 0) - h->spr.yoffset = (int8_t)(v * (1 / REPEAT_SCALE) / h->spr.yrepeat); + h->spr.yoffset = (int8_t)(v / h->spr.ScaleY()); else h->spr.yoffset = 0; } diff --git a/source/games/duke/src/player_d.cpp b/source/games/duke/src/player_d.cpp index 0a785110c..18df38916 100644 --- a/source/games/duke/src/player_d.cpp +++ b/source/games/duke/src/player_d.cpp @@ -339,7 +339,7 @@ static void shootweapon(DDukeActor *actor, int p, DVector3 pos, DAngle ang, int if (aimed) { - double dal = ((aimed->spr.xrepeat * tileHeight(aimed->spr.picnum)) * REPEAT_SCALE * 0.5) + 5; + double dal = ((aimed->spr.ScaleX() * tileHeight(aimed->spr.picnum)) * 0.5) + 5; switch (aimed->spr.picnum) { case GREENSLIME: @@ -597,7 +597,7 @@ static void shootstuff(DDukeActor* actor, int p, DVector3 pos, DAngle ang, int a if (aimed) { - double dal = ((aimed->spr.xrepeat * tileHeight(aimed->spr.picnum)) * REPEAT_SCALE * 0.5) - 12; + double dal = ((aimed->spr.ScaleX() * tileHeight(aimed->spr.picnum)) * 0.5) - 12; double dist = (ps[p].GetActor()->spr.pos.XY() - aimed->spr.pos.XY()).Length(); zvel = ((aimed->spr.pos.Z - pos.Z - dal) * vel) / dist; @@ -708,7 +708,7 @@ static void shootrpg(DDukeActor *actor, int p, DVector3 pos, DAngle ang, int atw aimed = aim(actor, AUTO_AIM_ANGLE); if (aimed) { - double dal = ((aimed->spr.xrepeat * tileHeight(aimed->spr.picnum)) * REPEAT_SCALE * 0.5) + 8; + double dal = ((aimed->spr.ScaleX() * tileHeight(aimed->spr.picnum)) * 0.5) + 8; double dist = (ps[p].GetActor()->spr.pos.XY() - aimed->spr.pos.XY()).Length(); zvel = ((aimed->spr.pos.Z - pos.Z - dal) * vel) / dist; if (aimed->spr.picnum != RECON) @@ -934,7 +934,7 @@ static void shootgrowspark(DDukeActor* actor, int p, DVector3 pos, DAngle ang) auto aimed = aim(actor, AUTO_AIM_ANGLE); if (aimed) { - double dal = ((aimed->spr.xrepeat * tileHeight(aimed->spr.picnum)) * REPEAT_SCALE * 0.5) + 5; + double dal = ((aimed->spr.ScaleX() * tileHeight(aimed->spr.picnum)) * 0.5) + 5; switch (aimed->spr.picnum) { case GREENSLIME: @@ -1043,7 +1043,7 @@ static void shootshrinker(DDukeActor* actor, int p, const DVector3& pos, DAngle auto aimed = isNamWW2GI() ? nullptr : aim(actor, AUTO_AIM_ANGLE); if (aimed) { - double dal = ((aimed->spr.xrepeat * tileHeight(aimed->spr.picnum)) * REPEAT_SCALE * 0.5); + double dal = ((aimed->spr.ScaleX() * tileHeight(aimed->spr.picnum)) * 0.5); double dist = (ps[p].GetActor()->spr.pos.XY() - aimed->spr.pos.XY()).Length(); zvel = ((aimed->spr.pos.Z - pos.Z - dal - 4) * 48) / dist; ang = (aimed->spr.pos.XY() - pos.XY()).Angle(); @@ -1113,7 +1113,7 @@ void shoot_d(DDukeActor* actor, int atwith) else { sang = actor->spr.angle; - spos = actor->spr.pos.plusZ(-(actor->spr.yrepeat * tileHeight(actor->spr.picnum) * REPEAT_SCALE * 0.5) + 4); + spos = actor->spr.pos.plusZ(-(actor->spr.ScaleY() * tileHeight(actor->spr.picnum) * 0.5) + 4); if (actor->spr.picnum != ROTATEGUN) { diff --git a/source/games/duke/src/player_r.cpp b/source/games/duke/src/player_r.cpp index e1cacd218..364c64360 100644 --- a/source/games/duke/src/player_r.cpp +++ b/source/games/duke/src/player_r.cpp @@ -213,7 +213,7 @@ static void shootweapon(DDukeActor* actor, int p, DVector3 pos, DAngle ang, int auto aimed = aim(actor, AUTO_AIM_ANGLE); if (aimed) { - double dal = ((aimed->spr.xrepeat * tileHeight(aimed->spr.picnum)) * REPEAT_SCALE * 0.5) + 5; + double dal = ((aimed->spr.ScaleX() * tileHeight(aimed->spr.picnum)) * 0.5) + 5; double dist = (ps[p].GetActor()->spr.pos.XY() - aimed->spr.pos.XY()).Length(); zvel = ((aimed->spr.pos.Z - pos.Z - dal) * 16) / dist; ang = (aimed->spr.pos - pos).Angle(); @@ -504,7 +504,7 @@ static void shootstuff(DDukeActor* actor, int p, DVector3 pos, DAngle ang, int a if (aimed) { - double dal = ((aimed->spr.xrepeat * tileHeight(aimed->spr.picnum)) * REPEAT_SCALE * 0.5) - 12; + double dal = ((aimed->spr.ScaleX() * tileHeight(aimed->spr.picnum)) * 0.5) - 12; double dist = (ps[p].GetActor()->spr.pos.XY() - aimed->spr.pos.XY()).Length(); zvel = ((aimed->spr.pos.Z - pos.Z - dal) * vel) / dist; @@ -621,7 +621,7 @@ static void shootrpg(DDukeActor* actor, int p, DVector3 pos, DAngle ang, int atw else act90 = aimed; } - double dal = ((aimed->spr.xrepeat * tileHeight(aimed->spr.picnum)) * REPEAT_SCALE * 0.5) + 8; + double dal = ((aimed->spr.ScaleX() * tileHeight(aimed->spr.picnum)) * 0.5) + 8; double dist = (ps[p].GetActor()->spr.pos.XY() - aimed->spr.pos.XY()).Length(); zvel = ((aimed->spr.pos.Z - pos.Z - dal) * vel) / dist; if (aimed->spr.picnum != RECON) @@ -775,7 +775,7 @@ static void shootwhip(DDukeActor* actor, int p, DVector3 pos, DAngle ang, int at if (aimed) { - double dal = ((aimed->spr.xrepeat * tileHeight(aimed->spr.picnum)) * REPEAT_SCALE * 0.5) -12; + double dal = ((aimed->spr.ScaleX() * tileHeight(aimed->spr.picnum)) * 0.5) -12; double dist = (ps[p].GetActor()->spr.pos.XY() - aimed->spr.pos.XY()).Length(); zvel = ((aimed->spr.pos.Z - pos.Z - dal) * vel) / dist; ang = (aimed->spr.pos.XY() - pos.XY()).Angle(); @@ -872,7 +872,7 @@ void shoot_r(DDukeActor* actor, int atwith) { p = -1; sang = actor->spr.angle; - spos = actor->spr.pos.plusZ(-(actor->spr.yrepeat * tileHeight(actor->spr.picnum) * REPEAT_SCALE * 0.5) - 3); + spos = actor->spr.pos.plusZ(-(actor->spr.ScaleY() * tileHeight(actor->spr.picnum) * 0.5) - 3); if (badguy(actor)) { diff --git a/source/games/exhumed/src/view.cpp b/source/games/exhumed/src/view.cpp index 837322438..649e88489 100644 --- a/source/games/exhumed/src/view.cpp +++ b/source/games/exhumed/src/view.cpp @@ -105,7 +105,7 @@ static void analyzesprites(tspriteArray& tsprites, const DVector3& view, double if ((pTSprite->picnum == kTorch1 || pTSprite->picnum == kTorch2) && (pTSprite->cstat & CSTAT_SPRITE_YCENTER) == 0) { pTSprite->cstat |= CSTAT_SPRITE_YCENTER; - double nTileY = (tileHeight(pTSprite->picnum) * pTSprite->yrepeat) * REPEAT_SCALE * 0.5; + double nTileY = (tileHeight(pTSprite->picnum) * pTSprite->ScaleY()) * 0.5; pTSprite->pos.Z -= nTileY; } diff --git a/source/games/sw/src/game.h b/source/games/sw/src/game.h index c16bca224..cdc62669f 100644 --- a/source/games/sw/src/game.h +++ b/source/games/sw/src/game.h @@ -204,7 +204,7 @@ int StdRandomRange(int range); inline double GetSpriteSizeZ(const spritetypebase* sp) { - return (tileHeight(sp->picnum) * sp->yrepeat) * REPEAT_SCALE; + return (tileHeight(sp->picnum) * sp->ScaleY()); } @@ -1989,7 +1989,7 @@ inline DVector3 ActorVectOfMiddle(DSWActor* actor) inline double ActorSizeZ(DSWActor* actor) { - return (tileHeight(actor->spr.picnum) * actor->spr.yrepeat) * REPEAT_SCALE; + return (tileHeight(actor->spr.picnum) * actor->spr.ScaleY()); } inline double ActorUpperZ(DSWActor* actor)