src/ai/api/ai_cargo.hpp
author truelight
Tue, 20 Mar 2007 00:14:29 +0000
branchnoai
changeset 9490 999eb7531205
parent 9472 063c3f50972a
child 9520 f7cf8bea10db
permissions -rw-r--r--
(svn r9360) [NoAI] -Add: class-functions can now be static and still be added to SQ. There they behave as they are non-static, which is fine for that level of coding.
-Change: changed IsValidCargo to a static member
/* $Id$ */

/** @file ai_cargo.hpp Everything to query about cargos */

#ifndef AI_CARGO_HPP
#define AI_CARGO_HPP

#include "ai_object.hpp"

/**
 * Class that handles all cargo related functions.
 */
class AICargo : public AIObject {
public:
	/**
	 * Checks whether the given cargo type is valid.
	 * @param cargo_type the cargo to check.
	 * @return true if and only if the cargo type is valid.
	 */
	static bool IsValidCargo(CargoID cargo_type);

	/**
	 * Gets the string representation of the cargo label.
	 * @param cargo_type to get the string representation of.
	 * @return the cargo label.
	 * @note the returned cargo label must be free'd (C++ only).
	 */
	char *GetCargoLabel(CargoID cargo_type);

	/**
	 * Checks whether the give cargo is a freight or not.
	 * @param cargo_type is this cargo freight or not?
	 * @return true if and only if the cargo is freight.
	 */
	bool IsFreight(CargoID cargo_type);

	/**
	 * Get the income for transporting a piece of cargo over the
	 *   given distance within the specified time.
	 * @param distance the distance the cargo travels from begin to end.
	 * @param days_in_transit amount of (game) days the cargo is in transit.
	 * @param cargo_type the cargo to transport.
	 * @return the amount of money that would be earned by this trip.
	 */
	int32 GetCargoIncome(uint32 distance, uint32 days_in_transit, CargoID cargo_type);
};

#ifdef DEFINE_SQUIRREL_CLASS
void SQAICargoRegister(Squirrel *engine) {
	DefSQClass <AICargo> SQAICargo("AICargo");
	SQAICargo.PreRegister(engine);
	SQAICargo.AddConstructor(engine);
	SQAICargo.DefSQFunction(engine, &AICargo::IsValidCargo,   "IsValidCargo");
	SQAICargo.DefSQFunction(engine, &AICargo::GetCargoLabel,  "GetCargoLabel");
	SQAICargo.DefSQFunction(engine, &AICargo::IsFreight,      "IsFreight");
	SQAICargo.DefSQFunction(engine, &AICargo::GetCargoIncome, "GetCargoIncome");
	SQAICargo.PostRegister(engine);
}
#endif /* SQUIRREL_CLASS */

#endif /* AI_CARGO_HPP */