From adc5363202629aa07c762f459d7e9f5bc78efa34 Mon Sep 17 00:00:00 2001 From: smatz Date: Wed, 1 Jul 2009 22:22:01 +0000 Subject: (svn r16717) -Codechange: make IsFrontEngine() member of Train --- src/saveload/afterload.cpp | 4 ++-- src/saveload/vehicle_sl.cpp | 15 +++++++++------ 2 files changed, 11 insertions(+), 8 deletions(-) (limited to 'src/saveload') diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp index c5534ddae..7defed1e6 100644 --- a/src/saveload/afterload.cpp +++ b/src/saveload/afterload.cpp @@ -985,7 +985,7 @@ bool AfterLoadGame() } FOR_ALL_TRAINS(v) { - if (IsFrontEngine(v) || IsFreeWagon(v)) TrainConsistChanged(v, true); + if (v->IsFrontEngine() || IsFreeWagon(v)) TrainConsistChanged(v, true); } } @@ -1344,7 +1344,7 @@ bool AfterLoadGame() Vehicle *v; /* Added a FIFO queue of vehicles loading at stations */ FOR_ALL_VEHICLES(v) { - if ((v->type != VEH_TRAIN || IsFrontEngine(v)) && // for all locs + if ((v->type != VEH_TRAIN || Train::From(v)->IsFrontEngine()) && // for all locs !(v->vehstatus & (VS_STOPPED | VS_CRASHED)) && // not stopped or crashed v->current_order.IsType(OT_LOADING)) { // loading Station::Get(v->last_station_visited)->loading_vehicles.push_back(v); diff --git a/src/saveload/vehicle_sl.cpp b/src/saveload/vehicle_sl.cpp index cc1cb4326..3525d2591 100644 --- a/src/saveload/vehicle_sl.cpp +++ b/src/saveload/vehicle_sl.cpp @@ -28,7 +28,7 @@ void ConnectMultiheadedTrains() } FOR_ALL_TRAINS(v) { - if (IsFrontEngine(v) || IsFreeWagon(v)) { + if (v->IsFrontEngine() || IsFreeWagon(v)) { /* Two ways to associate multiheaded parts to each other: * sequential-matching: Trains shall be arranged to look like <..>..<..>..<..>.. * bracket-matching: Free vehicle chains shall be arranged to look like ..<..<..>..<..>..>.. @@ -42,7 +42,7 @@ void ConnectMultiheadedTrains() * This is why two matching strategies are needed. */ - bool sequential_matching = IsFrontEngine(v); + bool sequential_matching = v->IsFrontEngine(); for (Train *u = v; u != NULL; u = GetNextVehicle(u)) { if (u->other_multiheaded_part != NULL) continue; // we already linked this one @@ -308,9 +308,12 @@ void AfterLoadVehicles(bool part_of_load) FOR_ALL_VEHICLES(v) { assert(v->first != NULL); - if (v->type == VEH_TRAIN && (IsFrontEngine(v) || IsFreeWagon(v))) { - if (IsFrontEngine(v)) Train::From(v)->tcache.last_speed = v->cur_speed; // update displayed train speed - TrainConsistChanged(Train::From(v), false); + if (v->type == VEH_TRAIN) { + Train *t = Train::From(v); + if (t->IsFrontEngine() || IsFreeWagon(t)) { + t->tcache.last_speed = t->cur_speed; // update displayed train speed + TrainConsistChanged(t, false); + } } else if (v->type == VEH_ROAD && IsRoadVehFront(v)) { RoadVehUpdateCache(RoadVehicle::From(v)); } @@ -319,7 +322,7 @@ void AfterLoadVehicles(bool part_of_load) /* Stop non-front engines */ if (CheckSavegameVersion(112)) { FOR_ALL_VEHICLES(v) { - if (v->type == VEH_TRAIN && !IsFrontEngine(v)) { + if (v->type == VEH_TRAIN && !Train::From(v)->IsFrontEngine()) { if (IsTrainEngine(v)) v->vehstatus |= VS_STOPPED; /* cur_speed is now relevant for non-front parts - nonzero breaks * moving-wagons-inside-depot- and autoreplace- code */ -- cgit v1.2.3-54-g00ecf