2005-07-24 14:12:37 +00:00
|
|
|
/* $Id$ */
|
|
|
|
|
2005-03-24 17:03:37 +00:00
|
|
|
#ifndef WAYPOINT_H
|
|
|
|
#define WAYPOINT_H
|
|
|
|
|
|
|
|
#include "pool.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-03-26 22:55:27 +00:00
|
|
|
StationID 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
|
|
|
};
|
|
|
|
|
|
|
|
extern MemoryPool _waypoint_pool;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the pointer to the waypoint with index 'index'
|
|
|
|
*/
|
|
|
|
static inline Waypoint *GetWaypoint(uint index)
|
|
|
|
{
|
|
|
|
return (Waypoint*)GetItemFromPool(&_waypoint_pool, index);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the current size of the WaypointPool
|
|
|
|
*/
|
|
|
|
static inline uint16 GetWaypointPoolSize(void)
|
|
|
|
{
|
|
|
|
return _waypoint_pool.total_items;
|
|
|
|
}
|
|
|
|
|
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-22 18:15:17 +00:00
|
|
|
static inline bool IsValidWaypointID(uint index)
|
|
|
|
{
|
|
|
|
return index < GetWaypointPoolSize() && IsValidWaypoint(GetWaypoint(index));
|
|
|
|
}
|
|
|
|
|
2006-08-22 15:33:35 +00:00
|
|
|
#define FOR_ALL_WAYPOINTS_FROM(wp, start) for (wp = GetWaypoint(start); wp != NULL; wp = (wp->index + 1 < GetWaypointPoolSize()) ? GetWaypoint(wp->index + 1) : 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 */
|