src/ai/api/ai_cargo.hpp
author truebrain
Fri, 23 May 2008 09:18:04 +0000
branchnoai
changeset 10675 b16fdb811ebb
parent 10196 aecabd927420
child 10831 f7e17819358b
permissions -rw-r--r--
(svn r13219) [NoAI] -Add: added AICargo.HasCargoClass(), which allows you to find, say, passenger-based cargo (tnx kuifware for the pointer!)
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
9829
80fbe02a4184 (svn r12491) [NoAI] -Documentation: made parts of the comments more uniform (@file header and class header)
truebrain
parents: 9814
diff changeset
     3
/** @file ai_cargo.hpp Everything to query cargos. */
9405
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_CARGO_HPP
df6f3b4b0038 (svn r9202) [NoAI] -Add: some initial functions for cargo and industries.
rubidium
parents:
diff changeset
     6
#define AI_CARGO_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"
df6f3b4b0038 (svn r9202) [NoAI] -Add: some initial functions for cargo and industries.
rubidium
parents:
diff changeset
     9
9447
8f3c1bc72204 (svn r9272) [NoAI] -Documentation: made the documentation of the first 3 API files more readable for non-programmers
truelight
parents: 9427
diff changeset
    10
/**
8f3c1bc72204 (svn r9272) [NoAI] -Documentation: made the documentation of the first 3 API files more readable for non-programmers
truelight
parents: 9427
diff changeset
    11
 * Class that handles all cargo related functions.
8f3c1bc72204 (svn r9272) [NoAI] -Documentation: made the documentation of the first 3 API files more readable for non-programmers
truelight
parents: 9427
diff changeset
    12
 */
9405
df6f3b4b0038 (svn r9202) [NoAI] -Add: some initial functions for cargo and industries.
rubidium
parents:
diff changeset
    13
class AICargo : public AIObject {
df6f3b4b0038 (svn r9202) [NoAI] -Add: some initial functions for cargo and industries.
rubidium
parents:
diff changeset
    14
public:
9529
5f26f4bc574b (svn r9450) [NoAI] -Fix: don't allow static-method calls from SQ to non-static functions
truelight
parents: 9526
diff changeset
    15
	static const char *GetClassName() { return "AICargo"; }
5f26f4bc574b (svn r9450) [NoAI] -Fix: don't allow static-method calls from SQ to non-static functions
truelight
parents: 9526
diff changeset
    16
5f26f4bc574b (svn r9450) [NoAI] -Fix: don't allow static-method calls from SQ to non-static functions
truelight
parents: 9526
diff changeset
    17
	/**
10675
b16fdb811ebb (svn r13219) [NoAI] -Add: added AICargo.HasCargoClass(), which allows you to find, say, passenger-based cargo (tnx kuifware for the pointer!)
truebrain
parents: 10196
diff changeset
    18
	 * The classes of cargo (from newgrf_cargo.h).
b16fdb811ebb (svn r13219) [NoAI] -Add: added AICargo.HasCargoClass(), which allows you to find, say, passenger-based cargo (tnx kuifware for the pointer!)
truebrain
parents: 10196
diff changeset
    19
	 */
b16fdb811ebb (svn r13219) [NoAI] -Add: added AICargo.HasCargoClass(), which allows you to find, say, passenger-based cargo (tnx kuifware for the pointer!)
truebrain
parents: 10196
diff changeset
    20
	enum CargoClass {
b16fdb811ebb (svn r13219) [NoAI] -Add: added AICargo.HasCargoClass(), which allows you to find, say, passenger-based cargo (tnx kuifware for the pointer!)
truebrain
parents: 10196
diff changeset
    21
		CC_PASSENGERS   = 1 <<  0, ///< Passengers
b16fdb811ebb (svn r13219) [NoAI] -Add: added AICargo.HasCargoClass(), which allows you to find, say, passenger-based cargo (tnx kuifware for the pointer!)
truebrain
parents: 10196
diff changeset
    22
		CC_MAIL         = 1 <<  1, ///< Mail
b16fdb811ebb (svn r13219) [NoAI] -Add: added AICargo.HasCargoClass(), which allows you to find, say, passenger-based cargo (tnx kuifware for the pointer!)
truebrain
parents: 10196
diff changeset
    23
		CC_EXPRESS      = 1 <<  2, ///< Express cargo (Goods, Food, Candy, but also possible for passengers)
b16fdb811ebb (svn r13219) [NoAI] -Add: added AICargo.HasCargoClass(), which allows you to find, say, passenger-based cargo (tnx kuifware for the pointer!)
truebrain
parents: 10196
diff changeset
    24
		CC_ARMOURED     = 1 <<  3, ///< Armoured cargo (Valuables, Gold, Diamonds)
b16fdb811ebb (svn r13219) [NoAI] -Add: added AICargo.HasCargoClass(), which allows you to find, say, passenger-based cargo (tnx kuifware for the pointer!)
truebrain
parents: 10196
diff changeset
    25
		CC_BULK         = 1 <<  4, ///< Bulk cargo (Coal, Grain etc., Ores, Fruit)
b16fdb811ebb (svn r13219) [NoAI] -Add: added AICargo.HasCargoClass(), which allows you to find, say, passenger-based cargo (tnx kuifware for the pointer!)
truebrain
parents: 10196
diff changeset
    26
		CC_PIECE_GOODS  = 1 <<  5, ///< Piece goods (Livestock, Wood, Steel, Paper)
b16fdb811ebb (svn r13219) [NoAI] -Add: added AICargo.HasCargoClass(), which allows you to find, say, passenger-based cargo (tnx kuifware for the pointer!)
truebrain
parents: 10196
diff changeset
    27
		CC_LIQUID       = 1 <<  6, ///< Liquids (Oil, Water, Rubber)
b16fdb811ebb (svn r13219) [NoAI] -Add: added AICargo.HasCargoClass(), which allows you to find, say, passenger-based cargo (tnx kuifware for the pointer!)
truebrain
parents: 10196
diff changeset
    28
		CC_REFRIGERATED = 1 <<  7, ///< Refrigerated cargo (Food, Fruit)
b16fdb811ebb (svn r13219) [NoAI] -Add: added AICargo.HasCargoClass(), which allows you to find, say, passenger-based cargo (tnx kuifware for the pointer!)
truebrain
parents: 10196
diff changeset
    29
		CC_HAZARDOUS    = 1 <<  8, ///< Hazardous cargo (Nucleair Fuel, Explosives, etc.)
b16fdb811ebb (svn r13219) [NoAI] -Add: added AICargo.HasCargoClass(), which allows you to find, say, passenger-based cargo (tnx kuifware for the pointer!)
truebrain
parents: 10196
diff changeset
    30
		CC_COVERED      = 1 <<  9, ///< Covered/Sheltered Freight (Transporation in Box Vans, Silo Wagons, etc.)
b16fdb811ebb (svn r13219) [NoAI] -Add: added AICargo.HasCargoClass(), which allows you to find, say, passenger-based cargo (tnx kuifware for the pointer!)
truebrain
parents: 10196
diff changeset
    31
	};
b16fdb811ebb (svn r13219) [NoAI] -Add: added AICargo.HasCargoClass(), which allows you to find, say, passenger-based cargo (tnx kuifware for the pointer!)
truebrain
parents: 10196
diff changeset
    32
b16fdb811ebb (svn r13219) [NoAI] -Add: added AICargo.HasCargoClass(), which allows you to find, say, passenger-based cargo (tnx kuifware for the pointer!)
truebrain
parents: 10196
diff changeset
    33
	/**
9472
063c3f50972a (svn r9312) [NoAI] -Codechange: add IsValidCargo.
rubidium
parents: 9447
diff changeset
    34
	 * Checks whether the given cargo type is valid.
9835
2541c2d325ed (svn r12500) [NoAI] -Documentation: many comment changes, mostly Capitals and lines end with a dot. Makes doxygen look pretty :)
truebrain
parents: 9829
diff changeset
    35
	 * @param cargo_type The cargo to check.
2541c2d325ed (svn r12500) [NoAI] -Documentation: many comment changes, mostly Capitals and lines end with a dot. Makes doxygen look pretty :)
truebrain
parents: 9829
diff changeset
    36
	 * @return True if and only if the cargo type is valid.
9472
063c3f50972a (svn r9312) [NoAI] -Codechange: add IsValidCargo.
rubidium
parents: 9447
diff changeset
    37
	 */
9490
999eb7531205 (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.
truelight
parents: 9472
diff changeset
    38
	static bool IsValidCargo(CargoID cargo_type);
9472
063c3f50972a (svn r9312) [NoAI] -Codechange: add IsValidCargo.
rubidium
parents: 9447
diff changeset
    39
063c3f50972a (svn r9312) [NoAI] -Codechange: add IsValidCargo.
rubidium
parents: 9447
diff changeset
    40
	/**
9447
8f3c1bc72204 (svn r9272) [NoAI] -Documentation: made the documentation of the first 3 API files more readable for non-programmers
truelight
parents: 9427
diff changeset
    41
	 * Gets the string representation of the cargo label.
9835
2541c2d325ed (svn r12500) [NoAI] -Documentation: many comment changes, mostly Capitals and lines end with a dot. Makes doxygen look pretty :)
truebrain
parents: 9829
diff changeset
    42
	 * @param cargo_type The cargo to get the string representation of.
2541c2d325ed (svn r12500) [NoAI] -Documentation: many comment changes, mostly Capitals and lines end with a dot. Makes doxygen look pretty :)
truebrain
parents: 9829
diff changeset
    43
	 * @return The cargo label.
2541c2d325ed (svn r12500) [NoAI] -Documentation: many comment changes, mostly Capitals and lines end with a dot. Makes doxygen look pretty :)
truebrain
parents: 9829
diff changeset
    44
	 * @note Never use this to check if it is a certain cargo. NewGRF can
2541c2d325ed (svn r12500) [NoAI] -Documentation: many comment changes, mostly Capitals and lines end with a dot. Makes doxygen look pretty :)
truebrain
parents: 9829
diff changeset
    45
	 *  redefine all of the names.
9405
df6f3b4b0038 (svn r9202) [NoAI] -Add: some initial functions for cargo and industries.
rubidium
parents:
diff changeset
    46
	 */
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: 9596
diff changeset
    47
	static char *GetCargoLabel(CargoID cargo_type);
9405
df6f3b4b0038 (svn r9202) [NoAI] -Add: some initial functions for cargo and industries.
rubidium
parents:
diff changeset
    48
df6f3b4b0038 (svn r9202) [NoAI] -Add: some initial functions for cargo and industries.
rubidium
parents:
diff changeset
    49
	/**
9447
8f3c1bc72204 (svn r9272) [NoAI] -Documentation: made the documentation of the first 3 API files more readable for non-programmers
truelight
parents: 9427
diff changeset
    50
	 * Checks whether the give cargo is a freight or not.
9835
2541c2d325ed (svn r12500) [NoAI] -Documentation: many comment changes, mostly Capitals and lines end with a dot. Makes doxygen look pretty :)
truebrain
parents: 9829
diff changeset
    51
	 * @param cargo_type The cargo to check on.
2541c2d325ed (svn r12500) [NoAI] -Documentation: many comment changes, mostly Capitals and lines end with a dot. Makes doxygen look pretty :)
truebrain
parents: 9829
diff changeset
    52
	 * @return True if and only if the cargo is freight.
9405
df6f3b4b0038 (svn r9202) [NoAI] -Add: some initial functions for cargo and industries.
rubidium
parents:
diff changeset
    53
	 */
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: 9596
diff changeset
    54
	static bool IsFreight(CargoID cargo_type);
9405
df6f3b4b0038 (svn r9202) [NoAI] -Add: some initial functions for cargo and industries.
rubidium
parents:
diff changeset
    55
df6f3b4b0038 (svn r9202) [NoAI] -Add: some initial functions for cargo and industries.
rubidium
parents:
diff changeset
    56
	/**
10675
b16fdb811ebb (svn r13219) [NoAI] -Add: added AICargo.HasCargoClass(), which allows you to find, say, passenger-based cargo (tnx kuifware for the pointer!)
truebrain
parents: 10196
diff changeset
    57
	 * Check if this cargo is in the requested cargo class.
b16fdb811ebb (svn r13219) [NoAI] -Add: added AICargo.HasCargoClass(), which allows you to find, say, passenger-based cargo (tnx kuifware for the pointer!)
truebrain
parents: 10196
diff changeset
    58
	 * @param cargo_type The cargo to check on.
b16fdb811ebb (svn r13219) [NoAI] -Add: added AICargo.HasCargoClass(), which allows you to find, say, passenger-based cargo (tnx kuifware for the pointer!)
truebrain
parents: 10196
diff changeset
    59
	 * @param cargo_class The class to check for.
b16fdb811ebb (svn r13219) [NoAI] -Add: added AICargo.HasCargoClass(), which allows you to find, say, passenger-based cargo (tnx kuifware for the pointer!)
truebrain
parents: 10196
diff changeset
    60
	 * @return True if and only if the cargo is in the cargo class.
b16fdb811ebb (svn r13219) [NoAI] -Add: added AICargo.HasCargoClass(), which allows you to find, say, passenger-based cargo (tnx kuifware for the pointer!)
truebrain
parents: 10196
diff changeset
    61
	 */
b16fdb811ebb (svn r13219) [NoAI] -Add: added AICargo.HasCargoClass(), which allows you to find, say, passenger-based cargo (tnx kuifware for the pointer!)
truebrain
parents: 10196
diff changeset
    62
	static bool HasCargoClass(CargoID cargo_type, CargoClass cargo_class);
b16fdb811ebb (svn r13219) [NoAI] -Add: added AICargo.HasCargoClass(), which allows you to find, say, passenger-based cargo (tnx kuifware for the pointer!)
truebrain
parents: 10196
diff changeset
    63
b16fdb811ebb (svn r13219) [NoAI] -Add: added AICargo.HasCargoClass(), which allows you to find, say, passenger-based cargo (tnx kuifware for the pointer!)
truebrain
parents: 10196
diff changeset
    64
	/**
9405
df6f3b4b0038 (svn r9202) [NoAI] -Add: some initial functions for cargo and industries.
rubidium
parents:
diff changeset
    65
	 * Get the income for transporting a piece of cargo over the
9447
8f3c1bc72204 (svn r9272) [NoAI] -Documentation: made the documentation of the first 3 API files more readable for non-programmers
truelight
parents: 9427
diff changeset
    66
	 *   given distance within the specified time.
9835
2541c2d325ed (svn r12500) [NoAI] -Documentation: many comment changes, mostly Capitals and lines end with a dot. Makes doxygen look pretty :)
truebrain
parents: 9829
diff changeset
    67
	 * @param cargo_type The cargo to transport.
2541c2d325ed (svn r12500) [NoAI] -Documentation: many comment changes, mostly Capitals and lines end with a dot. Makes doxygen look pretty :)
truebrain
parents: 9829
diff changeset
    68
	 * @param distance The distance the cargo travels from begin to end.
2541c2d325ed (svn r12500) [NoAI] -Documentation: many comment changes, mostly Capitals and lines end with a dot. Makes doxygen look pretty :)
truebrain
parents: 9829
diff changeset
    69
	 * @param days_in_transit Amount of (game) days the cargo is in transit.
2541c2d325ed (svn r12500) [NoAI] -Documentation: many comment changes, mostly Capitals and lines end with a dot. Makes doxygen look pretty :)
truebrain
parents: 9829
diff changeset
    70
	 * @return The amount of money that would be earned by this trip.
9405
df6f3b4b0038 (svn r9202) [NoAI] -Add: some initial functions for cargo and industries.
rubidium
parents:
diff changeset
    71
	 */
10196
aecabd927420 (svn r12728) [NoAI] -Codechange: always let functions return Money when they return something that can be quantified as money.
rubidium
parents: 9835
diff changeset
    72
	static Money GetCargoIncome(CargoID cargo_type, uint32 distance, uint32 days_in_transit);
9405
df6f3b4b0038 (svn r9202) [NoAI] -Add: some initial functions for cargo and industries.
rubidium
parents:
diff changeset
    73
};
df6f3b4b0038 (svn r9202) [NoAI] -Add: some initial functions for cargo and industries.
rubidium
parents:
diff changeset
    74
df6f3b4b0038 (svn r9202) [NoAI] -Add: some initial functions for cargo and industries.
rubidium
parents:
diff changeset
    75
#endif /* AI_CARGO_HPP */