changeset 156:749fdb864fdf

Queue current_area_id updates and prevent any coordinate collection while in combat.
author James D. Callahan III <jcallahan@curse.com>
date Fri, 05 Oct 2012 15:24:34 -0500
parents 0c4a6ea88403
children d16d4848f059
files Main.lua
diffstat 1 files changed, 25 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/Main.lua	Fri Oct 05 14:15:53 2012 -0500
+++ b/Main.lua	Fri Oct 05 15:24:34 2012 -0500
@@ -34,6 +34,7 @@
 -----------------------------------------------------------------------
 local DB_VERSION = 10
 local DEBUGGING = false
+local EVENT_DEBUG = false
 
 local DATABASE_DEFAULTS = {
     char = {},
@@ -72,6 +73,8 @@
     MERCHANT_UPDATE = "UpdateMerchantItems",
     PET_BAR_UPDATE = true,
     PET_JOURNAL_LIST_UPDATE = true,
+    PLAYER_REGEN_DISABLED = true,
+    PLAYER_REGEN_ENABLED = true,
     PLAYER_TARGET_CHANGED = true,
     QUEST_COMPLETE = true,
     QUEST_DETAIL = true,
@@ -254,8 +257,7 @@
 
 
 local function CurrentLocationData()
-    if _G.WorldMapFrame:IsVisible() then
-        Debug("Map is opened. Returning 0, 0 for x, y")
+    if _G.WorldMapFrame:IsVisible() or private.in_combat then
         return _G.GetRealZoneText(), current_area_id, 0, 0, 0, InstanceDifficultyToken()
     end
     WDP:SetCurrentAreaID()
@@ -609,6 +611,10 @@
     }
 
     function WDP:SetCurrentAreaID(event_name)
+        if private.in_combat then
+            private.set_area_id = true
+            return
+        end
         local map_area_id = _G.GetCurrentMapAreaID()
 
         if map_area_id == current_area_id then
@@ -677,14 +683,14 @@
     if _G.type(func) == "boolean" then
         self[event_name](self, ...)
     elseif _G.type(func) == "function" then
-        EVENT_MAPPING[event_name](self, ...)
+        self[EVENT_MAPPING[event_name]](self, ...)
     end
 end
 
 
 function WDP:OnEnable()
     for event_name, mapping in pairs(EVENT_MAPPING) do
-        if DEBUGGING then
+        if EVENT_DEBUG then
             self:RegisterEvent(event_name, "EventDispatcher")
         else
             self:RegisterEvent(event_name, (_G.type(mapping) ~= "boolean") and mapping or nil)
@@ -1592,6 +1598,21 @@
 end
 
 
+function WDP:PLAYER_REGEN_DISABLED(event_name)
+    private.in_combat = true
+end
+
+
+function WDP:PLAYER_REGEN_ENABLED(event_name)
+    private.in_combat = nil
+
+    if private.set_area_id then
+        self:SetCurrentAreaID(event_name)
+        private.set_area_id = nil
+    end
+end
+
+
 function WDP:PLAYER_TARGET_CHANGED(event_name)
     if not PlayerTarget() then
         return