Update: Translations from eints
[openttd-github.git] / src / script / api / script_waypoint.cpp
blob84c2a4aeb66b3f454859dbd83f8bb2fa5c5e7a1f
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_waypoint.cpp Implementation of ScriptWaypoint. */
10 #include "../../stdafx.h"
11 #include "script_waypoint.hpp"
12 #include "script_rail.hpp"
13 #include "script_marine.hpp"
14 #include "../../waypoint_base.h"
16 #include "../../safeguards.h"
18 /* static */ bool ScriptWaypoint::IsValidWaypoint(StationID waypoint_id)
20 EnforceDeityOrCompanyModeValid(false);
21 const Waypoint *wp = ::Waypoint::GetIfValid(waypoint_id);
22 return wp != nullptr && (wp->owner == ScriptObject::GetCompany() || ScriptCompanyMode::IsDeity() || wp->owner == OWNER_NONE);
25 /* static */ StationID ScriptWaypoint::GetWaypointID(TileIndex tile)
27 if (!ScriptRail::IsRailWaypointTile(tile) && !ScriptMarine::IsBuoyTile(tile)) return STATION_INVALID;
29 return ::GetStationIndex(tile);
32 /* static */ bool ScriptWaypoint::HasWaypointType(StationID waypoint_id, WaypointType waypoint_type)
34 if (!IsValidWaypoint(waypoint_id)) return false;
35 if (!HasExactlyOneBit(waypoint_type)) return false;
37 return (::Waypoint::Get(waypoint_id)->facilities & static_cast<StationFacility>(waypoint_type)) != 0;