From ab0a844c8c20666310df9e1d1ec1ca35d924855a Mon Sep 17 00:00:00 2001 From: jake Date: Sat, 11 Nov 2023 23:11:58 -0700 Subject: [PATCH] don't load shops for real this time --- src/ship/ship.rs | 11 +++++------ tests/common.rs | 12 +++++------- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/src/ship/ship.rs b/src/ship/ship.rs index 85ca6e5..5eacf5c 100644 --- a/src/ship/ship.rs +++ b/src/ship/ship.rs @@ -410,14 +410,13 @@ impl ShipServerStateBuilder { item_state: items::state::ItemState::default(), ip: self.ip.unwrap_or_else(|| Ipv4Addr::new(127,0,0,1)), port: self.port.unwrap_or(SHIP_PORT), - #[allow(clippy::box_default)] // this lint leads to another which just doesn't work - shops: Arc::new(self.shops.unwrap_or(Box::new(StandardItemShops::default()))), + shops: Arc::new(self.shops.unwrap_or_else(|| Box::::default())), blocks: Blocks(blocks), event: self.event.unwrap_or(Holiday::None), - map_builder: Arc::new(self.map_builder.unwrap_or(Box::new(generate_free_roam_maps))), - drop_table_builder: Arc::new(self.drop_table_builder.unwrap_or(Box::new(StandardDropTable::new))), - standard_quest_builder: Arc::new(self.standard_quest_builder.unwrap_or(Box::new(load_standard_quests))), - government_quest_builder: Arc::new(self.government_quest_builder.unwrap_or(Box::new(load_government_quests))), + map_builder: Arc::new(self.map_builder.unwrap_or_else(|| Box::new(generate_free_roam_maps))), + drop_table_builder: Arc::new(self.drop_table_builder.unwrap_or_else(|| Box::new(StandardDropTable::new))), + standard_quest_builder: Arc::new(self.standard_quest_builder.unwrap_or_else(|| Box::new(load_standard_quests))), + government_quest_builder: Arc::new(self.government_quest_builder.unwrap_or_else(|| Box::new(load_government_quests))), auth_token: self.auth_token.unwrap_or_else(|| AuthToken("".into())), ship_list: Arc::new(RwLock::new(Vec::new())), diff --git a/tests/common.rs b/tests/common.rs index f446d37..36c0d7a 100644 --- a/tests/common.rs +++ b/tests/common.rs @@ -36,10 +36,14 @@ impl DropTable for NullDropTable { } } +pub fn null_drop_table_builder(_episode: Episode, _difficult: Difficulty, _section_id: SectionID) -> Box { + Box::new(NullDropTable) +} + struct NullItemShops; #[async_trait::async_trait] -impl ItemShops for NullItemShops { +impl ItemShops for NullItemShops { async fn generate_weapon_list(&self, _difficulty: Difficulty, _section_id: SectionID, _char_level: usize) -> Option> { Some(Vec::new()) } @@ -51,12 +55,6 @@ impl ItemShops for NullItemShops { } } - - -pub fn null_drop_table_builder(_episode: Episode, _difficult: Difficulty, _section_id: SectionID) -> Box { - Box::new(NullDropTable) -} - pub fn standard_ship_buildable(gateway: EG) -> ShipServerStateBuilder { ShipServerState::builder() .gateway(gateway)