(svn r28004) -Update from Eints:
[openttd.git] / src / script / api / script_map.cpp
blob6334089fdb0f4f99101f7191a1d3ec77da3819f8
1 /* $Id$ */
3 /*
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/>.
8 */
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()
25 return ::MapSize();
28 /* static */ uint32 ScriptMap::GetMapSizeX()
30 return ::MapSizeX();
33 /* static */ uint32 ScriptMap::GetMapSizeY()
35 return ::MapSizeY();
38 /* static */ int32 ScriptMap::GetTileX(TileIndex t)
40 if (!::IsValidTile(t)) return -1;
41 return ::TileX(t);
44 /* static */ int32 ScriptMap::GetTileY(TileIndex t)
46 if (!::IsValidTile(t)) return -1;
47 return ::TileY(t);
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);