src/openttd.cpp
branchNewGRF_ports
changeset 6877 889301acc299
parent 6872 1c4a4a609f85
child 6878 7d1ff2f621c7
equal deleted inserted replaced
6876:2c40faeef7a5 6877:889301acc299
    76 #include "industry_map.h"
    76 #include "industry_map.h"
    77 #include "unmovable_map.h"
    77 #include "unmovable_map.h"
    78 #include "tree_map.h"
    78 #include "tree_map.h"
    79 #include "tunnelbridge_map.h"
    79 #include "tunnelbridge_map.h"
    80 #include "void_map.h"
    80 #include "void_map.h"
       
    81 #include "water.h"
    81 
    82 
    82 #include <stdarg.h>
    83 #include <stdarg.h>
    83 
    84 
    84 #include "table/strings.h"
    85 #include "table/strings.h"
    85 
    86 
  1714 					if (IsRoadStop(t)) SetRoadTypes(t, ROADTYPES_ROAD);
  1715 					if (IsRoadStop(t)) SetRoadTypes(t, ROADTYPES_ROAD);
  1715 					break;
  1716 					break;
  1716 
  1717 
  1717 				case MP_TUNNELBRIDGE:
  1718 				case MP_TUNNELBRIDGE:
  1718 					/* Middle part of "old" bridges */
  1719 					/* Middle part of "old" bridges */
  1719 					if (old_bridge && IsBridgeTile(t) && HasBit(_m[t].m5, 6)) break;
  1720 					if (old_bridge && IsBridge(t) && HasBit(_m[t].m5, 6)) break;
  1720 					if ((IsTunnel(t) ? GetTunnelBridgeTransportType(t) : (old_bridge ? (TransportType)GB(_m[t].m5, 1, 2) : GetTunnelBridgeTransportType(t))) == TRANSPORT_ROAD) {
  1721 					if (((old_bridge && IsBridge(t)) ? (TransportType)GB(_m[t].m5, 1, 2) : GetTunnelBridgeTransportType(t)) == TRANSPORT_ROAD) {
  1721 						SetRoadTypes(t, ROADTYPES_ROAD);
  1722 						SetRoadTypes(t, ROADTYPES_ROAD);
  1722 					}
  1723 					}
  1723 					break;
  1724 					break;
  1724 
  1725 
  1725 				default: break;
  1726 				default: break;
  1757 						}
  1758 						}
  1758 					} else {
  1759 					} else {
  1759 						if (GB(_m[t].m5, 3, 2) == 0) {
  1760 						if (GB(_m[t].m5, 3, 2) == 0) {
  1760 							MakeClear(t, CLEAR_GRASS, 3);
  1761 							MakeClear(t, CLEAR_GRASS, 3);
  1761 						} else {
  1762 						} else {
  1762 							MakeCanal(t, (GetTileOwner(t) == OWNER_WATER) ? OWNER_NONE : GetTileOwner(t), Random());
  1763 							if (GetTileSlope(t, NULL) != SLOPE_FLAT) {
       
  1764 								MakeShore(t);
       
  1765 							} else {
       
  1766 								if (GetTileOwner(t) == OWNER_WATER) {
       
  1767 									MakeWater(t);
       
  1768 								} else {
       
  1769 									MakeCanal(t, GetTileOwner(t), Random());
       
  1770 								}
       
  1771 							}
  1763 						}
  1772 						}
  1764 					}
  1773 					}
  1765 					SetBridgeMiddle(t, axis);
  1774 					SetBridgeMiddle(t, axis);
  1766 				} else { // ramp
  1775 				} else { // ramp
  1767 					Axis axis = (Axis)GB(_m[t].m5, 0, 1);
  1776 					Axis axis = (Axis)GB(_m[t].m5, 0, 1);
  2362 			}
  2371 			}
  2363 		}
  2372 		}
  2364 	}
  2373 	}
  2365 
  2374 
  2366 	if (CheckSavegameVersion(86)) {
  2375 	if (CheckSavegameVersion(86)) {
  2367 		/* Now all crossings should be in correct state */
       
  2368 		for (TileIndex t = 0; t < map_size; t++) {
  2376 		for (TileIndex t = 0; t < map_size; t++) {
       
  2377 			/* Now all crossings should be in correct state */
  2369 			if (IsLevelCrossingTile(t)) UpdateLevelCrossing(t, false);
  2378 			if (IsLevelCrossingTile(t)) UpdateLevelCrossing(t, false);
       
  2379 
       
  2380 			/* Move river flag and update canals to use water class */
       
  2381 			if (IsTileType(t, MP_WATER)) {
       
  2382 				if (_m[t].m5 == 2) {
       
  2383 					MakeRiver(t, Random());
       
  2384 				} else {
       
  2385 					Owner o = GetTileOwner(t);
       
  2386 					if (IsWater(t) && o != OWNER_WATER) {
       
  2387 						MakeCanal(t, o, Random());
       
  2388 					}
       
  2389 				}
       
  2390 			}
       
  2391 		}
       
  2392 
       
  2393 		/* Update locks, depots, docks and buoys to have a water class based
       
  2394 		 * on its neighbouring tiles. Done after river and canal updates to
       
  2395 		 * ensure neighbours are correct. */
       
  2396 		for (TileIndex t = 0; t < map_size; t++) {
       
  2397 			if (GetTileSlope(t, NULL) != SLOPE_FLAT) continue;
       
  2398 
       
  2399 			if (IsTileType(t, MP_WATER) && (GetWaterTileType(t) == WATER_TILE_LOCK || IsShipDepot(t))) SetWaterClassDependingOnSurroundings(t);
       
  2400 			if (IsTileType(t, MP_STATION) && (IsDock(t) || IsBuoy(t))) SetWaterClassDependingOnSurroundings(t);
  2370 		}
  2401 		}
  2371 	}
  2402 	}
  2372 
  2403 
  2373 	return InitializeWindowsAndCaches();
  2404 	return InitializeWindowsAndCaches();
  2374 }
  2405 }