Overhaul of ProductInfo: change to const refs, removed unused bug tracker, fixed...
authorMarc Cannon <vyhdycokio@gmail.com>
Wed, 2 Jan 2013 03:35:53 +0000 (03:35 +0000)
committerMarc Cannon <vyhdycokio@gmail.com>
Wed, 2 Jan 2013 03:35:53 +0000 (03:35 +0000)
src/DiagnosticsUtil.cpp
src/PrefsManager.cpp
src/ProductInfo.cpp
src/ProductInfo.h
src/ScreenTitleMenu.cpp
src/StepMania.cpp
src/archutils/Unix/CrashHandlerChild.cpp
src/archutils/Win32/Crash.cpp
src/archutils/Win32/GraphicsWindow.cpp

index d642bb9..6f4a159 100644 (file)
@@ -132,12 +132,12 @@ int DiagnosticsUtil::GetNumMachineScores()
 
 CString DiagnosticsUtil::GetProductName()
 {
-       return CString(ProductInfo::getFullVersionString());
+       return ProductInfo::GetFullVersion();
 }
 
 CString DiagnosticsUtil::GetProductVer()
 {
-       return CString(ProductInfo::getVersion());
+       return ProductInfo::GetBuildRevision();
 }
 
 namespace
@@ -147,7 +147,7 @@ namespace
         * from verstub. */
        CString GenerateDebugSerial()
        {
-               return CString(ProductInfo::getSerial());
+               return CString();
        }
 }
 
@@ -191,7 +191,7 @@ void DiagnosticsUtil::SetInputType( const CString &sType )
 void SetProgramGlobals( lua_State* L )
 {
        LUA->SetGlobal( "OPENITG", true );
-       LUA->SetGlobal( "OPENITG_VERSION", ProductInfo::getVersion() );
+       LUA->SetGlobal( "OPENITG_VERSION", ProductInfo::GetVersion() );
 }
 
 REGISTER_WITH_LUA_FUNCTION( SetProgramGlobals );
index a5af59a..0384c19 100755 (executable)
@@ -238,7 +238,7 @@ PrefsManager::PrefsManager() :
        m_iEndlessBreakLength                   ( "EndlessBreakLength",                 5 ),
        m_bDisableScreenSaver                   ( "DisableScreenSaver",                 true ),
        m_sLanguage                                             ( "Language",                                   "" ),   // ThemeManager will deal with this invalid language
-       m_sMemoryCardProfileSubdir              ( "MemoryCardProfileSubdir",    ProductInfo::getName()),
+       m_sMemoryCardProfileSubdir              ( "MemoryCardProfileSubdir",    ProductInfo::GetName()),
        m_iProductID                                    ( "ProductID",                                  1 ),
        m_sDefaultLocalProfileIDP1              ( "DefaultLocalProfileIDP1",    "" ),
        m_sDefaultLocalProfileIDP2              ( "DefaultLocalProfileIDP2",    "" ),
index 5e22d7e..a58a68f 100644 (file)
@@ -1,39 +1,67 @@
-#if defined(WIN32)
-       #include "global.h"
-#endif
 #include "StdString.h"
 #include "ProductInfo.h"
 
-CString ProductInfo::getName() {
-       return CString("OpenITG");
-}
+#if HAVE_CONFIG_H
+       #include "config.h"
+#else
+/* XXX: workaround until the Windows build can pull Git versioning. */
+       #define BUILD_VERSION "beta3 DEV"
+       #define BUILD_DATE "unknown date"
+       #define BUILD_REVISION_TAG "unknown revision"
+#endif
 
-CString ProductInfo::getVersion() {
-       return CString(OITG_VERSION);
-}
+#define VERSION_STRING( id, value ) \
+       static const CString g_s##id = CString( value ); \
+       const CString& ProductInfo::Get##id() { return g_s##id; }
 
-CString ProductInfo::getDate() {
-       return CString(OITG_DATE);
-}
+VERSION_STRING( Name, "OpenITG" );
+VERSION_STRING( Version, BUILD_VERSION );
 
-CString ProductInfo::getPlatform() {
-#if defined(ITG_ARCADE)
-       return CString("AC");
-#elif defined(XBOX)
-       return CString("CS");
-#else
-       return CString("PC");
-#endif
-}
+VERSION_STRING( BuildDate, BUILD_DATE );
+VERSION_STRING( BuildRevision, BUILD_REVISION_TAG );
 
-CString ProductInfo::getCrashReportUrl() {
-       return CString("http://wush.net/bugzilla/terabyte/");
-}
+VERSION_STRING( CrashReportURL, "<to be determined>" );
 
-CString ProductInfo::getFullVersionString() {
-       return getVersion() + "-" + getPlatform();
+namespace
+{
+       const CString GetPlatform()
+       {
+       #if defined(ITG_ARCADE)
+               return "AC";
+       #elif defined(XBOX)
+               return "CS";
+       #else
+               return "PC";
+       #endif
+       }
 }
 
-CString ProductInfo::getSerial() {
-       return CString("OITG-") + getVersion() + "-" + getPlatform();
-}
+VERSION_STRING( FullVersion, g_sName + " " + GetPlatform() + " " + g_sVersion );
+
+#undef VERSION_STRING
+
+/*
+ * (c) 2013 Marc Cannon
+ * All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, and/or sell copies of the Software, and to permit persons to
+ * whom the Software is furnished to do so, provided that the above
+ * copyright notice(s) and this permission notice appear in all copies of
+ * the Software and that both the above copyright notice(s) and this
+ * permission notice appear in supporting documentation.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
+ * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
+ * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
+ * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+ * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
index b5fe0db..6466541 100755 (executable)
@@ -3,31 +3,27 @@
 #ifndef PRODUCT_INFO_H
 #define PRODUCT_INFO_H
 
-#ifdef HAVE_CONFIG_H 
-#include "config.h"
-#endif
-
-#undef OFFICIAL_RELEASE
-//#define OFFICIAL_RELEASE 1
+namespace ProductInfo
+{
+       /* Binary name + release (e.g. "OpenITG", "beta3") */
+       const CString& GetName();
+       const CString& GetVersion();
 
-#include "StdString.h"
+       /* Binary name + build type + release (e.g. "OpenITG AC beta3") */
+       const CString& GetFullVersion();
 
-class ProductInfo {
+       /* Build data (e.g. "2012-12-31", "beta3-105-g63a1100") */
+       const CString& GetBuildDate();
+       const CString& GetBuildRevision();
 
-       public:
-               static CString getName();
-               static CString getVersion();
-               static CString getDate();
-               static CString getPlatform();
-               static CString getCrashReportUrl();
-               static CString getFullVersionString();
-               static CString getSerial();
+       /* Crash report URL */
+       const CString& GetCrashReportURL();
 };
 
 #endif
 
 /*
- * (c) 2003-2009 Chris Danford, BoXoRRoXoRs
+ * (c) 2003-2013 Chris Danford, Marc Cannon
  * All rights reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
index d29a454..3739ca2 100755 (executable)
@@ -15,7 +15,6 @@
 #include "CodeDetector.h"
 #include "RageTextureManager.h"
 #include "UnlockManager.h"
-#include "ProductInfo.h"
 #include "LightsManager.h"
 #include "CommonMetrics.h"
 #include "Game.h"
@@ -67,7 +66,7 @@ void ScreenTitleMenu::Init()
        m_textVersion.LoadFromFont( THEME->GetPathF("Common","normal") );
        m_textVersion.SetName( "Version" );
        /* easier debugging, plus product placement ;D */
-       m_textVersion.SetText( ProductInfo::getName() );
+       m_textVersion.SetText( ProductInfo::GetFullVersion() );
        this->AddChild( &m_textVersion );
        SET_XY_AND_ON_COMMAND( m_textVersion );
 
index 6bf117e..7779306 100755 (executable)
@@ -897,8 +897,12 @@ static void MountTreeOfZips( const CString &dir, bool recurse = true )
 
 static void WriteLogHeader()
 {
-       LOG->Info( ProductInfo::getFullVersionString());
-       LOG->Info( "Compiled %s (build %s)", ProductInfo::getDate().c_str(), ProductInfo::getVersion().c_str() );
+       LOG->Info( ProductInfo::GetFullVersion() );
+
+       LOG->Info( "Compiled %s (build %s)", 
+               ProductInfo::GetBuildDate().c_str(),
+               ProductInfo::GetBuildRevision().c_str()
+       );
 
        time_t cur_time;
        time(&cur_time);
index a091076..137478e 100755 (executable)
@@ -283,9 +283,9 @@ static void child_process()
                exit(1);
        }
 
-    fprintf(CrashDump, "%s crash report", ProductInfo::getFullVersionString().c_str() );
+    fprintf(CrashDump, "%s crash report", ProductInfo::GetFullVersion().c_str() );
 #if defined(HAVE_VERSION_INFO)
-    fprintf(CrashDump, " (build %u)", ProductInfo::getVersion().c_str() );
+    fprintf(CrashDump, " (build %u)", ProductInfo::GetBuildRevision().c_str() );
 #endif
     fprintf(CrashDump, "\n");
     fprintf(CrashDump, "--------------------------------------\n");
@@ -351,7 +351,7 @@ static void child_process()
 
 #if defined(DARWIN)
     InformUserOfCrash( sCrashInfoPath );
-    
+
     /* Forcibly kill our parent. */
     kill( getppid(), SIGKILL );
 #else
@@ -361,18 +361,18 @@ static void child_process()
     if( tty == NULL )
         tty = stderr;
 
-    fprintf(tty,
-                       "\n"
-            + ProductInfo::getName()
-                       + " has crashed.  Debug information has been output to\n"
-            "\n"
-            "    " + sCrashInfoPath + "\n"
-            "\n"
-            "Please report a bug at:\n"
-            "\n"
-            "    " + ProductInfo::getCrashReportUrl() + "\n"
-            "\n"
-            );
+       fprintf(tty,
+               "\n"
+               + ProductInfo::GetName()
+               + " has crashed.  Debug information has been output to\n"
+               "\n"
+               "    " + sCrashInfoPath + "\n"
+               "\n"
+               "Please report a bug at:\n"
+               "\n"
+               "    " + ProductInfo::GetCrashReportURL() + "\n"
+               "\n"
+       );
 
 #endif
 
index 781c5b6..9e359bf 100755 (executable)
@@ -785,8 +785,13 @@ static bool ReportCallStack( HWND hwnd, HANDLE hFile, const void **Backtrace )
 
        if( g_debugInfo.nBuildNumber != int(VersionNumber) )
        {
-               Report(hwnd, hFile, (CString("Incorrect %s file (build %d, expected %d) for this version of ") + ProductInfo::getName() + " -- call stack unavailable.").c_str(),
-                       g_debugInfo.sFilename, g_debugInfo.nBuildNumber, int(VersionNumber));
+               Report( hwnd, hFile,
+                       "Incorrect %s file (build %d, expected %d) -- call stack unavailable.").c_str(),
+                       g_debugInfo.sFilename,
+                       g_debugInfo.nBuildNumber,
+                       int(VersionNumber)
+               );
+
                return false;
        }
 
@@ -823,7 +828,7 @@ static void DoSave()
        Report(NULL, hFile,
                        "%s crash report (build %d)\r\n"
                        "--------------------------------------"
-                       "\r\n", ProductInfo::getFullVersionString().c_str(), VersionNumber);
+                       "\r\n", ProductInfo::GetFullVersion().c_str(), VersionNumber);
 
        ReportReason( NULL, hFile, &g_CrashInfo );
        Report(NULL, hFile, "");
@@ -926,9 +931,9 @@ BOOL APIENTRY CrashDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
                case IDC_CRASH_SAVE:
                        if (!s_bHaveCallstack)
                                if (IDOK != MessageBox(hDlg,
-                                       (ProductInfo::getName() + " cannot load its crash resource file, and thus the crash dump will be "
+                                       (ProductInfo::GetName() + " cannot load its crash resource file, and thus the crash dump will be "
                                        "missing the most important part, the call stack. Crash dumps are much less useful "
-                                       "without the call stack.").c_str(), (ProductInfo::getName() + " warning").c_str(), MB_OK|MB_ICONEXCLAMATION))
+                                       "without the call stack.").c_str(), (ProductInfo::GetName() + " warning").c_str(), MB_OK|MB_ICONEXCLAMATION))
                                        return TRUE;
 
                        ViewWithNotepad( s_sCrashLogPath );
@@ -962,8 +967,7 @@ BOOL APIENTRY CrashDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
                        EndDialog( hDlg, FALSE );
                        break;
                case IDC_BUTTON_REPORT:
-                       GotoURL( ProductInfo::getCrashReportUrl().c_str() );
-                       //GotoURL( http://sourceforge.net/tracker/?func=add&group_id=37892&atid=421366" );
+                       GotoURL( ProductInfo::GetCrashReportURL().c_str() );
                        break;
                }
                break;
index 9a29ac0..f904db8 100755 (executable)
@@ -11,7 +11,7 @@
 
 #include <set>
 
-static const CString g_sClassName = ProductInfo::getName() + " LowLevelWindow_Win32";
+static const CString g_sClassName = ProductInfo::GetName() + " LowLevelWindow_Win32";
 
 static HWND g_hWndMain;
 static HDC g_HDC;