equal
deleted
inserted
replaced
2 |
2 |
3 /** @file ai_station.cpp handles the functions of the AIStation class */ |
3 /** @file ai_station.cpp handles the functions of the AIStation class */ |
4 |
4 |
5 #include "ai_station.hpp" |
5 #include "ai_station.hpp" |
6 #include "ai_cargo.hpp" |
6 #include "ai_cargo.hpp" |
|
7 #include "../../debug.h" |
7 #include "../../station.h" |
8 #include "../../station.h" |
8 #include "../../station_map.h" |
9 #include "../../station_map.h" |
|
10 #include "../../variables.h" |
9 |
11 |
10 /* static */ bool AIStation::IsValidStation(StationID station_id) |
12 /* static */ bool AIStation::IsValidStation(StationID station_id) |
11 { |
13 { |
12 return ::IsValidStationID(station_id) && ::GetStation(station_id)->owner == _current_player; |
14 return ::IsValidStationID(station_id) && ::GetStation(station_id)->owner == _current_player; |
13 } |
15 } |
38 if (!AIStation::IsValidStation(station_id)) return -1; |
40 if (!AIStation::IsValidStation(station_id)) return -1; |
39 if (!AICargo::IsValidCargo(cargo_id)) return -1; |
41 if (!AICargo::IsValidCargo(cargo_id)) return -1; |
40 |
42 |
41 return ::GetStation(station_id)->goods[cargo_id].rating * 101 >> 8; |
43 return ::GetStation(station_id)->goods[cargo_id].rating * 101 >> 8; |
42 } |
44 } |
|
45 |
|
46 /* static */ int32 AIStation::GetCoverageRadius(AIStation::StationType type) |
|
47 { |
|
48 if (type == STATION_AIRPORT) { |
|
49 DEBUG(ai, 0, "GetCoverageRadius(): coverage radius of airports needs to be requested via AIAirport::GetAirportCoverageRadius(), as it requires AirportType"); |
|
50 return 0; |
|
51 } |
|
52 if (!_patches.modified_catchment) return 3; |
|
53 |
|
54 switch (type) { |
|
55 case STATION_TRAIN: return CA_TRAIN; |
|
56 case STATION_TRUCK_STOP: return CA_TRUCK; |
|
57 case STATION_BUS_STOP: return CA_BUS; |
|
58 case STATION_DOCK: return CA_DOCK; |
|
59 default: return CA_NONE; |
|
60 } |
|
61 } |