X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Flibgame%2Fmisc.c;h=d8140b7e8e09a189909ef7939bdba771ba45114b;hb=d9ebb78b0e0290d76d3ee3d8f864ac6767cab61e;hp=b72fa146cd684385f84190b654cfd66b8a784233;hpb=c4e1a476135ce36417cdd797481feeaaff4301af;p=rocksndiamonds.git diff --git a/src/libgame/misc.c b/src/libgame/misc.c index b72fa146..d8140b7e 100644 --- a/src/libgame/misc.c +++ b/src/libgame/misc.c @@ -1,7 +1,7 @@ /*********************************************************** * Artsoft Retro-Game Library * *----------------------------------------------------------* -* (c) 1994-2000 Artsoft Entertainment * +* (c) 1994-2001 Artsoft Entertainment * * Holger Schemel * * Detmolder Strasse 189 * * 33604 Bielefeld * @@ -473,7 +473,8 @@ void GetOptions(char *argv[]) " -l, --level directory alternative level directory\n" " -s, --serveronly only start network server\n" " -n, --network network multiplayer game\n" - " -v, --verbose verbose mode\n", + " -v, --verbose verbose mode\n" + " --debug display debugging information\n", program.command_basename); exit(0); } @@ -551,15 +552,18 @@ void Error(int mode, char *format, ...) { char *process_name = ""; FILE *error = stderr; + char *newline = "\n"; /* display warnings only when running in verbose mode */ if (mode & ERR_WARN && !options.verbose) return; #if !defined(PLATFORM_UNIX) + newline = "\r\n"; + if ((error = openErrorFile()) == NULL) { - printf("Cannot write to error output file!\n"); + printf("Cannot write to error output file!%s", newline); program.exit_function(1); } #endif @@ -584,15 +588,16 @@ void Error(int mode, char *format, ...) vfprintf(error, format, ap); va_end(ap); - fprintf(error, "\n"); + fprintf(error, "%s", newline); } if (mode & ERR_HELP) - fprintf(error, "%s: Try option '--help' for more information.\n", - program.command_basename); + fprintf(error, "%s: Try option '--help' for more information.%s", + program.command_basename, newline); if (mode & ERR_EXIT) - fprintf(error, "%s%s: aborting\n", program.command_basename, process_name); + fprintf(error, "%s%s: aborting%s", + program.command_basename, process_name, newline); if (error != stderr) fclose(error); @@ -696,26 +701,28 @@ void putFile32BitInteger(FILE *file, int value, int byte_order) } } -void getFileChunk(FILE *file, char *chunk_buffer, int *chunk_length, - int byte_order) +boolean getFileChunk(FILE *file, char *chunk_name, int *chunk_size, + int byte_order) { - const int chunk_identifier_length = 4; + const int chunk_name_length = 4; + + /* read chunk name */ + fgets(chunk_name, chunk_name_length + 1, file); - /* read chunk identifier */ - fgets(chunk_buffer, chunk_identifier_length + 1, file); + /* read chunk size */ + *chunk_size = getFile32BitInteger(file, byte_order); - /* read chunk length */ - *chunk_length = getFile32BitInteger(file, byte_order); + return (feof(file) || ferror(file) ? FALSE : TRUE); } -void putFileChunk(FILE *file, char *chunk_name, int chunk_length, +void putFileChunk(FILE *file, char *chunk_name, int chunk_size, int byte_order) { - /* write chunk identifier */ + /* write chunk name */ fputs(chunk_name, file); - /* write chunk length */ - putFile32BitInteger(file, chunk_length, byte_order); + /* write chunk size */ + putFile32BitInteger(file, chunk_size, byte_order); } #define TRANSLATE_KEYSYM_TO_KEYNAME 0