src/station_cmd.cpp
changeset 10290 56925f09d693
parent 10289 801e5451f0ca
child 10347 6da2d30f2fe8
equal deleted inserted replaced
10289:801e5451f0ca 10290:56925f09d693
    95 
    95 
    96 	return num;
    96 	return num;
    97 }
    97 }
    98 
    98 
    99 
    99 
   100 /** Calculate the radius of the station. Basicly it is the biggest
       
   101  *  radius that is available within the station
       
   102  * @param st Station to query
       
   103  * @return the so calculated radius
       
   104  */
       
   105 static uint FindCatchmentRadius(const Station *st)
       
   106 {
       
   107 	uint ret = CA_NONE;
       
   108 
       
   109 	if (st->bus_stops   != NULL) ret = max<uint>(ret, CA_BUS);
       
   110 	if (st->truck_stops != NULL) ret = max<uint>(ret, CA_TRUCK);
       
   111 	if (st->train_tile  != 0)    ret = max<uint>(ret, CA_TRAIN);
       
   112 	if (st->dock_tile   != 0)    ret = max<uint>(ret, CA_DOCK);
       
   113 	if (st->airport_tile)        ret = max<uint>(ret, st->Airport()->catchment);
       
   114 
       
   115 	return ret;
       
   116 }
       
   117 
       
   118 #define CHECK_STATIONS_ERR ((Station*)-1)
   100 #define CHECK_STATIONS_ERR ((Station*)-1)
   119 
   101 
   120 static Station *GetStationAround(TileIndex tile, int w, int h, StationID closest_station)
   102 static Station *GetStationAround(TileIndex tile, int w, int h, StationID closest_station)
   121 {
   103 {
   122 	/* check around to see if there's any stations there */
   104 	/* check around to see if there's any stations there */
   573 		GetAcceptanceAroundTiles(
   555 		GetAcceptanceAroundTiles(
   574 			accepts,
   556 			accepts,
   575 			TileXY(rect.left, rect.bottom),
   557 			TileXY(rect.left, rect.bottom),
   576 			rect.right - rect.left   + 1,
   558 			rect.right - rect.left   + 1,
   577 			rect.top   - rect.bottom + 1,
   559 			rect.top   - rect.bottom + 1,
   578 			_settings_game.station.modified_catchment ? FindCatchmentRadius(st) : (uint)CA_UNMODIFIED
   560 			st->GetCatchmentRadius()
   579 		);
   561 		);
   580 	} else {
   562 	} else {
   581 		memset(accepts, 0, sizeof(accepts));
   563 		memset(accepts, 0, sizeof(accepts));
   582 	}
   564 	}
   583 
   565 
  2905 			const int x_min_prod = max_rad + 1;
  2887 			const int x_min_prod = max_rad + 1;
  2906 			const int x_max_prod = max_rad + w_prod;
  2888 			const int x_max_prod = max_rad + w_prod;
  2907 			const int y_min_prod = max_rad + 1;
  2889 			const int y_min_prod = max_rad + 1;
  2908 			const int y_max_prod = max_rad + h_prod;
  2890 			const int y_max_prod = max_rad + h_prod;
  2909 
  2891 
  2910 			int rad = FindCatchmentRadius(st);
  2892 			int rad = st->GetCatchmentRadius();
  2911 
  2893 
  2912 			int x_dist = min(w_cur - x_min_prod, x_max_prod - w_cur);
  2894 			int x_dist = min(w_cur - x_min_prod, x_max_prod - w_cur);
  2913 			if (w_cur < x_min_prod) {
  2895 			if (w_cur < x_min_prod) {
  2914 				x_dist = x_min_prod - w_cur;
  2896 				x_dist = x_min_prod - w_cur;
  2915 			} else if (w_cur > x_max_prod) {
  2897 			} else if (w_cur > x_max_prod) {