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/>.
8 /** @file script_waypointlist.cpp Implementation of ScriptWaypointList and friends. */
10 #include "../../stdafx.h"
11 #include "script_waypointlist.hpp"
12 #include "script_vehicle.hpp"
13 #include "../../vehicle_base.h"
14 #include "../../waypoint_base.h"
16 #include "../../safeguards.h"
18 ScriptWaypointList::ScriptWaypointList(ScriptWaypoint::WaypointType waypoint_type
)
20 EnforceDeityOrCompanyModeValid_Void();
22 bool is_deity
= ScriptCompanyMode::IsDeity();
23 CompanyID owner
= ScriptObject::GetCompany();
24 ScriptList::FillList
<Waypoint
>(this,
25 [is_deity
, owner
, waypoint_type
](const Waypoint
*wp
) {
26 return (is_deity
|| wp
->owner
== owner
|| wp
->owner
== OWNER_NONE
) && (wp
->facilities
& static_cast<StationFacility
>(waypoint_type
)) != 0;
31 ScriptWaypointList_Vehicle::ScriptWaypointList_Vehicle(VehicleID vehicle_id
)
33 if (!ScriptVehicle::IsPrimaryVehicle(vehicle_id
)) return;
35 const Vehicle
*v
= ::Vehicle::Get(vehicle_id
);
37 for (const Order
*o
= v
->GetFirstOrder(); o
!= nullptr; o
= o
->next
) {
38 if (o
->IsType(OT_GOTO_WAYPOINT
)) this->AddItem(o
->GetDestination());