OpenTTD Source 20250312-master-gcdcc6b491d
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 "company_type.h"
14#include "group_type.h"
15#include "order_type.h"
16#include "station_type.h"
17#include "tile_type.h"
18#include "vehicle_type.h"
19#include "window_type.h"
20
30
36 uint32_t index;
37
39
40 bool Valid() const { return this->type < VLT_END; }
41
42 constexpr CompanyID ToCompanyID() const { assert(this->type == VL_STANDARD); return CompanyID(this->index); }
43 constexpr DestinationID ToDestinationID() const { assert(this->type == VL_DEPOT_LIST); return DestinationID(this->index); }
44 constexpr GroupID ToGroupID() const { assert(this->type == VL_GROUP_LIST); return GroupID(this->index); }
45 constexpr StationID ToStationID() const { assert(this->type == VL_STATION_LIST); return StationID(this->index); }
46 constexpr VehicleID ToVehicleID() const { assert(this->type == VL_SHARED_ORDERS); return VehicleID(this->index); }
47
48 constexpr void SetIndex(uint32_t index) { this->index = index; }
49 constexpr void SetIndex(ConvertibleThroughBase auto index) { this->index = index.base(); }
50
60
62 type(type), vtype(vtype), company(company), index(index.base()) {}
63
64 VehicleListIdentifier() = default;
65};
66
68typedef std::vector<const Vehicle *> VehicleList;
69
70bool GenerateVehicleSortList(VehicleList *list, const VehicleListIdentifier &identifier);
71void BuildDepotVehicleList(VehicleType type, TileIndex tile, VehicleList *engine_list, VehicleList *wagon_list, bool individual_wagons = false);
72uint GetUnitNumberDigits(VehicleList &vehicles);
73
74#endif /* VEHICLELIST_H */
Types related to companies.
A type is considered 'convertible through base()' when it has a 'base()' function that returns someth...
Types of a group.
Types related to orders.
Types related to stations.
The information about a vehicle list.
Definition vehiclelist.h:32
VehicleListType type
The type of vehicle list.
Definition vehiclelist.h:33
CompanyID company
The company associated with this list.
Definition vehiclelist.h:35
WindowNumber ToWindowNumber() const
Pack a VehicleListIdentifier in 32 bits so it can be used as unique WindowNumber.
VehicleType vtype
The vehicle type associated with this list.
Definition vehiclelist.h:34
VehicleListIdentifier(VehicleListType type, VehicleType vtype, CompanyID company, uint index=0)
Create a simple vehicle list.
Definition vehiclelist.h:58
uint32_t index
A vehicle list type specific index.
Definition vehiclelist.h:36
Number to differentiate different windows of the same class.
Types related to tiles.
Types related to vehicles.
PoolID< uint32_t, struct VehicleIDTag, 0xFF000, 0xFFFFF > VehicleID
The type all our vehicle IDs have.
VehicleType
Available vehicle types.
uint GetUnitNumberDigits(VehicleList &vehicles)
Get the number of digits the biggest unit number of a set of vehicles has.
std::vector< const Vehicle * > VehicleList
A list of vehicles.
Definition vehiclelist.h:68
void BuildDepotVehicleList(VehicleType type, TileIndex tile, VehicleList *engine_list, VehicleList *wagon_list, bool individual_wagons=false)
Generate a list of vehicles inside a depot.
bool GenerateVehicleSortList(VehicleList *list, const VehicleListIdentifier &identifier)
Generate a list of vehicles based on window type.
VehicleListType
Vehicle List type flags.
Definition vehiclelist.h:22
@ VL_GROUP_LIST
Index is the group.
Definition vehiclelist.h:27
@ VL_STANDARD
Index is the company.
Definition vehiclelist.h:23
@ VL_STATION_LIST
Index is the station.
Definition vehiclelist.h:25
@ VL_DEPOT_LIST
Index is the destination (station for hangar of aircraft, depot for others)
Definition vehiclelist.h:26
@ VL_SHARED_ORDERS
Index is the first vehicle of the shared orders.
Definition vehiclelist.h:24
Types related to windows.