diff --git a/src/industry_cmd.cpp b/src/industry_cmd.cpp --- a/src/industry_cmd.cpp +++ b/src/industry_cmd.cpp @@ -2432,7 +2432,7 @@ static int WhoCanServiceIndustry(Industr StationList stations; FindStationsAroundTiles(ind->location, &stations); - if (stations.Length() == 0) return 0; // No stations found at all => nobody services + if (stations.size() == 0) return 0; // No stations found at all => nobody services const Vehicle *v; int result = 0; @@ -2468,7 +2468,7 @@ static int WhoCanServiceIndustry(Industr /* Same cargo produced by industry is dropped here => not serviced by vehicle v */ if ((o->GetUnloadType() & OUFB_UNLOAD) && !c_accepts) break; - if (stations.Contains(st)) { + if (stations.find(st) != stations.end()) { if (v->owner == _local_company) return 2; // Company services industry result = 1; // Competitor services industry } diff --git a/src/newgrf_house.cpp b/src/newgrf_house.cpp --- a/src/newgrf_house.cpp +++ b/src/newgrf_house.cpp @@ -350,8 +350,7 @@ static uint32 GetDistanceFromNearbyHouse /* Collect acceptance stats. */ uint32 res = 0; - for (Station * const * st_iter = sl->Begin(); st_iter != sl->End(); st_iter++) { - const Station *st = *st_iter; + for (Station *st : *sl) { if (HasBit(st->goods[cid].status, GoodsEntry::GES_EVER_ACCEPTED)) SetBit(res, 0); if (HasBit(st->goods[cid].status, GoodsEntry::GES_LAST_MONTH)) SetBit(res, 1); if (HasBit(st->goods[cid].status, GoodsEntry::GES_CURRENT_MONTH)) SetBit(res, 2); diff --git a/src/script/api/script_industry.cpp b/src/script/api/script_industry.cpp --- a/src/script/api/script_industry.cpp +++ b/src/script/api/script_industry.cpp @@ -134,7 +134,7 @@ Industry *ind = ::Industry::Get(industry_id); StationList stations; ::FindStationsAroundTiles(ind->location, &stations); - return (int32)stations.Length(); + return (int32)stations.size(); } /* static */ int32 ScriptIndustry::GetDistanceManhattanToTile(IndustryID industry_id, TileIndex tile) diff --git a/src/station.cpp b/src/station.cpp --- a/src/station.cpp +++ b/src/station.cpp @@ -571,3 +571,8 @@ Money AirportMaintenanceCost(Owner owner /* 3 bits fraction for the maintenance cost factor. */ return total_cost >> 3; } + +bool StationCompare::operator() (const Station *lhs, const Station *rhs) const +{ + return lhs->index < rhs->index; +} diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp --- a/src/station_cmd.cpp +++ b/src/station_cmd.cpp @@ -3839,7 +3839,7 @@ void FindStationsAroundTiles(const TileA /* Insert the station in the set. This will fail if it has * already been added. */ - stations->Include(st); + stations->insert(st); } } } @@ -3867,9 +3867,7 @@ uint MoveGoodsToStation(CargoID type, ui uint best_rating1 = 0; // rating of st1 uint best_rating2 = 0; // rating of st2 - for (Station * const *st_iter = all_stations->Begin(); st_iter != all_stations->End(); ++st_iter) { - Station *st = *st_iter; - + for (Station *st : *all_stations) { /* Is the station reserved exclusively for somebody else? */ if (st->owner != OWNER_NONE && st->town->exclusive_counter > 0 && st->town->exclusivity != st->owner) continue; diff --git a/src/station_type.h b/src/station_type.h --- a/src/station_type.h +++ b/src/station_type.h @@ -12,9 +12,9 @@ #ifndef STATION_TYPE_H #define STATION_TYPE_H -#include "core/smallvec_type.hpp" #include "core/smallstack_type.hpp" #include "tilearea_type.h" +#include typedef uint16 StationID; typedef uint16 RoadStopID; @@ -90,8 +90,12 @@ enum CatchmentArea { static const uint MAX_LENGTH_STATION_NAME_CHARS = 32; ///< The maximum length of a station name in characters including '\0' +struct StationCompare { + bool operator() (const Station *lhs, const Station *rhs) const; +}; + /** List of stations */ -typedef SmallVector StationList; +typedef std::set StationList; /** * Structure contains cached list of stations nearby. The list