src/train_cmd.cpp
changeset 6998 403314de0154
parent 6987 b0f13039bda2
child 7042 d841fb0d8e9a
equal deleted inserted replaced
6997:bc9de79c355c 6998:403314de0154
  1983 
  1983 
  1984 	TrainFindDepotData tfdd = FindClosestTrainDepot(v, 0);
  1984 	TrainFindDepotData tfdd = FindClosestTrainDepot(v, 0);
  1985 	if (tfdd.best_length == (uint)-1) return_cmd_error(STR_883A_UNABLE_TO_FIND_ROUTE_TO);
  1985 	if (tfdd.best_length == (uint)-1) return_cmd_error(STR_883A_UNABLE_TO_FIND_ROUTE_TO);
  1986 
  1986 
  1987 	if (flags & DC_EXEC) {
  1987 	if (flags & DC_EXEC) {
       
  1988 		if (v->current_order.type == OT_LOADING) v->LeaveStation();
       
  1989 
  1988 		v->dest_tile = tfdd.tile;
  1990 		v->dest_tile = tfdd.tile;
  1989 		v->current_order.type = OT_GOTO_DEPOT;
  1991 		v->current_order.type = OT_GOTO_DEPOT;
  1990 		v->current_order.flags = OF_NON_STOP;
  1992 		v->current_order.flags = OF_NON_STOP;
  1991 		if (!(p2 & DEPOT_SERVICE)) SETBIT(v->current_order.flags, OFB_HALT_IN_DEPOT);
  1993 		if (!(p2 & DEPOT_SERVICE)) SETBIT(v->current_order.flags, OFB_HALT_IN_DEPOT);
  1992 		v->current_order.dest = GetDepotByTile(tfdd.tile)->index;
  1994 		v->current_order.dest = GetDepotByTile(tfdd.tile)->index;
  1993 		v->current_order.refit_cargo = CT_INVALID;
  1995 		v->current_order.refit_cargo = CT_INVALID;
  1994 		InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
  1996 		InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
  1995 		/* If there is no depot in front, reverse automatically */
  1997 		/* If there is no depot in front, reverse automatically */
  1996 		if (tfdd.reverse)
  1998 		if (tfdd.reverse) DoCommand(v->tile, v->index, 0, DC_EXEC, CMD_REVERSE_TRAIN_DIRECTION);
  1997 			DoCommand(v->tile, v->index, 0, DC_EXEC, CMD_REVERSE_TRAIN_DIRECTION);
       
  1998 	}
  1999 	}
  1999 
  2000 
  2000 	return 0;
  2001 	return 0;
  2001 }
  2002 }
  2002 
  2003