Commit 5fe95212 authored by Capucho's avatar Capucho

Fix the spam on disconnect

parent 9d805a74
......@@ -224,10 +224,7 @@ impl Client {
}
/// Send disconnect message to the server
pub fn request_logout(&mut self) {
self.postbox.send_message(ClientMsg::Disconnect);
self.client_state = ClientState::Disconnected;
}
pub fn request_logout(&mut self) { self.postbox.send_message(ClientMsg::Disconnect); }
/// Request a state transition to `ClientState::Registered` from an ingame
/// state.
......
......@@ -16,7 +16,6 @@ pub enum ClientState {
Registered,
Spectator,
Character,
Disconnected,
}
pub const MAX_BYTES_CHAT_MSG: usize = 256;
......
......@@ -91,7 +91,7 @@ impl<'a> System<'a> for Sys {
|| client.postbox.error().is_some()
// Postbox error
{
disconnect = true;
server_emitter.emit(ServerEvent::ClientDisconnect(entity));
} else if time - client.last_ping > CLIENT_TIMEOUT * 0.5 {
// Try pinging the client if the timeout is nearing.
client.postbox.send_message(ServerMsg::Ping);
......@@ -111,7 +111,6 @@ impl<'a> System<'a> for Sys {
server_emitter.emit(ServerEvent::ExitIngame { entity });
},
ClientState::Pending => {},
ClientState::Disconnected => unreachable!(),
},
// Request spectator state
ClientMsg::Spectate => match client.client_state {
......@@ -122,7 +121,6 @@ impl<'a> System<'a> for Sys {
client.allow_state(ClientState::Spectator)
},
ClientState::Pending => {},
ClientState::Disconnected => unreachable!(),
},
// Request registered state (login)
ClientMsg::Register {
......@@ -202,7 +200,6 @@ impl<'a> System<'a> for Sys {
},
ClientState::Character => client.error_state(RequestStateError::Already),
ClientState::Pending => {},
ClientState::Disconnected => unreachable!(),
},
ClientMsg::ControllerInputs(inputs) => match client.client_state {
ClientState::Connected
......@@ -216,7 +213,6 @@ impl<'a> System<'a> for Sys {
}
},
ClientState::Pending => {},
ClientState::Disconnected => unreachable!(),
},
ClientMsg::ControlEvent(event) => match client.client_state {
ClientState::Connected
......@@ -230,7 +226,6 @@ impl<'a> System<'a> for Sys {
}
},
ClientState::Pending => {},
ClientState::Disconnected => unreachable!(),
},
ClientMsg::ChatMsg { message } => match client.client_state {
ClientState::Connected => client.error_state(RequestStateError::Impossible),
......@@ -245,7 +240,6 @@ impl<'a> System<'a> for Sys {
),
},
ClientState::Pending => {},
ClientState::Disconnected => unreachable!(),
},
ClientMsg::PlayerPhysics { pos, vel, ori } => match client.client_state {
ClientState::Character => {
......@@ -286,7 +280,6 @@ impl<'a> System<'a> for Sys {
}
},
ClientState::Pending => {},
ClientState::Disconnected => unreachable!(),
},
// Always possible.
ClientMsg::Ping => client.postbox.send_message(ServerMsg::Pong),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment