src/ai/api/ai_industry.hpp
author truebrain
Sat, 23 Feb 2008 16:21:10 +0000
branchnoai
changeset 9746 e4ab7ea8d897
parent 9737 ee408edf3851
child 9787 959f15f96a1c
permissions -rw-r--r--
(svn r12226) [NoAI] -Fix: remove the dep for AIStationList_Vehicle on AIStationList, as Squirrel doesn't like it
9405
df6f3b4b0038 (svn r9202) [NoAI] -Add: some initial functions for cargo and industries.
rubidium
parents:
diff changeset
     1
/* $Id$ */
df6f3b4b0038 (svn r9202) [NoAI] -Add: some initial functions for cargo and industries.
rubidium
parents:
diff changeset
     2
df6f3b4b0038 (svn r9202) [NoAI] -Add: some initial functions for cargo and industries.
rubidium
parents:
diff changeset
     3
/** @file ai_industry.hpp Everything to query about industries */
df6f3b4b0038 (svn r9202) [NoAI] -Add: some initial functions for cargo and industries.
rubidium
parents:
diff changeset
     4
df6f3b4b0038 (svn r9202) [NoAI] -Add: some initial functions for cargo and industries.
rubidium
parents:
diff changeset
     5
#ifndef AI_INDUSTRY_HPP
df6f3b4b0038 (svn r9202) [NoAI] -Add: some initial functions for cargo and industries.
rubidium
parents:
diff changeset
     6
#define AI_INDUSTRY_HPP
df6f3b4b0038 (svn r9202) [NoAI] -Add: some initial functions for cargo and industries.
rubidium
parents:
diff changeset
     7
df6f3b4b0038 (svn r9202) [NoAI] -Add: some initial functions for cargo and industries.
rubidium
parents:
diff changeset
     8
#include "ai_object.hpp"
9723
eee46cb39750 (svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents: 9710
diff changeset
     9
#include "../../industry.h"
9405
df6f3b4b0038 (svn r9202) [NoAI] -Add: some initial functions for cargo and industries.
rubidium
parents:
diff changeset
    10
9448
2a4c4340233d (svn r9273) [NoAI] -Documentation: finished documenting the last few files; they should now be readable for any non-programmer.
truelight
parents: 9427
diff changeset
    11
/**
2a4c4340233d (svn r9273) [NoAI] -Documentation: finished documenting the last few files; they should now be readable for any non-programmer.
truelight
parents: 9427
diff changeset
    12
 * Class that handles all industry related functions.
2a4c4340233d (svn r9273) [NoAI] -Documentation: finished documenting the last few files; they should now be readable for any non-programmer.
truelight
parents: 9427
diff changeset
    13
 */
9405
df6f3b4b0038 (svn r9202) [NoAI] -Add: some initial functions for cargo and industries.
rubidium
parents:
diff changeset
    14
class AIIndustry : public AIObject {
df6f3b4b0038 (svn r9202) [NoAI] -Add: some initial functions for cargo and industries.
rubidium
parents:
diff changeset
    15
public:
df6f3b4b0038 (svn r9202) [NoAI] -Add: some initial functions for cargo and industries.
rubidium
parents:
diff changeset
    16
	/**
9529
5f26f4bc574b (svn r9450) [NoAI] -Fix: don't allow static-method calls from SQ to non-static functions
truelight
parents: 9526
diff changeset
    17
	 * The name of the class, needed by several sub-processes.
5f26f4bc574b (svn r9450) [NoAI] -Fix: don't allow static-method calls from SQ to non-static functions
truelight
parents: 9526
diff changeset
    18
	 */
5f26f4bc574b (svn r9450) [NoAI] -Fix: don't allow static-method calls from SQ to non-static functions
truelight
parents: 9526
diff changeset
    19
	static const char *GetClassName() { return "AIIndustry"; }
5f26f4bc574b (svn r9450) [NoAI] -Fix: don't allow static-method calls from SQ to non-static functions
truelight
parents: 9526
diff changeset
    20
5f26f4bc574b (svn r9450) [NoAI] -Fix: don't allow static-method calls from SQ to non-static functions
truelight
parents: 9526
diff changeset
    21
	/**
9448
2a4c4340233d (svn r9273) [NoAI] -Documentation: finished documenting the last few files; they should now be readable for any non-programmer.
truelight
parents: 9427
diff changeset
    22
	 * Gets the maximum industry index; there are no valid industries with a
2a4c4340233d (svn r9273) [NoAI] -Documentation: finished documenting the last few files; they should now be readable for any non-programmer.
truelight
parents: 9427
diff changeset
    23
	 *   higher index.
2a4c4340233d (svn r9273) [NoAI] -Documentation: finished documenting the last few files; they should now be readable for any non-programmer.
truelight
parents: 9427
diff changeset
    24
	 * @return the maximum industry index.
2a4c4340233d (svn r9273) [NoAI] -Documentation: finished documenting the last few files; they should now be readable for any non-programmer.
truelight
parents: 9427
diff changeset
    25
	 * @post return value is always non-negative.
9405
df6f3b4b0038 (svn r9202) [NoAI] -Add: some initial functions for cargo and industries.
rubidium
parents:
diff changeset
    26
	 */
9737
ee408edf3851 (svn r12216) [NoAI] -Codechange: made most functions 'static', which removes the need to create an instance to get, for example, engine information, and therefor heavily simplifying AI creation (Morloth)
truebrain
parents: 9723
diff changeset
    27
	static IndustryID GetMaxIndustryID();
9405
df6f3b4b0038 (svn r9202) [NoAI] -Add: some initial functions for cargo and industries.
rubidium
parents:
diff changeset
    28
df6f3b4b0038 (svn r9202) [NoAI] -Add: some initial functions for cargo and industries.
rubidium
parents:
diff changeset
    29
	/**
9448
2a4c4340233d (svn r9273) [NoAI] -Documentation: finished documenting the last few files; they should now be readable for any non-programmer.
truelight
parents: 9427
diff changeset
    30
	 * Gets the number of industries. This is different than GetMaxIndustryID()
2a4c4340233d (svn r9273) [NoAI] -Documentation: finished documenting the last few files; they should now be readable for any non-programmer.
truelight
parents: 9427
diff changeset
    31
	 *   because of the way OpenTTD works internally.
2a4c4340233d (svn r9273) [NoAI] -Documentation: finished documenting the last few files; they should now be readable for any non-programmer.
truelight
parents: 9427
diff changeset
    32
	 * @return the number of industries.
2a4c4340233d (svn r9273) [NoAI] -Documentation: finished documenting the last few files; they should now be readable for any non-programmer.
truelight
parents: 9427
diff changeset
    33
	 * @post return value is always non-negative.
9405
df6f3b4b0038 (svn r9202) [NoAI] -Add: some initial functions for cargo and industries.
rubidium
parents:
diff changeset
    34
	 */
9737
ee408edf3851 (svn r12216) [NoAI] -Codechange: made most functions 'static', which removes the need to create an instance to get, for example, engine information, and therefor heavily simplifying AI creation (Morloth)
truebrain
parents: 9723
diff changeset
    35
	static int32 GetIndustryCount();
9405
df6f3b4b0038 (svn r9202) [NoAI] -Add: some initial functions for cargo and industries.
rubidium
parents:
diff changeset
    36
df6f3b4b0038 (svn r9202) [NoAI] -Add: some initial functions for cargo and industries.
rubidium
parents:
diff changeset
    37
	/**
9448
2a4c4340233d (svn r9273) [NoAI] -Documentation: finished documenting the last few files; they should now be readable for any non-programmer.
truelight
parents: 9427
diff changeset
    38
	 * Checks whether the given industry index is valid.
2a4c4340233d (svn r9273) [NoAI] -Documentation: finished documenting the last few files; they should now be readable for any non-programmer.
truelight
parents: 9427
diff changeset
    39
	 * @param industry_id the index to check.
2a4c4340233d (svn r9273) [NoAI] -Documentation: finished documenting the last few files; they should now be readable for any non-programmer.
truelight
parents: 9427
diff changeset
    40
	 * @return true if and only if the industry is valid.
9405
df6f3b4b0038 (svn r9202) [NoAI] -Add: some initial functions for cargo and industries.
rubidium
parents:
diff changeset
    41
	 */
9497
f6678533ccba (svn r9369) [NoAI] -Codechange: make some IsValidXXX() function static, so they can be used by the other classes without the need for an instance.
rubidium
parents: 9448
diff changeset
    42
	static bool IsValidIndustry(IndustryID industry_id);
9405
df6f3b4b0038 (svn r9202) [NoAI] -Add: some initial functions for cargo and industries.
rubidium
parents:
diff changeset
    43
df6f3b4b0038 (svn r9202) [NoAI] -Add: some initial functions for cargo and industries.
rubidium
parents:
diff changeset
    44
	/**
9448
2a4c4340233d (svn r9273) [NoAI] -Documentation: finished documenting the last few files; they should now be readable for any non-programmer.
truelight
parents: 9427
diff changeset
    45
	 * Get the name of the industry.
2a4c4340233d (svn r9273) [NoAI] -Documentation: finished documenting the last few files; they should now be readable for any non-programmer.
truelight
parents: 9427
diff changeset
    46
	 * @param industry_id the industry to get the name of.
2a4c4340233d (svn r9273) [NoAI] -Documentation: finished documenting the last few files; they should now be readable for any non-programmer.
truelight
parents: 9427
diff changeset
    47
	 * @pre industry_id has to be valid (use IsValidIndustry()).
2a4c4340233d (svn r9273) [NoAI] -Documentation: finished documenting the last few files; they should now be readable for any non-programmer.
truelight
parents: 9427
diff changeset
    48
	 * @return the name of the industry.
2a4c4340233d (svn r9273) [NoAI] -Documentation: finished documenting the last few files; they should now be readable for any non-programmer.
truelight
parents: 9427
diff changeset
    49
	 * @note the returned name must be free'd (C++ only).
9405
df6f3b4b0038 (svn r9202) [NoAI] -Add: some initial functions for cargo and industries.
rubidium
parents:
diff changeset
    50
	 */
9737
ee408edf3851 (svn r12216) [NoAI] -Codechange: made most functions 'static', which removes the need to create an instance to get, for example, engine information, and therefor heavily simplifying AI creation (Morloth)
truebrain
parents: 9723
diff changeset
    51
	static char *GetName(IndustryID industry_id);
9405
df6f3b4b0038 (svn r9202) [NoAI] -Add: some initial functions for cargo and industries.
rubidium
parents:
diff changeset
    52
df6f3b4b0038 (svn r9202) [NoAI] -Add: some initial functions for cargo and industries.
rubidium
parents:
diff changeset
    53
	/**
9649
bc8c06513f5b (svn r10544) [NoAI] -Add: added AIIndustryList to list industries
truelight
parents: 9596
diff changeset
    54
	 * Gets the production of a cargo of the industry.
bc8c06513f5b (svn r10544) [NoAI] -Add: added AIIndustryList to list industries
truelight
parents: 9596
diff changeset
    55
	 * @param industry_id the index of the industry.
bc8c06513f5b (svn r10544) [NoAI] -Add: added AIIndustryList to list industries
truelight
parents: 9596
diff changeset
    56
	 * @param cargo_id the index of the cargo.
bc8c06513f5b (svn r10544) [NoAI] -Add: added AIIndustryList to list industries
truelight
parents: 9596
diff changeset
    57
	 * @pre industry_id has to be valid (use IsValidIndustry()).
bc8c06513f5b (svn r10544) [NoAI] -Add: added AIIndustryList to list industries
truelight
parents: 9596
diff changeset
    58
	 * @pre cargo_id has to be valid (use IsValidCargo()).
bc8c06513f5b (svn r10544) [NoAI] -Add: added AIIndustryList to list industries
truelight
parents: 9596
diff changeset
    59
	 * @return the production of the cargo for this industry.
bc8c06513f5b (svn r10544) [NoAI] -Add: added AIIndustryList to list industries
truelight
parents: 9596
diff changeset
    60
	 */
9650
7e5e1a7ecbff (svn r10545) [NoAI] -Fix: GetProduction doesn't return a tile, but a value (tnx glx)
truelight
parents: 9649
diff changeset
    61
	static int32 GetProduction(IndustryID industry_id, CargoID cargo_id);
9649
bc8c06513f5b (svn r10544) [NoAI] -Add: added AIIndustryList to list industries
truelight
parents: 9596
diff changeset
    62
bc8c06513f5b (svn r10544) [NoAI] -Add: added AIIndustryList to list industries
truelight
parents: 9596
diff changeset
    63
	/**
9710
ba44f8c1fd52 (svn r11294) [NoAI] -Add: added AIIndustry::IsCargoAccepted + Valuator (on request by Kilinich)
truelight
parents: 9650
diff changeset
    64
	 * See if an industry accepts a certain cargo.
ba44f8c1fd52 (svn r11294) [NoAI] -Add: added AIIndustry::IsCargoAccepted + Valuator (on request by Kilinich)
truelight
parents: 9650
diff changeset
    65
	 * @param industry_id the index of the industry.
ba44f8c1fd52 (svn r11294) [NoAI] -Add: added AIIndustry::IsCargoAccepted + Valuator (on request by Kilinich)
truelight
parents: 9650
diff changeset
    66
	 * @param cargo_id the index of the cargo.
ba44f8c1fd52 (svn r11294) [NoAI] -Add: added AIIndustry::IsCargoAccepted + Valuator (on request by Kilinich)
truelight
parents: 9650
diff changeset
    67
	 * @pre industry_id has to be valid (use IsValidIndustry()).
ba44f8c1fd52 (svn r11294) [NoAI] -Add: added AIIndustry::IsCargoAccepted + Valuator (on request by Kilinich)
truelight
parents: 9650
diff changeset
    68
	 * @pre cargo_id has to be valid (use IsValidCargo()).
ba44f8c1fd52 (svn r11294) [NoAI] -Add: added AIIndustry::IsCargoAccepted + Valuator (on request by Kilinich)
truelight
parents: 9650
diff changeset
    69
	 * @return the production of the cargo for this industry.
ba44f8c1fd52 (svn r11294) [NoAI] -Add: added AIIndustry::IsCargoAccepted + Valuator (on request by Kilinich)
truelight
parents: 9650
diff changeset
    70
	 */
ba44f8c1fd52 (svn r11294) [NoAI] -Add: added AIIndustry::IsCargoAccepted + Valuator (on request by Kilinich)
truelight
parents: 9650
diff changeset
    71
	static bool IsCargoAccepted(IndustryID industry_id, CargoID cargo_id);
ba44f8c1fd52 (svn r11294) [NoAI] -Add: added AIIndustry::IsCargoAccepted + Valuator (on request by Kilinich)
truelight
parents: 9650
diff changeset
    72
ba44f8c1fd52 (svn r11294) [NoAI] -Add: added AIIndustry::IsCargoAccepted + Valuator (on request by Kilinich)
truelight
parents: 9650
diff changeset
    73
	/**
9448
2a4c4340233d (svn r9273) [NoAI] -Documentation: finished documenting the last few files; they should now be readable for any non-programmer.
truelight
parents: 9427
diff changeset
    74
	 * Gets the location of the industry.
9649
bc8c06513f5b (svn r10544) [NoAI] -Add: added AIIndustryList to list industries
truelight
parents: 9596
diff changeset
    75
	 * @param industry_id the index of the industry.
9448
2a4c4340233d (svn r9273) [NoAI] -Documentation: finished documenting the last few files; they should now be readable for any non-programmer.
truelight
parents: 9427
diff changeset
    76
	 * @pre industry_id has to be valid (use IsValidIndustry()).
2a4c4340233d (svn r9273) [NoAI] -Documentation: finished documenting the last few files; they should now be readable for any non-programmer.
truelight
parents: 9427
diff changeset
    77
	 * @return the location of the industry.
2a4c4340233d (svn r9273) [NoAI] -Documentation: finished documenting the last few files; they should now be readable for any non-programmer.
truelight
parents: 9427
diff changeset
    78
	 * @post return value is always positive and below AIMap::GetMapSize().
9405
df6f3b4b0038 (svn r9202) [NoAI] -Add: some initial functions for cargo and industries.
rubidium
parents:
diff changeset
    79
	 */
9649
bc8c06513f5b (svn r10544) [NoAI] -Add: added AIIndustryList to list industries
truelight
parents: 9596
diff changeset
    80
	static TileIndex GetLocation(IndustryID industry_id);
9405
df6f3b4b0038 (svn r9202) [NoAI] -Add: some initial functions for cargo and industries.
rubidium
parents:
diff changeset
    81
};
df6f3b4b0038 (svn r9202) [NoAI] -Add: some initial functions for cargo and industries.
rubidium
parents:
diff changeset
    82
df6f3b4b0038 (svn r9202) [NoAI] -Add: some initial functions for cargo and industries.
rubidium
parents:
diff changeset
    83
#endif /* AI_INDUSTRY_HPP */