Merge pull request 'new_char_configs' (#106) from new_char_configs into master
This commit is contained in:
		
						commit
						b4399c7e7e
					
				| @ -2,6 +2,7 @@ use std::convert::{From, Into, TryFrom, TryInto}; | ||||
| use std::collections::HashMap; | ||||
| 
 | ||||
| use libpso::packet::ship::{UpdateConfig, WriteInfoboard}; | ||||
| use libpso::character::character::{DEFAULT_PALETTE_CONFIG, DEFAULT_TECH_MENU}; | ||||
| use crate::entity::item::tech::Technique; | ||||
| use crate::entity::account::UserAccountId; | ||||
| 
 | ||||
| @ -189,7 +190,7 @@ pub struct CharacterConfig { | ||||
| impl CharacterConfig { | ||||
|     fn new() -> CharacterConfig { | ||||
|         CharacterConfig { | ||||
|             raw_data: [0; 0xE8], | ||||
|             raw_data: DEFAULT_PALETTE_CONFIG, | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
| @ -228,6 +229,23 @@ pub struct CharacterGuildCard { | ||||
|     pub description: String, | ||||
| } | ||||
| 
 | ||||
| #[derive(Clone)] | ||||
| pub struct CharacterTechMenu { | ||||
|     pub tech_menu: [u8; 40], | ||||
| } | ||||
| 
 | ||||
| impl CharacterTechMenu { | ||||
|     fn new() -> CharacterTechMenu { | ||||
|         CharacterTechMenu { | ||||
|             tech_menu: DEFAULT_TECH_MENU, | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     pub fn as_bytes(&self) -> [u8; 40] { | ||||
|         self.tech_menu | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] | ||||
| pub struct CharacterEntityId(pub u32); | ||||
| @ -248,6 +266,8 @@ pub struct NewCharacterEntity { | ||||
|     pub config: CharacterConfig, | ||||
|     pub info_board: CharacterInfoboard, | ||||
|     pub guildcard: CharacterGuildCard, | ||||
| 
 | ||||
|     pub tech_menu: CharacterTechMenu, | ||||
| } | ||||
| 
 | ||||
| impl NewCharacterEntity { | ||||
| @ -264,6 +284,7 @@ impl NewCharacterEntity { | ||||
|             config: CharacterConfig::new(), | ||||
|             info_board: CharacterInfoboard::new(), | ||||
|             guildcard: CharacterGuildCard::default(), | ||||
|             tech_menu: CharacterTechMenu::new(), | ||||
|         } | ||||
|     } | ||||
| } | ||||
| @ -285,4 +306,6 @@ pub struct CharacterEntity { | ||||
|     pub config: CharacterConfig, | ||||
|     pub info_board: CharacterInfoboard, | ||||
|     pub guildcard: CharacterGuildCard, | ||||
| 
 | ||||
|     pub tech_menu: CharacterTechMenu, | ||||
| } | ||||
|  | ||||
| @ -123,6 +123,7 @@ impl EntityGateway for InMemoryGateway { | ||||
|             config: character.config, | ||||
|             info_board: character.info_board, | ||||
|             guildcard: character.guildcard, | ||||
|             tech_menu: character.tech_menu, | ||||
|         }; | ||||
|         characters.insert(new_character.id, new_character.clone()); | ||||
|         Some(new_character) | ||||
|  | ||||
| @ -184,7 +184,7 @@ pub struct Mag { | ||||
|     pub synchro: u8, | ||||
|     pub iq: u8, | ||||
|     pub photon_blast: [Option<PhotonBlast>; 3], | ||||
|     // color
 | ||||
|     pub color: u8, | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| @ -197,10 +197,10 @@ impl Mag { | ||||
|         result[6..8].copy_from_slice(&self.pow.to_le_bytes()); | ||||
|         result[8..10].copy_from_slice(&self.dex.to_le_bytes()); | ||||
|         result[10..12].copy_from_slice(&self.mnd.to_le_bytes()); | ||||
|         //result[12] = color
 | ||||
|         result[14] = self.photon_blast_count(); | ||||
|         result[13] = self.iq; | ||||
|         result[12] = self.synchro; | ||||
|         result[13] = self.iq; | ||||
|         result[14] = self.photon_blast_count(); | ||||
|         result[15] = self.color; | ||||
|         result | ||||
|     } | ||||
| 
 | ||||
|  | ||||
| @ -250,6 +250,7 @@ fn new_character<EG: EntityGateway>(entity_gateway: &mut EG, user: &UserAccountE | ||||
|                     synchro: 20, | ||||
|                     iq: 0, | ||||
|                     photon_blast: [None; 3], | ||||
|                     color: (character.appearance.skin % 18) as u8, | ||||
|                 }), | ||||
|             location: ItemLocation::Inventory { | ||||
|                 character_id: character.id, | ||||
|  | ||||
| @ -82,6 +82,8 @@ pub struct FullCharacterBytesBuilder<'a> { | ||||
|     inventory: Option<&'a ActiveInventory>, | ||||
|     key_config: Option<&'a [u8; 0x16C]>, | ||||
|     joystick_config: Option<&'a [u8; 0x38]>, | ||||
|     symbol_chat: Option<&'a [u8; 1248]>, | ||||
|     tech_menu: Option<&'a [u8; 40]>, | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| @ -94,6 +96,8 @@ impl<'a> FullCharacterBytesBuilder<'a> { | ||||
|             inventory: None, | ||||
|             key_config: None, | ||||
|             joystick_config: None, | ||||
|             symbol_chat: None, | ||||
|             tech_menu: None, | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
| @ -139,6 +143,20 @@ impl<'a> FullCharacterBytesBuilder<'a> { | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     pub fn symbol_chat(self, symbol_chat: &'a [u8; 1248]) -> FullCharacterBytesBuilder<'a> { | ||||
|         FullCharacterBytesBuilder { | ||||
|             symbol_chat: Some(symbol_chat), | ||||
|             ..self | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     pub fn tech_menu(self, tech_menu: &'a [u8; 40]) -> FullCharacterBytesBuilder<'a> { | ||||
|         FullCharacterBytesBuilder { | ||||
|             tech_menu: Some(tech_menu), | ||||
|             ..self | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
| 
 | ||||
|     pub fn build(self) -> character::FullCharacter { | ||||
|         let character = self.character.unwrap(); | ||||
| @ -147,6 +165,8 @@ impl<'a> FullCharacterBytesBuilder<'a> { | ||||
|         let inventory = self.inventory.unwrap(); | ||||
|         let key_config = self.key_config.unwrap(); | ||||
|         let joystick_config = self.joystick_config.unwrap(); | ||||
|         let symbol_chat = self.symbol_chat.unwrap(); | ||||
|         let tech_menu = self.tech_menu.unwrap(); | ||||
| 
 | ||||
|         character::FullCharacter { | ||||
|             character: CharacterBytesBuilder::new() | ||||
| @ -165,6 +185,8 @@ impl<'a> FullCharacterBytesBuilder<'a> { | ||||
|                 ..character::KeyTeamConfig::default() | ||||
|             }, | ||||
|             info_board: character.info_board.as_bytes(), | ||||
|             symbol_chats: *symbol_chat, | ||||
|             tech_menu: *tech_menu, | ||||
|             ..character::FullCharacter::default() | ||||
|         } | ||||
|     } | ||||
|  | ||||
| @ -143,6 +143,7 @@ impl RareDropTable { | ||||
|                     iq: 0, | ||||
|                     synchro: 20, | ||||
|                     photon_blast: [None; 3], | ||||
|                     color: rng.gen_range(0, 18), | ||||
|                 }) | ||||
|             } | ||||
|         } | ||||
|  | ||||
| @ -220,6 +220,8 @@ impl<EG: EntityGateway> ShipServerState<EG> { | ||||
|             .inventory(&client.inventory) | ||||
|             .key_config(&client.settings.settings.key_config) | ||||
|             .joystick_config(&client.settings.settings.joystick_config) | ||||
|             .symbol_chat(&client.settings.settings.symbol_chats) | ||||
|             .tech_menu(&client.character.tech_menu.as_bytes()) | ||||
|             .build(); | ||||
| 
 | ||||
|         Ok(vec![ | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user