summaryrefslogtreecommitdiff
path: root/src/station_type.h
diff options
context:
space:
mode:
authorsmatz <smatz@openttd.org>2009-11-15 21:06:13 +0000
committersmatz <smatz@openttd.org>2009-11-15 21:06:13 +0000
commit47660b984b3c2eb80ac41e265b4cc9399300f0c2 (patch)
treec1e81a6e2e338a84bf92264e3fd2bf9a8cdcb2ca /src/station_type.h
parente41c2e128bb8177613d664eddee9f7396d6ae842 (diff)
downloadopenttd-47660b984b3c2eb80ac41e265b4cc9399300f0c2.tar.xz
(svn r18110) -Codechange [FS#3316]: search for stations nearby only once per producer (instead of once pre produced cargo type) (fonsinchen)
Diffstat (limited to 'src/station_type.h')
-rw-r--r--src/station_type.h24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/station_type.h b/src/station_type.h
index 5f827fffc..2784f123b 100644
--- a/src/station_type.h
+++ b/src/station_type.h
@@ -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 */