X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Fmisc.c;h=88f1cd7719ba53f99210dd0acddeeaa99cd37bcd;hb=4f767d54c7ac468e9a42e22caf716111be1ceba9;hp=8c88fe2930ff054b8a7721df85b53bdc9eddcd53;hpb=c878cb2be6a0bffee850bf4f2dcb1939d5d2cd4f;p=rocksndiamonds.git diff --git a/src/misc.c b/src/misc.c index 8c88fe29..88f1cd77 100644 --- a/src/misc.c +++ b/src/misc.c @@ -18,6 +18,7 @@ #include #include #include +#include #include "misc.h" #include "init.h" @@ -26,6 +27,9 @@ #include "random.h" #include "joystick.h" +/* maximal allowed length of a command line option */ +#define MAX_OPTION_LEN 256 + static unsigned long mainCounter(int mode) { static struct timeval base_time = { 0, 0 }; @@ -158,9 +162,22 @@ unsigned int SimpleRND(unsigned int max) return (root % max); } +#ifdef DEBUG +static unsigned int last_RND_value = 0; + +unsigned int last_RND() +{ + return last_RND_value; +} +#endif + unsigned int RND(unsigned int max) { +#ifdef DEBUG + return (last_RND_value = random_linux_libc() % max); +#else return (random_linux_libc() % max); +#endif } unsigned int InitRND(long seed) @@ -226,6 +243,17 @@ char *getStringCopy(char *s) return s_copy; } +char *getStringToLower(char *s) +{ + char *s_copy = checked_malloc(strlen(s) + 1); + char *s_ptr = s_copy; + + while (*s) + *s_ptr++ = tolower(*s++); + + return s_copy; +} + void MarkTileDirty(int x, int y) { int xx = redraw_x1 + x;