From 11ef57d81ea1a9c94002ef9013cebb0990b337e7 Mon Sep 17 00:00:00 2001 From: frosch Date: Sat, 25 Oct 2008 14:19:09 +0000 Subject: [PATCH] (svn r14529) -Codechange: Turn FindCatchmentRadius() into Station::GetCatchmentRadius(). --- src/station.cpp | 22 ++++++++++++++++++++++ src/station_base.h | 2 ++ src/station_cmd.cpp | 22 ++-------------------- 3 files changed, 26 insertions(+), 20 deletions(-) diff --git a/src/station.cpp b/src/station.cpp index 128dbe9b74..1c3570d521 100644 --- a/src/station.cpp +++ b/src/station.cpp @@ -246,6 +246,28 @@ bool Station::IsBuoy() const return (had_vehicle_of_type & HVOT_BUOY) != 0; } +/** Determines the catchment radius of the station + * @return The radius + */ +uint Station::GetCatchmentRadius() const +{ + uint ret = CA_NONE; + + if (_settings_game.station.modified_catchment) { + if (this->bus_stops != NULL) ret = max(ret, CA_BUS); + if (this->truck_stops != NULL) ret = max(ret, CA_TRUCK); + if (this->train_tile != 0) ret = max(ret, CA_TRAIN); + if (this->dock_tile != 0) ret = max(ret, CA_DOCK); + if (this->airport_tile != 0) ret = max(ret, this->Airport()->catchment); + } else { + if (this->bus_stops != NULL || this->truck_stops != NULL || this->train_tile != 0 || this->dock_tile != 0 || this->airport_tile != 0) { + ret = CA_UNMODIFIED; + } + } + + return ret; +} + /************************************************************************/ /* StationRect implementation */ diff --git a/src/station_base.h b/src/station_base.h index 0a0019af2e..9e22f231ea 100644 --- a/src/station_base.h +++ b/src/station_base.h @@ -195,6 +195,8 @@ public: * @return true if and only is the station exists */ inline bool IsValid() const { return this->xy != 0; } + + uint GetCatchmentRadius() const; }; static inline StationID GetMaxStationIndex() diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp index ecddffc750..9adb5aff96 100644 --- a/src/station_cmd.cpp +++ b/src/station_cmd.cpp @@ -97,24 +97,6 @@ static uint GetNumRoadStopsInStation(const Station *st, RoadStopType type) } -/** Calculate the radius of the station. Basicly it is the biggest - * radius that is available within the station - * @param st Station to query - * @return the so calculated radius - */ -static uint FindCatchmentRadius(const Station *st) -{ - uint 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 != 0) ret = max(ret, CA_TRAIN); - if (st->dock_tile != 0) ret = max(ret, CA_DOCK); - if (st->airport_tile) ret = max(ret, st->Airport()->catchment); - - return ret; -} - #define CHECK_STATIONS_ERR ((Station*)-1) static Station *GetStationAround(TileIndex tile, int w, int h, StationID closest_station) @@ -575,7 +557,7 @@ static void UpdateStationAcceptance(Station *st, bool show_msg) TileXY(rect.left, rect.bottom), rect.right - rect.left + 1, rect.top - rect.bottom + 1, - _settings_game.station.modified_catchment ? FindCatchmentRadius(st) : (uint)CA_UNMODIFIED + st->GetCatchmentRadius() ); } else { memset(accepts, 0, sizeof(accepts)); @@ -2907,7 +2889,7 @@ StationSet FindStationsAroundIndustryTile(TileIndex tile, int w, int h) const int y_min_prod = max_rad + 1; const int y_max_prod = max_rad + h_prod; - int rad = FindCatchmentRadius(st); + int rad = st->GetCatchmentRadius(); int x_dist = min(w_cur - x_min_prod, x_max_prod - w_cur); if (w_cur < x_min_prod) {