From 4d04a4dd3ad068f6fcff59ad5dc2fddbadc9140d Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Mon, 29 Aug 2022 23:05:10 +1000 Subject: [PATCH] - Floatified automap's `gZoom`. * Also use the global directly in automap functions instead of passing it around as function variables. --- source/core/automap.cpp | 30 ++++++++++++++--------------- source/core/gamestruct.h | 2 +- source/games/blood/src/blood.h | 2 +- source/games/blood/src/view.cpp | 2 +- source/games/duke/src/duke3d.h | 2 +- source/games/duke/src/game_misc.cpp | 2 +- source/games/exhumed/src/exhumed.h | 2 +- source/games/exhumed/src/map.cpp | 2 +- source/games/sw/src/draw.cpp | 2 +- source/games/sw/src/game.h | 2 +- 10 files changed, 24 insertions(+), 24 deletions(-) diff --git a/source/core/automap.cpp b/source/core/automap.cpp index 6a83ee83a..ce18eacf4 100644 --- a/source/core/automap.cpp +++ b/source/core/automap.cpp @@ -59,7 +59,7 @@ int automapMode; static float am_zoomdir; int follow_x = INT_MAX, follow_y = INT_MAX; DAngle follow_a = DAngle::fromDeg(INT_MAX); -static int gZoom = 768; +static double gZoom = 768; bool automapping; bool gFullMap; BitArray show2dsector; @@ -186,9 +186,9 @@ static void CalcMapBounds() void AutomapControl() { - static int nonsharedtimer; - int ms = (int)screen->FrameTime; - int interval; + static double nonsharedtimer; + double ms = screen->FrameTime; + double interval; int panvert = 0, panhorz = 0; if (nonsharedtimer > 0 || ms < nonsharedtimer) @@ -209,22 +209,22 @@ void AutomapControl() const int keymove = 4; if (am_zoomdir > 0) { - gZoom = xs_CRoundToInt(gZoom * am_zoomdir); + gZoom = gZoom * am_zoomdir; } else if (am_zoomdir < 0) { - gZoom = xs_CRoundToInt(gZoom / -am_zoomdir); + gZoom = gZoom / -am_zoomdir; } am_zoomdir = 0; double j = interval * 35. / gZoom; if (buttonMap.ButtonDown(gamefunc_Enlarge_Screen)) - gZoom += (int)MulScaleF(j, max(gZoom, 256), 6); + gZoom += MulScaleF(j, max(gZoom, 256.), 6); if (buttonMap.ButtonDown(gamefunc_Shrink_Screen)) - gZoom -= (int)MulScaleF(j, max(gZoom, 256), 6); + gZoom -= MulScaleF(j, max(gZoom, 256.), 6); - gZoom = clamp(gZoom, 48, 2048); + gZoom = clamp(gZoom, 48., 2048.); if (!am_followplayer) { @@ -410,7 +410,7 @@ bool ShowRedLine(int j, int i) // //--------------------------------------------------------------------------- -static void drawredlines(int cposx, int cposy, int czoom, const DAngle cang) +static void drawredlines(int cposx, int cposy, const double czoom, const DAngle cang) { int xvect = -cang.Sin() * 16384. * czoom; int yvect = -cang.Cos() * 16384. * czoom; @@ -458,7 +458,7 @@ static void drawredlines(int cposx, int cposy, int czoom, const DAngle cang) // //--------------------------------------------------------------------------- -static void drawwhitelines(int cposx, int cposy, int czoom, const DAngle cang) +static void drawwhitelines(int cposx, int cposy, const double czoom, const DAngle cang) { int xvect = -cang.Sin() * 16384. * czoom; int yvect = -cang.Cos() * 16384. * czoom; @@ -500,7 +500,7 @@ static void drawwhitelines(int cposx, int cposy, int czoom, const DAngle cang) // //--------------------------------------------------------------------------- -static void DrawPlayerArrow(int cposx, int cposy, const DAngle cang, int pl_x, int pl_y, int zoom, const DAngle pl_angle) +static void DrawPlayerArrow(int cposx, int cposy, const DAngle cang, int pl_x, int pl_y, const double czoom, const DAngle pl_angle) { int arrow[] = { @@ -509,8 +509,8 @@ static void DrawPlayerArrow(int cposx, int cposy, const DAngle cang, int pl_x, i 0, 65536, 32768, 32878, }; - int xvect = -cang.Sin() * 16384. * zoom; - int yvect = -cang.Cos() * 16384. * zoom; + int xvect = -cang.Sin() * 16384. * czoom; + int yvect = -cang.Cos() * 16384. * czoom; int pxvect = -pl_angle.Sin() * 16384.; int pyvect = -pl_angle.Cos() * 16384.; @@ -547,7 +547,7 @@ static void DrawPlayerArrow(int cposx, int cposy, const DAngle cang, int pl_x, i // //--------------------------------------------------------------------------- -static void renderDrawMapView(int cposx, int cposy, int czoom, const DAngle cang) +static void renderDrawMapView(int cposx, int cposy, const double czoom, const DAngle cang) { int xvect = -cang.Sin() * 16384. * czoom; int yvect = -cang.Cos() * 16384. * czoom; diff --git a/source/core/gamestruct.h b/source/core/gamestruct.h index c7c3e02e3..b1f828d70 100644 --- a/source/core/gamestruct.h +++ b/source/core/gamestruct.h @@ -107,7 +107,7 @@ struct GameInterface virtual void NextLevel(MapRecord* map, int skill) {} virtual void NewGame(MapRecord* map, int skill, bool special = false) {} virtual void LevelCompleted(MapRecord* map, int skill) {} - virtual bool DrawAutomapPlayer(int mx, int my, int x, int y, int z, const DAngle a, double const smoothratio) { return false; } + virtual bool DrawAutomapPlayer(int mx, int my, int x, int y, const double z, const DAngle a, double const smoothratio) { return false; } virtual void SetTileProps(int tile, int surf, int vox, int shade) {} virtual fixed_t playerHorizMin() { return IntToFixed(-200); } virtual fixed_t playerHorizMax() { return IntToFixed(200); } diff --git a/source/games/blood/src/blood.h b/source/games/blood/src/blood.h index f3ba77b3e..2dbef79e7 100644 --- a/source/games/blood/src/blood.h +++ b/source/games/blood/src/blood.h @@ -133,7 +133,7 @@ struct GameInterface : public ::GameInterface void NewGame(MapRecord* sng, int skill, bool) override; void NextLevel(MapRecord* map, int skill) override; void LevelCompleted(MapRecord* map, int skill) override; - bool DrawAutomapPlayer(int mx, int my, int x, int y, int z, const DAngle a, double const smoothratio) override; + bool DrawAutomapPlayer(int mx, int my, int x, int y, const double z, const DAngle a, double const smoothratio) override; void SetTileProps(int til, int surf, int vox, int shade) override; fixed_t playerHorizMin() override { return IntToFixed(-180); } fixed_t playerHorizMax() override { return IntToFixed(120); } diff --git a/source/games/blood/src/view.cpp b/source/games/blood/src/view.cpp index 09196b38a..36613b9ae 100644 --- a/source/games/blood/src/view.cpp +++ b/source/games/blood/src/view.cpp @@ -860,7 +860,7 @@ std::pair GameInterface::GetCoordinates() // //--------------------------------------------------------------------------- -bool GameInterface::DrawAutomapPlayer(int mx, int my, int x, int y, int z, const DAngle a, double const smoothratio) +bool GameInterface::DrawAutomapPlayer(int mx, int my, int x, int y, const double z, const DAngle a, double const smoothratio) { for (int i = connecthead; i >= 0; i = connectpoint2[i]) { diff --git a/source/games/duke/src/duke3d.h b/source/games/duke/src/duke3d.h index bc9088bed..9da798feb 100644 --- a/source/games/duke/src/duke3d.h +++ b/source/games/duke/src/duke3d.h @@ -50,7 +50,7 @@ struct GameInterface : public ::GameInterface void NextLevel(MapRecord* map, int skill) override; void NewGame(MapRecord* map, int skill, bool) override; void LevelCompleted(MapRecord* map, int skill) override; - bool DrawAutomapPlayer(int mx, int my, int x, int y, int z, const DAngle a, double const smoothratio) override; + bool DrawAutomapPlayer(int mx, int my, int x, int y, const double z, const DAngle a, double const smoothratio) override; int playerKeyMove() override { return 40; } void WarpToCoords(int x, int y, int z, int a, int h) override; void ToggleThirdPerson() override; diff --git a/source/games/duke/src/game_misc.cpp b/source/games/duke/src/game_misc.cpp index f5424f665..f04d72405 100644 --- a/source/games/duke/src/game_misc.cpp +++ b/source/games/duke/src/game_misc.cpp @@ -385,7 +385,7 @@ ReservedSpace GameInterface::GetReservedScreenSpace(int viewsize) // //--------------------------------------------------------------------------- -bool GameInterface::DrawAutomapPlayer(int mx, int my, int cposx, int cposy, int czoom, const DAngle cang, double const smoothratio) +bool GameInterface::DrawAutomapPlayer(int mx, int my, int cposx, int cposy, const double czoom, const DAngle cang, double const smoothratio) { int i, j, k, l, x1, y1, x2, y2, x3, y3, x4, y4, ox, oy, xoff, yoff; int dax, day, cosang, sinang, xspan, yspan, sprx, spry; diff --git a/source/games/exhumed/src/exhumed.h b/source/games/exhumed/src/exhumed.h index c2800ac03..ce53e51cb 100644 --- a/source/games/exhumed/src/exhumed.h +++ b/source/games/exhumed/src/exhumed.h @@ -230,7 +230,7 @@ struct GameInterface : public ::GameInterface void NewGame(MapRecord *map, int skill, bool) override; void LevelCompleted(MapRecord *map, int skill) override; void NextLevel(MapRecord *map, int skill) override; - bool DrawAutomapPlayer(int mx, int my, int x, int y, int z, const DAngle a, double const smoothratio) override; + bool DrawAutomapPlayer(int mx, int my, int x, int y, const double z, const DAngle a, double const smoothratio) override; fixed_t playerHorizMin() override { return IntToFixed(-150); } fixed_t playerHorizMax() override { return IntToFixed(150); } int playerKeyMove() override { return 6; } diff --git a/source/games/exhumed/src/map.cpp b/source/games/exhumed/src/map.cpp index bfccac284..1c2286008 100644 --- a/source/games/exhumed/src/map.cpp +++ b/source/games/exhumed/src/map.cpp @@ -69,7 +69,7 @@ void GetActorExtents(DExhumedActor* actor, int* top, int* bottom) } } -bool GameInterface::DrawAutomapPlayer(int mx, int my, int x, int y, int z, const DAngle a, double const smoothratio) +bool GameInterface::DrawAutomapPlayer(int mx, int my, int x, int y, const double z, const DAngle a, double const smoothratio) { for (int i = connecthead; i >= 0; i = connectpoint2[i]) { diff --git a/source/games/sw/src/draw.cpp b/source/games/sw/src/draw.cpp index 7835a5f76..a3631958e 100644 --- a/source/games/sw/src/draw.cpp +++ b/source/games/sw/src/draw.cpp @@ -1567,7 +1567,7 @@ bool GameInterface::GenerateSavePic() -bool GameInterface::DrawAutomapPlayer(int mx, int my, int cposx, int cposy, int czoom, const DAngle cang, double const smoothratio) +bool GameInterface::DrawAutomapPlayer(int mx, int my, int cposx, int cposy, const double czoom, const DAngle cang, double const smoothratio) { int k, l, x1, y1, x2, y2, x3, y3, x4, y4, ox, oy, xoff, yoff; int dax, day, cosang, sinang, xspan, yspan, sprx, spry; diff --git a/source/games/sw/src/game.h b/source/games/sw/src/game.h index 96901c45b..1040d37ee 100644 --- a/source/games/sw/src/game.h +++ b/source/games/sw/src/game.h @@ -2038,7 +2038,7 @@ struct GameInterface : public ::GameInterface void LevelCompleted(MapRecord *map, int skill) override; void NextLevel(MapRecord *map, int skill) override; void NewGame(MapRecord *map, int skill, bool) override; - bool DrawAutomapPlayer(int mx, int my, int x, int y, int z, const DAngle a, double const smoothratio) override; + bool DrawAutomapPlayer(int mx, int my, int x, int y, const double z, const DAngle a, double const smoothratio) override; int playerKeyMove() override { return 35; } void WarpToCoords(int x, int y, int z, int a, int h) override; void ToggleThirdPerson() override;