Merge branch 'xvar/fix-admin-loss-on-character-switch' into 'master'

Preserve admin component if present on return to character select screen

Closes #780

See merge request veloren/veloren!1413
This commit is contained in:
Imbris 2020-09-27 20:34:05 +00:00
commit a4a75782ab

View File

@ -24,6 +24,8 @@ pub fn handle_exit_ingame(server: &mut Server, entity: EcsEntity) {
let maybe_client = state.ecs().write_storage::<Client>().remove(entity); let maybe_client = state.ecs().write_storage::<Client>().remove(entity);
let maybe_uid = state.read_component_copied::<Uid>(entity); let maybe_uid = state.read_component_copied::<Uid>(entity);
let maybe_player = state.ecs().write_storage::<comp::Player>().remove(entity); let maybe_player = state.ecs().write_storage::<comp::Player>().remove(entity);
let maybe_admin = state.ecs().write_storage::<comp::Admin>().remove(entity);
let maybe_group = state let maybe_group = state
.ecs() .ecs()
.write_storage::<group::Group>() .write_storage::<group::Group>()
@ -37,11 +39,18 @@ pub fn handle_exit_ingame(server: &mut Server, entity: EcsEntity) {
let entity_builder = state.ecs_mut().create_entity().with(client).with(player); let entity_builder = state.ecs_mut().create_entity().with(client).with(player);
// Preserve group component if present
let entity_builder = match maybe_group { let entity_builder = match maybe_group {
Some(group) => entity_builder.with(group), Some(group) => entity_builder.with(group),
None => entity_builder, None => entity_builder,
}; };
// Preserve admin component if present
let entity_builder = match maybe_admin {
Some(admin) => entity_builder.with(admin),
None => entity_builder,
};
// Ensure UidAllocator maps this uid to the new entity // Ensure UidAllocator maps this uid to the new entity
let uid = entity_builder let uid = entity_builder
.world .world