/* $Id: departures_type.h $ */

/*
 * This file is part of OpenTTD.
 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
 */

/** @file departures_type.h Types related to departures. */

#ifndef DEPARTURES_TYPE_H
#define DEPARTURES_TYPE_H

#include "station_base.h"
#include "order_base.h"

/** Whether or not a vehicle has arrived for a departure. */
typedef enum {
	D_TRAVELLING = 0,
	D_ARRIVED    = 1,
	D_CANCELLED  = 2,
} DepartureStatus;

/** The type of departures. */
typedef enum {
	D_DEPARTURE = 0,
	D_ARRIVAL   = 1,
} DepartureType;

/** A scheduled departure. */
typedef struct Departure {
	DateTicks scheduled_date;              ///< The date this departure is scheduled to finish on (i.e. when the vehicle leaves the station)
	DateTicks lateness;                    ///< How delayed the departure is expected to be
	StationID terminus;                    ///< The station at which the vehicle will terminate following this departure
	StationID via;                         ///< The station the departure should list as going via
	SmallVector<StationID, 32> calling_at; ///< The stations both called at and unloaded at by the vehicle after this departure before it terminates
	DepartureStatus status;                ///< Whether the vehicle has arrived yet for this departure
	DepartureType type;                    ///< The type of the departure (departure or arrival)
	const Vehicle *vehicle;                ///< The vehicle performing this departure
	const Order *order;                    ///< The order corresponding to this departure
	Departure() : terminus(INVALID_STATION), via(INVALID_STATION), calling_at(), vehicle(NULL) { }
	~Departure()
	{
		calling_at.Reset();
	}
} Departure;

typedef SmallVector<Departure*, 32> DepartureList;

#endif /* DEPARTURES_TYPE_H */
