author | truelight |
Fri, 13 Jul 2007 13:49:39 +0000 | |
branch | noai |
changeset 9648 | 760b7b504e37 |
parent 9638 | f6d169a5a45a |
child 9666 | 5765eb70736d |
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:
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:
diff
changeset
|
2 |
|
f6d169a5a45a
(svn r10529) [NoAI] -Add: added AIStation to gather information about stations directly by Id, which is used now by AIStationList
truelight
parents:
diff
changeset
|
3 |
/** @file ai_station.cpp handles the functions of the AIStation class */ |
f6d169a5a45a
(svn r10529) [NoAI] -Add: added AIStation to gather information about stations directly by Id, which is used now by AIStationList
truelight
parents:
diff
changeset
|
4 |
|
f6d169a5a45a
(svn r10529) [NoAI] -Add: added AIStation to gather information about stations directly by Id, which is used now by AIStationList
truelight
parents:
diff
changeset
|
5 |
#include "ai_station.hpp" |
f6d169a5a45a
(svn r10529) [NoAI] -Add: added AIStation to gather information about stations directly by Id, which is used now by AIStationList
truelight
parents:
diff
changeset
|
6 |
#include "ai_cargo.hpp" |
f6d169a5a45a
(svn r10529) [NoAI] -Add: added AIStation to gather information about stations directly by Id, which is used now by AIStationList
truelight
parents:
diff
changeset
|
7 |
#include "../../station.h" |
f6d169a5a45a
(svn r10529) [NoAI] -Add: added AIStation to gather information about stations directly by Id, which is used now by AIStationList
truelight
parents:
diff
changeset
|
8 |
|
f6d169a5a45a
(svn r10529) [NoAI] -Add: added AIStation to gather information about stations directly by Id, which is used now by AIStationList
truelight
parents:
diff
changeset
|
9 |
/* static */ bool AIStation::IsValidStation(StationID station_id) |
f6d169a5a45a
(svn r10529) [NoAI] -Add: added AIStation to gather information about stations directly by Id, which is used now by AIStationList
truelight
parents:
diff
changeset
|
10 |
{ |
f6d169a5a45a
(svn r10529) [NoAI] -Add: added AIStation to gather information about stations directly by Id, which is used now by AIStationList
truelight
parents:
diff
changeset
|
11 |
return ::IsValidStationID(station_id) && ::GetStation(station_id)->owner == _current_player; |
f6d169a5a45a
(svn r10529) [NoAI] -Add: added AIStation to gather information about stations directly by Id, which is used now by AIStationList
truelight
parents:
diff
changeset
|
12 |
} |
f6d169a5a45a
(svn r10529) [NoAI] -Add: added AIStation to gather information about stations directly by Id, which is used now by AIStationList
truelight
parents:
diff
changeset
|
13 |
|
f6d169a5a45a
(svn r10529) [NoAI] -Add: added AIStation to gather information about stations directly by Id, which is used now by AIStationList
truelight
parents:
diff
changeset
|
14 |
/* static */ TileIndex AIStation::GetLocation(StationID station_id) |
f6d169a5a45a
(svn r10529) [NoAI] -Add: added AIStation to gather information about stations directly by Id, which is used now by AIStationList
truelight
parents:
diff
changeset
|
15 |
{ |
f6d169a5a45a
(svn r10529) [NoAI] -Add: added AIStation to gather information about stations directly by Id, which is used now by AIStationList
truelight
parents:
diff
changeset
|
16 |
if (!AIStation::IsValidStation(station_id)) return INVALID_TILE; |
f6d169a5a45a
(svn r10529) [NoAI] -Add: added AIStation to gather information about stations directly by Id, which is used now by AIStationList
truelight
parents:
diff
changeset
|
17 |
|
f6d169a5a45a
(svn r10529) [NoAI] -Add: added AIStation to gather information about stations directly by Id, which is used now by AIStationList
truelight
parents:
diff
changeset
|
18 |
return ::GetStation(station_id)->xy; |
f6d169a5a45a
(svn r10529) [NoAI] -Add: added AIStation to gather information about stations directly by Id, which is used now by AIStationList
truelight
parents:
diff
changeset
|
19 |
} |
f6d169a5a45a
(svn r10529) [NoAI] -Add: added AIStation to gather information about stations directly by Id, which is used now by AIStationList
truelight
parents:
diff
changeset
|
20 |
|
f6d169a5a45a
(svn r10529) [NoAI] -Add: added AIStation to gather information about stations directly by Id, which is used now by AIStationList
truelight
parents:
diff
changeset
|
21 |
/* static */ int32 AIStation::GetCargoWaiting(StationID station_id, CargoID cargo_id) |
f6d169a5a45a
(svn r10529) [NoAI] -Add: added AIStation to gather information about stations directly by Id, which is used now by AIStationList
truelight
parents:
diff
changeset
|
22 |
{ |
f6d169a5a45a
(svn r10529) [NoAI] -Add: added AIStation to gather information about stations directly by Id, which is used now by AIStationList
truelight
parents:
diff
changeset
|
23 |
if (!AIStation::IsValidStation(station_id)) return -1; |
f6d169a5a45a
(svn r10529) [NoAI] -Add: added AIStation to gather information about stations directly by Id, which is used now by AIStationList
truelight
parents:
diff
changeset
|
24 |
if (!AICargo::IsValidCargo(cargo_id)) return -1; |
f6d169a5a45a
(svn r10529) [NoAI] -Add: added AIStation to gather information about stations directly by Id, which is used now by AIStationList
truelight
parents:
diff
changeset
|
25 |
|
f6d169a5a45a
(svn r10529) [NoAI] -Add: added AIStation to gather information about stations directly by Id, which is used now by AIStationList
truelight
parents:
diff
changeset
|
26 |
return ::GetStation(station_id)->goods[cargo_id].cargo.Count(); |
f6d169a5a45a
(svn r10529) [NoAI] -Add: added AIStation to gather information about stations directly by Id, which is used now by AIStationList
truelight
parents:
diff
changeset
|
27 |
} |
9648
760b7b504e37
(svn r10543) [NoAI] -Add: added AIStationListCargoRating as valuator for a station list
truelight
parents:
9638
diff
changeset
|
28 |
|
760b7b504e37
(svn r10543) [NoAI] -Add: added AIStationListCargoRating as valuator for a station list
truelight
parents:
9638
diff
changeset
|
29 |
/* static */ int32 AIStation::GetCargoRating(StationID station_id, CargoID cargo_id) |
760b7b504e37
(svn r10543) [NoAI] -Add: added AIStationListCargoRating as valuator for a station list
truelight
parents:
9638
diff
changeset
|
30 |
{ |
760b7b504e37
(svn r10543) [NoAI] -Add: added AIStationListCargoRating as valuator for a station list
truelight
parents:
9638
diff
changeset
|
31 |
if (!AIStation::IsValidStation(station_id)) return -1; |
760b7b504e37
(svn r10543) [NoAI] -Add: added AIStationListCargoRating as valuator for a station list
truelight
parents:
9638
diff
changeset
|
32 |
if (!AICargo::IsValidCargo(cargo_id)) return -1; |
760b7b504e37
(svn r10543) [NoAI] -Add: added AIStationListCargoRating as valuator for a station list
truelight
parents:
9638
diff
changeset
|
33 |
|
760b7b504e37
(svn r10543) [NoAI] -Add: added AIStationListCargoRating as valuator for a station list
truelight
parents:
9638
diff
changeset
|
34 |
return ::GetStation(station_id)->goods[cargo_id].rating * 101 >> 8; |
760b7b504e37
(svn r10543) [NoAI] -Add: added AIStationListCargoRating as valuator for a station list
truelight
parents:
9638
diff
changeset
|
35 |
} |