summaryrefslogtreecommitdiff
path: root/src/station.h
diff options
context:
space:
mode:
authorKUDr <KUDr@openttd.org>2007-01-14 19:18:50 +0000
committerKUDr <KUDr@openttd.org>2007-01-14 19:18:50 +0000
commit3ad14cc7a83892b7f6e8c36d254a222c982ffb7d (patch)
tree23a6f8249a3b99af865b2b3ffdaf026eb363edda /src/station.h
parente257f0e36c88f6c9437db1d36896ec29766db8f2 (diff)
downloadopenttd-3ad14cc7a83892b7f6e8c36d254a222c982ffb7d.tar.xz
(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).
Diffstat (limited to 'src/station.h')
-rw-r--r--src/station.h30
1 files changed, 21 insertions, 9 deletions
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 <deque>
#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);