(svn r18110) -Codechange [FS#3316]: search for stations nearby only once per producer (instead of once pre produced cargo type) (fonsinchen)

This commit is contained in:
smatz
2009-11-15 21:06:13 +00:00
parent e41c2e128b
commit 47660b984b
7 changed files with 53 additions and 13 deletions

View File

@@ -13,6 +13,7 @@
#define STATION_TYPE_H
#include "core/enum_type.hpp"
#include "core/smallvec_type.hpp"
#include "tile_type.h"
typedef uint16 StationID;
@@ -115,4 +116,27 @@ struct TileArea {
uint8 h; ///< The height of the area
};
/** List of stations */
typedef SmallVector<Station *, 2> StationList;
/**
* Structure contains cached list of stations nearby. The list
* is created upon first call to GetStations()
*/
class StationFinder {
StationList stations; ///< List of stations nearby
TileIndex tile; ///< Northern tile of producer, INVALID_TILE when # stations is valid
int x_extent; ///< Width of producer
int y_extent; ///< Height of producer
public:
/**
* Constructs StationFinder
* @param t northern tile
* @param dx width of producer
* @param dy height of producer
*/
StationFinder(TileIndex t, int dx, int dy) : tile(t), x_extent(dx), y_extent(dy) {}
const StationList *GetStations();
};
#endif /* STATION_TYPE_H */