|
|
@ -16,14 +16,14 @@ use crate::common::leveltable::CharacterLevelTable; |
|
|
|
use libpso::{utf8_to_array, utf8_to_utf16_array};
|
|
|
|
|
|
|
|
use crate::entity::gateway::EntityGateway;
|
|
|
|
use crate::entity::account::{UserAccountEntity, UserSettingsEntity, USERFLAG_NEWCHAR, USERFLAG_DRESSINGROOM};
|
|
|
|
use crate::entity::item::{ItemEntity, ItemDetail, ItemLocation};
|
|
|
|
use crate::entity::account::{UserAccountEntity, UserSettingsEntity, NewUserAccountEntity, NewUserSettingsEntity, USERFLAG_NEWCHAR, USERFLAG_DRESSINGROOM};
|
|
|
|
use crate::entity::item::{NewItemEntity, ItemEntity, ItemDetail, ItemLocation};
|
|
|
|
use crate::entity::item::weapon::Weapon;
|
|
|
|
use crate::entity::item::armor::Armor;
|
|
|
|
use crate::entity::item::tech::Technique;
|
|
|
|
use crate::entity::item::tool::Tool;
|
|
|
|
use crate::entity::item::mag::{Mag, MagType};
|
|
|
|
use crate::entity::character::{CharacterEntity, CharacterClass, TechLevel};
|
|
|
|
use crate::entity::character::{CharacterEntity, NewCharacterEntity, CharacterClass, TechLevel};
|
|
|
|
|
|
|
|
use crate::login::login::get_login_status;
|
|
|
|
|
|
|
@ -198,7 +198,7 @@ fn new_character<EG: EntityGateway>(entity_gateway: &mut EG, user: &UserAccountE |
|
|
|
_ => {}
|
|
|
|
}
|
|
|
|
|
|
|
|
entity_gateway.set_character(&mut character);
|
|
|
|
let character = entity_gateway.create_character(character).unwrap();
|
|
|
|
|
|
|
|
let new_weapon = match character.char_class {
|
|
|
|
CharacterClass::HUmar | CharacterClass::HUnewearl | CharacterClass::HUcast | CharacterClass::HUcaseal => item::weapon::WeaponType::Saber,
|
|
|
@ -207,9 +207,8 @@ fn new_character<EG: EntityGateway>(entity_gateway: &mut EG, user: &UserAccountE |
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
entity_gateway.set_item(
|
|
|
|
&mut ItemEntity {
|
|
|
|
id: None,
|
|
|
|
entity_gateway.create_item(
|
|
|
|
NewItemEntity {
|
|
|
|
item : ItemDetail::Weapon(
|
|
|
|
Weapon {
|
|
|
|
weapon: new_weapon,
|
|
|
@ -219,14 +218,13 @@ fn new_character<EG: EntityGateway>(entity_gateway: &mut EG, user: &UserAccountE |
|
|
|
tekked: true,
|
|
|
|
}),
|
|
|
|
location: ItemLocation::Inventory {
|
|
|
|
character_id: character.id.unwrap(),
|
|
|
|
character_id: character.id,
|
|
|
|
index: 0,
|
|
|
|
equipped: true,
|
|
|
|
}});
|
|
|
|
|
|
|
|
entity_gateway.set_item(
|
|
|
|
&mut ItemEntity {
|
|
|
|
id: None,
|
|
|
|
entity_gateway.create_item(
|
|
|
|
NewItemEntity {
|
|
|
|
item: ItemDetail::Armor (
|
|
|
|
Armor {
|
|
|
|
armor: item::armor::ArmorType::Frame,
|
|
|
@ -235,14 +233,13 @@ fn new_character<EG: EntityGateway>(entity_gateway: &mut EG, user: &UserAccountE |
|
|
|
slots: 0,
|
|
|
|
}),
|
|
|
|
location: ItemLocation::Inventory {
|
|
|
|
character_id: character.id.unwrap(),
|
|
|
|
character_id: character.id,
|
|
|
|
index: 1,
|
|
|
|
equipped: true,
|
|
|
|
}});
|
|
|
|
|
|
|
|
entity_gateway.set_item(
|
|
|
|
&mut ItemEntity {
|
|
|
|
id: None,
|
|
|
|
entity_gateway.create_item(
|
|
|
|
NewItemEntity {
|
|
|
|
item: ItemDetail::Mag(
|
|
|
|
Mag {
|
|
|
|
mag: MagType::Mag,
|
|
|
@ -255,33 +252,31 @@ fn new_character<EG: EntityGateway>(entity_gateway: &mut EG, user: &UserAccountE |
|
|
|
photon_blast: [None; 3],
|
|
|
|
}),
|
|
|
|
location: ItemLocation::Inventory {
|
|
|
|
character_id: character.id.unwrap(),
|
|
|
|
character_id: character.id,
|
|
|
|
index: 2,
|
|
|
|
equipped: true,
|
|
|
|
}});
|
|
|
|
|
|
|
|
for _ in 0..4 {
|
|
|
|
entity_gateway.set_item(
|
|
|
|
&mut ItemEntity {
|
|
|
|
id: None,
|
|
|
|
entity_gateway.create_item(
|
|
|
|
NewItemEntity {
|
|
|
|
item: ItemDetail::Tool (
|
|
|
|
Tool {
|
|
|
|
tool: item::tool::ToolType::Monomate,
|
|
|
|
}),
|
|
|
|
location: ItemLocation::Inventory {
|
|
|
|
character_id: character.id.unwrap(),
|
|
|
|
character_id: character.id,
|
|
|
|
index: 3,
|
|
|
|
equipped: false,
|
|
|
|
}});
|
|
|
|
entity_gateway.set_item(
|
|
|
|
&mut ItemEntity {
|
|
|
|
id: None,
|
|
|
|
entity_gateway.create_item(
|
|
|
|
NewItemEntity {
|
|
|
|
item: ItemDetail::Tool (
|
|
|
|
Tool {
|
|
|
|
tool: item::tool::ToolType::Monofluid,
|
|
|
|
}),
|
|
|
|
location: ItemLocation::Inventory {
|
|
|
|
character_id: character.id.unwrap(),
|
|
|
|
character_id: character.id,
|
|
|
|
index: 4,
|
|
|
|
equipped: false,
|
|
|
|
}});
|
|
|
@ -346,9 +341,8 @@ impl<EG: EntityGateway> CharacterServerState<EG> { |
|
|
|
let settings = match self.entity_gateway.get_user_settings_by_user(&user) {
|
|
|
|
Some(settings) => settings,
|
|
|
|
None => {
|
|
|
|
let mut user_settings = UserSettingsEntity::new(user.id.unwrap());
|
|
|
|
self.entity_gateway.set_user_settings(&mut user_settings);
|
|
|
|
user_settings
|
|
|
|
let user_settings = NewUserSettingsEntity::new(user.id);
|
|
|
|
self.entity_gateway.create_user_settings(user_settings).unwrap()
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
@ -437,7 +431,7 @@ impl<EG: EntityGateway> CharacterServerState<EG> { |
|
|
|
let client = self.clients.get_mut(&id).ok_or(CharacterError::ClientNotFound(id))?;
|
|
|
|
let mut user = client.user.as_mut().unwrap();
|
|
|
|
user.flags = setflag.flags;
|
|
|
|
self.entity_gateway.set_user(&mut user);
|
|
|
|
self.entity_gateway.save_user(&user);
|
|
|
|
Ok(None.into_iter())
|
|
|
|
}
|
|
|
|
|
|
|
@ -475,7 +469,7 @@ impl<EG: EntityGateway> CharacterServerState<EG> { |
|
|
|
client.session.action = SessionAction::SelectCharacter;
|
|
|
|
client.session.character_slot = preview.slot as u8;
|
|
|
|
user.flags = 0;
|
|
|
|
self.entity_gateway.set_user(&mut user);
|
|
|
|
self.entity_gateway.save_user(&user);
|
|
|
|
Ok(vec![SendCharacterPacket::LoginResponse(LoginResponse::by_char_select(user.guildcard,
|
|
|
|
user.team_id.unwrap_or(1),
|
|
|
|
client.session)),
|
|
|
@ -568,8 +562,8 @@ impl<EG: EntityGateway> ServerState for CharacterServerState<EG> { |
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn new_character_from_preview(user: &UserAccountEntity, preview: &CharacterPreview) -> CharacterEntity {
|
|
|
|
let mut character = CharacterEntity::new(user.id.unwrap());
|
|
|
|
fn new_character_from_preview(user: &UserAccountEntity, preview: &CharacterPreview) -> NewCharacterEntity {
|
|
|
|
let mut character = NewCharacterEntity::new(user.id);
|
|
|
|
character.slot = preview.slot;
|
|
|
|
character.name = String::from_utf16_lossy(&preview.character.name).trim_matches(char::from(0)).into();
|
|
|
|
character.section_id = preview.character.section_id.into();
|
|
|
@ -667,8 +661,8 @@ mod test { |
|
|
|
impl EntityGateway for TestData {
|
|
|
|
fn get_user_settings_by_user(&self, user: &UserAccountEntity) -> Option<UserSettingsEntity> {
|
|
|
|
Some(UserSettingsEntity {
|
|
|
|
id: Some(UserSettingsId(0)),
|
|
|
|
user_id: user.id.unwrap(),
|
|
|
|
id: UserSettingsId(0),
|
|
|
|
user_id: user.id,
|
|
|
|
settings: settings::UserSettings::default()
|
|
|
|
})
|
|
|
|
}
|
|
|
@ -677,7 +671,7 @@ mod test { |
|
|
|
let mut server = CharacterServerState::new(TestData {});
|
|
|
|
let mut clientstate = ClientState::new();
|
|
|
|
clientstate.user = Some(UserAccountEntity {
|
|
|
|
id: Some(UserAccountId(1)),
|
|
|
|
id: UserAccountId(1),
|
|
|
|
username: "testuser".to_owned(),
|
|
|
|
password: bcrypt::hash("mypassword", 5).unwrap(),
|
|
|
|
guildcard: 0,
|
|
|
@ -719,7 +713,7 @@ mod test { |
|
|
|
let TestData = InMemoryGateway::new();
|
|
|
|
let mut fake_user = ClientState::new();
|
|
|
|
fake_user.user = Some(UserAccountEntity {
|
|
|
|
id: Some(UserAccountId(3)),
|
|
|
|
id: UserAccountId(3),
|
|
|
|
username: "hi3".to_string(),
|
|
|
|
password: bcrypt::hash("qwer", 5).unwrap(),
|
|
|
|
guildcard: 3,
|
|
|
|