changeset 3104:a488aaa0e3ae draft

(svn r3699) Replace some magic numbers for checking for a suitable slope for a level crossing by some less magic numbers
author tron <tron@openttd.org>
date Wed, 01 Mar 2006 15:03:47 +0000
parents e7803c7f5beb
children b898e9399c98
files road_cmd.c
diffstat 1 files changed, 5 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/road_cmd.c
+++ b/road_cmd.c
@@ -261,7 +261,7 @@
 }
 
 
-static const RoadBits _valid_tileh_slopes_road[3][15] = {
+static const RoadBits _valid_tileh_slopes_road[][15] = {
 	// set of normal ones
 	{
 		ROAD_ALL, 0, 0,
@@ -291,14 +291,6 @@
 		ROAD_ALL,
 		ROAD_ALL
 	},
-	// valid railway crossings on slopes
-	{
-		1, 0, 0, // 0, 1, 2
-		0, 0, 1, // 3, 4, 5
-		0, 1, 0, // 6, 7, 8
-		0, 1, 1, // 9, 10, 11
-		0, 1, 1, // 12, 13, 14
-	}
 };
 
 
@@ -383,9 +375,12 @@
 				return_cmd_error(STR_1000_LAND_SLOPED_IN_WRONG_DIRECTION);
 			}
 
-			if (!_valid_tileh_slopes_road[2][ti.tileh]) { // prevent certain slopes
+#define M(x) (1 << (x))
+			/* Level crossings may only be built on these slopes */
+			if (!HASBIT(M(14) | M(13) | M(11) | M(10) | M(7) | M(5) | M(0), ti.tileh)) {
 				return_cmd_error(STR_1000_LAND_SLOPED_IN_WRONG_DIRECTION);
 			}
+#undef M
 
 			if (ti.map5 == 2) {
 				if (pieces & ROAD_Y) goto do_clear;