From cf2bac4ccbfb8d535e18bcab71e3ccf2339a7f82 Mon Sep 17 00:00:00 2001 From: jake Date: Sat, 11 Nov 2023 14:41:00 -0700 Subject: [PATCH] clippy cleanup --- client/src/client.rs | 6 +++--- items/src/actions.rs | 6 +----- items/src/tasks.rs | 2 ++ room/Cargo.toml | 2 +- room/src/room.rs | 8 ++++---- src/bin/main.rs | 2 +- src/ship/mod.rs | 12 ------------ 7 files changed, 12 insertions(+), 26 deletions(-) diff --git a/client/src/client.rs b/client/src/client.rs index 21b2281..e75ceaa 100644 --- a/client/src/client.rs +++ b/client/src/client.rs @@ -52,7 +52,7 @@ impl Clients { .await; let client = clients .get(&client_id) - .ok_or_else(|| ClientError::NotFound(client_id))? + .ok_or(ClientError::NotFound(client_id))? .read() .await; @@ -75,7 +75,7 @@ impl Clients { for (cindex, client_id) in client_ids.iter().enumerate() { let c = clients .get(client_id) - .ok_or_else(|| ClientError::NotFound(*client_id))? + .ok_or(ClientError::NotFound(*client_id))? .read() .await; client_states[cindex].write(c); @@ -101,7 +101,7 @@ impl Clients { .await; let mut client = clients .get(&client_id) - .ok_or_else(|| ClientError::NotFound(client_id))? + .ok_or(ClientError::NotFound(client_id))? .write() .await; diff --git a/items/src/actions.rs b/items/src/actions.rs index 873e735..0b55d6d 100644 --- a/items/src/actions.rs +++ b/items/src/actions.rs @@ -8,7 +8,6 @@ use std::pin::Pin; use std::iter::IntoIterator; use anyhow::Context; -use libpso::packet::{ship::Message, messages::GameMessage}; use entity::character::{CharacterEntity, CharacterEntityId}; use entity::gateway::{EntityGateway, EntityGatewayTransaction}; use entity::item::{ItemDetail, NewItemEntity, TradeId, ItemModifier}; @@ -22,7 +21,6 @@ use crate::floor::{FloorItem, FloorItemDetail}; use crate::apply_item::{apply_item, ApplyItemAction}; use shops::ShopItem; use drops::{ItemDrop, ItemDropType}; -//use crate::ship::packet::builder; use location::AreaClient; use maps::monster::MonsterType; @@ -1166,8 +1164,7 @@ where let (inventory_item_detail, create_item) = if item_detail.is_stackable() { let tool = item_detail.as_tool().ok_or_else(|| ItemStateError::NotATool(ClientItemId(0xFFFFFFFF)))?; - //let create_item = builder::message::create_stacked_item(area_client, item_id, &tool, 1).map_err(|_err| ItemStateError::Dummy)?; - let create_item = CreateItem::Stacked(area_client, item_id, tool.clone(), 1); + let create_item = CreateItem::Stacked(area_client, item_id, tool, 1); let item_detail = StackedItemDetail { entity_ids: vec![new_item.id], tool @@ -1179,7 +1176,6 @@ where entity_id: new_item.id, item: item_detail, }; - //let create_item = builder::message::create_individual_item(area_client, item_id, &item_detail).map_err(|_err| ItemStateError::Dummy)?; let create_item = CreateItem::Individual(area_client, item_id, item_detail.clone()); (InventoryItemDetail::Individual(item_detail), create_item) }; diff --git a/items/src/tasks.rs b/items/src/tasks.rs index 8a7a307..cf313fc 100644 --- a/items/src/tasks.rs +++ b/items/src/tasks.rs @@ -371,6 +371,8 @@ where Ok((transaction, result)) }) } + +#[allow(clippy::type_complexity)] pub fn trade_items<'a, EG> ( item_state: &'a mut ItemState, entity_gateway: &'a mut EG, diff --git a/room/Cargo.toml b/room/Cargo.toml index 361b597..d081284 100644 --- a/room/Cargo.toml +++ b/room/Cargo.toml @@ -10,7 +10,7 @@ quests = { workspace = true } location = { workspace = true } drops = { workspace = true } -rand= { workspace = true } +rand = { workspace = true } async-std = { workspace = true } futures = { workspace = true } anyhow = { workspace = true } diff --git a/room/src/room.rs b/room/src/room.rs index a065d55..5110d22 100644 --- a/room/src/room.rs +++ b/room/src/room.rs @@ -40,7 +40,7 @@ impl Rooms { pub async fn add(&self, room_id: RoomId, room: RoomState) -> Result<(), anyhow::Error> { *self.0 .get(room_id.0) - .ok_or_else(|| RoomError::Invalid(room_id.0 as u32))? + .ok_or(RoomError::Invalid(room_id.0 as u32))? .write() .await = Some(room); Ok(()) @@ -73,7 +73,7 @@ impl Rooms { { let room = self.0 .get(room_id.0) - .ok_or_else(|| RoomError::Invalid(room_id.0 as u32))? + .ok_or(RoomError::Invalid(room_id.0 as u32))? .read() .await; if let Some(room) = room.as_ref() { @@ -91,7 +91,7 @@ impl Rooms { { let mut room = self.0 .get(room_id.0) - .ok_or_else(|| RoomError::Invalid(room_id.0 as u32))? + .ok_or(RoomError::Invalid(room_id.0 as u32))? .write() .await; @@ -221,7 +221,7 @@ impl RoomState { } } - #[allow(clippy::too_many_arguments)] + #[allow(clippy::too_many_arguments, clippy::type_complexity)] pub fn new (room_id: RoomEntityId, mode: RoomEntityMode, episode: Episode, diff --git a/src/bin/main.rs b/src/bin/main.rs index 34e5793..18fdfbd 100644 --- a/src/bin/main.rs +++ b/src/bin/main.rs @@ -8,7 +8,7 @@ use elseware::patch::patch::{PatchServerState, generate_patch_tree, load_config, use elseware::ship::ship::ShipServerStateBuilder; use maps::Holiday; -use entity::gateway::{EntityGateway, InMemoryGateway, PostgresGateway}; +use entity::gateway::{EntityGateway, InMemoryGateway}; use entity::account::{NewUserAccountEntity, NewUserSettingsEntity}; use entity::character::NewCharacterEntity; use entity::item::{NewItemEntity, ItemDetail, InventoryItemEntity}; diff --git a/src/ship/mod.rs b/src/ship/mod.rs index f6ada33..cf2a804 100644 --- a/src/ship/mod.rs +++ b/src/ship/mod.rs @@ -1,16 +1,4 @@ #[allow(clippy::module_inception)] pub mod ship; -//pub mod location; -//pub mod character; -//pub mod client; -//pub mod room; -//pub mod items; -//pub mod item_stats; -//pub mod map; -//pub mod monster; -//pub mod drops; pub mod packet; -//pub mod quests; -//pub mod shops; -//pub mod trade; pub mod chatcommand;