mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r12094) -Codechange: use DC_BANKRUPT command flag when removing player property to allow further fixes
This commit is contained in:
parent
221494bd3f
commit
802c949755
|
@ -422,6 +422,7 @@ CommandCost DoCommand(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint32
|
|||
|
||||
if (_docommand_recursive == 1 &&
|
||||
!(flags & DC_QUERY_COST) &&
|
||||
!(flags & DC_BANKRUPT) &&
|
||||
res.GetCost() != 0 &&
|
||||
!CheckPlayerHasMoney(res)) {
|
||||
goto error;
|
||||
|
@ -446,7 +447,7 @@ error:
|
|||
}
|
||||
|
||||
/* if toplevel, subtract the money. */
|
||||
if (--_docommand_recursive == 0) {
|
||||
if (--_docommand_recursive == 0 && !(flags & DC_BANKRUPT)) {
|
||||
SubtractMoneyFromPlayer(res);
|
||||
/* XXX - Old AI hack which doesn't use DoCommandDP; update last build coord of player */
|
||||
if (tile != 0 && IsValidPlayer(_current_player)) {
|
||||
|
|
|
@ -271,6 +271,7 @@ enum {
|
|||
DC_NO_RAIL_OVERLAP = 0x10, ///< don't allow overlap of rails (used in buildrail)
|
||||
DC_AI_BUILDING = 0x20, ///< special building rules for AI
|
||||
DC_NO_TOWN_RATING = 0x40, ///< town rating does not disallow you from building
|
||||
DC_BANKRUPT = 0x80, ///< company bankrupts, skip money check, skip vehicle on tile check in some cases
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -455,7 +455,7 @@ CommandCost CmdRemoveSingleRail(TileIndex tile, uint32 flags, uint32 p1, uint32
|
|||
if (!IsLevelCrossing(tile) ||
|
||||
GetCrossingRailBits(tile) != trackbit ||
|
||||
(_current_player != OWNER_WATER && !CheckTileOwnership(tile)) ||
|
||||
!EnsureNoVehicleOnGround(tile)) {
|
||||
(!(flags & DC_BANKRUPT) && !EnsureNoVehicleOnGround(tile))) {
|
||||
return CMD_ERROR;
|
||||
}
|
||||
|
||||
|
@ -2146,7 +2146,7 @@ static void ChangeTileOwner_Track(TileIndex tile, PlayerID old_player, PlayerID
|
|||
if (new_player != PLAYER_SPECTATOR) {
|
||||
SetTileOwner(tile, new_player);
|
||||
} else {
|
||||
DoCommand(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR);
|
||||
DoCommand(tile, 0, 0, DC_EXEC | DC_BANKRUPT, CMD_LANDSCAPE_CLEAR);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1404,7 +1404,7 @@ static void ChangeTileOwner_Road(TileIndex tile, PlayerID old_player, PlayerID n
|
|||
if (GetRoadTileType(tile) == ROAD_TILE_DEPOT) {
|
||||
if (GetTileOwner(tile) == old_player) {
|
||||
if (new_player == PLAYER_SPECTATOR) {
|
||||
DoCommand(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR);
|
||||
DoCommand(tile, 0, 0, DC_EXEC | DC_BANKRUPT, CMD_LANDSCAPE_CLEAR);
|
||||
} else {
|
||||
SetTileOwner(tile, new_player);
|
||||
}
|
||||
|
@ -1423,7 +1423,7 @@ static void ChangeTileOwner_Road(TileIndex tile, PlayerID old_player, PlayerID n
|
|||
if (IsLevelCrossing(tile)) {
|
||||
if (GetTileOwner(tile) == old_player) {
|
||||
if (new_player == PLAYER_SPECTATOR) {
|
||||
MakeRoadNormal(tile, GetCrossingRoadBits(tile), GetRoadTypes(tile), GetTownIndex(tile), GetRoadOwner(tile, ROADTYPE_ROAD), GetRoadOwner(tile, ROADTYPE_TRAM), GetRoadOwner(tile, ROADTYPE_HWAY));
|
||||
DoCommand(tile, 0, AxisToTrack(OtherAxis(GetCrossingRoadAxis(tile))), DC_EXEC | DC_BANKRUPT, CMD_REMOVE_SINGLE_RAIL);
|
||||
} else {
|
||||
SetTileOwner(tile, new_player);
|
||||
}
|
||||
|
|
|
@ -2893,9 +2893,9 @@ static void ChangeTileOwner_Station(TileIndex tile, PlayerID old_player, PlayerI
|
|||
} else {
|
||||
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);
|
||||
DoCommand(tile, 0, (GetStationType(tile) == STATION_TRUCK) ? RoadStop::TRUCK : RoadStop::BUS, DC_EXEC | DC_BANKRUPT, CMD_REMOVE_ROAD_STOP);
|
||||
} else {
|
||||
DoCommand(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR);
|
||||
DoCommand(tile, 0, 0, DC_EXEC | DC_BANKRUPT, CMD_LANDSCAPE_CLEAR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1181,7 +1181,7 @@ static void ChangeTileOwner_TunnelBridge(TileIndex tile, PlayerID old_player, Pl
|
|||
if (new_player != PLAYER_SPECTATOR) {
|
||||
SetTileOwner(tile, new_player);
|
||||
} else {
|
||||
if (CmdFailed(DoCommand(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR))) {
|
||||
if (CmdFailed(DoCommand(tile, 0, 0, DC_EXEC | DC_BANKRUPT, CMD_LANDSCAPE_CLEAR))) {
|
||||
/* When clearing the bridge/tunnel failed there are still vehicles on/in
|
||||
* the bridge/tunnel. As all *our* vehicles are already removed, they
|
||||
* must be of another owner. Therefor this must be a road bridge/tunnel.
|
||||
|
|
|
@ -1140,7 +1140,7 @@ static void ChangeTileOwner_Water(TileIndex tile, PlayerID old_player, PlayerID
|
|||
if (new_player != PLAYER_SPECTATOR) {
|
||||
SetTileOwner(tile, new_player);
|
||||
} else if (IsShipDepot(tile)) {
|
||||
DoCommand(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR);
|
||||
DoCommand(tile, 0, 0, DC_EXEC | DC_BANKRUPT, CMD_LANDSCAPE_CLEAR);
|
||||
} else {
|
||||
SetTileOwner(tile, OWNER_NONE);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue