|
@ -1,3 +1,4 @@ |
|
|
|
|
|
#![allow(dead_code, unused_assignments)]
|
|
|
use std::io::Read;
|
|
|
use std::io::Read;
|
|
|
use std::collections::HashMap;
|
|
|
use std::collections::HashMap;
|
|
|
|
|
|
|
|
@ -16,8 +17,8 @@ use crate::common::leveltable::CharacterLevelTable; |
|
|
use libpso::{utf8_to_array, utf8_to_utf16_array};
|
|
|
use libpso::{utf8_to_array, utf8_to_utf16_array};
|
|
|
|
|
|
|
|
|
use crate::entity::gateway::EntityGateway;
|
|
|
use crate::entity::gateway::EntityGateway;
|
|
|
use crate::entity::account::{UserAccountEntity, UserSettingsEntity, NewUserAccountEntity, NewUserSettingsEntity, USERFLAG_NEWCHAR, USERFLAG_DRESSINGROOM};
|
|
|
|
|
|
use crate::entity::item::{NewItemEntity, ItemEntity, ItemDetail, ItemLocation};
|
|
|
|
|
|
|
|
|
use crate::entity::account::{UserAccountEntity, NewUserSettingsEntity, USERFLAG_NEWCHAR, USERFLAG_DRESSINGROOM};
|
|
|
|
|
|
use crate::entity::item::{NewItemEntity, ItemDetail, ItemLocation};
|
|
|
use crate::entity::item::weapon::Weapon;
|
|
|
use crate::entity::item::weapon::Weapon;
|
|
|
use crate::entity::item::armor::Armor;
|
|
|
use crate::entity::item::armor::Armor;
|
|
|
use crate::entity::item::tech::Technique;
|
|
|
use crate::entity::item::tech::Technique;
|
|
@ -363,7 +364,7 @@ impl<EG: EntityGateway> CharacterServerState<EG> { |
|
|
if select.reason == 0 {
|
|
|
if select.reason == 0 {
|
|
|
let chars = client.characters.as_ref().unwrap();
|
|
|
let chars = client.characters.as_ref().unwrap();
|
|
|
Ok(if let Some(char) = &chars[select.slot as usize] {
|
|
|
Ok(if let Some(char) = &chars[select.slot as usize] {
|
|
|
let (level, stats) = self.level_table.get_stats_from_exp(char.char_class, char.exp);
|
|
|
|
|
|
|
|
|
let (level, _stats) = self.level_table.get_stats_from_exp(char.char_class, char.exp);
|
|
|
vec![SendCharacterPacket::CharacterPreview(CharacterPreview {
|
|
|
vec![SendCharacterPacket::CharacterPreview(CharacterPreview {
|
|
|
slot: select.slot,
|
|
|
slot: select.slot,
|
|
|
character: SelectScreenCharacterBuilder::new()
|
|
|
character: SelectScreenCharacterBuilder::new()
|
|
@ -557,7 +558,7 @@ impl<EG: EntityGateway> ServerState for CharacterServerState<EG> { |
|
|
})
|
|
|
})
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
fn on_disconnect(&mut self, id: ClientId) -> Vec<(ClientId, SendCharacterPacket)> {
|
|
|
|
|
|
|
|
|
fn on_disconnect(&mut self, _id: ClientId) -> Vec<(ClientId, SendCharacterPacket)> {
|
|
|
Vec::new()
|
|
|
Vec::new()
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@ -711,7 +712,7 @@ mod test { |
|
|
|
|
|
|
|
|
#[test]
|
|
|
#[test]
|
|
|
fn test_character_create() {
|
|
|
fn test_character_create() {
|
|
|
let TestData = InMemoryGateway::new();
|
|
|
|
|
|
|
|
|
let test_data = InMemoryGateway::new();
|
|
|
let mut fake_user = ClientState::new();
|
|
|
let mut fake_user = ClientState::new();
|
|
|
fake_user.user = Some(UserAccountEntity {
|
|
|
fake_user.user = Some(UserAccountEntity {
|
|
|
id: UserAccountId(3),
|
|
|
id: UserAccountId(3),
|
|
@ -725,10 +726,10 @@ mod test { |
|
|
flags: 0,
|
|
|
flags: 0,
|
|
|
});
|
|
|
});
|
|
|
|
|
|
|
|
|
let mut server = CharacterServerState::new(TestData.clone());
|
|
|
|
|
|
|
|
|
let mut server = CharacterServerState::new(test_data.clone());
|
|
|
server.clients.insert(ClientId(1), fake_user.clone());
|
|
|
server.clients.insert(ClientId(1), fake_user.clone());
|
|
|
let mut send = server.handle(ClientId(1), &RecvCharacterPacket::SetFlag(SetFlag {flags: 1})).unwrap().collect::<Vec<_>>();
|
|
|
let mut send = server.handle(ClientId(1), &RecvCharacterPacket::SetFlag(SetFlag {flags: 1})).unwrap().collect::<Vec<_>>();
|
|
|
assert!(TestData.get_user_by_id(UserAccountId(3)).unwrap().flags == 1);
|
|
|
|
|
|
|
|
|
assert!(test_data.get_user_by_id(UserAccountId(3)).unwrap().flags == 1);
|
|
|
send = server.handle(ClientId(1), &RecvCharacterPacket::CharacterPreview(CharacterPreview {slot: 1, character: character::SelectScreenCharacter {
|
|
|
send = server.handle(ClientId(1), &RecvCharacterPacket::CharacterPreview(CharacterPreview {slot: 1, character: character::SelectScreenCharacter {
|
|
|
exp: 0,
|
|
|
exp: 0,
|
|
|
level: 0,
|
|
|
level: 0,
|
|
@ -758,7 +759,7 @@ mod test { |
|
|
} })).unwrap().collect::<Vec<_>>();
|
|
|
} })).unwrap().collect::<Vec<_>>();
|
|
|
assert!(send.len() == 2);
|
|
|
assert!(send.len() == 2);
|
|
|
|
|
|
|
|
|
let chars = TestData.get_characters_by_user(&fake_user.user.unwrap());
|
|
|
|
|
|
|
|
|
let chars = test_data.get_characters_by_user(&fake_user.user.unwrap());
|
|
|
assert!(chars[1].as_ref().unwrap().name == "\tEtest name");
|
|
|
assert!(chars[1].as_ref().unwrap().name == "\tEtest name");
|
|
|
assert!(chars[0].is_none());
|
|
|
assert!(chars[0].is_none());
|
|
|
}
|
|
|
}
|
|
|