projects
/
rocksndiamonds.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
7354588
)
added abstraction for function for generating UUID
author
Holger Schemel
<info@artsoft.org>
Wed, 5 Jan 2022 17:07:24 +0000
(18:07 +0100)
committer
Holger Schemel
<info@artsoft.org>
Wed, 5 Jan 2022 17:07:24 +0000
(18:07 +0100)
src/libgame/misc.c
patch
|
blob
|
history
diff --git
a/src/libgame/misc.c
b/src/libgame/misc.c
index 48d67a792dd5b7ea435f5217c0ad1a83b6e1f257..33c6abc16ff25a6c9e7ddb957173625b975dd627 100644
(file)
--- 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)
#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];
{
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++)
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);
data[6] = 0x40 | (data[6] & 0x0f);
data[8] = 0x80 | (data[8] & 0x3f);
@@
-582,6
+587,11
@@
char *getUUID(void)
return uuid;
}
return uuid;
}
+char *getUUID(void)
+{
+ return getUUIDExt(uuid_random_function);
+}
+
// ----------------------------------------------------------------------------
// counter functions
// ----------------------------------------------------------------------------
// counter functions