From cd74706c5409ab6c912618be25dfa6dcea7bbaf5 Mon Sep 17 00:00:00 2001 From: KUDr Date: Sun, 14 Jan 2007 23:02:12 +0000 Subject: (svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods. --- src/station.h | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) (limited to 'src/station.h') diff --git a/src/station.h b/src/station.h index 73486bffe..e2ec2e8a7 100644 --- a/src/station.h +++ b/src/station.h @@ -59,6 +59,29 @@ typedef struct StationSpecList { uint8 localidx; /// Station ID within GRF of station } StationSpecList; +/** 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 PtInRectXY(int x, int y) const; + bool IsEmpty() const; + bool BeforeAddTile(TileIndex tile, StationRectMode mode); + bool BeforeAddRect(TileIndex tile, int w, int h, StationRectMode mode); + bool AfterRemoveTile(Station *st, TileIndex tile); + bool AfterRemoveRect(Station *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); +}; + struct Station { TileIndex xy; RoadStop *bus_stops; @@ -107,9 +130,9 @@ struct Station { byte bus_stop_status_obsolete; byte blocked_months_obsolete; - Rect rect; ///< Station spread out rectangle (not saved) maintained by StationRect_xxx() functions + StationRect rect; ///< Station spread out rectangle (not saved) maintained by StationRect_xxx() functions - static const int cDebugCtorLevel = 1; + static const int cDebugCtorLevel = 3; Station(TileIndex tile = 0); ~Station(); -- cgit v1.2.3-54-g00ecf