forked from mirror/OpenTTD
(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:
@@ -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 */
|
||||
|
Reference in New Issue
Block a user