equal
deleted
inserted
replaced
1 #ifndef DEPOT_H |
1 #ifndef DEPOT_H |
2 #define DEPOT_H |
2 #define DEPOT_H |
|
3 |
|
4 /** @file depot.h Header files for depots (not hangars) |
|
5 * @see depot.c */ |
3 |
6 |
4 #include "pool.h" |
7 #include "pool.h" |
5 #include "tile.h" |
8 #include "tile.h" |
6 |
9 |
7 struct Depot { |
10 struct Depot { |
110 default: |
113 default: |
111 return INVALID_DIAGDIR; /* Not reached */ |
114 return INVALID_DIAGDIR; /* Not reached */ |
112 } |
115 } |
113 } |
116 } |
114 |
117 |
|
118 /** |
|
119 Find out if the slope of the tile is suitable to build a depot of given direction |
|
120 @param direction The direction in which the depot's exit points. Starts with 0 as NE and goes Clockwise |
|
121 @param tileh The slope of the tile in question |
|
122 @return true if the construction is possible |
|
123 |
|
124 |
|
125 This is checked by the ugly 0x4C >> direction magic, which does the following: |
|
126 0x4C is 0100 1100 and tileh has only bits 0..3 set (steep tiles are ruled out) |
|
127 So: for direction (only the significant bits are shown)<p> |
|
128 00 (exit towards NE) we need either bit 2 or 3 set in tileh: 0x4C >> 0 = 1100<p> |
|
129 01 (exit towards SE) we need either bit 1 or 2 set in tileh: 0x4C >> 1 = 0110<p> |
|
130 02 (exit towards SW) we need either bit 0 or 1 set in tileh: 0x4C >> 2 = 0011<p> |
|
131 03 (exit towards NW) we need either bit 0 or 4 set in tileh: 0x4C >> 3 = 1001<p> |
|
132 So ((0x4C >> p2) & tileh) determines whether the depot can be built on the current tileh |
|
133 */ |
|
134 static inline bool CanBuildDepotByTileh(uint32 direction, uint tileh) |
|
135 { |
|
136 return (0x4C >> direction) & tileh; |
|
137 } |
|
138 |
|
139 |
115 Depot *GetDepotByTile(TileIndex tile); |
140 Depot *GetDepotByTile(TileIndex tile); |
116 void InitializeDepot(void); |
141 void InitializeDepot(void); |
117 Depot *AllocateDepot(void); |
142 Depot *AllocateDepot(void); |
118 void DoDeleteDepot(TileIndex tile); |
143 void DoDeleteDepot(TileIndex tile); |
119 |
144 |