(svn r6047) -Codechange: FOR_ALL now _only_ loops valid items, and skips invalid ones
-Codechange: use IsValidXXX where ever possible Note: both changes to prepare for new pool system, which needs those changes. For every pool there are 2 ugly lines, which will be removed when done implementing new pool system. Based on FS#13 by blathijs, partly implemented.
This commit is contained in:
10
waypoint.h
10
waypoint.h
@@ -47,7 +47,15 @@ static inline bool IsWaypointIndex(uint index)
|
||||
return index < GetWaypointPoolSize();
|
||||
}
|
||||
|
||||
#define FOR_ALL_WAYPOINTS_FROM(wp, start) for (wp = GetWaypoint(start); wp != NULL; wp = (wp->index + 1 < GetWaypointPoolSize()) ? GetWaypoint(wp->index + 1) : NULL)
|
||||
/**
|
||||
* Check if a Waypoint really exists.
|
||||
*/
|
||||
static inline bool IsValidWaypoint(const Waypoint *wp)
|
||||
{
|
||||
return wp->xy != 0;
|
||||
}
|
||||
|
||||
#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))
|
||||
#define FOR_ALL_WAYPOINTS(wp) FOR_ALL_WAYPOINTS_FROM(wp, 0)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user