From 0f3c74af339d9b055e9e4567b7eb1d568f66539a Mon Sep 17 00:00:00 2001 From: Eric Robinson <68359262+kphoenix137@users.noreply.github.com> Date: Wed, 13 Sep 2023 13:33:59 -0400 Subject: [PATCH] Avoid rounding issues in automap and allow an extra zoom out step --- Source/automap.cpp | 6 +++--- test/automap_test.cpp | 38 +++++++++++++++++++------------------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/Source/automap.cpp b/Source/automap.cpp index e210f759ec0..0406a93ba7d 100644 --- a/Source/automap.cpp +++ b/Source/automap.cpp @@ -885,15 +885,15 @@ void AutomapZoomIn() if (AutoMapScale >= 200) return; - AutoMapScale += 5; + AutoMapScale += 25; } void AutomapZoomOut() { - if (AutoMapScale <= 50) + if (AutoMapScale <= 25) return; - AutoMapScale -= 5; + AutoMapScale -= 25; } void DrawAutomap(const Surface &out) diff --git a/test/automap_test.cpp b/test/automap_test.cpp index 2a8c7b2a06b..8218de20ecf 100644 --- a/test/automap_test.cpp +++ b/test/automap_test.cpp @@ -64,17 +64,17 @@ TEST(Automap, AutomapZoomIn) { AutoMapScale = 50; AutomapZoomIn(); - EXPECT_EQ(AutoMapScale, 55); - EXPECT_EQ(AmLine(64), 35); - EXPECT_EQ(AmLine(32), 17); - EXPECT_EQ(AmLine(16), 8); - EXPECT_EQ(AmLine(8), 4); - EXPECT_EQ(AmLine(4), 2); + EXPECT_EQ(AutoMapScale, 75); + EXPECT_EQ(AmLine(64), 48); + EXPECT_EQ(AmLine(32), 24); + EXPECT_EQ(AmLine(16), 12); + EXPECT_EQ(AmLine(8), 6); + EXPECT_EQ(AmLine(4), 3); } TEST(Automap, AutomapZoomIn_Max) { - AutoMapScale = 195; + AutoMapScale = 175; AutomapZoomIn(); AutomapZoomIn(); EXPECT_EQ(AutoMapScale, 200); @@ -89,25 +89,25 @@ TEST(Automap, AutomapZoomOut) { AutoMapScale = 200; AutomapZoomOut(); - EXPECT_EQ(AutoMapScale, 195); - EXPECT_EQ(AmLine(64), 124); - EXPECT_EQ(AmLine(32), 62); - EXPECT_EQ(AmLine(16), 31); - EXPECT_EQ(AmLine(8), 15); + EXPECT_EQ(AutoMapScale, 175); + EXPECT_EQ(AmLine(64), 112); + EXPECT_EQ(AmLine(32), 56); + EXPECT_EQ(AmLine(16), 28); + EXPECT_EQ(AmLine(8), 14); EXPECT_EQ(AmLine(4), 7); } TEST(Automap, AutomapZoomOut_Min) { - AutoMapScale = 55; + AutoMapScale = 50; AutomapZoomOut(); AutomapZoomOut(); - EXPECT_EQ(AutoMapScale, 50); - EXPECT_EQ(AmLine(64), 32); - EXPECT_EQ(AmLine(32), 16); - EXPECT_EQ(AmLine(16), 8); - EXPECT_EQ(AmLine(8), 4); - EXPECT_EQ(AmLine(4), 2); + EXPECT_EQ(AutoMapScale, 25); + EXPECT_EQ(AmLine(64), 16); + EXPECT_EQ(AmLine(32), 8); + EXPECT_EQ(AmLine(16), 4); + EXPECT_EQ(AmLine(8), 2); + EXPECT_EQ(AmLine(4), 1); } TEST(Automap, AutomapZoomReset)