openttd.c
branchcustombridgeheads
changeset 5590 dc34c43fc3eb
parent 5573 afa6f92a71fd
child 5596 fdbe3e553294
--- a/openttd.c	Thu Dec 28 16:11:07 2006 +0000
+++ b/openttd.c	Thu Dec 28 17:21:22 2006 +0000
@@ -1051,7 +1051,7 @@
 				}
 				/* FALLTHROUGH */
 
-			case MP_TUNNELBRIDGE:
+			case MP_TUNNEL: case MP_STREET_BRIDGE:
 				if (GetTileOwner(tile) & 0x80) SetTileOwner(tile, OWNER_TOWN);
 				break;
 
@@ -1303,11 +1303,10 @@
 	if (CheckSavegameVersion(42)) {
 		TileIndex map_end = MapSize();
 		TileIndex tile;
-		Vehicle* v;
 
 		for (tile = 0; tile != map_end; tile++) {
 			if (MayHaveBridgeAbove(tile)) ClearBridgeMiddle(tile);
-			if (IsBridgeTile(tile)) {
+			if (IsTileType(tile, MP_TUNNEL) && HASBIT(_m[tile].m5, 7)) {
 				if (HASBIT(_m[tile].m5, 6)) { // middle part
 					Axis axis = (Axis)GB(_m[tile].m5, 0, 1);
 
@@ -1347,7 +1346,31 @@
 				}
 			}
 		}
+	}
 
+	/* Divide MP_TUNNELBRIDGE into more tile types */
+	if (CheckSavegameVersion(43)) {
+		TileIndex tile;
+
+		for (tile = 0; tile != MapSize(); tile++) {
+			if (IsTileType(tile, MP_TUNNEL)) {
+				if (HASBIT(_m[tile].m5, 7)) { /* Bridge */
+					if (GB(_m[tile].m5, 2, 2) == 0) { /* Railway Bridge */
+						SetTileType(tile, MP_RAILWAY_BRIDGE);
+					} else {
+						SetTileType(tile, MP_STREET_BRIDGE);
+					}
+					CLRBIT(_m[tile].m5, 7);
+					SB(_m[tile].m5, 2, 2, 0);
+				} else { /* Tunnel */
+					SetTileType(tile, MP_TUNNEL);
+				}
+			}
+		}
+	}
+
+	if (CheckSavegameVersion(42)) {
+		Vehicle* v;
 		FOR_ALL_VEHICLES(v) {
 			if (v->type != VEH_Train && v->type != VEH_Road) continue;
 			if (IsBridgeTile(v->tile)) {
@@ -1417,16 +1440,12 @@
 					}
 					break;
 
-				case MP_TUNNELBRIDGE:
-					if (IsTunnel(t)) {
-						if (GetTunnelTransportType(t) == TRANSPORT_RAIL) {
-							SetRailType(t, UpdateRailType(GetRailType(t), min_rail));
-						}
-					} else {
-						if (GetBridgeTransportType(t) == TRANSPORT_RAIL) {
-							SetRailType(t, UpdateRailType(GetRailType(t), min_rail));
-						}
-					}
+				case MP_TUNNEL:
+					if (GetTunnelTransportType(t) == TRANSPORT_RAIL) SetRailType(t, UpdateRailType(GetRailType(t), min_rail));
+					break;
+
+				case MP_RAILWAY_BRIDGE:
+					SetRailType(t, UpdateRailType(GetRailType(t), min_rail));
 					break;
 
 				default: