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/vehicle_base.h | |
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/vehicle_base.h')
-rw-r--r-- | src/vehicle_base.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/vehicle_base.h b/src/vehicle_base.h index 751137889..6a72b5ead 100644 --- a/src/vehicle_base.h +++ b/src/vehicle_base.h @@ -309,6 +309,21 @@ public: virtual void OnNewDay() {}; /** + * Update vehicle sprite- and position caches + * @param moved Was the vehicle moved? + * @param turned Did the vehicle direction change? + */ + inline void UpdateViewport(bool moved, bool turned) + { + extern void VehicleMove(Vehicle *v, bool update_viewport); + + if (turned) this->UpdateDeltaXY(this->direction); + SpriteID old_image = this->cur_image; + this->cur_image = this->GetImage(this->direction); + if (moved || this->cur_image != old_image) VehicleMove(this, true); + } + + /** * Returns the Trackdir on which the vehicle is currently located. * Works for trains and ships. * Currently works only sortof for road vehicles, since they have a fuzzy |