From: Holger Schemel Date: Wed, 13 Nov 2013 00:29:26 +0000 (+0100) Subject: rnd-20131113-1-src X-Git-Tag: 3.3.1.2^2~2 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=3c53030b9e20c59004046274e94eff2ee90d0ab5;p=rocksndiamonds.git rnd-20131113-1-src * 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) * fixed determining main game data directory on Mac OS X "Mavericks" * version number set to 3.3.1.2 --- diff --git a/ChangeLog b/ChangeLog index 7c0df045..7a07f579 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +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 diff --git a/Makefile b/Makefile index b2d8476c..8a51c93a 100644 --- a/Makefile +++ b/Makefile @@ -143,7 +143,7 @@ backup: 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 diff --git a/src/Makefile b/src/Makefile index 853c415b..854d6e2f 100644 --- a/src/Makefile +++ b/src/Makefile @@ -146,7 +146,7 @@ CONFIG_GAME_DIR = $(CONFIG_RO_GAME_DIR) $(CONFIG_RW_GAME_DIR) CONFIG_GAME = $(CONFIG_GAME_DIR) $(CONFIG_SCORE_ENTRIES) $(CONFIG_SPECIAL) CONFIG = $(CONFIG_GAME) $(JOYSTICK) -# DEBUG = -DDEBUG -g +DEBUG = -DDEBUG -g # PROFILING = $(PROFILING_FLAGS) # OPTIONS = $(DEBUG) -Wall # only for debugging purposes diff --git a/src/config.c b/src/config.c index c812adfd..bb1c6ee4 100644 --- a/src/config.c +++ b/src/config.c @@ -71,15 +71,27 @@ char *getProgramInitString() { 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; } diff --git a/src/conftime.h b/src/conftime.h index f0fbdec7..92f1b94c 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "2013-11-04 00:44" +#define COMPILE_DATE_STRING "2013-11-13 01:14" diff --git a/src/init.c b/src/init.c index f176e13e..4735f046 100644 --- a/src/init.c +++ b/src/init.c @@ -6440,7 +6440,13 @@ void CloseAllAndExit(int exit_value) ClosePlatformDependentStuff(); if (exit_value != 0) + { + /* 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 */ NotifyUserAboutErrorFile(); + } exit(exit_value); } diff --git a/src/libgame/macosx.h b/src/libgame/macosx.h index c4818e76..ddd9d4b1 100644 --- a/src/libgame/macosx.h +++ b/src/libgame/macosx.h @@ -15,6 +15,11 @@ #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 diff --git a/src/libgame/misc.c b/src/libgame/misc.c index 60dbcf06..7e273ada 100644 --- a/src/libgame/misc.c +++ b/src/libgame/misc.c @@ -564,6 +564,36 @@ char *getBasePath(char *filename) 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 */ @@ -721,6 +751,18 @@ void GetOptions(char *argv[], void (*print_usage_function)(void)) 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 "Maverick") 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 @@ -732,6 +774,8 @@ void GetOptions(char *argv[], void (*print_usage_function)(void)) ro_base_path = program.command_basepath; if (strEqual(rw_base_path, ".")) rw_base_path = program.command_basepath; +#endif + #endif /* initialize global program options */ @@ -963,9 +1007,11 @@ void Error(int mode, char *format, ...) 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) { diff --git a/src/libgame/setup.c b/src/libgame/setup.c index 246e3891..ac5b78d0 100644 --- a/src/libgame/setup.c +++ b/src/libgame/setup.c @@ -3951,7 +3951,7 @@ void LoadLevelSetup_LastSeries() free(filename); } -void SaveLevelSetup_LastSeries() +static void SaveLevelSetup_LastSeries_Ext(boolean deactivate_last_level_series) { /* ----------------------------------------------------------------------- */ /* ~/./levelsetup.conf */ @@ -3972,6 +3972,10 @@ void SaveLevelSetup_LastSeries() 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)); @@ -3982,6 +3986,16 @@ void SaveLevelSetup_LastSeries() 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; diff --git a/src/libgame/setup.h b/src/libgame/setup.h index c667c348..61316bbd 100644 --- a/src/libgame/setup.h +++ b/src/libgame/setup.h @@ -317,6 +317,7 @@ void LoadLevelArtworkInfo(void); void LoadLevelSetup_LastSeries(void); void SaveLevelSetup_LastSeries(void); +void SaveLevelSetup_LastSeries_Deactivate(); void LoadLevelSetup_SeriesInfo(void); void SaveLevelSetup_SeriesInfo(void); diff --git a/src/libgame/system.c b/src/libgame/system.c index 51e8df89..da379735 100644 --- a/src/libgame/system.c +++ b/src/libgame/system.c @@ -129,9 +129,13 @@ void InitPlatformDependentStuff(void) 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) diff --git a/src/libgame/system.h b/src/libgame/system.h index 98225eae..b6c2ad3b 100644 --- a/src/libgame/system.h +++ b/src/libgame/system.h @@ -651,9 +651,11 @@ typedef int (*EventFilter)(const Event *); 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 */ diff --git a/src/main.h b/src/main.h index 738e39b9..a35337cf 100644 --- a/src/main.h +++ b/src/main.h @@ -2066,7 +2066,7 @@ #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"