#### Paste #pkoecxumh

2. {
3.     local NW = middle - map_size_x;
4.     local NE = middle - 1;
5.     local SE = middle + map_size_x;
6.     local SW = middle + 1;
7.
8.     NW = NW == start || NW == end; //Set to true if we want to build a road to / from the north-west
9.     NE = NE == start || NE == end; //Set to true if we want to build a road to / from the north-east
10.     SE = SE == start || SE == end; //Set to true if we want to build a road to / from the south-west
11.     SW = SW == start || SW == end; //Set to true if we want to build a road to / from the south-east
12.
13.     /* If there is a turn in the current tile, it can't be sloped. */
14.     if ((NW || SE) && (NE || SW)) return false;
15.
16.     local slope = _AITile.GetSlope(middle);
17.     /* A road on a steep slope is always sloped. */
18.     if (_AITile.IsSteepSlope(slope)) return true;
19.
20.     /* If only one corner is raised, the road is sloped. */
21.     if (slope == _AITile.SLOPE_N || slope == _AITile.SLOPE_W) return true;
22.     if (slope == _AITile.SLOPE_S || slope == _AITile.SLOPE_E) return true;
23.
24.     if (NW && (slope == _AITile.SLOPE_NW || slope == _AITile.SLOPE_SE)) return true;
25.     if (NE && (slope == _AITile.SLOPE_NE || slope == _AITile.SLOPE_SW)) return true;
26.
27.     return false;
28. }
29.
31. {
32.     local NW = 0; //Set to true if we want to build a road to / from the north-west
33.     local NE = 0; //Set to true if we want to build a road to / from the north-east
34.     local SW = 0; //Set to true if we want to build a road to / from the south-west
35.     local SE = 0; //Set to true if we want to build a road to / from the south-east
36.
37.     if (middle - AIMap.GetMapSizeX() == start || middle - AIMap.GetMapSizeX() == end) NW = 1;
38.     if (middle - 1 == start || middle - 1 == end) NE = 1;
39.     if (middle + AIMap.GetMapSizeX() == start || middle + AIMap.GetMapSizeX() == end) SE = 1;
40.     if (middle + 1 == start || middle + 1 == end) SW = 1;
41.
42.     /* If there is a turn in the current tile, it can't be sloped. */
43.     if ((NW || SE) && (NE || SW)) return false;
44.
45.     local slope = AITile.GetSlope(middle);
46.     /* A road on a steep slope is always sloped. */
47.     if (AITile.IsSteepSlope(slope)) return true;
48.
49.     /* If only one corner is raised, the road is sloped. */
50.     if (slope == AITile.SLOPE_N || slope == AITile.SLOPE_W) return true;
51.     if (slope == AITile.SLOPE_S || slope == AITile.SLOPE_E) return true;
52.
53.     if (NW && (slope == AITile.SLOPE_NW || slope == AITile.SLOPE_SE)) return true;
54.     if (NE && (slope == AITile.SLOPE_NE || slope == AITile.SLOPE_SW)) return true;
55.
56.     return false;
57. }