/** * If required, connects a new structure to an existing road or tram by building the missing roadbit. * @param tile Tile containing the structure to connect. * @param direction Direction to check. */ void ConnectRoadToStructure(TileIndex tile, DiagDirection direction) { tile += TileOffsByDiagDir(direction); /* if there is a roadpiece just outside of the station entrance, build a connecting route */ if (IsNormalRoadTile(tile)) { if (GetRoadBits(tile, _cur_roadtype) != ROAD_NONE) { DoCommandP(tile, _cur_roadtype << 4 | DiagDirToRoadBits(ReverseDiagDir(direction)), 0, CMD_BUILD_ROAD); } } }
/** Tests if a tile is a road tile with a single tramtrack (tram can reverse) */ static DiagDirection GetSingleTramBit(TileIndex tile) { if (IsNormalRoadTile(tile)) { RoadBits rb = GetRoadBits(tile, ROADTYPE_TRAM); switch (rb) { case ROAD_NW: return DIAGDIR_NW; case ROAD_SW: return DIAGDIR_SW; case ROAD_SE: return DIAGDIR_SE; case ROAD_NE: return DIAGDIR_NE; default: break; } } return INVALID_DIAGDIR; }
/** Tests if a tile is a road tile with a single tramtrack (tram can reverse) */ FORCEINLINE DiagDirection GetSingleTramBit(TileIndex tile) { assert(IsTram()); // this function shouldn't be called in other cases if (IsNormalRoadTile(tile)) { RoadBits rb = GetRoadBits(tile, ROADTYPE_TRAM); switch (rb) { case ROAD_NW: return DIAGDIR_NW; case ROAD_SW: return DIAGDIR_SW; case ROAD_SE: return DIAGDIR_SE; case ROAD_NE: return DIAGDIR_NE; default: break; } } return INVALID_DIAGDIR; }