2005-07-24 14:12:37 +00:00
|
|
|
/* $Id$ */
|
|
|
|
|
2005-03-24 17:03:37 +00:00
|
|
|
#ifndef WAYPOINT_H
|
|
|
|
#define WAYPOINT_H
|
|
|
|
|
2006-12-03 17:27:43 +00:00
|
|
|
#include "oldpool.h"
|
2006-03-17 07:02:34 +00:00
|
|
|
#include "rail_map.h"
|
2005-03-24 17:03:37 +00:00
|
|
|
|
|
|
|
struct Waypoint {
|
2005-11-16 22:20:15 +00:00
|
|
|
TileIndex xy; ///< Tile of waypoint
|
2006-08-26 16:34:03 +00:00
|
|
|
WaypointID index; ///< Index of waypoint
|
2005-11-16 22:20:15 +00:00
|
|
|
|
2006-03-26 22:41:56 +00:00
|
|
|
TownID town_index; ///< Town associated with the waypoint
|
2005-11-16 22:20:15 +00:00
|
|
|
byte town_cn; ///< The Nth waypoint for this town (consecutive number)
|
|
|
|
StringID string; ///< If this is zero (i.e. no custom name), town + town_cn is used for naming
|
|
|
|
|
|
|
|
ViewportSign sign; ///< Dimensions of sign (not saved)
|
2006-08-15 16:55:40 +00:00
|
|
|
Date build_date; ///< Date of construction
|
2005-11-16 22:20:15 +00:00
|
|
|
|
|
|
|
byte stat_id; ///< ID of waypoint within the waypoint class (not saved)
|
|
|
|
uint32 grfid; ///< ID of GRF file
|
|
|
|
byte localidx; ///< Index of station within GRF file
|
|
|
|
|
|
|
|
byte deleted; ///< Delete counter. If greater than 0 then it is decremented until it reaches 0; the waypoint is then is deleted.
|
2005-03-24 17:03:37 +00:00
|
|
|
};
|
|
|
|
|
2006-12-03 17:27:43 +00:00
|
|
|
DECLARE_OLD_POOL(Waypoint, Waypoint, 3, 8000)
|
2005-03-24 17:03:37 +00:00
|
|
|
|
2006-08-22 15:33:35 +00:00
|
|
|
/**
|
|
|
|
* Check if a Waypoint really exists.
|
|
|
|
*/
|
|
|
|
static inline bool IsValidWaypoint(const Waypoint *wp)
|
|
|
|
{
|
|
|
|
return wp->xy != 0;
|
|
|
|
}
|
|
|
|
|
2006-08-26 16:34:03 +00:00
|
|
|
static inline bool IsValidWaypointID(WaypointID index)
|
2006-08-22 18:15:17 +00:00
|
|
|
{
|
|
|
|
return index < GetWaypointPoolSize() && IsValidWaypoint(GetWaypoint(index));
|
|
|
|
}
|
|
|
|
|
2006-08-26 16:46:32 +00:00
|
|
|
void DestroyWaypoint(Waypoint *wp);
|
|
|
|
|
|
|
|
static inline void DeleteWaypoint(Waypoint *wp)
|
|
|
|
{
|
|
|
|
DestroyWaypoint(wp);
|
|
|
|
wp->xy = 0;
|
|
|
|
}
|
|
|
|
|
2006-10-28 11:59:10 +00:00
|
|
|
#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))
|
2005-03-24 17:03:37 +00:00
|
|
|
#define FOR_ALL_WAYPOINTS(wp) FOR_ALL_WAYPOINTS_FROM(wp, 0)
|
|
|
|
|
|
|
|
|
2005-11-16 22:20:15 +00:00
|
|
|
/**
|
|
|
|
* Fetch a waypoint by tile
|
|
|
|
* @param tile Tile of waypoint
|
|
|
|
* @return Waypoint
|
|
|
|
*/
|
|
|
|
static inline Waypoint *GetWaypointByTile(TileIndex tile)
|
|
|
|
{
|
|
|
|
assert(IsTileType(tile, MP_RAILWAY) && IsRailWaypoint(tile));
|
|
|
|
return GetWaypoint(_m[tile].m2);
|
|
|
|
}
|
|
|
|
|
2005-06-24 12:38:35 +00:00
|
|
|
int32 RemoveTrainWaypoint(TileIndex tile, uint32 flags, bool justremove);
|
|
|
|
Station *ComposeWaypointStation(TileIndex tile);
|
2005-07-17 20:14:58 +00:00
|
|
|
void ShowRenameWaypointWindow(const Waypoint *cp);
|
2005-10-16 09:13:04 +00:00
|
|
|
void DrawWaypointSprite(int x, int y, int image, RailType railtype);
|
2005-03-24 17:03:37 +00:00
|
|
|
void FixOldWaypoints(void);
|
|
|
|
void UpdateAllWaypointSigns(void);
|
2005-11-16 22:20:15 +00:00
|
|
|
void UpdateAllWaypointCustomGraphics(void);
|
2005-03-24 17:03:37 +00:00
|
|
|
|
|
|
|
#endif /* WAYPOINT_H */
|