Skip to content

Commit

Permalink
Fixed config seed
Browse files Browse the repository at this point in the history
  • Loading branch information
ELginas committed Jan 16, 2022
1 parent c47c564 commit 6341e91
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions feather/server/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
use std::{cell::RefCell, rc::Rc, sync::Arc};
use std::{
cell::RefCell,
collections::hash_map::DefaultHasher,
hash::{Hash, Hasher},
rc::Rc,
sync::Arc,
};

use anyhow::Context;
use base::anvil::level::SuperflatGeneratorOptions;
Expand Down Expand Up @@ -64,7 +70,11 @@ fn init_world_source(game: &mut Game, config: &Config) {
// world otherwise. This is a placeholder:
// we don't have proper world generation yet.

let seed = 42; // FIXME: load from the level file
let seed = config.world.seed.parse().unwrap_or_else(|_| {
let mut hasher = DefaultHasher::new();
config.world.seed.hash(&mut hasher);
hasher.finish()
});

let generator: Arc<dyn WorldGenerator> = match &config.world.generator[..] {
"flat" => Arc::new(SuperflatWorldGenerator::new(
Expand Down

0 comments on commit 6341e91

Please sign in to comment.