changeset 441:7e0ef2127b49

Replaced LibMapData-1.0 usage with standard WoW 5.X map functions. They even perform better (LibMapData-1.0 was returning 0,0 for new content).
author MMOSimca <MMOSimca@gmail.com>
date Sat, 28 Feb 2015 23:59:07 -0500
parents a4256abd13b7
children 2151f136ca5c
files .pkgmeta Main.lua libs.xml
diffstat 3 files changed, 109 insertions(+), 113 deletions(-) [+]
line wrap: on
line diff
--- a/.pkgmeta	Sat Feb 28 05:01:29 2015 -0500
+++ b/.pkgmeta	Sat Feb 28 23:59:07 2015 -0500
@@ -13,16 +13,12 @@
         url: svn://svn.wowace.com/wow/ace3/mainline/trunk/AceConsole-3.0
     Libs/AceEvent-3.0:
         url: svn://svn.wowace.com/wow/ace3/mainline/trunk/AceEvent-3.0
-    Libs/AceTimer-3.0:
-        url: svn://svn.wowace.com/wow/ace3/mainline/trunk/AceTimer-3.0
     Libs/AceDB-3.0:
         url: svn://svn.wowace.com/wow/ace3/mainline/trunk/AceDB-3.0
     Libs/LibDeformat-3.0:
         url: git://git.wowace.com/wow/libdeformat-3-0/mainline.git
     Libs/LibPetJournal-2.0:
         url: http://hg.curseforge.net/wow/libpetjournal-2-0/mainline
-    Libs/LibMapData-1.0:
-        url: svn://svn.wowace.com/wow/libmapdata-1-0/mainline/trunk
     Libs/LibDialog-1.0:
         url: http://hg.wowace.com/wow/libdialog-1-0/mainline
         tag: latest
--- a/Main.lua	Sat Feb 28 05:01:29 2015 -0500
+++ b/Main.lua	Sat Feb 28 23:59:07 2015 -0500
@@ -26,7 +26,6 @@
 
 local deformat = LibStub("LibDeformat-3.0")
 local LPJ = LibStub("LibPetJournal-2.0")
-local MapData = LibStub("LibMapData-1.0")
 
 local DatamineTT = _G.CreateFrame("GameTooltip", "WDPDatamineTT", _G.UIParent, "GameTooltipTemplate")
 DatamineTT:SetOwner(_G.WorldFrame, "ANCHOR_NONE")
@@ -363,49 +362,6 @@
 end
 
 
-local function DBEntry(data_type, unit_id)
-    if not data_type or not unit_id then
-        return
-    end
-    local category = global_db[data_type]
-
-    if not category then
-        category = {}
-        global_db[data_type] = category
-    end
-    local unit = category[unit_id]
-
-    if not unit then
-        unit = {}
-        category[unit_id] = unit
-    end
-    return unit
-end
-
-private.DBEntry = DBEntry
-
-local NPCEntry
-do
-    local npc_prototype = {}
-    local npc_meta = {
-        __index = npc_prototype
-    }
-
-    function NPCEntry(identifier)
-        local npc = DBEntry("npcs", identifier)
-        return npc and _G.setmetatable(npc, npc_meta) or nil
-    end
-
-    function npc_prototype:EncounterData(difficulty_token)
-        self.encounter_data = self.encounter_data or {}
-        self.encounter_data[difficulty_token] = self.encounter_data[difficulty_token] or {}
-        self.encounter_data[difficulty_token].stats = self.encounter_data[difficulty_token].stats or {}
-
-        return self.encounter_data[difficulty_token]
-    end
-end
-
-
 local function CurrentLocationData()
     if _G.GetCurrentMapAreaID() ~= current_area_id then
         return _G.GetRealZoneText(), current_area_id, 0, 0, 0, InstanceDifficultyToken()
@@ -446,76 +402,48 @@
 end
 
 
-local function CurrencyLinkToTexture(currency_link)
-    if not currency_link then
+local function DBEntry(data_type, unit_id)
+    if not data_type or not unit_id then
         return
     end
-    local _, _, texture_path = _G.GetCurrencyInfo(tonumber(currency_link:match("currency:(%d+)")))
-    return texture_path:match("[^\\]+$"):lower()
+    local category = global_db[data_type]
+
+    if not category then
+        category = {}
+        global_db[data_type] = category
+    end
+    local unit = category[unit_id]
+
+    if not unit then
+        unit = {}
+        category[unit_id] = unit
+    end
+    return unit
 end
 
-
-local function ItemLinkToID(item_link)
-    if not item_link then
-        return
+private.DBEntry = DBEntry
+
+local NPCEntry
+do
+    local npc_prototype = {}
+    local npc_meta = {
+        __index = npc_prototype
+    }
+
+    function NPCEntry(identifier)
+        local npc = DBEntry("npcs", identifier)
+        return npc and _G.setmetatable(npc, npc_meta) or nil
     end
-    return tonumber(tostring(item_link):match("item:(%d+)"))
+
+    function npc_prototype:EncounterData(difficulty_token)
+        self.encounter_data = self.encounter_data or {}
+        self.encounter_data[difficulty_token] = self.encounter_data[difficulty_token] or {}
+        self.encounter_data[difficulty_token].stats = self.encounter_data[difficulty_token].stats or {}
+
+        return self.encounter_data[difficulty_token]
+    end
 end
 
-private.ItemLinkToID = ItemLinkToID
-
-local function UnitTypeIsNPC(unit_type)
-    return unit_type == private.UNIT_TYPES.NPC or unit_type == private.UNIT_TYPES.VEHICLE
-end
-
-
-local ParseGUID
-do
-    local UNIT_TYPES = private.UNIT_TYPES
-
-    local NPC_ID_MAPPING = {
-        [62164] = 63191, -- Garalon
-    }
-
-
-    local function MatchUnitTypes(unit_type_name)
-        if not unit_type_name then
-            return UNIT_TYPES.UNKNOWN
-        end
-
-        for def, text in next, UNIT_TYPES do
-            if unit_type_name == text then
-                return UNIT_TYPES[def]
-            end
-        end
-        return UNIT_TYPES.UNKNOWN
-    end
-
-
-    function ParseGUID(guid)
-        if not guid then
-            return
-        end
-
-        -- We might want to use some of this new information later, but leaving the returns alone for now
-        local unit_type_name, unk_id1, server_id, instance_id, unk_id2, unit_idnum, spawn_id = ("-"):split(guid)
-
-        local unit_type = MatchUnitTypes(unit_type_name)
-        if unit_type ~= UNIT_TYPES.PLAYER and unit_type ~= UNIT_TYPES.PET and unit_type ~= UNIT_TYPES.ITEM then
-
-            local id_mapping = NPC_ID_MAPPING[unit_idnum]
-
-            if id_mapping and UnitTypeIsNPC(unit_type) then
-                unit_idnum = id_mapping
-            end
-            return unit_type, unit_idnum
-        end
-        return unit_type
-    end
-
-    private.ParseGUID = ParseGUID
-end -- do-block
-
 
 local UpdateDBEntryLocation
 do
@@ -554,7 +482,9 @@
 
         -- Special case for Fishing.
         if current_action.spell_label == "FISHING" then
-            local yard_width, yard_height = MapData:MapArea(area_id, map_level)
+            local _, qx, qy = _G.GetWorldLocFromMapPos(0, 0)
+            local _, wx, wy = _G.GetWorldLocFromMapPos(1, 1)
+            local yard_width, yard_height = qy - wy, qx - wx
 
             if yard_width > 0 and yard_height > 0 then
                 x, y = FishingCoordinates(x, y, yard_width, yard_height)
@@ -570,6 +500,77 @@
 end -- do-block
 
 
+local function CurrencyLinkToTexture(currency_link)
+    if not currency_link then
+        return
+    end
+    local _, _, texture_path = _G.GetCurrencyInfo(tonumber(currency_link:match("currency:(%d+)")))
+    return texture_path:match("[^\\]+$"):lower()
+end
+
+
+local function ItemLinkToID(item_link)
+    if not item_link then
+        return
+    end
+    return tonumber(tostring(item_link):match("item:(%d+)"))
+end
+
+private.ItemLinkToID = ItemLinkToID
+
+local function UnitTypeIsNPC(unit_type)
+    return unit_type == private.UNIT_TYPES.NPC or unit_type == private.UNIT_TYPES.VEHICLE
+end
+
+
+local ParseGUID
+do
+    local UNIT_TYPES = private.UNIT_TYPES
+
+    local NPC_ID_MAPPING = {
+        [62164] = 63191, -- Garalon
+    }
+
+
+    local function MatchUnitTypes(unit_type_name)
+        if not unit_type_name then
+            return UNIT_TYPES.UNKNOWN
+        end
+
+        for def, text in next, UNIT_TYPES do
+            if unit_type_name == text then
+                return UNIT_TYPES[def]
+            end
+        end
+        return UNIT_TYPES.UNKNOWN
+    end
+
+
+    function ParseGUID(guid)
+        if not guid then
+            return
+        end
+
+        -- We might want to use some of this new information later, but leaving the returns alone for now
+        local unit_type_name, unk_id1, server_id, instance_id, unk_id2, unit_idnum, spawn_id = ("-"):split(guid)
+
+        local unit_type = MatchUnitTypes(unit_type_name)
+        if unit_type ~= UNIT_TYPES.PLAYER and unit_type ~= UNIT_TYPES.PET and unit_type ~= UNIT_TYPES.ITEM then
+
+            local id_mapping = NPC_ID_MAPPING[unit_idnum]
+
+            if id_mapping and UnitTypeIsNPC(unit_type) then
+                unit_idnum = id_mapping
+            end
+            return unit_type, unit_idnum
+        end
+        return unit_type
+    end
+
+    private.ParseGUID = ParseGUID
+end -- do-block
+
+
 local function HandleItemUse(item_link, bag_index, slot_index)
     if not item_link then
         return
--- a/libs.xml	Sat Feb 28 05:01:29 2015 -0500
+++ b/libs.xml	Sat Feb 28 23:59:07 2015 -0500
@@ -12,6 +12,5 @@
     <Include file="Libs\LibDialog-1.0\lib.xml"/>
     <Include file="Libs\LibQTip-1.0\lib.xml"/>
     <Script file="Libs\LibPetJournal-2.0\LibPetJournal-2.0.lua"/>
-    <Script file="Libs\LibMapData-1.0\library.lua"/>
     <!--@end-no-lib-strip@-->
 </Ui>