changeset 13310:aa1ec5b3bac4 draft

(svn r17819) -Codechange: replace magic constant by symbolic constant
author smatz <smatz@openttd.org>
date Tue, 20 Oct 2009 17:36:06 +0000
parents f571faf401af
children 0f3dd8ac5336
files src/smallmap_gui.cpp
diffstat 1 files changed, 8 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/smallmap_gui.cpp
+++ b/src/smallmap_gui.cpp
@@ -562,7 +562,9 @@
 	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 @@
 		}
 	}
 
-	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 @@
 	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)