author | rubidium |
Thu, 03 Apr 2008 23:01:54 +0000 | |
branch | noai |
changeset 9865 | f241472f09dc |
parent 9837 | c9ec4f82e0d0 |
child 9869 | 6404afe43575 |
permissions | -rw-r--r-- |
9638
f6d169a5a45a
(svn r10529) [NoAI] -Add: added AIStation to gather information about stations directly by Id, which is used now by AIStationList
truelight
parents:
9636
diff
changeset
|
1 |
/* $Id$ */ |
f6d169a5a45a
(svn r10529) [NoAI] -Add: added AIStation to gather information about stations directly by Id, which is used now by AIStationList
truelight
parents:
9636
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_stationlist.cpp Implementation of AIStationList 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:
9778
diff
changeset
|
4 |
|
9636
1005ffccf641
(svn r10527) [NoAI] -Add: AIStationList(), which lists all your stations; useful to maintain routes
truelight
parents:
diff
changeset
|
5 |
#include "ai_stationlist.hpp" |
9645
25126afa0c25
(svn r10538) [NoAI] -Add: added AIVehicleStationList, which lists all stations a vehicle goes to
truelight
parents:
9638
diff
changeset
|
6 |
#include "ai_vehicle.hpp" |
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
7 |
#include "../../player_func.h" |
9837
c9ec4f82e0d0
(svn r12503) [NoAI] -Sync: with trunk r12461:12501.
rubidium
parents:
9833
diff
changeset
|
8 |
#include "../../station_base.h" |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9670
diff
changeset
|
9 |
#include "../../vehicle_base.h" |
9636
1005ffccf641
(svn r10527) [NoAI] -Add: AIStationList(), which lists all your stations; useful to maintain routes
truelight
parents:
diff
changeset
|
10 |
|
9778
38560cd27070
(svn r12273) [NoAI] -Documentation: big change of many list-related comments. It is now more readable, more explaining, and all unneeded things (API-wise) are removed
truebrain
parents:
9746
diff
changeset
|
11 |
AIStationList::AIStationList(AIStation::StationType station_type) |
9636
1005ffccf641
(svn r10527) [NoAI] -Add: AIStationList(), which lists all your stations; useful to maintain routes
truelight
parents:
diff
changeset
|
12 |
{ |
1005ffccf641
(svn r10527) [NoAI] -Add: AIStationList(), which lists all your stations; useful to maintain routes
truelight
parents:
diff
changeset
|
13 |
Station *st; |
1005ffccf641
(svn r10527) [NoAI] -Add: AIStationList(), which lists all your stations; useful to maintain routes
truelight
parents:
diff
changeset
|
14 |
FOR_ALL_STATIONS(st) { |
9778
38560cd27070
(svn r12273) [NoAI] -Documentation: big change of many list-related comments. It is now more readable, more explaining, and all unneeded things (API-wise) are removed
truebrain
parents:
9746
diff
changeset
|
15 |
if (st->owner == _current_player && (station_type == AIStation::STATION_ANY || (st->facilities & station_type) != 0)) this->AddItem(st->index); |
9636
1005ffccf641
(svn r10527) [NoAI] -Add: AIStationList(), which lists all your stations; useful to maintain routes
truelight
parents:
diff
changeset
|
16 |
} |
1005ffccf641
(svn r10527) [NoAI] -Add: AIStationList(), which lists all your stations; useful to maintain routes
truelight
parents:
diff
changeset
|
17 |
} |
9645
25126afa0c25
(svn r10538) [NoAI] -Add: added AIVehicleStationList, which lists all stations a vehicle goes to
truelight
parents:
9638
diff
changeset
|
18 |
|
9746
e4ab7ea8d897
(svn r12226) [NoAI] -Fix: remove the dep for AIStationList_Vehicle on AIStationList, as Squirrel doesn't like it
truebrain
parents:
9745
diff
changeset
|
19 |
AIStationList_Vehicle::AIStationList_Vehicle(VehicleID vehicle_id) |
9645
25126afa0c25
(svn r10538) [NoAI] -Add: added AIVehicleStationList, which lists all stations a vehicle goes to
truelight
parents:
9638
diff
changeset
|
20 |
{ |
25126afa0c25
(svn r10538) [NoAI] -Add: added AIVehicleStationList, which lists all stations a vehicle goes to
truelight
parents:
9638
diff
changeset
|
21 |
if (!AIVehicle::IsValidVehicle(vehicle_id)) return; |
25126afa0c25
(svn r10538) [NoAI] -Add: added AIVehicleStationList, which lists all stations a vehicle goes to
truelight
parents:
9638
diff
changeset
|
22 |
|
25126afa0c25
(svn r10538) [NoAI] -Add: added AIVehicleStationList, which lists all stations a vehicle goes to
truelight
parents:
9638
diff
changeset
|
23 |
Vehicle *v = ::GetVehicle(vehicle_id); |
25126afa0c25
(svn r10538) [NoAI] -Add: added AIVehicleStationList, which lists all stations a vehicle goes to
truelight
parents:
9638
diff
changeset
|
24 |
|
25126afa0c25
(svn r10538) [NoAI] -Add: added AIVehicleStationList, which lists all stations a vehicle goes to
truelight
parents:
9638
diff
changeset
|
25 |
for (Order *o = v->orders; o != NULL; o = o->next) { |
25126afa0c25
(svn r10538) [NoAI] -Add: added AIVehicleStationList, which lists all stations a vehicle goes to
truelight
parents:
9638
diff
changeset
|
26 |
if (o->type == OT_GOTO_STATION) this->AddItem(o->dest); |
25126afa0c25
(svn r10538) [NoAI] -Add: added AIVehicleStationList, which lists all stations a vehicle goes to
truelight
parents:
9638
diff
changeset
|
27 |
} |
25126afa0c25
(svn r10538) [NoAI] -Add: added AIVehicleStationList, which lists all stations a vehicle goes to
truelight
parents:
9638
diff
changeset
|
28 |
} |