waypoint.h
changeset 1542 62a03537ad0b
child 1718 96d76767ea93
equal deleted inserted replaced
1541:88d76661a786 1542:62a03537ad0b
       
     1 #ifndef WAYPOINT_H
       
     2 #define WAYPOINT_H
       
     3 
       
     4 #include "pool.h"
       
     5 
       
     6 struct Waypoint {
       
     7 	TileIndex xy;
       
     8 	uint16 index;
       
     9 
       
    10 	uint16 town_index;
       
    11 	byte town_cn;          // The Nth waypoint for this town (consecutive number)
       
    12 	StringID string;       // If this is zero, town + town_cn is used for naming
       
    13 
       
    14 	ViewportSign sign;
       
    15 	uint16 build_date;
       
    16 	byte stat_id;
       
    17 	byte deleted;          // this is a delete counter. when it reaches 0, the waypoint struct is deleted.
       
    18 };
       
    19 
       
    20 enum {
       
    21 	RAIL_TYPE_WAYPOINT = 0xC4,
       
    22 	RAIL_WAYPOINT_TRACK_MASK = 1,
       
    23 };
       
    24 
       
    25 extern MemoryPool _waypoint_pool;
       
    26 
       
    27 /**
       
    28  * Get the pointer to the waypoint with index 'index'
       
    29  */
       
    30 static inline Waypoint *GetWaypoint(uint index)
       
    31 {
       
    32 	return (Waypoint*)GetItemFromPool(&_waypoint_pool, index);
       
    33 }
       
    34 
       
    35 /**
       
    36  * Get the current size of the WaypointPool
       
    37  */
       
    38 static inline uint16 GetWaypointPoolSize(void)
       
    39 {
       
    40 	return _waypoint_pool.total_items;
       
    41 }
       
    42 
       
    43 #define FOR_ALL_WAYPOINTS_FROM(wp, start) for (wp = GetWaypoint(start); wp != NULL; wp = (wp->index + 1 < GetWaypointPoolSize()) ? GetWaypoint(wp->index + 1) : NULL)
       
    44 #define FOR_ALL_WAYPOINTS(wp) FOR_ALL_WAYPOINTS_FROM(wp, 0)
       
    45 
       
    46 static inline bool IsRailWaypoint(byte m5)
       
    47 {
       
    48 	return (m5 & 0xFC) == 0xC4;
       
    49 }
       
    50 
       
    51 int32 RemoveTrainWaypoint(uint tile, uint32 flags, bool justremove);
       
    52 Station *ComposeWaypointStation(uint tile);
       
    53 Waypoint *GetWaypointByTile(TileIndex tile);
       
    54 void ShowRenameWaypointWindow(Waypoint *cp);
       
    55 void DrawWaypointSprite(int x, int y, int image, int railtype);
       
    56 void UpdateWaypointSign(Waypoint *cp);
       
    57 void FixOldWaypoints(void);
       
    58 void UpdateAllWaypointSigns(void);
       
    59 
       
    60 #endif /* WAYPOINT_H */