forked from EXTERNAL/bareiron
getrandomg
This commit is contained in:
@@ -40,14 +40,6 @@
|
||||
// Calculated from TIME_BETWEEN_TICKS
|
||||
#define TICKS_PER_SECOND ((float)1000000 / TIME_BETWEEN_TICKS)
|
||||
|
||||
// Initial world generation seed, will be hashed on startup
|
||||
// Used in generating terrain and biomes
|
||||
#define INITIAL_WORLD_SEED 0xA103DE6C
|
||||
|
||||
// Initial general RNG seed, will be hashed on startup
|
||||
// Used in random game events like item drops and mob behavior
|
||||
#define INITIAL_RNG_SEED 0xE2B9419
|
||||
|
||||
// Size of each bilinearly interpolated area ("minichunk")
|
||||
// For best performance, CHUNK_SIZE should be a power of 2
|
||||
#define CHUNK_SIZE 8
|
||||
|
@@ -31,8 +31,8 @@
|
||||
ssize_t recv_count;
|
||||
uint8_t recv_buffer[MAX_RECV_BUF_LEN] = {0};
|
||||
|
||||
uint32_t world_seed = INITIAL_WORLD_SEED;
|
||||
uint32_t rng_seed = INITIAL_RNG_SEED;
|
||||
uint32_t world_seed;
|
||||
uint32_t rng_seed;
|
||||
|
||||
uint16_t world_time = 0;
|
||||
uint32_t server_ticks = 0;
|
||||
|
14
src/main.c
14
src/main.c
@@ -27,6 +27,7 @@
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <sys/select.h>
|
||||
#include <sys/random.h>
|
||||
#endif
|
||||
#include <unistd.h>
|
||||
#include <time.h>
|
||||
@@ -506,15 +507,16 @@ int main () {
|
||||
}
|
||||
#endif
|
||||
|
||||
// Hash the seeds to ensure they're random enough
|
||||
if (0) { // TODO: manual seed
|
||||
world_seed = splitmix64(world_seed);
|
||||
printf("World seed (hashed): ");
|
||||
} else {
|
||||
getrandom(&world_seed, 4, GRND_RANDOM);
|
||||
}
|
||||
printf("World seed: ");
|
||||
for (int i = 3; i >= 0; i --) printf("%X", (unsigned int)((world_seed >> (8 * i)) & 255));
|
||||
printf("\n");
|
||||
|
||||
rng_seed = splitmix64(rng_seed);
|
||||
printf("\nRNG seed (hashed): ");
|
||||
for (int i = 3; i >= 0; i --) printf("%X", (unsigned int)((rng_seed >> (8 * i)) & 255));
|
||||
printf("\n\n");
|
||||
getrandom(&rng_seed, 4, GRND_RANDOM);
|
||||
|
||||
// Initialize block changes entries as unallocated
|
||||
for (int i = 0; i < MAX_BLOCK_CHANGES; i ++) {
|
||||
|
Reference in New Issue
Block a user