update toolchain to nightly-2021-12-19

This commit is contained in:
Imbris 2021-12-21 15:19:23 -05:00 committed by Marcel Märtens
parent 119c802695
commit bf48bd5346
71 changed files with 234 additions and 118 deletions

View File

@ -13,7 +13,7 @@ variables:
# https://docs.gitlab.com/ee/ci/yaml/#shallow-cloning
GIT_DEPTH: 3
GIT_CLEAN_FLAGS: -f
CACHE_IMAGE_TAG: a4f7c998
CACHE_IMAGE_TAG: dd8d78be
default:
# https://docs.gitlab.com/ee/ci/pipelines/settings.html#auto-cancel-pending-pipelines

View File

@ -170,13 +170,12 @@ pub fn gen_stats(
let mut result = HashMap::new();
let mut all = timelines
.iter()
.map(|(s, t)| {
.flat_map(|(s, t)| {
let mut stat = CpuTimeStats::default();
stat.measures.push((0, 0.0));
result.insert(s.clone(), stat);
t.measures.iter().map(|e| &e.0)
})
.flatten()
.collect::<Vec<_>>();
all.sort();

View File

@ -88,9 +88,8 @@ impl InterpolatableComponent for Pos {
}
let (t0prime, m0) = vel.buf[(i + vel.buf.len() - 1) % vel.buf.len()];
let (t1prime, m1) = vel.buf[i % vel.buf.len()];
let mut out;
let t = (t2 - t0) / (t1 - t0);
if ENABLE_POSITION_HERMITE
let mut out = if ENABLE_POSITION_HERMITE
&& ((t0 - t0prime).abs() < f64::EPSILON && (t1 - t1prime).abs() < f64::EPSILON)
{
let h00 = |t: f64| (2.0 * t.powf(3.0) - 3.0 * t.powf(2.0) + 1.0) as f32;
@ -98,7 +97,7 @@ impl InterpolatableComponent for Pos {
let h01 = |t: f64| (-2.0 * t.powf(3.0) + 3.0 * t.powf(2.0)) as f32;
let h11 = |t: f64| (t.powf(3.0) - t.powf(2.0)) as f32;
let dt = (t1 - t0) as f32;
out = h00(t) * p0.0 + h10(t) * dt * m0.0 + h01(t) * p1.0 + h11(t) * dt * m1.0;
h00(t) * p0.0 + h10(t) * dt * m0.0 + h01(t) * p1.0 + h11(t) * dt * m1.0
} else {
if ENABLE_POSITION_HERMITE {
warn!(
@ -106,8 +105,8 @@ impl InterpolatableComponent for Pos {
interp_data, vel
);
}
out = Lerp::lerp_unclamped(p0.0, p1.0, t as f32);
}
Lerp::lerp_unclamped(p0.0, p1.0, t as f32)
};
if out.map(|x| x.is_nan()).reduce_or() {
warn!("interpolation output is nan: {}, {}, {:?}", t2, t, buf);

View File

@ -52,6 +52,7 @@ pub trait InterpolatableComponent: Component {
fn new_data(x: Self) -> Self::InterpData;
fn update_component(&self, data: &mut Self::InterpData, time: f64, force_update: bool);
#[must_use]
fn interpolate(self, data: &Self::InterpData, time: f64, read_data: &Self::ReadData) -> Self;
}
@ -167,6 +168,7 @@ impl<P: CompPacket> CompSyncPackage<P> {
.push((uid.into(), CompUpdateKind::Removed(PhantomData::<C>.into())));
}
#[must_use]
pub fn with_component<'a, C: Component + Clone + Send + Sync>(
mut self,
uids: &ReadStorage<'a, Uid>,

View File

@ -102,22 +102,26 @@ impl Default for Attack {
#[cfg(not(target_arch = "wasm32"))]
impl Attack {
#[must_use]
pub fn with_damage(mut self, damage: AttackDamage) -> Self {
self.damages.push(damage);
self
}
#[must_use]
pub fn with_effect(mut self, effect: AttackEffect) -> Self {
self.effects.push(effect);
self
}
#[must_use]
pub fn with_crit(mut self, crit_chance: f32, crit_multiplier: f32) -> Self {
self.crit_chance = crit_chance;
self.crit_multiplier = crit_multiplier;
self
}
#[must_use]
pub fn with_combo_increment(self) -> Self {
self.with_effect(
AttackEffect::new(None, CombatEffect::Combo(1))
@ -544,6 +548,7 @@ impl AttackDamage {
}
}
#[must_use]
pub fn with_effect(mut self, effect: CombatEffect) -> Self {
self.effects.push(effect);
self
@ -568,6 +573,7 @@ impl AttackEffect {
}
}
#[must_use]
pub fn with_requirement(mut self, requirement: CombatRequirement) -> Self {
self.requirements.push(requirement);
self
@ -806,6 +812,7 @@ impl Knockback {
}
}
#[must_use]
pub fn modify_strength(mut self, power: f32) -> Self {
self.strength *= power;
self

View File

@ -673,6 +673,7 @@ impl CharacterAbility {
}
}
#[must_use]
pub fn adjusted_by_stats(mut self, stats: Stats) -> Self {
use CharacterAbility::*;
match self {

View File

@ -126,6 +126,7 @@ impl From<BehaviorCapability> for Behavior {
impl Behavior {
/// Builder function
/// Set capabilities if Option is Some
#[must_use]
pub fn maybe_with_capabilities(
mut self,
maybe_capabilities: Option<BehaviorCapability>,
@ -138,6 +139,7 @@ impl Behavior {
/// Builder function
/// Set trade_site if Option is Some
#[must_use]
pub fn with_trade_site(mut self, trade_site: Option<SiteId>) -> Self {
self.trade_site = trade_site;
self
@ -323,6 +325,7 @@ impl Sound {
}
}
#[must_use]
pub fn with_new_vol(mut self, new_vol: f32) -> Self {
self.vol = new_vol;
@ -480,16 +483,19 @@ impl Agent {
}
}
#[must_use]
pub fn with_patrol_origin(mut self, origin: Vec3<f32>) -> Self {
self.patrol_origin = Some(origin);
self
}
#[must_use]
pub fn with_behavior(mut self, behavior: Behavior) -> Self {
self.behavior = behavior;
self
}
#[must_use]
pub fn with_no_flee_if(mut self, condition: bool) -> Self {
if condition {
self.psyche.flee_health = 0.0;
@ -498,6 +504,7 @@ impl Agent {
}
// FIXME: Only one of *three* things in this method sets a location.
#[must_use]
pub fn with_destination(mut self, pos: Vec3<f32>) -> Self {
self.psyche.flee_health = 0.0;
self.rtsim_controller = RtSimController::with_destination(pos);
@ -506,6 +513,7 @@ impl Agent {
}
#[allow(clippy::type_complexity)]
#[must_use]
pub fn with_position_pid_controller(
mut self,
pid: PidController<fn(Vec3<f32>, Vec3<f32>) -> f32, 16>,
@ -514,6 +522,7 @@ impl Agent {
self
}
#[must_use]
pub fn with_aggro_no_warn(mut self) -> Self {
self.psyche.aggro_dist = None;
self

View File

@ -20,7 +20,8 @@ impl LiquidKind {
/// precedence? (should be a rare edge case, since checkerboard patterns of
/// water and lava shouldn't show up in worldgen)
#[inline]
pub fn merge(self, other: LiquidKind) -> LiquidKind {
#[must_use]
pub fn merge(self, other: Self) -> Self {
use LiquidKind::{Lava, Water};
match (self, other) {
(Water, Water) => Water,

View File

@ -675,6 +675,7 @@ impl Item {
}
/// Duplicates an item, creating an exact copy but with a new item ID
#[must_use]
pub fn duplicate(&self, ability_map: &AbilityMap, msm: &MaterialStatManifest) -> Self {
let mut new_item = Item::new_from_item_def(
Arc::clone(&self.item_def),

View File

@ -105,7 +105,8 @@ impl Stats {
}
}
pub fn clamp_speed(mut self) -> Stats {
#[must_use]
pub fn clamp_speed(mut self) -> Self {
// if a tool has 0.0 speed, that panics due to being infinite duration, so
// enforce speed >= 0.1 on the final product (but not the intermediates)
self.speed = self.speed.max(0.1);
@ -345,6 +346,7 @@ pub struct AbilitySet<T> {
}
impl AbilitySet<AbilityItem> {
#[must_use]
pub fn modified_by_tool(
self,
tool: &Tool,

View File

@ -62,6 +62,7 @@ impl Ori {
Self(Quaternion::slerp(ori1.0, ori2.0, s).normalized())
}
#[must_use]
pub fn slerped_towards(self, ori: Ori, s: f32) -> Self { Self::slerp(self, ori, s) }
/// Multiply rotation quaternion by `q`
@ -80,6 +81,7 @@ impl Ori {
///
/// assert!((ori1.look_dir().dot(*ori2.look_dir()) - 1.0).abs() <= std::f32::EPSILON);
/// ```
#[must_use]
pub fn rotated(self, q: Quaternion<f32>) -> Self {
Self((self.to_quat() * q.normalized()).normalized())
}
@ -100,6 +102,7 @@ impl Ori {
///
/// assert!((ori1.look_dir().dot(*ori2.look_dir()) - 1.0).abs() <= std::f32::EPSILON);
/// ```
#[must_use]
pub fn prerotated(self, q: Quaternion<f32>) -> Self {
Self((q.normalized() * self.to_quat()).normalized())
}
@ -148,6 +151,7 @@ impl Ori {
self.to_quat() * local
}
#[must_use]
pub fn to_horizontal(self) -> Self {
// We don't use Self::look_dir to avoid the extra normalization step within
// Dir's Quaternion Mul impl
@ -210,32 +214,39 @@ impl Ori {
pub fn dot(self, other: Self) -> f32 { self.look_vec().dot(other.look_vec()) }
#[must_use]
pub fn pitched_up(self, angle_radians: f32) -> Self {
self.rotated(Quaternion::rotation_x(angle_radians))
}
#[must_use]
pub fn pitched_down(self, angle_radians: f32) -> Self {
self.rotated(Quaternion::rotation_x(-angle_radians))
}
#[must_use]
pub fn yawed_left(self, angle_radians: f32) -> Self {
self.rotated(Quaternion::rotation_z(angle_radians))
}
#[must_use]
pub fn yawed_right(self, angle_radians: f32) -> Self {
self.rotated(Quaternion::rotation_z(-angle_radians))
}
#[must_use]
pub fn rolled_left(self, angle_radians: f32) -> Self {
self.rotated(Quaternion::rotation_y(-angle_radians))
}
#[must_use]
pub fn rolled_right(self, angle_radians: f32) -> Self {
self.rotated(Quaternion::rotation_y(angle_radians))
}
/// Returns a version which is rolled such that its up points towards `dir`
/// as much as possible without pitching or yawing
#[must_use]
pub fn rolled_towards(self, dir: Dir) -> Self {
dir.projected(&Plane::from(self.look_dir()))
.map_or(self, |dir| self.prerotated(self.up().rotation_between(dir)))
@ -243,6 +254,7 @@ impl Ori {
/// Returns a version which has been pitched towards `dir` as much as
/// possible without yawing or rolling
#[must_use]
pub fn pitched_towards(self, dir: Dir) -> Self {
dir.projected(&Plane::from(self.right()))
.map_or(self, |dir_| {
@ -252,6 +264,7 @@ impl Ori {
/// Returns a version which has been yawed towards `dir` as much as possible
/// without pitching or rolling
#[must_use]
pub fn yawed_towards(self, dir: Dir) -> Self {
dir.projected(&Plane::from(self.up())).map_or(self, |dir_| {
self.prerotated(self.look_dir().rotation_between(dir_))
@ -279,6 +292,7 @@ impl Ori {
/// let ang2 = pd_rr.up().angle_between(zenith);
/// assert!((ang1 - ang2).abs() <= std::f32::EPSILON);
/// ```
#[must_use]
pub fn uprighted(self) -> Self { self.look_dir().into() }
fn is_normalized(&self) -> bool { self.0.into_vec4().is_normalized() }

View File

@ -402,6 +402,7 @@ impl ProjectileConstructor {
}
// TODO: split this to three methods per stat
#[must_use]
pub fn modified_projectile(mut self, power: f32, regen: f32, range: f32) -> Self {
use ProjectileConstructor::*;
match self {

View File

@ -75,7 +75,7 @@ lazy_static! {
let map = SkillTreeMap::load_expect_cloned(
"common.skill_trees.skills_skill-groups_manifest",
).0;
map.iter().map(|(sgk, skills)| skills.into_iter().map(move |s| (*s, *sgk))).flatten().collect()
map.iter().flat_map(|(sgk, skills)| skills.into_iter().map(move |s| (*s, *sgk))).collect()
};
// Loads the maximum level that a skill can obtain
pub static ref SKILL_MAX_LEVEL: HashMap<Skill, Option<u16>> = {

View File

@ -81,6 +81,7 @@ impl Segment {
}
/// Transform cells
#[must_use]
pub fn map(mut self, transform: impl Fn(Cell) -> Option<Cell>) -> Self {
for pos in self.full_pos_iter() {
if let Some(new) = transform(*self.get(pos).unwrap()) {
@ -92,6 +93,7 @@ impl Segment {
}
/// Transform cell colors
#[must_use]
pub fn map_rgb(self, transform: impl Fn(Rgb<u8>) -> Rgb<u8>) -> Self {
self.map(|cell| {
cell.get_color().map(|rgb| {
@ -114,11 +116,13 @@ impl<V: Vox + Copy> DynaUnionizer<V> {
#[allow(clippy::new_without_default)] // TODO: Pending review in #587
pub fn new() -> Self { DynaUnionizer(Vec::new()) }
#[must_use]
pub fn add(mut self, dyna: Dyna<V, ()>, offset: Vec3<i32>) -> Self {
self.0.push((dyna, offset));
self
}
#[must_use]
pub fn maybe_add(self, maybe: Option<(Dyna<V, ()>, Vec3<i32>)>) -> Self {
match maybe {
Some((dyna, offset)) => self.add(dyna, offset),
@ -175,6 +179,7 @@ impl MatSegment {
}
/// Transform cells
#[must_use]
pub fn map(mut self, transform: impl Fn(MatCell) -> Option<MatCell>) -> Self {
for pos in self.full_pos_iter() {
if let Some(new) = transform(*self.get(pos).unwrap()) {
@ -186,6 +191,7 @@ impl MatSegment {
}
/// Transform cell colors
#[must_use]
pub fn map_rgb(self, transform: impl Fn(Rgb<u8>) -> Rgb<u8>) -> Self {
self.map(|cell| match cell {
MatCell::Normal(data) => Some(MatCell::Normal(CellData {

View File

@ -140,6 +140,7 @@ impl EntityConfig {
.unwrap_or_else(|e| panic!("Failed to load {}. Error: {:?}", asset_specifier, e))
}
#[must_use]
pub fn with_body(mut self, body: BodyBuilder) -> Self {
self.body = body;
@ -201,6 +202,7 @@ impl EntityInfo {
}
/// Helper function for applying config from asset
#[must_use]
pub fn with_asset_expect(self, asset_specifier: &str) -> Self {
let config = EntityConfig::load_expect_cloned(asset_specifier);
@ -208,6 +210,7 @@ impl EntityInfo {
}
/// Evaluate and apply EntityConfig
#[must_use]
pub fn with_entity_config(mut self, config: EntityConfig, config_asset: Option<&str>) -> Self {
let EntityConfig {
name,
@ -297,6 +300,7 @@ impl EntityInfo {
self
}
#[must_use]
pub fn do_if(mut self, cond: bool, f: impl FnOnce(Self) -> Self) -> Self {
if cond {
self = f(self);
@ -304,66 +308,79 @@ impl EntityInfo {
self
}
#[must_use]
pub fn into_waypoint(mut self) -> Self {
self.is_waypoint = true;
self
}
#[must_use]
pub fn with_alignment(mut self, alignment: Alignment) -> Self {
self.alignment = alignment;
self
}
#[must_use]
pub fn with_body(mut self, body: Body) -> Self {
self.body = body;
self
}
#[must_use]
pub fn with_name(mut self, name: impl Into<String>) -> Self {
self.name = Some(name.into());
self
}
#[must_use]
pub fn with_agency(mut self, agency: bool) -> Self {
self.has_agency = agency;
self
}
#[must_use]
pub fn with_agent_mark(mut self, agent_mark: agent::Mark) -> Self {
self.agent_mark = Some(agent_mark);
self
}
#[must_use]
pub fn with_main_tool(mut self, main_tool: Item) -> Self {
self.main_tool = Some(main_tool);
self
}
#[must_use]
pub fn with_second_tool(mut self, second_tool: Item) -> Self {
self.second_tool = Some(second_tool);
self
}
#[must_use]
pub fn with_loot_drop(mut self, loot_drop: LootSpec<String>) -> Self {
self.loot = loot_drop;
self
}
#[must_use]
pub fn with_scale(mut self, scale: f32) -> Self {
self.scale = scale;
self
}
#[must_use]
pub fn with_health_scaling(mut self, level: u16) -> Self {
self.health_scaling = Some(level);
self
}
#[must_use]
pub fn with_loadout_asset(mut self, asset: String) -> Self {
self.loadout_asset = Some(asset);
self
}
#[must_use]
pub fn with_lazy_loadout(
mut self,
creator: fn(LoadoutBuilder, Option<&trade::SiteInformation>) -> LoadoutBuilder,
@ -372,11 +389,13 @@ impl EntityInfo {
self
}
#[must_use]
pub fn with_skillset_asset(mut self, asset: String) -> Self {
self.skillset_asset = Some(asset);
self
}
#[must_use]
pub fn with_automatic_name(mut self) -> Self {
let npc_names = NPC_NAMES.read();
let name = match &self.body {
@ -402,7 +421,8 @@ impl EntityInfo {
self
}
// map contains price+amount
/// map contains price+amount
#[must_use]
pub fn with_economy(mut self, e: &SiteInformation) -> Self {
self.trading_information = Some(e.clone());
self

View File

@ -18,8 +18,7 @@ impl<T> Grid<T> {
pub fn populate_from(size: Vec2<i32>, mut f: impl FnMut(Vec2<i32>) -> T) -> Self {
Self {
cells: (0..size.y)
.map(|y| (0..size.x).map(move |x| Vec2::new(x, y)))
.flatten()
.flat_map(|y| (0..size.x).map(move |x| Vec2::new(x, y)))
.map(&mut f)
.collect(),
size,
@ -79,8 +78,7 @@ impl<T> Grid<T> {
pos: Vec2<i32>,
size: Vec2<i32>,
) -> impl Iterator<Item = Option<(Vec2<i32>, &T)>> + '_ {
(0..size.x)
.map(move |x| {
(0..size.x).flat_map(move |x| {
(0..size.y).map(move |y| {
Some((
pos + Vec2::new(x, y),
@ -88,7 +86,6 @@ impl<T> Grid<T> {
))
})
})
.flatten()
}
pub fn raw(&self) -> &[T] { &self.cells }

View File

@ -248,8 +248,7 @@ impl Route {
})
.unwrap_or_else(|| {
(0..2)
.map(|i| (0..2).map(move |j| Vec2::new(i, j)))
.flatten()
.flat_map(|i| (0..2).map(move |j| Vec2::new(i, j)))
.map(|rpos| block_pos + rpos)
.map(|block_pos| {
let block_posf = block_pos.xy().map(|e| e as f32);

View File

@ -55,11 +55,13 @@ where
}
}
#[must_use]
pub fn max_iter(mut self, max_iter: usize) -> Self {
self.max_iter = max_iter;
self
}
#[must_use]
pub fn ignore_error(mut self) -> Self {
self.ignore_error = true;
self

View File

@ -71,6 +71,7 @@ impl Stage<f32> {
}
}
#[must_use]
pub fn adjusted_by_stats(mut self, stats: Stats) -> Self {
if let Some(CombatEffect::Buff(CombatBuff {
kind: _,
@ -101,6 +102,7 @@ impl Stage<f32> {
}
// TODO: name it as using knockback
#[must_use]
pub fn modify_strike(mut self, knockback_mult: f32) -> Self {
self.knockback *= knockback_mult;
self

View File

@ -341,6 +341,7 @@ impl Block {
/// If this block is a fluid, replace its sprite.
#[inline]
#[must_use]
pub fn with_sprite(mut self, sprite: SpriteKind) -> Self {
if !self.is_filled() {
self.attr[0] = sprite as u8;
@ -350,6 +351,7 @@ impl Block {
/// If this block can have orientation, give it a new orientation.
#[inline]
#[must_use]
pub fn with_ori(mut self, ori: u8) -> Option<Self> {
if self.get_sprite().map(|s| s.has_ori()).unwrap_or(false) {
self.attr[1] = (self.attr[1] & !0b111) | (ori & 0b111);
@ -361,6 +363,7 @@ impl Block {
/// Remove the terrain sprite or solid aspects of a block
#[inline]
#[must_use]
pub fn into_vacant(self) -> Self {
if self.is_fluid() {
Block::new(self.kind(), Rgb::zero())
@ -373,6 +376,7 @@ impl Block {
/// Attempt to convert a [`u32`] to a block
#[inline]
#[must_use]
pub fn from_u32(x: u32) -> Option<Self> {
let [bk, r, g, b] = x.to_le_bytes();
Some(Self {

View File

@ -79,12 +79,11 @@ impl<V, S: RectVolSize, M: Clone> Chonk<V, S, M> {
.iter()
.enumerate()
.filter(|(_, sc)| sc.num_groups() > 0)
.map(move |(i, sc)| {
.flat_map(move |(i, sc)| {
let z_offset = self.z_offset + i as i32 * SubChunkSize::<S>::SIZE.z as i32;
sc.vol_iter(Vec3::zero(), SubChunkSize::<S>::SIZE.map(|e| e as i32))
.map(move |(pos, vox)| (pos + Vec3::unit_z() * z_offset, vox))
})
.flatten()
}
// Returns the index (in self.sub_chunks) of the SubChunk that contains

View File

@ -104,6 +104,7 @@ impl Structure {
StructuresGroup::load_expect(&["world.manifests.", specifier].concat())
}
#[must_use]
pub fn with_center(mut self, center: Vec3<i32>) -> Self {
self.center = center;
self

View File

@ -363,7 +363,7 @@ impl SitePrices {
.map(|(slot, amount)| {
inventories[who]
.as_ref()
.map(|ri| {
.and_then(|ri| {
ri.inventory.get(slot).map(|item| {
let (material, factor) = TradePricing::get_material(&item.name);
self.values.get(&material).cloned().unwrap_or_default()
@ -372,7 +372,6 @@ impl SitePrices {
* if reduce { material.trade_margin() } else { 1.0 }
})
})
.flatten()
.unwrap_or_default()
})
.sum()

View File

@ -83,6 +83,7 @@ impl Dir {
Self(slerp_normalized(from.0, to.0, factor))
}
#[must_use]
pub fn slerped_to(self, to: Self, factor: f32) -> Self {
Self(slerp_normalized(self.0, to.0, factor))
}

View File

@ -17,6 +17,7 @@ pub trait Vox: Sized + Clone + PartialEq {
fn empty() -> Self;
fn is_empty(&self) -> bool;
#[must_use]
fn or(self, other: Self) -> Self { if self.is_empty() { other } else { self } }
}

View File

@ -38,8 +38,9 @@ where
})
};
range_iter(0)
.map(|i| range_iter(1).map(move |j| range_iter(2).map(move |k| Vec3::new(i, j, k))))
.flatten()
.flat_map(|i| {
range_iter(1).map(move |j| range_iter(2).map(move |k| Vec3::new(i, j, k)))
})
.flatten()
.map(|offs| self.inner.get(pos + offs))
.find(|vox| vox.as_ref().map(|v| !v.is_empty()).unwrap_or(false))

View File

@ -268,6 +268,7 @@ impl State {
}
/// Register a component with the state's ECS.
#[must_use]
pub fn with_component<T: Component>(mut self) -> Self
where
<T as Component>::Storage: Default,

View File

@ -215,19 +215,16 @@ impl<'a> System<'a> for Sys {
ModifierKind::Additive => *accumulated,
ModifierKind::Fractional => health.maximum() * *accumulated,
};
let damage_contributor = by
.map(|uid| {
read_data
.uid_allocator
.retrieve_entity_internal(uid.0)
.map(|entity| {
let damage_contributor = by.and_then(|uid| {
read_data.uid_allocator.retrieve_entity_internal(uid.0).map(
|entity| {
DamageContributor::new(
uid,
read_data.groups.get(entity).cloned(),
)
})
})
.flatten();
},
)
});
server_emitter.emit(ServerEvent::HealthChange {
entity,
change: HealthChange {

View File

@ -1952,7 +1952,8 @@ fn closest_points(n: LineSegment2<f32>, m: LineSegment2<f32>) -> (Vec2<f32>, Vec
// Check to see whether the lines are parallel
if !t.is_finite() || !u.is_finite() {
core::array::IntoIter::new([
// TODO: can use postfix .into_iter() when switching to Rust 2021
IntoIterator::into_iter([
(n.projected_point(m.start), m.start),
(n.projected_point(m.end), m.end),
(n.start, m.projected_point(n.start)),

View File

@ -1 +1 @@
nightly-2021-11-24
nightly-2021-12-19

View File

@ -471,7 +471,7 @@ fn handle_give_item(
) -> CmdResult<()> {
if let (Some(item_name), give_amount_opt) = parse_args!(args, String, u32) {
let give_amount = give_amount_opt.unwrap_or(1);
if let Ok(item) = Item::new_from_asset(&item_name.replace('/', ".").replace("\\", ".")) {
if let Ok(item) = Item::new_from_asset(&item_name.replace('/', ".").replace('\\', ".")) {
let mut item: Item = item;
let mut res = Ok(());
@ -2805,16 +2805,16 @@ fn handle_disconnect_all_players(
// TODO: This logging and verification of admin commands would be better moved
// to a more generic method used for auditing -all- admin commands.
let player_name;
if let Some(player) = players.get(client) {
player_name = &*player.alias;
let player_name = if let Some(player) = players.get(client) {
&*player.alias
} else {
warn!(
"Failed to get player name for admin who used /disconnect_all_players - ignoring \
command."
);
return Err("You do not exist, so you cannot use this command".to_string());
}
};
info!(
"Disconnecting all clients due to admin command from {}",

View File

@ -426,15 +426,13 @@ mod tests {
mockworld.insert(AbilityMap::default());
mockworld.register::<Inventory>();
mockworld.register::<Uid>();
let player: EcsEntity;
let merchant: EcsEntity;
player = mockworld
let player: EcsEntity = mockworld
.create_entity()
.with(Inventory::new_empty())
.build();
merchant = mockworld
let merchant: EcsEntity = mockworld
.create_entity()
.with(Inventory::new_empty())
.build();

View File

@ -131,13 +131,11 @@ impl StateExt for State {
let stats = self.ecs().read_storage::<comp::Stats>();
let groups = self.ecs().read_storage::<comp::Group>();
let damage_contributor = source
.map(|uid| {
let damage_contributor = source.and_then(|uid| {
self.ecs().entity_from_uid(uid.0).map(|attacker_entity| {
DamageContributor::new(uid, groups.get(attacker_entity).cloned())
})
})
.flatten();
});
let time = self.ecs().read_resource::<Time>();
let change = damage.calculate_health_change(
combat::Damage::compute_damage_reduction(
@ -612,10 +610,7 @@ impl StateExt for State {
let group_manager = ecs.read_resource::<comp::group::GroupManager>();
let group_info = msg
.get_group()
.map(|g| group_manager.group_info(*g))
.flatten();
let group_info = msg.get_group().and_then(|g| group_manager.group_info(*g));
let resolved_msg = msg
.clone()

View File

@ -66,8 +66,7 @@ fn dispatch_circuit_transport<'a>(
(circuits)
.join()
.map(|circuit| circuit.wires.iter())
.flatten()
.flat_map(|circuit| circuit.wires.iter())
.for_each(|wire| {
let input_value = computed_outputs
.get(&wire.input_entity)

View File

@ -183,7 +183,7 @@ fn dyn_lib_file(dyn_package: &str, active: bool) -> String {
format!(
"{}{}{}{}",
DLL_PREFIX,
dyn_package.replace("-", "_"),
dyn_package.replace('-', "_"),
if active { "_active" } else { "" },
DLL_SUFFIX
)

View File

@ -276,8 +276,7 @@ impl<'a> Widget for LootScroller<'a> {
&& ui
.widget_graph()
.widget(state.ids.message_box)
.map(|w| w.maybe_y_scroll_state)
.flatten()
.and_then(|w| w.maybe_y_scroll_state)
.map_or(false, |s| s.scrollable_range_len > BOX_HEIGHT)
{
Scrollbar::y_axis(state.ids.message_box)

View File

@ -1033,7 +1033,7 @@ impl<'a> Widget for Map<'a> {
} else {
size as f64 / 2.5
};
Text::new(&title.to_string())
Text::new(title)
.x_y_position_relative_to(
state.ids.map_layers[0],
position::Relative::Scalar(rpos.x as f64),

View File

@ -243,6 +243,8 @@ impl VoxelMinimap {
.map2(TerrainChunkSize::RECT_SIZE, |i, j| (i as u32).rem_euclid(j))
.as_();
let column = self.chunk_minimaps.get(&(cpos + coff));
// TODO: evaluate clippy, toolchain upgrade 2021-12-19
#[allow(clippy::unnecessary_lazy_evaluations)]
column
.map(
|MinimapColumn {
@ -255,7 +257,7 @@ impl VoxelMinimap {
.and_then(|grid| grid.get(cmod))
.map_or(false, |(_, b)| *b)
})
.unwrap_or_else(|| {
.unwrap_or_else(||
// if the `find` returned None, there's no solid blocks above the
// player within the chunk
if above.1 {
@ -269,7 +271,7 @@ impl VoxelMinimap {
// (subsequent arithmetic on ceiling_offset must be saturating)
i32::MAX
}
})
)
},
)
.unwrap_or(0)
@ -309,6 +311,8 @@ impl VoxelMinimap {
// the ceiling's height (using the top slice of the chunk if the
// ceiling is above the chunk, (e.g. so that forests with
// differently-tall trees are handled properly)
// TODO: evaluate clippy, toolchain upgrade 2021-12-19
#[allow(clippy::unnecessary_lazy_evaluations)]
layers
.get(
(((pos.z as i32 - zlo).saturating_add(ceiling_offset))

View File

@ -388,6 +388,7 @@ pub enum PositionSpecifier {
/// }
/// ```
pub trait Position {
#[must_use]
fn position(self, request: PositionSpecifier) -> Self;
}

View File

@ -158,6 +158,7 @@ pub struct Quad<V: Vertex> {
impl<V: Vertex> Quad<V> {
pub fn new(a: V, b: V, c: V, d: V) -> Self { Self { a, b, c, d } }
#[must_use]
pub fn rotated_by(self, n: usize) -> Self {
let verts = [self.a, self.b, self.c, self.d];

View File

@ -210,6 +210,7 @@ impl Light {
pub fn get_pos(&self) -> Vec3<f32> { Vec3::new(self.pos[0], self.pos[1], self.pos[2]) }
#[must_use]
pub fn with_strength(mut self, strength: f32) -> Self {
self.col = (Vec4::<f32>::from(self.col) * strength).into_array();
self

View File

@ -708,7 +708,7 @@ impl<V: RectRasterableVol> Terrain<V> {
let (bias, total) = Spiral2d::new()
.take(9)
.map(|rpos| {
.flat_map(|rpos| {
let chunk_pos = wpos_chunk + rpos;
self.chunks
.get(&chunk_pos)
@ -724,7 +724,6 @@ impl<V: RectRasterableVol> Terrain<V> {
)
})
})
.flatten()
.fold(
(Vec3::broadcast(0.001), 0.0),
|(bias, total), (lpos, level)| {

View File

@ -494,10 +494,10 @@ impl IcedRenderer {
let (r, t) = src_rect.max.into_tuple();
Some((
(
l / image_w as f32, /* * ratio_x*/
r / image_w as f32, /* * ratio_x*/
b / image_h as f32, /* * ratio_y*/
t / image_h as f32, /* * ratio_y*/
l / image_w as f32, /* * ratio_x */
r / image_w as f32, /* * ratio_x */
b / image_h as f32, /* * ratio_y */
t / image_h as f32, /* * ratio_y */
),
Extent2::new(
gl_size.w as f32 * ratio_x,

View File

@ -37,6 +37,7 @@ impl Style {
}
}
#[must_use]
pub fn hover_image(mut self, image: image::Handle) -> Self {
self.background = Some(match self.background {
Some(mut background) => {
@ -48,6 +49,7 @@ impl Style {
self
}
#[must_use]
pub fn press_image(mut self, image: image::Handle) -> Self {
self.background = Some(match self.background {
Some(mut background) => {
@ -61,6 +63,7 @@ impl Style {
// TODO: this needs to be refactored since the color isn't used if there is no
// background
#[must_use]
pub fn image_color(mut self, color: Rgba<u8>) -> Self {
if let Some(background) = &mut self.background {
background.color = color;
@ -68,11 +71,13 @@ impl Style {
self
}
#[must_use]
pub fn text_color(mut self, color: Color) -> Self {
self.enabled_text = color;
self
}
#[must_use]
pub fn disabled_text_color(mut self, color: Color) -> Self {
self.disabled_text = color;
self

View File

@ -33,6 +33,7 @@ impl Style {
}
}
#[must_use]
pub fn bg_hover_image(mut self, image: image::Handle) -> Self {
self.background = Some(match self.background {
Some(mut background) => {
@ -44,6 +45,7 @@ impl Style {
self
}
#[must_use]
pub fn bg_checked_image(mut self, image: image::Handle) -> Self {
self.background = Some(match self.background {
Some(mut background) => {
@ -55,6 +57,7 @@ impl Style {
self
}
#[must_use]
pub fn bg_hover_checked_image(mut self, image: image::Handle) -> Self {
self.background = Some(match self.background {
Some(mut background) => {

View File

@ -46,22 +46,26 @@ where
}
/// Set the ratio (width/height)
#[must_use]
pub fn ratio(mut self, ratio: f32) -> Self {
self.aspect_ratio = AspectRatio::Ratio(ratio);
self
}
/// Use the ratio of the provided image
#[must_use]
pub fn ratio_of_image(mut self, handle: R::ImageHandle) -> Self {
self.aspect_ratio = AspectRatio::Image(handle);
self
}
#[must_use]
pub fn max_width(mut self, max_width: u32) -> Self {
self.max_width = max_width;
self
}
#[must_use]
pub fn max_height(mut self, max_height: u32) -> Self {
self.max_height = max_height;
self

View File

@ -30,32 +30,38 @@ impl Padding {
}
}
#[must_use]
pub fn top(mut self, pad: u16) -> Self {
self.top = pad;
self
}
#[must_use]
pub fn bottom(mut self, pad: u16) -> Self {
self.bottom = pad;
self
}
#[must_use]
pub fn right(mut self, pad: u16) -> Self {
self.right = pad;
self
}
#[must_use]
pub fn left(mut self, pad: u16) -> Self {
self.left = pad;
self
}
#[must_use]
pub fn vertical(mut self, pad: u16) -> Self {
self.top = pad;
self.bottom = pad;
self
}
#[must_use]
pub fn horizontal(mut self, pad: u16) -> Self {
self.left = pad;
self.right = pad;
@ -110,16 +116,19 @@ where
}
}
#[must_use]
pub fn padding(mut self, padding: Padding) -> Self {
self.padding = padding;
self
}
#[must_use]
pub fn max_width(mut self, max_width: u32) -> Self {
self.max_width = max_width;
self
}
#[must_use]
pub fn max_height(mut self, max_height: u32) -> Self {
self.max_height = max_height;
self

View File

@ -45,6 +45,7 @@ impl Graphic {
)
}
#[must_use]
pub fn color(mut self, color: Rgba<u8>) -> Self {
match &mut self.kind {
GraphicKind::Image(_, c) => *c = color,
@ -108,16 +109,19 @@ impl CompoundGraphic {
this
}
#[must_use]
pub fn width(mut self, width: Length) -> Self {
self.width = width;
self
}
#[must_use]
pub fn height(mut self, height: Length) -> Self {
self.height = height;
self
}
#[must_use]
pub fn fix_aspect_ratio(mut self) -> Self {
self.fix_aspect_ratio = true;
self

View File

@ -36,21 +36,25 @@ where
}
}
#[must_use]
pub fn fill_fraction(mut self, fraction: f32) -> Self {
self.fill_fraction = fraction;
self
}
#[must_use]
pub fn vertical_adjustment(mut self, adjustment: f32) -> Self {
self.vertical_adjustment = adjustment;
self
}
#[must_use]
pub fn color(mut self, color: impl Into<iced::Color>) -> Self {
self.text = self.text.color(color);
self
}
#[must_use]
pub fn font(mut self, font: impl Into<R::Font>) -> Self {
self.text = self.text.font(font);
self

View File

@ -30,21 +30,25 @@ impl Image {
}
}
#[must_use]
pub fn width(mut self, width: Length) -> Self {
self.width = width;
self
}
#[must_use]
pub fn height(mut self, height: Length) -> Self {
self.height = height;
self
}
#[must_use]
pub fn fix_aspect_ratio(mut self) -> Self {
self.fix_aspect_ratio = true;
self
}
#[must_use]
pub fn color(mut self, color: Rgba<u8>) -> Self {
self.color = color;
self

View File

@ -44,46 +44,55 @@ where
}
}
#[must_use]
pub fn padding<P: Into<Padding>>(mut self, pad: P) -> Self {
self.padding = pad.into();
self
}
#[must_use]
pub fn width(mut self, width: Length) -> Self {
self.width = width;
self
}
#[must_use]
pub fn height(mut self, height: Length) -> Self {
self.height = height;
self
}
#[must_use]
pub fn max_width(mut self, max_width: u32) -> Self {
self.max_width = max_width;
self
}
#[must_use]
pub fn max_height(mut self, max_height: u32) -> Self {
self.max_height = max_height;
self
}
#[must_use]
pub fn align_x(mut self, align_x: Align) -> Self {
self.horizontal_alignment = align_x;
self
}
#[must_use]
pub fn align_y(mut self, align_y: Align) -> Self {
self.vertical_alignment = align_y;
self
}
#[must_use]
pub fn center_x(mut self) -> Self {
self.horizontal_alignment = Align::Center;
self
}
#[must_use]
pub fn center_y(mut self) -> Self {
self.vertical_alignment = Align::Center;
self

View File

@ -809,10 +809,10 @@ impl Ui {
let (l, r, b, t) = src_rect.l_r_b_t();
Some((
(
l / image_w as f64, /* * ratio_x*/
r / image_w as f64, /* * ratio_x*/
b / image_h as f64, /* * ratio_y*/
t / image_h as f64, /* * ratio_y*/
l / image_w as f64, /* * ratio_x */
r / image_w as f64, /* * ratio_x */
b / image_h as f64, /* * ratio_y */
t / image_h as f64, /* * ratio_y */
),
Extent2::new(
(gl_size.w as f64 * ratio_x) as f32,

View File

@ -419,6 +419,7 @@ impl<'a> ItemTooltip<'a> {
}
/// Specify the font used for displaying the text.
#[must_use]
pub fn font_id(mut self, font_id: text::font::Id) -> Self {
self.style.title.font_id = Some(Some(font_id));
self.style.desc.font_id = Some(Some(font_id));
@ -1211,7 +1212,7 @@ impl<'a> Widget for ItemTooltip<'a> {
// Stats
let stat_h = if util::stats_count(self.item) > 0 {
widget::Text::new(&"placeholder".to_string())
widget::Text::new("placeholder")
.with_style(self.style.desc)
.get_h(ui)
.unwrap_or(0.0)

View File

@ -49,6 +49,7 @@ impl<'a> OutlinedText<'a> {
}
}
#[must_use]
pub fn font_id(mut self, font_id: text::font::Id) -> Self {
self.text_style.font_id = Some(Some(font_id));
self

View File

@ -71,30 +71,35 @@ impl<'a, T> RadioList<'a, T> {
}
}
#[must_use]
pub fn source_rectangle(mut self, rect: Rect) -> Self {
self.f_image.src_rect = Some(rect);
self.t_image.src_rect = Some(rect);
self
}
#[must_use]
pub fn image_colors(mut self, f_color: Color, t_color: Color) -> Self {
self.f_image.color = button::ImageColor::Normal(f_color);
self.t_image.color = button::ImageColor::Normal(t_color);
self
}
#[must_use]
pub fn image_color_with_feedback(mut self, f_color: Color, t_color: Color) -> Self {
self.f_image.color = button::ImageColor::WithFeedback(f_color);
self.t_image.color = button::ImageColor::WithFeedback(t_color);
self
}
#[must_use]
pub fn hover_images(mut self, f_id: image::Id, t_id: image::Id) -> Self {
self.f_image.hover_image_id = Some(f_id);
self.t_image.hover_image_id = Some(t_id);
self
}
#[must_use]
pub fn press_images(mut self, f_id: image::Id, t_id: image::Id) -> Self {
self.f_image.press_image_id = Some(f_id);
self.t_image.press_image_id = Some(t_id);

View File

@ -499,16 +499,19 @@ where
pub with_background_color { background_color = Some(Color) }
}
#[must_use]
pub fn with_manager(mut self, slot_manager: &'a mut SlotManager<S>) -> Self {
self.slot_manager = Some(slot_manager);
self
}
#[must_use]
pub fn filled_slot(mut self, img: image::Id) -> Self {
self.filled_slot = img;
self
}
#[must_use]
pub fn with_icon(mut self, img: image::Id, size: Vec2<f32>, color: Option<Color>) -> Self {
self.icon = Some((img, size, color));
self

View File

@ -45,30 +45,35 @@ impl ToggleButton {
}
}
#[must_use]
pub fn source_rectangle(mut self, rect: Rect) -> Self {
self.f_image.src_rect = Some(rect);
self.t_image.src_rect = Some(rect);
self
}
#[must_use]
pub fn image_colors(mut self, f_color: Color, t_color: Color) -> Self {
self.f_image.color = button::ImageColor::Normal(f_color);
self.t_image.color = button::ImageColor::Normal(t_color);
self
}
#[must_use]
pub fn image_color_with_feedback(mut self, f_color: Color, t_color: Color) -> Self {
self.f_image.color = button::ImageColor::WithFeedback(f_color);
self.t_image.color = button::ImageColor::WithFeedback(t_color);
self
}
#[must_use]
pub fn hover_images(mut self, f_id: image::Id, t_id: image::Id) -> Self {
self.f_image.hover_image_id = Some(f_id);
self.t_image.hover_image_id = Some(t_id);
self
}
#[must_use]
pub fn press_images(mut self, f_id: image::Id, t_id: image::Id) -> Self {
self.f_image.press_image_id = Some(f_id);
self.t_image.press_image_id = Some(t_id);

View File

@ -348,6 +348,7 @@ impl<'a> Tooltip<'a> {
}
/// Specify the font used for displaying the text.
#[must_use]
pub fn font_id(mut self, font_id: text::font::Id) -> Self {
self.style.title.font_id = Some(Some(font_id));
self.style.desc.font_id = Some(Some(font_id));

View File

@ -5,13 +5,13 @@ use veloren_world::site::economy::{self, good_list, Economy};
fn good_name(g: Good) -> String {
let res = format!("{:?}", g);
let res = res.replace("(", "_");
res.replace(")", "_")
let res = res.replace('(', "_");
res.replace(')', "_")
}
fn labor_name(l: economy::Labor) -> String {
let res = format!("{:?}", l);
res.replace(" ", "_")
res.replace(' ', "_")
}
fn main() -> Result<(), std::io::Error> {

View File

@ -44,8 +44,7 @@ impl<'a> CanvasInfo<'a> {
pub fn col(&self, wpos: Vec2<i32>) -> Option<&'a ColumnSample> {
self.column_grid
.get(self.column_grid_border + wpos - self.wpos())
.map(Option::as_ref)
.flatten()
.and_then(Option::as_ref)
.map(|zc| &zc.sample)
}
@ -67,8 +66,7 @@ impl<'a> CanvasInfo<'a> {
/// spot, seed)`.
pub fn nearby_spots(&self) -> impl Iterator<Item = (Vec2<i32>, Spot, u32)> + '_ {
(-1..2)
.map(|x| (-1..2).map(move |y| Vec2::new(x, y)))
.flatten()
.flat_map(|x| (-1..2).map(move |y| Vec2::new(x, y)))
.filter_map(move |pos| {
let pos = self.chunk_pos + pos;
self.chunks.get(pos).and_then(|c| c.spot).map(|spot| {

View File

@ -35,7 +35,7 @@ pub fn apply_shrubs_to(canvas: &mut Canvas, _dynamic_rng: &mut impl Rng) {
let info = canvas.info();
canvas.foreach_col(|_, wpos2d, _| {
for (wpos, seed) in std::array::IntoIter::new(shrub_gen.get(wpos2d)) {
for (wpos, seed) in shrub_gen.get(wpos2d) {
shrub_cache.entry(wpos).or_insert_with(|| {
let col = info.col_or_gen(wpos)?;

View File

@ -164,13 +164,12 @@ impl World {
self.civs()
.caves
.iter()
.map(|(id, info)| {
.flat_map(|(id, info)| {
// separate the two locations, combine with name
std::iter::once((id.id() + num_sites, info.name.clone(), info.location.0))
// unfortunately we have to introduce a fake id (as it gets stored in a map in the client)
.chain(std::iter::once((id.id() + num_sites + num_caves, info.name.clone(), info.location.1)))
})
.flatten() // unwrap inner iteration
}) // unwrap inner iteration
.map(|(id, name, pos)| world_msg::SiteInfo {
id,
name: Some(name),
@ -335,8 +334,7 @@ impl World {
let sample_get = |offs| {
zcache_grid
.get(grid_border + offs)
.map(Option::as_ref)
.flatten()
.and_then(Option::as_ref)
.map(|zc| &zc.sample)
};

View File

@ -37,6 +37,7 @@ use rayon::prelude::*;
implicit none
*/
#[allow(clippy::needless_late_init)]
pub fn diffusion(
nx: usize,
ny: usize,
@ -404,6 +405,7 @@ pub fn diffusion(
INTEGER n
double precision a(n),b(n),c(n),r(n),u(n)
*/
#[allow(clippy::needless_late_init)]
pub fn tridag(a: &[f64], b: &[f64], c: &[f64], r: &[f64], u: &mut [f64], n: usize) {
/*
INTEGER j

View File

@ -138,8 +138,7 @@ pub fn sample_pos(
.and_then(|samples| {
chunk_idx
.and_then(|chunk_idx| samples.get(chunk_idx))
.map(Option::as_ref)
.flatten()
.and_then(Option::as_ref)
})
.map(|sample| {
// TODO: Eliminate the redundancy between this and the block renderer.

View File

@ -1731,12 +1731,11 @@ impl WorldSim {
let this = &self;
let waypoints = (0..this.map_size_lg().chunks().x)
.step_by(WAYPOINT_EVERY)
.map(|i| {
.flat_map(|i| {
(0..this.map_size_lg().chunks().y)
.step_by(WAYPOINT_EVERY)
.map(move |j| (i, j))
})
.flatten()
.collect::<Vec<_>>()
.into_par_iter()
.filter_map(|(i, j)| {
@ -2130,7 +2129,8 @@ impl WorldSim {
/// them spawning).
pub fn get_near_trees(&self, wpos: Vec2<i32>) -> impl Iterator<Item = TreeAttr> + '_ {
// Deterministic based on wpos
let normal_trees = std::array::IntoIter::new(self.gen_ctx.structure_gen.get(wpos))
// TODO: can use postfix .into_iter() when switching to Rust 2021
let normal_trees = IntoIterator::into_iter(self.gen_ctx.structure_gen.get(wpos))
.filter_map(move |(wpos, seed)| {
let lottery = self.make_forest_lottery(wpos);
Some(TreeAttr {

View File

@ -1278,8 +1278,7 @@ mod tests {
let mut neighbors: Vec<crate::site::economy::NeighborInformation> = e
.neighbors
.iter()
.map(|(nid, dist)| index.sites.recreate_id(*nid).map(|i| (i, dist)))
.flatten()
.flat_map(|(nid, dist)| index.sites.recreate_id(*nid).map(|i| (i, dist)))
.map(|(nid, dist)| crate::site::economy::NeighborInformation {
id: nid,
travel_distance: *dist,

View File

@ -21,11 +21,13 @@ impl BlockMask {
}
}
#[must_use]
pub const fn with_priority(mut self, priority: i32) -> Self {
self.priority = priority;
self
}
#[must_use]
pub const fn resolve_with(self, other: Self) -> Self {
if self.priority >= other.priority {
self

View File

@ -207,8 +207,7 @@ impl Archetype for House {
border: 4,
children: [1, -1]
.iter()
.map(|flip| (0..branches_per_side).map(move |i| (i, *flip)))
.flatten()
.flat_map(|flip| (0..branches_per_side).map(move |i| (i, *flip)))
.filter_map(|(i, flip)| {
if rng.gen() {
Some((

View File

@ -8,6 +8,7 @@ pub enum Ori {
}
impl Ori {
#[must_use]
pub fn flip(self) -> Self {
match self {
Ori::East => Ori::North,

View File

@ -217,8 +217,7 @@ impl Settlement {
let wpos = self.origin + tile * AREA_SIZE as i32;
if (0..4)
.map(|x| (0..4).map(move |y| Vec2::new(x, y)))
.flatten()
.flat_map(|x| (0..4).map(move |y| Vec2::new(x, y)))
.any(|offs| {
let wpos = wpos + offs * AREA_SIZE as i32 / 2;
let cpos = wpos.map(|e| e.div_euclid(TerrainChunkSize::RECT_SIZE.x as i32));
@ -446,7 +445,7 @@ impl Settlement {
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(),
ctx.sim.and_then(|sim| sim.calendar.as_ref()),
))
},
};

View File

@ -667,12 +667,10 @@ impl Site {
let tile = self.tiles.get(tpos);
let twpos = self.tile_wpos(tpos);
let border = TILE_SIZE as i32;
let cols = (-border..TILE_SIZE as i32 + border)
.map(|y| {
let cols = (-border..TILE_SIZE as i32 + border).flat_map(|y| {
(-border..TILE_SIZE as i32 + border)
.map(move |x| (twpos + Vec2::new(x, y), Vec2::new(x, y)))
})
.flatten();
});
#[allow(clippy::single_match)]
match &tile.kind {
@ -930,8 +928,7 @@ fn wpos_is_hazard(land: &Land, wpos: Vec2<i32>) -> Option<HazardKind> {
pub fn aabr_tiles(aabr: Aabr<i32>) -> impl Iterator<Item = Vec2<i32>> {
(0..aabr.size().h)
.map(move |y| (0..aabr.size().w).map(move |x| aabr.min + Vec2::new(x, y)))
.flatten()
.flat_map(move |y| (0..aabr.size().w).map(move |x| aabr.min + Vec2::new(x, y)))
}
pub struct Plaza {}