mirror of https://github.com/OpenTTD/OpenTTD
(svn r9935) -Fix: could not build a drive through station when there when you own the tram bits and the town owns the road.
parent
04f9b1ab61
commit
9ca9d73eea
|
@ -1248,7 +1248,6 @@ int32 CmdBuildRoadStop(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
||||||
bool is_drive_through = HASBIT(p2, 1);
|
bool is_drive_through = HASBIT(p2, 1);
|
||||||
bool build_over_road = is_drive_through && IsTileType(tile, MP_STREET) && GetRoadTileType(tile) == ROAD_TILE_NORMAL;
|
bool build_over_road = is_drive_through && IsTileType(tile, MP_STREET) && GetRoadTileType(tile) == ROAD_TILE_NORMAL;
|
||||||
bool town_owned_road = build_over_road && IsTileOwner(tile, OWNER_TOWN);
|
bool town_owned_road = build_over_road && IsTileOwner(tile, OWNER_TOWN);
|
||||||
Owner cur_owner = _current_player;
|
|
||||||
RoadTypes rts = (RoadTypes)GB(p2, 2, 3);
|
RoadTypes rts = (RoadTypes)GB(p2, 2, 3);
|
||||||
|
|
||||||
if (rts == ROADTYPES_NONE || HASBIT(rts, ROADTYPE_HWAY)) return CMD_ERROR;
|
if (rts == ROADTYPES_NONE || HASBIT(rts, ROADTYPE_HWAY)) return CMD_ERROR;
|
||||||
|
@ -1262,32 +1261,29 @@ int32 CmdBuildRoadStop(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
||||||
if (is_drive_through && !IsValidAxis((Axis)p1)) return CMD_ERROR;
|
if (is_drive_through && !IsValidAxis((Axis)p1)) return CMD_ERROR;
|
||||||
/* Road bits in the wrong direction */
|
/* Road bits in the wrong direction */
|
||||||
if (build_over_road && (GetAllRoadBits(tile) & ((Axis)p1 == AXIS_X ? ROAD_Y : ROAD_X)) != 0) return_cmd_error(STR_DRIVE_THROUGH_ERROR_DIRECTION);
|
if (build_over_road && (GetAllRoadBits(tile) & ((Axis)p1 == AXIS_X ? ROAD_Y : ROAD_X)) != 0) return_cmd_error(STR_DRIVE_THROUGH_ERROR_DIRECTION);
|
||||||
|
|
||||||
|
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
|
||||||
|
|
||||||
|
if (!(flags & DC_NO_TOWN_RATING) && !CheckIfAuthorityAllows(tile)) return CMD_ERROR;
|
||||||
|
|
||||||
|
int32 cost = 0;
|
||||||
|
|
||||||
/* Not allowed to build over this road */
|
/* Not allowed to build over this road */
|
||||||
if (build_over_road) {
|
if (build_over_road) {
|
||||||
if (IsTileOwner(tile, OWNER_TOWN) && !_patches.road_stop_on_town_road) return_cmd_error(STR_DRIVE_THROUGH_ERROR_ON_TOWN_ROAD);
|
if (IsTileOwner(tile, OWNER_TOWN) && !_patches.road_stop_on_town_road) return_cmd_error(STR_DRIVE_THROUGH_ERROR_ON_TOWN_ROAD);
|
||||||
if (GetRoadTileType(tile) != ROAD_TILE_NORMAL) return CMD_ERROR;
|
if (GetRoadTileType(tile) != ROAD_TILE_NORMAL) return CMD_ERROR;
|
||||||
|
|
||||||
RoadTypes cur_rts = GetRoadTypes(tile);
|
RoadTypes cur_rts = GetRoadTypes(tile);
|
||||||
if (!IsTileOwner(tile, OWNER_TOWN) && (
|
if (GetRoadOwner(tile, ROADTYPE_ROAD) != OWNER_TOWN && HASBIT(cur_rts, ROADTYPE_ROAD) && !CheckOwnership(GetRoadOwner(tile, ROADTYPE_ROAD))) return CMD_ERROR;
|
||||||
((HASBIT(cur_rts, ROADTYPE_ROAD) && !CheckOwnership(GetRoadOwner(tile, ROADTYPE_ROAD)))) ||
|
if (HASBIT(cur_rts, ROADTYPE_TRAM) && !CheckOwnership(GetRoadOwner(tile, ROADTYPE_TRAM))) return CMD_ERROR;
|
||||||
((HASBIT(cur_rts, ROADTYPE_TRAM) && !CheckOwnership(GetRoadOwner(tile, ROADTYPE_TRAM)))))) return CMD_ERROR;
|
|
||||||
/* Do not remove roadtypes! */
|
/* Do not remove roadtypes! */
|
||||||
rts |= GetRoadTypes(tile);
|
rts |= cur_rts;
|
||||||
|
} else {
|
||||||
|
cost = CheckFlatLandBelow(tile, 1, 1, flags, is_drive_through ? 5 << p1 : 1 << p1, NULL);
|
||||||
|
if (CmdFailed(cost)) return cost;
|
||||||
}
|
}
|
||||||
|
|
||||||
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
|
|
||||||
|
|
||||||
if (!(flags & DC_NO_TOWN_RATING) && !CheckIfAuthorityAllows(tile))
|
|
||||||
return CMD_ERROR;
|
|
||||||
|
|
||||||
if (build_over_road) flags ^= DC_AUTO;
|
|
||||||
|
|
||||||
if (town_owned_road) _current_player = OWNER_TOWN;
|
|
||||||
int32 ret = CheckFlatLandBelow(tile, 1, 1, flags, is_drive_through ? 5 << p1 : 1 << p1, NULL);
|
|
||||||
_current_player = cur_owner;
|
|
||||||
if (CmdFailed(ret)) return ret;
|
|
||||||
int32 cost = build_over_road ? 0 : ret; // Don't add cost of clearing road when overbuilding
|
|
||||||
|
|
||||||
Station *st = NULL;
|
Station *st = NULL;
|
||||||
|
|
||||||
if (!_patches.adjacent_stations || !HASBIT(p2, 5)) {
|
if (!_patches.adjacent_stations || !HASBIT(p2, 5)) {
|
||||||
|
|
Loading…
Reference in New Issue