+2013-11-20
+ * improved error handling: display error message on screen (not only in
+ the error file or on the console), and display path of the error file
+
2013-11-13
* fixed problem with R'n'D restarting with same level set that may have
caused a problem (and therefore failing again and again); after an
# run and test targets
# -----------------------------------------------------------------------------
-run: all
+run:
cd .. && ./$(PROGBASE) --verbose
-gdb: all
+gdb:
cd .. && gdb -batch -x GDB_COMMANDS ./$(PROGBASE)
-valgrind: all
+valgrind:
cd .. && valgrind -v --leak-check=yes ./$(PROGBASE) 2> valgrind.out
-#define COMPILE_DATE_STRING "2013-11-13 01:14"
+#define COMPILE_DATE_STRING "2013-11-20 00:53"
KeyboardAutoRepeatOff();
}
+void DisplayExitMessage(char *format, va_list ap)
+{
+ 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() */
void InitGfxBuffers();
void InitGadgets();
+void DisplayExitMessage(char *, va_list);
+
void OpenAll(void);
void CloseAllAndExit(int);
va_start(ap, format);
vfprintf_newline(program.error_file, format, ap);
va_end(ap);
+
+ if ((mode & ERR_EXIT) && !(mode & ERR_FROM_SERVER))
+ {
+ va_start(ap, format);
+ program.exit_message_function(format, ap);
+ va_end(ap);
+ }
}
if (mode & ERR_HELP)
program.error_file = stderr;
}
+void InitExitMessageFunction(void (*exit_message_function)(char *, va_list))
+{
+ program.exit_message_function = exit_message_function;
+}
+
void InitExitFunction(void (*exit_function)(int))
{
program.exit_function = exit_function;
int version_minor;
int version_patch;
+ void (*exit_message_function)(char *, va_list);
void (*exit_function)(int);
};
void InitProgramInfo(char *, char *, char *, char *, char *, char *, char *,
char *, char *, char *, char *, char *, int);
+void InitExitMessageFunction(void (*exit_message_function)(char *, va_list));
void InitExitFunction(void (*exit_function)(int));
void InitPlatformDependentStuff(void);
void ClosePlatformDependentStuff(void);
return current_line;
}
+int DrawTextBufferVA(int x, int y, char *format, va_list ap, int font_nr,
+ int line_length, int cut_length, int max_lines,
+ int line_spacing, int mask_mode, boolean autowrap,
+ boolean centered, boolean parse_comments)
+{
+ char text_buffer[MAX_OUTPUT_LINESIZE];
+ int text_length = vsnprintf(text_buffer, MAX_OUTPUT_LINESIZE, format, ap);
+
+ if (text_length >= MAX_OUTPUT_LINESIZE)
+ Error(ERR_WARN, "string too long in DrawTextBufferVA() -- truncated");
+
+ int num_lines_printed = DrawTextBuffer(x, y, text_buffer, font_nr,
+ line_length, cut_length, max_lines,
+ line_spacing, mask_mode, autowrap,
+ centered, parse_comments);
+ return num_lines_printed;
+}
+
int DrawTextFile(int x, int y, char *filename, int font_nr,
int line_length, int cut_length, int max_lines,
int line_spacing, int mask_mode, boolean autowrap,
char *GetTextBufferFromFile(char *, int);
int DrawTextBuffer(int, int, char *, int, int, int, int, int, int,
boolean, boolean, boolean);
+int DrawTextBufferVA(int, int, char *, va_list, int, int, int, int, int, int,
+ boolean, boolean, boolean);
int DrawTextFile(int, int, char *, int, int, int, int, int, int,
boolean, boolean, boolean);
MSDOS_POINTER_FILENAME,
COOKIE_PREFIX, FILENAME_PREFIX, GAME_VERSION_ACTUAL);
+ InitExitMessageFunction(DisplayExitMessage);
InitExitFunction(CloseAllAndExit);
InitPlatformDependentStuff();