src/ai/api/ai_town.hpp
author truebrain
Fri, 22 Feb 2008 12:30:17 +0000
branchnoai
changeset 9737 ee408edf3851
parent 9723 eee46cb39750
child 9801 03a3eebd7fb7
permissions -rw-r--r--
(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)
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
f4c7eb98b43d (svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff changeset
     3
/** @file ai_town.hpp Everything to query towns */
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:
f4c7eb98b43d (svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
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 "AITown"; }
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 town index; there are no valid towns with a 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
    23
	 * @return the maximum town 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
	 * @post return value is always non-negative.
9380
f4c7eb98b43d (svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff changeset
    25
	 */
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
    26
	static TownID GetMaxTownID();
9380
f4c7eb98b43d (svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff changeset
    27
f4c7eb98b43d (svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff changeset
    28
	/**
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
    29
	 * 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
    30
	 *   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
    31
	 * @return the number of towns.
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
	 * @post return value is always non-negative.
9380
f4c7eb98b43d (svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff changeset
    33
	 */
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
    34
	static int32 GetTownCount();
9380
f4c7eb98b43d (svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff changeset
    35
f4c7eb98b43d (svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff changeset
    36
	/**
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
    37
	 * Checks whether the given town 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
    38
	 * @param town_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
    39
	 * @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
    40
	 */
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
    41
	static bool IsValidTown(TownID town_id);
9380
f4c7eb98b43d (svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff changeset
    42
f4c7eb98b43d (svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff changeset
    43
	/**
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
    44
	 * Get the name of the town.
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
	 * @param town_id the town 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
    46
	 * @pre town_id has to be valid (use IsValidTown()).
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
	 * @return the name of the town.
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
	 * @note the returned name must be free'd (C++ only).
9380
f4c7eb98b43d (svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff changeset
    49
	 */
9582
40f54a61bb17 (svn r9606) [NoAI] -Fix: make GetXXX in AITown static, so we can use it without AITown instance
truelight
parents: 9541
diff changeset
    50
	static char *GetName(TownID town_id);
9380
f4c7eb98b43d (svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff changeset
    51
f4c7eb98b43d (svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff changeset
    52
	/**
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
    53
	 * Gets the number of inhabitants in the town.
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
    54
	 * @param town_id the town 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
    55
	 * @pre town_id has to be valid (use IsValidTown()).
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
    56
	 * @return the number of inhabitants.
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
	 * @post return value is always non-negative.
9380
f4c7eb98b43d (svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff changeset
    58
	 */
9582
40f54a61bb17 (svn r9606) [NoAI] -Fix: make GetXXX in AITown static, so we can use it without AITown instance
truelight
parents: 9541
diff changeset
    59
	static int32 GetPopulation(TownID town_id);
9380
f4c7eb98b43d (svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff changeset
    60
f4c7eb98b43d (svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff changeset
    61
	/**
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
    62
	 * Gets the location of the town.
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
    63
	 * @param town_id the location of the town.
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
    64
	 * @pre town_id has to be valid (use IsValidTown()).
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
    65
	 * @return the location of the town.
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
    66
	 * @post return value is always positive and below AIMap::GetMapSize().
9380
f4c7eb98b43d (svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff changeset
    67
	 */
9582
40f54a61bb17 (svn r9606) [NoAI] -Fix: make GetXXX in AITown static, so we can use it without AITown instance
truelight
parents: 9541
diff changeset
    68
	static TileIndex GetLocation(TownID town_id);
9380
f4c7eb98b43d (svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff changeset
    69
};
f4c7eb98b43d (svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff changeset
    70
f4c7eb98b43d (svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff changeset
    71
#endif /* AI_TOWN_HPP */