1.0.3 bugfix when tour gets changed / HarvestMap text

generic [05-09-22 - 18:30]
1.0.3 bugfix when tour gets changed / HarvestMap text
Filename
HarvestRoute.lua
Localization/default.lua
diff --git a/HarvestRoute.lua b/HarvestRoute.lua
index ce562d0..904f714 100644
--- a/HarvestRoute.lua
+++ b/HarvestRoute.lua
@@ -21,6 +21,7 @@ local HarvestRouteButton = nil
 local isActive = false
 local currentZoneId = nil
 local lastNodeId = nil
+local lastPathIndex = nil
 local pathNodeId = nil
 local pathNodes = {}

@@ -107,6 +108,7 @@ function HarvestRoute:OnPlayerLoaded()
       end
       lastNodeId = nil
       pathNodeId = nil
+      lastPathIndex = nill
       pathNodes = {}
       currentZoneId = newZoneId
       if isActive then
@@ -114,11 +116,29 @@ function HarvestRoute:OnPlayerLoaded()
       end
 end

--- hacky, but should do the trick: reset pathnodes when path has changed from outside
+-- reset pathnodes when path has changed from outside, and either last node or last path node are invalid
 function HarvestRoute:checkPath(event, path)
-  local index = Farm.path:GetIndex(pathNodeId)
-  if not index  then
+  local validpath = false
+  local validnode = false
+  if lastNodeId and MapCache then
+    -- does the nodeId still exist?
+    if MapCache.pinTypeId[lastNodeId] then
+      validnode = true
+      -- check if our path information still works
+      if pathNodeId and Farm.path then
+        local index = Farm.path:GetIndex(pathNodeId)
+        if index and (index == lastPathIndex) then
+          validpath = true
+        end
+      end
+    end
+  end
+  if not validnode then
+    lastNodeId = nil
+  end
+  if not validpath then
     pathNodeId = nil
+    lastPathIndex = nil
     pathNodes = {}
   end
 end
@@ -133,16 +153,17 @@ function HarvestRoute:OnUpdate (time)
           local index = Farm.path:GetIndex(nodeId)
           if index then
             pathNodeId = nodeId
+            lastPathIndex = index
           else
             if pathNodeId then
               Farm.path:InsertAfter(pathNodeId, nodeId)
               pathNodeId = nodeId
+              lastPathIndex = Farm.path:GetIndex(nodeId)
               Harvest.farm.display:Refresh(Farm.path, Harvest.farm.display.selectedPins, Harvest.farm.display.selectedMapCache)
               --Harvest.callbackManager:FireCallbacks(Harvest.events.TOUR_CHANGED, Farm.path)
               -- if we are farming, update the next pin so we can actually finish the loop if we want to
               if Farm.helper:IsRunning() then
-                index = Farm.path:GetIndex(pathNodeId)
-                Farm.helper.nextPathIndex = index
+                Farm.helper.nextPathIndex = lastPathIndex
                 Farm.helper:UpdateToNextTarget()
               end
             end
diff --git a/Localization/default.lua b/Localization/default.lua
index 68db4d8..af69038 100644
--- a/Localization/default.lua
+++ b/Localization/default.lua
@@ -28,9 +28,3 @@ function HarvestRoute.GetLocalization(tag)
 	return (current[ tag ] or default[ tag ]) or tag
 end

-local UIStrings = {"SI_BINDING_NAME_HARVEST_SHOW_FILTER", "SI_BINDING_NAME_SKIP_TARGET", "SI_BINDING_NAME_TOGGLE_WORLDPINS", "SI_BINDING_NAME_TOGGLE_MAPPINS", "SI_BINDING_NAME_TOGGLE_MINIMAPPINS", "SI_BINDING_NAME_HARVEST_SHOW_PANEL",
-		"HARVESTFARM_GENERATOR","HARVESTFARM_EDITOR","HARVESTFARM_SAVE"}
-for _, str in pairs(UIStrings) do
-	ZO_CreateStringId(str, HarvestRoute.GetLocalization(str))
-end
-