cargo fmt, pass calendar down into building creation

This commit is contained in:
Christof Petig 2021-12-14 12:54:01 -06:00 committed by Joshua Barretto
parent 42ba9212ea
commit 8a85d6e6e0
5 changed files with 7 additions and 12 deletions

View File

@ -362,10 +362,7 @@ impl Server {
);
#[cfg(feature = "worldgen")]
let map = world.get_map_data(
index.as_index_ref(),
state.thread_pool(),
);
let map = world.get_map_data(index.as_index_ref(), state.thread_pool());
#[cfg(not(feature = "worldgen"))]
let (world, index) = World::generate(settings.world_seed);

View File

@ -120,11 +120,7 @@ impl World {
// TODO
}
pub fn get_map_data(
&self,
index: IndexRef,
threadpool: &rayon::ThreadPool,
) -> WorldMapMsg {
pub fn get_map_data(&self, index: IndexRef, threadpool: &rayon::ThreadPool) -> WorldMapMsg {
threadpool.install(|| {
// we need these numbers to create unique ids for cave ends
let num_sites = self.civs().sites().count() as u64;

View File

@ -395,7 +395,7 @@ pub struct WorldSim {
impl WorldSim {
pub fn generate(seed: u32, opts: WorldOpts, threadpool: &rayon::ThreadPool) -> Self {
let calendar = opts.calendar; // separate lifetime of elements
let world_file = opts.world_file;
let world_file = opts.world_file;
// Parse out the contents of various map formats into the values we need.
let parsed_world_file = (|| {
let map = match world_file {

View File

@ -8,7 +8,7 @@ pub use self::{
};
use crate::IndexRef;
use common::terrain::Block;
use common::{calendar::Calendar, terrain::Block};
use rand::prelude::*;
use serde::Deserialize;
use vek::*;
@ -25,7 +25,7 @@ pub struct Building<A: Archetype> {
}
impl<A: Archetype> Building<A> {
pub fn generate(rng: &mut impl Rng, origin: Vec3<i32>) -> Self
pub fn generate(rng: &mut impl Rng, origin: Vec3<i32>, calendar: Option<&Calendar>) -> Self
where
A: Sized,
{

View File

@ -440,11 +440,13 @@ impl Settlement {
StructureKind::Keep(Building::<Keep>::generate(
ctx.rng,
Vec3::new(house_pos.x, house_pos.y, alt),
None,
))
} else {
StructureKind::House(Building::<House>::generate(
ctx.rng,
Vec3::new(house_pos.x, house_pos.y, alt),
ctx.sim.map(|sim| sim.calendar.as_ref()).flatten(),
))
},
};