# ai_vehiclelist.cpp

Go to the documentation of this file.

    00001 /* $Id: ai_vehiclelist.cpp 15355 2009-02-05 15:59:23Z rubidium $ */
    00002
    00005 #include "ai_vehiclelist.hpp"
    00006 #include "ai_station.hpp"
    00007 #include "ai_vehicle.hpp"
    00008 #include "../../company_func.h"
    00009 #include "../../vehicle_base.h"
    00010
    00011 AIVehicleList::AIVehicleList()
    00012 {
    00013   Vehicle *v;
    00014   FOR_ALL_VEHICLES(v) {
    00015     if (v->owner == _current_company && v->IsPrimaryVehicle()) this->AddItem(v->index);
    00016   }
    00017 }
    00018
    00019 AIVehicleList_Station::AIVehicleList_Station(StationID station_id)
    00020 {
    00021   if (!AIStation::IsValidStation(station_id)) return;
    00022
    00023   Vehicle *v;
    00024
    00025   FOR_ALL_VEHICLES(v) {
    00026     if (v->owner == _current_company && v->IsPrimaryVehicle()) {
    00027       const Order *order;
    00028
    00029       FOR_VEHICLE_ORDERS(v, order) {
    00030         if (order->IsType(OT_GOTO_STATION) && order->GetDestination() == station_id) {
    00031           this->AddItem(v->index);
    00032           break;
    00033         }
    00034       }
    00035     }
    00036   }
    00037 }
    00038
    00039 AIVehicleList_SharedOrders::AIVehicleList_SharedOrders(VehicleID vehicle_id)
    00040 {
    00041   if (!AIVehicle::IsValidVehicle(vehicle_id)) return;
    00042
    00043   for (const Vehicle *v = GetVehicle(vehicle_id)->FirstShared(); v != NULL; v->NextShared()) {
    00044     this->AddItem(v->index);
    00045   }
    00046 }