mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Fix client states server-side
Former-commit-id: 701dd2a7f53bd0f1943cbeb61cc9c251228a4b5f
This commit is contained in:
parent
616b922e36
commit
36e890bbd8
@ -47,6 +47,14 @@ impl Clients {
|
||||
self.clients.insert(entity, client);
|
||||
}
|
||||
|
||||
pub fn get<'a>(&'a self, entity: &EcsEntity) -> Option<&'a Client> {
|
||||
self.clients.get(entity)
|
||||
}
|
||||
|
||||
pub fn get_mut<'a>(&'a mut self, entity: &EcsEntity) -> Option<&'a mut Client> {
|
||||
self.clients.get_mut(entity)
|
||||
}
|
||||
|
||||
pub fn remove_if<F: FnMut(EcsEntity, &mut Client) -> bool>(&mut self, mut f: F) {
|
||||
self.clients.retain(|entity, client| !f(*entity, client));
|
||||
}
|
||||
|
@ -162,8 +162,7 @@ impl Server {
|
||||
state.write_component(entity, comp::Actions::new());
|
||||
|
||||
// Tell the client its request was successful.
|
||||
client.notify(ServerMsg::StateAnswer(Ok(ClientState::Character)));
|
||||
client.client_state = ClientState::Character;
|
||||
client.allow_state(ClientState::Character);
|
||||
}
|
||||
|
||||
/// Execute a single server tick, handle input and update the game state by the given duration.
|
||||
@ -584,16 +583,41 @@ impl Server {
|
||||
.collect::<Vec<EcsEntity>>();
|
||||
|
||||
for entity in todo_kill {
|
||||
self.state.ecs_mut().write_storage::<comp::Dying>().remove(entity);
|
||||
self.state.ecs_mut().write_storage::<comp::Actor>().remove(entity);
|
||||
self.state.ecs_mut().write_storage::<comp::Stats>().remove(entity);
|
||||
self.state.ecs_mut().write_storage::<comp::phys::Pos>().remove(entity);
|
||||
self.state.ecs_mut().write_storage::<comp::phys::Vel>().remove(entity);
|
||||
self.state.ecs_mut().write_storage::<comp::phys::Dir>().remove(entity);
|
||||
self.state.ecs_mut().write_storage::<comp::AnimationInfo>().remove(entity);
|
||||
self.state.ecs_mut().write_storage::<comp::Actions>().remove(entity);
|
||||
self.clients
|
||||
.notify(entity, ServerMsg::ForceState(ClientState::Registered));
|
||||
self.state
|
||||
.ecs_mut()
|
||||
.write_storage::<comp::Dying>()
|
||||
.remove(entity);
|
||||
self.state
|
||||
.ecs_mut()
|
||||
.write_storage::<comp::Actor>()
|
||||
.remove(entity);
|
||||
self.state
|
||||
.ecs_mut()
|
||||
.write_storage::<comp::Stats>()
|
||||
.remove(entity);
|
||||
self.state
|
||||
.ecs_mut()
|
||||
.write_storage::<comp::phys::Pos>()
|
||||
.remove(entity);
|
||||
self.state
|
||||
.ecs_mut()
|
||||
.write_storage::<comp::phys::Vel>()
|
||||
.remove(entity);
|
||||
self.state
|
||||
.ecs_mut()
|
||||
.write_storage::<comp::phys::Dir>()
|
||||
.remove(entity);
|
||||
self.state
|
||||
.ecs_mut()
|
||||
.write_storage::<comp::AnimationInfo>()
|
||||
.remove(entity);
|
||||
self.state
|
||||
.ecs_mut()
|
||||
.write_storage::<comp::Actions>()
|
||||
.remove(entity);
|
||||
if let Some(client) = self.clients.get_mut(&entity) {
|
||||
client.force_state(ClientState::Registered);
|
||||
}
|
||||
}
|
||||
|
||||
// Remove all force flags.
|
||||
|
Loading…
Reference in New Issue
Block a user