Loading

Paste #pav92t6hl

  1. /**
  2.  * Is this tile a target for ships to get to a nearby dock?
  3.  * @param tile Tile to query
  4.  * @param diagdir Diagonal direction to compare against or INVALID_DIAGDIR
  5.  * @return True if is a target for ships to get to this tile
  6.  */
  7. static inline bool IsTileDock(TileIndex tile, DiagDirection diagdir = INVALID_DIAGDIR)
  8. {
  9.     Axis axis = diagdir == INVALID_DIAGDIR ? INVALID_AXIS : DiagDirToAxis(diagdir);
  10.  
  11.     for (DiagDirection rot = DIAGDIR_BEGIN; rot < DIAGDIR_END; rot++) {
  12.         TileIndex tc = TileAddByDiagDir(tile, rot);
  13.         if (IsTileType(tc, MP_STATION) && (IsDock(tc) || IsOilRig(tc))) {
  14.             Station *dock = Station::GetByTile(tc);
  15.             TileIndex docking_location = TILE_ADD(dock->dock_tile, ToTileIndexDiff(GetDockOffset(dock->dock_tile)));
  16.             if (axis == INVALID_AXIS) {
  17.                 return tile == docking_location;
  18.             }
  19.             else {
  20.                 if (tile == docking_location) {
  21.                     Axis axis_tc = DiagDirToAxis(rot);
  22.                     return axis != axis_tc;
  23.                 }
  24.             }
  25.         }
  26.         if (rot == DIAGDIR_NE && IsTileType(tc + TileDiffXY(-1, 0), MP_INDUSTRY) && GetIndustryGfx(tc + TileDiffXY(-1, 0)) == GFX_OILRIG_1) return true;
  27.     }
  28.  
  29.     return false;
  30. }

Version history

Revision # Author Created at
pammldfgx Anonymous 08 Sep 2016, 14:13:05 UTC Diff

Comments