src/ai/api/ai_town.hpp
author truebrain
Fri, 25 Apr 2008 15:51:12 +0000
branchnoai
changeset 10360 3234cb59de55
parent 10339 ce6cd68d9eb8
child 10361 4cdffd48480f
permissions -rw-r--r--
(svn r12901) [NoAI] -Add: added AITown.IsWithinTownRadius, AIStation.IsWithinTownRadius and AITile.GetOwner (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"
f4c7eb98b43d (svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff changeset
     9
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
    10
/**
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
 * 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
    12
 */
9380
f4c7eb98b43d (svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff changeset
    13
class AITown : public AIObject {
f4c7eb98b43d (svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
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 "AITown"; }
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
	/**
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
    18
	 * 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
    19
	 * @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
    20
	 * @post Return value is always non-negative.
9380
f4c7eb98b43d (svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff changeset
    21
	 */
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
    22
	static TownID GetMaxTownID();
9380
f4c7eb98b43d (svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff changeset
    23
f4c7eb98b43d (svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff changeset
    24
	/**
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
    25
	 * 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
    26
	 *   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
    27
	 * @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
    28
	 * @post Return value is always non-negative.
9380
f4c7eb98b43d (svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff changeset
    29
	 */
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
    30
	static int32 GetTownCount();
9380
f4c7eb98b43d (svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff changeset
    31
f4c7eb98b43d (svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff changeset
    32
	/**
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
    33
	 * 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
    34
	 * @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
    35
	 * @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
    36
	 */
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
    37
	static bool IsValidTown(TownID town_id);
9380
f4c7eb98b43d (svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff changeset
    38
f4c7eb98b43d (svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff changeset
    39
	/**
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
    40
	 * 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
    41
	 * @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
    42
	 * @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
    43
	 * @return The name of the town.
9380
f4c7eb98b43d (svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff changeset
    44
	 */
9582
40f54a61bb17 (svn r9606) [NoAI] -Fix: make GetXXX in AITown static, so we can use it without AITown instance
truelight
parents: 9541
diff changeset
    45
	static char *GetName(TownID town_id);
9380
f4c7eb98b43d (svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff changeset
    46
f4c7eb98b43d (svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff changeset
    47
	/**
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
    48
	 * 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
    49
	 * @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
    50
	 * @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
    51
	 * @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
    52
	 * @post Return value is always non-negative.
9380
f4c7eb98b43d (svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff changeset
    53
	 */
9582
40f54a61bb17 (svn r9606) [NoAI] -Fix: make GetXXX in AITown static, so we can use it without AITown instance
truelight
parents: 9541
diff changeset
    54
	static int32 GetPopulation(TownID town_id);
9380
f4c7eb98b43d (svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff changeset
    55
f4c7eb98b43d (svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff changeset
    56
	/**
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
    57
	 * 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
    58
	 * @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
    59
	 * @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
    60
	 * @return The location of the town.
9380
f4c7eb98b43d (svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff changeset
    61
	 */
9582
40f54a61bb17 (svn r9606) [NoAI] -Fix: make GetXXX in AITown static, so we can use it without AITown instance
truelight
parents: 9541
diff changeset
    62
	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
    63
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
	 * 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
    66
	 *  of the town.
be51ea0adc29 (svn r12411) [NoAI] -Change [API CHANGE]: order of params of CargoIncome is changed
truebrain
parents: 9801
diff changeset
    67
	 * @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
    68
	 * @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
    69
	 * @pre IsValidTown(town_id).
9814
be51ea0adc29 (svn r12411) [NoAI] -Change [API CHANGE]: order of params of CargoIncome is changed
truebrain
parents: 9801
diff changeset
    70
	 * @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
    71
	 */
be51ea0adc29 (svn r12411) [NoAI] -Change [API CHANGE]: order of params of CargoIncome is changed
truebrain
parents: 9801
diff changeset
    72
	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
    73
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
	 * 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
    76
	 *  of the town.
be51ea0adc29 (svn r12411) [NoAI] -Change [API CHANGE]: order of params of CargoIncome is changed
truebrain
parents: 9801
diff changeset
    77
	 * @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
    78
	 * @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
    79
	 * @pre IsValidTown(town_id).
9814
be51ea0adc29 (svn r12411) [NoAI] -Change [API CHANGE]: order of params of CargoIncome is changed
truebrain
parents: 9801
diff changeset
    80
	 * @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
    81
	 */
be51ea0adc29 (svn r12411) [NoAI] -Change [API CHANGE]: order of params of CargoIncome is changed
truebrain
parents: 9801
diff changeset
    82
	static int32 GetDistanceSquareToTile(TownID town_id, TileIndex tile);
10360
3234cb59de55 (svn r12901) [NoAI] -Add: added AITown.IsWithinTownRadius, AIStation.IsWithinTownRadius and AITile.GetOwner (Yexo)
truebrain
parents: 10339
diff changeset
    83
3234cb59de55 (svn r12901) [NoAI] -Add: added AITown.IsWithinTownRadius, AIStation.IsWithinTownRadius and AITile.GetOwner (Yexo)
truebrain
parents: 10339
diff changeset
    84
	/**
3234cb59de55 (svn r12901) [NoAI] -Add: added AITown.IsWithinTownRadius, AIStation.IsWithinTownRadius and AITile.GetOwner (Yexo)
truebrain
parents: 10339
diff changeset
    85
	 * Find out if this tile is within the rating influence of a town.
3234cb59de55 (svn r12901) [NoAI] -Add: added AITown.IsWithinTownRadius, AIStation.IsWithinTownRadius and AITile.GetOwner (Yexo)
truebrain
parents: 10339
diff changeset
    86
	 * @param town_id The town to check.
3234cb59de55 (svn r12901) [NoAI] -Add: added AITown.IsWithinTownRadius, AIStation.IsWithinTownRadius and AITile.GetOwner (Yexo)
truebrain
parents: 10339
diff changeset
    87
	 * @param tile The tile to check.
3234cb59de55 (svn r12901) [NoAI] -Add: added AITown.IsWithinTownRadius, AIStation.IsWithinTownRadius and AITile.GetOwner (Yexo)
truebrain
parents: 10339
diff changeset
    88
	 * @return True if the tile is within the rating influence of the town.
3234cb59de55 (svn r12901) [NoAI] -Add: added AITown.IsWithinTownRadius, AIStation.IsWithinTownRadius and AITile.GetOwner (Yexo)
truebrain
parents: 10339
diff changeset
    89
	 */
3234cb59de55 (svn r12901) [NoAI] -Add: added AITown.IsWithinTownRadius, AIStation.IsWithinTownRadius and AITile.GetOwner (Yexo)
truebrain
parents: 10339
diff changeset
    90
	static bool IsWithinTownRadius(TownID town_id, TileIndex tile);
9380
f4c7eb98b43d (svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff changeset
    91
};
f4c7eb98b43d (svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff changeset
    92
f4c7eb98b43d (svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff changeset
    93
#endif /* AI_TOWN_HPP */