Add: [Script] ScriptVehicleList_Waypoint (#13456)
Creates a list of vehicles that have orders to a given waypoint.
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
#include "script_group.hpp"
|
||||
#include "script_map.hpp"
|
||||
#include "script_station.hpp"
|
||||
#include "script_waypoint.hpp"
|
||||
#include "../../depot_map.h"
|
||||
#include "../../vehicle_base.h"
|
||||
#include "../../vehiclelist_func.h"
|
||||
@@ -68,6 +69,21 @@ ScriptVehicleList_Station::ScriptVehicleList_Station(HSQUIRRELVM vm)
|
||||
);
|
||||
}
|
||||
|
||||
ScriptVehicleList_Waypoint::ScriptVehicleList_Waypoint(StationID waypoint_id)
|
||||
{
|
||||
EnforceDeityOrCompanyModeValid_Void();
|
||||
if (!ScriptWaypoint::IsValidWaypoint(waypoint_id)) return;
|
||||
|
||||
bool is_deity = ScriptCompanyMode::IsDeity();
|
||||
::CompanyID owner = ScriptObject::GetCompany();
|
||||
|
||||
FindVehiclesWithOrder(
|
||||
[is_deity, owner](const Vehicle *v) { return is_deity || v->owner == owner; },
|
||||
[waypoint_id](const Order *order) { return order->IsType(OT_GOTO_WAYPOINT) && order->GetDestination() == waypoint_id; },
|
||||
[this](const Vehicle *v) { this->AddItem(v->index.base()); }
|
||||
);
|
||||
}
|
||||
|
||||
ScriptVehicleList_Depot::ScriptVehicleList_Depot(TileIndex tile)
|
||||
{
|
||||
EnforceDeityOrCompanyModeValid_Void();
|
||||
|
||||
Reference in New Issue
Block a user