TILE(TileIndex tile, Trackdir td) { this->tile = tile; this->td = td; this->tile_type = GetTileType(tile); this->rail_type = GetTileRailType(tile); }
/** * Tests if a vehicle can enter a tile. * * @param tile The tile of interest. * @param dir The direction in which the vehicle drives onto a tile. * @param type The transporttype of the vehicle. * @param subtype For TRANSPORT_ROAD the compatible RoadTypes of the vehicle. * @param railtypes For TRANSPORT_RAIL the compatible RailTypes of the vehicle. * @param owner The owner of the vehicle. * @return true iff the vehicle can enter the tile. */ static bool CanEnterTile(TileIndex tile, DiagDirection dir, TransportType type, uint subtype, RailTypes railtypes, Owner owner) { /* Check tunnel entries and bridge ramps */ if (IsTileType(tile, MP_TUNNELBRIDGE) && GetTunnelBridgeDirection(tile) != dir) return false; /* Test ownership */ if (!CanEnterTileOwnerCheck(owner, tile, dir)) return false; /* check correct rail type (mono, maglev, etc) */ if (type == TRANSPORT_RAIL) { RailType rail_type = GetTileRailType(tile); if (!HasBit(railtypes, rail_type)) return false; } /* Depots, standard roadstops and single tram bits can only be entered from one direction */ DiagDirection single_entry = GetTileSingleEntry(tile, type, subtype); if (single_entry != INVALID_DIAGDIR && single_entry != ReverseDiagDir(dir)) return false; return true; }