From: <rel...@us...> - 2008-07-05 12:59:11
|
Revision: 213 http://modplug.svn.sourceforge.net/modplug/?rev=213&view=rev Author: relabsoluness Date: 2008-07-05 05:59:07 -0700 (Sat, 05 Jul 2008) Log Message: ----------- / Change to version handling along with minor changes to version information. The version related values and functions are now defined in version.h and the version resource is defined in mptrack.rc2(to be edited manually, not with Visual Studio). + Added _very_ primitive (unit) test framework and some version handling tests. Modified Paths: -------------- trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/Mainfrm.h trunk/OpenMPT/mptrack/Moddoc.cpp trunk/OpenMPT/mptrack/Mptrack.cpp trunk/OpenMPT/mptrack/Stdafx.h trunk/OpenMPT/mptrack/dlg_misc.cpp trunk/OpenMPT/mptrack/mptrack.rc trunk/OpenMPT/mptrack/mptrack.vcproj trunk/OpenMPT/mptrack/res/MPTRACK.RC2 trunk/OpenMPT/soundlib/Load_it.cpp trunk/OpenMPT/soundlib/Load_xm.cpp trunk/OpenMPT/soundlib/Sndfile.cpp Added Paths: ----------- trunk/OpenMPT/mptrack/test/ trunk/OpenMPT/mptrack/test/test.cpp trunk/OpenMPT/mptrack/test/test.h trunk/OpenMPT/mptrack/version.h Removed Paths: ------------- trunk/OpenMPT/mptrack/VersionNo.h Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2008-06-07 12:17:24 UTC (rev 212) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2008-07-05 12:59:07 UTC (rev 213) @@ -22,6 +22,7 @@ #include "MIDIMappingDialog.h" // -! NEW_FEATURE#0015 #include <direct.h> +#include "version.h" #ifdef _DEBUG #define new DEBUG_NEW @@ -598,7 +599,7 @@ dwDWORDSize = sizeof(DWORD); DWORD dwPreviousVersion; RegQueryValueEx(key, "Version", NULL, &dwREG_DWORD, (LPBYTE)&dwPreviousVersion, &dwDWORDSize); - gcsPreviousVersion=GetVersionString(dwPreviousVersion); + gcsPreviousVersion = MptVersion::ToStr(dwPreviousVersion); RegCloseKey(key); } m_pAutoSaver = new CAutoSaver(asEnabled, asInterval, asBackupHistory, asUseOriginalPath, asPath, asFileNameTemplate); @@ -619,7 +620,7 @@ #ifdef DEBUG title += CString(" DEBUG"); #endif - title += CString(" ") + GetFullVersionString(); + title += CString(" ") + MptVersion::str; SetTitle(title); OnUpdateFrameTitle(false); @@ -863,7 +864,7 @@ { CString iniFile = theApp.GetConfigFileName(); - CString version = CMainFrame::GetFullVersionString(); + CString version = MptVersion::str; WritePrivateProfileString("Version", "Version", version, iniFile); WritePrivateProfileString("Version", "InstallGUID", gcsInstallGUID, iniFile); WritePrivateProfileLong("Version", "CheckForUpdates", gnCheckForUpdates, iniFile); @@ -1632,70 +1633,7 @@ ///////////////////////////////////////////////////////////////////////////// // CMainFrame static helpers -DWORD CMainFrame::GetFullVersionNumeric() { - char szFullPath[MAX_PATH]; - DWORD dwVerHnd; - DWORD dwVerInfoSize; - // Get version information from the application - ::GetModuleFileName(NULL, szFullPath, sizeof(szFullPath)); - dwVerInfoSize = ::GetFileVersionInfoSize(szFullPath, &dwVerHnd); - if (!dwVerInfoSize) { - return 0; - } - char* pVersionInfo = new char[dwVerInfoSize]; - if (!pVersionInfo) { - return 0; - } - char* szVer = NULL; - UINT uVerLength; - if (!(::GetFileVersionInfo((LPTSTR)szFullPath, (DWORD)dwVerHnd, - (DWORD)dwVerInfoSize, (LPVOID)pVersionInfo))) { - delete[] pVersionInfo; - return 0; - } - if (!(::VerQueryValue(pVersionInfo, TEXT("\\StringFileInfo\\040904b0\\FileVersion"), - (LPVOID*)&szVer, &uVerLength))) { - delete[] pVersionInfo; - return 0; - } - - //version will be like: 1, 17, 2, 38 - CString version = szVer; - delete[] pVersionInfo; - - int v1, v2, v3, v4; - sscanf(version, "%x, %x, %x, %x", &v1, &v2, &v3, &v4); - DWORD versionLong = VERSIONNUMBER(v1, v2, v3, v4); - return versionLong; -} - -CString CMainFrame::GetFullVersionString() -//------------------------------------ -{ - return GetVersionString(GetFullVersionNumeric()); - -} - -CString CMainFrame::GetVersionString(DWORD v) -//------------------------------------------- -{ - CString version; - if (v==0) { - version = "Unknown"; - } - else { - version.Format("%X.%02X.%02X.%02X", - (v>>24)&0xFF, - (v>>16)&0xFF, - (v>>8)&0xFF, - (v)&0xFF); - } - return version; -} - - - void CMainFrame::UpdateColors() //----------------------------- { Modified: trunk/OpenMPT/mptrack/Mainfrm.h =================================================================== --- trunk/OpenMPT/mptrack/Mainfrm.h 2008-06-07 12:17:24 UTC (rev 212) +++ trunk/OpenMPT/mptrack/Mainfrm.h 2008-07-05 12:59:07 UTC (rev 213) @@ -489,9 +489,6 @@ public: static CMainFrame *GetMainFrame() { return (CMainFrame *)theApp.m_pMainWnd; } static VOID UpdateColors(); - static CString GetFullVersionString(); - static DWORD GetFullVersionNumeric(); - static CString GetVersionString(DWORD); static HICON GetModIcon() { return m_hIcon; } static HFONT GetGUIFont() { return m_hGUIFont; } static HFONT GetFixedFont() { return m_hFixedFont; } Modified: trunk/OpenMPT/mptrack/Moddoc.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.cpp 2008-06-07 12:17:24 UTC (rev 212) +++ trunk/OpenMPT/mptrack/Moddoc.cpp 2008-07-05 12:59:07 UTC (rev 213) @@ -12,6 +12,7 @@ #include "mod2wave.h" #include "mod2midi.h" #include "vstplug.h" +#include "version.h" #ifdef _DEBUG #define new DEBUG_NEW @@ -354,11 +355,11 @@ // -> DESC="channels management dlg" ReinitRecordState(); // -! NEW_FEATURE#0015 - if (m_SndFile.m_dwLastSavedWithVersion > CMainFrame::GetFullVersionNumeric()) { + if (m_SndFile.m_dwLastSavedWithVersion > MptVersion::num) { char s[256]; wsprintf(s, "Warning: this song was last saved with a more recent version of OpenMPT.\r\nSong saved with: v%s. Current version: v%s.\r\n", - CMainFrame::GetVersionString(m_SndFile.m_dwLastSavedWithVersion), - CMainFrame::GetFullVersionString()); + MptVersion::ToStr(m_SndFile.m_dwLastSavedWithVersion), + MptVersion::str); ::AfxMessageBox(s); } @@ -376,7 +377,7 @@ TCHAR fext[_MAX_EXT]=""; UINT nType = m_SndFile.m_nType, dwPacking = 0; BOOL bOk = FALSE; - m_SndFile.m_dwLastSavedWithVersion = CMainFrame::GetFullVersionNumeric(); + m_SndFile.m_dwLastSavedWithVersion = MptVersion::num; if (!lpszPathName) return FALSE; _tsplitpath(lpszPathName, NULL, NULL, NULL, fext); if (!lstrcmpi(fext, ".mod")) nType = MOD_TYPE_MOD; else Modified: trunk/OpenMPT/mptrack/Mptrack.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.cpp 2008-06-07 12:17:24 UTC (rev 212) +++ trunk/OpenMPT/mptrack/Mptrack.cpp 2008-07-05 12:59:07 UTC (rev 213) @@ -14,6 +14,8 @@ #include "hyperEdit.h" #include "bladedll.h" #include "commctrl.h" +#include "version.h" +#include "test/test.h" // rewbs.memLeak #define CRTDBG_MAP_ALLOC @@ -818,13 +820,18 @@ */ // Open settings if the previous execution was with an earlier version. - if (!cmdInfo.m_bNoSettingsOnNewVersion && CMainFrame::gcsPreviousVersion < CMainFrame::GetFullVersionString()) { + if (!cmdInfo.m_bNoSettingsOnNewVersion && MptVersion::ToNum(CMainFrame::gcsPreviousVersion) < MptVersion::num) { StopSplashScreen(); ShowChangesDialog(); m_pMainWnd->PostMessage(WM_COMMAND, ID_VIEW_OPTIONS); } EndWaitCursor(); + + #ifdef ENABLE_TESTS + MptTest::DoTests(); + #endif + return TRUE; } @@ -1602,7 +1609,7 @@ m_bmp.LoadBitmap(MAKEINTRESOURCE(IDB_MPTRACK)); wsprintf(s, "Build Date: %s", gszBuildDate); SetDlgItemText(IDC_EDIT2, s); - SetDlgItemText(IDC_EDIT3, CString("Open Modplug Tracker, version ") + CMainFrame::GetFullVersionString() + " (development build)"); + SetDlgItemText(IDC_EDIT3, CString("Open Modplug Tracker, version ") + MptVersion::str + " (development build)"); m_heContact.SetWindowText( "Contact / Discussion:\r\n\ Modified: trunk/OpenMPT/mptrack/Stdafx.h =================================================================== --- trunk/OpenMPT/mptrack/Stdafx.h 2008-06-07 12:17:24 UTC (rev 212) +++ trunk/OpenMPT/mptrack/Stdafx.h 2008-07-05 12:59:07 UTC (rev 213) @@ -76,8 +76,6 @@ #include "typedefs.h" -#define VERSIONNUMBER(v1, v2, v3, v4) ((v1 << 24) + (v2 << 16) + (v3 << 8) + v4) - //To mark string that should be translated in case of multilingual version. #define GetStrI18N(x) (x) Deleted: trunk/OpenMPT/mptrack/VersionNo.h =================================================================== --- trunk/OpenMPT/mptrack/VersionNo.h 2008-06-07 12:17:24 UTC (rev 212) +++ trunk/OpenMPT/mptrack/VersionNo.h 2008-07-05 12:59:07 UTC (rev 213) @@ -1,4 +0,0 @@ -#define FILE_VERSION 2,0,0,1 -#define PRODUCT_VERSION 2,0,0,1 -#define FILE_VERSION_STR "1, 0, 0, 1\n" -#define PRODUCT_VERSION_STR "Modplug Tracker" Modified: trunk/OpenMPT/mptrack/dlg_misc.cpp =================================================================== --- trunk/OpenMPT/mptrack/dlg_misc.cpp 2008-06-07 12:17:24 UTC (rev 212) +++ trunk/OpenMPT/mptrack/dlg_misc.cpp 2008-07-05 12:59:07 UTC (rev 213) @@ -9,6 +9,7 @@ #include "ChannelManagerDlg.h" #include ".\dlg_misc.h" #include "midi.h" +#include "version.h" #pragma warning(disable:4244) @@ -198,8 +199,8 @@ SetDlgItemText(IDC_EDIT5, "Created with:"); SetDlgItemText(IDC_EDIT6, "Last saved with:"); - SetDlgItemText(IDC_EDIT1, CMainFrame::GetVersionString(m_pSndFile->m_dwCreatedWithVersion)); - SetDlgItemText(IDC_EDIT2, CMainFrame::GetVersionString(m_pSndFile->m_dwLastSavedWithVersion)); + SetDlgItemText(IDC_EDIT1, MptVersion::ToStr(m_pSndFile->m_dwCreatedWithVersion)); + SetDlgItemText(IDC_EDIT2, MptVersion::ToStr(m_pSndFile->m_dwLastSavedWithVersion)); m_EditFlag.SetLimitText(16); Modified: trunk/OpenMPT/mptrack/mptrack.rc =================================================================== --- trunk/OpenMPT/mptrack/mptrack.rc 2008-06-07 12:17:24 UTC (rev 212) +++ trunk/OpenMPT/mptrack/mptrack.rc 2008-07-05 12:59:07 UTC (rev 213) @@ -1942,46 +1942,6 @@ ///////////////////////////////////////////////////////////////////////////// // -// Version -// - -VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,17,2,53 - PRODUCTVERSION 0,0,0,0 - FILEFLAGSMASK 0x3fL -#ifdef _DEBUG - FILEFLAGS 0x9L -#else - FILEFLAGS 0x8L -#endif - FILEOS 0x4L - FILETYPE 0x1L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904b0" - BEGIN - VALUE "CompanyName", "Olivier Lapicque / OpenMPT team" - VALUE "FileDescription", "OpenMPT / ModPlug Tracker" - VALUE "FileVersion", "1, 17, 2, 53" - VALUE "InternalName", "Modplug Tracker" - VALUE "LegalCopyright", "Copyright \xA91997-2003 Olivier Lapicque; \xA92004-2007 GPL." - VALUE "LegalTrademarks", "M.O.D.P.L.U.G" - VALUE "OriginalFilename", "mptrack.exe" - VALUE "ProductName", "OpenMPT / ModPlug Tracker" - VALUE "ProductVersion", "0, 0, 0, 0" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 1200 - END -END - - -///////////////////////////////////////////////////////////////////////////// -// // DESIGNINFO // Modified: trunk/OpenMPT/mptrack/mptrack.vcproj =================================================================== --- trunk/OpenMPT/mptrack/mptrack.vcproj 2008-06-07 12:17:24 UTC (rev 212) +++ trunk/OpenMPT/mptrack/mptrack.vcproj 2008-07-05 12:59:07 UTC (rev 213) @@ -1086,6 +1086,9 @@ RelativePath=".\typedefs.h"> </File> <File + RelativePath=".\version.h"> + </File> + <File RelativePath=".\view_com.h"> </File> <File @@ -1135,6 +1138,16 @@ </File> </Filter> </Filter> + <Filter + Name="test" + Filter=""> + <File + RelativePath=".\test\test.cpp"> + </File> + <File + RelativePath=".\test\test.h"> + </File> + </Filter> <File RelativePath=".\mptrack.reg"> </File> Modified: trunk/OpenMPT/mptrack/res/MPTRACK.RC2 =================================================================== --- trunk/OpenMPT/mptrack/res/MPTRACK.RC2 2008-06-07 12:17:24 UTC (rev 212) +++ trunk/OpenMPT/mptrack/res/MPTRACK.RC2 2008-07-05 12:59:07 UTC (rev 213) @@ -10,4 +10,51 @@ ///////////////////////////////////////////////////////////////////////////// // Add manually edited resources here... +#include "version.h" +#include <winver.h> + +#define VER_FILEVERSION VER_MAJORMAJOR,VER_MAJOR,VER_MINOR,VER_MINORMINOR +#define VER_FILEVERSION_STR STRINGIZE(VER_FILEVERSION) + +#ifndef _DEBUG + #define VER_DEBUG 0 +#else + #define VER_DEBUG VS_FF_DEBUG +#endif + +#define VER_FILEFLAGSMASK VS_FFI_FILEFLAGSMASK +#define VER_FILEFLAGS (VS_FF_PRIVATEBUILD|VS_FF_PRERELEASE|VER_DEBUG) +//Note: Changing this might need changes to BLOCK "StringFileInfo" defined below. + +VS_VERSION_INFO VERSIONINFO + FILEVERSION VER_FILEVERSION + PRODUCTVERSION VER_FILEVERSION + FILEFLAGSMASK VER_FILEFLAGSMASK + FILEFLAGS VER_FILEFLAGS + FILEOS 0x4L + FILETYPE 0x1L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "CompanyName", "Olivier Lapicque / OpenMPT team" + VALUE "FileDescription", "OpenMPT / ModPlug Tracker" + VALUE "FileVersion", VER_FILEVERSION_STR + VALUE "InternalName", "Modplug Tracker" + VALUE "LegalCopyright", "Copyright \xA91997-2003 Olivier Lapicque; \xA92004-2007 GPL." + VALUE "LegalTrademarks", "M.O.D.P.L.U.G" + VALUE "OriginalFilename", "mptrack.exe" + VALUE "PrivateBuild", "" + VALUE "ProductName", "OpenMPT / ModPlug Tracker" + VALUE "ProductVersion", VER_FILEVERSION_STR + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END + ///////////////////////////////////////////////////////////////////////////// Added: trunk/OpenMPT/mptrack/test/test.cpp =================================================================== --- trunk/OpenMPT/mptrack/test/test.cpp (rev 0) +++ trunk/OpenMPT/mptrack/test/test.cpp 2008-07-05 12:59:07 UTC (rev 213) @@ -0,0 +1,125 @@ +/* + * Miscellaneous (unit) tests. + * + */ + +#include "stdafx.h" +#include "test.h" +#include "../version.h" +#include "../misc_util.h" + +#ifdef ENABLE_TESTS + +namespace MptTest +{ + +//Verify that given parameters are 'equal'(show error message if not). +//The exact meaning of equality is not specified; for now using operator!=. +//The macro is active in both 'debug' and 'release' build. +#define VERIFY_EQUAL(x,y) \ + if((x) != (y)) \ + { \ + CString str; \ + str.Format("File: " STRINGIZE(__FILE__) "\nLine: " STRINGIZE(__LINE__) "\n\nVERIFY_EQUAL failed when comparing\n" #x "\nand\n" #y); \ + MessageBox(0, str, "VERIFY_EQUAL failed", MB_ICONERROR); \ + } + + +#define DO_TEST(func) \ +try \ +{ \ + func(); \ +} \ +catch(const std::exception& e) \ +{ \ + MessageBox(0, CString("Test \"" STRINGIZE(func) "\" threw an exception, message: ") + e.what(), "Test \"" STRINGIZE(func) "\": Exception was thrown", MB_ICONERROR); \ +} \ +catch(...) \ +{ \ + MessageBox(0, CString("Test \"" STRINGIZE(func) "\" threw an unknown exception."), "Test \"" STRINGIZE(func) "\": Exception was thrown", MB_ICONERROR); \ +} + + +void TestVersion(); + + + + +void DoTests() +//------------ +{ + DO_TEST(TestVersion); + + MessageBox(0, "Tests were run", "Testing", MB_ICONINFORMATION); +} + +void TestVersion() +//---------------- +{ + //Verify that macros and functions work. + { + VERIFY_EQUAL( MPT_VERSION_NUMERIC, MptVersion::num ); + VERIFY_EQUAL( CString(MPT_VERSION_STR), CString(MptVersion::str) ); + VERIFY_EQUAL( MptVersion::ToNum(MptVersion::ToStr(MptVersion::num)), MptVersion::num ); + VERIFY_EQUAL( MptVersion::ToStr(MptVersion::ToNum(MptVersion::str)), MptVersion::str ); + VERIFY_EQUAL( MptVersion::ToStr(18285096), "1.17.02.28" ); + VERIFY_EQUAL( MptVersion::ToNum("1.17.02.28"), 18285096 ); + VERIFY_EQUAL( MptVersion::ToNum(MptVersion::str), MptVersion::num ); + VERIFY_EQUAL( MptVersion::ToStr(MptVersion::num), MptVersion::str ); + STATIC_ASSERT( MAKE_VERSION_NUMERIC(1,17,2,28) == 18285096 ); + STATIC_ASSERT( MAKE_VERSION_NUMERIC(1,17,02,48) == 18285128 ); + STATIC_ASSERT( MAKE_VERSION_NUMERIC(01,17,02,52) == 18285138 ); + } + + //Verify that the version obtained from the executable file is the same as + //defined in MptVersion. + { + char szFullPath[MAX_PATH]; + DWORD dwVerHnd; + DWORD dwVerInfoSize; + + // Get version information from the application + ::GetModuleFileName(NULL, szFullPath, sizeof(szFullPath)); + dwVerInfoSize = ::GetFileVersionInfoSize(szFullPath, &dwVerHnd); + if (!dwVerInfoSize) + throw std::runtime_error("!dwVerInfoSize is true"); + + char* pVersionInfo = new char[dwVerInfoSize]; + if (!pVersionInfo) + throw std::runtime_error("!pVersionInfo is true"); + + char* szVer = NULL; + UINT uVerLength; + if (!(::GetFileVersionInfo((LPTSTR)szFullPath, (DWORD)dwVerHnd, + (DWORD)dwVerInfoSize, (LPVOID)pVersionInfo))) { + delete[] pVersionInfo; + throw std::runtime_error("GetFileVersionInfo() returned false"); + } + if (!(::VerQueryValue(pVersionInfo, TEXT("\\StringFileInfo\\040904b0\\FileVersion"), + (LPVOID*)&szVer, &uVerLength))) { + delete[] pVersionInfo; + throw std::runtime_error("VerQueryValue() returned false"); + } + + CString version = szVer; + delete[] pVersionInfo; + + //version string should be like: 1,17,2,38 Change ',' to '.' to get format 1.17.2.38 + version.Replace(',', '.'); + + VERIFY_EQUAL( version, MptVersion::str ); + VERIFY_EQUAL( MptVersion::ToNum(version), MptVersion::num ); + } +} + +}; //Namespace MptTest + +#else //Case: ENABLE_TESTS is not defined. + +namespace MptTest +{ + void DoTests() {} +}; + +#endif + Added: trunk/OpenMPT/mptrack/test/test.h =================================================================== --- trunk/OpenMPT/mptrack/test/test.h (rev 0) +++ trunk/OpenMPT/mptrack/test/test.h 2008-07-05 12:59:07 UTC (rev 213) @@ -0,0 +1,11 @@ +#ifndef _TEST_H +#define _TEST_H + +//#define ENABLE_TESTS + +namespace MptTest +{ + void DoTests(); +}; + +#endif // _TEST_H Added: trunk/OpenMPT/mptrack/version.h =================================================================== --- trunk/OpenMPT/mptrack/version.h (rev 0) +++ trunk/OpenMPT/mptrack/version.h 2008-07-05 12:59:07 UTC (rev 213) @@ -0,0 +1,58 @@ +/* + * Version related stuff. + * + */ + +#ifndef _VERSION_H +#define _VERSION_H + +//STRINGIZE makes a string of given argument. If used with #defined value, +//the string is made of the contents of the defined value. +#define HELPER_STRINGIZE(x) #x +#define STRINGIZE(x) HELPER_STRINGIZE(x) + +//Version definitions. The only thing that needs to be changed when changing version number. +#define VER_MAJORMAJOR 1 +#define VER_MAJOR 17 +#define VER_MINOR 02 +#define VER_MINORMINOR 53 + +//Creates version number from version parts that appears in version string. +//For example MAKE_VERSION_NUMERIC(1,17,02,28) gives version number of +//version 1.17.02.28. +#define MAKE_VERSION_NUMERIC(v0,v1,v2,v3) ((0x##v0 << 24) + (0x##v1<<16) + (0x##v2<<8) + (0x##v3)) + +//Version string. For example "1.17.02.28" +#define MPT_VERSION_STR STRINGIZE(VER_MAJORMAJOR)"."STRINGIZE(VER_MAJOR)"."STRINGIZE(VER_MINOR)"."STRINGIZE(VER_MINORMINOR) + +//Numerical value of the version. +#define MPT_VERSION_NUMERIC MAKE_VERSION_NUMERIC(VER_MAJORMAJOR,VER_MAJOR,VER_MINOR,VER_MINORMINOR) + +namespace MptVersion +{ + typedef uint32 VersionNum; + const VersionNum num = MPT_VERSION_NUMERIC; + const char* const str = MPT_VERSION_STR; + + //Returns numerical version value from given version string. + inline VersionNum ToNum(const char* const s) + { + int v1, v2, v3, v4; + sscanf(s, "%x.%x.%x.%x", &v1, &v2, &v3, &v4); + return ((v1 << 24) + (v2 << 16) + (v3 << 8) + v4); + } + //Returns version string from given numerical version value. + inline CString ToStr(const VersionNum v) + { + CString strVersion; + if(v == 0) + strVersion = "Unknown"; + else + strVersion.Format("%X.%02X.%02X.%02X", (v>>24)&0xFF, (v>>16)&0xFF, (v>>8)&0xFF, (v)&0xFF); + return strVersion; + } +}; //namespace MptVersion + + + +#endif // _VERSION_H Modified: trunk/OpenMPT/soundlib/Load_it.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_it.cpp 2008-06-07 12:17:24 UTC (rev 212) +++ trunk/OpenMPT/soundlib/Load_it.cpp 2008-07-05 12:59:07 UTC (rev 213) @@ -20,6 +20,7 @@ #include <fstream> #include <strstream> #include <list> +#include "../mptrack/version.h" using std::map; using std::list; using std::vector; @@ -891,7 +892,7 @@ m_nMaxPeriod = 0xF000; m_nMinPeriod = 8; - if(m_dwLastSavedWithVersion < VERSIONNUMBER(0x1, 0x17, 0x2, 0x50)) + if(m_dwLastSavedWithVersion < MAKE_VERSION_NUMERIC(1, 17, 2, 50)) { SetModFlag(MSF_MIDICC_BUGEMULATION, true); SetModFlag(MSF_OLDVOLSWING, true); @@ -1490,7 +1491,7 @@ } } - if(m_dwLastSavedWithVersion < VERSIONNUMBER(0x1, 0x17, 0x2, 0x50)) + if(m_dwLastSavedWithVersion < MAKE_VERSION_NUMERIC(1, 17, 2, 50)) { SetModFlag(MSF_MIDICC_BUGEMULATION, true); SetModFlag(MSF_OLDVOLSWING, true); Modified: trunk/OpenMPT/soundlib/Load_xm.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_xm.cpp 2008-06-07 12:17:24 UTC (rev 212) +++ trunk/OpenMPT/soundlib/Load_xm.cpp 2008-07-05 12:59:07 UTC (rev 213) @@ -9,6 +9,7 @@ #include "stdafx.h" #include "sndfile.h" +#include "../mptrack/version.h" //////////////////////////////////////////////////////// // FastTracker II XM file support @@ -633,7 +634,7 @@ if( code == 'MPTS' ) { LoadExtendedSongProperties(MOD_TYPE_XM, ptr, lpStream, dwMemLength); - if(m_dwLastSavedWithVersion < VERSIONNUMBER(0x1, 0x17, 0x2, 0x50)) + if(m_dwLastSavedWithVersion < MAKE_VERSION_NUMERIC(1, 17, 2, 50)) SetModFlag(MSF_MIDICC_BUGEMULATION, true); } Modified: trunk/OpenMPT/soundlib/Sndfile.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.cpp 2008-06-07 12:17:24 UTC (rev 212) +++ trunk/OpenMPT/soundlib/Sndfile.cpp 2008-07-05 12:59:07 UTC (rev 213) @@ -11,6 +11,7 @@ #include "../mptrack/mptrack.h" #include "../mptrack/mainfrm.h" #include "../mptrack/moddoc.h" +#include "../mptrack/version.h" #include "sndfile.h" #include "aeffectx.h" #include "wavConverter.h" @@ -600,7 +601,7 @@ #endif } else { // New song - m_dwCreatedWithVersion = CMainFrame::GetFullVersionNumeric(); + m_dwCreatedWithVersion = MptVersion::num; } // Adjust song names This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |