|
@@ -64,78 +64,78 @@ struct CargoSpec {
|
|
|
|
|
|
bool is_freight; ///< Cargo type is considered to be freight (affects train freight multiplier).
|
|
|
TownEffect town_effect; ///< The effect that delivering this cargo type has on towns. Also affects destination of subsidies.
|
|
|
uint16 multipliertowngrowth; ///< Size of the effect.
|
|
|
uint8 callback_mask; ///< Bitmask of cargo callbacks that have to be called
|
|
|
|
|
|
StringID name; ///< Name of this type of cargo.
|
|
|
StringID name_single; ///< Name of a single entity of this type of cargo.
|
|
|
StringID units_volume; ///< Name of a single unit of cargo of this type.
|
|
|
StringID quantifier; ///< Text for multiple units of cargo of this type.
|
|
|
StringID abbrev; ///< Two letter abbreviation for this cargo type.
|
|
|
|
|
|
SpriteID sprite; ///< Icon to display this cargo type, may be \c 0xFFF (which means to resolve an action123 chain).
|
|
|
|
|
|
uint16 classes; ///< Classes of this cargo type. @see CargoClass
|
|
|
const struct GRFFile *grffile; ///< NewGRF where #group belongs to.
|
|
|
const struct SpriteGroup *group;
|
|
|
|
|
|
Money current_payment;
|
|
|
|
|
|
/**
|
|
|
* Determines index of this cargospec
|
|
|
* @return index (in the CargoSpec::array array)
|
|
|
*/
|
|
|
FORCEINLINE CargoID Index() const
|
|
|
inline CargoID Index() const
|
|
|
{
|
|
|
return this - CargoSpec::array;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Tests for validity of this cargospec
|
|
|
* @return is this cargospec valid?
|
|
|
* @note assert(cs->IsValid()) can be triggered when GRF config is modified
|
|
|
*/
|
|
|
FORCEINLINE bool IsValid() const
|
|
|
inline bool IsValid() const
|
|
|
{
|
|
|
return this->bitnum != INVALID_CARGO;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Total number of cargospecs, both valid and invalid
|
|
|
* @return length of CargoSpec::array
|
|
|
*/
|
|
|
static FORCEINLINE size_t GetArraySize()
|
|
|
static inline size_t GetArraySize()
|
|
|
{
|
|
|
return lengthof(CargoSpec::array);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Retrieve cargo details for the given cargo ID
|
|
|
* @param index ID of cargo
|
|
|
* @pre index is a valid cargo ID
|
|
|
*/
|
|
|
static FORCEINLINE CargoSpec *Get(size_t index)
|
|
|
static inline CargoSpec *Get(size_t index)
|
|
|
{
|
|
|
assert(index < lengthof(CargoSpec::array));
|
|
|
return &CargoSpec::array[index];
|
|
|
}
|
|
|
|
|
|
SpriteID GetCargoIcon() const;
|
|
|
|
|
|
private:
|
|
|
static CargoSpec array[NUM_CARGO]; ///< Array holding all CargoSpecs
|
|
|
|
|
|
friend void SetupCargoForClimate(LandscapeID l);
|
|
|
};
|
|
|
|
|
|
extern uint32 _cargo_mask;
|
|
|
|
|
|
void SetupCargoForClimate(LandscapeID l);
|
|
|
CargoID GetCargoIDByLabel(CargoLabel cl);
|
|
|
CargoID GetCargoIDByBitnum(uint8 bitnum);
|
|
|
|
|
|
void InitializeSortedCargoSpecs();
|
|
|
extern const CargoSpec *_sorted_cargo_specs[NUM_CARGO];
|
|
|
extern uint8 _sorted_cargo_specs_size;
|
|
|
extern uint8 _sorted_standard_cargo_specs_size;
|
|
|
|