diff --git a/client/src/lib.rs b/client/src/lib.rs index c489d6c085..0f73686547 100644 --- a/client/src/lib.rs +++ b/client/src/lib.rs @@ -25,10 +25,10 @@ use common::{ }, event::{EventBus, LocalEvent}, msg::{ - validate_chat_msg, ChatMsgValidationError, ClientInGameMsg, ClientIngame, ClientMsg, + validate_chat_msg, ChatMsgValidationError, ClientInGameMsg, ClientIngame, ClientGeneralMsg, ClientNotInGameMsg, ClientRegisterMsg, ClientType, DisconnectReason, InviteAnswer, Notification, PingMsg, PlayerInfo, PlayerListUpdate, RegisterError, ServerInGameMsg, - ServerInfo, ServerInitMsg, ServerMsg, ServerNotInGameMsg, ServerRegisterAnswerMsg, + ServerInfo, ServerInitMsg, ServerGeneralMsg, ServerNotInGameMsg, ServerRegisterAnswerMsg, MAX_BYTES_CHAT_MSG, }, outcome::Outcome, @@ -502,7 +502,7 @@ impl Client { /// Send disconnect message to the server pub fn request_logout(&mut self) { debug!("Requesting logout from server"); - if let Err(e) = self.singleton_stream.send(ClientMsg::Disconnect) { + if let Err(e) = self.singleton_stream.send(ClientGeneralMsg::Disconnect) { error!( ?e, "Couldn't send disconnect package to server, did server close already?" @@ -844,7 +844,7 @@ impl Client { match validate_chat_msg(&message) { Ok(()) => self .singleton_stream - .send(ClientMsg::ChatMsg(message)) + .send(ClientGeneralMsg::ChatMsg(message)) .unwrap(), Err(ChatMsgValidationError::TooLong) => tracing::warn!( "Attempted to send a message that's too long (Over {} bytes)", @@ -1111,24 +1111,24 @@ impl Client { fn handle_server_msg( &mut self, frontend_events: &mut Vec, - msg: ServerMsg, + msg: ServerGeneralMsg, ) -> Result<(), Error> { match msg { - ServerMsg::Disconnect(reason) => match reason { + ServerGeneralMsg::Disconnect(reason) => match reason { DisconnectReason::Shutdown => return Err(Error::ServerShutdown), DisconnectReason::Requested => { debug!("finally sending ClientMsg::Terminate"); frontend_events.push(Event::Disconnect); - self.singleton_stream.send(ClientMsg::Terminate)?; + self.singleton_stream.send(ClientGeneralMsg::Terminate)?; }, DisconnectReason::Kicked(reason) => { debug!("sending ClientMsg::Terminate because we got kicked"); frontend_events.push(Event::Kicked(reason.clone())); - self.singleton_stream.send(ClientMsg::Terminate)?; + self.singleton_stream.send(ClientGeneralMsg::Terminate)?; }, }, - ServerMsg::PlayerListUpdate(PlayerListUpdate::Init(list)) => self.player_list = list, - ServerMsg::PlayerListUpdate(PlayerListUpdate::Add(uid, player_info)) => { + ServerGeneralMsg::PlayerListUpdate(PlayerListUpdate::Init(list)) => self.player_list = list, + ServerGeneralMsg::PlayerListUpdate(PlayerListUpdate::Add(uid, player_info)) => { if let Some(old_player_info) = self.player_list.insert(uid, player_info.clone()) { warn!( "Received msg to insert {} with uid {} into the player list but there was \ @@ -1137,7 +1137,7 @@ impl Client { ); } }, - ServerMsg::PlayerListUpdate(PlayerListUpdate::Admin(uid, admin)) => { + ServerGeneralMsg::PlayerListUpdate(PlayerListUpdate::Admin(uid, admin)) => { if let Some(player_info) = self.player_list.get_mut(&uid) { player_info.is_admin = admin; } else { @@ -1148,7 +1148,7 @@ impl Client { ); } }, - ServerMsg::PlayerListUpdate(PlayerListUpdate::SelectedCharacter(uid, char_info)) => { + ServerGeneralMsg::PlayerListUpdate(PlayerListUpdate::SelectedCharacter(uid, char_info)) => { if let Some(player_info) = self.player_list.get_mut(&uid) { player_info.character = Some(char_info); } else { @@ -1159,7 +1159,7 @@ impl Client { ); } }, - ServerMsg::PlayerListUpdate(PlayerListUpdate::LevelChange(uid, next_level)) => { + ServerGeneralMsg::PlayerListUpdate(PlayerListUpdate::LevelChange(uid, next_level)) => { if let Some(player_info) = self.player_list.get_mut(&uid) { player_info.character = match &player_info.character { Some(character) => Some(common::msg::CharacterInfo { @@ -1178,7 +1178,7 @@ impl Client { }; } }, - ServerMsg::PlayerListUpdate(PlayerListUpdate::Remove(uid)) => { + ServerGeneralMsg::PlayerListUpdate(PlayerListUpdate::Remove(uid)) => { // Instead of removing players, mark them as offline because we need to // remember the names of disconnected players in chat. // @@ -1203,7 +1203,7 @@ impl Client { ); } }, - ServerMsg::PlayerListUpdate(PlayerListUpdate::Alias(uid, new_name)) => { + ServerGeneralMsg::PlayerListUpdate(PlayerListUpdate::Alias(uid, new_name)) => { if let Some(player_info) = self.player_list.get_mut(&uid) { player_info.player_alias = new_name; } else { @@ -1214,38 +1214,38 @@ impl Client { ); } }, - ServerMsg::ChatMsg(m) => frontend_events.push(Event::Chat(m)), - ServerMsg::SetPlayerEntity(uid) => { + ServerGeneralMsg::ChatMsg(m) => frontend_events.push(Event::Chat(m)), + ServerGeneralMsg::SetPlayerEntity(uid) => { if let Some(entity) = self.state.ecs().entity_from_uid(uid.0) { self.entity = entity; } else { return Err(Error::Other("Failed to find entity from uid.".to_owned())); } }, - ServerMsg::TimeOfDay(time_of_day) => { + ServerGeneralMsg::TimeOfDay(time_of_day) => { *self.state.ecs_mut().write_resource() = time_of_day; }, - ServerMsg::EntitySync(entity_sync_package) => { + ServerGeneralMsg::EntitySync(entity_sync_package) => { self.state .ecs_mut() .apply_entity_sync_package(entity_sync_package); }, - ServerMsg::CompSync(comp_sync_package) => { + ServerGeneralMsg::CompSync(comp_sync_package) => { self.state .ecs_mut() .apply_comp_sync_package(comp_sync_package); }, - ServerMsg::CreateEntity(entity_package) => { + ServerGeneralMsg::CreateEntity(entity_package) => { self.state.ecs_mut().apply_entity_package(entity_package); }, - ServerMsg::DeleteEntity(entity) => { + ServerGeneralMsg::DeleteEntity(entity) => { if self.uid() != Some(entity) { self.state .ecs_mut() .delete_entity_and_clear_from_uid_allocator(entity.0); } }, - ServerMsg::Notification(n) => { + ServerGeneralMsg::Notification(n) => { frontend_events.push(Event::Notification(n)); }, } @@ -1802,7 +1802,7 @@ impl Client { impl Drop for Client { fn drop(&mut self) { trace!("Dropping client"); - if let Err(e) = self.singleton_stream.send(ClientMsg::Disconnect) { + if let Err(e) = self.singleton_stream.send(ClientGeneralMsg::Disconnect) { warn!( ?e, "Error during drop of client, couldn't send disconnect package, is the connection \ diff --git a/common/src/comp/chat.rs b/common/src/comp/chat.rs index 71af8a6960..0888a9e21b 100644 --- a/common/src/comp/chat.rs +++ b/common/src/comp/chat.rs @@ -1,4 +1,4 @@ -use crate::{comp::group::Group, msg::ServerMsg, sync::Uid}; +use crate::{comp::group::Group, msg::ServerGeneralMsg, sync::Uid}; use serde::{Deserialize, Serialize}; use specs::Component; use specs_idvs::IdvStorage; @@ -118,11 +118,11 @@ impl ChatType { } } impl ChatType { - pub fn server_msg(self, msg: S) -> ServerMsg + pub fn server_msg(self, msg: S) -> ServerGeneralMsg where S: Into, { - ServerMsg::ChatMsg(self.chat_msg(msg)) + ServerGeneralMsg::ChatMsg(self.chat_msg(msg)) } } // Stores chat text, type diff --git a/common/src/msg/client.rs b/common/src/msg/client.rs index 5e464fc5b9..23d904760a 100644 --- a/common/src/msg/client.rs +++ b/common/src/msg/client.rs @@ -63,9 +63,9 @@ pub enum ClientInGameMsg { /// Messages sent from the client to the server #[derive(Debug, Clone, Serialize, Deserialize)] -pub enum ClientMsg { +pub enum ClientGeneralMsg { ChatMsg(String), Command(String), Disconnect, Terminate, -} +} \ No newline at end of file diff --git a/common/src/msg/mod.rs b/common/src/msg/mod.rs index 964ee157fc..39fa3fc106 100644 --- a/common/src/msg/mod.rs +++ b/common/src/msg/mod.rs @@ -4,11 +4,11 @@ pub mod server; // Reexports pub use self::{ - client::{ClientInGameMsg, ClientMsg, ClientNotInGameMsg, ClientRegisterMsg, ClientType}, + client::{ClientInGameMsg, ClientGeneralMsg, ClientNotInGameMsg, ClientRegisterMsg, ClientType}, ecs_packet::EcsCompPacket, server::{ CharacterInfo, DisconnectReason, InviteAnswer, Notification, PlayerInfo, PlayerListUpdate, - RegisterError, ServerInGameMsg, ServerInfo, ServerInitMsg, ServerMsg, ServerNotInGameMsg, + RegisterError, ServerInGameMsg, ServerInfo, ServerInitMsg, ServerGeneralMsg, ServerNotInGameMsg, ServerRegisterAnswerMsg, }, }; diff --git a/common/src/msg/server.rs b/common/src/msg/server.rs index 8aaa9873c4..542d0a64f2 100644 --- a/common/src/msg/server.rs +++ b/common/src/msg/server.rs @@ -255,7 +255,7 @@ pub enum ServerInGameMsg { /// Messages sent from the server to the client #[derive(Debug, Clone, Serialize, Deserialize)] -pub enum ServerMsg { +pub enum ServerGeneralMsg { PlayerListUpdate(PlayerListUpdate), /// A message to go into the client chat box. The client is responsible for /// formatting the message and turning it into a speech bubble. @@ -285,6 +285,6 @@ impl From for RegisterError { fn from(err: AuthClientError) -> Self { Self::AuthError(err.to_string()) } } -impl From for ServerMsg { - fn from(v: comp::ChatMsg) -> Self { ServerMsg::ChatMsg(v) } +impl From for ServerGeneralMsg { + fn from(v: comp::ChatMsg) -> Self { ServerGeneralMsg::ChatMsg(v) } } diff --git a/server/src/client.rs b/server/src/client.rs index 7423589d1f..8c320280e7 100644 --- a/server/src/client.rs +++ b/server/src/client.rs @@ -1,7 +1,7 @@ use crate::error::Error; use common::msg::{ - ClientInGameMsg, ClientIngame, ClientMsg, ClientNotInGameMsg, ClientType, PingMsg, - ServerInGameMsg, ServerInitMsg, ServerMsg, ServerNotInGameMsg, + ClientInGameMsg, ClientIngame, ClientGeneralMsg, ClientNotInGameMsg, ClientType, PingMsg, + ServerInGameMsg, ServerInitMsg, ServerGeneralMsg, ServerNotInGameMsg, }; use hashbrown::HashSet; use network::{MessageBuffer, Participant, Stream}; @@ -57,7 +57,7 @@ impl Client { Self::internal_send(&self.network_error, &mut self.register_stream, msg); } - pub fn send_msg(&mut self, msg: ServerMsg) { + pub fn send_msg(&mut self, msg: ServerGeneralMsg) { Self::internal_send(&self.network_error, &mut self.singleton_stream, msg); } @@ -95,7 +95,7 @@ impl Client { } } - pub async fn recv_msg(&mut self) -> Result { + pub async fn recv_msg(&mut self) -> Result { Self::internal_recv(&self.network_error, &mut self.singleton_stream).await } diff --git a/server/src/cmd.rs b/server/src/cmd.rs index ccd9ca219f..7ebded8f51 100644 --- a/server/src/cmd.rs +++ b/server/src/cmd.rs @@ -12,7 +12,7 @@ use common::{ cmd::{ChatCommand, CHAT_COMMANDS, CHAT_SHORTCUTS}, comp::{self, ChatType, Item, LightEmitter, WaypointArea}, event::{EventBus, ServerEvent}, - msg::{DisconnectReason, Notification, PlayerListUpdate, ServerInGameMsg, ServerMsg}, + msg::{DisconnectReason, Notification, PlayerListUpdate, ServerInGameMsg, ServerGeneralMsg}, npc::{self, get_npc_name}, state::TimeOfDay, sync::{Uid, WorldSyncExt}, @@ -505,7 +505,7 @@ fn handle_alias( old_alias_optional, ) { let msg = - ServerMsg::PlayerListUpdate(PlayerListUpdate::Alias(*uid, player.alias.clone())); + ServerGeneralMsg::PlayerListUpdate(PlayerListUpdate::Alias(*uid, player.alias.clone())); server.state.notify_registered_clients(msg); // Announce alias change if target has a Body. @@ -1157,7 +1157,7 @@ fn handle_waypoint( .write_storage::() .insert(target, comp::Waypoint::new(pos.0, *time)); server.notify_client(client, ChatType::CommandInfo.server_msg("Waypoint saved!")); - server.notify_client(client, ServerMsg::Notification(Notification::WaypointSaved)); + server.notify_client(client, ServerGeneralMsg::Notification(Notification::WaypointSaved)); }, None => server.notify_client( client, @@ -1193,7 +1193,7 @@ fn handle_adminify( ecs.write_storage().insert(player, comp::Admin).is_ok() }; // Update player list so the player shows up as admin in client chat. - let msg = ServerMsg::PlayerListUpdate(PlayerListUpdate::Admin( + let msg = ServerGeneralMsg::PlayerListUpdate(PlayerListUpdate::Admin( *ecs.read_storage::() .get(player) .expect("Player should have uid"), @@ -1586,7 +1586,7 @@ fn find_target( ecs: &specs::World, opt_alias: Option, fallback: EcsEntity, -) -> Result { +) -> Result { if let Some(alias) = opt_alias { (&ecs.entities(), &ecs.read_storage::()) .join() @@ -1658,7 +1658,7 @@ fn handle_set_level( .expect("Failed to get uid for player"); server .state - .notify_registered_clients(ServerMsg::PlayerListUpdate( + .notify_registered_clients(ServerGeneralMsg::PlayerListUpdate( PlayerListUpdate::LevelChange(uid, lvl), )); @@ -1898,7 +1898,7 @@ fn kick_player(server: &mut Server, target_player: EcsEntity, reason: &str) { .emit_now(ServerEvent::ClientDisconnect(target_player)); server.notify_client( target_player, - ServerMsg::Disconnect(DisconnectReason::Kicked(reason.to_string())), + ServerGeneralMsg::Disconnect(DisconnectReason::Kicked(reason.to_string())), ); } diff --git a/server/src/events/entity_manipulation.rs b/server/src/events/entity_manipulation.rs index edb13243eb..6b890a7515 100644 --- a/server/src/events/entity_manipulation.rs +++ b/server/src/events/entity_manipulation.rs @@ -12,7 +12,7 @@ use common::{ Player, Pos, Stats, }, lottery::Lottery, - msg::{PlayerListUpdate, ServerInGameMsg, ServerMsg}, + msg::{PlayerListUpdate, ServerInGameMsg, ServerGeneralMsg}, outcome::Outcome, state::BlockChange, sync::{Uid, UidAllocator, WorldSyncExt}, @@ -656,7 +656,7 @@ pub fn handle_level_up(server: &mut Server, entity: EcsEntity, new_level: u32) { server .state - .notify_registered_clients(ServerMsg::PlayerListUpdate(PlayerListUpdate::LevelChange( + .notify_registered_clients(ServerGeneralMsg::PlayerListUpdate(PlayerListUpdate::LevelChange( *uid, new_level, ))); } diff --git a/server/src/events/interaction.rs b/server/src/events/interaction.rs index e34ea80d52..2496c0f7fa 100644 --- a/server/src/events/interaction.rs +++ b/server/src/events/interaction.rs @@ -4,7 +4,7 @@ use crate::{ }; use common::{ comp::{self, item}, - msg::ServerMsg, + msg::ServerGeneralMsg, sync::{Uid, WorldSyncExt}, }; use specs::{world::WorldExt, Entity as EcsEntity}; @@ -116,7 +116,7 @@ pub fn handle_possess(server: &Server, possessor_uid: Uid, possesse_uid: Uid) { let mut clients = ecs.write_storage::(); if clients.get_mut(possesse).is_none() { if let Some(mut client) = clients.remove(possessor) { - client.send_msg(ServerMsg::SetPlayerEntity(possesse_uid)); + client.send_msg(ServerGeneralMsg::SetPlayerEntity(possesse_uid)); clients .insert(possesse, client) .err() diff --git a/server/src/events/player.rs b/server/src/events/player.rs index 910e932131..2a73174b50 100644 --- a/server/src/events/player.rs +++ b/server/src/events/player.rs @@ -5,7 +5,7 @@ use crate::{ use common::{ comp, comp::{group, Player}, - msg::{PlayerListUpdate, ServerInGameMsg, ServerMsg}, + msg::{PlayerListUpdate, ServerInGameMsg, ServerGeneralMsg}, span, sync::{Uid, UidAllocator}, }; @@ -131,7 +131,7 @@ pub fn handle_client_disconnect(server: &mut Server, entity: EcsEntity) -> Event state.notify_registered_clients(comp::ChatType::Offline(*uid).server_msg("")); state - .notify_registered_clients(ServerMsg::PlayerListUpdate(PlayerListUpdate::Remove(*uid))); + .notify_registered_clients(ServerGeneralMsg::PlayerListUpdate(PlayerListUpdate::Remove(*uid))); } // Make sure to remove the player from the logged in list. (See LoginProvider) diff --git a/server/src/lib.rs b/server/src/lib.rs index c0b0e25526..3aa3524a58 100644 --- a/server/src/lib.rs +++ b/server/src/lib.rs @@ -46,7 +46,7 @@ use common::{ event::{EventBus, ServerEvent}, msg::{ server::WorldMapMsg, ClientType, DisconnectReason, ServerInGameMsg, ServerInfo, - ServerInitMsg, ServerMsg, ServerNotInGameMsg, + ServerInitMsg, ServerGeneralMsg, ServerNotInGameMsg, }, outcome::Outcome, recipe::default_recipe_book, @@ -885,7 +885,7 @@ impl Server { pub fn notify_client(&self, entity: EcsEntity, msg: S) where - S: Into, + S: Into, { if let Some(client) = self.state.ecs().write_storage::().get_mut(entity) { client.send_msg(msg.into()) @@ -910,7 +910,7 @@ impl Server { } } - pub fn notify_registered_clients(&mut self, msg: ServerMsg) { + pub fn notify_registered_clients(&mut self, msg: ServerGeneralMsg) { self.state.notify_registered_clients(msg); } @@ -990,7 +990,7 @@ impl Server { impl Drop for Server { fn drop(&mut self) { self.state - .notify_registered_clients(ServerMsg::Disconnect(DisconnectReason::Shutdown)); + .notify_registered_clients(ServerGeneralMsg::Disconnect(DisconnectReason::Shutdown)); } } diff --git a/server/src/state_ext.rs b/server/src/state_ext.rs index 14ef5bbf70..2554e71589 100644 --- a/server/src/state_ext.rs +++ b/server/src/state_ext.rs @@ -6,7 +6,7 @@ use common::{ comp, effect::Effect, msg::{ - CharacterInfo, ClientIngame, PlayerListUpdate, ServerInGameMsg, ServerMsg, + CharacterInfo, ClientIngame, PlayerListUpdate, ServerInGameMsg, ServerGeneralMsg, ServerNotInGameMsg, }, state::State, @@ -62,7 +62,7 @@ pub trait StateExt { fn update_character_data(&mut self, entity: EcsEntity, components: PersistedComponents); /// Iterates over registered clients and send each `ServerMsg` fn send_chat(&self, msg: comp::UnresolvedChatMsg); - fn notify_registered_clients(&self, msg: ServerMsg); + fn notify_registered_clients(&self, msg: ServerGeneralMsg); /// Delete an entity, recording the deletion in [`DeletedEntities`] fn delete_entity_recorded( &mut self, @@ -229,7 +229,7 @@ impl StateExt for State { if let Some(player_uid) = self.read_component_copied::(entity) { // Notify clients of a player list update - self.notify_registered_clients(ServerMsg::PlayerListUpdate( + self.notify_registered_clients(ServerGeneralMsg::PlayerListUpdate( PlayerListUpdate::SelectedCharacter(player_uid, CharacterInfo { name: String::from(&stats.name), level: stats.level.level(), @@ -276,7 +276,7 @@ impl StateExt for State { | comp::ChatType::Kill(_, _) | comp::ChatType::Meta | comp::ChatType::World(_) => { - self.notify_registered_clients(ServerMsg::ChatMsg(resolved_msg)) + self.notify_registered_clients(ServerGeneralMsg::ChatMsg(resolved_msg)) }, comp::ChatType::Tell(u, t) => { for (client, uid) in ( @@ -286,7 +286,7 @@ impl StateExt for State { .join() { if uid == u || uid == t { - client.send_msg(ServerMsg::ChatMsg(resolved_msg.clone())); + client.send_msg(ServerGeneralMsg::ChatMsg(resolved_msg.clone())); } } }, @@ -298,7 +298,7 @@ impl StateExt for State { if let Some(speaker_pos) = entity_opt.and_then(|e| positions.get(e)) { for (client, pos) in (&mut ecs.write_storage::(), &positions).join() { if is_within(comp::ChatMsg::SAY_DISTANCE, pos, speaker_pos) { - client.send_msg(ServerMsg::ChatMsg(resolved_msg.clone())); + client.send_msg(ServerGeneralMsg::ChatMsg(resolved_msg.clone())); } } } @@ -310,7 +310,7 @@ impl StateExt for State { if let Some(speaker_pos) = entity_opt.and_then(|e| positions.get(e)) { for (client, pos) in (&mut ecs.write_storage::(), &positions).join() { if is_within(comp::ChatMsg::REGION_DISTANCE, pos, speaker_pos) { - client.send_msg(ServerMsg::ChatMsg(resolved_msg.clone())); + client.send_msg(ServerGeneralMsg::ChatMsg(resolved_msg.clone())); } } } @@ -322,7 +322,7 @@ impl StateExt for State { if let Some(speaker_pos) = entity_opt.and_then(|e| positions.get(e)) { for (client, pos) in (&mut ecs.write_storage::(), &positions).join() { if is_within(comp::ChatMsg::NPC_DISTANCE, pos, speaker_pos) { - client.send_msg(ServerMsg::ChatMsg(resolved_msg.clone())); + client.send_msg(ServerGeneralMsg::ChatMsg(resolved_msg.clone())); } } } @@ -336,7 +336,7 @@ impl StateExt for State { .join() { if s == &faction.0 { - client.send_msg(ServerMsg::ChatMsg(resolved_msg.clone())); + client.send_msg(ServerGeneralMsg::ChatMsg(resolved_msg.clone())); } } }, @@ -348,7 +348,7 @@ impl StateExt for State { .join() { if g == group { - client.send_msg(ServerMsg::ChatMsg(resolved_msg.clone())); + client.send_msg(ServerGeneralMsg::ChatMsg(resolved_msg.clone())); } } }, @@ -356,7 +356,7 @@ impl StateExt for State { } /// Sends the message to all connected clients - fn notify_registered_clients(&self, msg: ServerMsg) { + fn notify_registered_clients(&self, msg: ServerGeneralMsg) { for client in (&mut self.ecs().write_storage::()) .join() .filter(|c| c.registered) diff --git a/server/src/sys/entity_sync.rs b/server/src/sys/entity_sync.rs index 3bd9b1d415..1faeca938d 100644 --- a/server/src/sys/entity_sync.rs +++ b/server/src/sys/entity_sync.rs @@ -8,7 +8,7 @@ use crate::{ }; use common::{ comp::{ForceUpdate, Inventory, InventoryUpdate, Last, Ori, Player, Pos, Vel}, - msg::{ServerInGameMsg, ServerMsg}, + msg::{ServerInGameMsg, ServerGeneralMsg}, outcome::Outcome, region::{Event as RegionEvent, RegionMap}, span, @@ -129,7 +129,7 @@ impl<'a> System<'a> for Sys { }) }) { let create_msg = - ServerMsg::CreateEntity(tracked_comps.create_entity_package( + ServerGeneralMsg::CreateEntity(tracked_comps.create_entity_package( entity, Some(*pos), vel.copied(), @@ -157,7 +157,7 @@ impl<'a> System<'a> for Sys { .map(|key| !regions.contains(key)) .unwrap_or(true) { - client.send_msg(ServerMsg::DeleteEntity(uid)); + client.send_msg(ServerGeneralMsg::DeleteEntity(uid)); } } } @@ -174,14 +174,14 @@ impl<'a> System<'a> for Sys { .take_deleted_in_region(key) .unwrap_or_default(), ); - let entity_sync_msg = ServerMsg::EntitySync(entity_sync_package); - let comp_sync_msg = ServerMsg::CompSync(comp_sync_package); + let entity_sync_msg = ServerGeneralMsg::EntitySync(entity_sync_package); + let comp_sync_msg = ServerGeneralMsg::CompSync(comp_sync_package); subscribers.iter_mut().for_each(move |(client, _, _, _)| { client.send_msg(entity_sync_msg.clone()); client.send_msg(comp_sync_msg.clone()); }); - let mut send_msg = |msg: ServerMsg, + let mut send_msg = |msg: ServerGeneralMsg, entity: EcsEntity, pos: Pos, force_update: Option<&ForceUpdate>, @@ -287,7 +287,7 @@ impl<'a> System<'a> for Sys { } send_msg( - ServerMsg::CompSync(comp_sync_package), + ServerGeneralMsg::CompSync(comp_sync_package), entity, pos, force_update, @@ -311,7 +311,7 @@ impl<'a> System<'a> for Sys { }) { for uid in &deleted { - client.send_msg(ServerMsg::DeleteEntity(Uid(*uid))); + client.send_msg(ServerGeneralMsg::DeleteEntity(Uid(*uid))); } } } @@ -353,7 +353,7 @@ impl<'a> System<'a> for Sys { // Sync resources // TODO: doesn't really belong in this system (rename system or create another // system?) - let tof_msg = ServerMsg::TimeOfDay(*time_of_day); + let tof_msg = ServerGeneralMsg::TimeOfDay(*time_of_day); for client in (&mut clients).join() { client.send_msg(tof_msg.clone()); } diff --git a/server/src/sys/message.rs b/server/src/sys/message.rs index 8cbbb947be..b44912695b 100644 --- a/server/src/sys/message.rs +++ b/server/src/sys/message.rs @@ -16,8 +16,8 @@ use common::{ event::{EventBus, ServerEvent}, msg::{ validate_chat_msg, CharacterInfo, ChatMsgValidationError, ClientInGameMsg, ClientIngame, - ClientMsg, ClientNotInGameMsg, ClientRegisterMsg, DisconnectReason, PingMsg, PlayerInfo, - PlayerListUpdate, RegisterError, ServerInGameMsg, ServerMsg, ServerNotInGameMsg, + ClientGeneralMsg, ClientNotInGameMsg, ClientRegisterMsg, DisconnectReason, PingMsg, PlayerInfo, + PlayerListUpdate, RegisterError, ServerInGameMsg, ServerGeneralMsg, ServerNotInGameMsg, ServerRegisterAnswerMsg, MAX_BYTES_CHAT_MSG, }, span, @@ -45,10 +45,10 @@ impl Sys { player_metrics: &ReadExpect<'_, PlayerMetrics>, uids: &ReadStorage<'_, Uid>, chat_modes: &ReadStorage<'_, ChatMode>, - msg: ClientMsg, + msg: ClientGeneralMsg, ) -> Result<(), crate::error::Error> { match msg { - ClientMsg::ChatMsg(message) => { + ClientGeneralMsg::ChatMsg(message) => { if client.registered { match validate_chat_msg(&message) { Ok(()) => { @@ -68,7 +68,7 @@ impl Sys { } } }, - ClientMsg::Command(message) => { + ClientGeneralMsg::Command(message) => { if client.registered { match validate_chat_msg(&message) { Ok(()) => { @@ -88,10 +88,10 @@ impl Sys { } } }, - ClientMsg::Disconnect => { - client.send_msg(ServerMsg::Disconnect(DisconnectReason::Requested)); + ClientGeneralMsg::Disconnect => { + client.send_msg(ServerGeneralMsg::Disconnect(DisconnectReason::Requested)); }, - ClientMsg::Terminate => { + ClientGeneralMsg::Terminate => { debug!(?entity, "Client send message to termitate session"); player_metrics .clients_disconnected @@ -435,7 +435,7 @@ impl Sys { .send(ServerRegisterAnswerMsg::Ok(()))?; // Send initial player list - client.send_msg(ServerMsg::PlayerListUpdate(PlayerListUpdate::Init( + client.send_msg(ServerGeneralMsg::PlayerListUpdate(PlayerListUpdate::Init( player_list.clone(), ))); @@ -734,7 +734,7 @@ impl<'a> System<'a> for Sys { // Tell all clients to add them to the player list. for entity in new_players { if let (Some(uid), Some(player)) = (uids.get(entity), players.get(entity)) { - let msg = ServerMsg::PlayerListUpdate(PlayerListUpdate::Add(*uid, PlayerInfo { + let msg = ServerGeneralMsg::PlayerListUpdate(PlayerListUpdate::Add(*uid, PlayerInfo { player_alias: player.alias.clone(), is_online: true, is_admin: admins.get(entity).is_some(), diff --git a/server/src/sys/subscription.rs b/server/src/sys/subscription.rs index 2ee739bada..ba5f3906df 100644 --- a/server/src/sys/subscription.rs +++ b/server/src/sys/subscription.rs @@ -5,7 +5,7 @@ use super::{ use crate::client::{self, Client, RegionSubscription}; use common::{ comp::{Ori, Player, Pos, Vel}, - msg::ServerMsg, + msg::ServerGeneralMsg, region::{region_in_vd, regions_in_vd, Event as RegionEvent, RegionMap}, span, sync::Uid, @@ -153,7 +153,7 @@ impl<'a> System<'a> for Sys { .map(|key| subscription.regions.contains(key)) .unwrap_or(false) { - client.send_msg(ServerMsg::DeleteEntity(uid)); + client.send_msg(ServerGeneralMsg::DeleteEntity(uid)); } } }, @@ -161,7 +161,7 @@ impl<'a> System<'a> for Sys { } // Tell client to delete entities in the region for (&uid, _) in (&uids, region.entities()).join() { - client.send_msg(ServerMsg::DeleteEntity(uid)); + client.send_msg(ServerGeneralMsg::DeleteEntity(uid)); } } // Send deleted entities since they won't be processed for this client in entity @@ -171,7 +171,7 @@ impl<'a> System<'a> for Sys { .iter() .flat_map(|v| v.iter()) { - client.send_msg(ServerMsg::DeleteEntity(Uid(*uid))); + client.send_msg(ServerGeneralMsg::DeleteEntity(Uid(*uid))); } } @@ -196,7 +196,7 @@ impl<'a> System<'a> for Sys { { // Send message to create entity and tracked components and physics // components - client.send_msg(ServerMsg::CreateEntity( + client.send_msg(ServerGeneralMsg::CreateEntity( tracked_comps.create_entity_package( entity, Some(*pos), @@ -249,7 +249,7 @@ pub fn initialize_region_subscription(world: &World, entity: specs::Entity) { .join() { // Send message to create entity and tracked components and physics components - client.send_msg(ServerMsg::CreateEntity( + client.send_msg(ServerGeneralMsg::CreateEntity( tracked_comps.create_entity_package( entity, Some(*pos), diff --git a/server/src/sys/waypoint.rs b/server/src/sys/waypoint.rs index a30911f4cc..ff86ab9bdf 100644 --- a/server/src/sys/waypoint.rs +++ b/server/src/sys/waypoint.rs @@ -2,7 +2,7 @@ use super::SysTimer; use crate::client::Client; use common::{ comp::{Player, Pos, Waypoint, WaypointArea}, - msg::{Notification, ServerMsg}, + msg::{Notification, ServerGeneralMsg}, span, state::Time, }; @@ -42,7 +42,7 @@ impl<'a> System<'a> for Sys { if let Ok(wp_old) = waypoints.insert(entity, Waypoint::new(player_pos.0, *time)) { if wp_old.map_or(true, |w| w.elapsed(*time) > NOTIFY_TIME) { - client.send_msg(ServerMsg::Notification(Notification::WaypointSaved)); + client.send_msg(ServerGeneralMsg::Notification(Notification::WaypointSaved)); } } }