Browse Source

lint src/login/*

pull/42/head
jake 4 years ago
parent
commit
5d6b109cc5
  1. 34
      src/login/character.rs
  2. 2
      src/login/login.rs
  3. 3
      src/login/mod.rs

34
src/login/character.rs

@ -86,14 +86,14 @@ impl RecvServerPacket for RecvCharacterPacket {
pub enum SendCharacterPacket {
LoginResponse(LoginResponse),
LoginWelcome(LoginWelcome),
SendKeyAndTeamSettings(SendKeyAndTeamSettings),
SendKeyAndTeamSettings(Box<SendKeyAndTeamSettings>),
CharAck(CharAck),
ChecksumAck(ChecksumAck),
CharacterPreview(CharacterPreview),
GuildcardDataHeader(GuildcardDataHeader),
GuildcardDataChunk(Box<GuildcardDataChunk>),
ParamDataHeader(ParamDataHeader),
ParamDataChunk(ParamDataChunk),
ParamDataChunk(Box<ParamDataChunk>),
Timestamp(Timestamp),
ShipList(ShipList),
RedirectClient(RedirectClient),
@ -285,10 +285,12 @@ async fn new_character<EG: EntityGateway>(entity_gateway: &mut EG, user: &UserAc
};
entity_gateway.set_character_inventory(&character.id, &inventory).await?;
entity_gateway.set_character_bank(&character.id, &BankEntity::default(), BankName("".into())).await?;
let mut equipped = EquippedEntity::default();
equipped.weapon = Some(weapon.id);
equipped.armor = Some(armor.id);
equipped.mag = Some(mag.id);
let equipped = EquippedEntity {
weapon: Some(weapon.id),
armor: Some(armor.id),
mag: Some(mag.id),
..Default::default()
};
entity_gateway.set_character_equips(&character.id, &equipped).await?;
Ok(())
}
@ -336,7 +338,7 @@ impl<EG: EntityGateway> CharacterServerState<EG> {
let client = self.clients.get_mut(&id).ok_or(CharacterError::ClientNotFound(id))?;
self.connected_clients.insert(user.id.clone(), ConnectedClient {
self.connected_clients.insert(user.id, ConnectedClient {
ship_id: None,
expires: None, //Some(chrono::Utc::now() + chrono::Duration::minutes(1)),
});
@ -368,7 +370,7 @@ impl<EG: EntityGateway> CharacterServerState<EG> {
let client = self.clients.get_mut(&id).ok_or(CharacterError::ClientNotFound(id))?;
let user = client.user.as_ref().unwrap();
let settings = match self.entity_gateway.get_user_settings_by_user(&user).await {
let settings = match self.entity_gateway.get_user_settings_by_user(user).await {
Ok(settings) => settings,
Err(_) => {
let user_settings = NewUserSettingsEntity::new(user.id);
@ -378,7 +380,7 @@ impl<EG: EntityGateway> CharacterServerState<EG> {
let pkt = SendKeyAndTeamSettings::new(settings.settings.key_config,
settings.settings.joystick_config, 0, 0);
let pkt = SendCharacterPacket::SendKeyAndTeamSettings(pkt);
let pkt = SendCharacterPacket::SendKeyAndTeamSettings(Box::new(pkt));
Ok(vec![pkt])
}
@ -396,7 +398,7 @@ impl<EG: EntityGateway> CharacterServerState<EG> {
vec![SendCharacterPacket::CharacterPreview(CharacterPreview {
slot: select.slot,
character: SelectScreenCharacterBuilder::new()
.character(&char)
.character(char)
.level(level)
.build()
})]
@ -461,7 +463,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.save_user(&user).await.unwrap();
self.entity_gateway.save_user(user).await.unwrap();
Ok(None.into_iter())
}
@ -477,10 +479,10 @@ impl<EG: EntityGateway> CharacterServerState<EG> {
data[..end-start].copy_from_slice(&self.param_data[start..end]);
Ok(vec![SendCharacterPacket::ParamDataChunk(
ParamDataChunk {
Box::new(ParamDataChunk {
chunk: chunk as u32,
data: data,
}
})
)])
}
@ -490,7 +492,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 {
new_character(&mut self.entity_gateway, &user, preview).await?
new_character(&mut self.entity_gateway, user, preview).await?
}
if user.flags == USERFLAG_DRESSINGROOM {
// TODO: dressing room stuff
@ -499,7 +501,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.save_user(&user).await.unwrap();
self.entity_gateway.save_user(user).await.unwrap();
Ok(vec![SendCharacterPacket::LoginResponse(LoginResponse::by_char_select(user.guildcard,
user.team_id.unwrap_or(1),
client.session)),
@ -512,7 +514,7 @@ impl<EG: EntityGateway> CharacterServerState<EG> {
fn select_ship(&mut self, id: ClientId, menuselect: &MenuSelect) -> Result<Vec<SendCharacterPacket>, anyhow::Error> {
if menuselect.menu != SHIP_MENU_ID {
Err(CharacterError::InvalidMenuSelection(menuselect.menu, menuselect.item))?;
return Err(CharacterError::InvalidMenuSelection(menuselect.menu, menuselect.item).into());
}
if let Some(client) = self.clients.get(&id) {

2
src/login/login.rs

@ -102,7 +102,7 @@ impl<EG: EntityGateway> LoginServerState<EG> {
pub fn new(entity_gateway: EG, character_server_ip: net::Ipv4Addr) -> LoginServerState<EG> {
LoginServerState {
entity_gateway: entity_gateway,
character_server_ip: character_server_ip.into(),
character_server_ip: character_server_ip,
clients: HashMap::new(),
}
}

3
src/login/mod.rs

@ -1,2 +1,3 @@
#[allow(clippy::module_inception)]
pub mod login;
pub mod character;
pub mod character;
Loading…
Cancel
Save