mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
move Calendar object into WorldSim
(needed for Christmas decoration in towns)
This commit is contained in:
parent
47a6cf8ee3
commit
42ba9212ea
@ -356,6 +356,7 @@ impl Server {
|
||||
// Load default map from assets.
|
||||
FileOpts::LoadAsset(DEFAULT_WORLD_MAP.into())
|
||||
},
|
||||
calendar: Some(settings.calendar_mode.calendar_now()),
|
||||
},
|
||||
state.thread_pool(),
|
||||
);
|
||||
@ -363,7 +364,6 @@ impl Server {
|
||||
#[cfg(feature = "worldgen")]
|
||||
let map = world.get_map_data(
|
||||
index.as_index_ref(),
|
||||
Some(&settings.calendar_mode.calendar_now()),
|
||||
state.thread_pool(),
|
||||
);
|
||||
|
||||
|
@ -123,7 +123,6 @@ impl World {
|
||||
pub fn get_map_data(
|
||||
&self,
|
||||
index: IndexRef,
|
||||
calendar: Option<&Calendar>,
|
||||
threadpool: &rayon::ThreadPool,
|
||||
) -> WorldMapMsg {
|
||||
threadpool.install(|| {
|
||||
@ -184,7 +183,7 @@ impl World {
|
||||
}),
|
||||
)
|
||||
.collect(),
|
||||
..self.sim.get_map(index, calendar)
|
||||
..self.sim.get_map(index, self.sim().calendar.as_ref())
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -184,6 +184,7 @@ pub struct WorldOpts {
|
||||
/// Set to false to disable seeding elements during worldgen.
|
||||
pub seed_elements: bool,
|
||||
pub world_file: FileOpts,
|
||||
pub calendar: Option<Calendar>,
|
||||
}
|
||||
|
||||
impl Default for WorldOpts {
|
||||
@ -191,6 +192,7 @@ impl Default for WorldOpts {
|
||||
Self {
|
||||
seed_elements: true,
|
||||
world_file: Default::default(),
|
||||
calendar: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -386,13 +388,17 @@ pub struct WorldSim {
|
||||
|
||||
pub(crate) gen_ctx: GenCtx,
|
||||
pub rng: ChaChaRng,
|
||||
|
||||
pub(crate) calendar: Option<Calendar>,
|
||||
}
|
||||
|
||||
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;
|
||||
// Parse out the contents of various map formats into the values we need.
|
||||
let parsed_world_file = (|| {
|
||||
let map = match opts.world_file {
|
||||
let map = match world_file {
|
||||
FileOpts::LoadLegacy(ref path) => {
|
||||
let file = match File::open(path) {
|
||||
Ok(file) => file,
|
||||
@ -492,7 +498,7 @@ impl WorldSim {
|
||||
},
|
||||
})
|
||||
.unwrap_or_else(|| {
|
||||
let size_lg = match opts.world_file {
|
||||
let size_lg = match world_file {
|
||||
FileOpts::Generate(SizeOpts { x_lg, y_lg, .. })
|
||||
| FileOpts::Save(SizeOpts { x_lg, y_lg, .. }) => {
|
||||
MapSizeLg::new(Vec2 { x: x_lg, y: y_lg }).unwrap_or_else(|e| {
|
||||
@ -507,7 +513,7 @@ impl WorldSim {
|
||||
let continent_scale_hack = if let Some(map) = &parsed_world_file {
|
||||
map.continent_scale_hack
|
||||
} else if let FileOpts::Generate(SizeOpts { scale, .. })
|
||||
| FileOpts::Save(SizeOpts { scale, .. }) = opts.world_file
|
||||
| FileOpts::Save(SizeOpts { scale, .. }) = world_file
|
||||
{
|
||||
scale
|
||||
} else {
|
||||
@ -1140,7 +1146,7 @@ impl WorldSim {
|
||||
basement,
|
||||
});
|
||||
(|| {
|
||||
if let FileOpts::Save { .. } = opts.world_file {
|
||||
if let FileOpts::Save { .. } = world_file {
|
||||
use std::time::SystemTime;
|
||||
// Check if folder exists and create it if it does not
|
||||
let mut path = PathBuf::from("./maps");
|
||||
@ -1443,6 +1449,7 @@ impl WorldSim {
|
||||
_locations: Vec::new(),
|
||||
gen_ctx,
|
||||
rng,
|
||||
calendar,
|
||||
};
|
||||
|
||||
this.generate_cliffs();
|
||||
|
Loading…
Reference in New Issue
Block a user