Cache the result of GetImage() in Vehicle::UpdateViewport() where possible.

Sprite number is not cached if callback is made, or a variable access
outside a whitelist occurs.
Invalidate cached sprite number when direction or cargo changes,
or vehicle is marked dirty.
This commit is contained in:
Jonathan G Rennison
2016-07-08 19:07:25 +01:00
parent 9ae057b8bf
commit 3ac94e97c8
9 changed files with 65 additions and 1 deletions

View File

@@ -408,6 +408,7 @@ void RoadVehicle::MarkDirty()
{
for (RoadVehicle *v = this; v != NULL; v = v->Next()) {
v->colourmap = PAL_NONE;
v->cur_image_valid_dir = INVALID_DIR;
v->UpdateViewport(true, false);
}
this->CargoChanged();