@@ -1618,55 +1618,61 @@ void Vehicle::UpdateBoundingBoxCoordinat
if (update_cache) {
/*
* If the old coordinates are invalid, set the cache to the new coordinates for correct
* behaviour the next time the coordinate cache is checked.
*/
this->sprite_cache.old_coord = this->coord.left == INVALID_COORD ? new_coord : this->coord;
}
else {
/* Extend the bounds of the existing cached bounding box so the next dirty window is correct */
this->sprite_cache.old_coord.left = std::min(this->sprite_cache.old_coord.left, this->coord.left);
this->sprite_cache.old_coord.top = std::min(this->sprite_cache.old_coord.top, this->coord.top);
this->sprite_cache.old_coord.right = std::max(this->sprite_cache.old_coord.right, this->coord.right);
this->sprite_cache.old_coord.bottom = std::max(this->sprite_cache.old_coord.bottom, this->coord.bottom);
this->coord = new_coord;
/**
* Update the vehicle on the viewport, updating the right hash and setting the new coordinates.
* @param dirty Mark the (new and old) coordinates of the vehicle as dirty.
void Vehicle::UpdateViewport(bool dirty)
{
Rect old_coord = this->sprite_cache.old_coord;
/* If the existing cache is invalid we should ignore it, as it will be set to the current coords by UpdateBoundingBoxCoordinates */
bool ignore_cached_coords = this->sprite_cache.old_coord.left == INVALID_COORD;
this->UpdateBoundingBoxCoordinates(true);
UpdateVehicleViewportHash(this, this->coord.left, this->coord.top, old_coord.left, old_coord.top);
if (ignore_cached_coords) {
UpdateVehicleViewportHash(this, this->coord.left, this->coord.top, INVALID_COORD, INVALID_COORD);
} else {
UpdateVehicleViewportHash(this, this->coord.left, this->coord.top, this->sprite_cache.old_coord.left, this->sprite_cache.old_coord.top);
if (dirty) {
if (old_coord.left == INVALID_COORD) {
this->sprite_cache.is_viewport_candidate = this->MarkAllViewportsDirty();
this->sprite_cache.is_viewport_candidate = ::MarkAllViewportsDirty(
std::min(this->sprite_cache.old_coord.left, this->coord.left),
std::min(this->sprite_cache.old_coord.top, this->coord.top),
std::max(this->sprite_cache.old_coord.right, this->coord.right),
std::max(this->sprite_cache.old_coord.bottom, this->coord.bottom));
* Update the position of the vehicle, and update the viewport.
void Vehicle::UpdatePositionAndViewport()
this->UpdatePosition();
this->UpdateViewport(true);
* Marks viewports dirty where the vehicle's image is.
* @return true if at least one viewport has a dirty block
Status change: