X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Flibgame%2Fmisc.c;h=a7eeb72f3042808a985ccbc1977fe3df1082dff4;hb=73dfe4a920cabf20138c0ba49964a3c8c3f752d0;hp=3612ba045fcd649f9b4ec9a52dcf4b1762ad7f9d;hpb=9afd3ebaca7211c2c7e10926ddaaf422c73486dc;p=rocksndiamonds.git diff --git a/src/libgame/misc.c b/src/libgame/misc.c index 3612ba04..a7eeb72f 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 == '-') { @@ -1208,7 +1232,7 @@ void translate_keyname(Key *keysym, char **x11name, char **name, int mode) char c = name_ptr[6]; if (c >= '0' && c <= '9') - key = KSYM_0 + (Key)(c - '0'); + key = KSYM_KP_0 + (Key)(c - '0'); } else if (strncmp(name_ptr, "XK_F", 4) == 0 && strlen(name_ptr) <= 6) {