# ai_map.cpp

Go to the documentation of this file.

    00001 /* $Id$ */
    00002
    00003 /*
    00004  * This file is part of OpenTTD.
    00005  * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
    00006  * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    00007  * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
    00008  */
    00009
    00012 #include "../../stdafx.h"
    00013 #include "ai_map.hpp"
    00014 #include "../../tile_map.h"
    00015
    00016 /* static */ bool AIMap::IsValidTile(TileIndex t)
    00017 {
    00018   return ::IsValidTile(t);
    00019 }
    00020
    00021 /* static */ TileIndex AIMap::GetMapSize()
    00022 {
    00023   return ::MapSize();
    00024 }
    00025
    00026 /* static */ uint32 AIMap::GetMapSizeX()
    00027 {
    00028   return ::MapSizeX();
    00029 }
    00030
    00031 /* static */ uint32 AIMap::GetMapSizeY()
    00032 {
    00033   return ::MapSizeY();
    00034 }
    00035
    00036 /* static */ int32 AIMap::GetTileX(TileIndex t)
    00037 {
    00038   if (!::IsValidTile(t)) return -1;
    00039   return ::TileX(t);
    00040 }
    00041
    00042 /* static */ int32 AIMap::GetTileY(TileIndex t)
    00043 {
    00044   if (!::IsValidTile(t)) return -1;
    00045   return ::TileY(t);
    00046 }
    00047
    00048 /* static */ TileIndex AIMap::GetTileIndex(uint32 x, uint32 y)
    00049 {
    00050   return ::TileXY(x, y);
    00051 }
    00052
    00053 /* static */ int32 AIMap::DistanceManhattan(TileIndex t1, TileIndex t2)
    00054 {
    00055   if (!::IsValidTile(t1) || !::IsValidTile(t2)) return -1;
    00056   return ::DistanceManhattan(t1, t2);
    00057 }
    00058
    00059 /* static */ int32 AIMap::DistanceMax(TileIndex t1, TileIndex t2)
    00060 {
    00061   if (!::IsValidTile(t1) || !::IsValidTile(t2)) return -1;
    00062   return ::DistanceMax(t1, t2);
    00063 }
    00064
    00065 /* static */ int32 AIMap::DistanceSquare(TileIndex t1, TileIndex t2)
    00066 {
    00067   if (!::IsValidTile(t1) || !::IsValidTile(t2)) return -1;
    00068   return ::DistanceSquare(t1, t2);
    00069 }
    00070
    00071 /* static */ int32 AIMap::DistanceFromEdge(TileIndex t)
    00072 {
    00073   if (!::IsValidTile(t)) return -1;
    00074   return ::DistanceFromEdge(t);
    00075 }