diff options
Diffstat (limited to 'src/main_gui.cpp')
-rw-r--r-- | src/main_gui.cpp | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/main_gui.cpp b/src/main_gui.cpp index 350439ce1..9d13deef6 100644 --- a/src/main_gui.cpp +++ b/src/main_gui.cpp @@ -253,11 +253,17 @@ struct MainWindow : Window virtual void OnTick() { - if (--refresh == 0) { - this->viewport->overlay->RebuildCache(); - this->GetWidget<NWidgetBase>(WID_M_VIEWPORT)->SetDirty(this); - this->refresh = LINKGRAPH_REFRESH_PERIOD; + if (--this->refresh > 0) return; + + this->refresh = LINKGRAPH_REFRESH_PERIOD; + + if (this->viewport->overlay->GetCargoMask() == 0 || + this->viewport->overlay->GetCompanyMask() == 0) { + return; } + + this->viewport->overlay->RebuildCache(); + this->GetWidget<NWidgetBase>(WID_M_VIEWPORT)->SetDirty(this); } virtual void OnPaint() |