summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/industry_cmd.cpp4
-rw-r--r--src/newgrf_house.cpp3
-rw-r--r--src/script/api/script_industry.cpp2
-rw-r--r--src/station.cpp5
-rw-r--r--src/station_cmd.cpp6
-rw-r--r--src/station_type.h8
6 files changed, 17 insertions, 11 deletions
diff --git a/src/industry_cmd.cpp b/src/industry_cmd.cpp
index ad12e5450..cc05893fb 100644
--- a/src/industry_cmd.cpp
+++ b/src/industry_cmd.cpp
@@ -2432,7 +2432,7 @@ static int WhoCanServiceIndustry(Industry *ind)
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(Industry *ind)
/* 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
index 314f02b3d..e6abf0962 100644
--- a/src/newgrf_house.cpp
+++ b/src/newgrf_house.cpp
@@ -350,8 +350,7 @@ static uint32 GetDistanceFromNearbyHouse(uint8 parameter, TileIndex tile, HouseI
/* 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
index c536ec559..b9025307b 100644
--- 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
index dc50b4f10..04c5a66bd 100644
--- 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
index a9460e562..5218a75e9 100644
--- a/src/station_cmd.cpp
+++ b/src/station_cmd.cpp
@@ -3839,7 +3839,7 @@ void FindStationsAroundTiles(const TileArea &location, StationList *stations)
/* 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, uint amount, SourceType source_type, Sourc
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
index 495e95a08..42d64fcf8 100644
--- 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 <set>
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<Station *, 2> StationList;
+typedef std::set<Station *, StationCompare> StationList;
/**
* Structure contains cached list of stations nearby. The list