MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / IsMapSurroundedByWater

Function IsMapSurroundedByWater

src/landscape.cpp:647–671  ·  view source on GitHub ↗

* Check if all tiles on the map edge should be considered water borders. * @return true If the edge of the map is flat and height 0, allowing for infinite water borders. */

Source from the content-addressed store, hash-verified

645 * @return true If the edge of the map is flat and height 0, allowing for infinite water borders.
646 */
647bool IsMapSurroundedByWater()
648{
649 auto check_tile = [](uint x, uint y) -> bool {
650 auto [slope, h] = GetTilePixelSlopeOutsideMap(x, y);
651 return ((slope == SLOPE_FLAT) && (h == 0));
652 };
653
654 /* Check the map corners. */
655 if (!check_tile(0, 0)) return false;
656 if (!check_tile(0, Map::SizeY())) return false;
657 if (!check_tile(Map::SizeX(), 0)) return false;
658 if (!check_tile(Map::SizeX(), Map::SizeY())) return false;
659
660 /* Check the map edges.*/
661 for (uint x = 0; x <= Map::SizeX(); x++) {
662 if (!check_tile(x, 0)) return false;
663 if (!check_tile(x, Map::SizeY())) return false;
664 }
665 for (uint y = 1; y < Map::SizeY(); y++) {
666 if (!check_tile(0, y)) return false;
667 if (!check_tile(Map::SizeX(), y)) return false;
668 }
669
670 return true;
671}
672
673/**
674 * Clear a piece of landscape

Callers 1

LoadHeightmapFunction · 0.85

Calls 1

Tested by

no test coverage detected