diff --git a/libs/s25main/GameInterface.h b/libs/s25main/GameInterface.h index 4e1aad0dc..aad106750 100644 --- a/libs/s25main/GameInterface.h +++ b/libs/s25main/GameInterface.h @@ -38,4 +38,5 @@ class GameInterface virtual void GI_BuildRoad() = 0; virtual Cheats& GI_GetCheats() = 0; + const Cheats& GI_GetCheats() const { return const_cast(*this).GI_GetCheats(); } }; diff --git a/libs/s25main/world/GameWorldBase.h b/libs/s25main/world/GameWorldBase.h index 8c56ea297..4d242e692 100644 --- a/libs/s25main/world/GameWorldBase.h +++ b/libs/s25main/world/GameWorldBase.h @@ -79,7 +79,8 @@ class GameWorldBase : public World // Remaining initialization after loading (BQ...) void InitAfterLoad(); - GameInterface* GetGameInterface() const { return gi; } + GameInterface* GetGameInterface() { return gi; } + const GameInterface* GetGameInterface() const { return gi; } void SetGameInterface(GameInterface* const gi) { this->gi = gi; } /// Get the economy mode handler if set. diff --git a/libs/s25main/world/GameWorldViewer.cpp b/libs/s25main/world/GameWorldViewer.cpp index 5765c6e6d..c2360b6ad 100644 --- a/libs/s25main/world/GameWorldViewer.cpp +++ b/libs/s25main/world/GameWorldViewer.cpp @@ -115,7 +115,7 @@ BuildingQuality GameWorldViewer::GetBQ(const MapPoint& pt) const Visibility GameWorldViewer::GetVisibility(const MapPoint pt) const { - auto* const gi = GetWorld().GetGameInterface(); + const auto* const gi = GetWorld().GetGameInterface(); if(gi && gi->GI_GetCheats().isAllVisible()) return Visibility::Visible; diff --git a/tests/s25Main/integration/testCheats.cpp b/tests/s25Main/integration/testCheats.cpp index 9b9a25d51..bbcf968fd 100644 --- a/tests/s25Main/integration/testCheats.cpp +++ b/tests/s25Main/integration/testCheats.cpp @@ -58,7 +58,9 @@ MOCK_BASE_CLASS(MockGameInterface, GameInterface) MOCK_METHOD(GI_StartRoadBuilding, 2) MOCK_METHOD(GI_CancelRoadBuilding, 0) MOCK_METHOD(GI_BuildRoad, 0) - MOCK_METHOD(GI_GetCheats, 0) + // clang-format off + MOCK_METHOD(GI_GetCheats, 0, Cheats&(void)) + // clang-format on // LCOV_EXCL_STOP }; } // namespace