/** * Is this tile a target for ships to get to a nearby dock? * @param tile Tile to query * @param diagdir Diagonal direction to compare against or INVALID_DIAGDIR * @return True if is a target for ships to get to this tile */ 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; }