diff options
author | tron <tron@openttd.org> | 2007-02-17 07:45:18 +0000 |
---|---|---|
committer | tron <tron@openttd.org> | 2007-02-17 07:45:18 +0000 |
commit | 8aacd2585d0992dc3a87da8042369bb1830d8cd5 (patch) | |
tree | cdfedf5d3384be14d0978c46e2c599f6c1265392 /src | |
parent | ee0739561d0ee2167f769ff0abca6302ce270581 (diff) | |
download | openttd-8aacd2585d0992dc3a87da8042369bb1830d8cd5.tar.xz |
(svn r8767) -Fix
-Codechange: Do not hardcode the catchment radius of airports, but hold the information in AirportFTAClass
-Fix (r979): The default AI tested possible airport locations with a fixed catchment radius instead of the radius of the to be built airport
Diffstat (limited to 'src')
-rw-r--r-- | src/ai/default/default.cpp | 8 | ||||
-rw-r--r-- | src/airport.cpp | 36 | ||||
-rw-r--r-- | src/airport.h | 4 | ||||
-rw-r--r-- | src/airport_gui.cpp | 16 | ||||
-rw-r--r-- | src/station.h | 12 | ||||
-rw-r--r-- | src/station_cmd.cpp | 28 |
6 files changed, 37 insertions, 67 deletions
diff --git a/src/ai/default/default.cpp b/src/ai/default/default.cpp index 33f62c7f2..f8af9c333 100644 --- a/src/ai/default/default.cpp +++ b/src/ai/default/default.cpp @@ -3333,19 +3333,13 @@ static int32 AiDoBuildDefaultAirportBlock(TileIndex tile, const AiDefaultBlockDa static bool AiCheckAirportResources(TileIndex tile, const AiDefaultBlockData *p, byte cargo) { uint values[NUM_CARGO]; - int rad; - - if (_patches.modified_catchment) { - rad = CA_AIR_LARGE; // I Have NFI what airport the - } else { // AI is going to build here - rad = 4; - } for (; p->mode == 0; p++) { TileIndex tile2 = TILE_ADD(tile, ToTileIndexDiff(p->tileoffs)); const AirportFTAClass* airport = GetAirport(p->attr); uint w = airport->size_x; uint h = airport->size_y; + uint rad = _patches.modified_catchment ? airport->catchment : 4; if (cargo & 0x80) { GetProductionAroundTiles(values, tile2, w, h, rad); diff --git a/src/airport.cpp b/src/airport.cpp index 3155129f9..0528cee91 100644 --- a/src/airport.cpp +++ b/src/airport.cpp @@ -42,7 +42,8 @@ void InitializeAirports(void) _airport_depots_country, lengthof(_airport_depots_country), 4, 3, - 0 + 0, + 4 ); CityAirport = new AirportFTAClass( @@ -55,7 +56,8 @@ void InitializeAirports(void) _airport_depots_city, lengthof(_airport_depots_city), 6, 6, - 0 + 0, + 5 ); MetropolitanAirport = new AirportFTAClass( @@ -68,7 +70,8 @@ void InitializeAirports(void) _airport_depots_metropolitan, lengthof(_airport_depots_metropolitan), 6, 6, - 0 + 0, + 6 ); InternationalAirport = new AirportFTAClass( @@ -81,7 +84,8 @@ void InitializeAirports(void) _airport_depots_international, lengthof(_airport_depots_international), 7, 7, - 0 + 0, + 8 ); IntercontinentalAirport = new AirportFTAClass( @@ -94,7 +98,8 @@ void InitializeAirports(void) _airport_depots_intercontinental, lengthof(_airport_depots_intercontinental), 9, 11, - 0 + 0, + 10 ); Heliport = new AirportFTAClass( @@ -107,7 +112,8 @@ void InitializeAirports(void) NULL, 0, 1, 1, - 60 + 60, + 4 ); Oilrig = new AirportFTAClass( @@ -120,7 +126,8 @@ void InitializeAirports(void) NULL, 0, 1, 1, - 54 + 54, + 3 ); CommuterAirport = new AirportFTAClass( @@ -133,7 +140,8 @@ void InitializeAirports(void) _airport_depots_commuter, lengthof(_airport_depots_commuter), 5, 4, - 0 + 0, + 4 ); HeliDepot = new AirportFTAClass( @@ -146,7 +154,8 @@ void InitializeAirports(void) _airport_depots_helidepot, lengthof(_airport_depots_helidepot), 2, 2, - 0 + 0, + 4 ); HeliStation = new AirportFTAClass( @@ -159,7 +168,8 @@ void InitializeAirports(void) _airport_depots_helistation, lengthof(_airport_depots_helistation), 4, 2, - 0 + 0, + 4 ); } @@ -198,7 +208,8 @@ AirportFTAClass::AirportFTAClass( const byte nof_depots_, uint size_x_, uint size_y_, - byte delta_z_ + byte delta_z_, + byte catchment_ ) : moving_data(moving_data_), terminals(terminals_), @@ -210,7 +221,8 @@ AirportFTAClass::AirportFTAClass( entry_points(entry_points_), size_x(size_x_), size_y(size_y_), - delta_z(delta_z_) + delta_z(delta_z_), + catchment(catchment_) { byte nofterminalgroups, nofhelipadgroups; diff --git a/src/airport.h b/src/airport.h index ce210301d..3abe056b6 100644 --- a/src/airport.h +++ b/src/airport.h @@ -139,7 +139,8 @@ typedef struct AirportFTAClass { byte nof_depots, uint size_x, uint size_y, - byte delta_z + byte delta_z, + byte catchment ); ~AirportFTAClass(); @@ -162,6 +163,7 @@ typedef struct AirportFTAClass { byte size_x; byte size_y; byte delta_z; // Z adjustment for helicopter pads + byte catchment; } AirportFTAClass; DECLARE_ENUM_AS_BIT_SET(AirportFTAClass::Flags) diff --git a/src/airport_gui.cpp b/src/airport_gui.cpp index 90eaab323..9a4b34304 100644 --- a/src/airport_gui.cpp +++ b/src/airport_gui.cpp @@ -150,7 +150,6 @@ static void BuildAirportPickerWndProc(Window *w, WindowEvent *e) case WE_PAINT: { int i; // airport enabling loop - int rad = 4; // default catchment radious uint32 avail_airports; const AirportFTAClass *airport; @@ -175,20 +174,7 @@ static void BuildAirportPickerWndProc(Window *w, WindowEvent *e) airport = GetAirport(_selected_airport_type); SetTileSelectSize(airport->size_x, airport->size_y); - if (_patches.modified_catchment) { - switch (_selected_airport_type) { - case AT_OILRIG: rad = CA_AIR_OILPAD; break; - case AT_HELIPORT: rad = CA_AIR_HELIPORT; break; - case AT_SMALL: rad = CA_AIR_SMALL; break; - case AT_LARGE: rad = CA_AIR_LARGE; break; - case AT_METROPOLITAN: rad = CA_AIR_METRO; break; - case AT_INTERNATIONAL: rad = CA_AIR_INTER; break; - case AT_COMMUTER: rad = CA_AIR_COMMUTER; break; - case AT_HELIDEPOT: rad = CA_AIR_HELIDEPOT; break; - case AT_INTERCON: rad = CA_AIR_INTERCON; break; - case AT_HELISTATION: rad = CA_AIR_HELISTATION; break; - } - } + uint rad = _patches.modified_catchment ? airport->catchment : 4; if (_station_show_coverage) SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad); diff --git a/src/station.h b/src/station.h index 6ec5777c6..b4ac9a2b3 100644 --- a/src/station.h +++ b/src/station.h @@ -209,18 +209,8 @@ typedef enum CatchmentAeras { CA_NONE = 0, CA_BUS = 3, CA_TRUCK = 3, - CA_AIR_OILPAD = 3, CA_TRAIN = 4, - CA_AIR_HELIPORT = 4, - CA_AIR_SMALL = 4, - CA_AIR_LARGE = 5, - CA_DOCK = 5, - CA_AIR_METRO = 6, - CA_AIR_INTER = 8, - CA_AIR_COMMUTER = 4, - CA_AIR_HELIDEPOT = 4, - CA_AIR_INTERCON = 10, - CA_AIR_HELISTATION = 4, + CA_DOCK = 5 } CatchmentAera; void ModifyStationRatingAround(TileIndex tile, PlayerID owner, int amount, uint radius); diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp index 425fb49f0..efb08d91f 100644 --- a/src/station_cmd.cpp +++ b/src/station_cmd.cpp @@ -110,27 +110,13 @@ static uint GetNumRoadStopsInStation(const Station* st, RoadStop::Type type) * radius that is available within the station */ static uint FindCatchmentRadius(const Station* st) { - CatchmentAera ret = CA_NONE; - - if (st->bus_stops != NULL) ret = max(ret, CA_BUS); - if (st->truck_stops != NULL) ret = max(ret, CA_TRUCK); - if (st->train_tile) ret = max(ret, CA_TRAIN); - if (st->dock_tile) ret = max(ret, CA_DOCK); - - if (st->airport_tile) { - switch (st->airport_type) { - case AT_OILRIG: ret = max(ret, CA_AIR_OILPAD); break; - case AT_SMALL: ret = max(ret, CA_AIR_SMALL); break; - case AT_HELIPORT: ret = max(ret, CA_AIR_HELIPORT); break; - case AT_LARGE: ret = max(ret, CA_AIR_LARGE); break; - case AT_METROPOLITAN: ret = max(ret, CA_AIR_METRO); break; - case AT_INTERNATIONAL: ret = max(ret, CA_AIR_INTER); break; - case AT_COMMUTER: ret = max(ret, CA_AIR_COMMUTER); break; - case AT_HELIDEPOT: ret = max(ret, CA_AIR_HELIDEPOT); break; - case AT_INTERCON: ret = max(ret, CA_AIR_INTERCON); break; - case AT_HELISTATION: ret = max(ret, CA_AIR_HELISTATION); break; - } - } + uint ret = CA_NONE; + + if (st->bus_stops != NULL) ret = max<uint>(ret, CA_BUS); + if (st->truck_stops != NULL) ret = max<uint>(ret, CA_TRUCK); + if (st->train_tile != 0) ret = max<uint>(ret, CA_TRAIN); + if (st->dock_tile != 0) ret = max<uint>(ret, CA_DOCK); + if (st->airport_tile) ret = max<uint>(ret, st->Airport()->catchment); return ret; } |