summaryrefslogtreecommitdiff
path: root/src/depot_func.h
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2011-09-25 13:35:17 +0000
committerfrosch <frosch@openttd.org>2011-09-25 13:35:17 +0000
commit8d5c1479f417dc8a79997a6c4a1b357fb30a9411 (patch)
tree05f340e63c07d081cb44f5a7b6424b874e812057 /src/depot_func.h
parentfa1f8b309e13aa2872f6c520c0bcb121e559eb6b (diff)
downloadopenttd-8d5c1479f417dc8a79997a6c4a1b357fb30a9411.tar.xz
(svn r22960) -Feature: Allow depots, standard roadstops and airports on steep slopes.
Diffstat (limited to 'src/depot_func.h')
-rw-r--r--src/depot_func.h15
1 files changed, 5 insertions, 10 deletions
diff --git a/src/depot_func.h b/src/depot_func.h
index c11901025..cb48e3a4d 100644
--- a/src/depot_func.h
+++ b/src/depot_func.h
@@ -26,19 +26,14 @@ void DeleteDepotHighlightOfVehicle(const Vehicle *v);
* @param direction The direction in which the depot's exit points
* @param tileh The slope of the tile in question
* @return true if the construction is possible
-
- * This is checked by the ugly 0x4C >> direction magic, which does the following:
- * 0x4C is 0100 1100 and tileh has only bits 0..3 set (steep tiles are ruled out)
- * So: for direction (only the significant bits are shown)<p>
- * 00 (exit towards NE) we need either bit 2 or 3 set in tileh: 0x4C >> 0 = 1100<p>
- * 01 (exit towards SE) we need either bit 1 or 2 set in tileh: 0x4C >> 1 = 0110<p>
- * 02 (exit towards SW) we need either bit 0 or 1 set in tileh: 0x4C >> 2 = 0011<p>
- * 03 (exit towards NW) we need either bit 0 or 4 set in tileh: 0x4C >> 3 = 1001<p>
- * So ((0x4C >> direction) & tileh) determines whether the depot can be built on the current tileh
*/
static inline bool CanBuildDepotByTileh(DiagDirection direction, Slope tileh)
{
- return ((0x4C >> direction) & tileh) != 0;
+ assert(tileh != SLOPE_FLAT);
+ Slope entrance_corners = InclinedSlope(direction);
+ /* For steep slopes both entrance corners must be raised (i.e. neither of them is the lowest corner),
+ * For non-steep slopes at least one corner must be raised. */
+ return IsSteepSlope(tileh) ? (tileh & entrance_corners) == entrance_corners : (tileh & entrance_corners) != 0;
}
#endif /* DEPOT_FUNC_H */