summaryrefslogtreecommitdiff
path: root/depot.h
diff options
context:
space:
mode:
authormatthijs <matthijs@openttd.org>2005-02-06 22:36:08 +0000
committermatthijs <matthijs@openttd.org>2005-02-06 22:36:08 +0000
commitcc0966405b3dc39a762e54ec0895ad3f346c53ab (patch)
treeb4e6f6fce72b1b3fcb2b25b635ad70c6bd5b6741 /depot.h
parent257e97c09a5445c339118c3269cd3bd39151c65c (diff)
downloadopenttd-cc0966405b3dc39a762e54ec0895ad3f346c53ab.tar.xz
(svn r1834) - Fix: NPF does not check the owner of its target, busses try to enter other players' depots. TODO
- Add: asserts to find the v->u.rail.track == 0 problem. - Add: IsValidDepot(), IsValidTown(), IsValidSign(), IsValidVehicle(), IsValidStation() - Add: GetTileOwner(), IsTileOwner() - Codechange: Replaced IsShipDepotTile(), IsTrainDepotTile(), IsRoadDepotTile() by IsTileDepotType(). - Codechange: typedeffed the MAP_OWNERS as Owner. Should be used as variable type. - Codechange: Replaced a few uint by TileIndex.
Diffstat (limited to 'depot.h')
-rw-r--r--depot.h34
1 files changed, 31 insertions, 3 deletions
diff --git a/depot.h b/depot.h
index b2ae02068..11f47401a 100644
--- a/depot.h
+++ b/depot.h
@@ -2,6 +2,7 @@
#define DEPOT_H
#include "pool.h"
+#include "tile.h"
struct Depot {
TileIndex xy;
@@ -40,12 +41,39 @@ 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);
+/**
+ * Check if a depot really exists.
+ */
+static inline bool IsValidDepot(Depot* depot)
+{
+ return depot->xy != 0; /* XXX: Replace by INVALID_TILE someday */
+}
+
+/**
+ * Check if a tile is a depot of the given type.
+ */
+static inline bool IsTileDepotType(TileIndex tile, TransportType type)
+{
+ switch(type)
+ {
+ case TRANSPORT_RAIL:
+ return IsTileType(tile, MP_RAILWAY) && (_map5[tile] & 0xFC) == 0xC0;
+ break;
+ case TRANSPORT_ROAD:
+ return IsTileType(tile, MP_STREET) && (_map5[tile] & 0xF0) == 0x20;
+ break;
+ case TRANSPORT_WATER:
+ return IsTileType(tile, MP_WATER) && (_map5[tile] & ~3) == 0x80;
+ break;
+ default:
+ assert(0);
+ return false;
+ }
+}
+
Depot *GetDepotByTile(uint tile);
void InitializeDepot(void);
Depot *AllocateDepot(void);
-bool IsShipDepotTile(TileIndex tile);
void DoDeleteDepot(uint tile);
#endif /* DEPOT_H */