X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Flibgame%2Fmisc.c;h=a810b6d11072c89d0389712014ae6b54cfb3063f;hb=4dba06ad2079d7f9df56ec5512c6d27a0cf8c18e;hp=154f83438daa3a83370cb8464b97b2778d64e855;hpb=95ff39b11bc3c268d8206193bad1433ac9526c94;p=rocksndiamonds.git diff --git a/src/libgame/misc.c b/src/libgame/misc.c index 154f8343..a810b6d1 100644 --- a/src/libgame/misc.c +++ b/src/libgame/misc.c @@ -470,7 +470,7 @@ static char *getLastPathSeparatorPtr(char *filename) return last_separator; } -static char *getBaseNamePtr(char *filename) +char *getBaseNamePtr(char *filename) { char *last_separator = getLastPathSeparatorPtr(filename); @@ -750,6 +750,45 @@ void GetOptions(char *argv[], void (*print_usage_function)(void)) /* when doing batch processing, always enable verbose mode (warnings) */ options.verbose = TRUE; } +#if 1 +#if DEBUG +#if defined(TARGET_SDL) + else if (strncmp(option, "-SDL_ListModes", option_len) == 0) + { + SDL_Rect **modes; + int i; + + SDL_Init(SDL_INIT_VIDEO); + + /* get available fullscreen/hardware modes */ + modes=SDL_ListModes(NULL, SDL_FULLSCREEN|SDL_HWSURFACE); + + /* check if there are any modes available */ + if (modes == (SDL_Rect **)0) + { + printf("No modes available!\n"); + + exit(-1); + } + + /* check if our resolution is restricted */ + if (modes == (SDL_Rect **)-1) + { + printf("All resolutions available.\n"); + } + else + { + /* print valid modes */ + printf("Available Modes:\n"); + for(i = 0; modes[i]; i++) + printf(" %d x %d\n", modes[i]->w, modes[i]->h); + } + + exit(0); + } +#endif +#endif +#endif else if (*option == '-') { Error(ERR_EXIT_HELP, "unrecognized option '%s'", option_str); @@ -1041,17 +1080,27 @@ boolean getFileChunk(FILE *file, char *chunk_name, int *chunk_size, return (feof(file) || ferror(file) ? FALSE : TRUE); } -void putFileChunk(FILE *file, char *chunk_name, int chunk_size, - int byte_order) +int putFileChunk(FILE *file, char *chunk_name, int chunk_size, + int byte_order) { + int num_bytes = 0; + /* write chunk name */ - fputs(chunk_name, file); + if (file != NULL) + fputs(chunk_name, file); + + num_bytes += strlen(chunk_name); if (chunk_size >= 0) { /* write chunk size */ - putFile32BitInteger(file, chunk_size, byte_order); + if (file != NULL) + putFile32BitInteger(file, chunk_size, byte_order); + + num_bytes += 4; } + + return num_bytes; } int getFileVersion(FILE *file) @@ -1065,17 +1114,22 @@ int getFileVersion(FILE *file) version_build); } -void putFileVersion(FILE *file, int version) +int putFileVersion(FILE *file, int version) { - int version_major = VERSION_MAJOR(version); - int version_minor = VERSION_MINOR(version); - int version_patch = VERSION_PATCH(version); - int version_build = VERSION_BUILD(version); + if (file != NULL) + { + int version_major = VERSION_MAJOR(version); + int version_minor = VERSION_MINOR(version); + int version_patch = VERSION_PATCH(version); + int version_build = VERSION_BUILD(version); - fputc(version_major, file); - fputc(version_minor, file); - fputc(version_patch, file); - fputc(version_build, file); + fputc(version_major, file); + fputc(version_minor, file); + fputc(version_patch, file); + fputc(version_build, file); + } + + return 4; } void ReadBytesFromFile(FILE *file, byte *buffer, unsigned long bytes) @@ -1779,6 +1833,7 @@ int get_parameter_value(char *value_raw, char *suffix, int type) string_has_parameter(value, "random") ? ANIM_RANDOM : string_has_parameter(value, "ce_value") ? ANIM_CE_VALUE : string_has_parameter(value, "ce_score") ? ANIM_CE_SCORE : + string_has_parameter(value, "ce_delay") ? ANIM_CE_DELAY : string_has_parameter(value, "horizontal") ? ANIM_HORIZONTAL : string_has_parameter(value, "vertical") ? ANIM_VERTICAL : ANIM_DEFAULT); @@ -2067,6 +2122,10 @@ static void LoadArtworkConfigFromFilename(struct ArtworkListInfo *artwork_info, if (filename == NULL) return; +#if 0 + printf("LoadArtworkConfigFromFilename '%s' ...\n", filename); +#endif + if ((setup_file_hash = loadSetupFileHash(filename)) == NULL) return; @@ -2433,10 +2492,6 @@ void LoadArtworkConfig(struct ArtworkListInfo *artwork_info) char *filename_base = UNDEFINED_FILENAME, *filename_local; int i, j; -#if 0 - printf("GOT CUSTOM ARTWORK CONFIG FILE '%s'\n", filename); -#endif - DrawInitText("Loading artwork config:", 120, FC_GREEN); DrawInitText(ARTWORKINFO_FILENAME(artwork_info->type), 150, FC_YELLOW);