mirror of
https://github.com/luanti-org/luanti.git
synced 2025-10-14 09:05:19 +02:00
Accept hexadecimal and string values for seeds
This commit is contained in:
@@ -19,6 +19,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
|
||||
#include "string.h"
|
||||
#include "pointer.h"
|
||||
#include "numeric.h"
|
||||
|
||||
#include "../sha1.h"
|
||||
#include "../base64.h"
|
||||
@@ -136,3 +137,18 @@ char *mystrtok_r(char *s, const char *sep, char **lasts) {
|
||||
*lasts = t;
|
||||
return s;
|
||||
}
|
||||
|
||||
u64 read_seed(const char *str) {
|
||||
char *endptr;
|
||||
u64 num;
|
||||
|
||||
if (str[0] == '0' && str[1] == 'x')
|
||||
num = strtoull(str, &endptr, 16);
|
||||
else
|
||||
num = strtoull(str, &endptr, 10);
|
||||
|
||||
if (*endptr)
|
||||
num = murmur_hash_64_ua(str, (int)strlen(str), 0x1337);
|
||||
|
||||
return num;
|
||||
}
|
||||
|
Reference in New Issue
Block a user