summaryrefslogtreecommitdiff
path: root/src/smallmap_gui.cpp
diff options
context:
space:
mode:
authorsmatz <smatz@openttd.org>2009-10-20 17:36:06 +0000
committersmatz <smatz@openttd.org>2009-10-20 17:36:06 +0000
commit49d0db19a4fad2935276e61a3e60acc3e5e12dc2 (patch)
treef10660c4cf938138e3c72e8a6d4700c1351d1838 /src/smallmap_gui.cpp
parent86031d434d11bb531a1a79239530e81f6627976b (diff)
downloadopenttd-49d0db19a4fad2935276e61a3e60acc3e5e12dc2.tar.xz
(svn r17819) -Codechange: replace magic constant by symbolic constant
Diffstat (limited to 'src/smallmap_gui.cpp')
-rw-r--r--src/smallmap_gui.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/smallmap_gui.cpp b/src/smallmap_gui.cpp
index 56ce1378b..535b72072 100644
--- a/src/smallmap_gui.cpp
+++ b/src/smallmap_gui.cpp
@@ -562,7 +562,9 @@ class SmallMapWindow : public Window
int32 scroll_x;
int32 scroll_y;
int32 subscroll;
- uint8 refresh;
+
+ static const uint8 FORCE_REFRESH_PERIOD = 0x1F; ///< map is redrawn after that many ticks
+ uint8 refresh; ///< refresh counter, zeroed every FORCE_REFRESH_PERIOD ticks
static const int COLUMN_WIDTH = 119;
static const int MIN_LEGEND_HEIGHT = 6 * 7;
@@ -874,7 +876,7 @@ public:
}
}
- SmallMapWindow(const WindowDesc *desc, int window_number) : Window(desc, window_number)
+ SmallMapWindow(const WindowDesc *desc, int window_number) : Window(desc, window_number), refresh(FORCE_REFRESH_PERIOD)
{
this->LowerWidget(this->map_type + SM_WIDGET_CONTOUR);
this->SetWidgetLoweredState(SM_WIDGET_TOGGLETOWNNAME, this->show_towns);
@@ -1050,7 +1052,10 @@ public:
virtual void OnTick()
{
/* update the window every now and then */
- if ((++this->refresh & 0x1F) == 0) this->SetDirty();
+ if (--this->refresh != 0) return;
+
+ this->refresh = FORCE_REFRESH_PERIOD;
+ this->SetDirty();
}
virtual void OnScroll(Point delta)