1
0
Fork 0

(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
release/0.6
tron 2007-02-17 07:45:18 +00:00
parent ee0739561d
commit 8aacd2585d
6 changed files with 36 additions and 66 deletions

View File

@ -3333,19 +3333,13 @@ static int32 AiDoBuildDefaultAirportBlock(TileIndex tile, const AiDefaultBlockDa
static bool AiCheckAirportResources(TileIndex tile, const AiDefaultBlockData *p, byte cargo) static bool AiCheckAirportResources(TileIndex tile, const AiDefaultBlockData *p, byte cargo)
{ {
uint values[NUM_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++) { for (; p->mode == 0; p++) {
TileIndex tile2 = TILE_ADD(tile, ToTileIndexDiff(p->tileoffs)); TileIndex tile2 = TILE_ADD(tile, ToTileIndexDiff(p->tileoffs));
const AirportFTAClass* airport = GetAirport(p->attr); const AirportFTAClass* airport = GetAirport(p->attr);
uint w = airport->size_x; uint w = airport->size_x;
uint h = airport->size_y; uint h = airport->size_y;
uint rad = _patches.modified_catchment ? airport->catchment : 4;
if (cargo & 0x80) { if (cargo & 0x80) {
GetProductionAroundTiles(values, tile2, w, h, rad); GetProductionAroundTiles(values, tile2, w, h, rad);

View File

@ -42,7 +42,8 @@ void InitializeAirports(void)
_airport_depots_country, _airport_depots_country,
lengthof(_airport_depots_country), lengthof(_airport_depots_country),
4, 3, 4, 3,
0 0,
4
); );
CityAirport = new AirportFTAClass( CityAirport = new AirportFTAClass(
@ -55,7 +56,8 @@ void InitializeAirports(void)
_airport_depots_city, _airport_depots_city,
lengthof(_airport_depots_city), lengthof(_airport_depots_city),
6, 6, 6, 6,
0 0,
5
); );
MetropolitanAirport = new AirportFTAClass( MetropolitanAirport = new AirportFTAClass(
@ -68,7 +70,8 @@ void InitializeAirports(void)
_airport_depots_metropolitan, _airport_depots_metropolitan,
lengthof(_airport_depots_metropolitan), lengthof(_airport_depots_metropolitan),
6, 6, 6, 6,
0 0,
6
); );
InternationalAirport = new AirportFTAClass( InternationalAirport = new AirportFTAClass(
@ -81,7 +84,8 @@ void InitializeAirports(void)
_airport_depots_international, _airport_depots_international,
lengthof(_airport_depots_international), lengthof(_airport_depots_international),
7, 7, 7, 7,
0 0,
8
); );
IntercontinentalAirport = new AirportFTAClass( IntercontinentalAirport = new AirportFTAClass(
@ -94,7 +98,8 @@ void InitializeAirports(void)
_airport_depots_intercontinental, _airport_depots_intercontinental,
lengthof(_airport_depots_intercontinental), lengthof(_airport_depots_intercontinental),
9, 11, 9, 11,
0 0,
10
); );
Heliport = new AirportFTAClass( Heliport = new AirportFTAClass(
@ -107,7 +112,8 @@ void InitializeAirports(void)
NULL, NULL,
0, 0,
1, 1, 1, 1,
60 60,
4
); );
Oilrig = new AirportFTAClass( Oilrig = new AirportFTAClass(
@ -120,7 +126,8 @@ void InitializeAirports(void)
NULL, NULL,
0, 0,
1, 1, 1, 1,
54 54,
3
); );
CommuterAirport = new AirportFTAClass( CommuterAirport = new AirportFTAClass(
@ -133,7 +140,8 @@ void InitializeAirports(void)
_airport_depots_commuter, _airport_depots_commuter,
lengthof(_airport_depots_commuter), lengthof(_airport_depots_commuter),
5, 4, 5, 4,
0 0,
4
); );
HeliDepot = new AirportFTAClass( HeliDepot = new AirportFTAClass(
@ -146,7 +154,8 @@ void InitializeAirports(void)
_airport_depots_helidepot, _airport_depots_helidepot,
lengthof(_airport_depots_helidepot), lengthof(_airport_depots_helidepot),
2, 2, 2, 2,
0 0,
4
); );
HeliStation = new AirportFTAClass( HeliStation = new AirportFTAClass(
@ -159,7 +168,8 @@ void InitializeAirports(void)
_airport_depots_helistation, _airport_depots_helistation,
lengthof(_airport_depots_helistation), lengthof(_airport_depots_helistation),
4, 2, 4, 2,
0 0,
4
); );
} }
@ -198,7 +208,8 @@ AirportFTAClass::AirportFTAClass(
const byte nof_depots_, const byte nof_depots_,
uint size_x_, uint size_x_,
uint size_y_, uint size_y_,
byte delta_z_ byte delta_z_,
byte catchment_
) : ) :
moving_data(moving_data_), moving_data(moving_data_),
terminals(terminals_), terminals(terminals_),
@ -210,7 +221,8 @@ AirportFTAClass::AirportFTAClass(
entry_points(entry_points_), entry_points(entry_points_),
size_x(size_x_), size_x(size_x_),
size_y(size_y_), size_y(size_y_),
delta_z(delta_z_) delta_z(delta_z_),
catchment(catchment_)
{ {
byte nofterminalgroups, nofhelipadgroups; byte nofterminalgroups, nofhelipadgroups;

View File

@ -139,7 +139,8 @@ typedef struct AirportFTAClass {
byte nof_depots, byte nof_depots,
uint size_x, uint size_x,
uint size_y, uint size_y,
byte delta_z byte delta_z,
byte catchment
); );
~AirportFTAClass(); ~AirportFTAClass();
@ -162,6 +163,7 @@ typedef struct AirportFTAClass {
byte size_x; byte size_x;
byte size_y; byte size_y;
byte delta_z; // Z adjustment for helicopter pads byte delta_z; // Z adjustment for helicopter pads
byte catchment;
} AirportFTAClass; } AirportFTAClass;
DECLARE_ENUM_AS_BIT_SET(AirportFTAClass::Flags) DECLARE_ENUM_AS_BIT_SET(AirportFTAClass::Flags)

View File

@ -150,7 +150,6 @@ static void BuildAirportPickerWndProc(Window *w, WindowEvent *e)
case WE_PAINT: { case WE_PAINT: {
int i; // airport enabling loop int i; // airport enabling loop
int rad = 4; // default catchment radious
uint32 avail_airports; uint32 avail_airports;
const AirportFTAClass *airport; const AirportFTAClass *airport;
@ -175,20 +174,7 @@ static void BuildAirportPickerWndProc(Window *w, WindowEvent *e)
airport = GetAirport(_selected_airport_type); airport = GetAirport(_selected_airport_type);
SetTileSelectSize(airport->size_x, airport->size_y); SetTileSelectSize(airport->size_x, airport->size_y);
if (_patches.modified_catchment) { uint rad = _patches.modified_catchment ? airport->catchment : 4;
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;
}
}
if (_station_show_coverage) SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad); if (_station_show_coverage) SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad);

View File

@ -209,18 +209,8 @@ typedef enum CatchmentAeras {
CA_NONE = 0, CA_NONE = 0,
CA_BUS = 3, CA_BUS = 3,
CA_TRUCK = 3, CA_TRUCK = 3,
CA_AIR_OILPAD = 3,
CA_TRAIN = 4, CA_TRAIN = 4,
CA_AIR_HELIPORT = 4, CA_DOCK = 5
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,
} CatchmentAera; } CatchmentAera;
void ModifyStationRatingAround(TileIndex tile, PlayerID owner, int amount, uint radius); void ModifyStationRatingAround(TileIndex tile, PlayerID owner, int amount, uint radius);

View File

@ -110,27 +110,13 @@ static uint GetNumRoadStopsInStation(const Station* st, RoadStop::Type type)
* radius that is available within the station */ * radius that is available within the station */
static uint FindCatchmentRadius(const Station* st) static uint FindCatchmentRadius(const Station* st)
{ {
CatchmentAera ret = CA_NONE; uint ret = CA_NONE;
if (st->bus_stops != NULL) ret = max(ret, CA_BUS); if (st->bus_stops != NULL) ret = max<uint>(ret, CA_BUS);
if (st->truck_stops != NULL) ret = max(ret, CA_TRUCK); if (st->truck_stops != NULL) ret = max<uint>(ret, CA_TRUCK);
if (st->train_tile) ret = max(ret, CA_TRAIN); if (st->train_tile != 0) ret = max<uint>(ret, CA_TRAIN);
if (st->dock_tile) ret = max(ret, CA_DOCK); if (st->dock_tile != 0) ret = max<uint>(ret, CA_DOCK);
if (st->airport_tile) ret = max<uint>(ret, st->Airport()->catchment);
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;
}
}
return ret; return ret;
} }