tron@2186: /* $Id$ */ tron@2186: truelight@1542: #ifndef WAYPOINT_H truelight@1542: #define WAYPOINT_H truelight@1542: truelight@1542: #include "pool.h" truelight@1542: truelight@1542: struct Waypoint { truelight@1542: TileIndex xy; truelight@1542: uint16 index; truelight@1542: truelight@1542: uint16 town_index; truelight@1542: byte town_cn; // The Nth waypoint for this town (consecutive number) truelight@1542: StringID string; // If this is zero, town + town_cn is used for naming truelight@1542: truelight@1542: ViewportSign sign; truelight@1542: uint16 build_date; truelight@1542: byte stat_id; truelight@1542: byte deleted; // this is a delete counter. when it reaches 0, the waypoint struct is deleted. truelight@1542: }; truelight@1542: truelight@1542: enum { truelight@1542: RAIL_TYPE_WAYPOINT = 0xC4, truelight@1542: RAIL_WAYPOINT_TRACK_MASK = 1, truelight@1542: }; truelight@1542: truelight@1542: extern MemoryPool _waypoint_pool; truelight@1542: truelight@1542: /** truelight@1542: * Get the pointer to the waypoint with index 'index' truelight@1542: */ truelight@1542: static inline Waypoint *GetWaypoint(uint index) truelight@1542: { truelight@1542: return (Waypoint*)GetItemFromPool(&_waypoint_pool, index); truelight@1542: } truelight@1542: truelight@1542: /** truelight@1542: * Get the current size of the WaypointPool truelight@1542: */ truelight@1542: static inline uint16 GetWaypointPoolSize(void) truelight@1542: { truelight@1542: return _waypoint_pool.total_items; truelight@1542: } truelight@1542: tron@1718: static inline bool IsWaypointIndex(uint index) tron@1718: { tron@1718: return index < GetWaypointPoolSize(); tron@1718: } tron@1718: truelight@1542: #define FOR_ALL_WAYPOINTS_FROM(wp, start) for (wp = GetWaypoint(start); wp != NULL; wp = (wp->index + 1 < GetWaypointPoolSize()) ? GetWaypoint(wp->index + 1) : NULL) truelight@1542: #define FOR_ALL_WAYPOINTS(wp) FOR_ALL_WAYPOINTS_FROM(wp, 0) truelight@1542: truelight@1542: static inline bool IsRailWaypoint(byte m5) truelight@1542: { truelight@1542: return (m5 & 0xFC) == 0xC4; truelight@1542: } truelight@1542: tron@1977: int32 RemoveTrainWaypoint(TileIndex tile, uint32 flags, bool justremove); tron@1977: Station *ComposeWaypointStation(TileIndex tile); truelight@1542: Waypoint *GetWaypointByTile(TileIndex tile); tron@2116: void ShowRenameWaypointWindow(const Waypoint *cp); tron@2520: void DrawWaypointSprite(int x, int y, int image, RailType railtype); truelight@1542: void UpdateWaypointSign(Waypoint *cp); truelight@1542: void FixOldWaypoints(void); truelight@1542: void UpdateAllWaypointSigns(void); truelight@1542: truelight@1542: #endif /* WAYPOINT_H */