(svn r4937) Reduce the use of _error_message a bit
This commit is contained in:
		@@ -904,6 +904,7 @@ int32 CmdConvertRail(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	money = GetAvailableMoneyForCommand();
 | 
						money = GetAvailableMoneyForCommand();
 | 
				
			||||||
	cost = 0;
 | 
						cost = 0;
 | 
				
			||||||
 | 
						ret = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	for (x = sx; x <= ex; ++x) {
 | 
						for (x = sx; x <= ex; ++x) {
 | 
				
			||||||
		for (y = sy; y <= ey; ++y) {
 | 
							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)
 | 
					static int32 RemoveTrainDepot(TileIndex tile, uint32 flags)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -656,10 +656,7 @@ static int32 DoClearBridge(TileIndex tile, uint32 flags)
 | 
				
			|||||||
		endtile - delta,
 | 
							endtile - delta,
 | 
				
			||||||
		GetBridgeHeightRamp(tile) + TILE_HEIGHT
 | 
							GetBridgeHeightRamp(tile) + TILE_HEIGHT
 | 
				
			||||||
	);
 | 
						);
 | 
				
			||||||
	if (v != NULL) {
 | 
						if (v != NULL) return_cmd_error(VehicleInTheWayErrMsg(v));
 | 
				
			||||||
		VehicleInTheWayErrMsg(v);
 | 
					 | 
				
			||||||
		return CMD_ERROR;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	t = ClosestTownFromTile(tile, (uint)-1); //needed for town rating penalty
 | 
						t = ClosestTownFromTile(tile, (uint)-1); //needed for town rating penalty
 | 
				
			||||||
	// check if you're allowed to remove the bridge owned by a town.
 | 
						// 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
 | 
							// Make sure there's no vehicle on the bridge
 | 
				
			||||||
		v = FindVehicleBetween(tile, endtile, z);
 | 
							v = FindVehicleBetween(tile, endtile, z);
 | 
				
			||||||
		if (v != NULL) {
 | 
							if (v != NULL) {
 | 
				
			||||||
			VehicleInTheWayErrMsg(v);
 | 
								return_cmd_error(VehicleInTheWayErrMsg(v));
 | 
				
			||||||
			return CMD_ERROR;
 | 
					 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if (!EnsureNoVehicle(tile) || !EnsureNoVehicle(endtile)) {
 | 
							if (!EnsureNoVehicle(tile) || !EnsureNoVehicle(endtile)) {
 | 
				
			||||||
			_error_message = STR_8803_TRAIN_IN_THE_WAY;
 | 
								return_cmd_error(STR_8803_TRAIN_IN_THE_WAY);
 | 
				
			||||||
			return CMD_ERROR;
 | 
					 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if (GetRailType(tile) == totype) return CMD_ERROR;
 | 
							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);
 | 
							(v->date_of_last_service + v->service_interval < _date);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void VehicleInTheWayErrMsg(const Vehicle* v)
 | 
					StringID VehicleInTheWayErrMsg(const Vehicle* v)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	switch (v->type) {
 | 
						switch (v->type) {
 | 
				
			||||||
		case VEH_Train:    _error_message = STR_8803_TRAIN_IN_THE_WAY;        break;
 | 
							case VEH_Train:    return STR_8803_TRAIN_IN_THE_WAY;
 | 
				
			||||||
		case VEH_Road:     _error_message = STR_9000_ROAD_VEHICLE_IN_THE_WAY; break;
 | 
							case VEH_Road:     return STR_9000_ROAD_VEHICLE_IN_THE_WAY;
 | 
				
			||||||
		case VEH_Aircraft: _error_message = STR_A015_AIRCRAFT_IN_THE_WAY;     break;
 | 
							case VEH_Aircraft: return STR_A015_AIRCRAFT_IN_THE_WAY;
 | 
				
			||||||
		default:           _error_message = STR_980E_SHIP_IN_THE_WAY;         break;
 | 
							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)
 | 
						if (v->tile != *(const TileIndex*)data || v->type == VEH_Disaster)
 | 
				
			||||||
		return NULL;
 | 
							return NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	VehicleInTheWayErrMsg(v);
 | 
						_error_message = VehicleInTheWayErrMsg(v);
 | 
				
			||||||
	return 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->tile != ti->tile || v->type == VEH_Disaster) return NULL;
 | 
				
			||||||
	if (v->z_pos > ti->z) return NULL;
 | 
						if (v->z_pos > ti->z) return NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	VehicleInTheWayErrMsg(v);
 | 
						_error_message = VehicleInTheWayErrMsg(v);
 | 
				
			||||||
	return 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);
 | 
					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);
 | 
					Vehicle *FindVehicleBetween(TileIndex from, TileIndex to, byte z);
 | 
				
			||||||
TileIndex GetVehicleOutOfTunnelTile(const Vehicle *v);
 | 
					TileIndex GetVehicleOutOfTunnelTile(const Vehicle *v);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user