From 45916d179433e5d00544667c6588d4bb23068340 Mon Sep 17 00:00:00 2001 From: Dmitry Kashitsyn Date: Tue, 2 Apr 2024 16:49:19 +0500 Subject: [PATCH 1/2] Fix accidental jump cancellation during dispatch of `NpcActivity::Goto` `AgentData::jump_if` cancels `InputKind::Jump` if condition is not met. Even if the jump itself was issued elsewhere. This prevented merchants and travelers from reaching target site if somewhere along the path jump is required. This is exactly what happens during dispatch of `NpcActivity::Goto`. Original implementation contained `traverse` followed by `jump_if` for flying NPCs which cancelled pending `InputKind::Jump` issued by `traverse`. This fix extends jump condition inside traverse by including `traversal_config.can_fly`. --- server/agent/src/action_nodes.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/server/agent/src/action_nodes.rs b/server/agent/src/action_nodes.rs index 8f1fc8d17d..42a940e530 100644 --- a/server/agent/src/action_nodes.rs +++ b/server/agent/src/action_nodes.rs @@ -165,7 +165,7 @@ impl<'a> AgentData<'a> { let climbing_out_of_water = self.physics_state.in_liquid().map_or(false, |h| h < 1.0) && bearing.z > 0.0 && self.physics_state.on_wall.is_some(); - self.jump_if(bearing.z > 1.5 || climbing_out_of_water, controller); + self.jump_if(bearing.z > 1.5 || climbing_out_of_water || self.traversal_config.can_fly, controller); controller.inputs.move_z = bearing.z; if bearing.z > 0.0 { controller.inputs.climb = Some(comp::Climb::Up); @@ -285,7 +285,6 @@ impl<'a> AgentData<'a> { }, ) { self.traverse(controller, bearing, speed.min(speed_factor)); - self.jump_if(self.traversal_config.can_fly, controller); let height_offset = bearing.z + if self.traversal_config.can_fly { From 4664f1455ffbeab1ac321af0c98349804cc1e54a Mon Sep 17 00:00:00 2001 From: Dmitry Kashitsyn Date: Tue, 2 Apr 2024 23:32:39 +0500 Subject: [PATCH 2/2] Reformat the source --- server/agent/src/action_nodes.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/server/agent/src/action_nodes.rs b/server/agent/src/action_nodes.rs index 42a940e530..6e3945e3c5 100644 --- a/server/agent/src/action_nodes.rs +++ b/server/agent/src/action_nodes.rs @@ -165,7 +165,10 @@ impl<'a> AgentData<'a> { let climbing_out_of_water = self.physics_state.in_liquid().map_or(false, |h| h < 1.0) && bearing.z > 0.0 && self.physics_state.on_wall.is_some(); - self.jump_if(bearing.z > 1.5 || climbing_out_of_water || self.traversal_config.can_fly, controller); + self.jump_if( + bearing.z > 1.5 || climbing_out_of_water || self.traversal_config.can_fly, + controller, + ); controller.inputs.move_z = bearing.z; if bearing.z > 0.0 { controller.inputs.climb = Some(comp::Climb::Up);