Fix smallmap not refreshing at all when paused

This commit is contained in:
Jonathan G Rennison
2020-10-25 17:47:38 +00:00
parent 890e0c1198
commit 9909f9ab54
2 changed files with 20 additions and 4 deletions

View File

@@ -1499,10 +1499,10 @@ int SmallMapWindow::GetPositionOnLegend(Point pt)
/* virtual */ void SmallMapWindow::OnRealtimeTick(uint delta_ms)
{
if (_pause_mode == PM_UNPAUSED) this->unpaused_since_last_redraw = true;
if (_pause_mode != PM_UNPAUSED) delta_ms = this->PausedAdjustRefreshTimeDelta(delta_ms);
/* Update the window every now and then */
if (!this->unpaused_since_last_redraw || !this->refresh.Elapsed(delta_ms)) return;
if (!this->refresh.Elapsed(delta_ms)) return;
if (this->map_type == SMT_LINKSTATS) {
uint32 company_mask = this->GetOverlayCompanyMask();
@@ -1516,7 +1516,6 @@ int SmallMapWindow::GetPositionOnLegend(Point pt)
this->refresh.SetInterval(this->GetRefreshPeriod());
this->SetDirty();
this->unpaused_since_last_redraw = false;
}
uint SmallMapWindow::GetRefreshPeriod() const
@@ -1536,6 +1535,23 @@ uint SmallMapWindow::GetRefreshPeriod() const
}
}
uint SmallMapWindow::PausedAdjustRefreshTimeDelta(uint delta_ms) const
{
if (_smallmap_industry_highlight != INVALID_INDUSTRYTYPE) return delta_ms;
switch (map_type) {
case SMT_CONTOUR:
case SMT_VEHICLES:
return CeilDivT<uint>(delta_ms, 4);
case SMT_LINKSTATS:
return delta_ms;
default:
return CeilDivT<uint>(delta_ms, 2);
}
}
/**
* Set new #scroll_x, #scroll_y, and #subscroll values after limiting them such that the center
* of the smallmap always contains a part of the map.