X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Finit.c;h=c2344a507175af8ce42059a4d563ca8c35cada54;hb=297ee9b33dab3bca9433befc81d7c7ce91450dd0;hp=3eb140519aeaf2154578a16c0d56836dc15808e9;hpb=61c3da024802ecc0268bab42d7499fc0346e4fd3;p=rocksndiamonds.git diff --git a/src/init.c b/src/init.c index 3eb14051..c2344a50 100644 --- a/src/init.c +++ b/src/init.c @@ -39,7 +39,7 @@ #define CONFIG_TOKEN_GLOBAL_BUSY "global.busy" #define DEBUG_PRINT_INIT_TIMESTAMPS TRUE -#define DEBUG_PRINT_INIT_TIMESTAMPS_DEPTH 1 +#define DEBUG_PRINT_INIT_TIMESTAMPS_DEPTH 0 static struct FontBitmapInfo font_initial[NUM_INITIAL_FONTS]; @@ -5313,6 +5313,7 @@ void Execute_Command(char *command) #if DEBUG #if defined(TARGET_SDL) +#if !defined(TARGET_SDL2) else if (strEqual(command, "SDL_ListModes")) { SDL_Rect **modes; @@ -5347,6 +5348,7 @@ void Execute_Command(char *command) exit(0); } #endif +#endif #endif else @@ -6274,6 +6276,63 @@ void KeyboardAutoRepeatOffUnlessAutoplay() KeyboardAutoRepeatOff(); } +void DisplayExitMessage(char *format, va_list ap) +{ + // check if draw buffer and fonts for exit message are already available + if (drawto == NULL || font_initial[NUM_INITIAL_FONTS - 1].bitmap == NULL) + return; + + int font_1 = FC_RED; + int font_2 = FC_YELLOW; + int font_3 = FC_BLUE; + int font_width = getFontWidth(font_2); + int font_height = getFontHeight(font_2); + int sx = SX; + int sy = SY; + int sxsize = WIN_XSIZE - 2 * sx; + int sysize = WIN_YSIZE - 2 * sy; + int line_length = sxsize / font_width; + int max_lines = sysize / font_height; + int num_lines_printed; + + gfx.sx = sx; + gfx.sy = sy; + gfx.sxsize = sxsize; + gfx.sysize = sysize; + + sy = 20; + + ClearRectangle(drawto, 0, 0, WIN_XSIZE, WIN_YSIZE); + + DrawTextSCentered(sy, font_1, "Fatal error:"); + sy += 3 * font_height;; + + num_lines_printed = + DrawTextBufferVA(sx, sy, format, ap, font_2, + line_length, line_length, max_lines, + 0, BLIT_ON_BACKGROUND, TRUE, TRUE, FALSE); + sy += (num_lines_printed + 3) * font_height; + + DrawTextSCentered(sy, font_1, "For details, see the following error file:"); + sy += 3 * font_height; + + num_lines_printed = + DrawTextBuffer(sx, sy, program.error_filename, font_2, + line_length, line_length, max_lines, + 0, BLIT_ON_BACKGROUND, TRUE, TRUE, FALSE); + + DrawTextSCentered(SYSIZE - 20, font_3, "Press any key or button to exit"); + + redraw_mask = REDRAW_ALL; + + BackToFront(); + + /* deactivate toons on error message screen */ + setup.toons = FALSE; + + WaitForEventToContinue(); +} + /* ========================================================================= */ /* OpenAll() */ @@ -6336,7 +6395,7 @@ void OpenAll() InitVideoDisplay(); InitVideoBuffer(WIN_XSIZE, WIN_YSIZE, DEFAULT_DEPTH, setup.fullscreen); - InitEventFilter(FilterMouseMotionEvents); + InitEventFilter(FilterEvents); print_timestamp_time("[init video stuff]"); @@ -6432,15 +6491,28 @@ void CloseAllAndExit(int exit_value) FreeAllImages(); #if defined(TARGET_SDL) +#if defined(TARGET_SDL2) + // !!! TODO !!! + // set a flag to tell the network server thread to quit and wait for it + // using SDL_WaitThread() +#else if (network_server) /* terminate network server */ SDL_KillThread(server_thread); +#endif #endif CloseVideoDisplay(); ClosePlatformDependentStuff(); if (exit_value != 0) - NotifyUserAboutErrorFile(); + { + /* fall back to default level set (current set may have caused an error) */ + SaveLevelSetup_LastSeries_Deactivate(); + + /* tell user where to find error log file which may contain more details */ + // (error notification now directly displayed on screen inside R'n'D + // NotifyUserAboutErrorFile(); /* currently only works for Windows */ + } exit(exit_value); }