tron@2186: /* $Id$ */ tron@2186: richk@6719: /** @file waypoint.h */ richk@6719: truelight@1542: #ifndef WAYPOINT_H truelight@1542: #define WAYPOINT_H truelight@1542: matthijs@5216: #include "oldpool.h" tron@3239: #include "rail_map.h" truelight@1542: truelight@1542: struct Waypoint { peter1138@2670: TileIndex xy; ///< Tile of waypoint truelight@4389: WaypointID index; ///< Index of waypoint truelight@1542: Darkvater@3346: TownID 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) rubidium@4289: Date 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: matthijs@5216: DECLARE_OLD_POOL(Waypoint, Waypoint, 3, 8000) truelight@1542: truelight@4346: /** truelight@4346: * Check if a Waypoint really exists. richk@6719: * @param wp Waypoint to query richk@6719: * @return the validity of the waypoint truelight@4346: */ truelight@4346: static inline bool IsValidWaypoint(const Waypoint *wp) truelight@4346: { truelight@4346: return wp->xy != 0; truelight@4346: } truelight@4346: truelight@4389: static inline bool IsValidWaypointID(WaypointID index) truelight@4352: { truelight@4352: return index < GetWaypointPoolSize() && IsValidWaypoint(GetWaypoint(index)); truelight@4352: } truelight@4352: truelight@4390: void DestroyWaypoint(Waypoint *wp); truelight@4390: truelight@4390: static inline void DeleteWaypoint(Waypoint *wp) truelight@4390: { truelight@4390: DestroyWaypoint(wp); truelight@4390: wp->xy = 0; truelight@4390: } truelight@4390: tron@4984: #define FOR_ALL_WAYPOINTS_FROM(wp, start) for (wp = GetWaypoint(start); wp != NULL; wp = (wp->index + 1U < GetWaypointPoolSize()) ? GetWaypoint(wp->index + 1U) : NULL) if (IsValidWaypoint(wp)) truelight@1542: #define FOR_ALL_WAYPOINTS(wp) FOR_ALL_WAYPOINTS_FROM(wp, 0) 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)); rubidium@6508: return GetWaypoint(GetWaypointIndex(tile)); 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); rubidium@6573: void FixOldWaypoints(); rubidium@6573: void UpdateAllWaypointSigns(); rubidium@6573: void AfterLoadWaypoints(); truelight@1542: truelight@1542: #endif /* WAYPOINT_H */