From: Holger Schemel Date: Wed, 5 Jan 2022 17:07:24 +0000 (+0100) Subject: added abstraction for function for generating UUID X-Git-Tag: 4.3.0.3~4 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=70c108958d4e0b09da1095b7dddb4e3ce465e09f;p=rocksndiamonds.git added abstraction for function for generating UUID --- diff --git a/src/libgame/misc.c b/src/libgame/misc.c index 48d67a79..33c6abc1 100644 --- a/src/libgame/misc.c +++ b/src/libgame/misc.c @@ -557,7 +557,12 @@ boolean getTokenValueFromString(char *string, char **token, char **value) #define UUID_CHARS (UUID_BYTES * 2) #define UUID_LENGTH (UUID_CHARS + 4) -char *getUUID(void) +static unsigned int uuid_random_function(int max) +{ + return GetSimpleRandom(max); +} + +char *getUUIDExt(unsigned int (*random_function)(int max)) { static char uuid[UUID_LENGTH + 1]; int data[UUID_BYTES]; @@ -565,7 +570,7 @@ char *getUUID(void) int i; for (i = 0; i < UUID_BYTES; i++) - data[i] = GetSimpleRandom(256); + data[i] = random_function(256); data[6] = 0x40 | (data[6] & 0x0f); data[8] = 0x80 | (data[8] & 0x3f); @@ -582,6 +587,11 @@ char *getUUID(void) return uuid; } +char *getUUID(void) +{ + return getUUIDExt(uuid_random_function); +} + // ---------------------------------------------------------------------------- // counter functions