From 5a686a0e8b75565b23955a51be8c455959427d85 Mon Sep 17 00:00:00 2001 From: Ryan Date: Fri, 7 Oct 2022 00:17:14 -0700 Subject: [PATCH] Derive terrain seed from current day It's easier to test things when the terrain isn't constantly changing. --- examples/terrain.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/examples/terrain.rs b/examples/terrain.rs index 1026785..993d5d7 100644 --- a/examples/terrain.rs +++ b/examples/terrain.rs @@ -1,5 +1,6 @@ use std::net::SocketAddr; use std::sync::atomic::{AtomicUsize, Ordering}; +use std::time::SystemTime; use log::LevelFilter; use noise::{NoiseFn, Seedable, SuperSimplex}; @@ -23,7 +24,12 @@ pub fn main() -> ShutdownResult { .parse_default_env() .init(); - let seed = rand::random(); + let seconds_per_day = 86_400; + + let seed = (SystemTime::now() + .duration_since(SystemTime::UNIX_EPOCH)? + .as_secs() + / seconds_per_day) as u32; valence::start_server( Game {