changeset 19953:e7954aa34d47 draft

-Codechange: [Win32] Refactor code to detect a Win9x OS version into a function.
author Michael Lutz <michi@icosahedron.de>
date Thu, 15 Nov 2012 22:03:46 +0100
parents 5e7bacb2a8d8
children 1593a72bcfaa
files src/os/windows/win32.cpp src/os/windows/win32.h
diffstat 2 files changed, 12 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/os/windows/win32.cpp
+++ b/src/os/windows/win32.cpp
@@ -437,7 +437,7 @@
 
 #if !defined(WINCE)
 	/* Check if a win9x user started the win32 version */
-	if (HasBit(GetVersion(), 31)) usererror("This version of OpenTTD doesn't run on windows 95/98/ME.\nPlease download the win9x binary and try again.");
+	if (IsWindows9x()) usererror("This version of OpenTTD doesn't run on windows 95/98/ME.\nPlease download the win9x binary and try again.");
 #endif
 
 	/* For UNICODE we need to convert the commandline to char* _AND_
--- a/src/os/windows/win32.h
+++ b/src/os/windows/win32.h
@@ -12,6 +12,8 @@
 #ifndef WIN32_H
 #define WIN32_H
 
+#include "../../core/bitmath_func.hpp"
+
 #include <windows.h>
 bool MyShowCursor(bool show, bool toggle = false);
 
@@ -52,4 +54,13 @@
 #define SHGFP_TYPE_CURRENT 0
 #endif /* __MINGW32__ */
 
+/**
+ * Is the current Windows version part of the Windows 9x line?
+ * @return True if the current Windows is a 9x Windows.
+ */
+static inline bool IsWindows9x()
+{
+	return HasBit(GetVersion(), 31);
+}
+
 #endif /* WIN32_H */