mirror of https://github.com/OpenTTD/OpenTTD
(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 sectionrelease/0.6
parent
e85cd647e1
commit
600cb8a314
|
@ -403,7 +403,7 @@ RoadStop *RoadStop::AllocateRaw( void )
|
||||||
/* We don't use FOR_ALL here, because FOR_ALL skips invalid items.
|
/* We don't use FOR_ALL here, because FOR_ALL skips invalid items.
|
||||||
* TODO - This is just a temporary stage, this will be removed. */
|
* 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) {
|
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;
|
RoadStopID index = rs->index;
|
||||||
|
|
||||||
memset(rs, 0, sizeof(*rs));
|
memset(rs, 0, sizeof(*rs));
|
||||||
|
@ -418,3 +418,9 @@ RoadStop *RoadStop::AllocateRaw( void )
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Determines whether a RoadStop is a valid (i.e. existing) one */
|
||||||
|
bool RoadStop::IsValid() const
|
||||||
|
{
|
||||||
|
return xy != INVALID_TILE;
|
||||||
|
}
|
||||||
|
|
|
@ -64,6 +64,8 @@ typedef struct RoadStop {
|
||||||
void *operator new (size_t size, int index);
|
void *operator new (size_t size, int index);
|
||||||
void operator delete(void *rs, int index);
|
void operator delete(void *rs, int index);
|
||||||
|
|
||||||
|
bool IsValid() const;
|
||||||
|
protected:
|
||||||
static RoadStop *AllocateRaw(void);
|
static RoadStop *AllocateRaw(void);
|
||||||
} RoadStop;
|
} RoadStop;
|
||||||
|
|
||||||
|
@ -253,15 +255,7 @@ static inline bool IsValidStationID(StationID index)
|
||||||
|
|
||||||
DECLARE_OLD_POOL(RoadStop, RoadStop, 5, 2000)
|
DECLARE_OLD_POOL(RoadStop, RoadStop, 5, 2000)
|
||||||
|
|
||||||
/**
|
#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())
|
||||||
* 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(rs) FOR_ALL_ROADSTOPS_FROM(rs, 0)
|
#define FOR_ALL_ROADSTOPS(rs) FOR_ALL_ROADSTOPS_FROM(rs, 0)
|
||||||
|
|
||||||
/* End of stuff for ROADSTOPS */
|
/* End of stuff for ROADSTOPS */
|
||||||
|
|
Loading…
Reference in New Issue