OpenTTD Source: src/vehiclelist.h Source File

OpenTTD Source 14.0-beta3

vehiclelist.h
Go to the documentation of this file.
1 /*
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/>.
6 */
7
10 #ifndef VEHICLELIST_H
11 #define VEHICLELIST_H
12
13 #include "vehicle_type.h"
14 #include "company_type.h"
15 #include "tile_type.h"
16
18 enum VehicleListType : byte {
19 VL_STANDARD,
20 VL_SHARED_ORDERS,
21 VL_STATION_LIST,
22 VL_DEPOT_LIST,
23 VL_GROUP_LIST,
24 VLT_END
25 };
26
28 struct VehicleListIdentifier {
29 VehicleListType type;
30 VehicleType vtype;
31 CompanyID company;
32 uint32_t index;
33
34 uint32_t Pack() const;
35 bool UnpackIfValid(uint32_t data);
36 static VehicleListIdentifier UnPack(uint32_t data);
37
38 bool Valid() const { return this->type < VLT_END; }
39
47 VehicleListIdentifier(VehicleListType type, VehicleType vtype, CompanyID company, uint index = 0) :
48 type(type), vtype(vtype), company(company), index(index) {}
49
50 VehicleListIdentifier() : type(), vtype(), company(), index() {}
51 };
52
54 typedef std::vector<const Vehicle *> VehicleList;
55
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);
59
60 #endif /* VEHICLELIST_H */
VehicleListType
VehicleListType
Vehicle List type flags.
Definition: vehiclelist.h:18
VehicleListIdentifier::VehicleListIdentifier
VehicleListIdentifier(VehicleListType type, VehicleType vtype, CompanyID company, uint index=0)
Create a simple vehicle list.
Definition: vehiclelist.h:47
VehicleList
std::vector< const Vehicle * > VehicleList
A list of vehicles.
Definition: vehiclelist.h:54
VehicleListIdentifier::company
CompanyID company
The company associated with this list.
Definition: vehiclelist.h:31
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:70
VehicleListIdentifier
The information about a vehicle list.
Definition: vehiclelist.h:28
StrongType::Typedef< uint32_t, struct TileIndexTag, StrongType::Compare, StrongType::Integer, StrongType::Compatible< int32_t >, StrongType::Compatible< int64_t > >
Owner
Owner
Enum for all companies/owners.
Definition: company_type.h:18
GenerateVehicleSortList
bool GenerateVehicleSortList(VehicleList *list, const VehicleListIdentifier &identifier)
Generate a list of vehicles based on window type.
Definition: vehiclelist.cpp:114
VehicleListIdentifier::index
uint32_t index
A vehicle list type specific index.
Definition: vehiclelist.h:32
VehicleListIdentifier::Pack
uint32_t Pack() const
Pack a VehicleListIdentifier in a single uint32.
Definition: vehiclelist.cpp:22
VehicleType
VehicleType
Available vehicle types.
Definition: vehicle_type.h:21
GetUnitNumberDigits
uint GetUnitNumberDigits(VehicleList &vehicles)
Get the number of digits the biggest unit number of a set of vehicles has.
Definition: vehicle_gui.cpp:212
vehicle_type.h
tile_type.h
VehicleListIdentifier::vtype
VehicleType vtype
The vehicle type associated with this list.
Definition: vehiclelist.h:30
VehicleListIdentifier::type
VehicleListType type
The type of vehicle list.
Definition: vehiclelist.h:29
VehicleListIdentifier::UnPack
static VehicleListIdentifier UnPack(uint32_t data)
Decode a packed vehicle list identifier into a new one.
Definition: vehiclelist.cpp:54
VehicleListIdentifier::UnpackIfValid
bool UnpackIfValid(uint32_t data)
Unpack a VehicleListIdentifier from a single uint32.
Definition: vehiclelist.cpp:39
company_type.h