X-Git-Url: https://git.artsoft.org/?p=rocksndiamonds.git;a=blobdiff_plain;f=src%2Flibgame%2Fmisc.c;h=8a1a011e267a89bf40e6b3c24a2d06bcb24238ba;hp=cf387ceb9234585a7ea7a2ed850ddffc3d85fb0e;hb=5e13b105ad48e61a5cd46941c61a16ad00445248;hpb=5f189129bbc68852e3eb8b8d66c0b01b7f9da8fc diff --git a/src/libgame/misc.c b/src/libgame/misc.c index cf387ceb..8a1a011e 100644 --- a/src/libgame/misc.c +++ b/src/libgame/misc.c @@ -654,6 +654,23 @@ char *getBaseName(char *filename) return getStringCopy(getBaseNamePtr(filename)); } +char *getBaseNameNoSuffix(char *filename) +{ + char *basename = getStringCopy(getBaseNamePtr(filename)); + + // remove trailing suffix (separated by dot or hyphen) + if (basename[0] != '.' && basename[0] != '-') + { + if (strchr(basename, '.') != NULL) + *strchr(basename, '.') = '\0'; + + if (strchr(basename, '-') != NULL) + *strchr(basename, '-') = '\0'; + } + + return basename; +} + char *getBasePath(char *filename) { char *basepath = getStringCopy(filename); @@ -925,13 +942,18 @@ boolean strSuffixLower(char *s, char *suffix) /* command line option handling functions */ /* ------------------------------------------------------------------------- */ -void GetOptions(char *argv[], +void GetOptions(int argc, char *argv[], void (*print_usage_function)(void), void (*print_version_function)(void)) { char *ro_base_path = RO_BASE_PATH; char *rw_base_path = RW_BASE_PATH; - char **options_left = &argv[1]; + char **argvplus = checked_calloc((argc + 1) * sizeof(char **)); + char **options_left = &argvplus[1]; + + /* replace original "argv" with null-terminated array of string pointers */ + while (argc--) + argvplus[argc] = argv[argc]; /* if the program is configured to start from current directory (default), determine program package directory from program binary (some versions @@ -1117,6 +1139,12 @@ void GetOptions(char *argv[], /* when doing batch processing, always enable verbose mode (warnings) */ options.verbose = TRUE; } +#if defined(PLATFORM_MACOSX) + else if (strPrefix(option, "-psn")) + { + /* ignore process serial number when launched via GUI on Mac OS X */ + } +#endif else if (*option == '-') { Error(ERR_EXIT_HELP, "unrecognized option '%s'", option_str); @@ -1306,7 +1334,7 @@ void clear_mem(void *ptr, unsigned int size) /* various helper functions */ /* ------------------------------------------------------------------------- */ -inline void swap_numbers(int *i1, int *i2) +void swap_numbers(int *i1, int *i2) { int help = *i1; @@ -1314,7 +1342,7 @@ inline void swap_numbers(int *i1, int *i2) *i2 = help; } -inline void swap_number_pairs(int *x1, int *y1, int *x2, int *y2) +void swap_number_pairs(int *x1, int *y1, int *x2, int *y2) { int help_x = *x1; int help_y = *y1; @@ -2400,7 +2428,7 @@ DirectoryEntry *readDirectory(Directory *dir) dir->dir_entry->is_directory = (stat(dir->dir_entry->filename, &file_status) == 0 && - (file_status.st_mode & S_IFMT) == S_IFDIR); + S_ISDIR(file_status.st_mode)); return dir->dir_entry; } @@ -2427,7 +2455,7 @@ boolean directoryExists(char *dir_name) struct stat file_status; boolean success = (stat(dir_name, &file_status) == 0 && - (file_status.st_mode & S_IFMT) == S_IFDIR); + S_ISDIR(file_status.st_mode)); #if defined(PLATFORM_ANDROID) if (!success) @@ -2684,6 +2712,7 @@ int get_parameter_value(char *value_raw, char *suffix, int type) string_has_parameter(value, "fade") ? FADE_MODE_FADE : string_has_parameter(value, "crossfade") ? FADE_MODE_CROSSFADE : string_has_parameter(value, "melt") ? FADE_MODE_MELT : + string_has_parameter(value, "curtain") ? FADE_MODE_CURTAIN : FADE_MODE_DEFAULT); } else if (strPrefix(suffix, ".font")) /* (may also be ".font_xyz") */