Changeset - r10235:e8fb965b4a0f
[Not reviewed]
master
0 2 0
rubidium - 16 years ago 2008-10-14 12:07:14
rubidium@openttd.org
(svn r14463) -Fix [FS#2348]: small possible chance of desync due to sorting on pointer instead of by (station) index (PhilSophus)
2 files changed with 19 insertions and 1 deletions:
0 comments (0 inline, 0 general)
src/oldpool.h
Show inline comments
 
@@ -155,6 +155,23 @@ static void PoolCleanBlock(uint start_it
 
	}
 
}
 

	
 
/**
 
 * Template providing a predicate to allow STL containers of
 
 * pointers to pool items to be sorted by index.
 
 */
 
template <typename T>
 
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.
src/station_func.h
Show inline comments
 
@@ -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<Station*> StationSet;
 
typedef std::set<Station*, PoolItemIndexLess<Station> > StationSet;
 

	
 
StationSet FindStationsAroundIndustryTile(TileIndex tile, int w, int h);
 

	
0 comments (0 inline, 0 general)