diff options
author | metamuffin <metamuffin@disroot.org> | 2024-07-18 15:52:12 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2024-07-18 15:52:12 +0200 |
commit | 1bff001db2914e8ee7bc331a4104592ad6e2e9a3 (patch) | |
tree | 28b12471e0dc905a8135123df8ddf400c24ed8b2 /server/src/entity | |
parent | 1dd3f549debdffd85639d74248a12dd884c5a59b (diff) | |
download | hurrycurry-1bff001db2914e8ee7bc331a4104592ad6e2e9a3.tar hurrycurry-1bff001db2914e8ee7bc331a4104592ad6e2e9a3.tar.bz2 hurrycurry-1bff001db2914e8ee7bc331a4104592ad6e2e9a3.tar.zst |
clippy
Diffstat (limited to 'server/src/entity')
-rw-r--r-- | server/src/entity/conveyor.rs | 6 | ||||
-rw-r--r-- | server/src/entity/customers/demands.rs | 8 | ||||
-rw-r--r-- | server/src/entity/customers/mod.rs | 4 | ||||
-rw-r--r-- | server/src/entity/customers/pathfinding.rs | 6 | ||||
-rw-r--r-- | server/src/entity/mod.rs | 2 |
5 files changed, 8 insertions, 18 deletions
diff --git a/server/src/entity/conveyor.rs b/server/src/entity/conveyor.rs index d1594ce7..6067c679 100644 --- a/server/src/entity/conveyor.rs +++ b/server/src/entity/conveyor.rs @@ -44,11 +44,7 @@ impl EntityT for Conveyor { .get(t) .ok_or(anyhow!("conveyor filter missing"))?; filter_tile.item.as_ref().map(|e| e.kind) - } else if let Some(i) = &self.filter_item { - Some(*i) - } else { - None - }; + } else { self.filter_item.as_ref().map(|i| *i) }; if let Some(filter) = filter { if from_item.kind != filter { diff --git a/server/src/entity/customers/demands.rs b/server/src/entity/customers/demands.rs index fa7e0dbf..4f15f86f 100644 --- a/server/src/entity/customers/demands.rs +++ b/server/src/entity/customers/demands.rs @@ -41,7 +41,7 @@ pub fn generate_demands( let prod_count = producable.len(); for r in &recipes { - let output_count = r.outputs().iter().filter(|o| !items.contains(&o)).count(); + let output_count = r.outputs().iter().filter(|o| !items.contains(o)).count(); let Some(ingred_cost) = r .inputs() .iter() @@ -79,16 +79,12 @@ pub fn generate_demands( raw_demands .iter() .filter_map(|(i, o, d)| { - if let Some(cost) = producable.get(i) { - Some(Demand { + producable.get(i).map(|cost| Demand { from: *i, to: *o, duration: *d, points: *cost as i64, }) - } else { - None - } }) .collect() } diff --git a/server/src/entity/customers/mod.rs b/server/src/entity/customers/mod.rs index 7f0b0c22..806a25f9 100644 --- a/server/src/entity/customers/mod.rs +++ b/server/src/entity/customers/mod.rs @@ -150,7 +150,7 @@ impl EntityT for Customers { game.data.customer_spawn.as_ivec2(), ) .expect("no path to exit"); - *self.chairs.get_mut(&chair).unwrap() = true; + *self.chairs.get_mut(chair).unwrap() = true; game.demands_failed += 1; game.points -= 1; game.score_changed = true; @@ -231,7 +231,7 @@ impl EntityT for Customers { game.data.customer_spawn.as_ivec2(), ) .ok_or(anyhow!("no path to exit"))?; - *self.chairs.get_mut(&chair).unwrap() = true; + *self.chairs.get_mut(chair).unwrap() = true; game.demands_completed += 1; game.points += demand.points; game.score_changed = true; diff --git a/server/src/entity/customers/pathfinding.rs b/server/src/entity/customers/pathfinding.rs index 97bd8328..87ccf391 100644 --- a/server/src/entity/customers/pathfinding.rs +++ b/server/src/entity/customers/pathfinding.rs @@ -47,7 +47,7 @@ pub fn find_path(walkable: &HashSet<IVec2>, from: IVec2, to: IVec2) -> Option<Pa struct Open(i32, IVec2, IVec2, i32); impl PartialOrd for Open { fn partial_cmp(&self, other: &Self) -> Option<Ordering> { - self.0.partial_cmp(&other.0) + Some(self.0.cmp(&other.0)) } } impl Ord for Open { @@ -61,9 +61,7 @@ pub fn find_path(walkable: &HashSet<IVec2>, from: IVec2, to: IVec2) -> Option<Pa open.push(Open(1, from, from, 0)); loop { - let Some(Open(_, pos, f, distance)) = open.pop() else { - return None; - }; + let Open(_, pos, f, distance) = open.pop()?; if visited.contains_key(&pos) { continue; } diff --git a/server/src/entity/mod.rs b/server/src/entity/mod.rs index beee9309..c471a6d4 100644 --- a/server/src/entity/mod.rs +++ b/server/src/entity/mod.rs @@ -101,7 +101,7 @@ pub fn construct_entity( }) } EntityDecl::Customers {} => { - let demands = generate_demands(tiles_used, items_used, &raw_demands, &recipes); + let demands = generate_demands(tiles_used, items_used, raw_demands, recipes); let chair = reg.register_tile("chair".to_string()); let chairs = initial_map .iter() |