Change: Decouple and remove landscape-dependent cargo types. (#11719)

Cargo types of default engines, industries and houses are now specified in terms of label.
This commit is contained in:
Peter Nelson
2024-02-04 10:16:08 +00:00
committed by GitHub
parent 83d63464db
commit 2fd9096070
32 changed files with 378 additions and 275 deletions

View File

@@ -17,9 +17,6 @@
#include "landscape_type.h"
#include "core/bitmath_func.hpp"
/** Globally unique label of a cargo type. */
typedef uint32_t CargoLabel;
/** Town growth effect when delivering cargo. */
enum TownAcceptanceEffect : byte {
TAE_BEGIN = 0,
@@ -194,8 +191,11 @@ struct CargoSpec {
private:
static CargoSpec array[NUM_CARGO]; ///< Array holding all CargoSpecs
static inline std::map<CargoLabel, CargoID> label_map{}; ///< Translation map from CargoLabel to Cargo ID.
friend void SetupCargoForClimate(LandscapeID l);
friend void BuildCargoLabelMap();
friend inline CargoID GetCargoIDByLabel(CargoLabel ct);
friend void FinaliseCargoArray();
};
@@ -203,9 +203,17 @@ extern CargoTypes _cargo_mask;
extern CargoTypes _standard_cargo_mask;
void SetupCargoForClimate(LandscapeID l);
CargoID GetCargoIDByLabel(CargoLabel cl);
bool IsDefaultCargo(CargoID cid);
void BuildCargoLabelMap();
CargoID GetCargoIDByBitnum(uint8_t bitnum);
CargoID GetDefaultCargoID(LandscapeID l, CargoType ct);
inline CargoID GetCargoIDByLabel(CargoLabel label)
{
auto found = CargoSpec::label_map.find(label);
if (found != std::end(CargoSpec::label_map)) return found->second;
return INVALID_CARGO;
}
Dimension GetLargestCargoIconSize();
void InitializeSortedCargoSpecs();