Addressing MR comments.

This commit is contained in:
Joshua Yanovski 2020-01-24 03:45:29 +01:00
parent 3a0483e8ee
commit 02f9c9490b
3 changed files with 15 additions and 13 deletions

View File

@ -94,11 +94,7 @@ impl ServerSettings {
}
pub fn singleplayer() -> Self {
let mut load = Self::load();
if let None = load.map_file {
// If loading the default map file, make sure the seed is also default.
load.world_seed = DEFAULT_WORLD_SEED;
};
let load = Self::load();
Self {
//BUG: theoretically another process can grab the port between here and server creation, however the timewindow is quite small
gameserver_address: SocketAddr::from((
@ -109,12 +105,18 @@ impl ServerSettings {
[127, 0, 0, 1],
pick_unused_port().expect("Failed to find unused port!"),
)),
// If loading the default map file, make sure the seed is also default.
world_seed: if load.map_file.is_some() {
load.world_seed
} else {
DEFAULT_WORLD_SEED
},
server_name: "Singleplayer".to_owned(),
server_description: "Who needs friends anyway?".to_owned(),
max_players: 100,
start_time: 9.0 * 3600.0,
admins: vec!["singleplayer".to_string()], // TODO: Let the player choose if they want to use admin commands or not
..Self::load() // Fill in remaining fields from settings.ron.
..load // Fill in remaining fields from settings.ron.
}
}

View File

@ -26,7 +26,7 @@ roots = "0.0.5"
serde = "1.0.102"
serde_derive = "1.0.102"
ron = "0.5.1"
pretty_env_logger = "0.3.0"
[dev-dependencies]
minifb = { git = "https://github.com/emoon/rust_minifb.git" }
pretty_env_logger = "0.3.0"

View File

@ -17,8 +17,8 @@ pub use self::map::{MapConfig, MapDebug};
pub use self::settlement::Settlement;
pub use self::util::{
cdf_irwin_hall, downhill, get_oceans, local_cells, map_edge_factor, neighbors,
uniform_idx_as_vec2, uniform_noise, uphill, vec2_as_uniform_idx, HybridMulti as HybridMulti_,
InverseCdf, ScaleBias, NEIGHBOR_DELTA,
uniform_idx_as_vec2, uniform_noise, uphill, vec2_as_uniform_idx, InverseCdf, ScaleBias,
NEIGHBOR_DELTA,
};
use crate::{
@ -88,7 +88,7 @@ pub(crate) struct GenCtx {
pub turb_x_nz: SuperSimplex,
pub turb_y_nz: SuperSimplex,
pub chaos_nz: RidgedMulti,
pub alt_nz: HybridMulti_,
pub alt_nz: util::HybridMulti,
pub hill_nz: SuperSimplex,
pub temp_nz: Fbm,
// Humidity noise
@ -313,12 +313,12 @@ impl WorldSim {
.set_frequency(RidgedMulti::DEFAULT_FREQUENCY * (5_000.0 / continent_scale))
.set_seed(rng.gen()),
hill_nz: SuperSimplex::new().set_seed(rng.gen()),
alt_nz: HybridMulti_::new()
alt_nz: util::HybridMulti::new()
.set_octaves(8)
.set_frequency((10_000.0 / continent_scale) as f64)
// persistence = lacunarity^(-(1.0 - fractal increment))
.set_lacunarity(HybridMulti_::DEFAULT_LACUNARITY)
.set_persistence(HybridMulti_::DEFAULT_LACUNARITY.powf(-(1.0 - 0.0)))
.set_lacunarity(util::HybridMulti::DEFAULT_LACUNARITY)
.set_persistence(util::HybridMulti::DEFAULT_LACUNARITY.powf(-(1.0 - 0.0)))
.set_offset(0.0)
.set_seed(rng.gen()),
temp_nz: Fbm::new()