Add setting for map edge behaviour, and how to display area outside map

This commit is contained in:
Jonathan G Rennison
2023-12-22 17:32:44 +00:00
parent 540cec2af5
commit 378a545dd4
9 changed files with 99 additions and 7 deletions

View File

@@ -1462,6 +1462,15 @@ static void ViewportMapLandscapeModeChanged(int32 new_value)
MarkAllViewportMapLandscapesDirty();
}
static void MarkAllViewportsDirty(int32 new_value)
{
extern void MarkAllViewportMapLandscapesDirty();
MarkAllViewportMapLandscapesDirty();
extern void MarkWholeNonMapViewportsDirty();
MarkWholeNonMapViewportsDirty();
}
static void UpdateLinkgraphColours(int32 new_value)
{
BuildLinkStatsLegend();
@@ -1655,6 +1664,35 @@ static void UpdateFreeformEdges(int32 new_value)
MarkWholeScreenDirty();
}
bool CheckMapEdgesAreWater()
{
auto check_tile = [&](uint x, uint y) -> bool {
int h = 0;
Slope slope = GetTilePixelSlopeOutsideMap(x, y, &h);
return slope == SLOPE_FLAT && h == 0;
};
for (uint x = 0; x <= MapMaxX(); x++) {
if (!check_tile(x, 0) || !check_tile(x, MapMaxY())) return false;
}
for (uint y = 1; y < MapMaxY(); y++) {
if (!check_tile(0, y) || !check_tile(MapMaxX(), y)) return false;
}
return true;
}
static bool CheckMapEdgeMode(int32 &new_value)
{
if (_game_mode == GM_MENU || !_settings_game.construction.freeform_edges || new_value == 0) return true;
if (!CheckMapEdgesAreWater()) {
ShowErrorMessage(STR_CONFIG_SETTING_EDGES_NOT_WATER, INVALID_STRING_ID, WL_ERROR);
return false;
}
return true;
}
/**
* Changing the setting "allow multiple NewGRF sets" is not allowed
* if there are vehicles.