|
|
@ -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) {
|
|
|
|