diff options
author | truelight <truelight@openttd.org> | 2005-02-06 10:18:47 +0000 |
---|---|---|
committer | truelight <truelight@openttd.org> | 2005-02-06 10:18:47 +0000 |
commit | bd7f37d5926ec9a5798134c4a39ef7b8cd3fd4ea (patch) | |
tree | 0b6bfe4dfd7abf3e94d0f7210b1b842e429c4a02 /depot.h | |
parent | e4913f1de822f64ae31ed697ca8ecff8cf745cce (diff) | |
download | openttd-bd7f37d5926ec9a5798134c4a39ef7b8cd3fd4ea.tar.xz |
(svn r1817) -Codechange: Moved depot-functions to depot.c
-Codechange: Added wrappers around depot-access (GetDepot no exists)
-Codechange: Made depot-functions a bit more logic (no longer
GetDepotByTile crashes your game when you request it on a non-depot tile)
-Add: made depots dynamic (yes, 64k depots are possible now)
Diffstat (limited to 'depot.h')
-rw-r--r-- | depot.h | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/depot.h b/depot.h new file mode 100644 index 000000000..b2ae02068 --- /dev/null +++ b/depot.h @@ -0,0 +1,51 @@ +#ifndef DEPOT_H +#define DEPOT_H + +#include "pool.h" + +struct Depot { + TileIndex xy; + uint16 town_index; + uint16 index; +}; + +extern MemoryPool _depot_pool; + +/** + * Get the pointer to the depot with index 'index' + */ +static inline Depot *GetDepot(uint index) +{ + return (Depot*)GetItemFromPool(&_depot_pool, index); +} + +/** + * Get the current size of the DepotPool + */ +static inline uint16 GetDepotPoolSize(void) +{ + return _depot_pool.total_items; +} + +#define FOR_ALL_DEPOTS_FROM(d, start) for (d = GetDepot(start); d != NULL; d = (d->index + 1 < GetDepotPoolSize()) ? GetDepot(d->index + 1) : NULL) +#define FOR_ALL_DEPOTS(d) FOR_ALL_DEPOTS_FROM(d, 0) + +#define MIN_SERVINT_PERCENT 5 +#define MAX_SERVINT_PERCENT 90 +#define MIN_SERVINT_DAYS 30 +#define MAX_SERVINT_DAYS 800 + +VARDEF TileIndex _last_built_train_depot_tile; +VARDEF TileIndex _last_built_road_depot_tile; +VARDEF TileIndex _last_built_aircraft_depot_tile; +VARDEF TileIndex _last_built_ship_depot_tile; + +bool IsTrainDepotTile(TileIndex tile); +bool IsRoadDepotTile(TileIndex tile); +Depot *GetDepotByTile(uint tile); +void InitializeDepot(void); +Depot *AllocateDepot(void); +bool IsShipDepotTile(TileIndex tile); +void DoDeleteDepot(uint tile); + +#endif /* DEPOT_H */ |