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:
@@ -186,6 +186,7 @@ void DisasterVehicle::UpdatePosition(int x, int y, int z)
|
||||
this->z_pos = z;
|
||||
this->tile = TileVirtXY(x, y);
|
||||
|
||||
this->cur_image_valid_dir = INVALID_DIR;
|
||||
this->UpdateImage();
|
||||
this->UpdatePositionAndViewport();
|
||||
|
||||
@@ -199,6 +200,7 @@ void DisasterVehicle::UpdatePosition(int x, int y, int z)
|
||||
safe_y = Clamp(u->y_pos, 0, MapMaxY() * TILE_SIZE);
|
||||
u->z_pos = GetSlopePixelZ(safe_x, safe_y);
|
||||
u->direction = this->direction;
|
||||
u->cur_image_valid_dir = INVALID_DIR;
|
||||
|
||||
u->UpdateImage();
|
||||
u->UpdatePositionAndViewport();
|
||||
|
Reference in New Issue
Block a user