diff options
author | celestar <celestar@openttd.org> | 2007-01-17 11:15:51 +0000 |
---|---|---|
committer | celestar <celestar@openttd.org> | 2007-01-17 11:15:51 +0000 |
commit | 8c547930686ae662b26dbe93362c05e6e4227ac1 (patch) | |
tree | 3335268e36d18ec8067bc2aac90872caadf1709a /src/station.h | |
parent | a973e457193b41afbfaa468be1c2fe22c484c845 (diff) | |
download | openttd-8c547930686ae662b26dbe93362c05e6e4227ac1.tar.xz |
(svn r8185) -Codechange: Equipped Roadstops with new/delete operators and gave them proper constructors/destructors (Thanks to KUDr for a nice interactive C++ lesson)
Diffstat (limited to 'src/station.h')
-rw-r--r-- | src/station.h | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/src/station.h b/src/station.h index b6cffe1d2..dc86f689f 100644 --- a/src/station.h +++ b/src/station.h @@ -53,6 +53,20 @@ typedef struct RoadStop { StationID station; struct RoadStop *next; struct RoadStop *prev; + + static const int cDebugCtorLevel = 3; + + RoadStop(TileIndex tile, StationID index); + ~RoadStop(); + + void *operator new (size_t size); + void operator delete(void *rs); + + /* For loading games */ + void *operator new (size_t size, int index); + void operator delete(void *rs, int index); + + static RoadStop *AllocateRaw( void ); } RoadStop; typedef struct StationSpecList { @@ -248,14 +262,6 @@ static inline bool IsValidRoadStop(const RoadStop *rs) return rs->used; } -void DestroyRoadStop(RoadStop* rs); - -static inline void DeleteRoadStop(RoadStop *rs) -{ - DestroyRoadStop(rs); - rs->used = false; -} - #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) |