From 6e1cc9a2c06c19d6f92d28b3ba1344db52c4a432 Mon Sep 17 00:00:00 2001 From: jake Date: Mon, 9 Dec 2019 23:12:55 -0800 Subject: [PATCH] send inventory to player --- src/ship/ship.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/ship/ship.rs b/src/ship/ship.rs index 5ce01b4..2c930db 100644 --- a/src/ship/ship.rs +++ b/src/ship/ship.rs @@ -17,6 +17,7 @@ use crate::common::leveltable::CharacterLevelTable; use crate::entity::gateway::EntityGateway; use crate::entity::account::{UserAccount, UserSettings, USERFLAG_NEWCHAR, USERFLAG_DRESSINGROOM}; use crate::entity::character::Character; +use crate::entity::item::ItemLocation; use crate::login::login::get_login_status; use crate::ship::location::ClientLocation; @@ -154,6 +155,27 @@ impl ShipServerState { fc.character.lck = stats.1.lck; fc.character.level = stats.0 - 1; + let items = self.entity_gateway.get_items_by_character(&client.character); + let (mut inventory, inv_len) = items + .iter() + .take(30) + .fold(([character::InventoryItem::default(); 30], 0), |(mut inv, len), item| { + let index = { + if let ItemLocation::Inventory{index, .. } = item.location { + index + } + else { + panic!("inventory item that isnt in inventory???"); + } + }; + let bytes = item.item.as_bytes(); + inv[index].data1.copy_from_slice(&bytes[0..12]); + inv[index].item_id = item.id; + (inv, len+1) + }); + fc.inventory.items = inventory; + fc.inventory.item_count = inv_len; + fc.key_team_config.key_config = client.settings.settings.key_config; fc.key_team_config.joystick_config = client.settings.settings.joystick_config;