mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Accept hexadecimal and string values for seeds
This commit is contained in:
parent
1a96987d0f
commit
e46c527733
6 changed files with 68 additions and 2 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue