Browse Source

move new char logic into its own function

pbs
jake 5 years ago
parent
commit
8f33512ea2
  1. 29
      src/login/character.rs

29
src/login/character.rs

@ -179,6 +179,24 @@ pub struct CharacterServerState<EG: EntityGateway> {
level_table: CharacterLevelTable,
}
fn new_character<EG: EntityGateway>(entity_gateway: &mut EG, user: &UserAccount, preview: &CharacterPreview) {
let mut char = entity_gateway.new_character_by_user(&user);
char.slot = preview.slot;
char.character = preview.character.as_character();
/*let char = Character {
id: 9,
slot: preview.slot,
user_id: user.id,
character: preview.character.as_character()
};*/
entity_gateway.set_character(&char);
}
impl<EG: EntityGateway> CharacterServerState<EG> {
pub fn new(entity_gateway: EG) -> CharacterServerState<EG> {
let (param_header, param_data) = generate_param_data("data/param/");
@ -347,16 +365,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();
if user.flags == USERFLAG_NEWCHAR {
let mut char = self.entity_gateway.new_character_by_user(&user);
char.slot = preview.slot;
char.character = preview.character.as_character();
let char = Character {
id: 9,
slot: preview.slot,
user_id: user.id,
character: preview.character.as_character()
};
self.entity_gateway.set_character(&char);
new_character(&mut self.entity_gateway, &user, preview)
}
if user.flags == USERFLAG_DRESSINGROOM {
// TODO: dressing room stuff

Loading…
Cancel
Save