Fixed issue caused by Uid component being removed too soon on logout

This commit is contained in:
Ben Wallis 2021-08-08 14:59:11 +01:00
parent 9bfd396c36
commit 7039bf7a0c

View File

@ -18,6 +18,10 @@ pub fn handle_exit_ingame(server: &mut Server, entity: EcsEntity) {
span!(_guard, "handle_exit_ingame");
let state = server.state_mut();
// Sync the player's character data to the database. This must be done before
// removing any components from the entity
let entity = persist_entity(state, entity);
// Create new entity with just `Client`, `Uid`, `Player`, and `...Stream`
// components Easier than checking and removing all other known components
// Note: If other `ServerEvent`s are referring to this entity they will be
@ -83,9 +87,6 @@ pub fn handle_exit_ingame(server: &mut Server, entity: EcsEntity) {
// Erase group component to avoid group restructure when deleting the entity
state.ecs().write_storage::<group::Group>().remove(entity);
// Sync the player's character data to the database
let entity = persist_entity(state, entity);
// Delete old entity
if let Err(e) = state.delete_entity_recorded(entity) {
error!(