Changeset - r6041:faeebb65e47c
[Not reviewed]
master
0 6 0
tron - 18 years ago 2007-02-17 07:45:18
tron@openttd.org
(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
6 files changed with 37 insertions and 67 deletions:
0 comments (0 inline, 0 general)
src/ai/default/default.cpp
Show inline comments
 
@@ -3333,19 +3333,13 @@ static int32 AiDoBuildDefaultAirportBloc
 
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);
src/airport.cpp
Show inline comments
 
@@ -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;
 

	
src/airport.h
Show inline comments
 
@@ -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)
src/airport_gui.cpp
Show inline comments
 
@@ -150,7 +150,6 @@ static void BuildAirportPickerWndProc(Wi
 

	
 
	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(Wi
 
		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);
 

	
src/station.h
Show inline comments
 
@@ -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);
src/station_cmd.cpp
Show inline comments
 
@@ -110,27 +110,13 @@ static uint GetNumRoadStopsInStation(con
 
 *  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;
 
}
0 comments (0 inline, 0 general)