Mercurial > hg > openttd
changeset 5835:60c031ec09c7 draft
(svn r8401) -Codechange: Make 'IsValidRoadStop' a method of RoadStop and rename it to 'IsValid'
-Codechange: While I'm at it, put 'RoadStop::AllocateRaw' into the protected section
author | celestar <celestar@openttd.org> |
---|---|
date | Thu, 25 Jan 2007 08:58:09 +0000 |
parents | f9e0c80cf037 |
children | 0b68d5a508a2 |
files | src/station.cpp src/station.h |
diffstat | 2 files changed, 10 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/src/station.cpp +++ b/src/station.cpp @@ -403,7 +403,7 @@ /* We don't use FOR_ALL here, because FOR_ALL skips invalid items. * TODO - This is just a temporary stage, this will be removed. */ for (rs = GetRoadStop(0); rs != NULL; rs = (rs->index + 1U < GetRoadStopPoolSize()) ? GetRoadStop(rs->index + 1U) : NULL) { - if (!IsValidRoadStop(rs)) { + if (!rs->IsValid()) { RoadStopID index = rs->index; memset(rs, 0, sizeof(*rs)); @@ -418,3 +418,9 @@ return NULL; } + +/** Determines whether a RoadStop is a valid (i.e. existing) one */ +bool RoadStop::IsValid() const +{ + return xy != INVALID_TILE; +}
--- a/src/station.h +++ b/src/station.h @@ -64,6 +64,8 @@ void *operator new (size_t size, int index); void operator delete(void *rs, int index); + bool IsValid() const; +protected: static RoadStop *AllocateRaw(void); } RoadStop; @@ -253,15 +255,7 @@ DECLARE_OLD_POOL(RoadStop, RoadStop, 5, 2000) -/** - * Check if a RaodStop really exists. - */ -static inline bool IsValidRoadStop(const RoadStop *rs) -{ - return rs->xy != INVALID_TILE; -} - -#define FOR_ALL_ROADSTOPS_FROM(rs, start) for (rs = GetRoadStop(start); rs != NULL; rs = (rs->index + 1U < GetRoadStopPoolSize()) ? GetRoadStop(rs->index + 1U) : NULL) if (IsValidRoadStop(rs)) +#define FOR_ALL_ROADSTOPS_FROM(rs, start) for (rs = GetRoadStop(start); rs != NULL; rs = (rs->index + 1U < GetRoadStopPoolSize()) ? GetRoadStop(rs->index + 1U) : NULL) if (rs->IsValid()) #define FOR_ALL_ROADSTOPS(rs) FOR_ALL_ROADSTOPS_FROM(rs, 0) /* End of stuff for ROADSTOPS */