From 8e95cb944de228fce7184e52b7a04a44cea1e35e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20M=C3=A4rtens?= Date: Thu, 5 Oct 2023 20:06:05 +0200 Subject: [PATCH] cargo fmt after updating new toolchain --- client/src/lib.rs | 18 +++++----- common/src/comp/group.rs | 19 +++++----- common/src/comp/inventory/loadout_builder.rs | 12 ++----- common/src/lottery.rs | 11 +++--- common/src/mounting.rs | 5 +-- common/src/volumes/chunk.rs | 8 ++--- common/state/src/plugin/exports.rs | 4 ++- common/systems/src/mount.rs | 36 +++++++++++-------- rtsim/src/gen/mod.rs | 25 ++++++++----- server/agent/src/attack.rs | 3 +- server/src/lib.rs | 30 ++++++---------- server/src/state_ext.rs | 8 +++-- server/src/sys/agent/behavior_tree.rs | 8 ++--- server/src/sys/subscription.rs | 4 +-- server/src/sys/teleporter.rs | 9 +++-- voxygen/src/hud/crafting.rs | 4 +-- voxygen/src/hud/mod.rs | 4 +-- voxygen/src/render/pipelines/trail.rs | 6 +++- voxygen/src/render/renderer.rs | 28 ++++----------- voxygen/src/render/renderer/drawer.rs | 4 ++- voxygen/src/scene/figure/mod.rs | 2 +- voxygen/src/session/interactable.rs | 10 +++--- .../src/singleplayer/singleplayer_world.rs | 2 +- world/examples/world_block_statistics.rs | 5 +-- world/src/civ/mod.rs | 4 ++- world/src/layer/cave.rs | 4 ++- world/src/sim/erosion.rs | 32 ++++++++--------- world/src/sim/util.rs | 4 +-- world/src/site2/plot/citadel.rs | 5 +-- world/src/site2/plot/gnarling.rs | 7 +--- world/src/site2/plot/house.rs | 10 +++--- 31 files changed, 163 insertions(+), 168 deletions(-) diff --git a/client/src/lib.rs b/client/src/lib.rs index 0d952e441d..34ed295b39 100644 --- a/client/src/lib.rs +++ b/client/src/lib.rs @@ -1809,18 +1809,16 @@ impl Client { // significant changes to this code. Here is the approximate order of // things. Please update it as this code changes. // - // 1) Collect input from the frontend, apply input effects to the state - // of the game + // 1) Collect input from the frontend, apply input effects to the state of the + // game // 2) Handle messages from the server - // 3) Go through any events (timer-driven or otherwise) that need handling - // and apply them to the state of the game - // 4) Perform a single LocalState tick (i.e: update the world and entities - // in the world) - // 5) Go through the terrain update queue and apply all changes - // to the terrain + // 3) Go through any events (timer-driven or otherwise) that need handling and + // apply them to the state of the game + // 4) Perform a single LocalState tick (i.e: update the world and entities in + // the world) + // 5) Go through the terrain update queue and apply all changes to the terrain // 6) Sync information to the server - // 7) Finish the tick, passing actions of the main thread back - // to the frontend + // 7) Finish the tick, passing actions of the main thread back to the frontend // 1) Handle input from frontend. // Pass character actions from frontend input to the player's entity. diff --git a/common/src/comp/group.rs b/common/src/comp/group.rs index 30fb2af02d..dd63a45710 100644 --- a/common/src/comp/group.rs +++ b/common/src/comp/group.rs @@ -118,14 +118,17 @@ pub fn members<'a>( ) -> impl Iterator + 'a { (entities, groups, alignments, uids) .join() - .filter(move |&(_e, g, _a, _u)| (*g == group)).map(|(e, _g, a, u)| ( - e, - if matches!(a, Alignment::Owned(owner) if owner != u) { - Role::Pet - } else { - Role::Member - }, - )) + .filter(move |&(_e, g, _a, _u)| (*g == group)) + .map(|(e, _g, a, u)| { + ( + e, + if matches!(a, Alignment::Owned(owner) if owner != u) { + Role::Pet + } else { + Role::Member + }, + ) + }) } // TODO: optimize add/remove for massive NPC groups diff --git a/common/src/comp/inventory/loadout_builder.rs b/common/src/comp/inventory/loadout_builder.rs index f7d804ab24..c363150199 100644 --- a/common/src/comp/inventory/loadout_builder.rs +++ b/common/src/comp/inventory/loadout_builder.rs @@ -121,16 +121,8 @@ impl Hands { Hands::InHands((mainhand, offhand)) => { let mut from_spec = |i: &ItemSpec| i.try_to_item(rng); - let mainhand = mainhand - .as_ref() - .map(&mut from_spec) - .transpose()? - .flatten(); - let offhand = offhand - .as_ref() - .map(&mut from_spec) - .transpose()? - .flatten(); + let mainhand = mainhand.as_ref().map(&mut from_spec).transpose()?.flatten(); + let offhand = offhand.as_ref().map(&mut from_spec).transpose()?.flatten(); Ok((mainhand, offhand)) }, Hands::Choice(pairs) => { diff --git a/common/src/lottery.rs b/common/src/lottery.rs index 1545ac65c3..63ddc9c95d 100644 --- a/common/src/lottery.rs +++ b/common/src/lottery.rs @@ -133,8 +133,12 @@ pub fn distribute_many( let Some(mut give) = participants .iter() - .map(|participant| (total_item_amount as f32 * participant.weight / total_weight).ceil() as u32 - participant.recieved_count) - .min() else { + .map(|participant| { + (total_item_amount as f32 * participant.weight / total_weight).ceil() as u32 + - participant.recieved_count + }) + .min() + else { tracing::error!("Tried to distribute items to no participants."); return; }; @@ -152,8 +156,7 @@ pub fn distribute_many( let participant_count = participants.len(); - let Some(winner) = participants - .get_mut(index) else { + let Some(winner) = participants.get_mut(index) else { tracing::error!("Tried to distribute items to no participants."); return; }; diff --git a/common/src/mounting.rs b/common/src/mounting.rs index 4ad742ea1d..002b4735e2 100644 --- a/common/src/mounting.rs +++ b/common/src/mounting.rs @@ -380,8 +380,9 @@ impl Link for VolumeMounting { Volume::Terrain => &*terrain_riders, Volume::Entity(uid) => { let Some(riders) = entity(uid) - .filter(|entity| is_alive(*entity)) - .and_then(|entity| volume_riders.get(entity)) else { + .filter(|entity| is_alive(*entity)) + .and_then(|entity| volume_riders.get(entity)) + else { return false; }; riders diff --git a/common/src/volumes/chunk.rs b/common/src/volumes/chunk.rs index 148a71d94a..ccb6d417f7 100644 --- a/common/src/volumes/chunk.rs +++ b/common/src/volumes/chunk.rs @@ -86,10 +86,10 @@ impl Chunk { // // Rationales: // - // 1. We have code in the implementation that assumes it. In particular, - // code using `.count_ones()`. - // 2. The maximum group size is `256x256x256`, because there's code that - // stores group relative indices as `u8`. + // 1. We have code in the implementation that assumes it. In particular, code + // using `.count_ones()`. + // 2. The maximum group size is `256x256x256`, because there's code that stores + // group relative indices as `u8`. // 3. There's code that stores group indices as `u8`. debug_assert!(S::SIZE.x.is_power_of_two()); debug_assert!(S::SIZE.y.is_power_of_two()); diff --git a/common/state/src/plugin/exports.rs b/common/state/src/plugin/exports.rs index 9b96af34f0..7ff9a1d9cc 100644 --- a/common/state/src/plugin/exports.rs +++ b/common/state/src/plugin/exports.rs @@ -84,7 +84,9 @@ pub(crate) fn wasi_fd_write( let Ok(cio) = iov_addr .add_offset(i) .and_then(|p| p.read(&memory.view(&store))) - else { return Errno::Memviolation as i32; }; + else { + return Errno::Memviolation as i32; + }; if let Err(e) = print_impl(env.data(), &store, cio.buf, cio.buf_len) { return e as i32; } diff --git a/common/systems/src/mount.rs b/common/systems/src/mount.rs index 064f91ef62..ce6a7c46e4 100644 --- a/common/systems/src/mount.rs +++ b/common/systems/src/mount.rs @@ -53,27 +53,35 @@ impl<'a> System<'a> for Sys { // For each mount... for (entity, is_mount, body) in (&entities, &is_mounts, bodies.maybe()).join() { // ...find the rider... - let Some((inputs_and_actions, rider)) = id_maps - .uid_entity(is_mount.rider) - .and_then(|rider| { - controllers - .get_mut(rider) - .map(|c| ( - // Only take inputs and actions from the rider if the mount is not intelligent (TODO: expand the definition of 'intelligent'). + let Some((inputs_and_actions, rider)) = + id_maps.uid_entity(is_mount.rider).and_then(|rider| { + controllers.get_mut(rider).map(|c| { + ( + // Only take inputs and actions from the rider if the mount is not + // intelligent (TODO: expand the definition of 'intelligent'). if !matches!(body, Some(Body::Humanoid(_))) { - let actions = c.actions.extract_if(|action| match action { - ControlAction::StartInput { input: i, .. } - | ControlAction::CancelInput(i) => matches!(i, InputKind::Jump | InputKind::Fly | InputKind::Roll), - _ => false - }).collect(); + let actions = c + .actions + .extract_if(|action| match action { + ControlAction::StartInput { input: i, .. } + | ControlAction::CancelInput(i) => matches!( + i, + InputKind::Jump | InputKind::Fly | InputKind::Roll + ), + _ => false, + }) + .collect(); Some((c.inputs.clone(), actions)) } else { None }, rider, - )) + ) + }) }) - else { continue }; + else { + continue; + }; // ...apply the mount's position/ori/velocity to the rider... let pos = positions.get(entity).copied(); diff --git a/rtsim/src/gen/mod.rs b/rtsim/src/gen/mod.rs index 4c20b55fd5..5af66d5589 100644 --- a/rtsim/src/gen/mod.rs +++ b/rtsim/src/gen/mod.rs @@ -94,7 +94,9 @@ impl Data { .faction .and_then(|f| this.factions.get(f)) .map(|f| f.good_or_evil) - else { continue }; + else { + continue; + }; let rand_wpos = |rng: &mut SmallRng, matches_plot: fn(&PlotKind) -> bool| { let wpos2d = site2 @@ -257,18 +259,23 @@ impl Data { let Some(species) = [ Some(comp::body::biped_large::Species::Ogre), Some(comp::body::biped_large::Species::Cyclops), - Some(comp::body::biped_large::Species::Wendigo).filter(|_| biome == BiomeKind::Taiga), + Some(comp::body::biped_large::Species::Wendigo) + .filter(|_| biome == BiomeKind::Taiga), Some(comp::body::biped_large::Species::Cavetroll), - Some(comp::body::biped_large::Species::Mountaintroll).filter(|_| biome == BiomeKind::Mountain), - Some(comp::body::biped_large::Species::Swamptroll).filter(|_| biome == BiomeKind::Swamp), + Some(comp::body::biped_large::Species::Mountaintroll) + .filter(|_| biome == BiomeKind::Mountain), + Some(comp::body::biped_large::Species::Swamptroll) + .filter(|_| biome == BiomeKind::Swamp), Some(comp::body::biped_large::Species::Blueoni), Some(comp::body::biped_large::Species::Redoni), - Some(comp::body::biped_large::Species::Tursus).filter(|_| chunk.temp < CONFIG.snow_temp), + Some(comp::body::biped_large::Species::Tursus) + .filter(|_| chunk.temp < CONFIG.snow_temp), ] - .into_iter() - .flatten() - .choose(&mut rng) - else { continue }; + .into_iter() + .flatten() + .choose(&mut rng) else { + continue; + }; this.npcs.create_npc(Npc::new( rng.gen(), diff --git a/server/agent/src/attack.rs b/server/agent/src/attack.rs index 46c09f65ab..fc867d8e2b 100644 --- a/server/agent/src/attack.rs +++ b/server/agent/src/attack.rs @@ -2924,7 +2924,8 @@ impl<'a> AgentData<'a> { { agent.action_state.counters[FCounters::SummonThreshold as usize] -= SUMMON_THRESHOLD; - agent.action_state.conditions[Conditions::AttackToggle as usize] = !agent.action_state.conditions[Conditions::AttackToggle as usize]; + agent.action_state.conditions[Conditions::AttackToggle as usize] = + !agent.action_state.conditions[Conditions::AttackToggle as usize]; } } else { // If target is in melee range use flamecrush diff --git a/server/src/lib.rs b/server/src/lib.rs index 7e3fc5758b..218bb13d08 100644 --- a/server/src/lib.rs +++ b/server/src/lib.rs @@ -4,13 +4,7 @@ clippy::needless_pass_by_ref_mut //until we find a better way for specs )] #![deny(clippy::clone_on_ref_ptr)] -#![feature( - box_patterns, - let_chains, - never_type, - option_zip, - unwrap_infallible -)] +#![feature(box_patterns, let_chains, never_type, option_zip, unwrap_infallible)] pub mod automod; mod character_creator; @@ -711,22 +705,20 @@ impl Server { // significant changes to this code. Here is the approximate order of // things. Please update it as this code changes. // - // 1) Collect input from the frontend, apply input effects to the - // state of the game - // 2) Go through any events (timer-driven or otherwise) that need handling - // and apply them to the state of the game - // 3) Go through all incoming client network communications, apply them to - // the game state - // 4) Perform a single LocalState tick (i.e: update the world and entities - // in the world) - // 5) Go through the terrain update queue and apply all changes to - // the terrain + // 1) Collect input from the frontend, apply input effects to the state of the + // game + // 2) Go through any events (timer-driven or otherwise) that need handling and + // apply them to the state of the game + // 3) Go through all incoming client network communications, apply them to the + // game state + // 4) Perform a single LocalState tick (i.e: update the world and entities in + // the world) + // 5) Go through the terrain update queue and apply all changes to the terrain // 6) Send relevant state updates to all clients // 7) Check for persistence updates related to character data, and message the // relevant entities // 8) Update Metrics with current data - // 9) Finish the tick, passing control of the main thread back - // to the frontend + // 9) Finish the tick, passing control of the main thread back to the frontend // 1) Build up a list of events for this frame, to be passed to the frontend. let mut frontend_events = Vec::new(); diff --git a/server/src/state_ext.rs b/server/src/state_ext.rs index eb8e943c9b..288d25ff59 100644 --- a/server/src/state_ext.rs +++ b/server/src/state_ext.rs @@ -875,8 +875,12 @@ impl StateExt for State { let mut automod = self.ecs().write_resource::(); let client = self.ecs().read_storage::(); let player = self.ecs().read_storage::(); - let Some(client) = client.get(entity) else { return true }; - let Some(player) = player.get(entity) else { return true }; + let Some(client) = client.get(entity) else { + return true; + }; + let Some(player) = player.get(entity) else { + return true; + }; match automod.validate_chat_msg( player.uuid(), diff --git a/server/src/sys/agent/behavior_tree.rs b/server/src/sys/agent/behavior_tree.rs index 36c01966dc..fad9d84823 100755 --- a/server/src/sys/agent/behavior_tree.rs +++ b/server/src/sys/agent/behavior_tree.rs @@ -885,11 +885,7 @@ fn remembers_fight_with( // read_data: &ReadData, // agent: &mut Agent, // target: EcsEntity, -// ) { -// rtsim_entity.is_some().then(|| { -// read_data -// .stats -// .get(target) -// .map(|stats| agent.add_fight_to_memory(&stats.name, +// ) { rtsim_entity.is_some().then(|| { read_data .stats .get(target) +// .map(|stats| agent.add_fight_to_memory(&stats.name, // read_data.time.0)) }); // } diff --git a/server/src/sys/subscription.rs b/server/src/sys/subscription.rs index b96ba391a0..599d33acca 100644 --- a/server/src/sys/subscription.rs +++ b/server/src/sys/subscription.rs @@ -61,8 +61,8 @@ impl<'a> System<'a> for Sys { // To update subscriptions // 1. Iterate through clients // 2. Calculate current chunk position - // 3. If chunk is different (use fuzziness) or the client view distance - // has changed continue, otherwise return + // 3. If chunk is different (use fuzziness) or the client view distance has + // changed continue, otherwise return // 4. Iterate through subscribed regions // 5. Check if region is still in range (use fuzziness) // 6. If not in range diff --git a/server/src/sys/teleporter.rs b/server/src/sys/teleporter.rs index 9959894b94..66f7f4afcd 100644 --- a/server/src/sys/teleporter.rs +++ b/server/src/sys/teleporter.rs @@ -83,11 +83,14 @@ impl<'a> System<'a> for Sys { .join() { let portal_pos = positions.get(teleporting.portal); - let Some(Object::Portal { target, requires_no_aggro, .. }) = objects - .get(teleporting.portal) + let Some(Object::Portal { + target, + requires_no_aggro, + .. + }) = objects.get(teleporting.portal) else { cancel_teleporting.push(entity); - continue + continue; }; if portal_pos.map_or(true, |portal_pos| { diff --git a/voxygen/src/hud/crafting.rs b/voxygen/src/hud/crafting.rs index 0b4d52b15f..1984985f12 100644 --- a/voxygen/src/hud/crafting.rs +++ b/voxygen/src/hud/crafting.rs @@ -1487,9 +1487,7 @@ impl<'a> Widget for Crafting<'a> { }); } - let can_perform = repair_slot - .item(self.inventory) - .map_or(false, can_repair); + let can_perform = repair_slot.item(self.inventory).map_or(false, can_repair); (repair_slot.slot, None, can_perform) }, diff --git a/voxygen/src/hud/mod.rs b/voxygen/src/hud/mod.rs index ce2eb7906c..d6685aee27 100755 --- a/voxygen/src/hud/mod.rs +++ b/voxygen/src/hud/mod.rs @@ -515,9 +515,7 @@ impl BuffIconKind { } impl PartialOrd for BuffIconKind { - fn partial_cmp(&self, other: &Self) -> Option { - Some(self.cmp(other)) - } + fn partial_cmp(&self, other: &Self) -> Option { Some(self.cmp(other)) } } impl Ord for BuffIconKind { diff --git a/voxygen/src/render/pipelines/trail.rs b/voxygen/src/render/pipelines/trail.rs index dc9107de20..77e2cffdab 100644 --- a/voxygen/src/render/pipelines/trail.rs +++ b/voxygen/src/render/pipelines/trail.rs @@ -39,7 +39,11 @@ impl Add for Vertex { fn add(self, other: Self) -> Self::Output { Self { - pos: [self.pos[0] + other.pos[0], self.pos[1] + other.pos[1], self.pos[2] + other.pos[2]], + pos: [ + self.pos[0] + other.pos[0], + self.pos[1] + other.pos[1], + self.pos[2] + other.pos[2], + ], } } } diff --git a/voxygen/src/render/renderer.rs b/voxygen/src/render/renderer.rs index fe0738fe0d..ad9e15c7c4 100644 --- a/voxygen/src/render/renderer.rs +++ b/voxygen/src/render/renderer.rs @@ -1484,27 +1484,13 @@ impl Renderer { // _bones: &Consts, // _lod: &lod_terrain::LodData, // _locals: &Consts, - // ) { - // // FIXME: Consider reenabling at some point. - // /* let (point_shadow_maps, directed_shadow_maps) = - // if let Some(shadow_map) = &mut self.shadow_map { - // ( - // ( - // shadow_map.point_res.clone(), - // shadow_map.point_sampler.clone(), - // ), - // ( - // shadow_map.directed_res.clone(), - // shadow_map.directed_sampler.clone(), - // ), - // ) - // } else { - // ( - // (self.noise_tex.srv.clone(), self.noise_tex.sampler.clone()), - // (self.noise_tex.srv.clone(), self.noise_tex.sampler.clone()), - // ) - // }; - // let model = &model.opaque; + // ) { // FIXME: Consider reenabling at some point. /* let (point_shadow_maps, + // directed_shadow_maps) = if let Some(shadow_map) = &mut self.shadow_map { ( + // ( shadow_map.point_res.clone(), shadow_map.point_sampler.clone(), ), ( + // shadow_map.directed_res.clone(), shadow_map.directed_sampler.clone(), ), ) + // } else { ( (self.noise_tex.srv.clone(), self.noise_tex.sampler.clone()), + // (self.noise_tex.srv.clone(), self.noise_tex.sampler.clone()), ) }; let + // model = &model.opaque; // self.encoder.draw( // &gfx::Slice { diff --git a/voxygen/src/render/renderer/drawer.rs b/voxygen/src/render/renderer/drawer.rs index 250398f990..15e87c4441 100644 --- a/voxygen/src/render/renderer/drawer.rs +++ b/voxygen/src/render/renderer/drawer.rs @@ -445,7 +445,9 @@ impl<'frame> Drawer<'frame> { /// pending uploads. fn run_ui_premultiply_passes(&mut self) { prof_span!("run_ui_premultiply_passes"); - let Some(premultiply_alpha) = self.borrow.pipelines.premultiply_alpha() else { return }; + let Some(premultiply_alpha) = self.borrow.pipelines.premultiply_alpha() else { + return; + }; let encoder = self.encoder.as_mut().unwrap(); let device = self.borrow.device; diff --git a/voxygen/src/scene/figure/mod.rs b/voxygen/src/scene/figure/mod.rs index baff501f36..93e19e1d62 100644 --- a/voxygen/src/scene/figure/mod.rs +++ b/voxygen/src/scene/figure/mod.rs @@ -1103,7 +1103,7 @@ impl FigureMgr { && light_emitter.is_some() && !(second_tool_hand.is_some() || matches!(active_tool_hand, Some(Hands::Two)) - && character.map_or(false, |c| c.is_wield())) + && character.map_or(false, |c| c.is_wield())) && !character.map_or(false, |c| c.is_using_hands()) && physics.in_liquid().is_none(); diff --git a/voxygen/src/session/interactable.rs b/voxygen/src/session/interactable.rs index 78f5f40ab8..76e639e982 100644 --- a/voxygen/src/session/interactable.rs +++ b/voxygen/src/session/interactable.rs @@ -59,7 +59,7 @@ impl Interactable { volume_pos: VolumePos, interaction: Interaction, ) -> Option { - let block= volume_pos.get_block(terrain, id_maps, colliders)?; + let block = volume_pos.get_block(terrain, id_maps, colliders)?; let block_interaction = match interaction { Interaction::Collect => { // Check if this is an unlockable sprite @@ -114,11 +114,11 @@ impl Interactable { /// interact with if the interact key is pressed /// Selected in the following order: /// 1) Targeted items, in order of nearest under cursor: -/// (a) entity (if within range) -/// (b) collectable -/// (c) can be mined, and is a mine sprite (Air) not a weak rock. +/// a) entity (if within range) +/// b) collectable +/// c) can be mined, and is a mine sprite (Air) not a weak rock. /// 2) outside of targeted cam ray -/// -> closest of nearest interactable entity/block +/// -> closest of nearest interactable entity/block pub(super) fn select_interactable( client: &Client, collect_target: Option>, diff --git a/voxygen/src/singleplayer/singleplayer_world.rs b/voxygen/src/singleplayer/singleplayer_world.rs index 9a9d885b64..8885064b08 100644 --- a/voxygen/src/singleplayer/singleplayer_world.rs +++ b/voxygen/src/singleplayer/singleplayer_world.rs @@ -36,7 +36,7 @@ fn load_map(path: &Path) -> Option { let meta_path = path.join("meta.ron"); let Ok(f) = fs::File::open(&meta_path) else { - error!("Failed to open {}", meta_path.to_string_lossy()); + error!("Failed to open {}", meta_path.to_string_lossy()); return None; }; diff --git a/world/examples/world_block_statistics.rs b/world/examples/world_block_statistics.rs index af03e04df1..551bfa688d 100644 --- a/world/examples/world_block_statistics.rs +++ b/world/examples/world_block_statistics.rs @@ -196,10 +196,7 @@ fn palette(conn: Connection) -> Result<(), Box> { let kind = BlockKind::from_str(&row.get::<_, String>(0)?)?; let rgb: Rgb = Rgb::new(row.get(1)?, row.get(2)?, row.get(3)?); let count: i64 = row.get(4)?; - block_colors - .entry(kind) - .or_default() - .push((rgb, count)); + block_colors.entry(kind).or_default().push((rgb, count)); } for (_, v) in block_colors.iter_mut() { v.sort_by(|a, b| b.1.cmp(&a.1)); diff --git a/world/src/civ/mod.rs b/world/src/civ/mod.rs index abd12dc5e3..5e871ac378 100644 --- a/world/src/civ/mod.rs +++ b/world/src/civ/mod.rs @@ -1569,7 +1569,9 @@ fn walk_in_all_dirs( let adjacents = NEIGHBORS.map(|dir| a + dir); - let Some(a_chunk) = sim.get(a) else { return potential }; + let Some(a_chunk) = sim.get(a) else { + return potential; + }; let mut chunks = [None; 8]; for i in 0..8 { if loc_suitable_for_walking(sim, adjacents[i]) { diff --git a/world/src/layer/cave.rs b/world/src/layer/cave.rs index 7a1f40bbfa..8714a2284b 100644 --- a/world/src/layer/cave.rs +++ b/world/src/layer/cave.rs @@ -145,7 +145,9 @@ impl Tunnel { } fn biome_at(&self, wpos: Vec3, info: &CanvasInfo) -> Biome { - let Some(col) = info.col_or_gen(wpos.xy()) else { return Biome::default() }; + let Some(col) = info.col_or_gen(wpos.xy()) else { + return Biome::default(); + }; // Below the ground let below = ((col.alt - wpos.z as f32) / 120.0).clamped(0.0, 1.0); diff --git a/world/src/sim/erosion.rs b/world/src/sim/erosion.rs index 19cb74e0f8..cd5b61f576 100644 --- a/world/src/sim/erosion.rs +++ b/world/src/sim/erosion.rs @@ -636,31 +636,31 @@ impl m32 { /// /// This algorithm does this in four steps: /// -/// 1. Sort the nodes in h by height (so the lowest node by altitude is first -/// in the list, and the highest node by altitude is last). +/// 1. Sort the nodes in h by height (so the lowest node by altitude is first in +/// the list, and the highest node by altitude is last). /// 2. Iterate through the list in *reverse.* For each node, we compute its /// drainage area as the sum of the drainage areas of its "children" nodes /// (i.e. the nodes with directed edges to this node). To do this -/// efficiently, we start with the "leaves" (the highest nodes), which -/// have no neighbors higher than them, hence no directed edges to them. -/// We add their area to themselves, and then to all neighbors that they -/// flow into (their "ancestors" in the flow graph); currently, this just -/// means the node immediately downhill of this node. As we go lower, we -/// know that all our "children" already had their areas computed, which -/// means that we can repeat the process in order to derive all the final -/// areas. +/// efficiently, we start with the "leaves" (the highest nodes), which have +/// no neighbors higher than them, hence no directed edges to them. We add +/// their area to themselves, and then to all neighbors that they flow into +/// (their "ancestors" in the flow graph); currently, this just means the +/// node immediately downhill of this node. As we go lower, we know that all +/// our "children" already had their areas computed, which means that we can +/// repeat the process in order to derive all the final areas. /// 3. Now, iterate through the list in *order.* Whether we used the filling /// method to compute a "filled" version of each depression, or used the lake /// connection algorithm described in [1], each node is guaranteed to have /// zero or one drainage edges out, representing the direction of water flow /// for that node. For nodes i with zero drainage edges out (boundary nodes /// and lake bottoms) we set the slope to 0 (so the change in altitude is -/// uplift(i)) -/// For nodes with at least one drainage edge out, we take advantage of the -/// fact that we are computing new heights in order and rewrite our equation -/// as (letting j = downhill[i], A[i] be the computed area of point i, -/// p(i) be the x-y position of point i, -/// flux(i) = k * A[i]^m / ((p(i) - p(j)).magnitude()), and δt = 1): +/// uplift(i)). +/// +/// For nodes with at least one drainage edge out, we take +/// advantage of the fact that we are computing new heights in order and +/// rewrite our equation as (letting j = downhill[i], A[i] be the computed +/// area of point i, p(i) be the x-y position of point i, flux(i) = k * +/// A[i]^m / ((p(i) - p(j)).magnitude()), and δt = 1): /// /// h[i](t + dt) = h[i](t) + δt * (uplift[i] + flux(i) * h[j](t + δt)) / (1 + /// flux(i) * δt). diff --git a/world/src/sim/util.rs b/world/src/sim/util.rs index f94d584b2f..1f875ce3f3 100644 --- a/world/src/sim/util.rs +++ b/world/src/sim/util.rs @@ -53,8 +53,8 @@ pub fn map_edge_factor(map_size_lg: MapSizeLg, posi: usize) -> f32 { /// At some point, we should probably contribute this back to stats-rs. /// /// 1. [https://www.r-bloggers.com/sums-of-random-variables/][1], -/// 2. Sadooghi-Alvandi, S., A. Nematollahi, & R. Habibi, 2009. -/// On the Distribution of the Sum of Independent Uniform Random Variables. +/// 2. Sadooghi-Alvandi, S., A. Nematollahi, & R. Habibi, 2009. On the +/// Distribution of the Sum of Independent Uniform Random Variables. /// Statistical Papers, 50, 171-175. /// 3. [https://en.wikipedia.org/wiki/Cumulative_distribution_function][3] /// diff --git a/world/src/site2/plot/citadel.rs b/world/src/site2/plot/citadel.rs index b592a708b5..1e692bcfd6 100644 --- a/world/src/site2/plot/citadel.rs +++ b/world/src/site2/plot/citadel.rs @@ -61,8 +61,9 @@ impl Citadel { .filter_map(|rpos| Some(grid.get(pos + rpos)?.as_ref()?.alt)) .min() { - let Some(Some(cell)) = grid.get_mut(pos) - else { continue }; + let Some(Some(cell)) = grid.get_mut(pos) else { + continue; + }; if min_alt < cell.alt { cell.colonade = Some(min_alt); } diff --git a/world/src/site2/plot/gnarling.rs b/world/src/site2/plot/gnarling.rs index f056084276..ce25e7ad2a 100644 --- a/world/src/site2/plot/gnarling.rs +++ b/world/src/site2/plot/gnarling.rs @@ -294,12 +294,7 @@ impl GnarlingFortification { .collect::>(); let wall_segments = outer_wall_segments .into_iter() - .chain( - wall_connections - .iter() - .copied() - .zip(inner_tower_locs), - ) + .chain(wall_connections.iter().copied().zip(inner_tower_locs)) .collect::>(); Self { diff --git a/world/src/site2/plot/house.rs b/world/src/site2/plot/house.rs index 380c3af782..68da7d0386 100644 --- a/world/src/site2/plot/house.rs +++ b/world/src/site2/plot/house.rs @@ -1703,8 +1703,8 @@ impl Structure for House { //1 => { // painter.prim(Primitive::Aabb(Aabb { // min: Vec2::new(stair_origin.x, stair_origin.y - // + 10).with_z(alt + previous_floor_height), - // max: Vec2::new(stair_origin.x + stair_width, + // + 10).with_z(alt + previous_floor_height), max: + // Vec2::new(stair_origin.x + stair_width, // stair_origin.y + 12).with_z(alt + previous_height + // 1), })) //}, @@ -1719,8 +1719,8 @@ impl Structure for House { //_ => { // painter.prim(Primitive::Aabb(Aabb { // min: Vec2::new(stair_origin.x, stair_origin.y - // + 10).with_z(alt + previous_floor_height), - // max: Vec2::new(stair_origin.x + stair_width, + // + 10).with_z(alt + previous_floor_height), max: + // Vec2::new(stair_origin.x + stair_width, // stair_origin.y + 12).with_z(alt + previous_height + // 1), })) //}, @@ -1792,7 +1792,7 @@ impl Structure for House { // painter.prim(Primitive::Aabb(Aabb { // min: Vec2::new(stair_origin.x, stair_origin.y // + stair_width).with_z(alt + previous_floor_height), - // max: Vec2::new(stair_origin.x + 2, + // max: Vec2::new(stair_origin.x + 2, // stair_origin.y + 2 * stair_width).with_z(alt + // previous_height + 1), })) //},