diff options
author | frosch <frosch@openttd.org> | 2009-08-08 18:45:12 +0000 |
---|---|---|
committer | frosch <frosch@openttd.org> | 2009-08-08 18:45:12 +0000 |
commit | efcaefd178410c303ae17db17200c300e4379298 (patch) | |
tree | 1c48cba6fda8b05d4663d3164ef58d008ca7ca95 /src/train_cmd.cpp | |
parent | 87014fec05a845cc9eab22ac33b2d7e7440b0dcc (diff) | |
download | openttd-efcaefd178410c303ae17db17200c300e4379298.tar.xz |
(svn r17121) -Fix [FS#3060]: Update vehicle position cache when the vehicle sprite changes.
Diffstat (limited to 'src/train_cmd.cpp')
-rw-r--r-- | src/train_cmd.cpp | 22 |
1 files changed, 6 insertions, 16 deletions
diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp index 4c4f142d6..b0cb85ff4 100644 --- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -1620,13 +1620,6 @@ void Train::UpdateDeltaXY(Direction direction) this->z_extent = 6; } -static void UpdateVarsAfterSwap(Train *v) -{ - v->UpdateDeltaXY(v->direction); - v->cur_image = v->GetImage(v->direction); - VehicleMove(v, true); -} - static inline void SetLastSpeed(Train *v, int spd) { int old = v->tcache.last_speed; @@ -1714,15 +1707,15 @@ static void ReverseTrainSwapVeh(Train *v, int l, int r) SwapTrainFlags(&a->flags, &b->flags); /* update other vars */ - UpdateVarsAfterSwap(a); - UpdateVarsAfterSwap(b); + a->UpdateViewport(true, true); + b->UpdateViewport(true, true); /* call the proper EnterTile function unless we are in a wormhole */ if (a->track != TRACK_BIT_WORMHOLE) VehicleEnterTile(a, a->tile, a->x_pos, a->y_pos); if (b->track != TRACK_BIT_WORMHOLE) VehicleEnterTile(b, b->tile, b->x_pos, b->y_pos); } else { if (a->track != TRACK_BIT_DEPOT) a->direction = ReverseDir(a->direction); - UpdateVarsAfterSwap(a); + a->UpdateViewport(true, true); if (a->track != TRACK_BIT_WORMHOLE) VehicleEnterTile(a, a->tile, a->x_pos, a->y_pos); } @@ -1948,7 +1941,7 @@ static void ReverseTrainDirection(Train *v) TrainConsistChanged(v, true); /* update all images */ - for (Vehicle *u = v; u != NULL; u = u->Next()) u->cur_image = u->GetImage(u->direction); + for (Vehicle *u = v; u != NULL; u = u->Next()) u->UpdateViewport(false, false); /* update crossing we were approaching */ if (crossing != INVALID_TILE) UpdateLevelCrossing(crossing); @@ -3324,8 +3317,7 @@ void Train::MarkDirty() { Vehicle *v = this; do { - v->cur_image = v->GetImage(v->direction); - MarkSingleVehicleDirty(v); + v->UpdateViewport(false, false); } while ((v = v->Next()) != NULL); /* need to update acceleration and cached values since the goods on the train changed. */ @@ -4450,9 +4442,7 @@ static bool TrainLocoHandler(Train *v, bool mode) for (Train *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); + u->UpdateViewport(false, false); } if (v->progress == 0) v->progress = j; // Save unused spd for next time, if TrainController didn't set progress |