equal
deleted
inserted
replaced
22 byte localidx; ///< Index of station within GRF file |
22 byte localidx; ///< Index of station within GRF file |
23 |
23 |
24 byte deleted; ///< Delete counter. If greater than 0 then it is decremented until it reaches 0; the waypoint is then is deleted. |
24 byte deleted; ///< Delete counter. If greater than 0 then it is decremented until it reaches 0; the waypoint is then is deleted. |
25 }; |
25 }; |
26 |
26 |
27 extern MemoryPool _waypoint_pool; |
27 DECLARE_POOL(Waypoint, Waypoint, 3, 8000) |
28 |
|
29 /** |
|
30 * Get the pointer to the waypoint with index 'index' |
|
31 */ |
|
32 static inline Waypoint *GetWaypoint(WaypointID index) |
|
33 { |
|
34 return (Waypoint*)GetItemFromPool(&_waypoint_pool, index); |
|
35 } |
|
36 |
|
37 /** |
|
38 * Get the current size of the WaypointPool |
|
39 */ |
|
40 static inline uint16 GetWaypointPoolSize(void) |
|
41 { |
|
42 return _waypoint_pool.total_items; |
|
43 } |
|
44 |
28 |
45 /** |
29 /** |
46 * Check if a Waypoint really exists. |
30 * Check if a Waypoint really exists. |
47 */ |
31 */ |
48 static inline bool IsValidWaypoint(const Waypoint *wp) |
32 static inline bool IsValidWaypoint(const Waypoint *wp) |
61 { |
45 { |
62 DestroyWaypoint(wp); |
46 DestroyWaypoint(wp); |
63 wp->xy = 0; |
47 wp->xy = 0; |
64 } |
48 } |
65 |
49 |
66 #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)) |
50 #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)) |
67 #define FOR_ALL_WAYPOINTS(wp) FOR_ALL_WAYPOINTS_FROM(wp, 0) |
51 #define FOR_ALL_WAYPOINTS(wp) FOR_ALL_WAYPOINTS_FROM(wp, 0) |
68 |
52 |
69 |
53 |
70 /** |
54 /** |
71 * Fetch a waypoint by tile |
55 * Fetch a waypoint by tile |