Merge branch 'timo-logout' into 'master'

Fix bugs causing duplicate login/logout messages

See merge request veloren/veloren!553
This commit is contained in:
Timo Koesters 2019-10-06 17:05:23 +00:00
commit 70718b9d02

View File

@ -980,6 +980,21 @@ impl Server {
ClientState::Registered
| ClientState::Spectator
| ClientState::Dead => {
if let (Some(player), None) = (
state.ecs().read_storage::<comp::Player>().get(entity),
// Only send login message if the player didn't have a body
// previously
state.ecs().read_storage::<comp::Body>().get(entity),
) {
new_chat_msgs.push((
None,
ServerMsg::broadcast(format!(
"[{}] is now online.",
&player.alias
)),
));
}
Self::create_player_character(
state,
entity,
@ -989,17 +1004,6 @@ impl Server {
main.map(|t| comp::Item::Tool { kind: t, power: 10 }),
&server_settings,
);
if let Some(player) =
state.ecs().read_storage::<comp::Player>().get(entity)
{
new_chat_msgs.push((
None,
ServerMsg::broadcast(format!(
"[{}] is now online.",
&player.alias
)),
));
}
}
ClientState::Character => {
client.error_state(RequestStateError::Already)
@ -1122,7 +1126,11 @@ impl Server {
}
if disconnect {
if let Some(player) = state.ecs().read_storage::<comp::Player>().get(entity) {
if let (Some(player), Some(_)) = (
state.ecs().read_storage::<comp::Player>().get(entity),
// It only shows a message if you had a body (not in char selection)
state.ecs().read_storage::<comp::Body>().get(entity),
) {
new_chat_msgs.push((
None,
ServerMsg::broadcast(format!("{} went offline.", &player.alias)),