static bool IsPossibleLockLocation(TileIndex tile)
{
DiagDirection dir = GetInclinedSlopeDirection(GetTileSlope(tile));
if (dir == INVALID_DIAGDIR) return false;
TileIndexDiff delta_mid = TileOffsByDiagDir(dir);
if (!IsTileFlat(tile + delta_mid)) return false;
if (!IsTileFlat(tile - delta_mid)) return false;
return true;
}
/**
* Check whether a river could (logically) flow into a lock.
* @param tile the middle tile of a lock.
* @param recursive whether the function is being called recursively.
* @return true iff the water can be flowing into a lock.
*/
static bool IsPossibleLockLocationRecursively(TileIndex tile, bool recursive = false)
{
if (!IsPossibleLockLocation(tile)) return false;
DiagDirection dir = GetInclinedSlopeDirection(GetTileSlope(tile));
TileIndexDiff delta_mid = TileOffsByDiagDir(dir);
etc.…;
}