(svn r12094) -Codechange: use DC_BANKRUPT command flag when removing player property to allow further fixes
--- a/src/command.cpp Sat Feb 09 12:20:50 2008 +0000
+++ b/src/command.cpp Sat Feb 09 15:07:31 2008 +0000
@@ -422,6 +422,7 @@
if (_docommand_recursive == 1 &&
!(flags & DC_QUERY_COST) &&
+ !(flags & DC_BANKRUPT) &&
res.GetCost() != 0 &&
!CheckPlayerHasMoney(res)) {
goto error;
@@ -446,7 +447,7 @@
}
/* 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)) {
--- a/src/command_type.h Sat Feb 09 12:20:50 2008 +0000
+++ b/src/command_type.h Sat Feb 09 15:07:31 2008 +0000
@@ -271,6 +271,7 @@
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
};
/**
--- a/src/rail_cmd.cpp Sat Feb 09 12:20:50 2008 +0000
+++ b/src/rail_cmd.cpp Sat Feb 09 15:07:31 2008 +0000
@@ -455,7 +455,7 @@
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 @@
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);
}
}
--- a/src/road_cmd.cpp Sat Feb 09 12:20:50 2008 +0000
+++ b/src/road_cmd.cpp Sat Feb 09 15:07:31 2008 +0000
@@ -1404,7 +1404,7 @@
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 @@
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);
}
--- a/src/station_cmd.cpp Sat Feb 09 12:20:50 2008 +0000
+++ b/src/station_cmd.cpp Sat Feb 09 15:07:31 2008 +0000
@@ -2893,9 +2893,9 @@
} 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);
}
}
}
--- a/src/tunnelbridge_cmd.cpp Sat Feb 09 12:20:50 2008 +0000
+++ b/src/tunnelbridge_cmd.cpp Sat Feb 09 15:07:31 2008 +0000
@@ -1181,7 +1181,7 @@
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.
--- a/src/water_cmd.cpp Sat Feb 09 12:20:50 2008 +0000
+++ b/src/water_cmd.cpp Sat Feb 09 15:07:31 2008 +0000
@@ -1140,7 +1140,7 @@
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);
}