Mercurial > hg > openttd
comparison src/saveload/afterload.cpp @ 12034:aa140a9c419c draft
(svn r16441) -Codechange: new class SpecializedVehicle used as superclass for all vehicle types
author | smatz <smatz@openttd.org> |
---|---|
date | Tue, 26 May 2009 22:10:13 +0000 |
parents | 2afeb10ae6ba |
children | dcc31c1d758a |
comparison
equal
deleted
inserted
replaced
12033:3a06a1a551f5 | 12034:aa140a9c419c |
---|---|
919 } | 919 } |
920 } | 920 } |
921 | 921 |
922 /* Elrails got added in rev 24 */ | 922 /* Elrails got added in rev 24 */ |
923 if (CheckSavegameVersion(24)) { | 923 if (CheckSavegameVersion(24)) { |
924 Vehicle *v; | |
925 RailType min_rail = RAILTYPE_ELECTRIC; | 924 RailType min_rail = RAILTYPE_ELECTRIC; |
926 | 925 |
927 FOR_ALL_VEHICLES(v) { | 926 Train *v; |
928 if (v->type == VEH_TRAIN) { | 927 FOR_ALL_TRAINS(v) { |
929 RailType rt = RailVehInfo(v->engine_type)->railtype; | 928 RailType rt = RailVehInfo(v->engine_type)->railtype; |
930 | 929 |
931 ((Train *)v)->railtype = rt; | 930 v->railtype = rt; |
932 if (rt == RAILTYPE_ELECTRIC) min_rail = RAILTYPE_RAIL; | 931 if (rt == RAILTYPE_ELECTRIC) min_rail = RAILTYPE_RAIL; |
933 } | |
934 } | 932 } |
935 | 933 |
936 /* .. so we convert the entire map from normal to elrail (so maintain "fairness") */ | 934 /* .. so we convert the entire map from normal to elrail (so maintain "fairness") */ |
937 for (TileIndex t = 0; t < map_size; t++) { | 935 for (TileIndex t = 0; t < map_size; t++) { |
938 switch (GetTileType(t)) { | 936 switch (GetTileType(t)) { |
961 default: | 959 default: |
962 break; | 960 break; |
963 } | 961 } |
964 } | 962 } |
965 | 963 |
966 FOR_ALL_VEHICLES(v) { | 964 FOR_ALL_TRAINS(v) { |
967 if (v->type == VEH_TRAIN && (IsFrontEngine(v) || IsFreeWagon(v))) TrainConsistChanged((Train *)v, true); | 965 if (IsFrontEngine(v) || IsFreeWagon(v)) TrainConsistChanged(v, true); |
968 } | 966 } |
969 | 967 |
970 } | 968 } |
971 | 969 |
972 /* In version 16.1 of the savegame a company can decide if trains, which get | 970 /* In version 16.1 of the savegame a company can decide if trains, which get |
1044 } | 1042 } |
1045 } | 1043 } |
1046 } | 1044 } |
1047 | 1045 |
1048 if (CheckSavegameVersion(25)) { | 1046 if (CheckSavegameVersion(25)) { |
1049 Vehicle *v; | 1047 RoadVehicle *rv; |
1050 FOR_ALL_VEHICLES(v) { | 1048 FOR_ALL_ROADVEHICLES(rv) { |
1051 if (v->type == VEH_ROAD) { | 1049 rv->vehstatus &= ~0x40; |
1052 RoadVehicle *rv = (RoadVehicle *)v; | 1050 rv->slot = NULL; |
1053 rv->vehstatus &= ~0x40; | 1051 rv->slot_age = 0; |
1054 rv->slot = NULL; | |
1055 rv->slot_age = 0; | |
1056 } | |
1057 } | 1052 } |
1058 } else { | 1053 } else { |
1059 Vehicle *v; | 1054 RoadVehicle *rv; |
1060 FOR_ALL_VEHICLES(v) { | 1055 FOR_ALL_ROADVEHICLES(rv) { |
1061 if (v->type != VEH_ROAD) continue; | |
1062 RoadVehicle *rv = (RoadVehicle *)v; | |
1063 if (rv->slot != NULL) rv->slot->num_vehicles++; | 1056 if (rv->slot != NULL) rv->slot->num_vehicles++; |
1064 } | 1057 } |
1065 } | 1058 } |
1066 | 1059 |
1067 if (CheckSavegameVersion(26)) { | 1060 if (CheckSavegameVersion(26)) { |
1380 } | 1373 } |
1381 } | 1374 } |
1382 | 1375 |
1383 if (CheckSavegameVersion(69)) { | 1376 if (CheckSavegameVersion(69)) { |
1384 /* In some old savegames a bit was cleared when it should not be cleared */ | 1377 /* In some old savegames a bit was cleared when it should not be cleared */ |
1385 Vehicle *v; | 1378 RoadVehicle *rv; |
1386 FOR_ALL_VEHICLES(v) { | 1379 FOR_ALL_ROADVEHICLES(rv) { |
1387 if (v->type != VEH_ROAD) continue; | |
1388 RoadVehicle *rv = (RoadVehicle *)v; | |
1389 if (rv->state == 250 || rv->state == 251) { | 1380 if (rv->state == 250 || rv->state == 251) { |
1390 SetBit(rv->state, RVS_IS_STOPPING); | 1381 SetBit(rv->state, RVS_IS_STOPPING); |
1391 } | 1382 } |
1392 } | 1383 } |
1393 } | 1384 } |
1706 } | 1697 } |
1707 } | 1698 } |
1708 | 1699 |
1709 /* Reserve all tracks trains are currently on. */ | 1700 /* Reserve all tracks trains are currently on. */ |
1710 if (CheckSavegameVersion(101)) { | 1701 if (CheckSavegameVersion(101)) { |
1711 Vehicle *u; | 1702 Train *t; |
1712 FOR_ALL_VEHICLES(u) { | 1703 FOR_ALL_TRAINS(t) { |
1713 if (u->type == VEH_TRAIN) { | 1704 if ((t->track & TRACK_BIT_WORMHOLE) == TRACK_BIT_WORMHOLE) { |
1714 Train *v = (Train *)u; | 1705 TryReserveRailTrack(t->tile, DiagDirToDiagTrack(GetTunnelBridgeDirection(t->tile))); |
1715 if ((v->track & TRACK_BIT_WORMHOLE) == TRACK_BIT_WORMHOLE) { | 1706 } else if ((t->track & TRACK_BIT_MASK) != TRACK_BIT_NONE) { |
1716 TryReserveRailTrack(v->tile, DiagDirToDiagTrack(GetTunnelBridgeDirection(v->tile))); | 1707 TryReserveRailTrack(t->tile, TrackBitsToTrack(t->track)); |
1717 } else if ((v->track & TRACK_BIT_MASK) != TRACK_BIT_NONE) { | |
1718 TryReserveRailTrack(v->tile, TrackBitsToTrack(v->track)); | |
1719 } | |
1720 } | 1708 } |
1721 } | 1709 } |
1722 } | 1710 } |
1723 | 1711 |
1724 if (CheckSavegameVersion(102)) { | 1712 if (CheckSavegameVersion(102)) { |