summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--rail_cmd.c3
-rw-r--r--tunnelbridge_cmd.c11
-rw-r--r--vehicle.c14
-rw-r--r--vehicle.h2
4 files changed, 13 insertions, 17 deletions
diff --git a/rail_cmd.c b/rail_cmd.c
index 203f83119..ec819ab36 100644
--- a/rail_cmd.c
+++ b/rail_cmd.c
@@ -904,6 +904,7 @@ int32 CmdConvertRail(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
money = GetAvailableMoneyForCommand();
cost = 0;
+ ret = 0;
for (x = sx; x <= ex; ++x) {
for (y = sy; y <= ey; ++y) {
@@ -933,7 +934,7 @@ int32 CmdConvertRail(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
}
}
- return (cost == 0) ? CMD_ERROR : cost;
+ return (cost == 0) ? ret : cost;
}
static int32 RemoveTrainDepot(TileIndex tile, uint32 flags)
diff --git a/tunnelbridge_cmd.c b/tunnelbridge_cmd.c
index 858465aaa..c3c339bdd 100644
--- a/tunnelbridge_cmd.c
+++ b/tunnelbridge_cmd.c
@@ -656,10 +656,7 @@ static int32 DoClearBridge(TileIndex tile, uint32 flags)
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 @@ int32 DoConvertTunnelBridgeRail(TileIndex tile, RailType totype, bool exec)
// 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;
diff --git a/vehicle.c b/vehicle.c
index 63d861129..eed5b2128 100644
--- a/vehicle.c
+++ b/vehicle.c
@@ -102,13 +102,13 @@ bool VehicleNeedsService(const Vehicle *v)
(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 @@ static void *EnsureNoVehicleProc(Vehicle *v, void *data)
if (v->tile != *(const TileIndex*)data || v->type == VEH_Disaster)
return NULL;
- VehicleInTheWayErrMsg(v);
+ _error_message = VehicleInTheWayErrMsg(v);
return v;
}
@@ -133,7 +133,7 @@ static void *EnsureNoVehicleProcZ(Vehicle *v, void *data)
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;
}
diff --git a/vehicle.h b/vehicle.h
index a4939c69e..5d22820be 100644
--- a/vehicle.h
+++ b/vehicle.h
@@ -284,7 +284,7 @@ Vehicle *CreateEffectVehicleRel(const Vehicle *v, int x, int y, int z, EffectVeh
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);