diff options
author | metamuffin <metamuffin@disroot.org> | 2024-11-24 17:18:01 +0100 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2024-11-24 17:18:11 +0100 |
commit | 696dbdd2238e919bffa756fff1f02ace90a81ecb (patch) | |
tree | 305e03ce4fea3c3ee151c7560414b0e2625264ba | |
parent | 95d14ada0c98fb8f2285fd0003000b5a517f9267 (diff) | |
download | hurrycurry-696dbdd2238e919bffa756fff1f02ace90a81ecb.tar hurrycurry-696dbdd2238e919bffa756fff1f02ace90a81ecb.tar.bz2 hurrycurry-696dbdd2238e919bffa756fff1f02ace90a81ecb.tar.zst |
Manual clippy
-rw-r--r-- | locale/tools/src/main.rs | 8 | ||||
-rw-r--r-- | pixel-client/src/render/font.rs | 2 | ||||
-rw-r--r-- | pixel-client/src/ui.rs | 2 | ||||
-rw-r--r-- | server/bot/src/algos/customer.rs | 14 | ||||
-rw-r--r-- | server/bot/src/algos/dishwasher.rs | 4 | ||||
-rw-r--r-- | server/discover/src/main.rs | 2 | ||||
-rw-r--r-- | server/registry/src/conn_test.rs | 2 | ||||
-rw-r--r-- | server/registry/src/main.rs | 3 | ||||
-rw-r--r-- | server/src/commands.rs | 15 | ||||
-rw-r--r-- | server/src/entity/campaign.rs | 2 | ||||
-rw-r--r-- | server/src/entity/tutorial.rs | 2 | ||||
-rw-r--r-- | server/src/message.rs | 6 | ||||
-rw-r--r-- | server/src/network/register.rs | 2 | ||||
-rw-r--r-- | server/src/server.rs | 2 |
14 files changed, 29 insertions, 37 deletions
diff --git a/locale/tools/src/main.rs b/locale/tools/src/main.rs index a6232dda..2f8c9718 100644 --- a/locale/tools/src/main.rs +++ b/locale/tools/src/main.rs @@ -61,11 +61,9 @@ static NATIVE_LANGUAGE_NAMES: &[(&str, &str)] = &[ fn export_load(inputs: &[PathBuf]) -> Result<BTreeMap<String, String>> { let mut ini = BTreeMap::new(); for path in inputs { - let f = load_ini(&path)?; + let f = load_ini(path)?; for (k, v) in f { - if !ini.contains_key(&k) { - ini.insert(k, v); - } + ini.entry(k).or_insert(v); } } for &(code, name) in NATIVE_LANGUAGE_NAMES { @@ -162,7 +160,7 @@ msgstr "" a, "{k},{}", v.values() - .map(|s| serde_json::to_string(s)) + .map(serde_json::to_string) .try_collect::<Vec<_>>()? .join(",") )?; diff --git a/pixel-client/src/render/font.rs b/pixel-client/src/render/font.rs index 54c760f1..96347d25 100644 --- a/pixel-client/src/render/font.rs +++ b/pixel-client/src/render/font.rs @@ -40,7 +40,7 @@ impl FontTextures { } } -impl<'a> Renderer<'a> { +impl Renderer<'_> { pub fn draw_text( &mut self, position: Vec2, diff --git a/pixel-client/src/ui.rs b/pixel-client/src/ui.rs index a77d2856..ad0b07a9 100644 --- a/pixel-client/src/ui.rs +++ b/pixel-client/src/ui.rs @@ -119,7 +119,7 @@ impl FocusDevice { } } -impl<'a, 'b> Ui<'a, 'b> { +impl Ui<'_, '_> { pub fn vertical(&mut self, content: impl FnOnce(&mut Ui)) { self.flow(false, content) } diff --git a/server/bot/src/algos/customer.rs b/server/bot/src/algos/customer.rs index 67605ad5..e26acf09 100644 --- a/server/bot/src/algos/customer.rs +++ b/server/bot/src/algos/customer.rs @@ -173,15 +173,11 @@ impl CustomerState { } } else if check && path.remaining_segments() < 5 - && game - .players - .iter() - .find(|(id, p)| { - p.class == PlayerClass::Customer - && **id != me - && p.movement.position.distance(chair.as_vec2() + 0.5) < 1. - }) - .is_some() + && game.players.iter().any(|(id, p)| { + p.class == PlayerClass::Customer + && *id != me + && p.movement.position.distance(chair.as_vec2() + 0.5) < 1. + }) { *self = CustomerState::New; BotInput::default() diff --git a/server/bot/src/algos/dishwasher.rs b/server/bot/src/algos/dishwasher.rs index b52b72d1..e4a49978 100644 --- a/server/bot/src/algos/dishwasher.rs +++ b/server/bot/src/algos/dishwasher.rs @@ -32,9 +32,9 @@ type LogicRes<Out = ()> = Result<Out, ()>; impl BotAlgo for DishWasher { fn tick(&mut self, me: PlayerID, game: &Game, dt: f32) -> BotInput { - if let None = self.dirty_plate { + if self.dirty_plate.is_none() { self.dirty_plate = game.data.get_item_by_name("dirty-plate"); - if let None = self.dirty_plate { + if self.dirty_plate.is_none() { return BotInput::default(); } } diff --git a/server/discover/src/main.rs b/server/discover/src/main.rs index f1f2bb35..f546cd6c 100644 --- a/server/discover/src/main.rs +++ b/server/discover/src/main.rs @@ -57,7 +57,7 @@ async fn async_main() -> Result<!> { .to_owned(), address: service_info .get_addresses() - .into_iter() + .iter() .map(|a| { format!("ws://{}", SocketAddr::new(*a, service_info.get_port())) }) diff --git a/server/registry/src/conn_test.rs b/server/registry/src/conn_test.rs index 2fda288c..9825997c 100644 --- a/server/registry/src/conn_test.rs +++ b/server/registry/src/conn_test.rs @@ -72,7 +72,7 @@ async fn test_connect_inner(addr: SocketAddr, uri: &str) -> Result<(u32, u32)> { let net = Network::connect_raw(stream, uri).await?; let packet = net.receive().await?; match packet { - Some(PacketC::Version { minor, major, .. }) => return Ok((major, minor)), + Some(PacketC::Version { minor, major, .. }) => Ok((major, minor)), _ => bail!("bad initial packet"), } } diff --git a/server/registry/src/main.rs b/server/registry/src/main.rs index 30fb8d66..85c0f066 100644 --- a/server/registry/src/main.rs +++ b/server/registry/src/main.rs @@ -138,7 +138,7 @@ impl Registry { self.servers.retain(|_, e| { e.address .retain(|_, updated| updated.elapsed() < Duration::from_secs(120)); - e.address.len() > 0 + !e.address.is_empty() }); } } @@ -152,6 +152,7 @@ struct InternalEntry { version: (u32, u32), } +#[allow(clippy::derivable_impls)] impl Default for InternalEntry { fn default() -> Self { Self { diff --git a/server/src/commands.rs b/server/src/commands.rs index 86a3de15..24752cc5 100644 --- a/server/src/commands.rs +++ b/server/src/commands.rs @@ -332,15 +332,10 @@ impl Server { .get_item_by_name(&item) .ok_or(tre!("s.error.item_not_found", s = item))?; #[cfg(not(test))] // TODO rust-analyser does not undestand trait upcasting - if self - .entities - .iter() - .find(|e| { - <dyn std::any::Any>::downcast_ref::<Tutorial>(e.as_ref()) - .map_or(false, |t| t.player == player) - }) - .is_some() - { + if self.entities.iter().any(|e| { + <dyn std::any::Any>::downcast_ref::<Tutorial>(e.as_ref()) + .map_or(false, |t| t.player == player) + }) { return Err(tre!("s.error.tutorial_already_running")); } self.entities.push(Box::new(Tutorial::new(player, item))); @@ -365,7 +360,7 @@ impl Server { player, message: Some(Message::Translation { id: message_id, - params: arguments.into_iter().map(|c| Message::Text(c)).collect(), + params: arguments.into_iter().map(Message::Text).collect(), }), timeout: None, }); diff --git a/server/src/entity/campaign.rs b/server/src/entity/campaign.rs index 6683716d..39926a12 100644 --- a/server/src/entity/campaign.rs +++ b/server/src/entity/campaign.rs @@ -117,6 +117,8 @@ impl GateCondition { .reduce(|a, b| trm!("s.campaign.list_helper", m = a, m = b)) .unwrap_or(Message::Text(String::new())), GateCondition::Stars(map, thres) => { + // TODO show current score + let _ = scoreboard; trm!( "s.campaign.condition.stars", s = thres.to_string(), diff --git a/server/src/entity/tutorial.rs b/server/src/entity/tutorial.rs index 1d28f13e..60b32c79 100644 --- a/server/src/entity/tutorial.rs +++ b/server/src/entity/tutorial.rs @@ -138,7 +138,7 @@ struct StepContext<'a> { player: PlayerID, } -impl<'a> StepContext<'a> { +impl StepContext<'_> { fn is_hand_item(&self, item: ItemIndex) -> bool { self.ent .game diff --git a/server/src/message.rs b/server/src/message.rs index 79c004a2..069c2b0b 100644 --- a/server/src/message.rs +++ b/server/src/message.rs @@ -25,7 +25,7 @@ macro_rules! trm { ($id:literal $(, $typ:ident = $param:expr)*) => { hurrycurry_protocol::Message::Translation { id: $id.to_owned(), - params: vec![$(crate::trm_param!($typ, $param)),*] + params: vec![$($crate::trm_param!($typ, $param)),*] } }; } @@ -76,9 +76,9 @@ impl Debug for TrError { #[macro_export] macro_rules! tre { ($id:literal $(, $typ:ident = $param:expr)*) => { - crate::message::TrError::Tr { + $crate::message::TrError::Tr { id: $id, - params: vec![$(crate::tre_param!($typ, $param)),*] + params: vec![$($crate::tre_param!($typ, $param)),*] } }; } diff --git a/server/src/network/register.rs b/server/src/network/register.rs index 2bd4fa92..eccdf22b 100644 --- a/server/src/network/register.rs +++ b/server/src/network/register.rs @@ -29,7 +29,7 @@ use std::{ }; use tokio::{sync::RwLock, time::interval}; -const REGISTRY_URI: &'static str = "https://hurrycurry-registry.metamuffin.org"; +const REGISTRY_URI: &str = "https://hurrycurry-registry.metamuffin.org"; pub struct Register { name: String, diff --git a/server/src/server.rs b/server/src/server.rs index d3e9ab59..b9cafede 100644 --- a/server/src/server.rs +++ b/server/src/server.rs @@ -568,7 +568,7 @@ impl Server { if let Some((_, t)) = &player.communicate_persist { timeout.initial = t.initial; }; - player.communicate_persist = message.clone().map(|m| (m, timeout.clone())); + player.communicate_persist = message.clone().map(|m| (m, timeout)); Some(timeout) } else { None |