(svn r3941) Get rid of RAIL_TYPE_SPECIAL
authortron
Sat, 18 Mar 2006 09:06:07 +0000
changeset 3253 015524c19f16
parent 3252 fb8df0423442
child 3254 b894326fcea0
(svn r3941) Get rid of RAIL_TYPE_SPECIAL
rail.h
rail_cmd.c
--- a/rail.h	Sat Mar 18 08:37:58 2006 +0000
+++ b/rail.h	Sat Mar 18 09:06:07 2006 +0000
@@ -9,22 +9,6 @@
 #include "rail_map.h"
 #include "tile.h"
 
-/*
- * Some enums for accesing the map bytes for rail tiles
- */
-
-enum { /* DEPRECATED TODO: Rewrite all uses of this */
-	RAIL_TYPE_SPECIAL = 0x80, /* This used to say "If this bit is set, then it's
-														 * not a regular track.", but currently, you
-														 * should rather view map5[6..7] as one type,
-														 * containing a value from RailTileTypes above.
-														 * This value is only maintained for backwards
-														 * compatibility */
-
-	/* There used to be RAIL_BIT_* enums here, they moved to (for now) npf.c as
-	 * TRACK_BIT_* */
-};
-
 
 /** These are a combination of tracks and directions. Values are 0-5 in one
 direction (corresponding to the Track enum) and 8-13 in the other direction. */
--- a/rail_cmd.c	Sat Mar 18 08:37:58 2006 +0000
+++ b/rail_cmd.c	Sat Mar 18 09:06:07 2006 +0000
@@ -315,7 +315,7 @@
 					!EnsureNoVehicle(tile)) {
 				return CMD_ERROR;
 			}
-			if (m5 & RAIL_TYPE_SPECIAL ||
+			if (GetRailTileType(tile) == RAIL_TYPE_DEPOT_WAYPOINT ||
 					!IsTileOwner(tile, _current_player) ||
 					GetRailType(tile) != p1) {
 				// Get detailed error message
@@ -1038,8 +1038,9 @@
 	m5 = _m[tile].m5;
 
 	if (flags & DC_AUTO) {
-		if (m5 & RAIL_TYPE_SPECIAL)
+		if (GetRailTileType(tile) == RAIL_TYPE_DEPOT_WAYPOINT) {
 			return_cmd_error(STR_2004_BUILDING_MUST_BE_DEMOLISHED);
+		}
 
 		if (!IsTileOwner(tile, _current_player))
 			return_cmd_error(STR_1024_AREA_IS_OWNED_BY_ANOTHER);
@@ -1349,7 +1350,7 @@
 	_drawtile_track_palette = SPRITE_PALETTE(PLAYER_SPRITE_COLOR(GetTileOwner(ti->tile)));
 
 	m5 = (byte)ti->map5;
-	if (!(m5 & RAIL_TYPE_SPECIAL)) {
+	if (GetRailTileType(ti->tile) != RAIL_TYPE_DEPOT_WAYPOINT) {
 		bool earth = (_m[ti->tile].m2 & RAIL_MAP2LO_GROUND_MASK) == RAIL_GROUND_BROWN;
 		bool snow = (_m[ti->tile].m2 & RAIL_MAP2LO_GROUND_MASK) == RAIL_GROUND_ICE_DESERT;
 
@@ -1360,8 +1361,7 @@
 		}
 
 		/* draw signals also? */
-		if (!(ti->map5 & RAIL_TYPE_SIGNALS))
-			return;
+		if (GetRailTileType(ti->tile) != RAIL_TYPE_SIGNALS) return;
 
 		{
 			byte m23;
@@ -1404,12 +1404,6 @@
 		const DrawTrackSeqStruct *drss;
 		byte type = m5 & 0x3F; // 0-3: depots, 4-5: waypoints
 
-		if (!(m5 & (RAIL_TILE_TYPE_MASK&~RAIL_TYPE_SPECIAL)))
-			/* XXX: There used to be "return;" here, but since I could not find out
-			 * why this would ever occur, I put assert(0) here. Let's see if someone
-			 * complains about it. If not, we'll remove this check. (Matthijs). */
-			 assert(0);
-
 		if (ti->tileh != 0) DrawFoundation(ti, ti->tileh);
 
 		if (IsRailWaypoint(ti->tile) && HASBIT(_m[ti->tile].m3, 4)) {
@@ -1855,7 +1849,11 @@
 	byte old_ground;
 	byte new_ground;
 
-	old_ground = _m[tile].m5 & RAIL_TYPE_SPECIAL ? GB(_m[tile].m4, 0, 4) : GB(_m[tile].m2, 0, 4);
+	if (GetRailType(tile) == RAIL_TYPE_DEPOT_WAYPOINT) {
+		old_ground = GB(_m[tile].m4, 0, 4);
+	} else {
+		old_ground = GB(_m[tile].m2, 0, 4);
+	}
 
 	switch (_opt.landscape) {
 		case LT_HILLY:
@@ -1874,7 +1872,7 @@
 	}
 
 	// Don't continue tile loop for depots
-	if (_m[tile].m5 & RAIL_TYPE_SPECIAL) return;
+	if (GetRailType(tile) == RAIL_TYPE_DEPOT_WAYPOINT) return;
 
 	new_ground = RAIL_GROUND_GREEN;
 
@@ -1956,7 +1954,7 @@
 modify_me:;
 	/* tile changed? */
 	if (old_ground != new_ground) {
-		if (_m[tile].m5 & RAIL_TYPE_SPECIAL) {
+		if (GetRailTileType(tile) == RAIL_TYPE_DEPOT_WAYPOINT) {
 			SB(_m[tile].m4, 0, 4, new_ground);
 		} else {
 			SB(_m[tile].m2, 0, 4, new_ground);
@@ -1976,9 +1974,9 @@
 
 	m5 = _m[tile].m5;
 
-	if (!(m5 & RAIL_TYPE_SPECIAL)) {
+	if (GetRailType(tile) != RAIL_TYPE_DEPOT_WAYPOINT) {
 		ret = (m5 | (m5 << 8)) & 0x3F3F;
-		if (!(m5 & RAIL_TYPE_SIGNALS)) {
+		if (GetRailType(tile) != RAIL_TYPE_SIGNALS) {
 			if ( (ret & 0xFF) == 3)
 			/* Diagonal crossing? */
 				ret |= 0x40;