From 1205820e8b4110095dba31197950bb16937ada95 Mon Sep 17 00:00:00 2001 From: Ben Wallis Date: Sun, 27 Sep 2020 20:25:00 +0100 Subject: [PATCH] Preserve admin component if present on return to character select screen --- server/src/events/player.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/server/src/events/player.rs b/server/src/events/player.rs index 111aae9c54..f92167bda8 100644 --- a/server/src/events/player.rs +++ b/server/src/events/player.rs @@ -24,6 +24,8 @@ pub fn handle_exit_ingame(server: &mut Server, entity: EcsEntity) { let maybe_client = state.ecs().write_storage::().remove(entity); let maybe_uid = state.read_component_copied::(entity); let maybe_player = state.ecs().write_storage::().remove(entity); + let maybe_admin = state.ecs().write_storage::().remove(entity); + let maybe_group = state .ecs() .write_storage::() @@ -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); + // Preserve group component if present let entity_builder = match maybe_group { Some(group) => entity_builder.with(group), 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 let uid = entity_builder .world