/** * Is this tile a target for ships to get to a nearby dock? * @param tile Tile to query * @param diagdir Optional diagonal direction to look for axis compatibility. * @return True if the tile is a target for ships to get to a nearby dock. * @note If the axis of the provided diagdir is paralel to the axis of a nearby * dock station, this function returns True. If diagdir is not provided, * only tile locations are compared. */ static inline bool IsTileDock(TileIndex tile, DiagDirection diagdir = INVALID_DIAGDIR) { Axis axis = diagdir == INVALID_DIAGDIR ? INVALID_AXIS : DiagDirToAxis(diagdir); for (DiagDirection rot = DIAGDIR_BEGIN; rot < DIAGDIR_END; rot++) { TileIndex tc = TileAddByDiagDir(tile, rot); if (IsTileType(tc, MP_STATION) && (IsDock(tc) || IsOilRig(tc))) { Station *dock = Station::GetByTile(tc); TileIndex docking_location = TILE_ADD(dock->dock_tile, ToTileIndexDiff(GetDockOffset(dock->dock_tile))); if (axis == INVALID_AXIS) { return tile == docking_location; } else { if (tile == docking_location) { Axis axis_tc = DiagDirToAxis(rot); return axis != axis_tc; } } } if (rot == DIAGDIR_NE && IsTileType(tc + TileDiffXY(-1, 0), MP_INDUSTRY) && GetIndustryGfx(tc + TileDiffXY(-1, 0)) == GFX_OILRIG_1) return true; } return false; }