summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2007-09-14 22:35:39 +0000
committerrubidium <rubidium@openttd.org>2007-09-14 22:35:39 +0000
commite8ff9ee98224ba8d5c88359dc5f1059abaffdd37 (patch)
treecba4d3ec0437760257c64a4cda060bee015f451c
parentfef64185b87e4517b7760e017171d646eaa1eb69 (diff)
downloadopenttd-e8ff9ee98224ba8d5c88359dc5f1059abaffdd37.tar.xz
(svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
-rw-r--r--src/autoslope.h42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/autoslope.h b/src/autoslope.h
new file mode 100644
index 000000000..c6f40eb52
--- /dev/null
+++ b/src/autoslope.h
@@ -0,0 +1,42 @@
+/* $Id$ */
+
+/** @file autoslope.h */
+
+#ifndef AUTOSLOPE_H
+#define AUTOSLOPE_H
+
+#include "depot.h"
+
+/**
+ * Autoslope check for tiles with an entrance on an edge.
+ * E.g. depots and non-drive-through-road-stops.
+ *
+ * The test succeeds if the slope is not steep and at least one corner of the entrance edge is on the TileMaxZ() level.
+ *
+ * @note The test does not check if autoslope is enabled at all.
+ *
+ * @param tile The tile.
+ * @param z_new New TileZ.
+ * @param tileh_new New TileSlope.
+ * @param entrance Entrance edge.
+ * @return true iff terraforming is allowed.
+ */
+static inline bool AutoslopeCheckForEntranceEdge(TileIndex tile, uint z_new, Slope tileh_new, DiagDirection entrance)
+{
+ if (IsSteepSlope(tileh_new) || (GetTileMaxZ(tile) != z_new + GetSlopeMaxZ(tileh_new))) return false;
+ return ((tileh_new == SLOPE_FLAT) || CanBuildDepotByTileh(entrance, tileh_new));
+}
+
+/**
+ * Tests if autoslope is enabled for _current_player.
+ *
+ * Autoslope is disabled for town/industry construction and old ai players.
+ *
+ * @return true iff autoslope is enabled.
+ */
+static inline bool AutoslopeEnabled()
+{
+ return (_patches.autoslope && IsValidPlayer(_current_player) && !_is_old_ai_player);
+}
+
+#endif /* AUTOSLOPE_H */