src/openttd.cpp
changeset 9470 08424e2e79e4
parent 9466 5a1d4eb2ae07
child 9533 e8b86b70c5f6
equal deleted inserted replaced
9469:520cbe2f5d14 9470:08424e2e79e4
    97 void ProcessAsyncSaveFinish();
    97 void ProcessAsyncSaveFinish();
    98 void CallWindowTickEvent();
    98 void CallWindowTickEvent();
    99 
    99 
   100 extern void SetDifficultyLevel(int mode, DifficultySettings *gm_opt);
   100 extern void SetDifficultyLevel(int mode, DifficultySettings *gm_opt);
   101 extern Player* DoStartupNewPlayer(bool is_ai);
   101 extern Player* DoStartupNewPlayer(bool is_ai);
   102 extern void ShowOSErrorBox(const char *buf);
   102 extern void ShowOSErrorBox(const char *buf, bool system);
   103 extern void InitializeRailGUI();
   103 extern void InitializeRailGUI();
   104 
   104 
   105 /**
   105 /**
   106  * Error handling for fatal errors.
   106  * Error handling for fatal user errors.
       
   107  * @param s the string to print.
       
   108  * @note Does NEVER return.
       
   109  */
       
   110 void CDECL usererror(const char *s, ...)
       
   111 {
       
   112 	va_list va;
       
   113 	char buf[512];
       
   114 
       
   115 	va_start(va, s);
       
   116 	vsnprintf(buf, lengthof(buf), s, va);
       
   117 	va_end(va);
       
   118 
       
   119 	ShowOSErrorBox(buf, false);
       
   120 	if (_video_driver != NULL) _video_driver->Stop();
       
   121 
       
   122 	exit(1);
       
   123 }
       
   124 
       
   125 /**
       
   126  * Error handling for fatal non-user errors.
   107  * @param s the string to print.
   127  * @param s the string to print.
   108  * @note Does NEVER return.
   128  * @note Does NEVER return.
   109  */
   129  */
   110 void CDECL error(const char *s, ...)
   130 void CDECL error(const char *s, ...)
   111 {
   131 {
   114 
   134 
   115 	va_start(va, s);
   135 	va_start(va, s);
   116 	vsnprintf(buf, lengthof(buf), s, va);
   136 	vsnprintf(buf, lengthof(buf), s, va);
   117 	va_end(va);
   137 	va_end(va);
   118 
   138 
   119 	ShowOSErrorBox(buf);
   139 	ShowOSErrorBox(buf, true);
   120 	if (_video_driver != NULL) _video_driver->Stop();
   140 	if (_video_driver != NULL) _video_driver->Stop();
   121 
   141 
   122 	assert(0);
   142 	assert(0);
   123 	exit(1);
   143 	exit(1);
   124 }
   144 }
   522 	GfxInitPalettes();
   542 	GfxInitPalettes();
   523 
   543 
   524 	DEBUG(misc, 1, "Loading blitter...");
   544 	DEBUG(misc, 1, "Loading blitter...");
   525 	if (BlitterFactoryBase::SelectBlitter(_ini_blitter) == NULL)
   545 	if (BlitterFactoryBase::SelectBlitter(_ini_blitter) == NULL)
   526 		StrEmpty(_ini_blitter) ?
   546 		StrEmpty(_ini_blitter) ?
   527 			error("Failed to autoprobe blitter") :
   547 			usererror("Failed to autoprobe blitter") :
   528 			error("Failed to select requested blitter '%s'; does it exist?", _ini_blitter);
   548 			usererror("Failed to select requested blitter '%s'; does it exist?", _ini_blitter);
   529 
   549 
   530 	DEBUG(driver, 1, "Loading drivers...");
   550 	DEBUG(driver, 1, "Loading drivers...");
   531 
   551 
   532 	_sound_driver = (SoundDriver*)SoundDriverFactoryBase::SelectDriver(_ini_sounddriver, Driver::DT_SOUND);
   552 	_sound_driver = (SoundDriver*)SoundDriverFactoryBase::SelectDriver(_ini_sounddriver, Driver::DT_SOUND);
   533 	if (_sound_driver == NULL) {
   553 	if (_sound_driver == NULL) {
   534 		StrEmpty(_ini_sounddriver) ?
   554 		StrEmpty(_ini_sounddriver) ?
   535 			error("Failed to autoprobe sound driver") :
   555 			usererror("Failed to autoprobe sound driver") :
   536 			error("Failed to select requested sound driver '%s'", _ini_sounddriver);
   556 			usererror("Failed to select requested sound driver '%s'", _ini_sounddriver);
   537 	}
   557 	}
   538 
   558 
   539 	_music_driver = (MusicDriver*)MusicDriverFactoryBase::SelectDriver(_ini_musicdriver, Driver::DT_MUSIC);
   559 	_music_driver = (MusicDriver*)MusicDriverFactoryBase::SelectDriver(_ini_musicdriver, Driver::DT_MUSIC);
   540 	if (_music_driver == NULL) {
   560 	if (_music_driver == NULL) {
   541 		StrEmpty(_ini_musicdriver) ?
   561 		StrEmpty(_ini_musicdriver) ?
   542 			error("Failed to autoprobe music driver") :
   562 			usererror("Failed to autoprobe music driver") :
   543 			error("Failed to select requested music driver '%s'", _ini_musicdriver);
   563 			usererror("Failed to select requested music driver '%s'", _ini_musicdriver);
   544 	}
   564 	}
   545 
   565 
   546 	_video_driver = (VideoDriver*)VideoDriverFactoryBase::SelectDriver(_ini_videodriver, Driver::DT_VIDEO);
   566 	_video_driver = (VideoDriver*)VideoDriverFactoryBase::SelectDriver(_ini_videodriver, Driver::DT_VIDEO);
   547 	if (_video_driver == NULL) {
   567 	if (_video_driver == NULL) {
   548 		StrEmpty(_ini_videodriver) ?
   568 		StrEmpty(_ini_videodriver) ?
   549 			error("Failed to autoprobe video driver") :
   569 			usererror("Failed to autoprobe video driver") :
   550 			error("Failed to select requested video driver '%s'", _ini_videodriver);
   570 			usererror("Failed to select requested video driver '%s'", _ini_videodriver);
   551 	}
   571 	}
   552 
   572 
   553 	_savegame_sort_order = SORT_BY_DATE | SORT_DESCENDING;
   573 	_savegame_sort_order = SORT_BY_DATE | SORT_DESCENDING;
   554 	/* Initialize the zoom level of the screen to normal */
   574 	/* Initialize the zoom level of the screen to normal */
   555 	_screen.zoom = ZOOM_LVL_NORMAL;
   575 	_screen.zoom = ZOOM_LVL_NORMAL;