diff Main.lua @ 126:f0c0819058b4 1.0.9

Bump DB version to 6. Change method of determining current area ID in order to play nice with the World Map.
author James D. Callahan III <jcallahan@curse.com>
date Tue, 18 Sep 2012 14:48:43 -0500
parents 8669b4c43278
children b06147ded0bc
line wrap: on
line diff
--- a/Main.lua	Mon Sep 17 16:02:08 2012 -0500
+++ b/Main.lua	Tue Sep 18 14:48:43 2012 -0500
@@ -31,7 +31,7 @@
 -----------------------------------------------------------------------
 -- Local constants.
 -----------------------------------------------------------------------
-local DB_VERSION = 5
+local DB_VERSION = 6
 
 
 local DATABASE_DEFAULTS = {
@@ -84,6 +84,7 @@
     UNIT_SPELLCAST_SENT = true,
     UNIT_SPELLCAST_SUCCEEDED = true,
     VOID_STORAGE_OPEN = true,
+    ZONE_CHANGED = true,
 }
 
 
@@ -124,6 +125,7 @@
 local reputation_npc_id
 local target_location_timer_handle
 local current_target_id
+local current_area_id
 
 -----------------------------------------------------------------------
 -- Data for our current action. Including possible values as a reference.
@@ -224,8 +226,6 @@
 
 
 local function CurrentLocationData()
-    _G.SetMapToCurrentZone()
-
     local map_level = _G.GetCurrentMapDungeonLevel() or 0
     local x, y = _G.GetPlayerMapPosition("player")
 
@@ -258,7 +258,7 @@
     if y % 2 ~= 0 then
         y = y + 1
     end
-    return _G.GetRealZoneText(), _G.GetCurrentMapAreaID(), x, y, map_level, InstanceDifficultyToken()
+    return _G.GetRealZoneText(), current_area_id, x, y, map_level, InstanceDifficultyToken()
 end
 
 
@@ -513,6 +513,15 @@
 end -- do-block
 
 
+local function SetCurrentAreaID()
+    local map_area_id = _G.GetCurrentMapAreaID()
+    _G.SetMapToCurrentZone()
+
+    current_area_id = _G.GetCurrentMapAreaID()
+    _G.SetMapByID(map_area_id)
+end
+
+
 -----------------------------------------------------------------------
 -- Methods.
 -----------------------------------------------------------------------
@@ -559,6 +568,8 @@
         local _, item_link = _G.GetItemInfo(identifier)
         HandleItemUse(item_link)
     end)
+
+    SetCurrentAreaID()
 end
 
 
@@ -1691,6 +1702,11 @@
 end
 
 
+function WDP:ZONE_CHANGED(event_name)
+    SetCurrentAreaID()
+end
+
+
 do
     local function SetUnitField(field, required_type)
         local unit_type, unit_idnum = ParseGUID(_G.UnitGUID("npc"))