mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r12095) -Fix [FS#1703]: when a company bankrupts, remove drive-through road stops, ship depots and buoys too. Update owners of water and road.
This commit is contained in:
parent
802c949755
commit
e3301db213
|
@ -1413,7 +1413,8 @@ static void ChangeTileOwner_Road(TileIndex tile, PlayerID old_player, PlayerID n
|
||||||
}
|
}
|
||||||
|
|
||||||
for (RoadType rt = ROADTYPE_ROAD; rt < ROADTYPE_END; rt++) {
|
for (RoadType rt = ROADTYPE_ROAD; rt < ROADTYPE_END; rt++) {
|
||||||
if (!HasBit(GetRoadTypes(tile), rt)) continue;
|
/* ROADTYPE_ROAD denotes the tile owner, so update it too */
|
||||||
|
if (rt != ROADTYPE_ROAD && !HasBit(GetRoadTypes(tile), rt)) continue;
|
||||||
|
|
||||||
if (GetRoadOwner(tile, rt) == old_player) {
|
if (GetRoadOwner(tile, rt) == old_player) {
|
||||||
SetRoadOwner(tile, rt, new_player == PLAYER_SPECTATOR ? OWNER_NONE : new_player);
|
SetRoadOwner(tile, rt, new_player == PLAYER_SPECTATOR ? OWNER_NONE : new_player);
|
||||||
|
|
|
@ -1465,6 +1465,15 @@ CommandCost CmdBuildRoadStop(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
||||||
return cost;
|
return cost;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void *ClearRoadStopStatusEnum(Vehicle *v, void *)
|
||||||
|
{
|
||||||
|
if (v->type == VEH_ROAD) ClrBit(v->u.road.state, RVS_IN_DT_ROAD_STOP);
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/** Remove a bus station
|
/** Remove a bus station
|
||||||
* @param st Station to remove
|
* @param st Station to remove
|
||||||
* @param flags operation to perform
|
* @param flags operation to perform
|
||||||
|
@ -1491,7 +1500,13 @@ static CommandCost RemoveRoadStop(Station *st, uint32 flags, TileIndex tile)
|
||||||
|
|
||||||
assert(cur_stop != NULL);
|
assert(cur_stop != NULL);
|
||||||
|
|
||||||
if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR;
|
/* don't do the check for drive-through road stops when company bankrupts */
|
||||||
|
if (IsDriveThroughStopTile(tile) && (flags & DC_BANKRUPT)) {
|
||||||
|
/* remove the 'going through road stop' status from all vehicles on that tile */
|
||||||
|
if (flags & DC_EXEC) VehicleFromPos(tile, NULL, &ClearRoadStopStatusEnum);
|
||||||
|
} else {
|
||||||
|
if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
if (flags & DC_EXEC) {
|
if (flags & DC_EXEC) {
|
||||||
if (*primary_stop == cur_stop) {
|
if (*primary_stop == cur_stop) {
|
||||||
|
@ -1905,7 +1920,8 @@ static CommandCost RemoveBuoy(Station *st, uint32 flags)
|
||||||
TileIndex tile = st->dock_tile;
|
TileIndex tile = st->dock_tile;
|
||||||
|
|
||||||
if (HasStationInUse(st->index, INVALID_PLAYER)) return_cmd_error(STR_BUOY_IS_IN_USE);
|
if (HasStationInUse(st->index, INVALID_PLAYER)) return_cmd_error(STR_BUOY_IS_IN_USE);
|
||||||
if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR;
|
/* remove the buoy if there is a ship on tile when company goes bankrupt... */
|
||||||
|
if (!(flags & DC_BANKRUPT) && !EnsureNoVehicleOnGround(tile)) return CMD_ERROR;
|
||||||
|
|
||||||
if (flags & DC_EXEC) {
|
if (flags & DC_EXEC) {
|
||||||
st->dock_tile = 0;
|
st->dock_tile = 0;
|
||||||
|
@ -2891,11 +2907,18 @@ static void ChangeTileOwner_Station(TileIndex tile, PlayerID old_player, PlayerI
|
||||||
RebuildStationLists();
|
RebuildStationLists();
|
||||||
InvalidateWindowClasses(WC_STATION_LIST);
|
InvalidateWindowClasses(WC_STATION_LIST);
|
||||||
} else {
|
} else {
|
||||||
if (IsDriveThroughStopTile(tile) && GetStopBuiltOnTownRoad(tile)) {
|
if (IsDriveThroughStopTile(tile)) {
|
||||||
/* For a drive-through stop on a town-owned road remove the stop and replace the road */
|
/* Remove the drive-through road stop */
|
||||||
DoCommand(tile, 0, (GetStationType(tile) == STATION_TRUCK) ? RoadStop::TRUCK : RoadStop::BUS, DC_EXEC | DC_BANKRUPT, CMD_REMOVE_ROAD_STOP);
|
DoCommand(tile, 0, (GetStationType(tile) == STATION_TRUCK) ? RoadStop::TRUCK : RoadStop::BUS, DC_EXEC | DC_BANKRUPT, CMD_REMOVE_ROAD_STOP);
|
||||||
|
assert(IsTileType(tile, MP_ROAD));
|
||||||
|
/* Change owner of tile and all roadtypes */
|
||||||
|
ChangeTileOwner(tile, old_player, new_player);
|
||||||
} else {
|
} else {
|
||||||
DoCommand(tile, 0, 0, DC_EXEC | DC_BANKRUPT, CMD_LANDSCAPE_CLEAR);
|
DoCommand(tile, 0, 0, DC_EXEC | DC_BANKRUPT, CMD_LANDSCAPE_CLEAR);
|
||||||
|
/* Set tile owner of water under (now removed) buoy and dock to OWNER_NONE.
|
||||||
|
* Update owner of buoy if it was not removed (was in orders).
|
||||||
|
* Do not update when owned by OWNER_WATER (sea and rivers). */
|
||||||
|
if ((IsTileType(tile, MP_WATER) || IsBuoyTile(tile)) && IsTileOwner(tile, old_player)) SetTileOwner(tile, OWNER_NONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -220,15 +220,15 @@ void MakeWaterKeepingClass(TileIndex tile, Owner o)
|
||||||
|
|
||||||
static CommandCost RemoveShipDepot(TileIndex tile, uint32 flags)
|
static CommandCost RemoveShipDepot(TileIndex tile, uint32 flags)
|
||||||
{
|
{
|
||||||
TileIndex tile2;
|
|
||||||
|
|
||||||
if (!IsShipDepot(tile)) return CMD_ERROR;
|
if (!IsShipDepot(tile)) return CMD_ERROR;
|
||||||
if (!CheckTileOwnership(tile)) return CMD_ERROR;
|
if (!CheckTileOwnership(tile)) return CMD_ERROR;
|
||||||
if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR;
|
|
||||||
|
|
||||||
tile2 = GetOtherShipDepotTile(tile);
|
TileIndex tile2 = GetOtherShipDepotTile(tile);
|
||||||
|
|
||||||
if (!EnsureNoVehicleOnGround(tile2)) return CMD_ERROR;
|
/* do not check for ship on tile when company goes bankrupt */
|
||||||
|
if (!(flags & DC_BANKRUPT)) {
|
||||||
|
if (!EnsureNoVehicleOnGround(tile) || !EnsureNoVehicleOnGround(tile2)) return CMD_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
if (flags & DC_EXEC) {
|
if (flags & DC_EXEC) {
|
||||||
/* Kill the depot, which is registered at the northernmost tile. Use that one */
|
/* Kill the depot, which is registered at the northernmost tile. Use that one */
|
||||||
|
@ -1139,11 +1139,15 @@ static void ChangeTileOwner_Water(TileIndex tile, PlayerID old_player, PlayerID
|
||||||
|
|
||||||
if (new_player != PLAYER_SPECTATOR) {
|
if (new_player != PLAYER_SPECTATOR) {
|
||||||
SetTileOwner(tile, new_player);
|
SetTileOwner(tile, new_player);
|
||||||
} else if (IsShipDepot(tile)) {
|
return;
|
||||||
DoCommand(tile, 0, 0, DC_EXEC | DC_BANKRUPT, CMD_LANDSCAPE_CLEAR);
|
|
||||||
} else {
|
|
||||||
SetTileOwner(tile, OWNER_NONE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Remove depot */
|
||||||
|
if (IsShipDepot(tile)) DoCommand(tile, 0, 0, DC_EXEC | DC_BANKRUPT, CMD_LANDSCAPE_CLEAR);
|
||||||
|
|
||||||
|
/* Set owner of canals and locks ... and also canal under dock there was before.
|
||||||
|
* Check if the new owner after removing depot isn't OWNER_WATER. */
|
||||||
|
if (IsTileOwner(tile, old_player)) SetTileOwner(tile, OWNER_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static VehicleEnterTileStatus VehicleEnter_Water(Vehicle *v, TileIndex tile, int x, int y)
|
static VehicleEnterTileStatus VehicleEnter_Water(Vehicle *v, TileIndex tile, int x, int y)
|
||||||
|
|
Loading…
Reference in New Issue