Browse Source

dont make new inventory

pbs
andy 4 years ago
parent
commit
34cf660cbd
  1. 4
      src/ship/items/inventory.rs
  2. 8
      src/ship/items/manager.rs

4
src/ship/items/inventory.rs

@ -631,5 +631,9 @@ impl CharacterInventory {
pub fn items(&self) -> &Vec<InventoryItem> {
&self.items
}
pub fn set_items(&mut self, sorted_items: Vec<InventoryItem>) {
self.items = sorted_items;
}
}

8
src/ship/items/manager.rs

@ -988,11 +988,13 @@ impl ItemManager {
let inventory = self.character_inventory.get_mut(&character.id).ok_or(ItemManagerError::NoCharacter(character.id))?;
let sorted_inventory_items: Vec<InventoryItem> = item_ids.iter()
.filter(|&client_item_id| *client_item_id < 0xFFFFFFFF)
.map(|&client_item_id| inventory.get_item_by_id(ClientItemId(client_item_id)).cloned().unwrap())
.map(|&client_item_id| inventory.get_item_by_id(ClientItemId(client_item_id)))
.filter(|&x| x.is_some() == true)
.map(|x| x.cloned().unwrap())
.collect();
let sorted_inventory = CharacterInventory::new(sorted_inventory_items);
update_inventory_slots(entity_gateway, character, &sorted_inventory).await;
inventory.set_items(sorted_inventory_items);
update_inventory_slots(entity_gateway, character, &inventory).await;
Ok(())
}
}
Loading…
Cancel
Save