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