From 62a11eb5a93a12994bdf84475930d0d4b7fb4315 Mon Sep 17 00:00:00 2001 From: Yexo Date: Thu, 5 Feb 2009 01:12:49 +0000 Subject: (svn r15345) -Add [NoAI]: Add AIVehicle::HasSharedOrders() and AIVehicleList_SharedOrders. --- src/ai/api/ai_vehiclelist.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/ai/api/ai_vehiclelist.cpp') diff --git a/src/ai/api/ai_vehiclelist.cpp b/src/ai/api/ai_vehiclelist.cpp index c7e75c795..1c099910b 100644 --- a/src/ai/api/ai_vehiclelist.cpp +++ b/src/ai/api/ai_vehiclelist.cpp @@ -4,6 +4,7 @@ #include "ai_vehiclelist.hpp" #include "ai_station.hpp" +#include "ai_vehicle.hpp" #include "../../company_func.h" #include "../../vehicle_base.h" @@ -34,3 +35,17 @@ AIVehicleList_Station::AIVehicleList_Station(StationID station_id) } } } + +AIVehicleList_SharedOrders::AIVehicleList_SharedOrders(VehicleID vehicle_id) +{ + if (!AIVehicle::IsValidVehicle(vehicle_id)) return; + + Vehicle *v = GetVehicle(vehicle_id)->FirstShared(); + if (v == NULL) { + this->AddItem(vehicle_id); + return; + } + for (; v != NULL; v->NextShared()) { + this->AddItem(v->index); + } +} -- cgit v1.2.3-54-g00ecf