mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Closes #450: Send update chat message to all clients on successful alias change.
This commit is contained in:
parent
49d4141f0e
commit
cba403df36
@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
### Added
|
||||
|
||||
- Added context-sensitive crosshair
|
||||
- Announce alias changes to all clients.
|
||||
|
||||
### Changed
|
||||
|
||||
|
@ -339,24 +339,31 @@ fn handle_alias(
|
||||
action: &ChatCommand,
|
||||
) {
|
||||
if let Ok(alias) = scan_fmt!(&args, &action.arg_fmt(), String) {
|
||||
server
|
||||
let old_alias_optional = server
|
||||
.state
|
||||
.ecs_mut()
|
||||
.write_storage::<comp::Player>()
|
||||
.get_mut(target)
|
||||
.map(|player| player.alias = alias);
|
||||
.map(|player| std::mem::replace(&mut player.alias, alias));
|
||||
|
||||
// Update name on client player lists
|
||||
let ecs = server.state.ecs();
|
||||
if let (Some(uid), Some(player)) = (
|
||||
if let (Some(uid), Some(player), Some(old_alias)) = (
|
||||
ecs.read_storage::<Uid>().get(target),
|
||||
ecs.read_storage::<comp::Player>().get(target),
|
||||
old_alias_optional,
|
||||
) {
|
||||
let msg = ServerMsg::PlayerListUpdate(PlayerListUpdate::Alias(
|
||||
(*uid).into(),
|
||||
player.alias.clone(),
|
||||
));
|
||||
server.state.notify_registered_clients(msg);
|
||||
server
|
||||
.state
|
||||
.notify_registered_clients(ServerMsg::broadcast(format!(
|
||||
"{} is now known as {}.",
|
||||
old_alias, player.alias
|
||||
)));
|
||||
}
|
||||
} else {
|
||||
server.notify_client(
|
||||
|
Loading…
Reference in New Issue
Block a user