Update: Translations from eints
[openttd-github.git] / src / script / api / script_map.cpp
blobfb76ac0bf6b31ee6b4d70d054ce5cd923ec20426
1 /*
2 * This file is part of OpenTTD.
3 * 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.
4 * 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.
5 * 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/>.
6 */
8 /** @file script_map.cpp Implementation of ScriptMap. */
10 #include "../../stdafx.h"
11 #include "script_map.hpp"
12 #include "../../tile_map.h"
14 #include "../../safeguards.h"
16 /* static */ bool ScriptMap::IsValidTile(TileIndex t)
18 return ::IsValidTile(t);
21 /* static */ SQInteger ScriptMap::GetMapSize()
23 return ::Map::Size();
26 /* static */ SQInteger ScriptMap::GetMapSizeX()
28 return ::Map::SizeX();
31 /* static */ SQInteger ScriptMap::GetMapSizeY()
33 return ::Map::SizeY();
36 /* static */ SQInteger ScriptMap::GetTileX(TileIndex t)
38 if (!::IsValidTile(t)) return -1;
39 return ::TileX(t);
42 /* static */ SQInteger ScriptMap::GetTileY(TileIndex t)
44 if (!::IsValidTile(t)) return -1;
45 return ::TileY(t);
48 /* static */ TileIndex ScriptMap::GetTileIndex(SQInteger x, SQInteger y)
50 return ::TileXY(x, y);
53 /* static */ SQInteger ScriptMap::DistanceManhattan(TileIndex t1, TileIndex t2)
55 if (!::IsValidTile(t1) || !::IsValidTile(t2)) return -1;
56 return ::DistanceManhattan(t1, t2);
59 /* static */ SQInteger ScriptMap::DistanceMax(TileIndex t1, TileIndex t2)
61 if (!::IsValidTile(t1) || !::IsValidTile(t2)) return -1;
62 return ::DistanceMax(t1, t2);
65 /* static */ SQInteger ScriptMap::DistanceSquare(TileIndex t1, TileIndex t2)
67 if (!::IsValidTile(t1) || !::IsValidTile(t2)) return -1;
68 return ::DistanceSquare(t1, t2);
71 /* static */ SQInteger ScriptMap::DistanceFromEdge(TileIndex t)
73 if (!::IsValidTile(t)) return -1;
74 return ::DistanceFromEdge(t);