summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2009-01-13 18:18:53 +0000
committerpeter1138 <peter1138@openttd.org>2009-01-13 18:18:53 +0000
commit02bda12599ced659e5e3ff9404ff21f0ca718cd1 (patch)
treeae7816db55022acd80a77f5e646ba906e2ee9762
parente1f64922c5acb3f2173108ca81b656266bb8b651 (diff)
downloadopenttd-02bda12599ced659e5e3ff9404ff21f0ca718cd1.tar.xz
(svn r15067) -Fix [FS#2531]: Possible compiler bug, alleviated by using SmallVector instead of using std::set. SmallVector does everything needed anyway.
-rw-r--r--src/ai/api/ai_industry.cpp2
-rw-r--r--src/industry_cmd.cpp6
-rw-r--r--src/station_cmd.cpp12
-rw-r--r--src/station_func.h8
4 files changed, 13 insertions, 15 deletions
diff --git a/src/ai/api/ai_industry.cpp b/src/ai/api/ai_industry.cpp
index 64687af51..9a09d5ecd 100644
--- a/src/ai/api/ai_industry.cpp
+++ b/src/ai/api/ai_industry.cpp
@@ -123,7 +123,7 @@
if (!IsValidIndustry(industry_id)) return -1;
Industry *ind = ::GetIndustry(industry_id);
- return (int32)::FindStationsAroundTiles(ind->xy, ind->width, ind->height).size();
+ return (int32)::FindStationsAroundTiles(ind->xy, ind->width, ind->height).Length();
}
/* static */ int32 AIIndustry::GetDistanceManhattanToTile(IndustryID industry_id, TileIndex tile)
diff --git a/src/industry_cmd.cpp b/src/industry_cmd.cpp
index e752976fe..5fd794275 100644
--- a/src/industry_cmd.cpp
+++ b/src/industry_cmd.cpp
@@ -1992,9 +1992,9 @@ static void CanCargoServiceIndustry(CargoID cargo, Industry *ind, bool *c_accept
int WhoCanServiceIndustry(Industry *ind)
{
/* Find all stations within reach of the industry */
- StationSet stations = FindStationsAroundTiles(ind->xy, ind->width, ind->height);
+ StationList stations = FindStationsAroundTiles(ind->xy, ind->width, ind->height);
- if (stations.size() == 0) return 0; // No stations found at all => nobody services
+ if (stations.Length() == 0) return 0; // No stations found at all => nobody services
const Vehicle *v;
int result = 0;
@@ -2030,7 +2030,7 @@ 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.find(st) != stations.end()) {
+ if (stations.Contains(st)) {
if (v->owner == _local_company) return 2; // Company services industry
result = 1; // Competitor services industry
}
diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp
index 17c1c9aac..9c3529390 100644
--- a/src/station_cmd.cpp
+++ b/src/station_cmd.cpp
@@ -2940,9 +2940,9 @@ CommandCost CmdRenameStation(TileIndex tile, uint32 flags, uint32 p1, uint32 p2,
*
* @return: Set of found stations
*/
-StationSet FindStationsAroundTiles(TileIndex tile, int w_prod, int h_prod)
+StationList FindStationsAroundTiles(TileIndex tile, int w_prod, int h_prod)
{
- StationSet station_set;
+ StationList stations;
/* area to search = producer plus station catchment radius */
int max_rad = (_settings_game.station.modified_catchment ? MAX_CATCHMENT : CA_UNMODIFIED);
@@ -2989,11 +2989,11 @@ StationSet FindStationsAroundTiles(TileIndex tile, int w_prod, int h_prod)
/* Insert the station in the set. This will fail if it has
* already been added.
*/
- station_set.insert(st);
+ stations.Include(st);
END_TILE_LOOP(cur_tile, w, h, tile - TileDiffXY(max_rad, max_rad))
- return station_set;
+ return stations;
}
uint MoveGoodsToStation(TileIndex tile, int w, int h, CargoID type, uint amount)
@@ -3003,8 +3003,8 @@ uint MoveGoodsToStation(TileIndex tile, int w, int h, CargoID type, uint amount)
uint best_rating1 = 0; // rating of st1
uint best_rating2 = 0; // rating of st2
- StationSet all_stations = FindStationsAroundTiles(tile, w, h);
- for (StationSet::iterator st_iter = all_stations.begin(); st_iter != all_stations.end(); ++st_iter) {
+ StationList all_stations = FindStationsAroundTiles(tile, w, h);
+ for (Station **st_iter = all_stations.Begin(); st_iter != all_stations.End(); ++st_iter) {
Station *st = *st_iter;
/* Is the station reserved exclusively for somebody else? */
diff --git a/src/station_func.h b/src/station_func.h
index 4bcf3d8eb..d65f0ff07 100644
--- a/src/station_func.h
+++ b/src/station_func.h
@@ -13,14 +13,12 @@
#include "tile_type.h"
#include "cargo_type.h"
#include "vehicle_type.h"
-#include <set>
+#include "core/smallvec_type.hpp"
void ModifyStationRatingAround(TileIndex tile, Owner owner, int amount, uint radius);
-/** A set of stations (\c const \c Station* ) */
-typedef std::set<Station*, PoolItemIndexLess<Station> > StationSet;
-
-StationSet FindStationsAroundTiles(TileIndex tile, int w_prod, int h_prod);
+typedef SmallVector<Station*, 1> StationList;
+StationList FindStationsAroundTiles(TileIndex tile, int w_prod, int h_prod);
void ShowStationViewWindow(StationID station);
void UpdateAllStationVirtCoord();