Codechange: rename CargoID to CargoType and amend related variables/comments
This commit is contained in:
@@ -107,7 +107,7 @@ struct CargoSpec {
|
||||
* Determines index of this cargospec
|
||||
* @return index (in the CargoSpec::array array)
|
||||
*/
|
||||
inline CargoID Index() const
|
||||
inline CargoType Index() const
|
||||
{
|
||||
return this - CargoSpec::array;
|
||||
}
|
||||
@@ -132,9 +132,9 @@ struct CargoSpec {
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve cargo details for the given cargo ID
|
||||
* Retrieve cargo details for the given cargo type
|
||||
* @param index ID of cargo
|
||||
* @pre index is a valid cargo ID
|
||||
* @pre index is a valid cargo type
|
||||
*/
|
||||
static inline CargoSpec *Get(size_t index)
|
||||
{
|
||||
@@ -199,11 +199,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.
|
||||
static inline std::map<CargoLabel, CargoType> label_map{}; ///< Translation map from CargoLabel to Cargo type.
|
||||
|
||||
friend void SetupCargoForClimate(LandscapeID l);
|
||||
friend void BuildCargoLabelMap();
|
||||
friend inline CargoID GetCargoIDByLabel(CargoLabel ct);
|
||||
friend inline CargoType GetCargoTypeByLabel(CargoLabel ct);
|
||||
friend void FinaliseCargoArray();
|
||||
};
|
||||
|
||||
@@ -211,12 +211,12 @@ extern CargoTypes _cargo_mask;
|
||||
extern CargoTypes _standard_cargo_mask;
|
||||
|
||||
void SetupCargoForClimate(LandscapeID l);
|
||||
bool IsDefaultCargo(CargoID cid);
|
||||
bool IsDefaultCargo(CargoType cargo_type);
|
||||
void BuildCargoLabelMap();
|
||||
|
||||
std::optional<std::string> BuildCargoAcceptanceString(const CargoArray &acceptance, StringID label);
|
||||
|
||||
inline CargoID GetCargoIDByLabel(CargoLabel label)
|
||||
inline CargoType GetCargoTypeByLabel(CargoLabel label)
|
||||
{
|
||||
auto found = CargoSpec::label_map.find(label);
|
||||
if (found != std::end(CargoSpec::label_map)) return found->second;
|
||||
@@ -236,16 +236,16 @@ extern std::span<const CargoSpec *> _sorted_standard_cargo_specs;
|
||||
* @param cc Cargo class.
|
||||
* @return The type fits in the class.
|
||||
*/
|
||||
inline bool IsCargoInClass(CargoID c, CargoClass cc)
|
||||
inline bool IsCargoInClass(CargoType c, CargoClass cc)
|
||||
{
|
||||
return (CargoSpec::Get(c)->classes & cc) != 0;
|
||||
}
|
||||
|
||||
using SetCargoBitIterator = SetBitIterator<CargoID, CargoTypes>;
|
||||
using SetCargoBitIterator = SetBitIterator<CargoType, CargoTypes>;
|
||||
|
||||
/** Comparator to sort CargoID by according to desired order. */
|
||||
struct CargoIDComparator {
|
||||
bool operator() (const CargoID &lhs, const CargoID &rhs) const { return _sorted_cargo_types[lhs] < _sorted_cargo_types[rhs]; }
|
||||
/** Comparator to sort CargoType by according to desired order. */
|
||||
struct CargoTypeComparator {
|
||||
bool operator() (const CargoType &lhs, const CargoType &rhs) const { return _sorted_cargo_types[lhs] < _sorted_cargo_types[rhs]; }
|
||||
};
|
||||
|
||||
#endif /* CARGOTYPE_H */
|
||||
|
||||
Reference in New Issue
Block a user