changeset 8573:ed1fec953237 draft

(svn r12154) -Codechange: removed a magic number
author glx <glx@openttd.org>
date Fri, 15 Feb 2008 23:57:03 +0000
parents 8a95003be848
children a34203ecde25
files src/ai/default/default.cpp src/airport_gui.cpp src/dock_gui.cpp src/rail_gui.cpp src/road_gui.cpp src/station.h src/station_cmd.cpp
diffstat 7 files changed, 10 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/src/ai/default/default.cpp
+++ b/src/ai/default/default.cpp
@@ -1604,7 +1604,7 @@
 
 static bool AiCheckTrackResources(TileIndex tile, const AiDefaultBlockData *p, byte cargo)
 {
-	uint rad = (_patches.modified_catchment) ? CA_TRAIN : 4;
+	uint rad = (_patches.modified_catchment) ? CA_TRAIN : CA_UNMODIFIED;
 
 	for (; p->mode != 4; p++) {
 		AcceptedCargo values;
@@ -3409,7 +3409,7 @@
 		const AirportFTAClass* airport = GetAirport(p->attr);
 		uint w = airport->size_x;
 		uint h = airport->size_y;
-		uint rad = _patches.modified_catchment ? airport->catchment : 4;
+		uint rad = _patches.modified_catchment ? airport->catchment : CA_UNMODIFIED;
 
 		if (cargo & 0x80) {
 			GetProductionAroundTiles(values, tile2, w, h, rad);
--- a/src/airport_gui.cpp
+++ b/src/airport_gui.cpp
@@ -179,7 +179,7 @@
 		airport = GetAirport(_selected_airport_type);
 		SetTileSelectSize(airport->size_x, airport->size_y);
 
-		int rad = _patches.modified_catchment ? airport->catchment : 4;
+		int rad = _patches.modified_catchment ? airport->catchment : CA_UNMODIFIED;
 
 		if (_station_show_coverage) SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad);
 
--- a/src/dock_gui.cpp
+++ b/src/dock_gui.cpp
@@ -243,7 +243,7 @@
 	case WE_CREATE: w->LowerWidget(_station_show_coverage + 3); break;
 
 	case WE_PAINT: {
-		int rad = (_patches.modified_catchment) ? CA_DOCK : 4;
+		int rad = (_patches.modified_catchment) ? CA_DOCK : CA_UNMODIFIED;
 
 		if (WP(w, def_d).close) return;
 		DrawWindowWidgets(w);
--- a/src/rail_gui.cpp
+++ b/src/rail_gui.cpp
@@ -818,7 +818,7 @@
 				SetTileSelectSize(x, y);
 		}
 
-		int rad = (_patches.modified_catchment) ? CA_TRAIN : 4;
+		int rad = (_patches.modified_catchment) ? CA_TRAIN : CA_UNMODIFIED;
 
 		if (_station_show_coverage)
 			SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad);
--- a/src/road_gui.cpp
+++ b/src/road_gui.cpp
@@ -809,7 +809,7 @@
 		DrawWindowWidgets(w);
 
 		if (_station_show_coverage) {
-			int rad = _patches.modified_catchment ? CA_TRUCK /* = CA_BUS */ : 4;
+			int rad = _patches.modified_catchment ? CA_TRUCK /* = CA_BUS */ : CA_UNMODIFIED;
 			SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad);
 		} else {
 			SetTileSelectSize(1, 1);
--- a/src/station.h
+++ b/src/station.h
@@ -239,6 +239,8 @@
 	CA_TRAIN           =  4,
 	CA_DOCK            =  5,
 
+	CA_UNMODIFIED      =  4, ///< Used when _patches.modified_catchment is false
+
 	MAX_CATCHMENT      = 10, ///< Airports have a catchment up to this number.
 };
 
--- a/src/station_cmd.cpp
+++ b/src/station_cmd.cpp
@@ -599,7 +599,7 @@
 			TileXY(rect.min_x, rect.min_y),
 			rect.max_x - rect.min_x + 1,
 			rect.max_y - rect.min_y + 1,
-			_patches.modified_catchment ? FindCatchmentRadius(st) : 4
+			_patches.modified_catchment ? FindCatchmentRadius(st) : CA_UNMODIFIED
 		);
 	} else {
 		memset(accepts, 0, sizeof(accepts));
@@ -2712,7 +2712,7 @@
 		h_prod = 0;
 		w += 8;
 		h += 8;
-		max_rad = 4;
+		max_rad = CA_UNMODIFIED;
 	}
 
 	BEGIN_TILE_LOOP(cur_tile, w, h, tile - TileDiffXY(max_rad, max_rad))