rubidium@9405: /* $Id$ */ rubidium@9405: truebrain@9829: /** @file ai_cargo.hpp Everything to query cargos. */ rubidium@9405: rubidium@9405: #ifndef AI_CARGO_HPP rubidium@9405: #define AI_CARGO_HPP rubidium@9405: rubidium@9405: #include "ai_object.hpp" rubidium@9405: truelight@9447: /** truelight@9447: * Class that handles all cargo related functions. truelight@9447: */ rubidium@9405: class AICargo : public AIObject { rubidium@9405: public: truelight@9529: static const char *GetClassName() { return "AICargo"; } truelight@9529: truelight@9529: /** truebrain@10675: * The classes of cargo (from newgrf_cargo.h). truebrain@10675: */ truebrain@10675: enum CargoClass { truebrain@10675: CC_PASSENGERS = 1 << 0, ///< Passengers truebrain@10675: CC_MAIL = 1 << 1, ///< Mail truebrain@10675: CC_EXPRESS = 1 << 2, ///< Express cargo (Goods, Food, Candy, but also possible for passengers) truebrain@10675: CC_ARMOURED = 1 << 3, ///< Armoured cargo (Valuables, Gold, Diamonds) truebrain@10675: CC_BULK = 1 << 4, ///< Bulk cargo (Coal, Grain etc., Ores, Fruit) truebrain@10675: CC_PIECE_GOODS = 1 << 5, ///< Piece goods (Livestock, Wood, Steel, Paper) truebrain@10675: CC_LIQUID = 1 << 6, ///< Liquids (Oil, Water, Rubber) truebrain@10675: CC_REFRIGERATED = 1 << 7, ///< Refrigerated cargo (Food, Fruit) truebrain@10675: CC_HAZARDOUS = 1 << 8, ///< Hazardous cargo (Nucleair Fuel, Explosives, etc.) truebrain@10675: CC_COVERED = 1 << 9, ///< Covered/Sheltered Freight (Transporation in Box Vans, Silo Wagons, etc.) truebrain@10675: }; truebrain@10675: truebrain@10675: /** truebrain@10831: * The effects a cargo can have on a town. truebrain@10831: */ truebrain@10831: enum TownEffect { truebrain@10831: TE_NONE = 0, ///< This cargo has no effect on a town truebrain@10831: TE_PASSENGERS = 1, ///< This cargo supplies passengers to a town truebrain@10831: TE_MAIL = 2, ///< This cargo supplies mail to a town truebrain@10831: TE_GOODS = 3, ///< This cargo supplies goods to a town truebrain@10831: TE_WATER = 4, ///< This cargo supplies water to a town truebrain@10831: TE_FOOD = 5, ///< This cargo supplies food to a town truebrain@10831: }; truebrain@10831: truebrain@10831: /** rubidium@9472: * Checks whether the given cargo type is valid. truebrain@9835: * @param cargo_type The cargo to check. truebrain@9835: * @return True if and only if the cargo type is valid. rubidium@9472: */ truelight@9490: static bool IsValidCargo(CargoID cargo_type); rubidium@9472: rubidium@9472: /** truelight@9447: * Gets the string representation of the cargo label. truebrain@9835: * @param cargo_type The cargo to get the string representation of. truebrain@9835: * @return The cargo label. truebrain@9835: * @note Never use this to check if it is a certain cargo. NewGRF can truebrain@9835: * redefine all of the names. rubidium@9405: */ truebrain@9737: static char *GetCargoLabel(CargoID cargo_type); rubidium@9405: rubidium@9405: /** truelight@9447: * Checks whether the give cargo is a freight or not. truebrain@9835: * @param cargo_type The cargo to check on. truebrain@9835: * @return True if and only if the cargo is freight. rubidium@9405: */ truebrain@9737: static bool IsFreight(CargoID cargo_type); rubidium@9405: rubidium@9405: /** truebrain@10675: * Check if this cargo is in the requested cargo class. truebrain@10675: * @param cargo_type The cargo to check on. truebrain@10675: * @param cargo_class The class to check for. truebrain@10675: * @return True if and only if the cargo is in the cargo class. truebrain@10675: */ truebrain@10675: static bool HasCargoClass(CargoID cargo_type, CargoClass cargo_class); truebrain@10675: truebrain@10675: /** truebrain@10831: * Get the effect this cargo has on a town. truebrain@10831: * @param cargo_type The cargo to check on. truebrain@10831: * @return The effect this cargo has on a town, or TE_NONE if it has no effect. truebrain@10831: */ truebrain@10831: static TownEffect GetTownEffect(CargoID cargo_type); truebrain@10831: truebrain@10831: /** rubidium@9405: * Get the income for transporting a piece of cargo over the truelight@9447: * given distance within the specified time. truebrain@9835: * @param cargo_type The cargo to transport. truebrain@9835: * @param distance The distance the cargo travels from begin to end. truebrain@9835: * @param days_in_transit Amount of (game) days the cargo is in transit. truebrain@9835: * @return The amount of money that would be earned by this trip. rubidium@9405: */ rubidium@10196: static Money GetCargoIncome(CargoID cargo_type, uint32 distance, uint32 days_in_transit); rubidium@9405: }; rubidium@9405: rubidium@9405: #endif /* AI_CARGO_HPP */