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 { peter1138@2670: TileIndex xy; ///< Tile of waypoint peter1138@2670: uint16 index; ///< Index of waypoint truelight@1542: peter1138@2670: uint16 town_index; ///< Town associated with the waypoint peter1138@2670: byte town_cn; ///< The Nth waypoint for this town (consecutive number) peter1138@2670: StringID string; ///< If this is zero (i.e. no custom name), town + town_cn is used for naming truelight@1542: peter1138@2670: ViewportSign sign; ///< Dimensions of sign (not saved) peter1138@2670: uint16 build_date; ///< Date of construction peter1138@2670: peter1138@2670: byte stat_id; ///< ID of waypoint within the waypoint class (not saved) peter1138@2670: uint32 grfid; ///< ID of GRF file peter1138@2670: byte localidx; ///< Index of station within GRF file peter1138@2670: peter1138@2670: byte deleted; ///< Delete counter. If greater than 0 then it is decremented until it reaches 0; the waypoint is then 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@2668: static inline bool IsRailWaypoint(TileIndex tile) truelight@1542: { truelight@2668: return (_m[tile].m5 & 0xFC) == 0xC4; truelight@1542: } truelight@1542: peter1138@2670: /** peter1138@2670: * Fetch a waypoint by tile peter1138@2670: * @param tile Tile of waypoint peter1138@2670: * @return Waypoint peter1138@2670: */ peter1138@2670: static inline Waypoint *GetWaypointByTile(TileIndex tile) peter1138@2670: { peter1138@2670: assert(IsTileType(tile, MP_RAILWAY) && IsRailWaypoint(tile)); peter1138@2670: return GetWaypoint(_m[tile].m2); peter1138@2670: } peter1138@2670: tron@1977: int32 RemoveTrainWaypoint(TileIndex tile, uint32 flags, bool justremove); tron@1977: Station *ComposeWaypointStation(TileIndex tile); tron@2116: void ShowRenameWaypointWindow(const Waypoint *cp); tron@2520: void DrawWaypointSprite(int x, int y, int image, RailType railtype); truelight@1542: void FixOldWaypoints(void); truelight@1542: void UpdateAllWaypointSigns(void); peter1138@2670: void UpdateAllWaypointCustomGraphics(void); truelight@1542: truelight@1542: #endif /* WAYPOINT_H */