diff options
-rw-r--r-- | src/roadveh_cmd.cpp | 14 | ||||
-rw-r--r-- | src/train_cmd.cpp | 21 |
2 files changed, 22 insertions, 13 deletions
diff --git a/src/roadveh_cmd.cpp b/src/roadveh_cmd.cpp index eecf6741f..fa68a9247 100644 --- a/src/roadveh_cmd.cpp +++ b/src/roadveh_cmd.cpp @@ -1248,7 +1248,6 @@ static bool RoadVehLeaveDepot(Vehicle *v, bool first) v->u.road.state = tdir; v->u.road.frame = RVC_DEPOT_START_FRAME; - v->cur_image = v->GetImage(v->direction); v->UpdateDeltaXY(v->direction); SetRoadVehPosition(v, x, y); @@ -1377,7 +1376,6 @@ static bool IndividualRoadVehicleController(Vehicle *v, const Vehicle *prev) if (IsTileType(gp.new_tile, MP_TUNNELBRIDGE) && HasBit(VehicleEnterTile(v, gp.new_tile, gp.x, gp.y), VETS_ENTERED_WORMHOLE)) { /* Vehicle has just entered a bridge or tunnel */ - v->cur_image = v->GetImage(v->direction); v->UpdateDeltaXY(v->direction); SetRoadVehPosition(v, gp.x, gp.y); return true; @@ -1524,7 +1522,6 @@ again: v->cur_speed -= v->cur_speed >> 2; } - v->cur_image = v->GetImage(v->direction); v->UpdateDeltaXY(v->direction); RoadZPosAffectSpeed(v, SetRoadVehPosition(v, x, y)); return true; @@ -1590,7 +1587,6 @@ again: v->cur_speed -= v->cur_speed >> 2; } - v->cur_image = v->GetImage(v->direction); v->UpdateDeltaXY(v->direction); RoadZPosAffectSpeed(v, SetRoadVehPosition(v, x, y)); return true; @@ -1631,7 +1627,6 @@ again: v->cur_speed -= (v->cur_speed >> 2); if (old_dir != v->u.road.state) { /* The vehicle is in a road stop */ - v->cur_image = v->GetImage(v->direction); v->UpdateDeltaXY(v->direction); SetRoadVehPosition(v, v->x_pos, v->y_pos); /* Note, return here means that the frame counter is not incremented @@ -1755,7 +1750,6 @@ again: * in a depot or entered a tunnel/bridge */ if (!HasBit(r, VETS_ENTERED_WORMHOLE)) v->u.road.frame++; - v->cur_image = v->GetImage(v->direction); v->UpdateDeltaXY(v->direction); RoadZPosAffectSpeed(v, SetRoadVehPosition(v, x, y)); return true; @@ -1813,6 +1807,14 @@ static void RoadVehController(Vehicle *v) if (j >= adv_spd && RoadVehCheckTrainCrash(v)) break; } + for (Vehicle *u = v; u != NULL; u = u->Next()) { + if ((u->vehstatus & VS_HIDDEN) != 0) continue; + + uint16 old_image = u->cur_image; + u->cur_image = u->GetImage(u->direction); + if (old_image != u->cur_image) VehicleMove(u, true); + } + if (v->progress == 0) v->progress = j; } diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp index 8b268fd31..8cccb6763 100644 --- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -39,7 +39,7 @@ static Track ChooseTrainTrack(Vehicle *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks, bool force_res, bool *got_reservation, bool mark_stuck); static bool TrainCheckIfLineEnds(Vehicle *v); -static void TrainController(Vehicle *v, Vehicle *nomove, bool update_image); +static void TrainController(Vehicle *v, Vehicle *nomove); static TileIndex TrainApproachingCrossingTile(const Vehicle *v); static void CheckIfTrainNeedsService(Vehicle *v); static void CheckNextTrainTile(Vehicle *v); @@ -1760,7 +1760,7 @@ static void AdvanceWagonsBeforeSwap(Vehicle *v) /* do not update images now * negative differential will be handled in AdvanceWagonsAfterSwap() */ - for (int i = 0; i < differential; i++) TrainController(first, last->Next(), false); + for (int i = 0; i < differential; i++) TrainController(first, last->Next()); base = first; // == base->Next() length -= 2; @@ -1790,7 +1790,7 @@ static void AdvanceWagonsAfterSwap(Vehicle *v) if (d <= 0) { leave->vehstatus &= ~VS_HIDDEN; // move it out of the depot leave->u.rail.track = TrackToTrackBits(GetRailDepotTrack(leave->tile)); - for (int i = 0; i >= d; i--) TrainController(leave, NULL, false); // maybe move it, and maybe let another wagon leave + for (int i = 0; i >= d; i--) TrainController(leave, NULL); // maybe move it, and maybe let another wagon leave } } else { dep = NULL; // no vehicle in a depot, so no vehicle leaving a depot @@ -1819,7 +1819,7 @@ static void AdvanceWagonsAfterSwap(Vehicle *v) int differential = last->u.rail.cached_veh_length - base->u.rail.cached_veh_length; /* do not update images now */ - for (int i = 0; i < differential; i++) TrainController(first, (nomove ? last->Next() : NULL), false); + for (int i = 0; i < differential; i++) TrainController(first, (nomove ? last->Next() : NULL)); base = first; // == base->Next() length -= 2; @@ -3639,7 +3639,7 @@ static Vehicle *CheckVehicleAtSignal(Vehicle *v, void *data) return NULL; } -static void TrainController(Vehicle *v, Vehicle *nomove, bool update_image) +static void TrainController(Vehicle *v, Vehicle *nomove) { Vehicle *prev; @@ -3841,7 +3841,6 @@ static void TrainController(Vehicle *v, Vehicle *nomove, bool update_image) /* update image of train, as well as delta XY */ v->UpdateDeltaXY(v->direction); - if (update_image) v->cur_image = v->GetImage(v->direction); v->x_pos = gp.x; v->y_pos = gp.y; @@ -4340,7 +4339,7 @@ static void TrainLocoHandler(Vehicle *v, bool mode) /* Loop until the train has finished moving. */ do { j -= adv_spd; - TrainController(v, NULL, true); + TrainController(v, NULL); /* Don't continue to move if the train crashed. */ if (CheckTrainCollision(v)) break; /* 192 spd used for going straight, 256 for going diagonally. */ @@ -4349,6 +4348,14 @@ static void TrainLocoHandler(Vehicle *v, bool mode) SetLastSpeed(v, v->cur_speed); } + for (Vehicle *u = v; u != NULL; u = u->Next()) { + if ((u->vehstatus & VS_HIDDEN) != 0) continue; + + uint16 old_image = u->cur_image; + u->cur_image = u->GetImage(u->direction); + if (old_image != u->cur_image) VehicleMove(u, true); + } + if (v->progress == 0) v->progress = j; // Save unused spd for next time, if TrainController didn't set progress } |