summaryrefslogtreecommitdiff
path: root/src/base_station_base.h
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2009-07-26 16:17:49 +0000
committerrubidium <rubidium@openttd.org>2009-07-26 16:17:49 +0000
commit2dd998ab06d0f79445bf96239da9944fa30b7578 (patch)
treed230b550010fe91e42a879808170d09958464f67 /src/base_station_base.h
parent0081bb9a960473bd1e4f4891416f401d1f50e5b8 (diff)
downloadopenttd-2dd998ab06d0f79445bf96239da9944fa30b7578.tar.xz
(svn r16962) -Codechange: more work towards multi tile waypoints
Diffstat (limited to 'src/base_station_base.h')
-rw-r--r--src/base_station_base.h37
1 files changed, 36 insertions, 1 deletions
diff --git a/src/base_station_base.h b/src/base_station_base.h
index 70146aa82..5f99adab8 100644
--- a/src/base_station_base.h
+++ b/src/base_station_base.h
@@ -35,6 +35,30 @@ struct TileArea {
uint8 h; ///< The height of the area
};
+
+/** StationRect - used to track station spread out rectangle - cheaper than scanning whole map */
+struct StationRect : public Rect {
+ enum StationRectMode
+ {
+ ADD_TEST = 0,
+ ADD_TRY,
+ ADD_FORCE
+ };
+
+ StationRect();
+ void MakeEmpty();
+ bool PtInExtendedRect(int x, int y, int distance = 0) const;
+ bool IsEmpty() const;
+ bool BeforeAddTile(TileIndex tile, StationRectMode mode);
+ bool BeforeAddRect(TileIndex tile, int w, int h, StationRectMode mode);
+ bool AfterRemoveTile(BaseStation *st, TileIndex tile);
+ bool AfterRemoveRect(BaseStation *st, TileIndex tile, int w, int h);
+
+ static bool ScanForStationTiles(StationID st_id, int left_a, int top_a, int right_a, int bottom_a);
+
+ StationRect& operator = (Rect src);
+};
+
/** Base class for all station-ish types */
struct BaseStation : StationPool::PoolItem<&_station_pool> {
TileIndex xy; ///< Base tile of the station
@@ -57,7 +81,18 @@ struct BaseStation : StationPool::PoolItem<&_station_pool> {
byte waiting_triggers; ///< Waiting triggers (NewGRF) for this station
uint8 cached_anim_triggers; ///< NOSAVE: Combined animation trigger bitmask, used to determine if trigger processing should happen.
- BaseStation(TileIndex tile) : xy(tile) { }
+ TileArea train_station; ///< Tile area the train 'station' part covers
+ StationRect rect; ///< NOSAVE: Station spread out rectangle maintained by StationRect::xxx() functions
+
+ /**
+ * Initialize the base station.
+ * @param tile The location of the station sign
+ */
+ BaseStation(TileIndex tile) :
+ xy(tile),
+ train_station(INVALID_TILE, 0, 0)
+ {
+ }
virtual ~BaseStation();