Changeset - r9934:91e1ab4a9402
[Not reviewed]
master
0 2 0
rubidium - 16 years ago 2008-08-17 11:04:37
rubidium@openttd.org
(svn r14089) -Fix [FS#2219]: trains not being able to find a route to a depot when the front is already in the depot.
2 files changed with 9 insertions and 6 deletions:
0 comments (0 inline, 0 general)
src/train_cmd.cpp
Show inline comments
 
@@ -2125,22 +2125,29 @@ static bool NtpCallbFindDepot(TileIndex 
 
static TrainFindDepotData FindClosestTrainDepot(Vehicle *v, int max_distance)
 
{
 
	assert(!(v->vehstatus & VS_CRASHED));
 

	
 
	TrainFindDepotData tfdd;
 
	tfdd.owner = v->owner;
 
	tfdd.best_length = UINT_MAX;
 
	tfdd.reverse = false;
 

	
 
	if (IsRailDepotTile(v->tile)) {
 
		tfdd.tile = v->tile;
 
		tfdd.best_length = 0;
 
		return tfdd;
 
	}
 

	
 
	PBSTileInfo origin = FollowTrainReservation(v);
 
	if (IsRailDepotTile(origin.tile)) {
 
		tfdd.tile = origin.tile;
 
		tfdd.best_length = 0;
 
		return tfdd;
 
	}
 

	
 
	tfdd.best_length = UINT_MAX;
 

	
 
	uint8 pathfinder = _settings_game.pf.pathfinder_for_trains;
 
	if ((_settings_game.pf.reserve_paths || HasReservedTracks(v->tile, v->u.rail.track)) && pathfinder == VPF_NTP) pathfinder = VPF_NPF;
 

	
 
	switch (pathfinder) {
 
		case VPF_YAPF: { /* YAPF */
 
			bool found = YapfFindNearestRailDepotTwoWay(v, max_distance, NPF_INFINITE_PENALTY, &tfdd.tile, &tfdd.reverse);
src/vehicle.cpp
Show inline comments
 
@@ -2493,13 +2493,13 @@ void Vehicle::HandleLoading(bool mode)
 
}
 

	
 
CommandCost Vehicle::SendToDepot(uint32 flags, DepotCommand command)
 
{
 
	if (!CheckOwnership(this->owner)) return CMD_ERROR;
 
	if (this->vehstatus & VS_CRASHED) return CMD_ERROR;
 
	if (this->IsInDepot()) return CMD_ERROR;
 
	if (this->IsStoppedInDepot()) return CMD_ERROR;
 

	
 
	if (this->current_order.IsType(OT_GOTO_DEPOT)) {
 
		bool halt_in_depot = this->current_order.GetDepotActionType() & ODATFB_HALT;
 
		if (!!(command & DEPOT_SERVICE) == halt_in_depot) {
 
			/* We called with a different DEPOT_SERVICE setting.
 
			 * Now we change the setting to apply the new one and let the vehicle head for the same depot.
 
@@ -2521,16 +2521,12 @@ CommandCost Vehicle::SendToDepot(uint32 
 
			this->current_order.MakeDummy();
 
			InvalidateWindowWidget(WC_VEHICLE_VIEW, this->index, VVW_WIDGET_START_STOP_VEH);
 
		}
 
		return CommandCost();
 
	}
 

	
 
	/* check if at a standstill (not stopped only) in a depot
 
	 * the check is down here to make it possible to alter stop/service for trains entering the depot */
 
	if (this->type == VEH_TRAIN && IsRailDepotTile(this->tile) && this->cur_speed == 0) return CMD_ERROR;
 

	
 
	TileIndex location;
 
	DestinationID destination;
 
	bool reverse;
 
	static const StringID no_depot[] = {STR_883A_UNABLE_TO_FIND_ROUTE_TO, STR_9019_UNABLE_TO_FIND_LOCAL_DEPOT, STR_981A_UNABLE_TO_FIND_LOCAL_DEPOT, STR_A012_CAN_T_SEND_AIRCRAFT_TO};
 
	if (!this->FindClosestDepot(&location, &destination, &reverse)) return_cmd_error(no_depot[this->type]);
 

	
0 comments (0 inline, 0 general)