Browse Source

cleanup

pull/124/head
jake 2 years ago
parent
commit
2959181873
  1. 3
      src/ship/items/actions.rs
  2. 10
      src/ship/items/state.rs

3
src/ship/items/actions.rs

@ -56,7 +56,6 @@ where
let character = character.clone(); let character = character.clone();
move |(mut item_state, transaction), floor_item| { move |(mut item_state, transaction), floor_item| {
let character = character.clone(); let character = character.clone();
let transaction = transaction.clone();
Box::pin(async move { Box::pin(async move {
let mut inventory = item_state.inventory(&character.id).await?; let mut inventory = item_state.inventory(&character.id).await?;
@ -538,7 +537,7 @@ where
} }
} }
#[allow(clippy::needless_lifetimes)] // clippy this lifetime is not needless get off my case
pub(super) fn add_bought_item_to_inventory<'a, EG, TR>( pub(super) fn add_bought_item_to_inventory<'a, EG, TR>(
character_id: CharacterEntityId, character_id: CharacterEntityId,
shop_item: &'a (dyn ShopItem + Send + Sync), shop_item: &'a (dyn ShopItem + Send + Sync),

10
src/ship/items/state.rs

@ -401,7 +401,7 @@ impl ItemStateProxy {
if let Some(element) = master if let Some(element) = master
.read() .read()
.await .await
.get(&key) {
.get(key) {
*element *element
.write() .write()
.await = value.clone(); .await = value.clone();
@ -453,7 +453,7 @@ impl ItemStateProxy {
pub async fn inventory(&mut self, character_id: &CharacterEntityId) -> Result<InventoryState, ItemStateError> { pub async fn inventory(&mut self, character_id: &CharacterEntityId) -> Result<InventoryState, ItemStateError> {
get_or_clone(&self.item_state.character_inventory, get_or_clone(&self.item_state.character_inventory,
&mut self.proxied_state.character_inventory,
&self.proxied_state.character_inventory,
*character_id, *character_id,
ItemStateError::NoCharacter).await ItemStateError::NoCharacter).await
} }
@ -464,7 +464,7 @@ impl ItemStateProxy {
pub async fn bank(&mut self, character_id: &CharacterEntityId) -> Result<BankState, ItemStateError> { pub async fn bank(&mut self, character_id: &CharacterEntityId) -> Result<BankState, ItemStateError> {
get_or_clone(&self.item_state.character_bank, get_or_clone(&self.item_state.character_bank,
&mut self.proxied_state.character_bank,
&self.proxied_state.character_bank,
*character_id, *character_id,
ItemStateError::NoCharacter).await ItemStateError::NoCharacter).await
} }
@ -477,8 +477,8 @@ impl ItemStateProxy {
let room_id = *self.item_state.character_room.read().await.get(character_id).unwrap(); let room_id = *self.item_state.character_room.read().await.get(character_id).unwrap();
Ok(FloorState { Ok(FloorState {
character_id: *character_id, character_id: *character_id,
local: get_or_clone(&self.item_state.character_floor, &mut self.proxied_state.character_floor, *character_id, ItemStateError::NoCharacter).await?,
shared: get_or_clone(&self.item_state.room_floor, &mut self.proxied_state.room_floor, room_id, ItemStateError::NoRoom).await?,
local: get_or_clone(&self.item_state.character_floor, &self.proxied_state.character_floor, *character_id, ItemStateError::NoCharacter).await?,
shared: get_or_clone(&self.item_state.room_floor, &self.proxied_state.room_floor, room_id, ItemStateError::NoRoom).await?,
}) })
} }

Loading…
Cancel
Save