(svn r17121) -Fix [FS#3060]: Update vehicle position cache when the vehicle sprite changes.

This commit is contained in:
frosch
2009-08-08 18:45:12 +00:00
parent 0644123d51
commit 32a47df09a
5 changed files with 38 additions and 52 deletions

View File

@@ -308,6 +308,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.