diff options
-rw-r--r-- | src/command.cpp | 3 | ||||
-rw-r--r-- | src/command_type.h | 1 | ||||
-rw-r--r-- | src/rail_cmd.cpp | 4 | ||||
-rw-r--r-- | src/road_cmd.cpp | 4 | ||||
-rw-r--r-- | src/station_cmd.cpp | 4 | ||||
-rw-r--r-- | src/tunnelbridge_cmd.cpp | 2 | ||||
-rw-r--r-- | src/water_cmd.cpp | 2 |
7 files changed, 11 insertions, 9 deletions
diff --git a/src/command.cpp b/src/command.cpp index bb7e91456..b37222293 100644 --- a/src/command.cpp +++ b/src/command.cpp @@ -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)) { diff --git a/src/command_type.h b/src/command_type.h index 4fc0f87ef..281933e43 100644 --- a/src/command_type.h +++ b/src/command_type.h @@ -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 }; /** diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp index e3217ca72..03517b2c3 100644 --- a/src/rail_cmd.cpp +++ b/src/rail_cmd.cpp @@ -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); } } diff --git a/src/road_cmd.cpp b/src/road_cmd.cpp index 7610b46fe..4711fa052 100644 --- a/src/road_cmd.cpp +++ b/src/road_cmd.cpp @@ -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); } diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp index 5d29fbf9e..750a723e7 100644 --- a/src/station_cmd.cpp +++ b/src/station_cmd.cpp @@ -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); } } } diff --git a/src/tunnelbridge_cmd.cpp b/src/tunnelbridge_cmd.cpp index 0ea62d5ea..56eca808a 100644 --- a/src/tunnelbridge_cmd.cpp +++ b/src/tunnelbridge_cmd.cpp @@ -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. diff --git a/src/water_cmd.cpp b/src/water_cmd.cpp index 4c5484d24..5f316dac2 100644 --- a/src/water_cmd.cpp +++ b/src/water_cmd.cpp @@ -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); } |