summaryrefslogtreecommitdiff
path: root/src/openttd.cpp
diff options
context:
space:
mode:
authorglx <glx@openttd.org>2008-06-05 20:54:52 +0000
committerglx <glx@openttd.org>2008-06-05 20:54:52 +0000
commitee256e770afb5f04a6a10f3b2045dd426d3167ff (patch)
tree62bef57de81c1ddcc691d5de5e8db395615bdacc /src/openttd.cpp
parent5176319dd5145138604dd48c44b056693d900b10 (diff)
downloadopenttd-ee256e770afb5f04a6a10f3b2045dd426d3167ff.tar.xz
(svn r13390) -Codechange: introduce usererror() for fatal but not openttd related errors. Now all error() will 'crash' openttd after showing the message in win32 releases (MSVC), creating a crash.log and crash.dmp (like the '!' hack used before). On the other hand, usererror() will just close the game. So use error() only when it can be helpful to debugging, else use usererror().
Diffstat (limited to 'src/openttd.cpp')
-rw-r--r--src/openttd.cpp42
1 files changed, 31 insertions, 11 deletions
diff --git a/src/openttd.cpp b/src/openttd.cpp
index 2bf7ce337..1861d3cd3 100644
--- a/src/openttd.cpp
+++ b/src/openttd.cpp
@@ -99,11 +99,31 @@ void CallWindowTickEvent();
extern void SetDifficultyLevel(int mode, DifficultySettings *gm_opt);
extern Player* DoStartupNewPlayer(bool is_ai);
-extern void ShowOSErrorBox(const char *buf);
+extern void ShowOSErrorBox(const char *buf, bool system);
extern void InitializeRailGUI();
/**
- * Error handling for fatal errors.
+ * Error handling for fatal user errors.
+ * @param s the string to print.
+ * @note Does NEVER return.
+ */
+void CDECL usererror(const char *s, ...)
+{
+ va_list va;
+ char buf[512];
+
+ va_start(va, s);
+ vsnprintf(buf, lengthof(buf), s, va);
+ va_end(va);
+
+ ShowOSErrorBox(buf, false);
+ if (_video_driver != NULL) _video_driver->Stop();
+
+ exit(1);
+}
+
+/**
+ * Error handling for fatal non-user errors.
* @param s the string to print.
* @note Does NEVER return.
*/
@@ -116,7 +136,7 @@ void CDECL error(const char *s, ...)
vsnprintf(buf, lengthof(buf), s, va);
va_end(va);
- ShowOSErrorBox(buf);
+ ShowOSErrorBox(buf, true);
if (_video_driver != NULL) _video_driver->Stop();
assert(0);
@@ -524,30 +544,30 @@ int ttd_main(int argc, char *argv[])
DEBUG(misc, 1, "Loading blitter...");
if (BlitterFactoryBase::SelectBlitter(_ini_blitter) == NULL)
StrEmpty(_ini_blitter) ?
- error("Failed to autoprobe blitter") :
- error("Failed to select requested blitter '%s'; does it exist?", _ini_blitter);
+ usererror("Failed to autoprobe blitter") :
+ usererror("Failed to select requested blitter '%s'; does it exist?", _ini_blitter);
DEBUG(driver, 1, "Loading drivers...");
_sound_driver = (SoundDriver*)SoundDriverFactoryBase::SelectDriver(_ini_sounddriver, Driver::DT_SOUND);
if (_sound_driver == NULL) {
StrEmpty(_ini_sounddriver) ?
- error("Failed to autoprobe sound driver") :
- error("Failed to select requested sound driver '%s'", _ini_sounddriver);
+ usererror("Failed to autoprobe sound driver") :
+ usererror("Failed to select requested sound driver '%s'", _ini_sounddriver);
}
_music_driver = (MusicDriver*)MusicDriverFactoryBase::SelectDriver(_ini_musicdriver, Driver::DT_MUSIC);
if (_music_driver == NULL) {
StrEmpty(_ini_musicdriver) ?
- error("Failed to autoprobe music driver") :
- error("Failed to select requested music driver '%s'", _ini_musicdriver);
+ usererror("Failed to autoprobe music driver") :
+ usererror("Failed to select requested music driver '%s'", _ini_musicdriver);
}
_video_driver = (VideoDriver*)VideoDriverFactoryBase::SelectDriver(_ini_videodriver, Driver::DT_VIDEO);
if (_video_driver == NULL) {
StrEmpty(_ini_videodriver) ?
- error("Failed to autoprobe video driver") :
- error("Failed to select requested video driver '%s'", _ini_videodriver);
+ usererror("Failed to autoprobe video driver") :
+ usererror("Failed to select requested video driver '%s'", _ini_videodriver);
}
_savegame_sort_order = SORT_BY_DATE | SORT_DESCENDING;