src/ai/api/ai_town.hpp
author truebrain
Wed, 23 Apr 2008 12:05:32 +0000
branchnoai
changeset 10308 0c81dfce3e9b
parent 9838 0839682a601b
child 10339 ce6cd68d9eb8
permissions -rw-r--r--
(svn r12849) [NoAI] -Fix: when .hpp.sq doesn't exists, don't run diff (tnx to Yexo)
9380
f4c7eb98b43d (svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff changeset
     1
/* $Id$ */
f4c7eb98b43d (svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
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_town.hpp Everything to query towns. */
9380
f4c7eb98b43d (svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff changeset
     4
f4c7eb98b43d (svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff changeset
     5
#ifndef AI_TOWN_HPP
f4c7eb98b43d (svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff changeset
     6
#define AI_TOWN_HPP
f4c7eb98b43d (svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff changeset
     7
f4c7eb98b43d (svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff changeset
     8
#include "ai_object.hpp"
9723
eee46cb39750 (svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents: 9596
diff changeset
     9
#include "../../town_type.h"
9380
f4c7eb98b43d (svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
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 town 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
 */
9380
f4c7eb98b43d (svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff changeset
    14
class AITown : public AIObject {
f4c7eb98b43d (svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff changeset
    15
public:
9529
5f26f4bc574b (svn r9450) [NoAI] -Fix: don't allow static-method calls from SQ to non-static functions
truelight
parents: 9526
diff changeset
    16
	static const char *GetClassName() { return "AITown"; }
5f26f4bc574b (svn r9450) [NoAI] -Fix: don't allow static-method calls from SQ to non-static functions
truelight
parents: 9526
diff changeset
    17
5f26f4bc574b (svn r9450) [NoAI] -Fix: don't allow static-method calls from SQ to non-static functions
truelight
parents: 9526
diff changeset
    18
	/**
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
    19
	 * Gets the maximum town index; there are no valid towns with a higher index.
9838
0839682a601b (svn r12504) [NoAI] -Documentation: the last few files which now are consistent in their comments (anyway, so I hope :))
truebrain
parents: 9829
diff changeset
    20
	 * @return The maximum town index.
0839682a601b (svn r12504) [NoAI] -Documentation: the last few files which now are consistent in their comments (anyway, so I hope :))
truebrain
parents: 9829
diff changeset
    21
	 * @post Return value is always non-negative.
9380
f4c7eb98b43d (svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff changeset
    22
	 */
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
    23
	static TownID GetMaxTownID();
9380
f4c7eb98b43d (svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff changeset
    24
f4c7eb98b43d (svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff changeset
    25
	/**
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
    26
	 * Gets the number of towns. This is different than GetMaxTownID()
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
    27
	 *   because of the way OpenTTD works internally.
9838
0839682a601b (svn r12504) [NoAI] -Documentation: the last few files which now are consistent in their comments (anyway, so I hope :))
truebrain
parents: 9829
diff changeset
    28
	 * @return The number of towns.
0839682a601b (svn r12504) [NoAI] -Documentation: the last few files which now are consistent in their comments (anyway, so I hope :))
truebrain
parents: 9829
diff changeset
    29
	 * @post Return value is always non-negative.
9380
f4c7eb98b43d (svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff changeset
    30
	 */
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
    31
	static int32 GetTownCount();
9380
f4c7eb98b43d (svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff changeset
    32
f4c7eb98b43d (svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff changeset
    33
	/**
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
    34
	 * Checks whether the given town index is valid.
9838
0839682a601b (svn r12504) [NoAI] -Documentation: the last few files which now are consistent in their comments (anyway, so I hope :))
truebrain
parents: 9829
diff changeset
    35
	 * @param town_id The index to check.
0839682a601b (svn r12504) [NoAI] -Documentation: the last few files which now are consistent in their comments (anyway, so I hope :))
truebrain
parents: 9829
diff changeset
    36
	 * @return True if and only if the town is valid.
9380
f4c7eb98b43d (svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff changeset
    37
	 */
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
    38
	static bool IsValidTown(TownID town_id);
9380
f4c7eb98b43d (svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff changeset
    39
f4c7eb98b43d (svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff changeset
    40
	/**
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
    41
	 * Get the name of the town.
9838
0839682a601b (svn r12504) [NoAI] -Documentation: the last few files which now are consistent in their comments (anyway, so I hope :))
truebrain
parents: 9829
diff changeset
    42
	 * @param town_id The town to get the name of.
0839682a601b (svn r12504) [NoAI] -Documentation: the last few files which now are consistent in their comments (anyway, so I hope :))
truebrain
parents: 9829
diff changeset
    43
	 * @pre IsValidTown(town_id).
0839682a601b (svn r12504) [NoAI] -Documentation: the last few files which now are consistent in their comments (anyway, so I hope :))
truebrain
parents: 9829
diff changeset
    44
	 * @return The name of the town.
9380
f4c7eb98b43d (svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff changeset
    45
	 */
9582
40f54a61bb17 (svn r9606) [NoAI] -Fix: make GetXXX in AITown static, so we can use it without AITown instance
truelight
parents: 9541
diff changeset
    46
	static char *GetName(TownID town_id);
9380
f4c7eb98b43d (svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff changeset
    47
f4c7eb98b43d (svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff changeset
    48
	/**
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
    49
	 * Gets the number of inhabitants in the town.
9838
0839682a601b (svn r12504) [NoAI] -Documentation: the last few files which now are consistent in their comments (anyway, so I hope :))
truebrain
parents: 9829
diff changeset
    50
	 * @param town_id The town to get the name of.
0839682a601b (svn r12504) [NoAI] -Documentation: the last few files which now are consistent in their comments (anyway, so I hope :))
truebrain
parents: 9829
diff changeset
    51
	 * @pre IsValidTown(town_id).
0839682a601b (svn r12504) [NoAI] -Documentation: the last few files which now are consistent in their comments (anyway, so I hope :))
truebrain
parents: 9829
diff changeset
    52
	 * @return The number of inhabitants.
0839682a601b (svn r12504) [NoAI] -Documentation: the last few files which now are consistent in their comments (anyway, so I hope :))
truebrain
parents: 9829
diff changeset
    53
	 * @post Return value is always non-negative.
9380
f4c7eb98b43d (svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff changeset
    54
	 */
9582
40f54a61bb17 (svn r9606) [NoAI] -Fix: make GetXXX in AITown static, so we can use it without AITown instance
truelight
parents: 9541
diff changeset
    55
	static int32 GetPopulation(TownID town_id);
9380
f4c7eb98b43d (svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff changeset
    56
f4c7eb98b43d (svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff changeset
    57
	/**
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
    58
	 * Gets the location of the town.
9838
0839682a601b (svn r12504) [NoAI] -Documentation: the last few files which now are consistent in their comments (anyway, so I hope :))
truebrain
parents: 9829
diff changeset
    59
	 * @param town_id The location of the town.
0839682a601b (svn r12504) [NoAI] -Documentation: the last few files which now are consistent in their comments (anyway, so I hope :))
truebrain
parents: 9829
diff changeset
    60
	 * @pre IsValidTown(town_id).
0839682a601b (svn r12504) [NoAI] -Documentation: the last few files which now are consistent in their comments (anyway, so I hope :))
truebrain
parents: 9829
diff changeset
    61
	 * @return The location of the town.
9380
f4c7eb98b43d (svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff changeset
    62
	 */
9582
40f54a61bb17 (svn r9606) [NoAI] -Fix: make GetXXX in AITown static, so we can use it without AITown instance
truelight
parents: 9541
diff changeset
    63
	static TileIndex GetLocation(TownID town_id);
9814
be51ea0adc29 (svn r12411) [NoAI] -Change [API CHANGE]: order of params of CargoIncome is changed
truebrain
parents: 9801
diff changeset
    64
be51ea0adc29 (svn r12411) [NoAI] -Change [API CHANGE]: order of params of CargoIncome is changed
truebrain
parents: 9801
diff changeset
    65
	/**
be51ea0adc29 (svn r12411) [NoAI] -Change [API CHANGE]: order of params of CargoIncome is changed
truebrain
parents: 9801
diff changeset
    66
	 * Get the manhattan distance from the tile to the AITown::GetLocation()
be51ea0adc29 (svn r12411) [NoAI] -Change [API CHANGE]: order of params of CargoIncome is changed
truebrain
parents: 9801
diff changeset
    67
	 *  of the town.
be51ea0adc29 (svn r12411) [NoAI] -Change [API CHANGE]: order of params of CargoIncome is changed
truebrain
parents: 9801
diff changeset
    68
	 * @param town_id The town to get the distance to.
be51ea0adc29 (svn r12411) [NoAI] -Change [API CHANGE]: order of params of CargoIncome is changed
truebrain
parents: 9801
diff changeset
    69
	 * @param tile The tile to get the distance to.
9838
0839682a601b (svn r12504) [NoAI] -Documentation: the last few files which now are consistent in their comments (anyway, so I hope :))
truebrain
parents: 9829
diff changeset
    70
	 * @pre IsValidTown(town_id).
9814
be51ea0adc29 (svn r12411) [NoAI] -Change [API CHANGE]: order of params of CargoIncome is changed
truebrain
parents: 9801
diff changeset
    71
	 * @return The distance between town and tile.
be51ea0adc29 (svn r12411) [NoAI] -Change [API CHANGE]: order of params of CargoIncome is changed
truebrain
parents: 9801
diff changeset
    72
	 */
be51ea0adc29 (svn r12411) [NoAI] -Change [API CHANGE]: order of params of CargoIncome is changed
truebrain
parents: 9801
diff changeset
    73
	static int32 GetDistanceManhattanToTile(TownID town_id, TileIndex tile);
be51ea0adc29 (svn r12411) [NoAI] -Change [API CHANGE]: order of params of CargoIncome is changed
truebrain
parents: 9801
diff changeset
    74
be51ea0adc29 (svn r12411) [NoAI] -Change [API CHANGE]: order of params of CargoIncome is changed
truebrain
parents: 9801
diff changeset
    75
	/**
be51ea0adc29 (svn r12411) [NoAI] -Change [API CHANGE]: order of params of CargoIncome is changed
truebrain
parents: 9801
diff changeset
    76
	 * Get the square distance from the tile to the AITown::GetLocation()
be51ea0adc29 (svn r12411) [NoAI] -Change [API CHANGE]: order of params of CargoIncome is changed
truebrain
parents: 9801
diff changeset
    77
	 *  of the town.
be51ea0adc29 (svn r12411) [NoAI] -Change [API CHANGE]: order of params of CargoIncome is changed
truebrain
parents: 9801
diff changeset
    78
	 * @param town_id The town to get the distance to.
be51ea0adc29 (svn r12411) [NoAI] -Change [API CHANGE]: order of params of CargoIncome is changed
truebrain
parents: 9801
diff changeset
    79
	 * @param tile The tile to get the distance to.
9838
0839682a601b (svn r12504) [NoAI] -Documentation: the last few files which now are consistent in their comments (anyway, so I hope :))
truebrain
parents: 9829
diff changeset
    80
	 * @pre IsValidTown(town_id).
9814
be51ea0adc29 (svn r12411) [NoAI] -Change [API CHANGE]: order of params of CargoIncome is changed
truebrain
parents: 9801
diff changeset
    81
	 * @return The distance between town and tile.
be51ea0adc29 (svn r12411) [NoAI] -Change [API CHANGE]: order of params of CargoIncome is changed
truebrain
parents: 9801
diff changeset
    82
	 */
be51ea0adc29 (svn r12411) [NoAI] -Change [API CHANGE]: order of params of CargoIncome is changed
truebrain
parents: 9801
diff changeset
    83
	static int32 GetDistanceSquareToTile(TownID town_id, TileIndex tile);
9380
f4c7eb98b43d (svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff changeset
    84
};
f4c7eb98b43d (svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff changeset
    85
f4c7eb98b43d (svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff changeset
    86
#endif /* AI_TOWN_HPP */