Fix smallmap not refreshing at all when paused

pull/203/head
Jonathan G Rennison 4 years ago
parent 890e0c1198
commit 9909f9ab54

@ -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.

@ -105,7 +105,6 @@ protected:
int zoom; ///< Zoom level. Bigger number means more zoom-out (further away).
GUITimer refresh; ///< Refresh timer.
bool unpaused_since_last_redraw = false;
LinkGraphOverlay *overlay;
static void BreakIndustryChainLink();
@ -179,6 +178,7 @@ protected:
void SwitchMapType(SmallMapType map_type);
void SetNewScroll(int sx, int sy, int sub);
uint GetRefreshPeriod() const;
uint PausedAdjustRefreshTimeDelta(uint delta_ms) const;
void DrawMapIndicators() const;
void DrawSmallMapColumn(void *dst, uint xc, uint yc, int pitch, int reps, int start_pos, int end_pos, Blitter *blitter) const;

Loading…
Cancel
Save