509 DEBUG(driver, 1, "Loading drivers..."); |
512 DEBUG(driver, 1, "Loading drivers..."); |
510 LoadDriver(SOUND_DRIVER, _ini_sounddriver); |
513 LoadDriver(SOUND_DRIVER, _ini_sounddriver); |
511 LoadDriver(MUSIC_DRIVER, _ini_musicdriver); |
514 LoadDriver(MUSIC_DRIVER, _ini_musicdriver); |
512 LoadDriver(VIDEO_DRIVER, _ini_videodriver); // load video last, to prevent an empty window while sound and music loads |
515 LoadDriver(VIDEO_DRIVER, _ini_videodriver); // load video last, to prevent an empty window while sound and music loads |
513 _savegame_sort_order = SORT_BY_DATE | SORT_DESCENDING; |
516 _savegame_sort_order = SORT_BY_DATE | SORT_DESCENDING; |
|
517 /* Initialize the zoom level of the screen to normal */ |
|
518 _screen.zoom = ZOOM_LVL_NORMAL; |
514 |
519 |
515 /* restore saved music volume */ |
520 /* restore saved music volume */ |
516 _music_driver->set_volume(msf.music_vol); |
521 _music_driver->set_volume(msf.music_vol); |
517 |
522 |
518 NetworkStartUp(); // initialize network-core |
523 NetworkStartUp(); // initialize network-core |
1289 WP(w,vp_d).scrollpos_x = _saved_scrollpos_x; |
1294 WP(w,vp_d).scrollpos_x = _saved_scrollpos_x; |
1290 WP(w,vp_d).scrollpos_y = _saved_scrollpos_y; |
1295 WP(w,vp_d).scrollpos_y = _saved_scrollpos_y; |
1291 |
1296 |
1292 vp = w->viewport; |
1297 vp = w->viewport; |
1293 vp->zoom = _saved_scrollpos_zoom; |
1298 vp->zoom = _saved_scrollpos_zoom; |
1294 vp->virtual_width = vp->width << vp->zoom; |
1299 vp->virtual_width = ScaleByZoom(vp->width, vp->zoom); |
1295 vp->virtual_height = vp->height << vp->zoom; |
1300 vp->virtual_height = ScaleByZoom(vp->height, vp->zoom); |
1296 |
1301 |
1297 /* in version 4.1 of the savegame, is_active was introduced to determine |
1302 /* in version 4.1 of the savegame, is_active was introduced to determine |
1298 * if a player does exist, rather then checking name_1 */ |
1303 * if a player does exist, rather then checking name_1 */ |
1299 if (CheckSavegameVersionOldStyle(4, 1)) CheckIsPlayerActive(); |
1304 if (CheckSavegameVersionOldStyle(4, 1)) CheckIsPlayerActive(); |
1300 |
1305 |
1416 p->engine_renew_months = _patches.autorenew_months; |
1421 p->engine_renew_months = _patches.autorenew_months; |
1417 p->engine_renew_money = _patches.autorenew_money; |
1422 p->engine_renew_money = _patches.autorenew_money; |
1418 } |
1423 } |
1419 } |
1424 } |
1420 |
1425 |
1421 if (CheckSavegameVersion(42)) { |
|
1422 Vehicle* v; |
|
1423 |
|
1424 for (TileIndex t = 0; t < map_size; t++) { |
|
1425 if (MayHaveBridgeAbove(t)) ClearBridgeMiddle(t); |
|
1426 if (IsBridgeTile(t)) { |
|
1427 if (HASBIT(_m[t].m5, 6)) { // middle part |
|
1428 Axis axis = (Axis)GB(_m[t].m5, 0, 1); |
|
1429 |
|
1430 if (HASBIT(_m[t].m5, 5)) { // transport route under bridge? |
|
1431 if (GB(_m[t].m5, 3, 2) == TRANSPORT_RAIL) { |
|
1432 MakeRailNormal( |
|
1433 t, |
|
1434 GetTileOwner(t), |
|
1435 axis == AXIS_X ? TRACK_BIT_Y : TRACK_BIT_X, |
|
1436 GetRailType(t) |
|
1437 ); |
|
1438 } else { |
|
1439 TownID town = IsTileOwner(t, OWNER_TOWN) ? ClosestTownFromTile(t, (uint)-1)->index : 0; |
|
1440 |
|
1441 MakeRoadNormal( |
|
1442 t, |
|
1443 GetTileOwner(t), |
|
1444 axis == AXIS_X ? ROAD_Y : ROAD_X, |
|
1445 town |
|
1446 ); |
|
1447 } |
|
1448 } else { |
|
1449 if (GB(_m[t].m5, 3, 2) == 0) { |
|
1450 MakeClear(t, CLEAR_GRASS, 3); |
|
1451 } else { |
|
1452 MakeCanal(t, GetTileOwner(t)); |
|
1453 } |
|
1454 } |
|
1455 SetBridgeMiddle(t, axis); |
|
1456 } else { // ramp |
|
1457 Axis axis = (Axis)GB(_m[t].m5, 0, 1); |
|
1458 uint north_south = GB(_m[t].m5, 5, 1); |
|
1459 DiagDirection dir = ReverseDiagDir(XYNSToDiagDir(axis, north_south)); |
|
1460 TransportType type = (TransportType)GB(_m[t].m5, 1, 2); |
|
1461 |
|
1462 _m[t].m5 = 1 << 7 | type << 2 | dir; |
|
1463 } |
|
1464 } |
|
1465 } |
|
1466 |
|
1467 FOR_ALL_VEHICLES(v) { |
|
1468 if (v->type != VEH_TRAIN && v->type != VEH_ROAD) continue; |
|
1469 if (IsBridgeTile(v->tile)) { |
|
1470 DiagDirection dir = GetBridgeRampDirection(v->tile); |
|
1471 |
|
1472 if (dir != DirToDiagDir(v->direction)) continue; |
|
1473 switch (dir) { |
|
1474 default: NOT_REACHED(); |
|
1475 case DIAGDIR_NE: if ((v->x_pos & 0xF) != 0) continue; break; |
|
1476 case DIAGDIR_SE: if ((v->y_pos & 0xF) != TILE_SIZE - 1) continue; break; |
|
1477 case DIAGDIR_SW: if ((v->x_pos & 0xF) != TILE_SIZE - 1) continue; break; |
|
1478 case DIAGDIR_NW: if ((v->y_pos & 0xF) != 0) continue; break; |
|
1479 } |
|
1480 } else if (v->z_pos > GetSlopeZ(v->x_pos, v->y_pos)) { |
|
1481 v->tile = GetNorthernBridgeEnd(v->tile); |
|
1482 } else { |
|
1483 continue; |
|
1484 } |
|
1485 if (v->type == VEH_TRAIN) { |
|
1486 v->u.rail.track = TRACK_BIT_WORMHOLE; |
|
1487 } else { |
|
1488 v->u.road.state = RVSB_WORMHOLE; |
|
1489 } |
|
1490 } |
|
1491 } |
|
1492 |
|
1493 if (CheckSavegameVersion(48)) { |
1426 if (CheckSavegameVersion(48)) { |
1494 for (TileIndex t = 0; t < map_size; t++) { |
1427 for (TileIndex t = 0; t < map_size; t++) { |
1495 switch (GetTileType(t)) { |
1428 switch (GetTileType(t)) { |
1496 case MP_RAILWAY: |
1429 case MP_RAILWAY: |
1497 if (IsPlainRailTile(t)) { |
1430 if (IsPlainRailTile(t)) { |
1516 default: break; |
1449 default: break; |
1517 } |
1450 } |
1518 } |
1451 } |
1519 } |
1452 } |
1520 |
1453 |
|
1454 if (CheckSavegameVersion(61)) { |
|
1455 /* Added the RoadType */ |
|
1456 for (TileIndex t = 0; t < map_size; t++) { |
|
1457 switch(GetTileType(t)) { |
|
1458 case MP_STREET: |
|
1459 SB(_m[t].m5, 6, 2, GB(_m[t].m5, 4, 2)); |
|
1460 switch (GetRoadTileType(t)) { |
|
1461 default: NOT_REACHED(); |
|
1462 case ROAD_TILE_NORMAL: |
|
1463 SB(_m[t].m4, 0, 4, GB(_m[t].m5, 0, 4)); |
|
1464 SB(_m[t].m4, 4, 4, 0); |
|
1465 SB(_m[t].m6, 2, 4, 0); |
|
1466 break; |
|
1467 case ROAD_TILE_CROSSING: |
|
1468 SB(_m[t].m4, 5, 2, GB(_m[t].m5, 2, 2)); |
|
1469 break; |
|
1470 case ROAD_TILE_DEPOT: break; |
|
1471 } |
|
1472 SetRoadTypes(t, ROADTYPES_ROAD); |
|
1473 break; |
|
1474 |
|
1475 case MP_STATION: |
|
1476 if (IsRoadStop(t)) SetRoadTypes(t, ROADTYPES_ROAD); |
|
1477 break; |
|
1478 |
|
1479 case MP_TUNNELBRIDGE: |
|
1480 if ((IsTunnel(t) ? GetTunnelTransportType(t) : GetBridgeTransportType(t)) == TRANSPORT_ROAD) { |
|
1481 SetRoadTypes(t, ROADTYPES_ROAD); |
|
1482 } |
|
1483 break; |
|
1484 |
|
1485 default: break; |
|
1486 } |
|
1487 } |
|
1488 } |
|
1489 |
|
1490 if (CheckSavegameVersion(42)) { |
|
1491 Vehicle* v; |
|
1492 |
|
1493 for (TileIndex t = 0; t < map_size; t++) { |
|
1494 if (MayHaveBridgeAbove(t)) ClearBridgeMiddle(t); |
|
1495 if (IsBridgeTile(t)) { |
|
1496 if (HASBIT(_m[t].m5, 6)) { // middle part |
|
1497 Axis axis = (Axis)GB(_m[t].m5, 0, 1); |
|
1498 |
|
1499 if (HASBIT(_m[t].m5, 5)) { // transport route under bridge? |
|
1500 if (GB(_m[t].m5, 3, 2) == TRANSPORT_RAIL) { |
|
1501 MakeRailNormal( |
|
1502 t, |
|
1503 GetTileOwner(t), |
|
1504 axis == AXIS_X ? TRACK_BIT_Y : TRACK_BIT_X, |
|
1505 GetRailType(t) |
|
1506 ); |
|
1507 } else { |
|
1508 TownID town = IsTileOwner(t, OWNER_TOWN) ? ClosestTownFromTile(t, (uint)-1)->index : 0; |
|
1509 |
|
1510 MakeRoadNormal( |
|
1511 t, |
|
1512 axis == AXIS_X ? ROAD_Y : ROAD_X, |
|
1513 ROADTYPES_ROAD, |
|
1514 town, |
|
1515 GetTileOwner(t), OWNER_NONE, OWNER_NONE |
|
1516 ); |
|
1517 } |
|
1518 } else { |
|
1519 if (GB(_m[t].m5, 3, 2) == 0) { |
|
1520 MakeClear(t, CLEAR_GRASS, 3); |
|
1521 } else { |
|
1522 MakeCanal(t, GetTileOwner(t)); |
|
1523 } |
|
1524 } |
|
1525 SetBridgeMiddle(t, axis); |
|
1526 } else { // ramp |
|
1527 Axis axis = (Axis)GB(_m[t].m5, 0, 1); |
|
1528 uint north_south = GB(_m[t].m5, 5, 1); |
|
1529 DiagDirection dir = ReverseDiagDir(XYNSToDiagDir(axis, north_south)); |
|
1530 TransportType type = (TransportType)GB(_m[t].m5, 1, 2); |
|
1531 |
|
1532 _m[t].m5 = 1 << 7 | type << 2 | dir; |
|
1533 } |
|
1534 } |
|
1535 } |
|
1536 |
|
1537 FOR_ALL_VEHICLES(v) { |
|
1538 if (v->type != VEH_TRAIN && v->type != VEH_ROAD) continue; |
|
1539 if (IsBridgeTile(v->tile)) { |
|
1540 DiagDirection dir = GetBridgeRampDirection(v->tile); |
|
1541 |
|
1542 if (dir != DirToDiagDir(v->direction)) continue; |
|
1543 switch (dir) { |
|
1544 default: NOT_REACHED(); |
|
1545 case DIAGDIR_NE: if ((v->x_pos & 0xF) != 0) continue; break; |
|
1546 case DIAGDIR_SE: if ((v->y_pos & 0xF) != TILE_SIZE - 1) continue; break; |
|
1547 case DIAGDIR_SW: if ((v->x_pos & 0xF) != TILE_SIZE - 1) continue; break; |
|
1548 case DIAGDIR_NW: if ((v->y_pos & 0xF) != 0) continue; break; |
|
1549 } |
|
1550 } else if (v->z_pos > GetSlopeZ(v->x_pos, v->y_pos)) { |
|
1551 v->tile = GetNorthernBridgeEnd(v->tile); |
|
1552 } else { |
|
1553 continue; |
|
1554 } |
|
1555 if (v->type == VEH_TRAIN) { |
|
1556 v->u.rail.track = TRACK_BIT_WORMHOLE; |
|
1557 } else { |
|
1558 v->u.road.state = RVSB_WORMHOLE; |
|
1559 } |
|
1560 } |
|
1561 } |
|
1562 |
1521 /* Elrails got added in rev 24 */ |
1563 /* Elrails got added in rev 24 */ |
1522 if (CheckSavegameVersion(24)) { |
1564 if (CheckSavegameVersion(24)) { |
1523 Vehicle *v; |
1565 Vehicle *v; |
1524 RailType min_rail = RAILTYPE_ELECTRIC; |
1566 RailType min_rail = RAILTYPE_ELECTRIC; |
1525 |
1567 |
1774 |
1816 |
1775 /* From version 53, the map array was changed for house tiles to allow |
1817 /* From version 53, the map array was changed for house tiles to allow |
1776 * space for newhouses grf features. A new byte, m7, was also added. */ |
1818 * space for newhouses grf features. A new byte, m7, was also added. */ |
1777 if (CheckSavegameVersion(53)) { |
1819 if (CheckSavegameVersion(53)) { |
1778 for (TileIndex t = 0; t < map_size; t++) { |
1820 for (TileIndex t = 0; t < map_size; t++) { |
1779 _me[t].m7 = 0; |
|
1780 |
|
1781 if (IsTileType(t, MP_HOUSE)) { |
1821 if (IsTileType(t, MP_HOUSE)) { |
1782 if (GB(_m[t].m3, 6, 2) != TOWN_HOUSE_COMPLETED) { |
1822 if (GB(_m[t].m3, 6, 2) != TOWN_HOUSE_COMPLETED) { |
1783 /* Move the construction stage from m3[7..6] to m5[5..4]. |
1823 /* Move the construction stage from m3[7..6] to m5[5..4]. |
1784 * The construction counter does not have to move. */ |
1824 * The construction counter does not have to move. */ |
1785 SB(_m[t].m5, 3, 2, GB(_m[t].m3, 6, 2)); |
1825 SB(_m[t].m5, 3, 2, GB(_m[t].m3, 6, 2)); |
1941 FOR_ALL_VEHICLES(v) { |
1981 FOR_ALL_VEHICLES(v) { |
1942 if ((v->type != VEH_TRAIN || IsFrontEngine(v)) && // for all locs |
1982 if ((v->type != VEH_TRAIN || IsFrontEngine(v)) && // for all locs |
1943 !(v->vehstatus & (VS_STOPPED | VS_CRASHED)) && // not stopped or crashed |
1983 !(v->vehstatus & (VS_STOPPED | VS_CRASHED)) && // not stopped or crashed |
1944 v->current_order.type == OT_LOADING) { // loading |
1984 v->current_order.type == OT_LOADING) { // loading |
1945 GetStation(v->last_station_visited)->loading_vehicles.push_back(v); |
1985 GetStation(v->last_station_visited)->loading_vehicles.push_back(v); |
|
1986 |
|
1987 /* The loading finished flag is *only* set when actually completely |
|
1988 * finished. Because the vehicle is loading, it is not finished. */ |
|
1989 CLRBIT(v->vehicle_flags, VF_LOADING_FINISHED); |
1946 } |
1990 } |
1947 } |
1991 } |
1948 } |
1992 } |
1949 |
1993 |
1950 if (CheckSavegameVersion(58)) { |
1994 if (CheckSavegameVersion(58)) { |