diff options
author | tron <tron@openttd.org> | 2006-05-21 11:34:08 +0000 |
---|---|---|
committer | tron <tron@openttd.org> | 2006-05-21 11:34:08 +0000 |
commit | 2b17d16ce21ebc8298f2e85656d73aa896bfabb3 (patch) | |
tree | 9c3b4dc89f3074d62fa671598258426160248e38 | |
parent | 14d347b4262542d4a5ed1e0b7832d5cd5ce0380c (diff) | |
download | openttd-2b17d16ce21ebc8298f2e85656d73aa896bfabb3.tar.xz |
(svn r4937) Reduce the use of _error_message a bit
-rw-r--r-- | rail_cmd.c | 3 | ||||
-rw-r--r-- | tunnelbridge_cmd.c | 11 | ||||
-rw-r--r-- | vehicle.c | 14 | ||||
-rw-r--r-- | vehicle.h | 2 |
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; @@ -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); |