OpenTTD Source
20240919-master-gdf0233f4c2
|
#include "stdafx.h"
#include "cargotype.h"
#include "core/geometry_func.hpp"
#include "newgrf_cargo.h"
#include "string_func.h"
#include "strings_func.h"
#include "settings_type.h"
#include "table/sprites.h"
#include "table/strings.h"
#include "table/cargo_const.h"
#include "safeguards.h"
Go to the source code of this file.
Functions | |
void | SetupCargoForClimate (LandscapeID l) |
Set up the default cargo types for the given landscape type. More... | |
void | BuildCargoLabelMap () |
Build cargo label map. More... | |
bool | IsDefaultCargo (CargoID cid) |
Test if a cargo is a default cargo type. More... | |
Dimension | GetLargestCargoIconSize () |
Get dimensions of largest cargo icon. More... | |
CargoID | GetCargoIDByBitnum (uint8_t bitnum) |
Find the CargoID of a 'bitnum' value. More... | |
static bool | CargoSpecNameSorter (const CargoSpec *const &a, const CargoSpec *const &b) |
Sort cargo specifications by their name. | |
static bool | CargoSpecClassSorter (const CargoSpec *const &a, const CargoSpec *const &b) |
Sort cargo specifications by their cargo class. | |
void | InitializeSortedCargoSpecs () |
Initialize the list of sorted cargo specifications. | |
Variables | |
CargoTypes | _cargo_mask |
Bitmask of cargo types available. More... | |
CargoTypes | _standard_cargo_mask |
Bitmask of real cargo types available. More... | |
static std::vector< CargoLabel > | _default_cargo_labels |
List of default cargo labels, used when setting up cargo types for default vehicles. More... | |
std::array< uint8_t, NUM_CARGO > | _sorted_cargo_types |
Sort order of cargoes by cargo ID. | |
std::vector< const CargoSpec * > | _sorted_cargo_specs |
Cargo specifications sorted alphabetically by name. | |
std::span< const CargoSpec * > | _sorted_standard_cargo_specs |
Standard cargo specifications sorted alphabetically by name. | |
Implementation of cargoes.
Definition in file cargotype.cpp.
void BuildCargoLabelMap | ( | ) |
Build cargo label map.
This is called multiple times during NewGRF initialization as cargos are defined, so that TranslateRefitMask() and GetCargoTranslation(), also used during initialization, get the correct information.
Definition at line 93 of file cargotype.cpp.
References CargoSpec::array, CT_INVALID, and CargoSpec::label_map.
CargoID GetCargoIDByBitnum | ( | uint8_t | bitnum | ) |
Find the CargoID of a 'bitnum' value.
bitnum | 'bitnum' to find. |
Definition at line 138 of file cargotype.cpp.
References INVALID_CARGO_BITNUM.
Dimension GetLargestCargoIconSize | ( | ) |
Get dimensions of largest cargo icon.
Definition at line 124 of file cargotype.cpp.
References _sorted_cargo_specs, GetSpriteSize(), and maxdim().
Referenced by SubsidyListWindow::OnInit(), and IndustryViewWindow::OnInit().
bool IsDefaultCargo | ( | CargoID | cid | ) |
Test if a cargo is a default cargo type.
cid | Cargo ID. |
Definition at line 111 of file cargotype.cpp.
References _default_cargo_labels, and CargoSpec::Get().
Referenced by CalculateRefitMasks().
void SetupCargoForClimate | ( | LandscapeID | l | ) |
Set up the default cargo types for the given landscape type.
l | Landscape |
Definition at line 48 of file cargotype.cpp.
References _cargo_mask, _default_cargo, _default_cargo_labels, _default_climate_cargo, CargoSpec::array, CargoSpec::label, and lengthof.
CargoTypes _cargo_mask |
Bitmask of cargo types available.
This includes phony cargoes like regearing cargoes. Initialized during a call to SetupCargoForClimate.
Definition at line 31 of file cargotype.cpp.
Referenced by SetupCargoForClimate().
|
static |
List of default cargo labels, used when setting up cargo types for default vehicles.
This is done by label so that a cargo label can be redefined in a different slot.
Definition at line 42 of file cargotype.cpp.
Referenced by IsDefaultCargo(), and SetupCargoForClimate().
CargoTypes _standard_cargo_mask |
Bitmask of real cargo types available.
Phony cargoes like regearing cargoes are excluded.
Definition at line 36 of file cargotype.cpp.
Referenced by CargoAndEngineFilter(), InitializeSortedCargoSpecs(), and BuildVehicleWindow::SetCargoFilterArray().