From e60881079f7a823cd434935c22b35e34dbdfa173 Mon Sep 17 00:00:00 2001 From: tommy Date: Wed, 17 Jul 2019 15:01:04 -0400 Subject: [PATCH] Add "You tell {}" message to sending player --- server/src/cmd.rs | 58 +++++++++++++++++++++++++++-------------------- 1 file changed, 34 insertions(+), 24 deletions(-) diff --git a/server/src/cmd.rs b/server/src/cmd.rs index d117d47d7f..c3b4951587 100644 --- a/server/src/cmd.rs +++ b/server/src/cmd.rs @@ -449,33 +449,43 @@ fn handle_msg(server: &mut Server, entity: EcsEntity, args: String, action: &Cha let msg = &args[alias.len()..args.len()]; match opt_player { Some(player) => { - if msg.len() > 1 { - let opt_name = ecs - .read_storage::() - .get(entity) - .map(|s| s.alias.clone()); - match opt_name { - Some(name) => { - server.clients.notify( - player, - ServerMsg::Chat(format!("{} tells you:{}", name, msg)), - ); - } - None => { - server.clients.notify( - entity, - ServerMsg::Chat(String::from("You do not exist!")), - ); + if player != entity { + if msg.len() > 1 { + let opt_name = ecs + .read_storage::() + .get(entity) + .map(|s| s.alias.clone()); + match opt_name { + Some(name) => { + server.clients.notify( + player, + ServerMsg::Chat(format!("{} tells you:{}", name, msg)), + ); + server.clients.notify( + player, + ServerMsg::Chat(format!("You tell {} {}", alias, msg)), + ); + } + None => { + server.clients.notify( + entity, + ServerMsg::Chat(String::from("You do not exist!")), + ); + } } + } else { + server.clients.notify( + entity, + ServerMsg::Chat(format!( + "You really should say something to {}!", + alias + )), + ); } } else { - server.clients.notify( - entity, - ServerMsg::Chat(format!( - "You really should say something to {}!", - alias - )), - ); + server + .clients + .notify(entity, ServerMsg::Chat(format!("Don't be crazy!"))); } } None => {