Mercurial > hg > openttd
changeset 6041:1342ec694693 draft
(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
author | tron <tron@openttd.org> |
---|---|
date | Sat, 17 Feb 2007 07:45:18 +0000 |
parents | 0438dc727808 |
children | f251bed7063f |
files | src/ai/default/default.cpp src/airport.cpp src/airport.h src/airport_gui.cpp src/station.h src/station_cmd.cpp |
diffstat | 6 files changed, 37 insertions(+), 67 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ai/default/default.cpp +++ b/src/ai/default/default.cpp @@ -3333,19 +3333,13 @@ 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);
--- a/src/airport.cpp +++ b/src/airport.cpp @@ -42,7 +42,8 @@ _airport_depots_country, lengthof(_airport_depots_country), 4, 3, - 0 + 0, + 4 ); CityAirport = new AirportFTAClass( @@ -55,7 +56,8 @@ _airport_depots_city, lengthof(_airport_depots_city), 6, 6, - 0 + 0, + 5 ); MetropolitanAirport = new AirportFTAClass( @@ -68,7 +70,8 @@ _airport_depots_metropolitan, lengthof(_airport_depots_metropolitan), 6, 6, - 0 + 0, + 6 ); InternationalAirport = new AirportFTAClass( @@ -81,7 +84,8 @@ _airport_depots_international, lengthof(_airport_depots_international), 7, 7, - 0 + 0, + 8 ); IntercontinentalAirport = new AirportFTAClass( @@ -94,7 +98,8 @@ _airport_depots_intercontinental, lengthof(_airport_depots_intercontinental), 9, 11, - 0 + 0, + 10 ); Heliport = new AirportFTAClass( @@ -107,7 +112,8 @@ NULL, 0, 1, 1, - 60 + 60, + 4 ); Oilrig = new AirportFTAClass( @@ -120,7 +126,8 @@ NULL, 0, 1, 1, - 54 + 54, + 3 ); CommuterAirport = new AirportFTAClass( @@ -133,7 +140,8 @@ _airport_depots_commuter, lengthof(_airport_depots_commuter), 5, 4, - 0 + 0, + 4 ); HeliDepot = new AirportFTAClass( @@ -146,7 +154,8 @@ _airport_depots_helidepot, lengthof(_airport_depots_helidepot), 2, 2, - 0 + 0, + 4 ); HeliStation = new AirportFTAClass( @@ -159,7 +168,8 @@ _airport_depots_helistation, lengthof(_airport_depots_helistation), 4, 2, - 0 + 0, + 4 ); } @@ -198,7 +208,8 @@ 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 @@ 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;
--- a/src/airport.h +++ b/src/airport.h @@ -139,7 +139,8 @@ byte nof_depots, uint size_x, uint size_y, - byte delta_z + byte delta_z, + byte catchment ); ~AirportFTAClass(); @@ -162,6 +163,7 @@ byte size_x; byte size_y; byte delta_z; // Z adjustment for helicopter pads + byte catchment; } AirportFTAClass; DECLARE_ENUM_AS_BIT_SET(AirportFTAClass::Flags)
--- a/src/airport_gui.cpp +++ b/src/airport_gui.cpp @@ -150,7 +150,6 @@ case WE_PAINT: { int i; // airport enabling loop - int rad = 4; // default catchment radious uint32 avail_airports; const AirportFTAClass *airport; @@ -175,20 +174,7 @@ 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);
--- a/src/station.h +++ b/src/station.h @@ -209,18 +209,8 @@ 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);
--- a/src/station_cmd.cpp +++ b/src/station_cmd.cpp @@ -110,27 +110,13 @@ * 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; }