From 212be963d909621d15ebab53f26350d728a21e23 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 3 Sep 2022 20:40:57 +0200 Subject: [PATCH] - floatified SO scale_dist et.al. --- source/games/sw/src/game.h | 13 +++++++------ source/games/sw/src/morph.cpp | 36 +++++++++++++++++------------------ source/games/sw/src/save.cpp | 6 +++--- source/games/sw/src/track.cpp | 24 +++++++++++------------ 4 files changed, 40 insertions(+), 39 deletions(-) diff --git a/source/games/sw/src/game.h b/source/games/sw/src/game.h index 6eaf953e7..867fc8d30 100644 --- a/source/games/sw/src/game.h +++ b/source/games/sw/src/game.h @@ -1524,14 +1524,15 @@ struct SECTOR_OBJECT scale_active_type, // activated by a switch or trigger // values for whole SO - _scale_dist, // distance from center - scale_speed, // speed of scaling - _scale_dist_min, // absolute min - _scale_dist_max, // absolute max - scale_rand_freq, // freqency of direction change - based on rand(1024) + scale_rand_freq; // freqency of direction change - based on rand(1024) + + double scale_dist, // distance from center + scale_dist_min, // absolute min + scale_dist_max, // absolute max + scale_speed; // speed of scaling // values for single point scaling - scale_point_dist[MAX_SO_POINTS], // distance from center + int16_t scale_point_dist[MAX_SO_POINTS], // distance from center scale_point_speed[MAX_SO_POINTS], // speed of scaling scale_point_base_speed, // base speed of scaling scale_point_dist_min, // absolute min diff --git a/source/games/sw/src/morph.cpp b/source/games/sw/src/morph.cpp index e8c3299aa..8a7599496 100644 --- a/source/games/sw/src/morph.cpp +++ b/source/games/sw/src/morph.cpp @@ -72,13 +72,13 @@ short DoSectorObjectSetScale(short match) sop->scale_type = sop->scale_active_type; - if (sop->_scale_dist == sop->_scale_dist_max) + if (sop->scale_dist == sop->scale_dist_max) { // make it negative if (sop->scale_speed > 0) sop->scale_speed = -sop->scale_speed; } - else if (sop->_scale_dist == sop->_scale_dist_min) + else if (sop->scale_dist == sop->scale_dist_min) { // make it positive if (sop->scale_speed < 0) @@ -196,16 +196,16 @@ void ScaleSectorObject(SECTOR_OBJECT* sop) // to dest case SO_SCALE_DEST: - sop->_scale_dist += sop->scale_speed; + sop->scale_dist += sop->scale_speed; - if (sop->_scale_dist > sop->_scale_dist_max) + if (sop->scale_dist > sop->scale_dist_max) { - sop->_scale_dist = sop->_scale_dist_max; + sop->scale_dist = sop->scale_dist_max; sop->scale_type = SO_SCALE_HOLD; } - else if (sop->_scale_dist < sop->_scale_dist_min) + else if (sop->scale_dist < sop->scale_dist_min) { - sop->_scale_dist = sop->_scale_dist_min; + sop->scale_dist = sop->scale_dist_min; sop->scale_type = SO_SCALE_HOLD; } @@ -214,16 +214,16 @@ void ScaleSectorObject(SECTOR_OBJECT* sop) // random direction change case SO_SCALE_RANDOM: - sop->_scale_dist += sop->scale_speed; - if (sop->_scale_dist > sop->_scale_dist_max) + sop->scale_dist += sop->scale_speed; + if (sop->scale_dist > sop->scale_dist_max) { sop->scale_speed *= -1; - sop->_scale_dist = sop->_scale_dist_max; + sop->scale_dist = sop->scale_dist_max; } - else if (sop->_scale_dist < sop->_scale_dist_min) + else if (sop->scale_dist < sop->scale_dist_min) { sop->scale_speed *= -1; - sop->_scale_dist = sop->_scale_dist_min; + sop->scale_dist = sop->scale_dist_min; } if (RANDOM_P2(1024) < sop->scale_rand_freq<<3) @@ -235,17 +235,17 @@ void ScaleSectorObject(SECTOR_OBJECT* sop) // cycle through max and min case SO_SCALE_CYCLE: - sop->_scale_dist += sop->scale_speed; + sop->scale_dist += sop->scale_speed; - if (sop->_scale_dist > sop->_scale_dist_max) + if (sop->scale_dist > sop->scale_dist_max) { sop->scale_speed *= -1; - sop->_scale_dist = sop->_scale_dist_max; + sop->scale_dist = sop->scale_dist_max; } - else if (sop->_scale_dist < sop->_scale_dist_min) + else if (sop->scale_dist < sop->scale_dist_min) { sop->scale_speed *= -1; - sop->_scale_dist = sop->_scale_dist_min; + sop->scale_dist = sop->scale_dist_min; } break; } @@ -313,7 +313,7 @@ void MorphTornado(SECTOR_OBJECT* sop) DVector2 mpos = pos + sop->morph_ang.ToVector() * sop->morph_speed; // bound check radius - if ((sop->pmid - mpos).Length() > sop->morph_dist_max + sop->_scale_dist * zinttoworld) + if ((sop->pmid - mpos).Length() > sop->morph_dist_max + sop->scale_dist) { // find and reverse angle sop->morph_ang = VecToAngle(mpos - sop->pmid) + DAngle180; diff --git a/source/games/sw/src/save.cpp b/source/games/sw/src/save.cpp index ae2e1a146..1ca9fb3c1 100644 --- a/source/games/sw/src/save.cpp +++ b/source/games/sw/src/save.cpp @@ -679,10 +679,10 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, SECTOR_OBJECT& w, ("match_event_sprite", w.match_event_actor, def->match_event_actor) ("scale_type", w.scale_type, def->scale_type) ("scale_active_type", w.scale_active_type, def->scale_active_type) - ("scale_dist", w._scale_dist, def->_scale_dist) + ("scale_dist", w.scale_dist, def->scale_dist) ("scale_speed", w.scale_speed, def->scale_speed) - ("scale_dist_min", w._scale_dist_min, def->_scale_dist_min) - ("scale_dist_max", w._scale_dist_max, def->_scale_dist_max) + ("scale_dist_min", w.scale_dist_min, def->scale_dist_min) + ("scale_dist_max", w.scale_dist_max, def->scale_dist_max) ("scale_rand_freq", w.scale_rand_freq, def->scale_rand_freq) .Array("clipbox_dist", w.clipbox_dist, def->clipbox_dist, w.clipbox_num) .Array("clipbox_xoff", w.clipbox_xoff, def->clipbox_xoff, w.clipbox_num) diff --git a/source/games/sw/src/track.cpp b/source/games/sw/src/track.cpp index 09878c07d..dfbdd02dd 100644 --- a/source/games/sw/src/track.cpp +++ b/source/games/sw/src/track.cpp @@ -959,10 +959,10 @@ void SetupSectorObject(sectortype* sectp, short tag) sop->max_damage = -9999; sop->scale_type = SO_SCALE_NONE; - sop->_scale_dist = 0; - sop->scale_speed = 20; - sop->_scale_dist_min = -1024; - sop->_scale_dist_max = 1024; + sop->scale_dist = 0; + sop->scale_speed = 1.25; + sop->scale_dist_min = -64; + sop->scale_dist_max = 64; sop->scale_rand_freq = 64>>3; sop->scale_x_mult = 256; @@ -1034,9 +1034,9 @@ void SetupSectorObject(sectortype* sectp, short tag) case SO_SCALE_INFO: sop->flags |= (SOBJ_DYNAMIC); - sop->scale_speed = SP_TAG2(actor); - sop->_scale_dist_min = -SP_TAG5(actor); - sop->_scale_dist_max = SP_TAG6(actor); + sop->scale_speed = SP_TAG2(actor) * maptoworld; + sop->scale_dist_min = -SP_TAG5(actor) * maptoworld; + sop->scale_dist_max = SP_TAG6(actor) * maptoworld; sop->scale_type = SP_TAG4(actor); sop->scale_active_type = SP_TAG7(actor); @@ -1047,9 +1047,9 @@ void SetupSectorObject(sectortype* sectp, short tag) sop->scale_rand_freq = 64>>3; if (SP_TAG3(actor) == 0) - sop->_scale_dist = sop->_scale_dist_min; + sop->scale_dist = sop->scale_dist_min; else if (SP_TAG3(actor) == 1) - sop->_scale_dist = sop->_scale_dist_max; + sop->scale_dist = sop->scale_dist_max; KillActor(actor); break; @@ -1087,7 +1087,7 @@ void SetupSectorObject(sectortype* sectp, short tag) sop->morph_z_speed = 6; sop->morph_dist_max = 64; sop->morph_rand_freq = 8; - sop->_scale_dist_min = -768; + sop->scale_dist_min = -48; KillActor(actor); break; case SO_FLOOR_MORPH: @@ -1799,8 +1799,8 @@ void RefreshPoints(SECTOR_OBJECT* sop, int nx, int ny, bool dynamic) } else { - int xmul = (sop->_scale_dist * sop->scale_x_mult)>>8; - int ymul = (sop->_scale_dist * sop->scale_y_mult)>>8; + int xmul = int(sop->scale_dist * sop->scale_x_mult)>>4; + int ymul = int(sop->scale_dist * sop->scale_y_mult)>>4; dx = x + MulScale(xmul, bcos(ang), 14); dy = y + MulScale(ymul, bsin(ang), 14);