mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Rename Disconnected to Visitor
Former-commit-id: aeb729a933cda380c03efe346347fc4dc0648dfb
This commit is contained in:
parent
fc2e6c3624
commit
07a2aab8a3
@ -57,7 +57,7 @@ impl Client {
|
|||||||
view_distance: u64,
|
view_distance: u64,
|
||||||
) -> Result<Self, Error> {
|
) -> Result<Self, Error> {
|
||||||
|
|
||||||
let mut client_state = ClientState::Disconnected;
|
let mut client_state = ClientState::Visitor;
|
||||||
let mut postbox = PostBox::to(addr)?;
|
let mut postbox = PostBox::to(addr)?;
|
||||||
|
|
||||||
// Send connection request
|
// Send connection request
|
||||||
|
@ -9,7 +9,7 @@ pub use self::ecs_packet::EcsPacket;
|
|||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)]
|
||||||
pub enum ClientState {
|
pub enum ClientState {
|
||||||
Disconnected,
|
Visitor,
|
||||||
Connected,
|
Connected,
|
||||||
Spectator,
|
Spectator,
|
||||||
Character,
|
Character,
|
||||||
|
@ -60,7 +60,7 @@ impl Clients {
|
|||||||
|
|
||||||
pub fn notify_connected(&mut self, msg: ServerMsg) {
|
pub fn notify_connected(&mut self, msg: ServerMsg) {
|
||||||
for client in self.clients.values_mut() {
|
for client in self.clients.values_mut() {
|
||||||
if client.client_state != ClientState::Disconnected {
|
if client.client_state != ClientState::Visitor {
|
||||||
client.notify(msg.clone());
|
client.notify(msg.clone());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -68,7 +68,7 @@ impl Clients {
|
|||||||
|
|
||||||
pub fn notify_connected_except(&mut self, except_entity: EcsEntity, msg: ServerMsg) {
|
pub fn notify_connected_except(&mut self, except_entity: EcsEntity, msg: ServerMsg) {
|
||||||
for (entity, client) in self.clients.iter_mut() {
|
for (entity, client) in self.clients.iter_mut() {
|
||||||
if client.client_state != ClientState::Disconnected && *entity != except_entity {
|
if client.client_state != ClientState::Visitor && *entity != except_entity {
|
||||||
client.notify(msg.clone());
|
client.notify(msg.clone());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -217,7 +217,7 @@ impl Server {
|
|||||||
self.clients.add(
|
self.clients.add(
|
||||||
entity,
|
entity,
|
||||||
Client {
|
Client {
|
||||||
client_state: ClientState::Disconnected,
|
client_state: ClientState::Visitor,
|
||||||
postbox,
|
postbox,
|
||||||
last_ping: self.state.get_time(),
|
last_ping: self.state.get_time(),
|
||||||
},
|
},
|
||||||
@ -250,15 +250,15 @@ impl Server {
|
|||||||
for msg in new_msgs {
|
for msg in new_msgs {
|
||||||
match msg {
|
match msg {
|
||||||
ClientMsg::RequestState(requested_state) => match requested_state {
|
ClientMsg::RequestState(requested_state) => match requested_state {
|
||||||
ClientState::Disconnected => disconnect = true,
|
ClientState::Visitor => disconnect = true,
|
||||||
ClientState::Connected => match client.client_state {
|
ClientState::Connected => match client.client_state {
|
||||||
ClientState::Disconnected => {}, // Use ClientMsg::Connect instead
|
ClientState::Visitor => {}, // Use ClientMsg::Connect instead
|
||||||
ClientState::Connected => client.error_state(RequestStateError::Already),
|
ClientState::Connected => client.error_state(RequestStateError::Already),
|
||||||
ClientState::Spectator => client.allow_state(ClientState::Connected),
|
ClientState::Spectator => client.allow_state(ClientState::Connected),
|
||||||
ClientState::Character => client.allow_state(ClientState::Connected),
|
ClientState::Character => client.allow_state(ClientState::Connected),
|
||||||
},
|
},
|
||||||
ClientState::Spectator => match requested_state {
|
ClientState::Spectator => match requested_state {
|
||||||
ClientState::Disconnected => {}, // Become Connected first
|
ClientState::Visitor => {}, // Become Connected first
|
||||||
ClientState::Connected => client.allow_state(ClientState::Spectator),
|
ClientState::Connected => client.allow_state(ClientState::Spectator),
|
||||||
ClientState::Spectator => client.error_state(RequestStateError::Already),
|
ClientState::Spectator => client.error_state(RequestStateError::Already),
|
||||||
ClientState::Character => client.allow_state(ClientState::Spectator),
|
ClientState::Character => client.allow_state(ClientState::Spectator),
|
||||||
@ -266,17 +266,17 @@ impl Server {
|
|||||||
ClientState::Character => {}, // Use ClientMsg::Character instead
|
ClientState::Character => {}, // Use ClientMsg::Character instead
|
||||||
},
|
},
|
||||||
ClientMsg::Connect { player } => match client.client_state {
|
ClientMsg::Connect { player } => match client.client_state {
|
||||||
ClientState::Disconnected => Self::initialize_client(state, entity, client, player),
|
ClientState::Visitor => Self::initialize_client(state, entity, client, player),
|
||||||
_ => {},
|
_ => {},
|
||||||
},
|
},
|
||||||
ClientMsg::Character(character) => match client.client_state {
|
ClientMsg::Character(character) => match client.client_state {
|
||||||
ClientState::Disconnected => {},
|
ClientState::Visitor => {},
|
||||||
ClientState::Connected | ClientState::Spectator =>
|
ClientState::Connected | ClientState::Spectator =>
|
||||||
Self::create_player_character(state, entity, client, character),
|
Self::create_player_character(state, entity, client, character),
|
||||||
ClientState::Character => client.error_state(RequestStateError::Already),
|
ClientState::Character => client.error_state(RequestStateError::Already),
|
||||||
},
|
},
|
||||||
ClientMsg::Chat(msg) => match client.client_state {
|
ClientMsg::Chat(msg) => match client.client_state {
|
||||||
ClientState::Disconnected => {},
|
ClientState::Visitor => {},
|
||||||
ClientState::Connected => new_chat_msgs.push((entity, msg)),
|
ClientState::Connected => new_chat_msgs.push((entity, msg)),
|
||||||
ClientState::Spectator => new_chat_msgs.push((entity, msg)),
|
ClientState::Spectator => new_chat_msgs.push((entity, msg)),
|
||||||
ClientState::Character => new_chat_msgs.push((entity, msg)),
|
ClientState::Character => new_chat_msgs.push((entity, msg)),
|
||||||
@ -296,7 +296,7 @@ impl Server {
|
|||||||
_ => disconnect = true,
|
_ => disconnect = true,
|
||||||
},
|
},
|
||||||
ClientMsg::TerrainChunkRequest { key } => match client.client_state {
|
ClientMsg::TerrainChunkRequest { key } => match client.client_state {
|
||||||
ClientState::Disconnected => {},
|
ClientState::Visitor => {},
|
||||||
ClientState::Connected => disconnect = true,
|
ClientState::Connected => disconnect = true,
|
||||||
ClientState::Spectator | ClientState::Character => {
|
ClientState::Spectator | ClientState::Character => {
|
||||||
match state.terrain().get_key(key) {
|
match state.terrain().get_key(key) {
|
||||||
@ -327,7 +327,7 @@ impl Server {
|
|||||||
if disconnect {
|
if disconnect {
|
||||||
disconnected_clients.push(entity);
|
disconnected_clients.push(entity);
|
||||||
client.postbox.send_message(ServerMsg::StateAnswer(
|
client.postbox.send_message(ServerMsg::StateAnswer(
|
||||||
Err((RequestStateError::Impossible, ClientState::Disconnected))));
|
Err((RequestStateError::Impossible, ClientState::Visitor))));
|
||||||
true
|
true
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
|
Loading…
Reference in New Issue
Block a user