send inventory to player
This commit is contained in:
		
							parent
							
								
									41e7f1c41a
								
							
						
					
					
						commit
						6e1cc9a2c0
					
				| @ -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<EG: EntityGateway> ShipServerState<EG> { | ||||
|         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; | ||||
| 
 | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user