+2013-11-24
+ * version 3.3.1.2 released
+
+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
+ error, the last level set is now deactivated in file "levelsetup.conf"
+ to restart with default level set (which should work without error)
+
+2013-11-07
+ * fixed determining main game data directory on Mac OS X "Mavericks"
+
+2013-11-04
+ * version number set to 3.3.1.2
+
2013-11-04
* version 3.3.1.1 released
backup-net-copy:
./Scripts/make_backup.sh src scp
-backup-net: backup backup-net-copy
+backup-all: backup backup-net-copy
backup_lev:
./Scripts/make_backup.sh lev
# 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
{
static char *program_init_string = NULL;
+#if 1
+ // do not display compile target anymore, as it is almost always "SDL" now
if (program_init_string == NULL)
{
program_init_string = checked_malloc(strlen(PROGRAM_TITLE_STRING) + 1 +
- strlen(getProgramVersionString()) +1 +
+ strlen(getProgramVersionString()) + 1);
+
+ sprintf(program_init_string, "%s %s",
+ PROGRAM_TITLE_STRING, getProgramVersionString());
+ }
+#else
+ if (program_init_string == NULL)
+ {
+ program_init_string = checked_malloc(strlen(PROGRAM_TITLE_STRING) + 1 +
+ strlen(getProgramVersionString()) + 1 +
strlen(TARGET_STRING) + 1);
sprintf(program_init_string, "%s %s %s",
PROGRAM_TITLE_STRING, getProgramVersionString(), TARGET_STRING);
}
+#endif
return program_init_string;
}
-#define COMPILE_DATE_STRING "2013-11-04 00:44"
+#define COMPILE_DATE_STRING "2013-11-24 14:05"
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() */
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);
}
void InitGfxBuffers();
void InitGadgets();
+void DisplayExitMessage(char *, va_list);
+
void OpenAll(void);
void CloseAllAndExit(int);
#define MACOSX_H
+/* define some Mac OS X specific paths */
+
+#define MAC_APP_BINARY_SUBDIR "Contents/MacOS"
+
+
/* some symbols are already defined on Mac OS X */
#define Delay Delay_internal
#define DrawLine DrawLine_internal
return basepath;
}
+static char *getProgramMainDataPath()
+{
+ char *main_data_path = getStringCopy(program.command_basepath);
+
+#if defined(PLATFORM_MACOSX)
+ static char *main_data_binary_subdir = NULL;
+
+ if (main_data_binary_subdir == NULL)
+ {
+ main_data_binary_subdir = checked_malloc(strlen(program.program_title) + 1 +
+ strlen("app") + 1 +
+ strlen(MAC_APP_BINARY_SUBDIR) + 1);
+
+ sprintf(main_data_binary_subdir, "%s.app/%s",
+ program.program_title, MAC_APP_BINARY_SUBDIR);
+ }
+
+ // cut relative path to Mac OS X application binary directory from path
+ if (strSuffix(main_data_path, main_data_binary_subdir))
+ main_data_path[strlen(main_data_path) -
+ strlen(main_data_binary_subdir)] = '\0';
+
+ // cut trailing path separator from path (but not if path is root directory)
+ if (strSuffix(main_data_path, "/") && !strEqual(main_data_path, "/"))
+ main_data_path[strlen(main_data_path) - 1] = '\0';
+#endif
+
+ return main_data_path;
+}
+
/* ------------------------------------------------------------------------- */
/* various string functions */
char *rw_base_path = RW_BASE_PATH;
char **options_left = &argv[1];
+#if 1
+ /* if the program is configured to start from current directory (default),
+ determine program package directory from program binary (some versions
+ of KDE/Konqueror and Mac OS X (especially "Mavericks") apparently do not
+ set the current working directory to the program package directory) */
+
+ if (strEqual(ro_base_path, "."))
+ ro_base_path = getProgramMainDataPath();
+ if (strEqual(rw_base_path, "."))
+ rw_base_path = getProgramMainDataPath();
+#else
+
#if !defined(PLATFORM_MACOSX)
/* if the program is configured to start from current directory (default),
determine program package directory (KDE/Konqueror does not do this by
ro_base_path = program.command_basepath;
if (strEqual(rw_base_path, "."))
rw_base_path = program.command_basepath;
+#endif
+
#endif
/* initialize global program options */
static boolean last_line_was_separator = FALSE;
char *process_name = "";
+#if 1
/* display warnings only when running in verbose mode */
if (mode & ERR_WARN && !options.verbose)
return;
+#endif
if (mode == ERR_INFO_LINE)
{
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)
free(filename);
}
-void SaveLevelSetup_LastSeries()
+static void SaveLevelSetup_LastSeries_Ext(boolean deactivate_last_level_series)
{
/* ----------------------------------------------------------------------- */
/* ~/.<program>/levelsetup.conf */
fprintf(file, "%s\n\n", getFormattedSetupEntry(TOKEN_STR_FILE_IDENTIFIER,
getCookie("LEVELSETUP")));
+
+ if (deactivate_last_level_series)
+ fprintf(file, "# %s\n# ", "the following level set may have caused a problem and was deactivated");
+
fprintf(file, "%s\n", getFormattedSetupEntry(TOKEN_STR_LAST_LEVEL_SERIES,
level_subdir));
free(filename);
}
+void SaveLevelSetup_LastSeries()
+{
+ SaveLevelSetup_LastSeries_Ext(FALSE);
+}
+
+void SaveLevelSetup_LastSeries_Deactivate()
+{
+ SaveLevelSetup_LastSeries_Ext(TRUE);
+}
+
static void checkSeriesInfo()
{
static char *level_directory = NULL;
void LoadLevelSetup_LastSeries(void);
void SaveLevelSetup_LastSeries(void);
+void SaveLevelSetup_LastSeries_Deactivate();
void LoadLevelSetup_SeriesInfo(void);
void SaveLevelSetup_SeriesInfo(void);
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;
updateUserGameDataDir();
#endif
+#if 1
+ openErrorFile();
+#else
#if !defined(PLATFORM_UNIX) || defined(PLATFORM_MACOSX)
openErrorFile();
#endif
+#endif
#if defined(TARGET_SDL)
if (SDL_Init(SDL_INIT_EVENTTHREAD | SDL_INIT_NOPARACHUTE) < 0)
struct ProgramInfo
{
- char *command_basepath; /* directory that contains the program */
+ char *command_basepath; /* path to the program binary */
char *command_basename; /* base filename of the program binary */
+ char *maindata_path; /* main game data (installation) directory */
+
char *userdata_subdir; /* personal user game data directory */
char *userdata_subdir_unix; /* personal user game data directory (Unix) */
char *userdata_path; /* resulting full path to game data directory */
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();
#define PROGRAM_VERSION_MAJOR 3
#define PROGRAM_VERSION_MINOR 3
#define PROGRAM_VERSION_PATCH 1
-#define PROGRAM_VERSION_BUILD 1
+#define PROGRAM_VERSION_BUILD 2
#define PROGRAM_TITLE_STRING "Rocks'n'Diamonds"
#define PROGRAM_AUTHOR_STRING "Holger Schemel"