src/ai/api/ai_map.cpp
author truelight
Sun, 19 Aug 2007 13:31:04 +0000
branchnoai
changeset 9698 1d50fe99b7e9
parent 9655 e8e43f333832
child 9723 eee46cb39750
permissions -rw-r--r--
(svn r10939) [NoAI] -Add: added AITileList valuator Water
[NoAI] -Add: added AITile::IsWater
9379
6e89b780c2c9 (svn r9168) [NoAI] -Add: AI wrapper functions for some map related queries.
rubidium
parents:
diff changeset
     1
/* $Id$ */
6e89b780c2c9 (svn r9168) [NoAI] -Add: AI wrapper functions for some map related queries.
rubidium
parents:
diff changeset
     2
9430
9e0a193b2bec (svn r9234) [NoAI] -Codechange: move away from the 'much' subdirectory approach for the API implementation.
rubidium
parents: 9427
diff changeset
     3
/** @file ai_map.cpp handles the query-related of the AIMap class */
9379
6e89b780c2c9 (svn r9168) [NoAI] -Add: AI wrapper functions for some map 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_map.hpp"
9489
d7ee0a65ead9 (svn r9359) [NoAI] -Add: function to determine distance and clear tiles.
rubidium
parents: 9430
diff changeset
     6
#include "../../command.h"
9379
6e89b780c2c9 (svn r9168) [NoAI] -Add: AI wrapper functions for some map related queries.
rubidium
parents:
diff changeset
     7
9655
e8e43f333832 (svn r10557) [NoAI] -Add: added for all lists 2 valuators: DistanceManhattanToTile and DistanceSquareToTile, to get the distance from object to some tile you specify
truelight
parents: 9502
diff changeset
     8
/* static */ bool AIMap::IsValidTile(TileIndex t)
9379
6e89b780c2c9 (svn r9168) [NoAI] -Add: AI wrapper functions for some map related queries.
rubidium
parents:
diff changeset
     9
{
9655
e8e43f333832 (svn r10557) [NoAI] -Add: added for all lists 2 valuators: DistanceManhattanToTile and DistanceSquareToTile, to get the distance from object to some tile you specify
truelight
parents: 9502
diff changeset
    10
	return t < AIMap::GetMapSize();
9379
6e89b780c2c9 (svn r9168) [NoAI] -Add: AI wrapper functions for some map related queries.
rubidium
parents:
diff changeset
    11
}
6e89b780c2c9 (svn r9168) [NoAI] -Add: AI wrapper functions for some map related queries.
rubidium
parents:
diff changeset
    12
9655
e8e43f333832 (svn r10557) [NoAI] -Add: added for all lists 2 valuators: DistanceManhattanToTile and DistanceSquareToTile, to get the distance from object to some tile you specify
truelight
parents: 9502
diff changeset
    13
/* static */ TileIndex AIMap::GetMapSize()
9379
6e89b780c2c9 (svn r9168) [NoAI] -Add: AI wrapper functions for some map related queries.
rubidium
parents:
diff changeset
    14
{
6e89b780c2c9 (svn r9168) [NoAI] -Add: AI wrapper functions for some map related queries.
rubidium
parents:
diff changeset
    15
	return ::MapSize();
6e89b780c2c9 (svn r9168) [NoAI] -Add: AI wrapper functions for some map related queries.
rubidium
parents:
diff changeset
    16
}
6e89b780c2c9 (svn r9168) [NoAI] -Add: AI wrapper functions for some map related queries.
rubidium
parents:
diff changeset
    17
9655
e8e43f333832 (svn r10557) [NoAI] -Add: added for all lists 2 valuators: DistanceManhattanToTile and DistanceSquareToTile, to get the distance from object to some tile you specify
truelight
parents: 9502
diff changeset
    18
/* static */ uint32 AIMap::GetMapSizeX()
9379
6e89b780c2c9 (svn r9168) [NoAI] -Add: AI wrapper functions for some map related queries.
rubidium
parents:
diff changeset
    19
{
6e89b780c2c9 (svn r9168) [NoAI] -Add: AI wrapper functions for some map related queries.
rubidium
parents:
diff changeset
    20
	return ::MapSizeX();
6e89b780c2c9 (svn r9168) [NoAI] -Add: AI wrapper functions for some map related queries.
rubidium
parents:
diff changeset
    21
}
6e89b780c2c9 (svn r9168) [NoAI] -Add: AI wrapper functions for some map related queries.
rubidium
parents:
diff changeset
    22
9655
e8e43f333832 (svn r10557) [NoAI] -Add: added for all lists 2 valuators: DistanceManhattanToTile and DistanceSquareToTile, to get the distance from object to some tile you specify
truelight
parents: 9502
diff changeset
    23
/* static */ uint32 AIMap::GetMapSizeY()
9379
6e89b780c2c9 (svn r9168) [NoAI] -Add: AI wrapper functions for some map related queries.
rubidium
parents:
diff changeset
    24
{
6e89b780c2c9 (svn r9168) [NoAI] -Add: AI wrapper functions for some map related queries.
rubidium
parents:
diff changeset
    25
	return ::MapSizeY();
6e89b780c2c9 (svn r9168) [NoAI] -Add: AI wrapper functions for some map related queries.
rubidium
parents:
diff changeset
    26
}
9430
9e0a193b2bec (svn r9234) [NoAI] -Codechange: move away from the 'much' subdirectory approach for the API implementation.
rubidium
parents: 9427
diff changeset
    27
9655
e8e43f333832 (svn r10557) [NoAI] -Add: added for all lists 2 valuators: DistanceManhattanToTile and DistanceSquareToTile, to get the distance from object to some tile you specify
truelight
parents: 9502
diff changeset
    28
/* static */ uint32 AIMap::GetTileX(TileIndex t)
9430
9e0a193b2bec (svn r9234) [NoAI] -Codechange: move away from the 'much' subdirectory approach for the API implementation.
rubidium
parents: 9427
diff changeset
    29
{
9e0a193b2bec (svn r9234) [NoAI] -Codechange: move away from the 'much' subdirectory approach for the API implementation.
rubidium
parents: 9427
diff changeset
    30
	return ::TileX(t);
9e0a193b2bec (svn r9234) [NoAI] -Codechange: move away from the 'much' subdirectory approach for the API implementation.
rubidium
parents: 9427
diff changeset
    31
}
9e0a193b2bec (svn r9234) [NoAI] -Codechange: move away from the 'much' subdirectory approach for the API implementation.
rubidium
parents: 9427
diff changeset
    32
9655
e8e43f333832 (svn r10557) [NoAI] -Add: added for all lists 2 valuators: DistanceManhattanToTile and DistanceSquareToTile, to get the distance from object to some tile you specify
truelight
parents: 9502
diff changeset
    33
/* static */ uint32 AIMap::GetTileY(TileIndex t)
9430
9e0a193b2bec (svn r9234) [NoAI] -Codechange: move away from the 'much' subdirectory approach for the API implementation.
rubidium
parents: 9427
diff changeset
    34
{
9e0a193b2bec (svn r9234) [NoAI] -Codechange: move away from the 'much' subdirectory approach for the API implementation.
rubidium
parents: 9427
diff changeset
    35
	return ::TileY(t);
9e0a193b2bec (svn r9234) [NoAI] -Codechange: move away from the 'much' subdirectory approach for the API implementation.
rubidium
parents: 9427
diff changeset
    36
}
9489
d7ee0a65ead9 (svn r9359) [NoAI] -Add: function to determine distance and clear tiles.
rubidium
parents: 9430
diff changeset
    37
9655
e8e43f333832 (svn r10557) [NoAI] -Add: added for all lists 2 valuators: DistanceManhattanToTile and DistanceSquareToTile, to get the distance from object to some tile you specify
truelight
parents: 9502
diff changeset
    38
/* static */ TileIndex AIMap::GetTileIndex(uint32 x, uint32 y)
9502
5eb285182114 (svn r9379) [NoAI] -Add: function to get the TileIndex from an (X, Y) coordinate.
rubidium
parents: 9489
diff changeset
    39
{
5eb285182114 (svn r9379) [NoAI] -Add: function to get the TileIndex from an (X, Y) coordinate.
rubidium
parents: 9489
diff changeset
    40
	return ::TileXY(x, y);
5eb285182114 (svn r9379) [NoAI] -Add: function to get the TileIndex from an (X, Y) coordinate.
rubidium
parents: 9489
diff changeset
    41
}
5eb285182114 (svn r9379) [NoAI] -Add: function to get the TileIndex from an (X, Y) coordinate.
rubidium
parents: 9489
diff changeset
    42
9655
e8e43f333832 (svn r10557) [NoAI] -Add: added for all lists 2 valuators: DistanceManhattanToTile and DistanceSquareToTile, to get the distance from object to some tile you specify
truelight
parents: 9502
diff changeset
    43
/* static */ uint32 AIMap::DistanceManhattan(TileIndex t1, TileIndex t2)
9489
d7ee0a65ead9 (svn r9359) [NoAI] -Add: function to determine distance and clear tiles.
rubidium
parents: 9430
diff changeset
    44
{
d7ee0a65ead9 (svn r9359) [NoAI] -Add: function to determine distance and clear tiles.
rubidium
parents: 9430
diff changeset
    45
	return ::DistanceManhattan(t1, t2);
d7ee0a65ead9 (svn r9359) [NoAI] -Add: function to determine distance and clear tiles.
rubidium
parents: 9430
diff changeset
    46
}
d7ee0a65ead9 (svn r9359) [NoAI] -Add: function to determine distance and clear tiles.
rubidium
parents: 9430
diff changeset
    47
9655
e8e43f333832 (svn r10557) [NoAI] -Add: added for all lists 2 valuators: DistanceManhattanToTile and DistanceSquareToTile, to get the distance from object to some tile you specify
truelight
parents: 9502
diff changeset
    48
/* static */ uint32 AIMap::DistanceMax(TileIndex t1, TileIndex t2)
9489
d7ee0a65ead9 (svn r9359) [NoAI] -Add: function to determine distance and clear tiles.
rubidium
parents: 9430
diff changeset
    49
{
d7ee0a65ead9 (svn r9359) [NoAI] -Add: function to determine distance and clear tiles.
rubidium
parents: 9430
diff changeset
    50
	return ::DistanceMax(t1, t2);
d7ee0a65ead9 (svn r9359) [NoAI] -Add: function to determine distance and clear tiles.
rubidium
parents: 9430
diff changeset
    51
}
d7ee0a65ead9 (svn r9359) [NoAI] -Add: function to determine distance and clear tiles.
rubidium
parents: 9430
diff changeset
    52
9655
e8e43f333832 (svn r10557) [NoAI] -Add: added for all lists 2 valuators: DistanceManhattanToTile and DistanceSquareToTile, to get the distance from object to some tile you specify
truelight
parents: 9502
diff changeset
    53
/* static */ uint32 AIMap::DistanceSquare(TileIndex t1, TileIndex t2)
9489
d7ee0a65ead9 (svn r9359) [NoAI] -Add: function to determine distance and clear tiles.
rubidium
parents: 9430
diff changeset
    54
{
d7ee0a65ead9 (svn r9359) [NoAI] -Add: function to determine distance and clear tiles.
rubidium
parents: 9430
diff changeset
    55
	return ::DistanceSquare(t1, t2);
d7ee0a65ead9 (svn r9359) [NoAI] -Add: function to determine distance and clear tiles.
rubidium
parents: 9430
diff changeset
    56
}
d7ee0a65ead9 (svn r9359) [NoAI] -Add: function to determine distance and clear tiles.
rubidium
parents: 9430
diff changeset
    57
9655
e8e43f333832 (svn r10557) [NoAI] -Add: added for all lists 2 valuators: DistanceManhattanToTile and DistanceSquareToTile, to get the distance from object to some tile you specify
truelight
parents: 9502
diff changeset
    58
/* static */ uint32 AIMap::DistanceFromEdge(TileIndex t)
9489
d7ee0a65ead9 (svn r9359) [NoAI] -Add: function to determine distance and clear tiles.
rubidium
parents: 9430
diff changeset
    59
{
d7ee0a65ead9 (svn r9359) [NoAI] -Add: function to determine distance and clear tiles.
rubidium
parents: 9430
diff changeset
    60
	return ::DistanceFromEdge(t);
d7ee0a65ead9 (svn r9359) [NoAI] -Add: function to determine distance and clear tiles.
rubidium
parents: 9430
diff changeset
    61
}
d7ee0a65ead9 (svn r9359) [NoAI] -Add: function to determine distance and clear tiles.
rubidium
parents: 9430
diff changeset
    62
d7ee0a65ead9 (svn r9359) [NoAI] -Add: function to determine distance and clear tiles.
rubidium
parents: 9430
diff changeset
    63
bool AIMap::DemolishTile(TileIndex t)
d7ee0a65ead9 (svn r9359) [NoAI] -Add: function to determine distance and clear tiles.
rubidium
parents: 9430
diff changeset
    64
{
d7ee0a65ead9 (svn r9359) [NoAI] -Add: function to determine distance and clear tiles.
rubidium
parents: 9430
diff changeset
    65
	return this->DoCommand(t, 0, 0, CMD_LANDSCAPE_CLEAR);
d7ee0a65ead9 (svn r9359) [NoAI] -Add: function to determine distance and clear tiles.
rubidium
parents: 9430
diff changeset
    66
}