Browse Source

Merge pull request 'new_char_configs' (#106) from new_char_configs into master

pbs
jake 5 years ago
parent
commit
b4399c7e7e
  1. 25
      src/entity/character.rs
  2. 1
      src/entity/gateway/inmemory.rs
  3. 8
      src/entity/item/mag.rs
  4. 1
      src/login/character.rs
  5. 22
      src/ship/character.rs
  6. 1
      src/ship/drops/rare_drop_table.rs
  7. 2
      src/ship/ship.rs

25
src/entity/character.rs

@ -2,6 +2,7 @@ use std::convert::{From, Into, TryFrom, TryInto};
use std::collections::HashMap; use std::collections::HashMap;
use libpso::packet::ship::{UpdateConfig, WriteInfoboard}; 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::item::tech::Technique;
use crate::entity::account::UserAccountId; use crate::entity::account::UserAccountId;
@ -189,7 +190,7 @@ pub struct CharacterConfig {
impl CharacterConfig { impl CharacterConfig {
fn new() -> CharacterConfig { fn new() -> CharacterConfig {
CharacterConfig { CharacterConfig {
raw_data: [0; 0xE8],
raw_data: DEFAULT_PALETTE_CONFIG,
} }
} }
@ -228,6 +229,23 @@ pub struct CharacterGuildCard {
pub description: String, 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)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub struct CharacterEntityId(pub u32); pub struct CharacterEntityId(pub u32);
@ -248,6 +266,8 @@ pub struct NewCharacterEntity {
pub config: CharacterConfig, pub config: CharacterConfig,
pub info_board: CharacterInfoboard, pub info_board: CharacterInfoboard,
pub guildcard: CharacterGuildCard, pub guildcard: CharacterGuildCard,
pub tech_menu: CharacterTechMenu,
} }
impl NewCharacterEntity { impl NewCharacterEntity {
@ -264,6 +284,7 @@ impl NewCharacterEntity {
config: CharacterConfig::new(), config: CharacterConfig::new(),
info_board: CharacterInfoboard::new(), info_board: CharacterInfoboard::new(),
guildcard: CharacterGuildCard::default(), guildcard: CharacterGuildCard::default(),
tech_menu: CharacterTechMenu::new(),
} }
} }
} }
@ -285,4 +306,6 @@ pub struct CharacterEntity {
pub config: CharacterConfig, pub config: CharacterConfig,
pub info_board: CharacterInfoboard, pub info_board: CharacterInfoboard,
pub guildcard: CharacterGuildCard, pub guildcard: CharacterGuildCard,
pub tech_menu: CharacterTechMenu,
} }

1
src/entity/gateway/inmemory.rs

@ -123,6 +123,7 @@ impl EntityGateway for InMemoryGateway {
config: character.config, config: character.config,
info_board: character.info_board, info_board: character.info_board,
guildcard: character.guildcard, guildcard: character.guildcard,
tech_menu: character.tech_menu,
}; };
characters.insert(new_character.id, new_character.clone()); characters.insert(new_character.id, new_character.clone());
Some(new_character) Some(new_character)

8
src/entity/item/mag.rs

@ -184,7 +184,7 @@ pub struct Mag {
pub synchro: u8, pub synchro: u8,
pub iq: u8, pub iq: u8,
pub photon_blast: [Option<PhotonBlast>; 3], 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[6..8].copy_from_slice(&self.pow.to_le_bytes());
result[8..10].copy_from_slice(&self.dex.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[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[12] = self.synchro;
result[13] = self.iq;
result[14] = self.photon_blast_count();
result[15] = self.color;
result result
} }

1
src/login/character.rs

@ -250,6 +250,7 @@ fn new_character<EG: EntityGateway>(entity_gateway: &mut EG, user: &UserAccountE
synchro: 20, synchro: 20,
iq: 0, iq: 0,
photon_blast: [None; 3], photon_blast: [None; 3],
color: (character.appearance.skin % 18) as u8,
}), }),
location: ItemLocation::Inventory { location: ItemLocation::Inventory {
character_id: character.id, character_id: character.id,

22
src/ship/character.rs

@ -82,6 +82,8 @@ pub struct FullCharacterBytesBuilder<'a> {
inventory: Option<&'a ActiveInventory>, inventory: Option<&'a ActiveInventory>,
key_config: Option<&'a [u8; 0x16C]>, key_config: Option<&'a [u8; 0x16C]>,
joystick_config: Option<&'a [u8; 0x38]>, 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, inventory: None,
key_config: None, key_config: None,
joystick_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 { pub fn build(self) -> character::FullCharacter {
let character = self.character.unwrap(); let character = self.character.unwrap();
@ -147,6 +165,8 @@ impl<'a> FullCharacterBytesBuilder<'a> {
let inventory = self.inventory.unwrap(); let inventory = self.inventory.unwrap();
let key_config = self.key_config.unwrap(); let key_config = self.key_config.unwrap();
let joystick_config = self.joystick_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::FullCharacter {
character: CharacterBytesBuilder::new() character: CharacterBytesBuilder::new()
@ -165,6 +185,8 @@ impl<'a> FullCharacterBytesBuilder<'a> {
..character::KeyTeamConfig::default() ..character::KeyTeamConfig::default()
}, },
info_board: character.info_board.as_bytes(), info_board: character.info_board.as_bytes(),
symbol_chats: *symbol_chat,
tech_menu: *tech_menu,
..character::FullCharacter::default() ..character::FullCharacter::default()
} }
} }

1
src/ship/drops/rare_drop_table.rs

@ -143,6 +143,7 @@ impl RareDropTable {
iq: 0, iq: 0,
synchro: 20, synchro: 20,
photon_blast: [None; 3], photon_blast: [None; 3],
color: rng.gen_range(0, 18),
}) })
} }
} }

2
src/ship/ship.rs

@ -220,6 +220,8 @@ impl<EG: EntityGateway> ShipServerState<EG> {
.inventory(&client.inventory) .inventory(&client.inventory)
.key_config(&client.settings.settings.key_config) .key_config(&client.settings.settings.key_config)
.joystick_config(&client.settings.settings.joystick_config) .joystick_config(&client.settings.settings.joystick_config)
.symbol_chat(&client.settings.settings.symbol_chats)
.tech_menu(&client.character.tech_menu.as_bytes())
.build(); .build();
Ok(vec![ Ok(vec![

Loading…
Cancel
Save