Quantcast

Throttle archoaeology distance checks

James Whitehead II [03-06-11 - 20:46]
Throttle archoaeology distance checks
Filename
sources/ArchaeologyDigSites.lua
diff --git a/sources/ArchaeologyDigSites.lua b/sources/ArchaeologyDigSites.lua
index fb6a713..770c471 100644
--- a/sources/ArchaeologyDigSites.lua
+++ b/sources/ArchaeologyDigSites.lua
@@ -18,7 +18,6 @@ eventFrame:RegisterEvent("ARTIFACT_DIG_SITE_UPDATED")

 -- Creates waypoints for each of the dig sites that can be found
 -- on the current continent
-
 local waypoints = {}
 local function UpdateDigSites()
     if not addon.db.profile.archaeologyDigSitesSource then
@@ -71,9 +70,18 @@ eventFrame:SetScript("OnEvent", function(self, event, ...)
 end)

 local throttle = 2.0
+local counter = 0
 eventFrame:SetScript("OnUpdate", function(self, elapsed)
+    counter = counter + elapsed
+    if counter < throttle then
+        return
+    else
+        counter = counter - throttle
+    end
+
     local min = math.huge
     local closest
+
     for key, waypoint in pairs(waypoints) do
         local distance, angle = addon:GetVectorFromCurrent(unpack(waypoint))
         if distance and distance < min then