src/ai/api/ai_industry.hpp
branchnoai
changeset 9836 54afebfded49
parent 9829 80fbe02a4184
child 10300 f947a1d7e544
equal deleted inserted replaced
9835:2541c2d325ed 9836:54afebfded49
    16 	static const char *GetClassName() { return "AIIndustry"; }
    16 	static const char *GetClassName() { return "AIIndustry"; }
    17 
    17 
    18 	/**
    18 	/**
    19 	 * Gets the maximum industry index; there are no valid industries with a
    19 	 * Gets the maximum industry index; there are no valid industries with a
    20 	 *   higher index.
    20 	 *   higher index.
    21 	 * @return the maximum industry index.
    21 	 * @return The maximum industry index.
    22 	 * @post return value is always non-negative.
    22 	 * @post Return value is always non-negative.
    23 	 */
    23 	 */
    24 	static IndustryID GetMaxIndustryID();
    24 	static IndustryID GetMaxIndustryID();
    25 
    25 
    26 	/**
    26 	/**
    27 	 * Gets the number of industries. This is different than GetMaxIndustryID()
    27 	 * Gets the number of industries. This is different than GetMaxIndustryID()
    28 	 *   because of the way OpenTTD works internally.
    28 	 *   because of the way OpenTTD works internally.
    29 	 * @return the number of industries.
    29 	 * @return The number of industries.
    30 	 * @post return value is always non-negative.
    30 	 * @post Return value is always non-negative.
    31 	 */
    31 	 */
    32 	static int32 GetIndustryCount();
    32 	static int32 GetIndustryCount();
    33 
    33 
    34 	/**
    34 	/**
    35 	 * Checks whether the given industry index is valid.
    35 	 * Checks whether the given industry index is valid.
    36 	 * @param industry_id the index to check.
    36 	 * @param industry_id The index to check.
    37 	 * @return true if and only if the industry is valid.
    37 	 * @return True if and only if the industry is valid.
    38 	 */
    38 	 */
    39 	static bool IsValidIndustry(IndustryID industry_id);
    39 	static bool IsValidIndustry(IndustryID industry_id);
    40 
    40 
    41 	/**
    41 	/**
    42 	 * Get the name of the industry.
    42 	 * Get the name of the industry.
    43 	 * @param industry_id the industry to get the name of.
    43 	 * @param industry_id The industry to get the name of.
    44 	 * @pre industry_id has to be valid (use IsValidIndustry()).
    44 	 * @pre IsValidIndustry(industry_id).
    45 	 * @return the name of the industry.
    45 	 * @return The name of the industry.
    46 	 * @note the returned name must be free'd (C++ only).
       
    47 	 */
    46 	 */
    48 	static char *GetName(IndustryID industry_id);
    47 	static char *GetName(IndustryID industry_id);
    49 
    48 
    50 	/**
    49 	/**
    51 	 * Gets the production of a cargo of the industry.
    50 	 * Gets the production of a cargo of the industry.
    52 	 * @param industry_id the index of the industry.
    51 	 * @param industry_id The index of the industry.
    53 	 * @param cargo_id the index of the cargo.
    52 	 * @param cargo_id The index of the cargo.
    54 	 * @pre industry_id has to be valid (use IsValidIndustry()).
    53 	 * @pre IsValidIndustry(industry_id).
    55 	 * @pre cargo_id has to be valid (use IsValidCargo()).
    54 	 * @pre AICargo::IsValidCargo(cargo_id).
    56 	 * @return the production of the cargo for this industry, or -1 if
    55 	 * @return The production of the cargo for this industry, or -1 if
    57 	 *   this industry doesn't produce this cargo.
    56 	 *   this industry doesn't produce this cargo.
    58 	 */
    57 	 */
    59 	static int32 GetProduction(IndustryID industry_id, CargoID cargo_id);
    58 	static int32 GetProduction(IndustryID industry_id, CargoID cargo_id);
    60 
    59 
    61 	/**
    60 	/**
    62 	 * See if an industry accepts a certain cargo.
    61 	 * See if an industry accepts a certain cargo.
    63 	 * @param industry_id the index of the industry.
    62 	 * @param industry_id The index of the industry.
    64 	 * @param cargo_id the index of the cargo.
    63 	 * @param cargo_id The index of the cargo.
    65 	 * @pre industry_id has to be valid (use IsValidIndustry()).
    64 	 * @pre IsValidIndustry(industry_id).
    66 	 * @pre cargo_id has to be valid (use IsValidCargo()).
    65 	 * @pre AICargo::IsValidCargo(cargo_id).
    67 	 * @return the production of the cargo for this industry.
    66 	 * @return The production of the cargo for this industry.
    68 	 */
    67 	 */
    69 	static bool IsCargoAccepted(IndustryID industry_id, CargoID cargo_id);
    68 	static bool IsCargoAccepted(IndustryID industry_id, CargoID cargo_id);
    70 
    69 
    71 	/**
    70 	/**
    72 	 * Gets the location of the industry.
       
    73 	 * @param industry_id the index of the industry.
       
    74 	 * @pre industry_id has to be valid (use IsValidIndustry()).
       
    75 	 * @return the location of the industry.
       
    76 	 * @post return value is always valid with AIMap::IsValidTile().
       
    77 	 */
       
    78 	static TileIndex GetLocation(IndustryID industry_id);
       
    79 
       
    80 
       
    81 	/**
       
    82 	 * Get the total last month's production of the given cargo at an industry.
    71 	 * Get the total last month's production of the given cargo at an industry.
    83 	 * @param industry_id the index of the industry.
    72 	 * @param industry_id The index of the industry.
    84 	 * @param cargo_id the index of the cargo.
    73 	 * @param cargo_id The index of the cargo.
    85 	 * @pre industry_id has to be valid (use IsValidIndustry()).
    74 	 * @pre IsValidIndustry(industry_id).
    86 	 * @pre cargo_id has to be valid (use IsValidCargo()).
    75 	 * @pre AICargo::IsValidCargo(cargo_id).
    87 	 * @return the last month's production of the given cargo for this industry.
    76 	 * @return The last month's production of the given cargo for this industry.
    88 	 */
    77 	 */
    89 	static uint16 GetLastMonthProduction(IndustryID industry_id, CargoID cargo_id);
    78 	static uint16 GetLastMonthProduction(IndustryID industry_id, CargoID cargo_id);
    90 
    79 
    91 	/**
    80 	/**
    92 	 * Get the total amount of cargo transported from an industry last month.
    81 	 * Get the total amount of cargo transported from an industry last month.
    93 	 * @param industry_id the index of the industry.
    82 	 * @param industry_id The index of the industry.
    94 	 * @param cargo_id the index of the cargo.
    83 	 * @param cargo_id The index of the cargo.
    95 	 * @pre industry_id has to be valid (use IsValidIndustry()).
    84 	 * @pre IsValidIndustry(industry_id).
    96 	 * @pre cargo_id has to be valid (use IsValidCargo()).
    85 	 * @pre AICargo::IsValidCargo(cargo_id).
    97 	 * @return the amount of given cargo transported from this industry last month.
    86 	 * @return The amount of given cargo transported from this industry last month.
    98 	 */
    87 	 */
    99 	static uint16 GetLastMonthTransported(IndustryID industry_id, CargoID cargo_id);
    88 	static uint16 GetLastMonthTransported(IndustryID industry_id, CargoID cargo_id);
       
    89 
       
    90 	/**
       
    91 	 * Gets the location of the industry.
       
    92 	 * @param industry_id The index of the industry.
       
    93 	 * @pre IsValidIndustry(industry_id).
       
    94 	 * @return The location of the industry.
       
    95 	 */
       
    96 	static TileIndex GetLocation(IndustryID industry_id);
   100 
    97 
   101 	/**
    98 	/**
   102 	 * Get the manhattan distance from the tile to the AIIndustry::GetLocation()
    99 	 * Get the manhattan distance from the tile to the AIIndustry::GetLocation()
   103 	 *  of the industry.
   100 	 *  of the industry.
   104 	 * @param industry_id The industry to get the distance to.
   101 	 * @param industry_id The industry to get the distance to.
   105 	 * @param tile The tile to get the distance to.
   102 	 * @param tile The tile to get the distance to.
       
   103 	 * @pre IsValidIndustry(industry_id).
       
   104 	 * @pre AIMap::IsValidTile(tile).
   106 	 * @return The distance between industry and tile.
   105 	 * @return The distance between industry and tile.
   107 	 */
   106 	 */
   108 	static int32 GetDistanceManhattanToTile(IndustryID industry_id, TileIndex tile);
   107 	static int32 GetDistanceManhattanToTile(IndustryID industry_id, TileIndex tile);
   109 
   108 
   110 	/**
   109 	/**
   111 	 * Get the square distance from the tile to the AIIndustry::GetLocation()
   110 	 * Get the square distance from the tile to the AIIndustry::GetLocation()
   112 	 *  of the industry.
   111 	 *  of the industry.
   113 	 * @param industry_id The industry to get the distance to.
   112 	 * @param industry_id The industry to get the distance to.
   114 	 * @param tile The tile to get the distance to.
   113 	 * @param tile The tile to get the distance to.
       
   114 	 * @pre IsValidIndustry(industry_id).
       
   115 	 * @pre AIMap::IsValidTile(tile).
   115 	 * @return The distance between industry and tile.
   116 	 * @return The distance between industry and tile.
   116 	 */
   117 	 */
   117 	static int32 GetDistanceSquareToTile(IndustryID industry_id, TileIndex tile);
   118 	static int32 GetDistanceSquareToTile(IndustryID industry_id, TileIndex tile);
   118 };
   119 };
   119 
   120