src/ai/api/ai_map.cpp
author rubidium
Wed, 09 Jan 2008 18:11:12 +0000
branchnoai
changeset 9723 eee46cb39750
parent 9655 e8e43f333832
child 9737 ee408edf3851
permissions -rw-r--r--
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
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"
9723
eee46cb39750 (svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents: 9655
diff changeset
     6
#include "../../command_type.h"
eee46cb39750 (svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents: 9655
diff changeset
     7
#include "../../map_func.h"
9379
6e89b780c2c9 (svn r9168) [NoAI] -Add: AI wrapper functions for some map related queries.
rubidium
parents:
diff changeset
     8
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
     9
/* static */ bool AIMap::IsValidTile(TileIndex t)
9379
6e89b780c2c9 (svn r9168) [NoAI] -Add: AI wrapper functions for some map related queries.
rubidium
parents:
diff changeset
    10
{
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
    11
	return t < AIMap::GetMapSize();
9379
6e89b780c2c9 (svn r9168) [NoAI] -Add: AI wrapper functions for some map related queries.
rubidium
parents:
diff changeset
    12
}
6e89b780c2c9 (svn r9168) [NoAI] -Add: AI wrapper functions for some map related queries.
rubidium
parents:
diff changeset
    13
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
    14
/* static */ TileIndex AIMap::GetMapSize()
9379
6e89b780c2c9 (svn r9168) [NoAI] -Add: AI wrapper functions for some map related queries.
rubidium
parents:
diff changeset
    15
{
6e89b780c2c9 (svn r9168) [NoAI] -Add: AI wrapper functions for some map related queries.
rubidium
parents:
diff changeset
    16
	return ::MapSize();
6e89b780c2c9 (svn r9168) [NoAI] -Add: AI wrapper functions for some map related queries.
rubidium
parents:
diff changeset
    17
}
6e89b780c2c9 (svn r9168) [NoAI] -Add: AI wrapper functions for some map related queries.
rubidium
parents:
diff changeset
    18
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
    19
/* static */ uint32 AIMap::GetMapSizeX()
9379
6e89b780c2c9 (svn r9168) [NoAI] -Add: AI wrapper functions for some map related queries.
rubidium
parents:
diff changeset
    20
{
6e89b780c2c9 (svn r9168) [NoAI] -Add: AI wrapper functions for some map related queries.
rubidium
parents:
diff changeset
    21
	return ::MapSizeX();
6e89b780c2c9 (svn r9168) [NoAI] -Add: AI wrapper functions for some map related queries.
rubidium
parents:
diff changeset
    22
}
6e89b780c2c9 (svn r9168) [NoAI] -Add: AI wrapper functions for some map related queries.
rubidium
parents:
diff changeset
    23
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
    24
/* static */ uint32 AIMap::GetMapSizeY()
9379
6e89b780c2c9 (svn r9168) [NoAI] -Add: AI wrapper functions for some map related queries.
rubidium
parents:
diff changeset
    25
{
6e89b780c2c9 (svn r9168) [NoAI] -Add: AI wrapper functions for some map related queries.
rubidium
parents:
diff changeset
    26
	return ::MapSizeY();
6e89b780c2c9 (svn r9168) [NoAI] -Add: AI wrapper functions for some map related queries.
rubidium
parents:
diff changeset
    27
}
9430
9e0a193b2bec (svn r9234) [NoAI] -Codechange: move away from the 'much' subdirectory approach for the API implementation.
rubidium
parents: 9427
diff changeset
    28
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
    29
/* 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
    30
{
9e0a193b2bec (svn r9234) [NoAI] -Codechange: move away from the 'much' subdirectory approach for the API implementation.
rubidium
parents: 9427
diff changeset
    31
	return ::TileX(t);
9e0a193b2bec (svn r9234) [NoAI] -Codechange: move away from the 'much' subdirectory approach for the API implementation.
rubidium
parents: 9427
diff changeset
    32
}
9e0a193b2bec (svn r9234) [NoAI] -Codechange: move away from the 'much' subdirectory approach for the API implementation.
rubidium
parents: 9427
diff changeset
    33
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
    34
/* 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
    35
{
9e0a193b2bec (svn r9234) [NoAI] -Codechange: move away from the 'much' subdirectory approach for the API implementation.
rubidium
parents: 9427
diff changeset
    36
	return ::TileY(t);
9e0a193b2bec (svn r9234) [NoAI] -Codechange: move away from the 'much' subdirectory approach for the API implementation.
rubidium
parents: 9427
diff changeset
    37
}
9489
d7ee0a65ead9 (svn r9359) [NoAI] -Add: function to determine distance and clear tiles.
rubidium
parents: 9430
diff changeset
    38
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
    39
/* 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
    40
{
5eb285182114 (svn r9379) [NoAI] -Add: function to get the TileIndex from an (X, Y) coordinate.
rubidium
parents: 9489
diff changeset
    41
	return ::TileXY(x, y);
5eb285182114 (svn r9379) [NoAI] -Add: function to get the TileIndex from an (X, Y) coordinate.
rubidium
parents: 9489
diff changeset
    42
}
5eb285182114 (svn r9379) [NoAI] -Add: function to get the TileIndex from an (X, Y) coordinate.
rubidium
parents: 9489
diff changeset
    43
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
    44
/* 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
    45
{
d7ee0a65ead9 (svn r9359) [NoAI] -Add: function to determine distance and clear tiles.
rubidium
parents: 9430
diff changeset
    46
	return ::DistanceManhattan(t1, t2);
d7ee0a65ead9 (svn r9359) [NoAI] -Add: function to determine distance and clear tiles.
rubidium
parents: 9430
diff changeset
    47
}
d7ee0a65ead9 (svn r9359) [NoAI] -Add: function to determine distance and clear tiles.
rubidium
parents: 9430
diff changeset
    48
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
    49
/* 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
    50
{
d7ee0a65ead9 (svn r9359) [NoAI] -Add: function to determine distance and clear tiles.
rubidium
parents: 9430
diff changeset
    51
	return ::DistanceMax(t1, t2);
d7ee0a65ead9 (svn r9359) [NoAI] -Add: function to determine distance and clear tiles.
rubidium
parents: 9430
diff changeset
    52
}
d7ee0a65ead9 (svn r9359) [NoAI] -Add: function to determine distance and clear tiles.
rubidium
parents: 9430
diff changeset
    53
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
    54
/* 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
    55
{
d7ee0a65ead9 (svn r9359) [NoAI] -Add: function to determine distance and clear tiles.
rubidium
parents: 9430
diff changeset
    56
	return ::DistanceSquare(t1, t2);
d7ee0a65ead9 (svn r9359) [NoAI] -Add: function to determine distance and clear tiles.
rubidium
parents: 9430
diff changeset
    57
}
d7ee0a65ead9 (svn r9359) [NoAI] -Add: function to determine distance and clear tiles.
rubidium
parents: 9430
diff changeset
    58
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
    59
/* static */ uint32 AIMap::DistanceFromEdge(TileIndex t)
9489
d7ee0a65ead9 (svn r9359) [NoAI] -Add: function to determine distance and clear tiles.
rubidium
parents: 9430
diff changeset
    60
{
d7ee0a65ead9 (svn r9359) [NoAI] -Add: function to determine distance and clear tiles.
rubidium
parents: 9430
diff changeset
    61
	return ::DistanceFromEdge(t);
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
d7ee0a65ead9 (svn r9359) [NoAI] -Add: function to determine distance and clear tiles.
rubidium
parents: 9430
diff changeset
    64
bool AIMap::DemolishTile(TileIndex t)
d7ee0a65ead9 (svn r9359) [NoAI] -Add: function to determine distance and clear tiles.
rubidium
parents: 9430
diff changeset
    65
{
d7ee0a65ead9 (svn r9359) [NoAI] -Add: function to determine distance and clear tiles.
rubidium
parents: 9430
diff changeset
    66
	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
    67
}