2009-01-12 18:11:45 +01:00
|
|
|
/* $Id$ */
|
|
|
|
|
2009-08-21 22:21:05 +02:00
|
|
|
/*
|
|
|
|
* This file is part of OpenTTD.
|
|
|
|
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
|
|
|
|
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2009-01-12 18:11:45 +01:00
|
|
|
/** @file ai_industry.hpp Everything to query and build industries. */
|
|
|
|
|
|
|
|
#ifndef AI_INDUSTRY_HPP
|
|
|
|
#define AI_INDUSTRY_HPP
|
|
|
|
|
|
|
|
#include "ai_object.hpp"
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Class that handles all industry related functions.
|
|
|
|
*/
|
|
|
|
class AIIndustry : public AIObject {
|
|
|
|
public:
|
|
|
|
static const char *GetClassName() { return "AIIndustry"; }
|
|
|
|
|
|
|
|
/**
|
2009-02-23 22:07:01 +01:00
|
|
|
* Gets the number of industries.
|
2009-01-12 18:11:45 +01:00
|
|
|
* @return The number of industries.
|
|
|
|
* @post Return value is always non-negative.
|
2009-02-23 22:07:01 +01:00
|
|
|
* @note The maximum valid IndustryID can be higher then the value returned.
|
2009-01-12 18:11:45 +01:00
|
|
|
*/
|
|
|
|
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);
|
|
|
|
|
2010-05-09 17:59:30 +02:00
|
|
|
/**
|
|
|
|
* Get the IndustryID of a tile, if there is an industry.
|
|
|
|
* @param tile The tile to find the IndustryID of.
|
|
|
|
* @return IndustryID of the industry.
|
|
|
|
* @post Use IsValidIndustry() to see if the industry is valid.
|
|
|
|
* @note GetIndustryID will return an invalid IndustryID for the
|
|
|
|
* station tile of industries with a dock/heliport.
|
|
|
|
*/
|
|
|
|
static IndustryID GetIndustryID(TileIndex tile);
|
|
|
|
|
2009-01-12 18:11:45 +01:00
|
|
|
/**
|
|
|
|
* Get the name of the industry.
|
|
|
|
* @param industry_id The industry to get the name of.
|
|
|
|
* @pre IsValidIndustry(industry_id).
|
|
|
|
* @return The name of the industry.
|
|
|
|
*/
|
2009-01-17 16:31:30 +01:00
|
|
|
static char *GetName(IndustryID industry_id);
|
2009-01-12 18:11:45 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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 IsValidIndustry(industry_id).
|
|
|
|
* @pre AICargo::IsValidCargo(cargo_id).
|
2009-01-23 23:09:31 +01:00
|
|
|
* @return True if and only if the industry accepts the cargo.
|
2009-01-12 18:11:45 +01:00
|
|
|
*/
|
|
|
|
static bool IsCargoAccepted(IndustryID industry_id, CargoID cargo_id);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the amount of cargo stockpiled for processing.
|
|
|
|
* @param industry_id The index of the industry.
|
|
|
|
* @param cargo_id The index of the cargo.
|
|
|
|
* @pre IsValidIndustry(industry_id).
|
|
|
|
* @pre AICargo::IsValidCargo(cargo_id).
|
|
|
|
* @return The amount of cargo that is waiting for processing.
|
|
|
|
*/
|
|
|
|
static int32 GetStockpiledCargo(IndustryID industry_id, CargoID cargo_id);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the total last month's production of the given cargo at an industry.
|
|
|
|
* @param industry_id The index of the industry.
|
|
|
|
* @param cargo_id The index of the cargo.
|
|
|
|
* @pre IsValidIndustry(industry_id).
|
|
|
|
* @pre AICargo::IsValidCargo(cargo_id).
|
|
|
|
* @return The last month's production of the given cargo for this industry.
|
|
|
|
*/
|
|
|
|
static int32 GetLastMonthProduction(IndustryID industry_id, CargoID cargo_id);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the total amount of cargo transported from an industry last month.
|
|
|
|
* @param industry_id The index of the industry.
|
|
|
|
* @param cargo_id The index of the cargo.
|
|
|
|
* @pre IsValidIndustry(industry_id).
|
|
|
|
* @pre AICargo::IsValidCargo(cargo_id).
|
|
|
|
* @return The amount of given cargo transported from this industry last month.
|
|
|
|
*/
|
|
|
|
static int32 GetLastMonthTransported(IndustryID industry_id, CargoID cargo_id);
|
2009-08-27 15:50:07 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the percentage of cargo transported from an industry last month.
|
|
|
|
* @param industry_id The index of the industry.
|
|
|
|
* @param cargo_id The index of the cargo.
|
|
|
|
* @pre IsValidIndustry(industry_id).
|
|
|
|
* @pre AICargo::IsValidCargo(cargo_id).
|
|
|
|
* @return The percentage of given cargo transported from this industry last month.
|
|
|
|
*/
|
|
|
|
static int32 GetLastMonthTransportedPercentage(IndustryID industry_id, CargoID cargo_id);
|
2009-01-12 18:11:45 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the location of the industry.
|
|
|
|
* @param industry_id The index of the industry.
|
|
|
|
* @pre IsValidIndustry(industry_id).
|
|
|
|
* @return The location of the industry.
|
|
|
|
*/
|
|
|
|
static TileIndex GetLocation(IndustryID industry_id);
|
|
|
|
|
|
|
|
/**
|
2009-04-26 00:57:15 +02:00
|
|
|
* Get the number of stations around an industry. All stations that can
|
|
|
|
* service the industry are counted, your own stations but also your
|
|
|
|
* opponents stations.
|
2009-01-12 18:11:45 +01:00
|
|
|
* @param industry_id The index of the industry.
|
|
|
|
* @pre IsValidIndustry(industry_id).
|
|
|
|
* @return The number of stations around an industry.
|
|
|
|
*/
|
|
|
|
static int32 GetAmountOfStationsAround(IndustryID industry_id);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the manhattan distance from the tile to the AIIndustry::GetLocation()
|
|
|
|
* of the industry.
|
|
|
|
* @param industry_id The industry to get the distance to.
|
|
|
|
* @param tile The tile to get the distance to.
|
|
|
|
* @pre IsValidIndustry(industry_id).
|
|
|
|
* @pre AIMap::IsValidTile(tile).
|
|
|
|
* @return The distance between industry and tile.
|
|
|
|
*/
|
|
|
|
static int32 GetDistanceManhattanToTile(IndustryID industry_id, TileIndex tile);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the square distance from the tile to the AIIndustry::GetLocation()
|
|
|
|
* of the industry.
|
|
|
|
* @param industry_id The industry to get the distance to.
|
|
|
|
* @param tile The tile to get the distance to.
|
|
|
|
* @pre IsValidIndustry(industry_id).
|
|
|
|
* @pre AIMap::IsValidTile(tile).
|
|
|
|
* @return The distance between industry and tile.
|
|
|
|
*/
|
|
|
|
static int32 GetDistanceSquareToTile(IndustryID industry_id, TileIndex tile);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Is this industry built on water.
|
|
|
|
* @param industry_id The index of the industry.
|
|
|
|
* @pre IsValidIndustry(industry_id).
|
|
|
|
* @return True when the industry is built on water.
|
|
|
|
*/
|
|
|
|
static bool IsBuiltOnWater(IndustryID industry_id);
|
|
|
|
|
|
|
|
/**
|
2009-02-14 22:09:48 +01:00
|
|
|
* Does this industry have a heliport?
|
2009-01-12 18:11:45 +01:00
|
|
|
* @param industry_id The index of the industry.
|
|
|
|
* @pre IsValidIndustry(industry_id).
|
2009-02-14 22:09:48 +01:00
|
|
|
* @return True when the industry has a heliport.
|
2009-01-12 18:11:45 +01:00
|
|
|
*/
|
2009-02-14 22:09:48 +01:00
|
|
|
static bool HasHeliport(IndustryID industry_id);
|
2009-01-12 18:11:45 +01:00
|
|
|
|
|
|
|
/**
|
2009-02-14 22:09:48 +01:00
|
|
|
* Gets the location of the industry's heliport.
|
2009-01-12 18:11:45 +01:00
|
|
|
* @param industry_id The index of the industry.
|
|
|
|
* @pre IsValidIndustry(industry_id).
|
2009-02-14 22:09:48 +01:00
|
|
|
* @pre HasHeliport(industry_id).
|
|
|
|
* @return The location of the industry's heliport.
|
2009-01-12 18:11:45 +01:00
|
|
|
*/
|
2009-02-14 22:09:48 +01:00
|
|
|
static TileIndex GetHeliportLocation(IndustryID industry_id);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Does this industry have a dock?
|
|
|
|
* @param industry_id The index of the industry.
|
|
|
|
* @pre IsValidIndustry(industry_id).
|
|
|
|
* @return True when the industry has a dock.
|
|
|
|
*/
|
|
|
|
static bool HasDock(IndustryID industry_id);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the location of the industry's dock.
|
|
|
|
* @param industry_id The index of the industry.
|
|
|
|
* @pre IsValidIndustry(industry_id).
|
|
|
|
* @pre HasDock(industry_id).
|
|
|
|
* @return The location of the industry's dock.
|
|
|
|
*/
|
|
|
|
static TileIndex GetDockLocation(IndustryID industry_id);
|
2009-01-12 18:11:45 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the IndustryType of the industry.
|
|
|
|
* @param industry_id The index of the industry.
|
|
|
|
* @pre IsValidIndustry(industry_id).
|
|
|
|
* @return The IndustryType of the industry.
|
|
|
|
*/
|
|
|
|
static IndustryType GetIndustryType(IndustryID industry_id);
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* AI_INDUSTRY_HPP */
|