X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Flibgame%2Fmisc.c;h=cb0f65255487ad3ab9b2109a44bbe0481004acfe;hb=d42e0a36609c7990f8b9f6fcd80f37f65bcf5149;hp=3612ba045fcd649f9b4ec9a52dcf4b1762ad7f9d;hpb=9afd3ebaca7211c2c7e10926ddaaf422c73486dc;p=rocksndiamonds.git diff --git a/src/libgame/misc.c b/src/libgame/misc.c index 3612ba04..cb0f6525 100644 --- a/src/libgame/misc.c +++ b/src/libgame/misc.c @@ -52,6 +52,7 @@ void printf_line(char *line_string, int line_length) fprintf_line(stdout, line_string, line_length); } + /* int2str() returns a number converted to a string; the used memory is static, but will be overwritten by later calls, so if you want to save the result, copy it to a private string buffer; @@ -82,6 +83,7 @@ char *int2str(int number, int size) } } + /* something similar to "int2str()" above, but allocates its own memory and has a different interface; we cannot use "itoa()", because this seems to be already defined when cross-compiling to the win32 target */ @@ -103,6 +105,23 @@ char *i_to_a(unsigned int i) } +/* calculate base-2 logarithm of argument (rounded down to integer; + this function returns the number of the highest bit set in argument) */ + +int log_2(unsigned int x) +{ + int e = 0; + + while ((1 << e) < x) + { + x -= (1 << e); /* for rounding down (rounding up: remove this line) */ + e++; + } + + return e; +} + + /* ------------------------------------------------------------------------- */ /* counter functions */ /* ------------------------------------------------------------------------- */ @@ -660,6 +679,11 @@ void GetOptions(char *argv[], void (*print_usage_function)(void)) options.execute_command = option_arg; if (option_arg == next_option) options_left++; + +#if 1 + /* when doing batch processing, always enable verbose mode (warnings) */ + options.verbose = TRUE; +#endif } else if (*option == '-') {