Skip to content

Commit

Permalink
Avoid rounding issues in automap and allow an extra zoom out step
Browse files Browse the repository at this point in the history
  • Loading branch information
kphoenix137 authored Sep 13, 2023
1 parent e049bbb commit 0f3c74a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 22 deletions.
6 changes: 3 additions & 3 deletions Source/automap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
38 changes: 19 additions & 19 deletions test/automap_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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)
Expand Down

0 comments on commit 0f3c74a

Please sign in to comment.