mirror of https://github.com/OpenTTD/OpenTTD
(svn r8852) -Fix (r8735): make the dynamite tool for drive through road stops as if it were removing a normal road tile (consider the local authority and such).
-Fix (r8735): remove drive through road stops on town owned roads when going bankrupt/being removed.release/0.6
parent
dcb217a6ac
commit
202702c007
10
src/road.h
10
src/road.h
|
@ -40,4 +40,14 @@ static inline bool IsStraightRoadTrackdir(Trackdir dir)
|
||||||
return (dir & 0x06) == 0;
|
return (dir & 0x06) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is it allowed to remove the given road bits from the given tile?
|
||||||
|
* @param tile the tile to remove the road from
|
||||||
|
* @param remove the roadbits that are going to be removed
|
||||||
|
* @param owner the actual owner of the roadbits of the tile
|
||||||
|
* @param edge_road are the removed bits from a town?
|
||||||
|
* @return true when it is allowed to remove the road bits
|
||||||
|
*/
|
||||||
|
bool CheckAllowRemoveRoad(TileIndex tile, RoadBits remove, Owner owner, bool *edge_road);
|
||||||
|
|
||||||
#endif /* ROAD_H */
|
#endif /* ROAD_H */
|
||||||
|
|
|
@ -35,11 +35,10 @@ static uint CountRoadBits(RoadBits r)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static bool CheckAllowRemoveRoad(TileIndex tile, RoadBits remove, bool* edge_road)
|
bool CheckAllowRemoveRoad(TileIndex tile, RoadBits remove, Owner owner, bool *edge_road)
|
||||||
{
|
{
|
||||||
RoadBits present;
|
RoadBits present;
|
||||||
RoadBits n;
|
RoadBits n;
|
||||||
Owner owner;
|
|
||||||
*edge_road = true;
|
*edge_road = true;
|
||||||
|
|
||||||
if (_game_mode == GM_EDITOR) return true;
|
if (_game_mode == GM_EDITOR) return true;
|
||||||
|
@ -47,8 +46,6 @@ static bool CheckAllowRemoveRoad(TileIndex tile, RoadBits remove, bool* edge_roa
|
||||||
// Only do the special processing for actual players.
|
// Only do the special processing for actual players.
|
||||||
if (!IsValidPlayer(_current_player)) return true;
|
if (!IsValidPlayer(_current_player)) return true;
|
||||||
|
|
||||||
owner = IsLevelCrossingTile(tile) ? GetCrossingRoadOwner(tile) : GetTileOwner(tile);
|
|
||||||
|
|
||||||
// Only do the special processing if the road is owned
|
// Only do the special processing if the road is owned
|
||||||
// by a town
|
// by a town
|
||||||
if (owner != OWNER_TOWN) return (owner == OWNER_NONE) || CheckOwnership(owner);
|
if (owner != OWNER_TOWN) return (owner == OWNER_NONE) || CheckOwnership(owner);
|
||||||
|
@ -81,6 +78,10 @@ static bool CheckAllowRemoveRoad(TileIndex tile, RoadBits remove, bool* edge_roa
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool CheckAllowRemoveRoad(TileIndex tile, RoadBits remove, bool *edge_road)
|
||||||
|
{
|
||||||
|
return CheckAllowRemoveRoad(tile, remove, IsLevelCrossingTile(tile) ? GetCrossingRoadOwner(tile) : GetTileOwner(tile), edge_road);
|
||||||
|
}
|
||||||
|
|
||||||
/** Delete a piece of road.
|
/** Delete a piece of road.
|
||||||
* @param tile tile where to remove road from
|
* @param tile tile where to remove road from
|
||||||
|
|
|
@ -2584,10 +2584,31 @@ static void ChangeTileOwner_Station(TileIndex tile, PlayerID old_player, PlayerI
|
||||||
RebuildStationLists();
|
RebuildStationLists();
|
||||||
InvalidateWindowClasses(WC_STATION_LIST);
|
InvalidateWindowClasses(WC_STATION_LIST);
|
||||||
} else {
|
} else {
|
||||||
DoCommand(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR);
|
if (IsDriveThroughStopTile(tile) && GetStopBuiltOnTownRoad(tile)) {
|
||||||
|
/* For a drive-through stop on a town-owned road remove the stop and replace the road */
|
||||||
|
DoCommand(tile, 0, (GetStationType(tile) == STATION_TRUCK) ? RoadStop::TRUCK : RoadStop::BUS, DC_EXEC, CMD_REMOVE_ROAD_STOP);
|
||||||
|
} else {
|
||||||
|
DoCommand(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if a drive-through road stop tile can be cleared.
|
||||||
|
* Road stops built on town-owned roads check the conditions
|
||||||
|
* that would allow clearing of the original road.
|
||||||
|
* @param tile road stop tile to check
|
||||||
|
* @return true if the road can be cleared
|
||||||
|
*/
|
||||||
|
static bool CanRemoveRoadWithStop(TileIndex tile)
|
||||||
|
{
|
||||||
|
/* The road can always be cleared if it was not a town-owned road */
|
||||||
|
if (!GetStopBuiltOnTownRoad(tile)) return true;
|
||||||
|
|
||||||
|
bool edge_road;
|
||||||
|
return CheckAllowRemoveRoad(tile, GetAnyRoadBits(tile), OWNER_TOWN, &edge_road);
|
||||||
|
}
|
||||||
|
|
||||||
static int32 ClearTile_Station(TileIndex tile, byte flags)
|
static int32 ClearTile_Station(TileIndex tile, byte flags)
|
||||||
{
|
{
|
||||||
if (flags & DC_AUTO) {
|
if (flags & DC_AUTO) {
|
||||||
|
@ -2610,11 +2631,11 @@ static int32 ClearTile_Station(TileIndex tile, byte flags)
|
||||||
case STATION_RAIL: return RemoveRailroadStation(st, tile, flags);
|
case STATION_RAIL: return RemoveRailroadStation(st, tile, flags);
|
||||||
case STATION_AIRPORT: return RemoveAirport(st, flags);
|
case STATION_AIRPORT: return RemoveAirport(st, flags);
|
||||||
case STATION_TRUCK:
|
case STATION_TRUCK:
|
||||||
if (IsDriveThroughStopTile(tile) && GetStopBuiltOnTownRoad(tile))
|
if (IsDriveThroughStopTile(tile) && !CanRemoveRoadWithStop(tile))
|
||||||
return_cmd_error(STR_3047_MUST_DEMOLISH_TRUCK_STATION);
|
return_cmd_error(STR_3047_MUST_DEMOLISH_TRUCK_STATION);
|
||||||
return RemoveRoadStop(st, flags, tile);
|
return RemoveRoadStop(st, flags, tile);
|
||||||
case STATION_BUS:
|
case STATION_BUS:
|
||||||
if (IsDriveThroughStopTile(tile) && GetStopBuiltOnTownRoad(tile))
|
if (IsDriveThroughStopTile(tile) && !CanRemoveRoadWithStop(tile))
|
||||||
return_cmd_error(STR_3046_MUST_DEMOLISH_BUS_STATION);
|
return_cmd_error(STR_3046_MUST_DEMOLISH_BUS_STATION);
|
||||||
return RemoveRoadStop(st, flags, tile);
|
return RemoveRoadStop(st, flags, tile);
|
||||||
case STATION_BUOY: return RemoveBuoy(st, flags);
|
case STATION_BUOY: return RemoveBuoy(st, flags);
|
||||||
|
|
Loading…
Reference in New Issue