X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Flibgame%2Fmisc.c;h=e7c2e098f513cfebe52a6a97a01e45de043900f2;hb=effd5d5c5bcf0edefb1bccf031510d9839d7789c;hp=ed4c2606e81026f94c307d9da347eab39f3db3b8;hpb=411da92d158734699a25a7925a89f29b18fb373f;p=rocksndiamonds.git diff --git a/src/libgame/misc.c b/src/libgame/misc.c index ed4c2606..e7c2e098 100644 --- a/src/libgame/misc.c +++ b/src/libgame/misc.c @@ -549,6 +549,40 @@ boolean getTokenValueFromString(char *string, char **token, char **value) } +// ---------------------------------------------------------------------------- +// UUID functions +// ---------------------------------------------------------------------------- + +#define UUID_BYTES 16 +#define UUID_CHARS (UUID_BYTES * 2) +#define UUID_LENGTH (UUID_CHARS + 4) + +char *getUUID(void) +{ + static char uuid[UUID_LENGTH + 1]; + int data[UUID_BYTES]; + int count = 0; + int i; + + for (i = 0; i < UUID_BYTES; i++) + data[i] = GetSimpleRandom(256); + + data[6] = 0x40 | (data[6] & 0x0f); + data[8] = 0x80 | (data[8] & 0x3f); + + for (i = 0; i < UUID_BYTES; i++) + { + sprintf(&uuid[count], "%02x", data[i]); + count += 2; + + if (i == 3 || i == 5 || i == 7 || i == 9) + strcat(&uuid[count++], "-"); + } + + return uuid; +} + + // ---------------------------------------------------------------------------- // counter functions // ---------------------------------------------------------------------------- @@ -1265,6 +1299,7 @@ void GetOptions(int argc, char *argv[], options.tape_log_filename = NULL; options.special_flags = NULL; options.debug_mode = NULL; + options.player_name = NULL; options.mytapes = FALSE; options.serveronly = FALSE; @@ -1402,6 +1437,15 @@ void GetOptions(int argc, char *argv[], if (option_arg != next_option) options.debug_mode = getStringCopy(option_arg); } + else if (strncmp(option, "-player-name", option_len) == 0) + { + if (option_arg == NULL) + FailWithHelp("option '%s' requires an argument", option_str); + + options.player_name = getStringCopy(option_arg); + if (option_arg == next_option) + options_left++; + } else if (strncmp(option, "-verbose", option_len) == 0) { options.verbose = TRUE;