diff --git a/client/src/lib.rs b/client/src/lib.rs index f6ba8a588d..0f0eb33f22 100644 --- a/client/src/lib.rs +++ b/client/src/lib.rs @@ -750,18 +750,35 @@ impl Client { uid, char_info, )) => { - warn!( - "ServerMsg::PlayerListUpdate PlayerListUpdate::LevelChange not \ - implemented: {} {:?}", - uid, char_info - ); + if let Some(player_info) = self.player_list.get_mut(&uid) { + player_info.character = Some(char_info); + } else { + warn!( + "Received msg to update character info for uid {}, but they were \ + not in the list.", + uid + ); + } }, ServerMsg::PlayerListUpdate(PlayerListUpdate::LevelChange(uid, next_level)) => { - warn!( - "ServerMsg::PlayerListUpdate PlayerListUpdate::LevelChange not \ - implemented: {} {}", - uid, next_level - ); + if let Some(player_info) = self.player_list.get_mut(&uid) { + if let Some(character) = &player_info.character { + // TODO: assign next value + // &character.level = next_level; + } else { + warn!( + "Received msg to update character level info to {} for uid \ + {}, but this player's character is None.", + next_level, uid + ); + } + } else { + warn!( + "Received msg to update character level info to {} for uid {}, \ + but they were not in the list.", + next_level, uid + ); + } }, ServerMsg::PlayerListUpdate(PlayerListUpdate::Remove(uid)) => { if self.player_list.remove(&uid).is_none() { diff --git a/server/src/state_ext.rs b/server/src/state_ext.rs index 5834792165..2783f24ef4 100644 --- a/server/src/state_ext.rs +++ b/server/src/state_ext.rs @@ -6,7 +6,9 @@ use common::{ assets, comp::{self, item}, effect::Effect, - msg::{ClientState, RegisterError, RequestStateError, ServerMsg}, + msg::{ + CharacterInfo, ClientState, PlayerListUpdate, RegisterError, RequestStateError, ServerMsg, + }, state::State, sync::{Uid, WorldSyncExt}, util::Dir, @@ -279,6 +281,24 @@ impl StateExt for State { self.write_component(entity, comp::Admin); } + let uids = &self.ecs().read_storage::(); + let uid = uids + .get(entity) + .expect("Failed to fetch uid component for entity.") + .0; + + let stats = &self.ecs().read_storage::(); + let stat = stats + .get(entity) + .expect("Failed to fetch stats component for entity."); + + self.notify_registered_clients(ServerMsg::PlayerListUpdate( + PlayerListUpdate::SelectedCharacter(uid, CharacterInfo { + name: stat.name.to_string(), + level: stat.level.level(), + }), + )); + // Tell the client its request was successful. if let Some(client) = self.ecs().write_storage::().get_mut(entity) { client.allow_state(ClientState::Character);