mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r3484) -fix: fixed issue in last commit where loading savegame versions 18 and 19 didn't init the multiheaded engine pointers
This commit is contained in:
parent
b7beb3d87d
commit
8c7e594b08
|
@ -1150,9 +1150,8 @@ bool AfterLoadGame(void)
|
||||||
* subtype to the new format */
|
* subtype to the new format */
|
||||||
if (CheckSavegameVersionOldStyle(17, 1)) ConvertOldMultiheadToNew();
|
if (CheckSavegameVersionOldStyle(17, 1)) ConvertOldMultiheadToNew();
|
||||||
|
|
||||||
/* Connect front and rear engines of multiheaded trains
|
/* Connect front and rear engines of multiheaded trains */
|
||||||
since this info were no longer saved in savegame version 20 */
|
ConnectMultiheadedTrains();
|
||||||
if (!CheckSavegameVersion(20)) ConnectMultiheadedTrains();
|
|
||||||
|
|
||||||
// Update current year
|
// Update current year
|
||||||
SetDate(_date);
|
SetDate(_date);
|
||||||
|
|
35
train_cmd.c
35
train_cmd.c
|
@ -3617,41 +3617,6 @@ void ConvertOldMultiheadToNew(void)
|
||||||
break;
|
break;
|
||||||
default: NOT_REACHED(); break;
|
default: NOT_REACHED(); break;
|
||||||
}
|
}
|
||||||
END_ENUM_WAGONS(u)
|
|
||||||
u = v;
|
|
||||||
BEGIN_ENUM_WAGONS(u)
|
|
||||||
const RailVehicleInfo *rvi = RailVehInfo(u->engine_type);
|
|
||||||
|
|
||||||
if (u->u.rail.other_multiheaded_part != NULL) continue;
|
|
||||||
|
|
||||||
if (rvi->flags & RVI_MULTIHEAD) {
|
|
||||||
if (!IsTrainEngine(u)) {
|
|
||||||
/* we got a rear car without a front car. We will convert it to a front one */
|
|
||||||
SetTrainEngine(u);
|
|
||||||
u->spritenum--;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
Vehicle *w;
|
|
||||||
|
|
||||||
for(w = u->next; w != NULL && (w->engine_type != u->engine_type || w->u.rail.other_multiheaded_part != NULL); w = GetNextVehicle(w));
|
|
||||||
if (w != NULL) {
|
|
||||||
/* we found a car to partner with this engine. Now we will make sure it face the right way */
|
|
||||||
if (IsTrainEngine(w)) {
|
|
||||||
ClearTrainEngine(w);
|
|
||||||
w->spritenum++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (w != NULL) {
|
|
||||||
w->u.rail.other_multiheaded_part = u;
|
|
||||||
u->u.rail.other_multiheaded_part = w;
|
|
||||||
} else {
|
|
||||||
/* we got a front car and no rear cars. We will fake this one for forget that it should have been multiheaded */
|
|
||||||
ClearMultiheaded(u);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
END_ENUM_WAGONS(u)
|
END_ENUM_WAGONS(u)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue