mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
More wrong messages will be punished with disconnect
Former-commit-id: 767f3226c62d7560d26a909eed8a69b8afe11110
This commit is contained in:
parent
07a2aab8a3
commit
ba6ead4077
@ -258,46 +258,43 @@ impl Server {
|
||||
ClientState::Character => client.allow_state(ClientState::Connected),
|
||||
},
|
||||
ClientState::Spectator => match requested_state {
|
||||
ClientState::Visitor => {}, // Become Connected first
|
||||
ClientState::Visitor => disconnect = true, // Become Connected first
|
||||
ClientState::Connected => client.allow_state(ClientState::Spectator),
|
||||
ClientState::Spectator => client.error_state(RequestStateError::Already),
|
||||
ClientState::Character => client.allow_state(ClientState::Spectator),
|
||||
},
|
||||
ClientState::Character => {}, // Use ClientMsg::Character instead
|
||||
ClientState::Character => disconnect = true, // Use ClientMsg::Character instead
|
||||
},
|
||||
ClientMsg::Connect { player } => match client.client_state {
|
||||
ClientState::Visitor => Self::initialize_client(state, entity, client, player),
|
||||
_ => {},
|
||||
_ => disconnect = true,
|
||||
},
|
||||
ClientMsg::Character(character) => match client.client_state {
|
||||
ClientState::Visitor => {},
|
||||
ClientState::Visitor => disconnect = true, // Become Connected first
|
||||
ClientState::Connected | ClientState::Spectator =>
|
||||
Self::create_player_character(state, entity, client, character),
|
||||
ClientState::Character => client.error_state(RequestStateError::Already),
|
||||
},
|
||||
ClientMsg::Chat(msg) => match client.client_state {
|
||||
ClientState::Visitor => {},
|
||||
ClientState::Visitor => disconnect = true,
|
||||
ClientState::Connected => new_chat_msgs.push((entity, msg)),
|
||||
ClientState::Spectator => new_chat_msgs.push((entity, msg)),
|
||||
ClientState::Character => new_chat_msgs.push((entity, msg)),
|
||||
},
|
||||
ClientMsg::PlayerAnimation(animation_history) => match client.client_state {
|
||||
// Only characters can send animations
|
||||
ClientState::Character => state.write_component(entity, animation_history),
|
||||
_ => disconnect = true,
|
||||
_ => disconnect = true, // Only characters can send animations
|
||||
},
|
||||
ClientMsg::PlayerPhysics { pos, vel, dir } => match client.client_state {
|
||||
// Only characters send their position
|
||||
ClientState::Character => {
|
||||
state.write_component(entity, pos);
|
||||
state.write_component(entity, vel);
|
||||
state.write_component(entity, dir);
|
||||
},
|
||||
_ => disconnect = true,
|
||||
_ => disconnect = true, // Only characters send their position
|
||||
},
|
||||
ClientMsg::TerrainChunkRequest { key } => match client.client_state {
|
||||
ClientState::Visitor => {},
|
||||
ClientState::Connected => disconnect = true,
|
||||
ClientState::Visitor | ClientState::Connected => disconnect = true, // Not allowed
|
||||
ClientState::Spectator | ClientState::Character => {
|
||||
match state.terrain().get_key(key) {
|
||||
Some(chunk) => {} /*client.postbox.send_message(ServerMsg::TerrainChunkUpdate {
|
||||
|
@ -72,8 +72,8 @@ impl PlayState for CharSelectionState {
|
||||
},
|
||||
ui::Event::Play => {
|
||||
self.client.borrow_mut().postbox.send_message(ClientMsg::Character(self.char_selection_ui.character));
|
||||
Box::new(SessionState::new(&mut global_state.window, self.client.clone()))
|
||||
},
|
||||
return PlayStateResult::Switch( Box::new(SessionState::new(&mut global_state.window, self.client.clone())));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user