Loading

Paste #puwrfr4h7

  1. function Road::_IsSlopedRoad(start, middle, end)
  2. {
  3.     local NW = 0; //Set to true if we want to build a road to / from the north-west
  4.     local NE = 0; //Set to true if we want to build a road to / from the north-east
  5.     local SW = 0; //Set to true if we want to build a road to / from the south-west
  6.     local SE = 0; //Set to true if we want to build a road to / from the south-east
  7.  
  8.     if (middle - AIMap.GetMapSizeX() == start || middle - AIMap.GetMapSizeX() == end) NW = 1;
  9.     if (middle - 1 == start || middle - 1 == end) NE = 1;
  10.     if (middle + AIMap.GetMapSizeX() == start || middle + AIMap.GetMapSizeX() == end) SE = 1;
  11.     if (middle + 1 == start || middle + 1 == end) SW = 1;
  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. }

Comments