From 9286de13681abbc12b4d00ff41270297d0d9d72b Mon Sep 17 00:00:00 2001 From: Joshua Barretto Date: Wed, 17 Apr 2019 14:00:24 +0100 Subject: [PATCH] Added ForceUpdate component upon teleport-related commands Former-commit-id: ff10c863466e6f4f6cc931b5980917145f38b222 --- server/src/cmd.rs | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/server/src/cmd.rs b/server/src/cmd.rs index 529b09f0a8..7834e1f85c 100644 --- a/server/src/cmd.rs +++ b/server/src/cmd.rs @@ -55,32 +55,28 @@ lazy_static! { ChatCommand::new( "jump", "{d} {d} {d}", - "jump: offset your current position by a vector\n - Usage: /jump [x] [y] [z]", + "/jump : Offset your current position", handle_jump ), ChatCommand::new( "goto", "{d} {d} {d}", - "goto: teleport to a given position\n - Usage: /goto [x] [y] [z]", + "/goto : Teleport to a position", handle_goto ), ChatCommand::new( "alias", "{}", - "alias: change your player name (cannot contain spaces)\n - Usage: /alias [name]", + "/alias : Change your alias", handle_alias ), ChatCommand::new( "tp", "{}", - "tp: teleport to a named player\n - Usage: /tp [name]", + "/tp : Teleport to another player", handle_tp ), - ChatCommand::new("help", "", "help: display this message", handle_help) + ChatCommand::new("help", "", "/help: Display this message", handle_help) ]; } @@ -92,9 +88,10 @@ fn handle_jump(server: &mut Server, entity: EcsEntity, args: String, action: &Ch .state .read_component_cloned::(entity) { - Some(current_pos) => server - .state - .write_component(entity, comp::phys::Pos(current_pos.0 + Vec3::new(x, y, z))), + Some(current_pos) => { + server.state.write_component(entity, comp::phys::Pos(current_pos.0 + Vec3::new(x, y, z))); + server.state.write_component(entity, comp::phys::ForceUpdate); + }, None => server.clients.notify( entity, ServerMsg::Chat(String::from("Command 'jump' invalid in current state")), @@ -110,9 +107,10 @@ fn handle_jump(server: &mut Server, entity: EcsEntity, args: String, action: &Ch fn handle_goto(server: &mut Server, entity: EcsEntity, args: String, action: &ChatCommand) { let (opt_x, opt_y, opt_z) = scan_fmt!(&args, action.arg_fmt, f32, f32, f32); match (opt_x, opt_y, opt_z) { - (Some(x), Some(y), Some(z)) => server - .state - .write_component(entity, comp::phys::Pos(Vec3::new(x, y, z))), + (Some(x), Some(y), Some(z)) => { + server.state.write_component(entity, comp::phys::Pos(Vec3::new(x, y, z))); + server.state.write_component(entity, comp::phys::ForceUpdate); + }, _ => server .clients .notify(entity, ServerMsg::Chat(String::from(action.help_string))), @@ -145,13 +143,15 @@ fn handle_tp(server: &mut Server, entity: EcsEntity, args: String, action: &Chat .state .read_component_cloned::(player) { - Some(pos) => server.state.write_component(entity, pos), + Some(pos) => { + server.state.write_component(entity, pos); + server.state.write_component(entity, comp::phys::ForceUpdate); + }, None => server.clients.notify( entity, ServerMsg::Chat(format!("Unable to teleport to player '{}'", alias)), ), }, - None => { server.clients.notify( entity, @@ -175,4 +175,4 @@ fn handle_help(server: &mut Server, entity: EcsEntity, _args: String, _action: & .clients .notify(entity, ServerMsg::Chat(String::from(cmd.help_string))); } -} \ No newline at end of file +}