-#ifdef CHECK_VERSION
- // locate and open RADIANT_MAJOR and RADIANT_MINOR
- qboolean bVerIsGood = true;
- Str ver_file_name;
- ver_file_name = g_strAppPath;
- ver_file_name += "RADIANT_MAJOR";
- FILE *ver_file = fopen (ver_file_name.GetBuffer(), "r");
- if (ver_file)
- {
- char buf[10];
- int chomp;
- fread(buf, 1, 10, ver_file);
- // chomp it (the hard way)
- chomp = 0;
- while(buf[chomp] >= '0' && buf[chomp] <= '9')
- chomp++;
- buf[chomp] = '\0';
- if (strcmp(buf, RADIANT_MAJOR_VERSION))
- {
- Sys_Printf("ERROR: file RADIANT_MAJOR doesn't match ('%s')\n", buf);
- bVerIsGood = false;
- }
- }
- else
- {
- Sys_Printf("ERROR: can't find RADIANT_MAJOR in '%s'\n", ver_file_name.GetBuffer());
- bVerIsGood = false;
- }
- ver_file_name = g_strAppPath;
- ver_file_name += "RADIANT_MINOR";
- ver_file = fopen (ver_file_name.GetBuffer(), "r");
- if (ver_file)
- {
- char buf[10];
- int chomp;
- fread(buf, 1, 10, ver_file);
- // chomp it (the hard way)
- chomp = 0;
- while(buf[chomp] >= '0' && buf[chomp] <= '9')
- chomp++;
- buf[chomp] = '\0';
- if (strcmp(buf, RADIANT_MINOR_VERSION))
- {
- Sys_Printf("ERROR: file RADIANT_MINOR doesn't match ('%s')\n", buf);
- bVerIsGood = false;
- }
- }
- else
- {
- Sys_Printf("ERROR: can't find RADIANT_MINOR in '%s'\n", ver_file_name.GetBuffer());
- bVerIsGood = false;
- }
- if (!bVerIsGood)
- {
- CString msg;
- msg = "This editor binary (" RADIANT_VERSION ") doesn't match what the latest setup has configured in this directory\n";
- msg += "Make sure you run the right/latest editor binary you installed\n";
- msg += g_strAppPath; msg += "\n";
- msg += "Check http://www.qeradiant.com/faq/index.cgi?file=219 for more information";
- gtk_MessageBox(NULL, msg.GetBuffer(), "Radiant", MB_OK, "http://www.qeradiant.com/faq/index.cgi?file=219");
- _exit(-1);
- }
-#endif
-
- g_qeglobals.disable_ini = false;
- g_PrefsDlg.Init ();
-
- // close the primary
- if (remove (g_pidFile.GetBuffer ()) == -1)
- {
- CString msg;
- msg = "WARNING: Could not delete "; msg += g_pidGameFile;
- gtk_MessageBox (NULL, msg, "Radiant", MB_OK | MB_ICONERROR );
- }
-
- /*!
- now the secondary game dependant .pid file
- http://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=297
- */
- g_pidGameFile = g_PrefsDlg.m_rc_path->str;
- g_pidGameFile += "radiant-game.pid";
-
- pid = fopen (g_pidGameFile.GetBuffer(), "r");
- if (pid != NULL)
- {
- fclose (pid);
- CString msg;
- if (remove (g_pidGameFile.GetBuffer ()) == -1)
- {
- msg = "WARNING: Could not delete "; msg += g_pidGameFile;
- gtk_MessageBox (NULL, msg, "Radiant", MB_OK | MB_ICONERROR );
- }
-
- msg = "Found the file ";
- msg += g_pidGameFile;
- msg += ".\nThis indicates that Radiant failed to load the last time it was run.\n"
- "Choose YES to clean Radiant's registry settings and shut down Radiant.\n"
- "WARNING: preferences will be lost if you choose YES.";
-
- // in debug, never prompt to clean registry, turn console logging auto after a failed start
-#if !defined(_DEBUG)
- //bleh
- if (gtk_MessageBox (NULL, msg, "Radiant - Clean Registry?", MB_YESNO | MB_ICONQUESTION) == IDYES)
- {
- // remove the game prefs files
- remove (g_PrefsDlg.m_inipath->str);
- char buf[PATH_MAX];
- sprintf(buf, "%sSavedInfo.bin", g_PrefsDlg.m_rc_path->str);
- remove(buf);
- // remove the global pref too
- g_PrefsDlg.mGamesDialog.Reset();
- gtk_MessageBox(NULL, "Cleaned registry settings, choose OK to close Radiant.\nThe next time Radiant runs it will use default settings.", "Radiant", MB_OK );
- _exit(-1);
- }
- msg = "Logging console output to ";
- msg += g_strTempPath;
- msg += "radiant.log\nRefer to the log if Radiant fails to start again.";
-
- gtk_MessageBox (NULL, msg, "Radiant - Console Log", MB_OK);
-#endif
+#ifdef CHECK_VERSION
+ // locate and open RADIANT_MAJOR and RADIANT_MINOR
+ bool bVerIsGood = true;
+ {
+ StringOutputStream ver_file_name( 256 );
+ ver_file_name << AppPath_get() << "RADIANT_MAJOR";
+ bVerIsGood = check_version_file( ver_file_name.c_str(), RADIANT_MAJOR_VERSION );
+ }
+ {
+ StringOutputStream ver_file_name( 256 );
+ ver_file_name << AppPath_get() << "RADIANT_MINOR";
+ bVerIsGood = check_version_file( ver_file_name.c_str(), RADIANT_MINOR_VERSION );
+ }
+
+ if ( !bVerIsGood ) {
+ StringOutputStream msg( 256 );
+ msg << "This editor binary ("
+ << radiant::version()
+ << ") doesn't match what the latest setup has configured in this directory\n"
+ "Make sure you run the right/latest editor binary you installed\n"
+ << AppPath_get();
+ ui::alert( 0, msg.c_str(), "Radiant", eMB_OK, eMB_ICONDEFAULT );
+ }
+ return bVerIsGood;
+#else
+ return true;
+#endif*/
+}