diff options
author | truelight <truelight@openttd.org> | 2006-08-22 15:33:35 +0000 |
---|---|---|
committer | truelight <truelight@openttd.org> | 2006-08-22 15:33:35 +0000 |
commit | 0461d896123b918b492a3d16439bb46b041528cd (patch) | |
tree | 618708068f10739a382af83313db9c96b4744ef5 /waypoint.h | |
parent | 4c2abf1de53e28a5c3c6c6920efabc4653693c4c (diff) | |
download | openttd-0461d896123b918b492a3d16439bb46b041528cd.tar.xz |
(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.
Diffstat (limited to 'waypoint.h')
-rw-r--r-- | waypoint.h | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/waypoint.h b/waypoint.h index aa3cf8cf8..aac46518a 100644 --- a/waypoint.h +++ b/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) |