src/ai/api/ai_town.cpp
author truebrain
Sat, 07 Jun 2008 23:05:36 +0000
branchnoai
changeset 10853 87f2238f47d4
parent 10844 affb2821fb9f
child 10859 4c14a8041c0a
permissions -rw-r--r--
(svn r13404) [NoAI] -Change [API CHANGE]: AITile::IsBuildable no longer returns 'true' on road, but only on a halve piece of road (as that is auto-removed). This should make this function return less 'true', and more sane results :)
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
9833
89a64246458f (svn r12496) [NoAI] -Documentation: give the .cpp files a nice uniform format too
truebrain
parents: 9814
diff changeset
     3
/** @file ai_town.cpp Implementation of AITown. */
9380
f4c7eb98b43d (svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff changeset
     4
9430
9e0a193b2bec (svn r9234) [NoAI] -Codechange: move away from the 'much' subdirectory approach for the API implementation.
rubidium
parents: 9427
diff changeset
     5
#include "ai_town.hpp"
9814
be51ea0adc29 (svn r12411) [NoAI] -Change [API CHANGE]: order of params of CargoIncome is changed
truebrain
parents: 9737
diff changeset
     6
#include "ai_map.hpp"
10840
fd5945ab9ea6 (svn r13391) [NoAI] -Add: added AITown.GetNumHouses(), AITown.GetLastMonthProduction(), AITown.GetLastMonthTransported() and AITown.GetMaxProduction()
glx
parents: 10361
diff changeset
     7
#include "ai_cargo.hpp"
10339
ce6cd68d9eb8 (svn r12880) [NoAI] -Add: introduces ai_types.hpp, which has all NNNId like VehicleID. This simplifies the include-mess, and avoids including tons of _type.h for just a single typedef.
truebrain
parents: 10194
diff changeset
     8
#include "../../openttd.h"
9430
9e0a193b2bec (svn r9234) [NoAI] -Codechange: move away from the 'much' subdirectory approach for the API implementation.
rubidium
parents: 9427
diff changeset
     9
#include "../../town.h"
9723
eee46cb39750 (svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents: 9582
diff changeset
    10
#include "../../strings_func.h"
eee46cb39750 (svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents: 9582
diff changeset
    11
#include "../../core/alloc_func.hpp"
9405
df6f3b4b0038 (svn r9202) [NoAI] -Add: some initial functions for cargo and industries.
rubidium
parents: 9380
diff changeset
    12
#include "table/strings.h"
9380
f4c7eb98b43d (svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff changeset
    13
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: 9736
diff changeset
    14
/* static */ TownID AITown::GetMaxTownID()
9380
f4c7eb98b43d (svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff changeset
    15
{
f4c7eb98b43d (svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff changeset
    16
	return ::GetMaxTownIndex();
f4c7eb98b43d (svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff changeset
    17
}
f4c7eb98b43d (svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff changeset
    18
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: 9736
diff changeset
    19
/* static */ int32 AITown::GetTownCount()
9380
f4c7eb98b43d (svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff changeset
    20
{
f4c7eb98b43d (svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff changeset
    21
	return ::GetNumTowns();
f4c7eb98b43d (svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff changeset
    22
}
f4c7eb98b43d (svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff changeset
    23
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: 9459
diff changeset
    24
/* static */ bool AITown::IsValidTown(TownID town_id)
9380
f4c7eb98b43d (svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff changeset
    25
{
f4c7eb98b43d (svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff changeset
    26
	return ::IsValidTownID(town_id);
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
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: 9736
diff changeset
    29
/* static */ char *AITown::GetName(TownID town_id)
9380
f4c7eb98b43d (svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff changeset
    30
{
9736
183b38e0a480 (svn r12215) [NoAI] -Codechange: added '::' if a function comes from non-AI-API functions (was inconsistant till now)
truebrain
parents: 9723
diff changeset
    31
	if (!IsValidTown(town_id)) return NULL;
9380
f4c7eb98b43d (svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff changeset
    32
	static const int len = 64;
f4c7eb98b43d (svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff changeset
    33
	char *town_name = MallocT<char>(len);
f4c7eb98b43d (svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff changeset
    34
9736
183b38e0a480 (svn r12215) [NoAI] -Codechange: added '::' if a function comes from non-AI-API functions (was inconsistant till now)
truebrain
parents: 9723
diff changeset
    35
	::SetDParam(0, town_id);
183b38e0a480 (svn r12215) [NoAI] -Codechange: added '::' if a function comes from non-AI-API functions (was inconsistant till now)
truebrain
parents: 9723
diff changeset
    36
	::GetString(town_name, STR_TOWN, &town_name[len - 1]);
9380
f4c7eb98b43d (svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff changeset
    37
f4c7eb98b43d (svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff changeset
    38
	return town_name;
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
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: 9736
diff changeset
    41
/* static */ int32 AITown::GetPopulation(TownID town_id)
9380
f4c7eb98b43d (svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff changeset
    42
{
10194
c9fdeb7450da (svn r12727) [NoAI] -Fix (API CHANGE): return -1 to indicate invalidity, instead of 0 or -1, depending on the class
truebrain
parents: 9833
diff changeset
    43
	if (!IsValidTown(town_id)) return -1;
9380
f4c7eb98b43d (svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff changeset
    44
	const Town *t = ::GetTown(town_id);
f4c7eb98b43d (svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff changeset
    45
	return t->population;
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
10844
affb2821fb9f (svn r13395) [NoAI] -Fix [API CHANGE]: Rename AIOrder::GetNumberOfORders to AIOrder::GetOrderCount
truebrain
parents: 10840
diff changeset
    48
/* static */ int32 AITown::GetHouseCount(TownID town_id)
10840
fd5945ab9ea6 (svn r13391) [NoAI] -Add: added AITown.GetNumHouses(), AITown.GetLastMonthProduction(), AITown.GetLastMonthTransported() and AITown.GetMaxProduction()
glx
parents: 10361
diff changeset
    49
{
fd5945ab9ea6 (svn r13391) [NoAI] -Add: added AITown.GetNumHouses(), AITown.GetLastMonthProduction(), AITown.GetLastMonthTransported() and AITown.GetMaxProduction()
glx
parents: 10361
diff changeset
    50
	if (!IsValidTown(town_id)) return -1;
fd5945ab9ea6 (svn r13391) [NoAI] -Add: added AITown.GetNumHouses(), AITown.GetLastMonthProduction(), AITown.GetLastMonthTransported() and AITown.GetMaxProduction()
glx
parents: 10361
diff changeset
    51
	const Town *t = ::GetTown(town_id);
fd5945ab9ea6 (svn r13391) [NoAI] -Add: added AITown.GetNumHouses(), AITown.GetLastMonthProduction(), AITown.GetLastMonthTransported() and AITown.GetMaxProduction()
glx
parents: 10361
diff changeset
    52
	return t->num_houses;
fd5945ab9ea6 (svn r13391) [NoAI] -Add: added AITown.GetNumHouses(), AITown.GetLastMonthProduction(), AITown.GetLastMonthTransported() and AITown.GetMaxProduction()
glx
parents: 10361
diff changeset
    53
}
fd5945ab9ea6 (svn r13391) [NoAI] -Add: added AITown.GetNumHouses(), AITown.GetLastMonthProduction(), AITown.GetLastMonthTransported() and AITown.GetMaxProduction()
glx
parents: 10361
diff changeset
    54
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: 9736
diff changeset
    55
/* static */ TileIndex AITown::GetLocation(TownID town_id)
9380
f4c7eb98b43d (svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff changeset
    56
{
9736
183b38e0a480 (svn r12215) [NoAI] -Codechange: added '::' if a function comes from non-AI-API functions (was inconsistant till now)
truebrain
parents: 9723
diff changeset
    57
	if (!IsValidTown(town_id)) return INVALID_TILE;
9380
f4c7eb98b43d (svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff changeset
    58
	const Town *t = ::GetTown(town_id);
f4c7eb98b43d (svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff changeset
    59
	return t->xy;
f4c7eb98b43d (svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff changeset
    60
}
9814
be51ea0adc29 (svn r12411) [NoAI] -Change [API CHANGE]: order of params of CargoIncome is changed
truebrain
parents: 9737
diff changeset
    61
10840
fd5945ab9ea6 (svn r13391) [NoAI] -Add: added AITown.GetNumHouses(), AITown.GetLastMonthProduction(), AITown.GetLastMonthTransported() and AITown.GetMaxProduction()
glx
parents: 10361
diff changeset
    62
/* static */ int32 AITown::GetLastMonthProduction(TownID town_id, CargoID cargo_id)
fd5945ab9ea6 (svn r13391) [NoAI] -Add: added AITown.GetNumHouses(), AITown.GetLastMonthProduction(), AITown.GetLastMonthTransported() and AITown.GetMaxProduction()
glx
parents: 10361
diff changeset
    63
{
fd5945ab9ea6 (svn r13391) [NoAI] -Add: added AITown.GetNumHouses(), AITown.GetLastMonthProduction(), AITown.GetLastMonthTransported() and AITown.GetMaxProduction()
glx
parents: 10361
diff changeset
    64
	if (!IsValidTown(town_id)) return -1;
fd5945ab9ea6 (svn r13391) [NoAI] -Add: added AITown.GetNumHouses(), AITown.GetLastMonthProduction(), AITown.GetLastMonthTransported() and AITown.GetMaxProduction()
glx
parents: 10361
diff changeset
    65
	if (!AICargo::IsValidCargo(cargo_id)) return -1;
fd5945ab9ea6 (svn r13391) [NoAI] -Add: added AITown.GetNumHouses(), AITown.GetLastMonthProduction(), AITown.GetLastMonthTransported() and AITown.GetMaxProduction()
glx
parents: 10361
diff changeset
    66
fd5945ab9ea6 (svn r13391) [NoAI] -Add: added AITown.GetNumHouses(), AITown.GetLastMonthProduction(), AITown.GetLastMonthTransported() and AITown.GetMaxProduction()
glx
parents: 10361
diff changeset
    67
	const Town *t = ::GetTown(town_id);
fd5945ab9ea6 (svn r13391) [NoAI] -Add: added AITown.GetNumHouses(), AITown.GetLastMonthProduction(), AITown.GetLastMonthTransported() and AITown.GetMaxProduction()
glx
parents: 10361
diff changeset
    68
fd5945ab9ea6 (svn r13391) [NoAI] -Add: added AITown.GetNumHouses(), AITown.GetLastMonthProduction(), AITown.GetLastMonthTransported() and AITown.GetMaxProduction()
glx
parents: 10361
diff changeset
    69
	switch(AICargo::GetTownEffect(cargo_id)) {
fd5945ab9ea6 (svn r13391) [NoAI] -Add: added AITown.GetNumHouses(), AITown.GetLastMonthProduction(), AITown.GetLastMonthTransported() and AITown.GetMaxProduction()
glx
parents: 10361
diff changeset
    70
		case AICargo::TE_PASSENGERS: return t->act_pass;
fd5945ab9ea6 (svn r13391) [NoAI] -Add: added AITown.GetNumHouses(), AITown.GetLastMonthProduction(), AITown.GetLastMonthTransported() and AITown.GetMaxProduction()
glx
parents: 10361
diff changeset
    71
		case AICargo::TE_MAIL:       return t->act_mail;
fd5945ab9ea6 (svn r13391) [NoAI] -Add: added AITown.GetNumHouses(), AITown.GetLastMonthProduction(), AITown.GetLastMonthTransported() and AITown.GetMaxProduction()
glx
parents: 10361
diff changeset
    72
		default: return -1;
fd5945ab9ea6 (svn r13391) [NoAI] -Add: added AITown.GetNumHouses(), AITown.GetLastMonthProduction(), AITown.GetLastMonthTransported() and AITown.GetMaxProduction()
glx
parents: 10361
diff changeset
    73
	}
fd5945ab9ea6 (svn r13391) [NoAI] -Add: added AITown.GetNumHouses(), AITown.GetLastMonthProduction(), AITown.GetLastMonthTransported() and AITown.GetMaxProduction()
glx
parents: 10361
diff changeset
    74
}
fd5945ab9ea6 (svn r13391) [NoAI] -Add: added AITown.GetNumHouses(), AITown.GetLastMonthProduction(), AITown.GetLastMonthTransported() and AITown.GetMaxProduction()
glx
parents: 10361
diff changeset
    75
fd5945ab9ea6 (svn r13391) [NoAI] -Add: added AITown.GetNumHouses(), AITown.GetLastMonthProduction(), AITown.GetLastMonthTransported() and AITown.GetMaxProduction()
glx
parents: 10361
diff changeset
    76
/* static */ int32 AITown::GetLastMonthTransported(TownID town_id, CargoID cargo_id)
fd5945ab9ea6 (svn r13391) [NoAI] -Add: added AITown.GetNumHouses(), AITown.GetLastMonthProduction(), AITown.GetLastMonthTransported() and AITown.GetMaxProduction()
glx
parents: 10361
diff changeset
    77
{
fd5945ab9ea6 (svn r13391) [NoAI] -Add: added AITown.GetNumHouses(), AITown.GetLastMonthProduction(), AITown.GetLastMonthTransported() and AITown.GetMaxProduction()
glx
parents: 10361
diff changeset
    78
	if (!IsValidTown(town_id)) return -1;
fd5945ab9ea6 (svn r13391) [NoAI] -Add: added AITown.GetNumHouses(), AITown.GetLastMonthProduction(), AITown.GetLastMonthTransported() and AITown.GetMaxProduction()
glx
parents: 10361
diff changeset
    79
	if (!AICargo::IsValidCargo(cargo_id)) return -1;
fd5945ab9ea6 (svn r13391) [NoAI] -Add: added AITown.GetNumHouses(), AITown.GetLastMonthProduction(), AITown.GetLastMonthTransported() and AITown.GetMaxProduction()
glx
parents: 10361
diff changeset
    80
fd5945ab9ea6 (svn r13391) [NoAI] -Add: added AITown.GetNumHouses(), AITown.GetLastMonthProduction(), AITown.GetLastMonthTransported() and AITown.GetMaxProduction()
glx
parents: 10361
diff changeset
    81
	const Town *t = ::GetTown(town_id);
fd5945ab9ea6 (svn r13391) [NoAI] -Add: added AITown.GetNumHouses(), AITown.GetLastMonthProduction(), AITown.GetLastMonthTransported() and AITown.GetMaxProduction()
glx
parents: 10361
diff changeset
    82
fd5945ab9ea6 (svn r13391) [NoAI] -Add: added AITown.GetNumHouses(), AITown.GetLastMonthProduction(), AITown.GetLastMonthTransported() and AITown.GetMaxProduction()
glx
parents: 10361
diff changeset
    83
	switch(AICargo::GetTownEffect(cargo_id)) {
fd5945ab9ea6 (svn r13391) [NoAI] -Add: added AITown.GetNumHouses(), AITown.GetLastMonthProduction(), AITown.GetLastMonthTransported() and AITown.GetMaxProduction()
glx
parents: 10361
diff changeset
    84
		case AICargo::TE_PASSENGERS: return t->pct_pass_transported;
fd5945ab9ea6 (svn r13391) [NoAI] -Add: added AITown.GetNumHouses(), AITown.GetLastMonthProduction(), AITown.GetLastMonthTransported() and AITown.GetMaxProduction()
glx
parents: 10361
diff changeset
    85
		case AICargo::TE_MAIL:       return t->pct_mail_transported;
fd5945ab9ea6 (svn r13391) [NoAI] -Add: added AITown.GetNumHouses(), AITown.GetLastMonthProduction(), AITown.GetLastMonthTransported() and AITown.GetMaxProduction()
glx
parents: 10361
diff changeset
    86
		default: return -1;
fd5945ab9ea6 (svn r13391) [NoAI] -Add: added AITown.GetNumHouses(), AITown.GetLastMonthProduction(), AITown.GetLastMonthTransported() and AITown.GetMaxProduction()
glx
parents: 10361
diff changeset
    87
	}
fd5945ab9ea6 (svn r13391) [NoAI] -Add: added AITown.GetNumHouses(), AITown.GetLastMonthProduction(), AITown.GetLastMonthTransported() and AITown.GetMaxProduction()
glx
parents: 10361
diff changeset
    88
}
fd5945ab9ea6 (svn r13391) [NoAI] -Add: added AITown.GetNumHouses(), AITown.GetLastMonthProduction(), AITown.GetLastMonthTransported() and AITown.GetMaxProduction()
glx
parents: 10361
diff changeset
    89
fd5945ab9ea6 (svn r13391) [NoAI] -Add: added AITown.GetNumHouses(), AITown.GetLastMonthProduction(), AITown.GetLastMonthTransported() and AITown.GetMaxProduction()
glx
parents: 10361
diff changeset
    90
/* static */ int32 AITown::GetMaxProduction(TownID town_id, CargoID cargo_id)
fd5945ab9ea6 (svn r13391) [NoAI] -Add: added AITown.GetNumHouses(), AITown.GetLastMonthProduction(), AITown.GetLastMonthTransported() and AITown.GetMaxProduction()
glx
parents: 10361
diff changeset
    91
{
fd5945ab9ea6 (svn r13391) [NoAI] -Add: added AITown.GetNumHouses(), AITown.GetLastMonthProduction(), AITown.GetLastMonthTransported() and AITown.GetMaxProduction()
glx
parents: 10361
diff changeset
    92
	if (!IsValidTown(town_id)) return -1;
fd5945ab9ea6 (svn r13391) [NoAI] -Add: added AITown.GetNumHouses(), AITown.GetLastMonthProduction(), AITown.GetLastMonthTransported() and AITown.GetMaxProduction()
glx
parents: 10361
diff changeset
    93
	if (!AICargo::IsValidCargo(cargo_id)) return -1;
fd5945ab9ea6 (svn r13391) [NoAI] -Add: added AITown.GetNumHouses(), AITown.GetLastMonthProduction(), AITown.GetLastMonthTransported() and AITown.GetMaxProduction()
glx
parents: 10361
diff changeset
    94
fd5945ab9ea6 (svn r13391) [NoAI] -Add: added AITown.GetNumHouses(), AITown.GetLastMonthProduction(), AITown.GetLastMonthTransported() and AITown.GetMaxProduction()
glx
parents: 10361
diff changeset
    95
	const Town *t = ::GetTown(town_id);
fd5945ab9ea6 (svn r13391) [NoAI] -Add: added AITown.GetNumHouses(), AITown.GetLastMonthProduction(), AITown.GetLastMonthTransported() and AITown.GetMaxProduction()
glx
parents: 10361
diff changeset
    96
fd5945ab9ea6 (svn r13391) [NoAI] -Add: added AITown.GetNumHouses(), AITown.GetLastMonthProduction(), AITown.GetLastMonthTransported() and AITown.GetMaxProduction()
glx
parents: 10361
diff changeset
    97
	switch(AICargo::GetTownEffect(cargo_id)) {
fd5945ab9ea6 (svn r13391) [NoAI] -Add: added AITown.GetNumHouses(), AITown.GetLastMonthProduction(), AITown.GetLastMonthTransported() and AITown.GetMaxProduction()
glx
parents: 10361
diff changeset
    98
		case AICargo::TE_PASSENGERS: return t->max_pass;
fd5945ab9ea6 (svn r13391) [NoAI] -Add: added AITown.GetNumHouses(), AITown.GetLastMonthProduction(), AITown.GetLastMonthTransported() and AITown.GetMaxProduction()
glx
parents: 10361
diff changeset
    99
		case AICargo::TE_MAIL:       return t->max_mail;
fd5945ab9ea6 (svn r13391) [NoAI] -Add: added AITown.GetNumHouses(), AITown.GetLastMonthProduction(), AITown.GetLastMonthTransported() and AITown.GetMaxProduction()
glx
parents: 10361
diff changeset
   100
		default: return -1;
fd5945ab9ea6 (svn r13391) [NoAI] -Add: added AITown.GetNumHouses(), AITown.GetLastMonthProduction(), AITown.GetLastMonthTransported() and AITown.GetMaxProduction()
glx
parents: 10361
diff changeset
   101
	}
fd5945ab9ea6 (svn r13391) [NoAI] -Add: added AITown.GetNumHouses(), AITown.GetLastMonthProduction(), AITown.GetLastMonthTransported() and AITown.GetMaxProduction()
glx
parents: 10361
diff changeset
   102
}
fd5945ab9ea6 (svn r13391) [NoAI] -Add: added AITown.GetNumHouses(), AITown.GetLastMonthProduction(), AITown.GetLastMonthTransported() and AITown.GetMaxProduction()
glx
parents: 10361
diff changeset
   103
9814
be51ea0adc29 (svn r12411) [NoAI] -Change [API CHANGE]: order of params of CargoIncome is changed
truebrain
parents: 9737
diff changeset
   104
/* static */ int32 AITown::GetDistanceManhattanToTile(TownID town_id, TileIndex tile)
be51ea0adc29 (svn r12411) [NoAI] -Change [API CHANGE]: order of params of CargoIncome is changed
truebrain
parents: 9737
diff changeset
   105
{
be51ea0adc29 (svn r12411) [NoAI] -Change [API CHANGE]: order of params of CargoIncome is changed
truebrain
parents: 9737
diff changeset
   106
	return AIMap::DistanceManhattan(tile, GetLocation(town_id));
be51ea0adc29 (svn r12411) [NoAI] -Change [API CHANGE]: order of params of CargoIncome is changed
truebrain
parents: 9737
diff changeset
   107
}
be51ea0adc29 (svn r12411) [NoAI] -Change [API CHANGE]: order of params of CargoIncome is changed
truebrain
parents: 9737
diff changeset
   108
be51ea0adc29 (svn r12411) [NoAI] -Change [API CHANGE]: order of params of CargoIncome is changed
truebrain
parents: 9737
diff changeset
   109
/* static */ int32 AITown::GetDistanceSquareToTile(TownID town_id, TileIndex tile)
be51ea0adc29 (svn r12411) [NoAI] -Change [API CHANGE]: order of params of CargoIncome is changed
truebrain
parents: 9737
diff changeset
   110
{
be51ea0adc29 (svn r12411) [NoAI] -Change [API CHANGE]: order of params of CargoIncome is changed
truebrain
parents: 9737
diff changeset
   111
	return AIMap::DistanceSquare(tile, GetLocation(town_id));
be51ea0adc29 (svn r12411) [NoAI] -Change [API CHANGE]: order of params of CargoIncome is changed
truebrain
parents: 9737
diff changeset
   112
}
10360
3234cb59de55 (svn r12901) [NoAI] -Add: added AITown.IsWithinTownRadius, AIStation.IsWithinTownRadius and AITile.GetOwner (Yexo)
truebrain
parents: 10339
diff changeset
   113
10361
4cdffd48480f (svn r12902) [NoAI] -Fix r12901 [API CHANGE]: renamed IsWithinTownRadius to IsWithinTownInfluence, as that reflects the meaning much better
truebrain
parents: 10360
diff changeset
   114
/* static */ bool AITown::IsWithinTownInfluence(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
   115
{
3234cb59de55 (svn r12901) [NoAI] -Add: added AITown.IsWithinTownRadius, AIStation.IsWithinTownRadius and AITile.GetOwner (Yexo)
truebrain
parents: 10339
diff changeset
   116
	const Town *t = ::GetTown(town_id);
3234cb59de55 (svn r12901) [NoAI] -Add: added AITown.IsWithinTownRadius, AIStation.IsWithinTownRadius and AITile.GetOwner (Yexo)
truebrain
parents: 10339
diff changeset
   117
	return ((uint32)GetDistanceSquareToTile(town_id, tile) <= t->squared_town_zone_radius[0]);
3234cb59de55 (svn r12901) [NoAI] -Add: added AITown.IsWithinTownRadius, AIStation.IsWithinTownRadius and AITile.GetOwner (Yexo)
truebrain
parents: 10339
diff changeset
   118
}