2 * This file is part of OpenTTD.
3 * 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.
4 * 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.
5 * 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/>.
8 /** @file vehiclelist.h Functions and type for generating vehicle lists. */
13 #include "vehicle_type.h"
14 #include "company_type.h"
15 #include "tile_type.h"
17 /** Vehicle List type flags */
18 enum VehicleListType
: uint8_t {
27 /** The information about a vehicle list. */
28 struct VehicleListIdentifier
{
29 VehicleListType type
; ///< The type of vehicle list.
30 VehicleType vtype
; ///< The vehicle type associated with this list.
31 CompanyID company
; ///< The company associated with this list.
32 uint32_t index
; ///< A vehicle list type specific index.
34 uint32_t Pack() const;
35 bool UnpackIfValid(uint32_t data
);
36 static VehicleListIdentifier
UnPack(uint32_t data
);
38 bool Valid() const { return this->type
< VLT_END
; }
41 * Create a simple vehicle list.
42 * @param type List type.
43 * @param vtype Vehicle type associated with this list.
44 * @param company Company associated with this list.
45 * @param index Optional type specific index.
47 VehicleListIdentifier(VehicleListType type
, VehicleType vtype
, CompanyID company
, uint index
= 0) :
48 type(type
), vtype(vtype
), company(company
), index(index
) {}
50 VehicleListIdentifier() : type(), vtype(), company(), index() {}
53 /** A list of vehicles. */
54 typedef std::vector
<const Vehicle
*> VehicleList
;
56 bool GenerateVehicleSortList(VehicleList
*list
, const VehicleListIdentifier
&identifier
);
57 void BuildDepotVehicleList(VehicleType type
, TileIndex tile
, VehicleList
*engine_list
, VehicleList
*wagon_list
, bool individual_wagons
= false);
58 uint
GetUnitNumberDigits(VehicleList
&vehicles
);
60 #endif /* VEHICLELIST_H */