src/cargotype.h
branchcpp_gui
changeset 6303 84c215fc8eb8
parent 6298 c30fe89622df
child 6307 f40e88cff863
equal deleted inserted replaced
6302:bd80897189ba 6303:84c215fc8eb8
     5 #ifndef CARGOTYPE_H
     5 #ifndef CARGOTYPE_H
     6 #define CARGOTYPE_H
     6 #define CARGOTYPE_H
     7 
     7 
     8 
     8 
     9 typedef uint32 CargoLabel;
     9 typedef uint32 CargoLabel;
       
    10 
       
    11 enum TownEffect {
       
    12 	TE_NONE,
       
    13 	TE_PASSENGERS,
       
    14 	TE_MAIL,
       
    15 	TE_GOODS,
       
    16 	TE_WATER,
       
    17 	TE_FOOD,
       
    18 };
    10 
    19 
    11 
    20 
    12 struct CargoSpec {
    21 struct CargoSpec {
    13 	uint8 bitnum;
    22 	uint8 bitnum;
    14 	CargoLabel label;
    23 	CargoLabel label;
    18 	uint8 weight;
    27 	uint8 weight;
    19 	uint16 initial_payment;
    28 	uint16 initial_payment;
    20 	uint8 transit_days[2];
    29 	uint8 transit_days[2];
    21 
    30 
    22 	bool is_freight;
    31 	bool is_freight;
    23 	uint8 substitutetowngrowth;
    32 	TownEffect town_effect; ///< The effect this cargo type has on towns
    24 	uint16 multipliertowngrowth;
    33 	uint16 multipliertowngrowth;
    25 	uint8 callbackflags;
    34 	uint8 callback_mask;
    26 
    35 
    27 	StringID name;
    36 	StringID name;
    28 	StringID name_plural;
    37 	StringID name_plural;
    29 	StringID units_volume;
    38 	StringID units_volume;
    30 	StringID quantifier;
    39 	StringID quantifier;
    31 	StringID abbrev;
    40 	StringID abbrev;
    32 
    41 
    33 	SpriteID sprite;
    42 	SpriteID sprite;
    34 
    43 
    35 	uint16 classes;
    44 	uint16 classes;
       
    45 	const struct SpriteGroup *group;
    36 
    46 
    37 	bool IsValid() const;
    47 	bool IsValid() const;
    38 };
    48 };
    39 
    49 
    40 
    50 
    41 extern uint32 _cargo_mask;
    51 extern uint32 _cargo_mask;
       
    52 extern CargoSpec _cargo[NUM_CARGO];
    42 
    53 
    43 
    54 
    44 /* Set up the default cargo types for the given landscape type */
    55 /* Set up the default cargo types for the given landscape type */
    45 void SetupCargoForClimate(LandscapeID l);
    56 void SetupCargoForClimate(LandscapeID l);
    46 /* Retrieve cargo details for the given cargo ID */
    57 /* Retrieve cargo details for the given cargo ID */
    47 const CargoSpec *GetCargo(CargoID c);
    58 const CargoSpec *GetCargo(CargoID c);
    48 /* Get the cargo ID with the cargo label */
    59 /* Get the cargo ID with the cargo label */
    49 CargoID GetCargoIDByLabel(CargoLabel cl);
    60 CargoID GetCargoIDByLabel(CargoLabel cl);
    50 
    61 
       
    62 static inline bool IsCargoInClass(CargoID c, uint16 cc)
       
    63 {
       
    64 	return (GetCargo(c)->classes & cc) != 0;
       
    65 }
       
    66 
    51 
    67 
    52 #endif /* CARGOTYPE_H */
    68 #endif /* CARGOTYPE_H */