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:
@@ -108,6 +108,7 @@ void GroundVehicle<T, Type>::CargoChanged()
|
||||
weight += current_weight;
|
||||
/* Slope steepness is in percent, result in N. */
|
||||
u->gcache.cached_slope_resistance = current_weight * u->GetSlopeSteepness() * 100;
|
||||
u->cur_image_valid_dir = INVALID_DIR;
|
||||
}
|
||||
|
||||
/* Store consist weight in cache. */
|
||||
|
Reference in New Issue
Block a user