# HG changeset patch # User rubidium # Date 1223986034 0 # Node ID 531716190738d137f51797f8bfd8ee8dfd7e14c8 # Parent 84fbb9da68987772b928c8764311cdfe681e3f51 (svn r14463) -Fix [FS#2348]: small possible chance of desync due to sorting on pointer instead of by (station) index (PhilSophus) diff -r 84fbb9da6898 -r 531716190738 src/oldpool.h --- a/src/oldpool.h Mon Oct 13 03:40:48 2008 +0000 +++ b/src/oldpool.h Tue Oct 14 12:07:14 2008 +0000 @@ -155,6 +155,23 @@ } } +/** + * Template providing a predicate to allow STL containers of + * pointers to pool items to be sorted by index. + */ +template +struct PoolItemIndexLess { + /** + * The actual comparator. + * @param lhs the left hand side of the comparison. + * @param rhs the right hand side of the comparison. + * @return true if lhs' index is less than rhs' index. + */ + bool operator()(const T *lhs, const T *rhs) const + { + return lhs->index < rhs->index; + } +}; /** * Generalization for all pool items that are saved in the savegame. diff -r 84fbb9da6898 -r 531716190738 src/station_func.h --- a/src/station_func.h Mon Oct 13 03:40:48 2008 +0000 +++ b/src/station_func.h Tue Oct 14 12:07:14 2008 +0000 @@ -7,6 +7,7 @@ #include "station_type.h" #include "sprite.h" +#include "oldpool.h" #include "rail_type.h" #include "road_type.h" #include "tile_type.h" @@ -17,7 +18,7 @@ void ModifyStationRatingAround(TileIndex tile, Owner owner, int amount, uint radius); /** A set of stations (\c const \c Station* ) */ -typedef std::set StationSet; +typedef std::set > StationSet; StationSet FindStationsAroundIndustryTile(TileIndex tile, int w, int h);