4 * This file is part of OpenTTD.
5 * 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.
6 * 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.
7 * 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/>.
10 /** @file script_map.cpp Implementation of ScriptMap. */
12 #include "../../stdafx.h"
13 #include "script_map.hpp"
14 #include "../../tile_map.h"
16 #include "../../safeguards.h"
18 /* static */ bool ScriptMap::IsValidTile(TileIndex t
)
20 return ::IsValidTile(t
);
23 /* static */ TileIndex
ScriptMap::GetMapSize()
28 /* static */ uint32
ScriptMap::GetMapSizeX()
33 /* static */ uint32
ScriptMap::GetMapSizeY()
38 /* static */ int32
ScriptMap::GetTileX(TileIndex t
)
40 if (!::IsValidTile(t
)) return -1;
44 /* static */ int32
ScriptMap::GetTileY(TileIndex t
)
46 if (!::IsValidTile(t
)) return -1;
50 /* static */ TileIndex
ScriptMap::GetTileIndex(uint32 x
, uint32 y
)
52 return ::TileXY(x
, y
);
55 /* static */ int32
ScriptMap::DistanceManhattan(TileIndex t1
, TileIndex t2
)
57 if (!::IsValidTile(t1
) || !::IsValidTile(t2
)) return -1;
58 return ::DistanceManhattan(t1
, t2
);
61 /* static */ int32
ScriptMap::DistanceMax(TileIndex t1
, TileIndex t2
)
63 if (!::IsValidTile(t1
) || !::IsValidTile(t2
)) return -1;
64 return ::DistanceMax(t1
, t2
);
67 /* static */ int32
ScriptMap::DistanceSquare(TileIndex t1
, TileIndex t2
)
69 if (!::IsValidTile(t1
) || !::IsValidTile(t2
)) return -1;
70 return ::DistanceSquare(t1
, t2
);
73 /* static */ int32
ScriptMap::DistanceFromEdge(TileIndex t
)
75 if (!::IsValidTile(t
)) return -1;
76 return ::DistanceFromEdge(t
);