src/ai/api/ai_industry.hpp
author truebrain
Thu, 28 Feb 2008 01:11:23 +0000
branchnoai
changeset 9803 c86d5834fb11
parent 9801 03a3eebd7fb7
child 9810 a84fc1be9e3b
permissions -rw-r--r--
(svn r12309) [NoAI] -Codechange: optimize a little bit (a very small little bit, but every bit counts :) ) (glx)
/* $Id$ */

/** @file ai_industry.hpp Everything to query about industries */

#ifndef AI_INDUSTRY_HPP
#define AI_INDUSTRY_HPP

#include "ai_object.hpp"
#include "../../industry.h"

/**
 * Class that handles all industry related functions.
 */
class AIIndustry : public AIObject {
public:
	/**
	 * The name of the class, needed by several sub-processes.
	 */
	static const char *GetClassName() { return "AIIndustry"; }

	/**
	 * Gets the maximum industry index; there are no valid industries with a
	 *   higher index.
	 * @return the maximum industry index.
	 * @post return value is always non-negative.
	 */
	static IndustryID GetMaxIndustryID();

	/**
	 * Gets the number of industries. This is different than GetMaxIndustryID()
	 *   because of the way OpenTTD works internally.
	 * @return the number of industries.
	 * @post return value is always non-negative.
	 */
	static int32 GetIndustryCount();

	/**
	 * Checks whether the given industry index is valid.
	 * @param industry_id the index to check.
	 * @return true if and only if the industry is valid.
	 */
	static bool IsValidIndustry(IndustryID industry_id);

	/**
	 * Get the name of the industry.
	 * @param industry_id the industry to get the name of.
	 * @pre industry_id has to be valid (use IsValidIndustry()).
	 * @return the name of the industry.
	 * @note the returned name must be free'd (C++ only).
	 */
	static char *GetName(IndustryID industry_id);

	/**
	 * Gets the production of a cargo of the industry.
	 * @param industry_id the index of the industry.
	 * @param cargo_id the index of the cargo.
	 * @pre industry_id has to be valid (use IsValidIndustry()).
	 * @pre cargo_id has to be valid (use IsValidCargo()).
	 * @return the production of the cargo for this industry, or -1 if
	 *   this industry doesn't produce this cargo.
	 */
	static int32 GetProduction(IndustryID industry_id, CargoID cargo_id);

	/**
	 * See if an industry accepts a certain cargo.
	 * @param industry_id the index of the industry.
	 * @param cargo_id the index of the cargo.
	 * @pre industry_id has to be valid (use IsValidIndustry()).
	 * @pre cargo_id has to be valid (use IsValidCargo()).
	 * @return the production of the cargo for this industry.
	 */
	static bool IsCargoAccepted(IndustryID industry_id, CargoID cargo_id);

	/**
	 * Gets the location of the industry.
	 * @param industry_id the index of the industry.
	 * @pre industry_id has to be valid (use IsValidIndustry()).
	 * @return the location of the industry.
	 * @post return value is always valid with AIMap::IsValidTile().
	 */
	static TileIndex GetLocation(IndustryID industry_id);
};

#endif /* AI_INDUSTRY_HPP */