src/ai/api/ai_vehiclelist.cpp
author rubidium
Thu, 03 Apr 2008 23:01:54 +0000
branchnoai
changeset 9865 f241472f09dc
parent 9837 c9ec4f82e0d0
child 9869 6404afe43575
permissions -rw-r--r--
(svn r12555) [NoAI] -Add: support for GetLastError for AICompany.
/* $Id$ */

/** @file ai_vehiclelist.cpp Implementation of AIVehicleList and friends. */

#include "ai_vehiclelist.hpp"
#include "ai_station.hpp"
#include "../../player_func.h"
#include "../../vehicle_base.h"

AIVehicleList::AIVehicleList()
{
	Vehicle *v;
	FOR_ALL_VEHICLES(v) {
		if (v->owner == _current_player && v->IsPrimaryVehicle()) this->AddItem(v->index);
	}
}

AIVehicleList_Station::AIVehicleList_Station(StationID station_id)
{
	if (!AIStation::IsValidStation(station_id)) return;

	Vehicle *v;

	FOR_ALL_VEHICLES(v) {
		if (v->owner == _current_player && v->IsPrimaryVehicle()) {
			const Order *order;

			FOR_VEHICLE_ORDERS(v, order) {
				if (order->type == OT_GOTO_STATION && order->dest == station_id) {
					this->AddItem(v->index);
					break;
				}
			}
		}
	}
}