src/ai/api/ai_vehiclelist.cpp
author truebrain
Tue, 29 Apr 2008 21:34:17 +0000
branchnoai
changeset 10383 bda80b3e9c25
parent 10339 ce6cd68d9eb8
permissions -rw-r--r--
(svn r12925) [NoAI] -Add: added AIIndustry::GetAmountOfStationsAround() (Yexo)
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"
10339
ce6cd68d9eb8 (svn r12880) [NoAI] -Add: introduces ai_types.hpp, which has all NNNId like VehicleID. This simplifies the include-mess, and avoids including tons of _type.h for just a single typedef.
truebrain
parents: 9869
diff changeset
     7
#include "../../openttd.h"
9724
b39bc69bb2f2 (svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents: 9723
diff changeset
     8
#include "../../player_func.h"
9723
eee46cb39750 (svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents: 9647
diff changeset
     9
#include "../../vehicle_base.h"
9614
814c3bbf8ecc (svn r9781) [NoAI] -Add: added AIVehicleListProfit[This|Last]Year as valuator
truelight
parents:
diff changeset
    10
814c3bbf8ecc (svn r9781) [NoAI] -Add: added AIVehicleListProfit[This|Last]Year as valuator
truelight
parents:
diff changeset
    11
AIVehicleList::AIVehicleList()
814c3bbf8ecc (svn r9781) [NoAI] -Add: added AIVehicleListProfit[This|Last]Year as valuator
truelight
parents:
diff changeset
    12
{
814c3bbf8ecc (svn r9781) [NoAI] -Add: added AIVehicleListProfit[This|Last]Year as valuator
truelight
parents:
diff changeset
    13
	Vehicle *v;
814c3bbf8ecc (svn r9781) [NoAI] -Add: added AIVehicleListProfit[This|Last]Year as valuator
truelight
parents:
diff changeset
    14
	FOR_ALL_VEHICLES(v) {
9633
6099483c684c (svn r10524) [NoAI] -Fix: follow coding-style
truelight
parents: 9627
diff changeset
    15
		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
    16
	}
814c3bbf8ecc (svn r9781) [NoAI] -Add: added AIVehicleListProfit[This|Last]Year as valuator
truelight
parents:
diff changeset
    17
}
9647
c17046b1b8a2 (svn r10540) [NoAI] -Add: added AIStationVehicleList, which lists all vehicles that go to a given station
truelight
parents: 9633
diff changeset
    18
9745
fb2454d70f37 (svn r12225) [NoAI] -Change [API CHANGE]: AIStationVehicleList -> AIVehicleList_Station (WATCH THE NAMES CAREFULLY!)
truebrain
parents: 9740
diff changeset
    19
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
    20
{
9740
a98f20bce404 (svn r12220) [NoAI] -Fix: minor type in AIVehicleStation, and missing security check
truebrain
parents: 9724
diff changeset
    21
	if (!AIStation::IsValidStation(station_id)) return;
a98f20bce404 (svn r12220) [NoAI] -Fix: minor type in AIVehicleStation, and missing security check
truebrain
parents: 9724
diff changeset
    22
9647
c17046b1b8a2 (svn r10540) [NoAI] -Add: added AIStationVehicleList, which lists all vehicles that go to a given station
truelight
parents: 9633
diff changeset
    23
	Vehicle *v;
c17046b1b8a2 (svn r10540) [NoAI] -Add: added AIStationVehicleList, which lists all vehicles that go to a given station
truelight
parents: 9633
diff changeset
    24
c17046b1b8a2 (svn r10540) [NoAI] -Add: added AIStationVehicleList, which lists all vehicles that go to a given station
truelight
parents: 9633
diff changeset
    25
	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
    26
		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
    27
			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
    28
c17046b1b8a2 (svn r10540) [NoAI] -Add: added AIStationVehicleList, which lists all vehicles that go to a given station
truelight
parents: 9633
diff changeset
    29
			FOR_VEHICLE_ORDERS(v, order) {
9869
6404afe43575 (svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents: 9837
diff changeset
    30
				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
    31
					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
    32
					break;
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
	}
c17046b1b8a2 (svn r10540) [NoAI] -Add: added AIStationVehicleList, which lists all vehicles that go to a given station
truelight
parents: 9633
diff changeset
    37
}