src/ai/api/ai_stationlist.cpp
author rubidium
Sun, 15 Jul 2007 16:39:11 +0000
branchnoai
changeset 9668 6fe3d2cb9655
parent 9645 25126afa0c25
child 9670 820b77e19bb3
permissions -rw-r--r--
(svn r10582) [NoAI] -Codechange: allow getting the president and company names of other companies as well as their company value and bank balance.
/* $Id$ */

#include "ai_stationlist.hpp"
#include "ai_vehicle.hpp"
#include "../../player.h"
#include "../../station.h"
#include "../../order.h"
#include "../../vehicle.h"

AIStationList::AIStationList(AIStationList::StationType type)
{
	Station *st;
	FOR_ALL_STATIONS(st) {
		if (st->owner == _current_player && (type == AIStationList::STATION_ANY || (st->facilities & type) != 0)) this->AddItem(st->index);
	}
}

AIVehicleStationList::AIVehicleStationList(VehicleID vehicle_id)
{
	if (!AIVehicle::IsValidVehicle(vehicle_id)) return;

	Vehicle *v = ::GetVehicle(vehicle_id);

	for (Order *o = v->orders; o != NULL; o = o->next) {
		if (o->type == OT_GOTO_STATION) this->AddItem(o->dest);
	}
}