Browse Source

return the correct things

pbs
Jake Probst 5 years ago
parent
commit
1d7d4d8205
  1. 27
      src/login/character.rs

27
src/login/character.rs

@ -45,16 +45,17 @@ impl RecvServerPacket for RecvCharacterPacket {
#[derive(Debug)]
pub enum SendCharacterPacket {
//LoginResponse(LoginResponse),
LoginResponse(LoginResponse),
LoginWelcome(LoginWelcome),
//RedirectClient(RedirectClient),
SendKeyAndTeamSettings(SendKeyAndTeamSettings),
}
impl SendServerPacket for SendCharacterPacket {
fn as_bytes(&self) -> Vec<u8> {
match self {
//SendCharacterPacket::LoginResponse(pkt) => pkt.as_bytes(),
SendCharacterPacket::LoginResponse(pkt) => pkt.as_bytes(),
SendCharacterPacket::LoginWelcome(pkt) => pkt.as_bytes(),
SendCharacterPacket::SendKeyAndTeamSettings(pkt) => pkt.as_bytes(),
//SendLoginPacket::RedirectClient(pkt) => pkt.as_bytes(),
}
}
@ -73,17 +74,17 @@ impl<DA: DataAccess> CharacterServerState<DA> {
}
}
fn validate_login(&mut self, pkt: &Login) -> Box<PktVec> {
fn validate_login(&mut self, pkt: &Login) -> Vec<SendCharacterPacket> {
match get_login_status(&self.shared_state.data_access, pkt) {
Ok(user) => {
let mut response = LoginResponse::by_status(AccountStatus::Ok, pkt.security_data);
response.guildcard = user.guildcard.map_or(0, |gc| gc) as u32;
response.team_id = user.team_id.map_or(0, |ti| ti) as u32;
self.user = Some(user);
pktvec![response]
vec![SendCharacterPacket::LoginResponse(response)]
},
Err(err) => {
pktvec![LoginResponse::by_status(err, pkt.security_data)]
vec![SendCharacterPacket::LoginResponse(LoginResponse::by_status(err, pkt.security_data))]
}
}
}
@ -113,16 +114,14 @@ impl<DA: DataAccess> ServerState for CharacterServerState<DA> {
}
fn handle(&mut self, pkt: &RecvCharacterPacket) -> Box<dyn Iterator<Item = SendCharacterPacket>> {
println!("[character: recv] {:?}", pkt);
/*match pkt {
CharacterPacket::Login(login) => {
self.validate_login(login)
match pkt {
RecvCharacterPacket::Login(login) => {
Box::new(self.validate_login(login).into_iter())
},
CharacterPacket::RequestSettings(_req) => {
self.get_settings()
RecvCharacterPacket::RequestSettings(_req) => {
Box::new(self.get_settings().into_iter())
}
}*/
Box::new(None.into_iter())
}
}
}

Loading…
Cancel
Save