From 8b65342449c7d36ef166ec2e5dc37abe3cc67bdf Mon Sep 17 00:00:00 2001 From: KUDr Date: Sun, 14 Jan 2007 19:18:50 +0000 Subject: (svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp). --- src/station.h | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) (limited to 'src/station.h') diff --git a/src/station.h b/src/station.h index a253b979f..6c624f88b 100644 --- a/src/station.h +++ b/src/station.h @@ -3,6 +3,7 @@ #ifndef STATION_H #define STATION_H +#include #include "player.h" #include "oldpool.h" #include "sprite.h" @@ -97,6 +98,26 @@ struct Station { byte blocked_months_obsolete; Rect rect; ///< Station spread out rectangle (not saved) maintained by StationRect_xxx() functions + + static const int cDebugCtorLevel = 1; + + Station(TileIndex tile = 0); + ~Station(); + + /* normal new/delete operators. Used when building/removing station */ + void* operator new (size_t size); + void operator delete(void *p); + + /* new/delete operators accepting station index. Used when loading station from savegame. */ + void* operator new (size_t size, int st_idx); + void operator delete(void *p, int st_idx); + + void MarkDirty() const; + void MarkTilesDirty() const; + bool TileBelongsToRailStation(TileIndex tile) const; + +protected: + static Station *AllocateRaw(void); }; enum { @@ -176,14 +197,6 @@ static inline bool IsValidStationID(StationID index) return index < GetStationPoolSize() && IsValidStation(GetStation(index)); } -void DestroyStation(Station *st); - -static inline void DeleteStation(Station *st) -{ - DestroyStation(st); - st->xy = 0; -} - #define FOR_ALL_STATIONS_FROM(st, start) for (st = GetStation(start); st != NULL; st = (st->index + 1U < GetStationPoolSize()) ? GetStation(st->index + 1U) : NULL) if (IsValidStation(st)) #define FOR_ALL_STATIONS(st) FOR_ALL_STATIONS_FROM(st, 0) @@ -219,7 +232,6 @@ void GetProductionAroundTiles(AcceptedCargo produced, TileIndex tile, int w, int void GetAcceptanceAroundTiles(AcceptedCargo accepts, TileIndex tile, int w, int h, int rad); uint GetStationPlatforms(const Station *st, TileIndex tile); uint GetPlatformLength(TileIndex tile, DiagDirection dir); -void MarkStationTilesDirty(const Station *st); const DrawTileSprites *GetStationTileLayout(byte gfx); -- cgit v1.2.3-54-g00ecf