From 946cee01fc04da87a6c54bb0e804626fcfaaa487 Mon Sep 17 00:00:00 2001 From: KimLS Date: Mon, 18 Jan 2016 20:14:57 -0800 Subject: [PATCH] Minor tweak to autoporting code --- common/pathfind.cpp | 4 ---- zone/pathing.cpp | 15 ++++++++++++--- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/common/pathfind.cpp b/common/pathfind.cpp index f886577e9..2ce88935d 100644 --- a/common/pathfind.cpp +++ b/common/pathfind.cpp @@ -309,10 +309,6 @@ PathfindingRoute::~PathfindingRoute() bool PathfindingRoute::DestinationValid(const glm::vec3 &dest) { - if (m_current_node >= 255) { - return false; - } - auto dist = vec_dist(dest, m_dest); if (dist <= max_dest_drift) { return true; diff --git a/zone/pathing.cpp b/zone/pathing.cpp index c46ece58a..20d75b177 100644 --- a/zone/pathing.cpp +++ b/zone/pathing.cpp @@ -39,11 +39,10 @@ glm::vec3 Mob::UpdatePath(float ToX, float ToY, float ToZ, float Speed, bool &Wa m_pathing_route = zone->pathing.FindRoute(from, to); auto &nodes = m_pathing_route.GetNodesEdit(); + auto &last_node = nodes[nodes.size() - 1]; //Code to complete partial paths. - //256 is the max number of nodes, if we get that back then we likely got a partial path that - //*may* have more after so instead let it run the path till it gets there and then DestinationValid will return false again + //If the path is too long then just warp to end. if (nodes.size() < 256) { - auto &last_node = nodes[nodes.size() - 1]; auto dist = DistanceSquared(glm::vec4(last_node.position, 1.0f), glm::vec4(ToX, ToY, ToZ, 0.0f)); if (dist > 10000.0f) { auto flag_temp = last_node.flag; @@ -65,6 +64,16 @@ glm::vec3 Mob::UpdatePath(float ToX, float ToY, float ToZ, float Speed, bool &Wa nodes.push_back(end); } } + else { + auto flag_temp = last_node.flag; + last_node.flag = NavigationPolyFlagPortal; + PathfindingNode end; + end.position.x = ToX; + end.position.y = ToY; + end.position.z = ToZ; + end.flag = flag_temp; + nodes.push_back(end); + } } m_pathing_route.CalcCurrentNode(from, WaypointChanged);