X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Flibgame%2Fmisc.c;h=9b3f663352d5833598f6fc81885014758e5f05d5;hb=891c39ca37c4fea5f6cc4ca40f913a56c68ef495;hp=84ec36021cfc3dbc20c8dbcc06e08f7000b3f69f;hpb=1bd9644544424ed912d886777c6e8ed387aac24a;p=rocksndiamonds.git diff --git a/src/libgame/misc.c b/src/libgame/misc.c index 84ec3602..9b3f6633 100644 --- a/src/libgame/misc.c +++ b/src/libgame/misc.c @@ -323,10 +323,27 @@ unsigned int init_random_number(int nr, long seed) return (unsigned int) seed; } +#if 1 unsigned int get_random_number(int nr, unsigned int max) { return (max > 0 ? random_linux_libc(nr) % max : 0); } +#else +unsigned int get_random_number(int nr, unsigned int max) +{ + unsigned int rnd = (max > 0 ? random_linux_libc(nr) % max : 0); + + if (nr == 0 && FrameCounter < 2) + printf("::: %d [%d]\n", rnd, FrameCounter); + +#if 0 + if (nr == 0 && FrameCounter < 2 && rnd == 8) + rnd /= 0; +#endif + + return rnd; +} +#endif /* ------------------------------------------------------------------------- */ @@ -533,36 +550,7 @@ void setString(char **old_value, char *new_value) /* command line option handling functions */ /* ------------------------------------------------------------------------- */ -static void printUsage() -{ - printf("\n" - "Usage: %s [OPTION]... [HOSTNAME [PORT]]\n" - "\n" - "Options:\n" - " -d, --display HOSTNAME[:SCREEN] specify X server display\n" - " -b, --basepath DIRECTORY alternative base DIRECTORY\n" - " -l, --level DIRECTORY alternative level DIRECTORY\n" - " -g, --graphics DIRECTORY alternative graphics DIRECTORY\n" - " -s, --sounds DIRECTORY alternative sounds DIRECTORY\n" - " -m, --music DIRECTORY alternative music DIRECTORY\n" - " -n, --network network multiplayer game\n" - " --serveronly only start network server\n" - " -v, --verbose verbose mode\n" - " --debug display debugging information\n" - " -e, --execute COMMAND execute batch COMMAND:\n" - "\n" - "Valid commands for '--execute' option:\n" - " \"print graphicsinfo.conf\" print default graphics config\n" - " \"print soundsinfo.conf\" print default sounds config\n" - " \"print musicinfo.conf\" print default music config\n" - " \"dump level FILE\" dump level data from FILE\n" - " \"dump tape FILE\" dump tape data from FILE\n" - " \"autoplay LEVELDIR\" play level tapes for LEVELDIR\n" - "\n", - program.command_basename); -} - -void GetOptions(char *argv[]) +void GetOptions(char *argv[], void (*print_usage_function)(void)) { char **options_left = &argv[1]; @@ -624,7 +612,7 @@ void GetOptions(char *argv[]) Error(ERR_EXIT_HELP, "unrecognized option '%s'", option); else if (strncmp(option, "-help", option_len) == 0) { - printUsage(); + print_usage_function(); exit(0); } @@ -984,28 +972,26 @@ void putFileChunk(FILE *file, char *chunk_name, int chunk_size, int getFileVersion(FILE *file) { - int version_major, version_minor, version_patch, version_release; - - version_major = fgetc(file); - version_minor = fgetc(file); - version_patch = fgetc(file); - version_release = fgetc(file); + int version_major = fgetc(file); + int version_minor = fgetc(file); + int version_patch = fgetc(file); + int version_build = fgetc(file); - return RELEASE_IDENT(version_major, version_minor, version_patch, - version_release); + return VERSION_IDENT(version_major, version_minor, version_patch, + version_build); } void 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_release = VERSION_RELEASE(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); - fputc(version_major, file); - fputc(version_minor, file); - fputc(version_patch, file); - fputc(version_release, file); + fputc(version_major, file); + fputc(version_minor, file); + fputc(version_patch, file); + fputc(version_build, file); } void ReadUnusedBytesFromFile(FILE *file, unsigned long bytes) @@ -2043,7 +2029,7 @@ static void LoadArtworkConfigFromFilename(struct ArtworkListInfo *artwork_info, /* ---------- step 0: search for matching base prefix ---------- */ start_pos = 0; - for (i=0; i