tron@2186: /* $Id$ */ tron@2186: rubidium@9111: /** @file waypoint.h Base of waypoints. */ belugas@6432: truelight@1542: #ifndef WAYPOINT_H truelight@1542: #define WAYPOINT_H truelight@1542: rubidium@8775: #include "waypoint_type.h" matthijs@5216: #include "oldpool.h" tron@3239: #include "rail_map.h" rubidium@8237: #include "command_type.h" rubidium@8769: #include "station_type.h" rubidium@8962: #include "town_type.h" rubidium@9129: #include "viewport_type.h" truelight@1542: rubidium@7381: DECLARE_OLD_POOL(Waypoint, Waypoint, 3, 8000) rubidium@7381: rubidium@7381: struct Waypoint : PoolItem { peter1138@2670: TileIndex xy; ///< Tile of waypoint truelight@1542: Darkvater@3346: TownID town_index; ///< Town associated with the waypoint smatz@8579: uint16 town_cn; ///< The Nth waypoint for this town (consecutive number) peter1138@8258: StringID string; ///< C000-C03F have special meaning in old games peter1138@8258: char *name; ///< Custom name. If not set, 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 rubidium@10207: OwnerByte owner; ///< Whom this waypoint belongs to 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@7381: Waypoint(TileIndex tile = 0); rubidium@7381: ~Waypoint(); rubidium@7381: rubidium@7496: inline bool IsValid() const { return this->xy != 0; } rubidium@7381: }; truelight@4346: truelight@4389: static inline bool IsValidWaypointID(WaypointID index) truelight@4352: { rubidium@7381: return index < GetWaypointPoolSize() && GetWaypoint(index)->IsValid(); truelight@4352: } truelight@4352: rubidium@7381: #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: { smatz@10099: assert(IsRailWaypointTile(tile)); rubidium@6182: return GetWaypoint(GetWaypointIndex(tile)); peter1138@2670: } peter1138@2670: rubidium@6943: CommandCost RemoveTrainWaypoint(TileIndex tile, uint32 flags, bool justremove); tron@1977: Station *ComposeWaypointStation(TileIndex tile); belugas@9949: void ShowWaypointWindow(const Waypoint *wp); rubidium@7318: void DrawWaypointSprite(int x, int y, int stat_id, RailType railtype); rubidium@6247: void FixOldWaypoints(); rubidium@6247: void UpdateAllWaypointSigns(); rubidium@6247: void AfterLoadWaypoints(); truelight@1542: truelight@1542: #endif /* WAYPOINT_H */