rubidium@9405: /* $Id$ */ rubidium@9405: rubidium@9405: /** @file ai_cargo.hpp Everything to query about 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: rubidium@9405: /** rubidium@9472: * Checks whether the given cargo type is valid. rubidium@9472: * @param cargo_type the cargo to check. rubidium@9472: * @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. truelight@9447: * @param cargo_type to get the string representation of. truelight@9447: * @return the cargo label. truelight@9447: * @note the returned cargo label must be free'd (C++ only). rubidium@9405: */ rubidium@9405: char *GetCargoLabel(CargoID cargo_type); rubidium@9405: rubidium@9405: /** truelight@9447: * Checks whether the give cargo is a freight or not. rubidium@9405: * @param cargo_type is this cargo freight or not? truelight@9447: * @return true if and only if the cargo is freight. rubidium@9405: */ rubidium@9405: bool IsFreight(CargoID cargo_type); rubidium@9405: rubidium@9405: /** rubidium@9405: * Get the income for transporting a piece of cargo over the truelight@9447: * given distance within the specified time. truelight@9447: * @param distance the distance the cargo travels from begin to end. truelight@9447: * @param days_in_transit amount of (game) days the cargo is in transit. truelight@9447: * @param cargo_type the cargo to transport. truelight@9447: * @return the amount of money that would be earned by this trip. rubidium@9405: */ rubidium@9405: int32 GetCargoIncome(uint32 distance, uint32 days_in_transit, CargoID cargo_type); rubidium@9405: }; rubidium@9405: truelight@9425: #ifdef DEFINE_SQUIRREL_CLASS truelight@9422: void SQAICargoRegister(Squirrel *engine) { rubidium@9405: DefSQClass SQAICargo("AICargo"); rubidium@9405: SQAICargo.PreRegister(engine); rubidium@9405: SQAICargo.AddConstructor(engine); rubidium@9472: SQAICargo.DefSQFunction(engine, &AICargo::IsValidCargo, "IsValidCargo"); rubidium@9405: SQAICargo.DefSQFunction(engine, &AICargo::GetCargoLabel, "GetCargoLabel"); rubidium@9405: SQAICargo.DefSQFunction(engine, &AICargo::IsFreight, "IsFreight"); rubidium@9405: SQAICargo.DefSQFunction(engine, &AICargo::GetCargoIncome, "GetCargoIncome"); rubidium@9405: SQAICargo.PostRegister(engine); rubidium@9405: } rubidium@9405: #endif /* SQUIRREL_CLASS */ rubidium@9405: rubidium@9405: #endif /* AI_CARGO_HPP */