From dd3346cbc5cbae2957d2c7069daeee5ebfc1f06b Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 7 Oct 2022 18:39:28 +0200 Subject: [PATCH] - mostly comparisons and code surrounding them --- source/games/duke/src/actors_d.cpp | 18 +++++++++--------- source/games/duke/src/actors_r.cpp | 14 +++++++------- source/games/duke/src/game_misc.cpp | 2 +- source/games/duke/src/gameexec.cpp | 2 +- source/games/duke/src/spawn.cpp | 2 +- source/games/exhumed/src/object.cpp | 2 +- source/games/sw/src/sprite.cpp | 2 +- source/games/sw/src/weapon.cpp | 12 ++++++------ 8 files changed, 27 insertions(+), 27 deletions(-) diff --git a/source/games/duke/src/actors_d.cpp b/source/games/duke/src/actors_d.cpp index 5130bf733..594fbe29f 100644 --- a/source/games/duke/src/actors_d.cpp +++ b/source/games/duke/src/actors_d.cpp @@ -1660,7 +1660,7 @@ static void weaponcommon_d(DDukeActor* proj) return; } } - else if (proj->spr.picnum == RPG && proj->sector()->lotag == 2 && proj->spr.xrepeat >= 10 && rnd(140)) + else if (proj->spr.picnum == RPG && proj->sector()->lotag == 2 && proj->spr.ScaleX() >= 0.15625 && rnd(140)) spawn(proj, WATERBUBBLE); } @@ -2390,8 +2390,8 @@ static void greenslime(DDukeActor *actor) if (actor->temp_data[0] == 1) { actor->spr.picnum = GREENSLIME; - if (actor->spr.yrepeat < 40) actor->spr.yrepeat += 8; - if (actor->spr.ScaleX() > 0.125 ) actor->spr.xrepeat -= 4; + if (actor->spr.ScaleY() < 0.625) actor->spr.AddScaleY(0.125); + if (actor->spr.ScaleX() > 0.125 ) actor->spr.AddScaleX(-0.0625); if (actor->vel.Z > -12) actor->vel.Z -= 348 / 256.; actor->spr.pos.Z += actor->vel.Z; @@ -2416,8 +2416,8 @@ static void greenslime(DDukeActor *actor) } else { - if (actor->spr.yrepeat < (40 - 4)) actor->spr.yrepeat += 8; - if (actor->spr.ScaleX() > 0.125 ) actor->spr.xrepeat -= 4; + if (actor->spr.ScaleY() < 0.5625) actor->spr.AddScaleY(0.125); + if (actor->spr.ScaleX() > 0.125 ) actor->spr.AddScaleX(-0.0625); } if (actor->spr.pos.Z > actor->floorz - 8) @@ -2512,7 +2512,7 @@ static void flamethrowerflame(DDukeActor *actor) fi.checkhitceiling(actor->sector()); } - if (actor->spr.xrepeat >= 10) + if (actor->spr.ScaleX() >= 0.15625) { int x = actor->spr.extra; fi.hitradius(actor, gs.rpgblastradius, x >> 2, x >> 1, x - (x >> 2), x); @@ -2753,7 +2753,7 @@ void moveactors_d(void) { auto sectp = act->sector(); - if (act->spr.xrepeat == 0 || sectp == nullptr) + if (act->spr.ScaleX() == 0 || sectp == nullptr) { deletesprite(act); continue; @@ -2935,7 +2935,7 @@ static void fireflyflyingeffect(DDukeActor *actor) return; } - if (Owner->spr.xrepeat >= 24 || Owner->spr.pal == 1) + if (Owner->spr.ScaleX() >= 0.375 || Owner->spr.pal == 1) actor->spr.cstat |= CSTAT_SPRITE_INVISIBLE; else actor->spr.cstat &= ~CSTAT_SPRITE_INVISIBLE; @@ -2966,7 +2966,7 @@ void moveexplosions_d(void) // STATNUM 5 DukeStatIterator it(STAT_MISC); while (auto act = it.Next()) { - if (!act->insector() || act->spr.xrepeat == 0) + if (!act->insector() || act->spr.ScaleX() == 0) { deletesprite(act); continue; diff --git a/source/games/duke/src/actors_r.cpp b/source/games/duke/src/actors_r.cpp index 1f8fe448d..a7dacc678 100644 --- a/source/games/duke/src/actors_r.cpp +++ b/source/games/duke/src/actors_r.cpp @@ -220,7 +220,7 @@ void hitradius_r(DDukeActor* actor, int r, int hp1, int hp2, int hp3, int h double radius = r * inttoworld; static const uint8_t statlist[] = { STAT_DEFAULT, STAT_ACTOR, STAT_STANDABLE, STAT_PLAYER, STAT_FALLER, STAT_ZOMBIEACTOR, STAT_MISC }; - if (actor->spr.xrepeat >= 11 || !(actor->spr.picnum == RPG || ((isRRRA()) && actor->spr.picnum == RPG2))) + if (actor->spr.ScaleX() >= 0.17675 || !(actor->spr.picnum == RPG || ((isRRRA()) && actor->spr.picnum == RPG2))) { BFSSectorSearch search(actor->sector()); @@ -910,7 +910,7 @@ void movestandables_r(void) static void chickenarrow(DDukeActor* actor) { actor->spr.hitag++; - if (actor->attackertype != BOSS2 && actor->spr.xrepeat >= 10 && actor->sector()->lotag != 2) + if (actor->attackertype != BOSS2 && actor->spr.ScaleX() >= 0.15625 && actor->sector()->lotag != 2) { auto spawned = spawn(actor, SMALLSMOKE); if (spawned) spawned->spr.pos.Z += 1; @@ -1180,7 +1180,7 @@ static void weaponcommon_r(DDukeActor *proj) switch (proj->spr.picnum) { case RPG: - if (proj->attackertype != BOSS2 && proj->spr.xrepeat >= 10 && proj->sector()->lotag != 2) + if (proj->attackertype != BOSS2 && proj->spr.ScaleX() >= 0.15625 && proj->sector()->lotag != 2) { auto spawned = spawn(proj, SMALLSMOKE); if (spawned) spawned->spr.pos.Z += 1; @@ -1200,7 +1200,7 @@ static void weaponcommon_r(DDukeActor *proj) } else makeitfall(proj); - if (proj->spr.xrepeat >= 10 && proj->sector()->lotag != 2) + if (proj->spr.ScaleX() >= 0.15625 && proj->sector()->lotag != 2) { auto spawned = spawn(proj, SMALLSMOKE); if (spawned) spawned->spr.pos.Z += 1; @@ -1296,7 +1296,7 @@ static void weaponcommon_r(DDukeActor *proj) deletesprite(proj); return; } - if ((proj->spr.picnum == RPG || (isRRRA() && proj->spr.picnum == RPG2)) && proj->sector()->lotag == 2 && proj->spr.xrepeat >= 10 && rnd(184)) + if ((proj->spr.picnum == RPG || (isRRRA() && proj->spr.picnum == RPG2)) && proj->sector()->lotag == 2 && proj->spr.ScaleX() >= 0.15625 && rnd(184)) spawn(proj, WATERBUBBLE); } @@ -2615,7 +2615,7 @@ void moveactors_r(void) { bool deleteafterexecute = false; // taking a cue here from RedNukem to not run scripts on deleted sprites. - if( act->spr.xrepeat == 0 || !act->insector()) + if( act->spr.ScaleX() == 0 || !act->insector()) { deletesprite(act); continue; @@ -2872,7 +2872,7 @@ void moveexplosions_r(void) // STATNUM 5 t = &act->temp_data[0]; auto sectp = act->sector(); - if (!act->insector() || act->spr.xrepeat == 0) + if (!act->insector() || act->spr.ScaleX() == 0) { deletesprite(act); continue; diff --git a/source/games/duke/src/game_misc.cpp b/source/games/duke/src/game_misc.cpp index af596595f..1439848a8 100644 --- a/source/games/duke/src/game_misc.cpp +++ b/source/games/duke/src/game_misc.cpp @@ -396,7 +396,7 @@ bool GameInterface::DrawAutomapPlayer(const DVector2& mxy, const DVector2& cpos, DukeSectIterator it(ii); while (auto act = it.Next()) { - if (act == ps[screenpeek].actor || (act->spr.cstat & CSTAT_SPRITE_INVISIBLE) || act->spr.cstat == CSTAT_SPRITE_BLOCK_ALL || act->spr.xrepeat == 0) continue; + if (act == ps[screenpeek].actor || (act->spr.cstat & CSTAT_SPRITE_INVISIBLE) || act->spr.cstat == CSTAT_SPRITE_BLOCK_ALL || act->spr.ScaleX() == 0) continue; if ((act->spr.cstat & CSTAT_SPRITE_BLOCK_ALL) != 0) { diff --git a/source/games/duke/src/gameexec.cpp b/source/games/duke/src/gameexec.cpp index 8622737c9..03476cc37 100644 --- a/source/games/duke/src/gameexec.cpp +++ b/source/games/duke/src/gameexec.cpp @@ -2791,7 +2791,7 @@ int ParseState::parse(void) } case concmd_pstomp: insptr++; - if( ps[g_p].knee_incs == 0 && ps[g_p].GetActor()->spr.xrepeat >= (isRR()? 9: 40) ) + if( ps[g_p].knee_incs == 0 && ps[g_p].GetActor()->spr.ScaleX() >= (isRR()? 0.140625 : 0.625) ) if (cansee(g_ac->spr.pos.plusZ(-4), g_ac->sector(), ps[g_p].pos.plusZ(16), ps[g_p].GetActor()->sector())) { ps[g_p].knee_incs = 1; diff --git a/source/games/duke/src/spawn.cpp b/source/games/duke/src/spawn.cpp index 54b185e19..d73bd6061 100644 --- a/source/games/duke/src/spawn.cpp +++ b/source/games/duke/src/spawn.cpp @@ -232,7 +232,7 @@ void spawninitdefault(DDukeActor* actj, DDukeActor *act) } // Init the size - if (act->spr.xrepeat == 0 || act->spr.yrepeat == 0) + if (act->spr.ScaleX() == 0 || act->spr.ScaleY() == 0) act->spr.SetScale(REPEAT_SCALE, REPEAT_SCALE); if (actorflag(act, SFLAG_BADGUY)) diff --git a/source/games/exhumed/src/object.cpp b/source/games/exhumed/src/object.cpp index bfefa6a9e..5481a6749 100644 --- a/source/games/exhumed/src/object.cpp +++ b/source/games/exhumed/src/object.cpp @@ -1465,7 +1465,7 @@ void AISpark::Tick(RunListEvent* ev) pActor->spr.shade += 3; pActor->spr.xrepeat -= 2; - if (pActor->spr.xrepeat >= 4 && pActor->spr.shade <= 100) + if (pActor->spr.ScaleX() >= 0.0625 && pActor->spr.shade <= 100) { pActor->spr.yrepeat -= 2; diff --git a/source/games/sw/src/sprite.cpp b/source/games/sw/src/sprite.cpp index d23c8b207..884655e60 100644 --- a/source/games/sw/src/sprite.cpp +++ b/source/games/sw/src/sprite.cpp @@ -2638,7 +2638,7 @@ void SpriteSetup(void) if (!actor->hasU()) SpawnUser(actor, ST1, nullptr); - if (actor->spr.xrepeat == 64 && actor->spr.yrepeat == 64) // clear default xrepeat. + if (actor->spr.ScaleX() == 1 && actor->spr.ScaleY() == 1) // clear default scale. actor->spr.SetScale(0, 0); change_actor_stat(actor, STAT_SPAWN_SPOT); diff --git a/source/games/sw/src/weapon.cpp b/source/games/sw/src/weapon.cpp index 3e91900f5..0ce7e252d 100644 --- a/source/games/sw/src/weapon.cpp +++ b/source/games/sw/src/weapon.cpp @@ -7813,7 +7813,7 @@ int DoPlasmaDone(DSWActor* actor) actor->spr.yrepeat -= 4; actor->user.Counter += 2; - if (actor->spr.yrepeat < 6) + if (actor->spr.ScaleY() < 0.09375) { KillActor(actor); return 0; @@ -18325,7 +18325,7 @@ int DoFloorBlood(DSWActor* actor) } // See if any players stepped in blood - if (actor->spr.xrepeat != 4 && actor->spr.ScaleY() > 0.0625) + if (actor->spr.ScaleX() > 0.0625 && actor->spr.ScaleY() > 0.0625) { TRAVERSE_CONNECT(pnum) { @@ -18342,11 +18342,11 @@ int DoFloorBlood(DSWActor* actor) } // If blood has already grown to max size, we can shrink it - if (actor->spr.xrepeat == 40 && actor->spr.ScaleY() > 0.15625) + if (actor->spr.ScaleX() == 0.625 && actor->spr.ScaleY() > 0.15625) { - actor->spr.yrepeat -= 10; - if (actor->spr.yrepeat <= 10) // Shrink it down and don't use it anymore - actor->spr.xrepeat = actor->spr.yrepeat = 4; + actor->spr.AddScaleY(-0.15625); + if (actor->spr.ScaleY() <= 0.15625) // Shrink it down and don't use it anymore + actor->spr.SetScale(0.0625, 0.0625); } } }