|
|
@ -3,7 +3,7 @@ use std::net::Ipv4Addr; |
|
|
|
use std::collections::HashMap;
|
|
|
|
|
|
|
|
use async_std::channel;
|
|
|
|
use async_std::sync::{Arc, Mutex};
|
|
|
|
use async_std::sync::{Arc, Mutex, RwLock};
|
|
|
|
|
|
|
|
use rand::Rng;
|
|
|
|
use thiserror::Error;
|
|
|
@ -449,7 +449,7 @@ impl<EG: EntityGateway + Clone + 'static> ShipServerStateBuilder<EG> { |
|
|
|
event: self.event.unwrap_or(ShipEvent::None),
|
|
|
|
|
|
|
|
auth_token: self.auth_token.unwrap_or_else(|| AuthToken("".into())),
|
|
|
|
ship_list: Vec::new(),
|
|
|
|
ship_list: Arc::new(RwLock::new(Vec::new())),
|
|
|
|
shipgate_sender: None,
|
|
|
|
trades: Default::default(),
|
|
|
|
}
|
|
|
@ -492,7 +492,7 @@ pub struct ShipServerState<EG: EntityGateway + Clone + 'static> { |
|
|
|
port: u16,
|
|
|
|
|
|
|
|
auth_token: AuthToken,
|
|
|
|
ship_list: Vec<Ship>,
|
|
|
|
ship_list: Arc<RwLock<Vec<Ship>>>,
|
|
|
|
shipgate_sender: Option<channel::Sender<ShipMessage>>,
|
|
|
|
trades: TradeState,
|
|
|
|
}
|
|
|
@ -666,7 +666,7 @@ impl<EG: EntityGateway + Clone> ServerState for ShipServerState<EG> { |
|
|
|
match menuselect.menu {
|
|
|
|
SHIP_MENU_ID => {
|
|
|
|
let leave_lobby = handler::lobby::remove_from_lobby(id, &mut block.client_location).await.into_iter().into_iter().flatten();
|
|
|
|
let select_ship = handler::ship::selected_ship(id, menuselect, &self.ship_list)?;
|
|
|
|
let select_ship = handler::ship::selected_ship(id, menuselect, &self.ship_list).await?;
|
|
|
|
leave_lobby.chain(select_ship).collect()
|
|
|
|
}
|
|
|
|
BLOCK_MENU_ID => {
|
|
|
@ -784,7 +784,7 @@ impl<EG: EntityGateway + Clone> ServerState for ShipServerState<EG> { |
|
|
|
handler::settings::save_options(id, save_options, &self.clients, &mut self.entity_gateway).await?
|
|
|
|
},
|
|
|
|
RecvShipPacket::RequestShipList(_) => {
|
|
|
|
handler::ship::ship_list(id, &self.ship_list)
|
|
|
|
handler::ship::ship_list(id, &self.ship_list).await
|
|
|
|
},
|
|
|
|
RecvShipPacket::RequestShipBlockList(_) => {
|
|
|
|
handler::ship::block_list(id, &self.name, self.blocks.0.len())
|
|
|
@ -865,8 +865,12 @@ impl<EG: EntityGateway + Clone> InterserverActor for ShipServerState<EG> { |
|
|
|
LoginMessage::SendMail{..} => {
|
|
|
|
Ok(Vec::new())
|
|
|
|
},
|
|
|
|
LoginMessage::ShipList{ships} => {
|
|
|
|
self.ship_list = ships;
|
|
|
|
LoginMessage::ShipList{mut ships} => {
|
|
|
|
let mut ship_list = self.ship_list
|
|
|
|
.write()
|
|
|
|
.await;
|
|
|
|
ship_list.clear();
|
|
|
|
ship_list.append(&mut ships);
|
|
|
|
Ok(Vec::new())
|
|
|
|
},
|
|
|
|
LoginMessage::RequestUsers => {
|
|
|
|