OpenTTD Source 20260711-master-g3fb3006dff
vehiclelist.h File Reference

Functions and type for generating vehicle lists. More...

#include "company_type.h"
#include "group_type.h"
#include "order_type.h"
#include "station_type.h"
#include "tile_type.h"
#include "vehicle_type.h"
#include "window_type.h"

Go to the source code of this file.

Data Structures

struct  VehicleListIdentifier
 The information about a vehicle list. More...

Typedefs

typedef std::vector< const Vehicle * > VehicleList
 A list of vehicles.

Enumerations

enum class  VehicleListType : uint8_t {
  Company , VehicleSharedOrders , Station , Depot ,
  Group , End
}
 Vehicle List type flags. More...

Functions

bool GenerateVehicleSortList (VehicleList *list, const VehicleListIdentifier &identifier)
 Generate a list of vehicles based on window type.
void BuildDepotVehicleList (VehicleType type, TileIndex tile, VehicleList *engine_list, VehicleList *wagon_list, bool individual_wagons=false)
 Generate a list of vehicles inside a depot.
uint GetUnitNumberDigits (VehicleList &vehicles)
 Get the number of digits the biggest unit number of a set of vehicles has.

Detailed Description

Functions and type for generating vehicle lists.

Definition in file vehiclelist.h.

Typedef Documentation

◆ VehicleList

typedef std::vector<const Vehicle *> VehicleList

A list of vehicles.

Definition at line 68 of file vehiclelist.h.

Enumeration Type Documentation

◆ VehicleListType

enum class VehicleListType : uint8_t
strong

Vehicle List type flags.

Enumerator
Company 

Index is the company.

VehicleSharedOrders 

Index is the first vehicle of the shared orders.

Station 

Index is the station.

Depot 

Index is the destination (station for hangar of aircraft, depot for others).

Group 

Index is the group.

End 

End marker.

Definition at line 22 of file vehiclelist.h.

Function Documentation

◆ BuildDepotVehicleList()

void BuildDepotVehicleList ( VehicleType type,
TileIndex tile,
VehicleList * engines,
VehicleList * wagons,
bool individual_wagons )

Generate a list of vehicles inside a depot.

Parameters
typeType of vehicle
tileThe tile the depot is located on
enginesPointer to list to add vehicles to
wagonsPointer to list to add wagons to (can be nullptr)
individual_wagonsIf true add every wagon to wagons which is not attached to an engine. If false only add the first wagon of every row.

Definition at line 43 of file vehiclelist.cpp.

References SpecializedVehicle< T, Type >::First(), SpecializedVehicle< Train, Type >::From(), Vehicle::IsArticulatedPart(), GroundVehicle< T, Type >::IsFreeWagon(), and Train.

Referenced by CmdDepotMassAutoReplace(), CmdDepotSellAllVehicles(), and CmdMassStartStopVehicle().

◆ GenerateVehicleSortList()

bool GenerateVehicleSortList ( VehicleList * list,
const VehicleListIdentifier & vli )

Generate a list of vehicles based on window type.

Parameters
listPointer to list to add vehicles to
vliThe identifier of this vehicle list.
Returns
false if invalid list is requested

Definition at line 69 of file vehiclelist.cpp.

References ALL_GROUP, Company, VehicleListIdentifier::company, Depot, FindVehiclesWithOrder(), Group, Vehicle::group_id, GroupIsInGroup(), Vehicle::IsPrimaryVehicle(), NearestDepot, Vehicle::NextShared(), Vehicle::owner, Station, BaseVehicle::type, VehicleListIdentifier::type, VehicleSharedOrders, and VehicleListIdentifier::vtype.

Referenced by CmdAddVehicleGroup(), CmdMassStartStopVehicle(), and SendAllVehiclesToDepot().

◆ GetUnitNumberDigits()

uint GetUnitNumberDigits ( VehicleList & vehicles)

Get the number of digits the biggest unit number of a set of vehicles has.

Parameters
vehiclesThe list of vehicles.
Returns
The number of digits to allocate space for.

Definition at line 210 of file vehicle_gui.cpp.

References CountDigitsForAllocatingSpace().

Referenced by DepotWindow::OnPaint().