openttd.c
branchcustombridgeheads
changeset 5590 dc34c43fc3eb
parent 5573 afa6f92a71fd
child 5596 fdbe3e553294
equal deleted inserted replaced
5589:0375bd469024 5590:dc34c43fc3eb
  1049 				if (IsLevelCrossing(tile) && GetCrossingRoadOwner(tile) & 0x80) {
  1049 				if (IsLevelCrossing(tile) && GetCrossingRoadOwner(tile) & 0x80) {
  1050 					SetCrossingRoadOwner(tile, OWNER_TOWN);
  1050 					SetCrossingRoadOwner(tile, OWNER_TOWN);
  1051 				}
  1051 				}
  1052 				/* FALLTHROUGH */
  1052 				/* FALLTHROUGH */
  1053 
  1053 
  1054 			case MP_TUNNELBRIDGE:
  1054 			case MP_TUNNEL: case MP_STREET_BRIDGE:
  1055 				if (GetTileOwner(tile) & 0x80) SetTileOwner(tile, OWNER_TOWN);
  1055 				if (GetTileOwner(tile) & 0x80) SetTileOwner(tile, OWNER_TOWN);
  1056 				break;
  1056 				break;
  1057 
  1057 
  1058 			default: break;
  1058 			default: break;
  1059 		}
  1059 		}
  1301 	}
  1301 	}
  1302 
  1302 
  1303 	if (CheckSavegameVersion(42)) {
  1303 	if (CheckSavegameVersion(42)) {
  1304 		TileIndex map_end = MapSize();
  1304 		TileIndex map_end = MapSize();
  1305 		TileIndex tile;
  1305 		TileIndex tile;
  1306 		Vehicle* v;
       
  1307 
  1306 
  1308 		for (tile = 0; tile != map_end; tile++) {
  1307 		for (tile = 0; tile != map_end; tile++) {
  1309 			if (MayHaveBridgeAbove(tile)) ClearBridgeMiddle(tile);
  1308 			if (MayHaveBridgeAbove(tile)) ClearBridgeMiddle(tile);
  1310 			if (IsBridgeTile(tile)) {
  1309 			if (IsTileType(tile, MP_TUNNEL) && HASBIT(_m[tile].m5, 7)) {
  1311 				if (HASBIT(_m[tile].m5, 6)) { // middle part
  1310 				if (HASBIT(_m[tile].m5, 6)) { // middle part
  1312 					Axis axis = (Axis)GB(_m[tile].m5, 0, 1);
  1311 					Axis axis = (Axis)GB(_m[tile].m5, 0, 1);
  1313 
  1312 
  1314 					if (HASBIT(_m[tile].m5, 5)) { // transport route under bridge?
  1313 					if (HASBIT(_m[tile].m5, 5)) { // transport route under bridge?
  1315 						if (GB(_m[tile].m5, 3, 2) == TRANSPORT_RAIL) {
  1314 						if (GB(_m[tile].m5, 3, 2) == TRANSPORT_RAIL) {
  1345 
  1344 
  1346 					_m[tile].m5 = 1 << 7 | type << 2 | dir;
  1345 					_m[tile].m5 = 1 << 7 | type << 2 | dir;
  1347 				}
  1346 				}
  1348 			}
  1347 			}
  1349 		}
  1348 		}
  1350 
  1349 	}
       
  1350 
       
  1351 	/* Divide MP_TUNNELBRIDGE into more tile types */
       
  1352 	if (CheckSavegameVersion(43)) {
       
  1353 		TileIndex tile;
       
  1354 
       
  1355 		for (tile = 0; tile != MapSize(); tile++) {
       
  1356 			if (IsTileType(tile, MP_TUNNEL)) {
       
  1357 				if (HASBIT(_m[tile].m5, 7)) { /* Bridge */
       
  1358 					if (GB(_m[tile].m5, 2, 2) == 0) { /* Railway Bridge */
       
  1359 						SetTileType(tile, MP_RAILWAY_BRIDGE);
       
  1360 					} else {
       
  1361 						SetTileType(tile, MP_STREET_BRIDGE);
       
  1362 					}
       
  1363 					CLRBIT(_m[tile].m5, 7);
       
  1364 					SB(_m[tile].m5, 2, 2, 0);
       
  1365 				} else { /* Tunnel */
       
  1366 					SetTileType(tile, MP_TUNNEL);
       
  1367 				}
       
  1368 			}
       
  1369 		}
       
  1370 	}
       
  1371 
       
  1372 	if (CheckSavegameVersion(42)) {
       
  1373 		Vehicle* v;
  1351 		FOR_ALL_VEHICLES(v) {
  1374 		FOR_ALL_VEHICLES(v) {
  1352 			if (v->type != VEH_Train && v->type != VEH_Road) continue;
  1375 			if (v->type != VEH_Train && v->type != VEH_Road) continue;
  1353 			if (IsBridgeTile(v->tile)) {
  1376 			if (IsBridgeTile(v->tile)) {
  1354 				DiagDirection dir = GetBridgeRampDirection(v->tile);
  1377 				DiagDirection dir = GetBridgeRampDirection(v->tile);
  1355 
  1378 
  1415 					if (IsRailwayStation(t)) {
  1438 					if (IsRailwayStation(t)) {
  1416 						SetRailType(t, UpdateRailType(GetRailType(t), min_rail));
  1439 						SetRailType(t, UpdateRailType(GetRailType(t), min_rail));
  1417 					}
  1440 					}
  1418 					break;
  1441 					break;
  1419 
  1442 
  1420 				case MP_TUNNELBRIDGE:
  1443 				case MP_TUNNEL:
  1421 					if (IsTunnel(t)) {
  1444 					if (GetTunnelTransportType(t) == TRANSPORT_RAIL) SetRailType(t, UpdateRailType(GetRailType(t), min_rail));
  1422 						if (GetTunnelTransportType(t) == TRANSPORT_RAIL) {
  1445 					break;
  1423 							SetRailType(t, UpdateRailType(GetRailType(t), min_rail));
  1446 
  1424 						}
  1447 				case MP_RAILWAY_BRIDGE:
  1425 					} else {
  1448 					SetRailType(t, UpdateRailType(GetRailType(t), min_rail));
  1426 						if (GetBridgeTransportType(t) == TRANSPORT_RAIL) {
       
  1427 							SetRailType(t, UpdateRailType(GetRailType(t), min_rail));
       
  1428 						}
       
  1429 					}
       
  1430 					break;
  1449 					break;
  1431 
  1450 
  1432 				default:
  1451 				default:
  1433 					break;
  1452 					break;
  1434 			}
  1453 			}