OpenTTD

vehiclelist.h
Go to the documentation of this file.
1 /* $Id: vehiclelist.h 27677 2016-11-05 19:16:59Z frosch $ */
2
3 /*
4 * This file is part of OpenTTD.
5 * 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.
6 * 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.
7 * 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 */
9
12 #ifndef VEHICLELIST_H
13 #define VEHICLELIST_H
14
15 #include "core/smallvec_type.hpp"
16 #include "vehicle_type.h"
17 #include "company_type.h"
18 #include "tile_type.h"
19
21 enum VehicleListType {
22 VL_STANDARD,
23 VL_SHARED_ORDERS,
24 VL_STATION_LIST,
25 VL_DEPOT_LIST,
26 VL_GROUP_LIST,
27 VLT_END
28 };
29
31 struct VehicleListIdentifier {
32 VehicleListType type;
33 VehicleType vtype;
34 CompanyID company;
35 uint32 index;
36
37 uint32 Pack() const;
38 bool UnpackIfValid(uint32 data);
39 static VehicleListIdentifier UnPack(uint32 data);
40
48 VehicleListIdentifier(VehicleListType type, VehicleType vtype, CompanyID company, uint index = 0) :
49 type(type), vtype(vtype), company(company), index(index) {}
50
51 VehicleListIdentifier() : type(), vtype(), company(), index() {}
52 };
53
55 typedef SmallVector<const Vehicle *, 32> VehicleList;
56
57 bool GenerateVehicleSortList(VehicleList *list, const VehicleListIdentifier &identifier);
58 void BuildDepotVehicleList(VehicleType type, TileIndex tile, VehicleList *engine_list, VehicleList *wagon_list, bool individual_wagons = false);
59 uint GetUnitNumberDigits(VehicleList &vehicles);
60
61 #endif /* VEHICLELIST_H */
VehicleListIdentifier::company
CompanyID company
The company associated with this list.
Definition: vehiclelist.h:34
VehicleList
SmallVector< const Vehicle *, 32 > VehicleList
A list of vehicles.
Definition: vehiclelist.h:55
VehicleListIdentifier
The information about a vehicle list.
Definition: vehiclelist.h:31
smallvec_type.hpp
Simple vector class that allows allocating an item without the need to copy this->data needlessly...
VehicleListIdentifier::UnpackIfValid
bool UnpackIfValid(uint32 data)
Unpack a VehicleListIdentifier from a single uint32.
Definition: vehiclelist.cpp:40
SmallVector< const Vehicle *, 32 >
VehicleListIdentifier::VehicleListIdentifier
VehicleListIdentifier(VehicleListType type, VehicleType vtype, CompanyID company, uint index=0)
Create a simple vehicle list.
Definition: vehiclelist.h:48
VehicleType
VehicleType
Available vehicle types.
Definition: vehicle_type.h:21
VehicleListIdentifier::index
uint32 index
A vehicle list type specific index.
Definition: vehiclelist.h:35
BuildDepotVehicleList
void BuildDepotVehicleList(VehicleType type, TileIndex tile, VehicleList *engine_list, VehicleList *wagon_list, bool individual_wagons=false)
Generate a list of vehicles inside a depot.
Definition: vehiclelist.cpp:71
VehicleListIdentifier::UnPack
static VehicleListIdentifier UnPack(uint32 data)
Decode a packed vehicle list identifier into a new one.
Definition: vehiclelist.cpp:55
GenerateVehicleSortList
bool GenerateVehicleSortList(VehicleList *list, const VehicleListIdentifier &identifier)
Generate a list of vehicles based on window type.
Definition: vehiclelist.cpp:116
TileIndex
uint32 TileIndex
The index/ID of a Tile.
Definition: tile_type.h:80
VehicleListIdentifier::Pack
uint32 Pack() const
Pack a VehicleListIdentifier in a single uint32.
Definition: vehiclelist.cpp:23
VehicleListIdentifier::type
VehicleListType type
The type of vehicle list.
Definition: vehiclelist.h:32
vehicle_type.h
Types related to vehicles.
VehicleListType
VehicleListType
Vehicle List type flags.
Definition: vehiclelist.h:21
company_type.h
Types related to companies.
GetUnitNumberDigits
uint GetUnitNumberDigits(VehicleList &vehicles)
Get the number of digits the biggest unit number of a set of vehicles has.
Definition: vehicle_gui.cpp:106
Owner
Owner
Enum for all companies/owners.
Definition: company_type.h:20
tile_type.h
Types related to tiles.
VehicleListIdentifier::vtype
VehicleType vtype
The vehicle type associated with this list.
Definition: vehiclelist.h:33