src/ai/api/ai_vehiclelist.cpp
author rubidium
Sun, 06 Apr 2008 23:07:42 +0000
branchnoai
changeset 9869 6404afe43575
parent 9837 c9ec4f82e0d0
child 10339 ce6cd68d9eb8
permissions -rw-r--r--
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
9820
8c116d4c6033 (svn r12423) [NoAI] -Change: bring a little more uniformness into the first few lines of the API related files (add missing /* $Id$ */ and such).
rubidium
parents: 9746
diff changeset
     1
/* $Id$ */
8c116d4c6033 (svn r12423) [NoAI] -Change: bring a little more uniformness into the first few lines of the API related files (add missing /* $Id$ */ and such).
rubidium
parents: 9746
diff changeset
     2
9833
89a64246458f (svn r12496) [NoAI] -Documentation: give the .cpp files a nice uniform format too
truebrain
parents: 9820
diff changeset
     3
/** @file ai_vehiclelist.cpp Implementation of AIVehicleList and friends. */
9820
8c116d4c6033 (svn r12423) [NoAI] -Change: bring a little more uniformness into the first few lines of the API related files (add missing /* $Id$ */ and such).
rubidium
parents: 9746
diff changeset
     4
9614
814c3bbf8ecc (svn r9781) [NoAI] -Add: added AIVehicleListProfit[This|Last]Year as valuator
truelight
parents:
diff changeset
     5
#include "ai_vehiclelist.hpp"
9740
a98f20bce404 (svn r12220) [NoAI] -Fix: minor type in AIVehicleStation, and missing security check
truebrain
parents: 9724
diff changeset
     6
#include "ai_station.hpp"
9724
b39bc69bb2f2 (svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents: 9723
diff changeset
     7
#include "../../player_func.h"
9723
eee46cb39750 (svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents: 9647
diff changeset
     8
#include "../../vehicle_base.h"
9614
814c3bbf8ecc (svn r9781) [NoAI] -Add: added AIVehicleListProfit[This|Last]Year as valuator
truelight
parents:
diff changeset
     9
814c3bbf8ecc (svn r9781) [NoAI] -Add: added AIVehicleListProfit[This|Last]Year as valuator
truelight
parents:
diff changeset
    10
AIVehicleList::AIVehicleList()
814c3bbf8ecc (svn r9781) [NoAI] -Add: added AIVehicleListProfit[This|Last]Year as valuator
truelight
parents:
diff changeset
    11
{
814c3bbf8ecc (svn r9781) [NoAI] -Add: added AIVehicleListProfit[This|Last]Year as valuator
truelight
parents:
diff changeset
    12
	Vehicle *v;
814c3bbf8ecc (svn r9781) [NoAI] -Add: added AIVehicleListProfit[This|Last]Year as valuator
truelight
parents:
diff changeset
    13
	FOR_ALL_VEHICLES(v) {
9633
6099483c684c (svn r10524) [NoAI] -Fix: follow coding-style
truelight
parents: 9627
diff changeset
    14
		if (v->owner == _current_player && v->IsPrimaryVehicle()) this->AddItem(v->index);
9614
814c3bbf8ecc (svn r9781) [NoAI] -Add: added AIVehicleListProfit[This|Last]Year as valuator
truelight
parents:
diff changeset
    15
	}
814c3bbf8ecc (svn r9781) [NoAI] -Add: added AIVehicleListProfit[This|Last]Year as valuator
truelight
parents:
diff changeset
    16
}
9647
c17046b1b8a2 (svn r10540) [NoAI] -Add: added AIStationVehicleList, which lists all vehicles that go to a given station
truelight
parents: 9633
diff changeset
    17
9745
fb2454d70f37 (svn r12225) [NoAI] -Change [API CHANGE]: AIStationVehicleList -> AIVehicleList_Station (WATCH THE NAMES CAREFULLY!)
truebrain
parents: 9740
diff changeset
    18
AIVehicleList_Station::AIVehicleList_Station(StationID station_id)
9647
c17046b1b8a2 (svn r10540) [NoAI] -Add: added AIStationVehicleList, which lists all vehicles that go to a given station
truelight
parents: 9633
diff changeset
    19
{
9740
a98f20bce404 (svn r12220) [NoAI] -Fix: minor type in AIVehicleStation, and missing security check
truebrain
parents: 9724
diff changeset
    20
	if (!AIStation::IsValidStation(station_id)) return;
a98f20bce404 (svn r12220) [NoAI] -Fix: minor type in AIVehicleStation, and missing security check
truebrain
parents: 9724
diff changeset
    21
9647
c17046b1b8a2 (svn r10540) [NoAI] -Add: added AIStationVehicleList, which lists all vehicles that go to a given station
truelight
parents: 9633
diff changeset
    22
	Vehicle *v;
c17046b1b8a2 (svn r10540) [NoAI] -Add: added AIStationVehicleList, which lists all vehicles that go to a given station
truelight
parents: 9633
diff changeset
    23
c17046b1b8a2 (svn r10540) [NoAI] -Add: added AIStationVehicleList, which lists all vehicles that go to a given station
truelight
parents: 9633
diff changeset
    24
	FOR_ALL_VEHICLES(v) {
c17046b1b8a2 (svn r10540) [NoAI] -Add: added AIStationVehicleList, which lists all vehicles that go to a given station
truelight
parents: 9633
diff changeset
    25
		if (v->owner == _current_player && v->IsPrimaryVehicle()) {
c17046b1b8a2 (svn r10540) [NoAI] -Add: added AIStationVehicleList, which lists all vehicles that go to a given station
truelight
parents: 9633
diff changeset
    26
			const Order *order;
c17046b1b8a2 (svn r10540) [NoAI] -Add: added AIStationVehicleList, which lists all vehicles that go to a given station
truelight
parents: 9633
diff changeset
    27
c17046b1b8a2 (svn r10540) [NoAI] -Add: added AIStationVehicleList, which lists all vehicles that go to a given station
truelight
parents: 9633
diff changeset
    28
			FOR_VEHICLE_ORDERS(v, order) {
9869
6404afe43575 (svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents: 9837
diff changeset
    29
				if (order->IsType(OT_GOTO_STATION) && order->GetDestination() == station_id) {
9647
c17046b1b8a2 (svn r10540) [NoAI] -Add: added AIStationVehicleList, which lists all vehicles that go to a given station
truelight
parents: 9633
diff changeset
    30
					this->AddItem(v->index);
c17046b1b8a2 (svn r10540) [NoAI] -Add: added AIStationVehicleList, which lists all vehicles that go to a given station
truelight
parents: 9633
diff changeset
    31
					break;
c17046b1b8a2 (svn r10540) [NoAI] -Add: added AIStationVehicleList, which lists all vehicles that go to a given station
truelight
parents: 9633
diff changeset
    32
				}
c17046b1b8a2 (svn r10540) [NoAI] -Add: added AIStationVehicleList, which lists all vehicles that go to a given station
truelight
parents: 9633
diff changeset
    33
			}
c17046b1b8a2 (svn r10540) [NoAI] -Add: added AIStationVehicleList, which lists all vehicles that go to a given station
truelight
parents: 9633
diff changeset
    34
		}
c17046b1b8a2 (svn r10540) [NoAI] -Add: added AIStationVehicleList, which lists all vehicles that go to a given station
truelight
parents: 9633
diff changeset
    35
	}
c17046b1b8a2 (svn r10540) [NoAI] -Add: added AIStationVehicleList, which lists all vehicles that go to a given station
truelight
parents: 9633
diff changeset
    36
}