--- a/rail_cmd.c Sat May 20 21:04:43 2006 +0000
+++ b/rail_cmd.c Sun May 21 11:34:08 2006 +0000
@@ -904,6 +904,7 @@
money = GetAvailableMoneyForCommand();
cost = 0;
+ ret = 0;
for (x = sx; x <= ex; ++x) {
for (y = sy; y <= ey; ++y) {
@@ -933,7 +934,7 @@
}
}
- return (cost == 0) ? CMD_ERROR : cost;
+ return (cost == 0) ? ret : cost;
}
static int32 RemoveTrainDepot(TileIndex tile, uint32 flags)
--- a/tunnelbridge_cmd.c Sat May 20 21:04:43 2006 +0000
+++ b/tunnelbridge_cmd.c Sun May 21 11:34:08 2006 +0000
@@ -656,10 +656,7 @@
endtile - delta,
GetBridgeHeightRamp(tile) + TILE_HEIGHT
);
- if (v != NULL) {
- VehicleInTheWayErrMsg(v);
- return CMD_ERROR;
- }
+ if (v != NULL) return_cmd_error(VehicleInTheWayErrMsg(v));
t = ClosestTownFromTile(tile, (uint)-1); //needed for town rating penalty
// check if you're allowed to remove the bridge owned by a town.
@@ -770,13 +767,11 @@
// Make sure there's no vehicle on the bridge
v = FindVehicleBetween(tile, endtile, z);
if (v != NULL) {
- VehicleInTheWayErrMsg(v);
- return CMD_ERROR;
+ return_cmd_error(VehicleInTheWayErrMsg(v));
}
if (!EnsureNoVehicle(tile) || !EnsureNoVehicle(endtile)) {
- _error_message = STR_8803_TRAIN_IN_THE_WAY;
- return CMD_ERROR;
+ return_cmd_error(STR_8803_TRAIN_IN_THE_WAY);
}
if (GetRailType(tile) == totype) return CMD_ERROR;
--- a/vehicle.c Sat May 20 21:04:43 2006 +0000
+++ b/vehicle.c Sun May 21 11:34:08 2006 +0000
@@ -102,13 +102,13 @@
(v->date_of_last_service + v->service_interval < _date);
}
-void VehicleInTheWayErrMsg(const Vehicle* v)
+StringID VehicleInTheWayErrMsg(const Vehicle* v)
{
switch (v->type) {
- case VEH_Train: _error_message = STR_8803_TRAIN_IN_THE_WAY; break;
- case VEH_Road: _error_message = STR_9000_ROAD_VEHICLE_IN_THE_WAY; break;
- case VEH_Aircraft: _error_message = STR_A015_AIRCRAFT_IN_THE_WAY; break;
- default: _error_message = STR_980E_SHIP_IN_THE_WAY; break;
+ case VEH_Train: return STR_8803_TRAIN_IN_THE_WAY;
+ case VEH_Road: return STR_9000_ROAD_VEHICLE_IN_THE_WAY;
+ case VEH_Aircraft: return STR_A015_AIRCRAFT_IN_THE_WAY;
+ default: return STR_980E_SHIP_IN_THE_WAY;
}
}
@@ -117,7 +117,7 @@
if (v->tile != *(const TileIndex*)data || v->type == VEH_Disaster)
return NULL;
- VehicleInTheWayErrMsg(v);
+ _error_message = VehicleInTheWayErrMsg(v);
return v;
}
@@ -133,7 +133,7 @@
if (v->tile != ti->tile || v->type == VEH_Disaster) return NULL;
if (v->z_pos > ti->z) return NULL;
- VehicleInTheWayErrMsg(v);
+ _error_message = VehicleInTheWayErrMsg(v);
return v;
}
--- a/vehicle.h Sat May 20 21:04:43 2006 +0000
+++ b/vehicle.h Sun May 21 11:34:08 2006 +0000
@@ -284,7 +284,7 @@
uint32 VehicleEnterTile(Vehicle *v, TileIndex tile, int x, int y);
-void VehicleInTheWayErrMsg(const Vehicle* v);
+StringID VehicleInTheWayErrMsg(const Vehicle* v);
Vehicle *FindVehicleBetween(TileIndex from, TileIndex to, byte z);
TileIndex GetVehicleOutOfTunnelTile(const Vehicle *v);