src/ai/api/ai_tile.cpp
author truebrain
Thu, 24 Apr 2008 23:39:18 +0000
branchnoai
changeset 10339 ce6cd68d9eb8
parent 10191 da75d1460a4b
child 10360 3234cb59de55
permissions -rw-r--r--
(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.
-Note: this is perfectly safe; when a type changes, any sane compiler starts complaining about redefining the typedef to an other type
9617
df9cedf12aab (svn r9786) [NoAI] -Fix: NeighbourRoad -> NeighbourRoadCount
truelight
parents:
diff changeset
     1
/* $Id$ */
df9cedf12aab (svn r9786) [NoAI] -Fix: NeighbourRoad -> NeighbourRoadCount
truelight
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_tile.cpp Implementation of AITile. */
9617
df9cedf12aab (svn r9786) [NoAI] -Fix: NeighbourRoad -> NeighbourRoadCount
truelight
parents:
diff changeset
     4
df9cedf12aab (svn r9786) [NoAI] -Fix: NeighbourRoad -> NeighbourRoadCount
truelight
parents:
diff changeset
     5
#include "ai_tile.hpp"
9814
be51ea0adc29 (svn r12411) [NoAI] -Change [API CHANGE]: order of params of CargoIncome is changed
truebrain
parents: 9801
diff changeset
     6
#include "ai_map.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: 10191
diff changeset
     7
#include "../../openttd.h"
9723
eee46cb39750 (svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents: 9708
diff changeset
     8
#include "../../tile_map.h"
eee46cb39750 (svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents: 9708
diff changeset
     9
#include "../../map_func.h"
9617
df9cedf12aab (svn r9786) [NoAI] -Fix: NeighbourRoad -> NeighbourRoadCount
truelight
parents:
diff changeset
    10
#include "../../variables.h"
9837
c9ec4f82e0d0 (svn r12503) [NoAI] -Sync: with trunk r12461:12501.
rubidium
parents: 9834
diff changeset
    11
#include "../../station_func.h"
9723
eee46cb39750 (svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents: 9708
diff changeset
    12
#include "../../command_type.h"
9724
b39bc69bb2f2 (svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents: 9723
diff changeset
    13
#include "../../settings_type.h"
9769
015b6674c8ad (svn r12259) [NoAI] -Fix: depots were considered buildable (tnx Progman)
truebrain
parents: 9737
diff changeset
    14
#include "../../road_map.h"
9617
df9cedf12aab (svn r9786) [NoAI] -Fix: NeighbourRoad -> NeighbourRoadCount
truelight
parents:
diff changeset
    15
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
    16
/* static */ bool AITile::IsBuildable(TileIndex tile)
9617
df9cedf12aab (svn r9786) [NoAI] -Fix: NeighbourRoad -> NeighbourRoadCount
truelight
parents:
diff changeset
    17
{
9801
03a3eebd7fb7 (svn r12307) [NoAI] -Codechange: as followup on r12303 (trunk), use ::IsValidTile to check if a tile is inside the map, instead of all our custom ways
truebrain
parents: 9769
diff changeset
    18
	if (!::IsValidTile(tile)) return false;
9617
df9cedf12aab (svn r9786) [NoAI] -Fix: NeighbourRoad -> NeighbourRoadCount
truelight
parents:
diff changeset
    19
df9cedf12aab (svn r9786) [NoAI] -Fix: NeighbourRoad -> NeighbourRoadCount
truelight
parents:
diff changeset
    20
	switch (::GetTileType(tile)) {
9728
d7bd32dc6c59 (svn r12151) [NoAI] -Fix: use the correct types for returned values
glx
parents: 9724
diff changeset
    21
		default: return true;
9617
df9cedf12aab (svn r9786) [NoAI] -Fix: NeighbourRoad -> NeighbourRoadCount
truelight
parents:
diff changeset
    22
		case MP_VOID:
df9cedf12aab (svn r9786) [NoAI] -Fix: NeighbourRoad -> NeighbourRoadCount
truelight
parents:
diff changeset
    23
		case MP_HOUSE:
df9cedf12aab (svn r9786) [NoAI] -Fix: NeighbourRoad -> NeighbourRoadCount
truelight
parents:
diff changeset
    24
		case MP_STATION:
df9cedf12aab (svn r9786) [NoAI] -Fix: NeighbourRoad -> NeighbourRoadCount
truelight
parents:
diff changeset
    25
		case MP_INDUSTRY:
9697
a6a9379988f6 (svn r10938) [NoAI] -Fix r10937: regression update
truelight
parents: 9658
diff changeset
    26
		case MP_UNMOVABLE:
9728
d7bd32dc6c59 (svn r12151) [NoAI] -Fix: use the correct types for returned values
glx
parents: 9724
diff changeset
    27
		case MP_WATER: return false;
9769
015b6674c8ad (svn r12259) [NoAI] -Fix: depots were considered buildable (tnx Progman)
truebrain
parents: 9737
diff changeset
    28
015b6674c8ad (svn r12259) [NoAI] -Fix: depots were considered buildable (tnx Progman)
truebrain
parents: 9737
diff changeset
    29
		case MP_ROAD:
015b6674c8ad (svn r12259) [NoAI] -Fix: depots were considered buildable (tnx Progman)
truebrain
parents: 9737
diff changeset
    30
			/* Depots aren't considered buildable */
015b6674c8ad (svn r12259) [NoAI] -Fix: depots were considered buildable (tnx Progman)
truebrain
parents: 9737
diff changeset
    31
			if (::GetRoadTileType(tile) == ROAD_TILE_DEPOT) return false;
015b6674c8ad (svn r12259) [NoAI] -Fix: depots were considered buildable (tnx Progman)
truebrain
parents: 9737
diff changeset
    32
			return true;
9617
df9cedf12aab (svn r9786) [NoAI] -Fix: NeighbourRoad -> NeighbourRoadCount
truelight
parents:
diff changeset
    33
	}
df9cedf12aab (svn r9786) [NoAI] -Fix: NeighbourRoad -> NeighbourRoadCount
truelight
parents:
diff changeset
    34
}
df9cedf12aab (svn r9786) [NoAI] -Fix: NeighbourRoad -> NeighbourRoadCount
truelight
parents:
diff changeset
    35
9814
be51ea0adc29 (svn r12411) [NoAI] -Change [API CHANGE]: order of params of CargoIncome is changed
truebrain
parents: 9801
diff changeset
    36
/* static */ bool AITile::IsBuildableRectangle(TileIndex tile, uint width, uint height)
be51ea0adc29 (svn r12411) [NoAI] -Change [API CHANGE]: order of params of CargoIncome is changed
truebrain
parents: 9801
diff changeset
    37
{
be51ea0adc29 (svn r12411) [NoAI] -Change [API CHANGE]: order of params of CargoIncome is changed
truebrain
parents: 9801
diff changeset
    38
	uint tx, ty;
be51ea0adc29 (svn r12411) [NoAI] -Change [API CHANGE]: order of params of CargoIncome is changed
truebrain
parents: 9801
diff changeset
    39
be51ea0adc29 (svn r12411) [NoAI] -Change [API CHANGE]: order of params of CargoIncome is changed
truebrain
parents: 9801
diff changeset
    40
	tx = AIMap::GetTileX(tile);
be51ea0adc29 (svn r12411) [NoAI] -Change [API CHANGE]: order of params of CargoIncome is changed
truebrain
parents: 9801
diff changeset
    41
	ty = AIMap::GetTileY(tile);
be51ea0adc29 (svn r12411) [NoAI] -Change [API CHANGE]: order of params of CargoIncome is changed
truebrain
parents: 9801
diff changeset
    42
be51ea0adc29 (svn r12411) [NoAI] -Change [API CHANGE]: order of params of CargoIncome is changed
truebrain
parents: 9801
diff changeset
    43
	for (uint x = tx; x < width + tx; x++) {
be51ea0adc29 (svn r12411) [NoAI] -Change [API CHANGE]: order of params of CargoIncome is changed
truebrain
parents: 9801
diff changeset
    44
		for (uint y = ty; y < height + ty; y++) {
be51ea0adc29 (svn r12411) [NoAI] -Change [API CHANGE]: order of params of CargoIncome is changed
truebrain
parents: 9801
diff changeset
    45
			if (!IsBuildable(AIMap::GetTileIndex(x, y))) return false;
be51ea0adc29 (svn r12411) [NoAI] -Change [API CHANGE]: order of params of CargoIncome is changed
truebrain
parents: 9801
diff changeset
    46
		}
be51ea0adc29 (svn r12411) [NoAI] -Change [API CHANGE]: order of params of CargoIncome is changed
truebrain
parents: 9801
diff changeset
    47
	}
be51ea0adc29 (svn r12411) [NoAI] -Change [API CHANGE]: order of params of CargoIncome is changed
truebrain
parents: 9801
diff changeset
    48
be51ea0adc29 (svn r12411) [NoAI] -Change [API CHANGE]: order of params of CargoIncome is changed
truebrain
parents: 9801
diff changeset
    49
	return true;
be51ea0adc29 (svn r12411) [NoAI] -Change [API CHANGE]: order of params of CargoIncome is changed
truebrain
parents: 9801
diff changeset
    50
}
be51ea0adc29 (svn r12411) [NoAI] -Change [API CHANGE]: order of params of CargoIncome is changed
truebrain
parents: 9801
diff changeset
    51
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
    52
/* static */ bool AITile::IsWater(TileIndex tile)
9698
1d50fe99b7e9 (svn r10939) [NoAI] -Add: added AITileList valuator Water
truelight
parents: 9697
diff changeset
    53
{
9801
03a3eebd7fb7 (svn r12307) [NoAI] -Codechange: as followup on r12303 (trunk), use ::IsValidTile to check if a tile is inside the map, instead of all our custom ways
truebrain
parents: 9769
diff changeset
    54
	if (!::IsValidTile(tile)) return false;
9698
1d50fe99b7e9 (svn r10939) [NoAI] -Add: added AITileList valuator Water
truelight
parents: 9697
diff changeset
    55
1d50fe99b7e9 (svn r10939) [NoAI] -Add: added AITileList valuator Water
truelight
parents: 9697
diff changeset
    56
	return ::GetTileType(tile) == MP_WATER;
1d50fe99b7e9 (svn r10939) [NoAI] -Add: added AITileList valuator Water
truelight
parents: 9697
diff changeset
    57
}
1d50fe99b7e9 (svn r10939) [NoAI] -Add: added AITileList valuator Water
truelight
parents: 9697
diff changeset
    58
10191
da75d1460a4b (svn r12722) [NoAI] -Add (or -Feature for yorick): added AITile::IsSteepSlope(), AITile::IsHalftileSlope() and AITile::GetComplementSlope()
truebrain
parents: 10089
diff changeset
    59
/* static */ bool AITile::IsSteepSlope(Slope slope)
9617
df9cedf12aab (svn r9786) [NoAI] -Fix: NeighbourRoad -> NeighbourRoadCount
truelight
parents:
diff changeset
    60
{
10191
da75d1460a4b (svn r12722) [NoAI] -Add (or -Feature for yorick): added AITile::IsSteepSlope(), AITile::IsHalftileSlope() and AITile::GetComplementSlope()
truebrain
parents: 10089
diff changeset
    61
	if (slope == SLOPE_INVALID) return false;
9617
df9cedf12aab (svn r9786) [NoAI] -Fix: NeighbourRoad -> NeighbourRoadCount
truelight
parents:
diff changeset
    62
10191
da75d1460a4b (svn r12722) [NoAI] -Add (or -Feature for yorick): added AITile::IsSteepSlope(), AITile::IsHalftileSlope() and AITile::GetComplementSlope()
truebrain
parents: 10089
diff changeset
    63
	return ::IsSteepSlope((::Slope)slope);
da75d1460a4b (svn r12722) [NoAI] -Add (or -Feature for yorick): added AITile::IsSteepSlope(), AITile::IsHalftileSlope() and AITile::GetComplementSlope()
truebrain
parents: 10089
diff changeset
    64
}
da75d1460a4b (svn r12722) [NoAI] -Add (or -Feature for yorick): added AITile::IsSteepSlope(), AITile::IsHalftileSlope() and AITile::GetComplementSlope()
truebrain
parents: 10089
diff changeset
    65
da75d1460a4b (svn r12722) [NoAI] -Add (or -Feature for yorick): added AITile::IsSteepSlope(), AITile::IsHalftileSlope() and AITile::GetComplementSlope()
truebrain
parents: 10089
diff changeset
    66
/* static */ bool AITile::IsHalftileSlope(Slope slope)
da75d1460a4b (svn r12722) [NoAI] -Add (or -Feature for yorick): added AITile::IsSteepSlope(), AITile::IsHalftileSlope() and AITile::GetComplementSlope()
truebrain
parents: 10089
diff changeset
    67
{
da75d1460a4b (svn r12722) [NoAI] -Add (or -Feature for yorick): added AITile::IsSteepSlope(), AITile::IsHalftileSlope() and AITile::GetComplementSlope()
truebrain
parents: 10089
diff changeset
    68
	if (slope == SLOPE_INVALID) return false;
da75d1460a4b (svn r12722) [NoAI] -Add (or -Feature for yorick): added AITile::IsSteepSlope(), AITile::IsHalftileSlope() and AITile::GetComplementSlope()
truebrain
parents: 10089
diff changeset
    69
da75d1460a4b (svn r12722) [NoAI] -Add (or -Feature for yorick): added AITile::IsSteepSlope(), AITile::IsHalftileSlope() and AITile::GetComplementSlope()
truebrain
parents: 10089
diff changeset
    70
	return ::IsHalftileSlope((::Slope)slope);
da75d1460a4b (svn r12722) [NoAI] -Add (or -Feature for yorick): added AITile::IsSteepSlope(), AITile::IsHalftileSlope() and AITile::GetComplementSlope()
truebrain
parents: 10089
diff changeset
    71
}
da75d1460a4b (svn r12722) [NoAI] -Add (or -Feature for yorick): added AITile::IsSteepSlope(), AITile::IsHalftileSlope() and AITile::GetComplementSlope()
truebrain
parents: 10089
diff changeset
    72
da75d1460a4b (svn r12722) [NoAI] -Add (or -Feature for yorick): added AITile::IsSteepSlope(), AITile::IsHalftileSlope() and AITile::GetComplementSlope()
truebrain
parents: 10089
diff changeset
    73
/* static */ AITile::Slope AITile::GetSlope(TileIndex tile)
da75d1460a4b (svn r12722) [NoAI] -Add (or -Feature for yorick): added AITile::IsSteepSlope(), AITile::IsHalftileSlope() and AITile::GetComplementSlope()
truebrain
parents: 10089
diff changeset
    74
{
da75d1460a4b (svn r12722) [NoAI] -Add (or -Feature for yorick): added AITile::IsSteepSlope(), AITile::IsHalftileSlope() and AITile::GetComplementSlope()
truebrain
parents: 10089
diff changeset
    75
	if (!::IsValidTile(tile)) return SLOPE_INVALID;
da75d1460a4b (svn r12722) [NoAI] -Add (or -Feature for yorick): added AITile::IsSteepSlope(), AITile::IsHalftileSlope() and AITile::GetComplementSlope()
truebrain
parents: 10089
diff changeset
    76
da75d1460a4b (svn r12722) [NoAI] -Add (or -Feature for yorick): added AITile::IsSteepSlope(), AITile::IsHalftileSlope() and AITile::GetComplementSlope()
truebrain
parents: 10089
diff changeset
    77
	return (Slope)::GetTileSlope(tile, NULL);
da75d1460a4b (svn r12722) [NoAI] -Add (or -Feature for yorick): added AITile::IsSteepSlope(), AITile::IsHalftileSlope() and AITile::GetComplementSlope()
truebrain
parents: 10089
diff changeset
    78
}
da75d1460a4b (svn r12722) [NoAI] -Add (or -Feature for yorick): added AITile::IsSteepSlope(), AITile::IsHalftileSlope() and AITile::GetComplementSlope()
truebrain
parents: 10089
diff changeset
    79
da75d1460a4b (svn r12722) [NoAI] -Add (or -Feature for yorick): added AITile::IsSteepSlope(), AITile::IsHalftileSlope() and AITile::GetComplementSlope()
truebrain
parents: 10089
diff changeset
    80
/* static */ AITile::Slope AITile::GetComplementSlope(Slope slope)
da75d1460a4b (svn r12722) [NoAI] -Add (or -Feature for yorick): added AITile::IsSteepSlope(), AITile::IsHalftileSlope() and AITile::GetComplementSlope()
truebrain
parents: 10089
diff changeset
    81
{
da75d1460a4b (svn r12722) [NoAI] -Add (or -Feature for yorick): added AITile::IsSteepSlope(), AITile::IsHalftileSlope() and AITile::GetComplementSlope()
truebrain
parents: 10089
diff changeset
    82
	if (slope == SLOPE_INVALID) return SLOPE_INVALID;
da75d1460a4b (svn r12722) [NoAI] -Add (or -Feature for yorick): added AITile::IsSteepSlope(), AITile::IsHalftileSlope() and AITile::GetComplementSlope()
truebrain
parents: 10089
diff changeset
    83
	if (IsSteepSlope(slope)) return SLOPE_INVALID;
da75d1460a4b (svn r12722) [NoAI] -Add (or -Feature for yorick): added AITile::IsSteepSlope(), AITile::IsHalftileSlope() and AITile::GetComplementSlope()
truebrain
parents: 10089
diff changeset
    84
	if (IsHalftileSlope(slope)) return SLOPE_INVALID;
da75d1460a4b (svn r12722) [NoAI] -Add (or -Feature for yorick): added AITile::IsSteepSlope(), AITile::IsHalftileSlope() and AITile::GetComplementSlope()
truebrain
parents: 10089
diff changeset
    85
da75d1460a4b (svn r12722) [NoAI] -Add (or -Feature for yorick): added AITile::IsSteepSlope(), AITile::IsHalftileSlope() and AITile::GetComplementSlope()
truebrain
parents: 10089
diff changeset
    86
	return (Slope)::ComplementSlope((::Slope)slope);
9700
e442ce398e83 (svn r10941) [NoAI] -Add: added AITile::GetHeight and AITileList valuator Height
truelight
parents: 9698
diff changeset
    87
}
e442ce398e83 (svn r10941) [NoAI] -Add: added AITile::GetHeight and AITileList valuator Height
truelight
parents: 9698
diff changeset
    88
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
    89
/* static */ int32 AITile::GetHeight(TileIndex tile)
9700
e442ce398e83 (svn r10941) [NoAI] -Add: added AITile::GetHeight and AITileList valuator Height
truelight
parents: 9698
diff changeset
    90
{
9801
03a3eebd7fb7 (svn r12307) [NoAI] -Codechange: as followup on r12303 (trunk), use ::IsValidTile to check if a tile is inside the map, instead of all our custom ways
truebrain
parents: 9769
diff changeset
    91
	if (!::IsValidTile(tile)) return false;
9700
e442ce398e83 (svn r10941) [NoAI] -Add: added AITile::GetHeight and AITileList valuator Height
truelight
parents: 9698
diff changeset
    92
e442ce398e83 (svn r10941) [NoAI] -Add: added AITile::GetHeight and AITileList valuator Height
truelight
parents: 9698
diff changeset
    93
	return ::TileHeight(tile);
9617
df9cedf12aab (svn r9786) [NoAI] -Fix: NeighbourRoad -> NeighbourRoadCount
truelight
parents:
diff changeset
    94
}
df9cedf12aab (svn r9786) [NoAI] -Fix: NeighbourRoad -> NeighbourRoadCount
truelight
parents:
diff changeset
    95
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
    96
/* static */ int32 AITile::GetCargoAcceptance(TileIndex tile, CargoID cargo_type, uint width, uint height, uint radius)
9617
df9cedf12aab (svn r9786) [NoAI] -Fix: NeighbourRoad -> NeighbourRoadCount
truelight
parents:
diff changeset
    97
{
9801
03a3eebd7fb7 (svn r12307) [NoAI] -Codechange: as followup on r12303 (trunk), use ::IsValidTile to check if a tile is inside the map, instead of all our custom ways
truebrain
parents: 9769
diff changeset
    98
	if (!::IsValidTile(tile)) return false;
9617
df9cedf12aab (svn r9786) [NoAI] -Fix: NeighbourRoad -> NeighbourRoadCount
truelight
parents:
diff changeset
    99
df9cedf12aab (svn r9786) [NoAI] -Fix: NeighbourRoad -> NeighbourRoadCount
truelight
parents:
diff changeset
   100
	AcceptedCargo accepts;
9736
183b38e0a480 (svn r12215) [NoAI] -Codechange: added '::' if a function comes from non-AI-API functions (was inconsistant till now)
truebrain
parents: 9735
diff changeset
   101
	::GetAcceptanceAroundTiles(accepts, tile, width, height, _patches.modified_catchment ? radius : (uint)CA_UNMODIFIED);
9617
df9cedf12aab (svn r9786) [NoAI] -Fix: NeighbourRoad -> NeighbourRoadCount
truelight
parents:
diff changeset
   102
	return accepts[cargo_type];
df9cedf12aab (svn r9786) [NoAI] -Fix: NeighbourRoad -> NeighbourRoadCount
truelight
parents:
diff changeset
   103
}
9708
a63a756fd080 (svn r11274) [NoAI] -Add: added LowerTile and RaiseTile to 'terraform' the map a bit (dynaxo)
truelight
parents: 9700
diff changeset
   104
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
   105
/* static */ int32 AITile::GetCargoProduction(TileIndex tile, CargoID cargo_type, uint width, uint height, uint radius)
9729
c264c78a3567 (svn r12152) [NoAI] -Add [FS#1772]: add AITile.GetCargoProduction() function (Morloth)
glx
parents: 9728
diff changeset
   106
{
9801
03a3eebd7fb7 (svn r12307) [NoAI] -Codechange: as followup on r12303 (trunk), use ::IsValidTile to check if a tile is inside the map, instead of all our custom ways
truebrain
parents: 9769
diff changeset
   107
	if (!::IsValidTile(tile)) return false;
9729
c264c78a3567 (svn r12152) [NoAI] -Add [FS#1772]: add AITile.GetCargoProduction() function (Morloth)
glx
parents: 9728
diff changeset
   108
c264c78a3567 (svn r12152) [NoAI] -Add [FS#1772]: add AITile.GetCargoProduction() function (Morloth)
glx
parents: 9728
diff changeset
   109
	AcceptedCargo produced;
9736
183b38e0a480 (svn r12215) [NoAI] -Codechange: added '::' if a function comes from non-AI-API functions (was inconsistant till now)
truebrain
parents: 9735
diff changeset
   110
	::GetProductionAroundTiles(produced, tile, width, height, _patches.modified_catchment ? radius : (uint)CA_UNMODIFIED);
9729
c264c78a3567 (svn r12152) [NoAI] -Add [FS#1772]: add AITile.GetCargoProduction() function (Morloth)
glx
parents: 9728
diff changeset
   111
	return produced[cargo_type];
c264c78a3567 (svn r12152) [NoAI] -Add [FS#1772]: add AITile.GetCargoProduction() function (Morloth)
glx
parents: 9728
diff changeset
   112
}
c264c78a3567 (svn r12152) [NoAI] -Add [FS#1772]: add AITile.GetCargoProduction() function (Morloth)
glx
parents: 9728
diff changeset
   113
9834
9abe20fc83e5 (svn r12497) [NoAI] -Change [API CHANGE]: AIMap.DemolishTile -> AITile.DemolishTile (that makes much more sense, doesn't it? ;))
truebrain
parents: 9833
diff changeset
   114
/* static */ int32 AITile::GetDistanceManhattanToTile(TileIndex tile_from, TileIndex tile_to)
9abe20fc83e5 (svn r12497) [NoAI] -Change [API CHANGE]: AIMap.DemolishTile -> AITile.DemolishTile (that makes much more sense, doesn't it? ;))
truebrain
parents: 9833
diff changeset
   115
{
9abe20fc83e5 (svn r12497) [NoAI] -Change [API CHANGE]: AIMap.DemolishTile -> AITile.DemolishTile (that makes much more sense, doesn't it? ;))
truebrain
parents: 9833
diff changeset
   116
	return AIMap::DistanceManhattan(tile_from, tile_to);
9abe20fc83e5 (svn r12497) [NoAI] -Change [API CHANGE]: AIMap.DemolishTile -> AITile.DemolishTile (that makes much more sense, doesn't it? ;))
truebrain
parents: 9833
diff changeset
   117
}
9abe20fc83e5 (svn r12497) [NoAI] -Change [API CHANGE]: AIMap.DemolishTile -> AITile.DemolishTile (that makes much more sense, doesn't it? ;))
truebrain
parents: 9833
diff changeset
   118
9abe20fc83e5 (svn r12497) [NoAI] -Change [API CHANGE]: AIMap.DemolishTile -> AITile.DemolishTile (that makes much more sense, doesn't it? ;))
truebrain
parents: 9833
diff changeset
   119
/* static */ int32 AITile::GetDistanceSquareToTile(TileIndex tile_from, TileIndex tile_to)
9abe20fc83e5 (svn r12497) [NoAI] -Change [API CHANGE]: AIMap.DemolishTile -> AITile.DemolishTile (that makes much more sense, doesn't it? ;))
truebrain
parents: 9833
diff changeset
   120
{
9abe20fc83e5 (svn r12497) [NoAI] -Change [API CHANGE]: AIMap.DemolishTile -> AITile.DemolishTile (that makes much more sense, doesn't it? ;))
truebrain
parents: 9833
diff changeset
   121
	return AIMap::DistanceSquare(tile_from, tile_to);
9abe20fc83e5 (svn r12497) [NoAI] -Change [API CHANGE]: AIMap.DemolishTile -> AITile.DemolishTile (that makes much more sense, doesn't it? ;))
truebrain
parents: 9833
diff changeset
   122
}
9abe20fc83e5 (svn r12497) [NoAI] -Change [API CHANGE]: AIMap.DemolishTile -> AITile.DemolishTile (that makes much more sense, doesn't it? ;))
truebrain
parents: 9833
diff changeset
   123
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
   124
/* static */ bool AITile::RaiseTile(TileIndex tile, int32 slope)
9708
a63a756fd080 (svn r11274) [NoAI] -Add: added LowerTile and RaiseTile to 'terraform' the map a bit (dynaxo)
truelight
parents: 9700
diff changeset
   125
{
10089
e351169bf3a5 (svn r12613) [NoAI] -Add: support for GetLastError in AITile. Patch by Morloth.
rubidium
parents: 9837
diff changeset
   126
	EnforcePrecondition(false, ::IsValidTile(tile));
9708
a63a756fd080 (svn r11274) [NoAI] -Add: added LowerTile and RaiseTile to 'terraform' the map a bit (dynaxo)
truelight
parents: 9700
diff changeset
   127
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
   128
	return AIObject::DoCommand(tile, slope, 1, CMD_TERRAFORM_LAND);
9708
a63a756fd080 (svn r11274) [NoAI] -Add: added LowerTile and RaiseTile to 'terraform' the map a bit (dynaxo)
truelight
parents: 9700
diff changeset
   129
}
a63a756fd080 (svn r11274) [NoAI] -Add: added LowerTile and RaiseTile to 'terraform' the map a bit (dynaxo)
truelight
parents: 9700
diff changeset
   130
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
   131
/* static */ bool AITile::LowerTile(TileIndex tile, int32 slope)
9708
a63a756fd080 (svn r11274) [NoAI] -Add: added LowerTile and RaiseTile to 'terraform' the map a bit (dynaxo)
truelight
parents: 9700
diff changeset
   132
{
10089
e351169bf3a5 (svn r12613) [NoAI] -Add: support for GetLastError in AITile. Patch by Morloth.
rubidium
parents: 9837
diff changeset
   133
	EnforcePrecondition(false, ::IsValidTile(tile));
9708
a63a756fd080 (svn r11274) [NoAI] -Add: added LowerTile and RaiseTile to 'terraform' the map a bit (dynaxo)
truelight
parents: 9700
diff changeset
   134
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
   135
	return AIObject::DoCommand(tile, slope, 0, CMD_TERRAFORM_LAND);
9708
a63a756fd080 (svn r11274) [NoAI] -Add: added LowerTile and RaiseTile to 'terraform' the map a bit (dynaxo)
truelight
parents: 9700
diff changeset
   136
}
9814
be51ea0adc29 (svn r12411) [NoAI] -Change [API CHANGE]: order of params of CargoIncome is changed
truebrain
parents: 9801
diff changeset
   137
10089
e351169bf3a5 (svn r12613) [NoAI] -Add: support for GetLastError in AITile. Patch by Morloth.
rubidium
parents: 9837
diff changeset
   138
/* static */ bool AITile::DemolishTile(TileIndex tile)
9814
be51ea0adc29 (svn r12411) [NoAI] -Change [API CHANGE]: order of params of CargoIncome is changed
truebrain
parents: 9801
diff changeset
   139
{
10089
e351169bf3a5 (svn r12613) [NoAI] -Add: support for GetLastError in AITile. Patch by Morloth.
rubidium
parents: 9837
diff changeset
   140
	EnforcePrecondition(false, ::IsValidTile(tile));
e351169bf3a5 (svn r12613) [NoAI] -Add: support for GetLastError in AITile. Patch by Morloth.
rubidium
parents: 9837
diff changeset
   141
e351169bf3a5 (svn r12613) [NoAI] -Add: support for GetLastError in AITile. Patch by Morloth.
rubidium
parents: 9837
diff changeset
   142
	return AIObject::DoCommand(tile, 0, 0, CMD_LANDSCAPE_CLEAR);
9814
be51ea0adc29 (svn r12411) [NoAI] -Change [API CHANGE]: order of params of CargoIncome is changed
truebrain
parents: 9801
diff changeset
   143
}