mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-16 00:12:51 +00:00
(svn r4937) Reduce the use of _error_message a bit
This commit is contained in:
parent
14d347b426
commit
2b17d16ce2
@ -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)
|
||||
|
@ -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;
|
||||
|
14
vehicle.c
14
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;
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user