tron@2186: /* $Id$ */ tron@2186: belugas@6928: /** @file waypoint.h */ belugas@6928: 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: rubidium@7877: struct Waypoint; rubidium@7877: DECLARE_OLD_POOL(Waypoint, Waypoint, 3, 8000) rubidium@7877: rubidium@7877: struct Waypoint : PoolItem { peter1138@2670: TileIndex xy; ///< Tile 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: rubidium@7877: Waypoint(TileIndex tile = 0); rubidium@7877: ~Waypoint(); rubidium@7877: rubidium@7877: void QuickFree(); rubidium@7877: rubidium@7877: bool IsValid() const; rubidium@7877: }; truelight@4346: truelight@4389: static inline bool IsValidWaypointID(WaypointID index) truelight@4352: { rubidium@7877: return index < GetWaypointPoolSize() && GetWaypoint(index)->IsValid(); truelight@4352: } truelight@4352: truelight@4390: static inline void DeleteWaypoint(Waypoint *wp) truelight@4390: { rubidium@7877: wp->~Waypoint(); truelight@4390: } truelight@4390: rubidium@7877: #define FOR_ALL_WAYPOINTS_FROM(wp, start) for (wp = GetWaypoint(start); wp != NULL; wp = (wp->index + 1U < GetWaypointPoolSize()) ? GetWaypoint(wp->index + 1U) : NULL) if (wp->IsValid()) 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: rubidium@7439: CommandCost RemoveTrainWaypoint(TileIndex tile, uint32 flags, bool justremove); tron@1977: Station *ComposeWaypointStation(TileIndex tile); tron@2116: void ShowRenameWaypointWindow(const Waypoint *cp); rubidium@7814: void DrawWaypointSprite(int x, int y, int stat_id, RailType railtype); rubidium@6573: void FixOldWaypoints(); rubidium@6573: void UpdateAllWaypointSigns(); rubidium@6573: void AfterLoadWaypoints(); truelight@1542: truelight@1542: #endif /* WAYPOINT_H */