From 704451b0964f7eef2f52701e74d1464f344a77dc Mon Sep 17 00:00:00 2001 From: evil_morfar Date: Wed, 14 Aug 2019 18:10:31 +0200 Subject: [PATCH 1/5] Updated wow API files --- __tests/wow_api.lua | 154 ++++++++++++++++++++++++++++++++++++++- __tests/wow_item_api.lua | 148 +++++++++++++++++++++++++++++++++++++ 2 files changed, 301 insertions(+), 1 deletion(-) create mode 100644 __tests/wow_item_api.lua diff --git a/__tests/wow_api.lua b/__tests/wow_api.lua index 1b6cad02..aafdd9f6 100644 --- a/__tests/wow_api.lua +++ b/__tests/wow_api.lua @@ -106,6 +106,10 @@ function GetTime() return _time end +function _G.StaticPopup_OnHide(args) + -- body... +end + function IsAddOnLoaded() return nil end SlashCmdList = {} @@ -150,6 +154,10 @@ function GetLocale() return "enUS" end +function GetCurrentRegion() + return 3 -- EU +end + function GetAddOnInfo() return end @@ -158,6 +166,26 @@ function GetNumAddOns() return 0 end +function IsPartyLFG () + return _G.IsPartyLFGVal +end + +function IsInRaid() + return _G.IsInRaidVal +end + +function UnitInRaid() + return _G.IsInRaidVal +end + +function UnitInParty() + return _G.IsInGroupVal +end + +function IsInGroup () + return _G.IsInGroupVal +end + function getglobal(k) return _G[k] end @@ -276,7 +304,9 @@ function WoWAPI_FireUpdate(forceNow) end end - +function GetServerTime () + return os.time() +end -- utility function for "dumping" a number of arguments (return a string representation of them) @@ -294,3 +324,125 @@ function dump(...) end return "<"..table.concat(t, "> <")..">" end + +function tDeleteItem(tbl, item) + local index = 1; + while tbl[index] do + if ( item == tbl[index] ) then + tremove(tbl, index); + else + index = index + 1; + end + end +end + +function tIndexOf(tbl, item) + for i, v in ipairs(tbl) do + if item == v then + return i; + end + end +end + +function tContains(tbl, item) + return tIndexOf(tbl, item) ~= nil; +end + +function tInvert(tbl) + local inverted = {}; + for k, v in pairs(tbl) do + inverted[v] = k; + end + return inverted; +end + +function tFilter(tbl, pred, isIndexTable) + local out = {}; + + if (isIndexTable) then + local currentIndex = 1; + for i, v in ipairs(tbl) do + if (pred(v)) then + out[currentIndex] = v; + currentIndex = currentIndex + 1; + end + end + else + for k, v in pairs(tbl) do + if (pred(v)) then + out[k] = v; + end + end + end + + return out; +end + +function CopyTable(settings) + local copy = {}; + for k, v in pairs(settings) do + if ( type(v) == "table" ) then + copy[k] = CopyTable(v); + else + copy[k] = v; + end + end + return copy; +end + +function FindInTableIf(tbl, pred) + for k, v in pairs(tbl) do + if (pred(v)) then + return k, v; + end + end + + return nil; +end + +function Ambiguate(name, method) + if method == "short" then + name = gsub(name, "%-.+", "") + end + return name +end + +function string:split(sep) + local sep, fields = sep or ":", {} + local pattern = string.format("([^%s]+)", sep) + self:gsub(pattern, function(c) fields[#fields+1] = c end) + return fields +end + +function UnitGUID (name) + return "Player-FFF-ABCDF012" +end + +-- Enable some globals +_G.gsub = string.gsub +_G.strfind = string.find +_G.strsplit = string.split +_G.strsub = string.sub +_G.tremove = table.remove +_G.strrep = string.rep +_G.tinsert = table.insert + +-- Not part of the WoWAPI, but added to emulate the ingame /dump cmd +printtable = function( data, level ) + if not data then return end + level = level or 0 + local ident=strrep(' ', level) + if level>6 then return end + if type(data)~='table' then print(tostring(data)) end; + for index,value in pairs(data) do repeat + if type(value)~='table' then + print( ident .. '['..tostring(index)..'] = ' .. tostring(value) .. ' (' .. type(value) .. ')' ); + break; + end + print( ident .. '['..tostring(index)..'] = {') + printtable(value, level+1) + print( ident .. '}' ); + until true end +end + +C_Timer = {After = function() end} diff --git a/__tests/wow_item_api.lua b/__tests/wow_item_api.lua new file mode 100644 index 00000000..3671aa22 --- /dev/null +++ b/__tests/wow_item_api.lua @@ -0,0 +1,148 @@ +-- Simulation of Blizzard Item functions. +-- Note: Only select return types are available, with the rest just being a string + +local _G = getfenv(0) +_G.Items = {} + +function GetItemInfo (item) + local i = assert(_G.Items[item], "item "..item .." isn't registered for GetItemInfo") + return i.itemName, i.itemLink, i.itemRarity, i.itemLevel, i.itemMinLevel, "itemType", "itemSubType", "itemStackCount", +i.itemEquipLoc, "itemIcon", "itemSellPrice", i.itemClassID, i.itemSubClassID, "bindType", "expacID", "itemSetID", +i.isCraftingReagent +end + +function GetItemInfoInstant (item) + local i = assert(_G.Items[item], "item "..item .." isn't registered for GetItemInfoInstant") + return i.itemID, "itemType", "itemSubType", i.itemEquipLoc, "icon", i.itemClassID, i.itemSubClassID +end + +---------------------------------------------------------------- +-- List of predefined items the functions can handle +---------------------------------------------------------------- +_G.Items = { + ["item:166418::::::::120:104::5:4:4799:1808:1522:4786:::"] = { + itemName = "Crest of Pa'ku", + itemID = 166418, + itemLink = "|cffa335ee|Hitem:166418::::::::120:104::5:4:4799:1808:1522:4786:::|h[Crest of Pa'ku]|h|r", + itemString = "item:166418::::::::120:104::5:4:4799:1808:1522:4786:::", + itemRarity = 4, + itemLevel = 400, + itemMinLevel = 120, + itemEquipLoc = "INVTYPE_TRINKET", + itemClassID = 4, --LE_ITEM_CLASS_ARMOR + itemSubClassID = 0, --LE_ITEM_ARMOR_GENERIC + isCraftingReagent = false + }, + ["item:160651::::::::120:104::6:3:4800:1512:4783:::"] = { + itemName = "Vigilant's Bloodshaper", + itemID = 160651, + itemLink = "|cffa335ee|Hitem:160651::::::::120:104::6:3:4800:1512:4783:::|h[Vigilant's Bloodshaper]|h|r", + itemString = "item:160651::::::::120:104::6:3:4800:1512:4783:::", + itemRarity = 4, + itemLevel = 400, + itemMinLevel = 120, + itemEquipLoc = "INVTYPE_TRINKET", + itemClassID = 4, --LE_ITEM_CLASS_ARMOR + itemSubClassID = 0, --LE_ITEM_ARMOR_GENERIC + isCraftingReagent = false + }, + ["item:165818::::::::120:104::5:4:4823:1522:4786:5417:::"] = { + itemName = "Crown of the Seducer", + itemID = 165818, + itemLink = "|cffa335ee|Hitem:165818::::::::120:104::5:4:4823:1522:4786:5417:::|h[Crown of the Seducer]|h|r", + itemString = "item:165818::::::::120:104::5:4:4823:1522:4786:5417:::", + itemRarity = 4, + itemLevel = 385, + itemMinLevel = 120, + itemEquipLoc = "INVTYPE_HEAD", + itemClassID = 4, --LE_ITEM_CLASS_ARMOR + itemSubClassID = 1, --LE_ITEM_ARMOR_CLOTH + isCraftingReagent = false + }, + ["item:165501::::::::120:104::5:3:4799:1522:4786:::"] = { + itemName = "Bracers of Zealous Calling", + itemID = 165501, + itemLink = "|cffa335ee|Hitem:165501::::::::120:104::5:3:4799:1522:4786:::|h[Bracers of Zealous Calling]|h|r", + itemString = "item:165501::::::::120:104::5:3:4799:1522:4786:::", + itemRarity = 4, + itemLevel = 385, + itemMinLevel = 120, + itemEquipLoc = "INVTYPE_WRIST", + itemClassID = 4, --LE_ITEM_CLASS_ARMOR + itemSubClassID = 1, --LE_ITEM_ARMOR_CLOTH + isCraftingReagent = false + }, + ["item:168363::::::::120:256::3:4:4822:1487:4786:6263:::"] = { + itemName = "Dark Passenger's Breastplate", + itemID = 168363, + itemLink = "|cffa335ee|Hitem:168363::::::::120:256::3:4:4822:1487:4786:6263:::|h[Dark Passenger's Breastplate]|h|r", + itemString = "item:168363::::::::120:256::3:4:4822:1487:4786:6263:::", + itemRarity = 4, + itemLevel = 415, + itemMinLevel = 120, + itemEquipLoc = "INVTYPE_CHEST", + itemClassID = 4, --LE_ITEM_CLASS_ARMOR + itemSubClassID = 4, --LE_ITEM_ARMOR_PLATE + isCraftingReagent = false + }, + ["item:168337::::::::120:104::3:4:4822:1487:4786:6263:::"] = { + itemName = "Vestments of Creeping Terror", + itemID = 168337, + itemLink = "|cffa335ee|Hitem:168337::::::::120:104::3:4:4822:1487:4786:6263:::|h[Vestments of Creeping Terror]|h|r", + itemString = "item:168337::::::::120:104::3:4:4822:1487:4786:6263:::", + itemRarity = 4, + itemLevel = 415, + itemMinLevel = 120, + itemEquipLoc = "INVTYPE_ROBE", + itemClassID = 4, --LE_ITEM_CLASS_ARMOR + itemSubClassID = 1, --LE_ITEM_ARMOR_CLOTH + isCraftingReagent = false + }, + ["item:168882::::::::120:256::3:3:4798:1487:4786:::"] = { + itemName = "Shackles of Dissonance", + itemID = 168882, + itemLink = "|cffa335ee|Hitem:168882::::::::120:256::3:3:4798:1487:4786:::|h[Shackles of Dissonance]|h|r", + itemString = "item:168882::::::::120:256::3:3:4798:1487:4786:::", + itemRarity = 4, + itemLevel = 415, + itemMinLevel = 120, + itemEquipLoc = "INVTYPE_WRIST", + itemClassID = 4, --LE_ITEM_CLASS_ARMOR + itemSubClassID = 3, --LE_ITEM_ARMOR_MAIL + isCraftingReagent = false + }, + --|cffa335ee|Hitem:168884::::::::120:256::3:3:4798:1487:4786:::|h[Bindings of the Herald]|h|r + ["item:168884::::::::120:256::3:3:4798:1487:4786:::"] = { + itemName = "Bindings of the Herald", + itemID = 168884, + itemLink = "|cffa335ee|Hitem:168884::::::::120:256::3:3:4798:1487:4786:::|h[Bindings of the Herald]|h|r", + itemString = "item:168884::::::::120:256::3:3:4798:1487:4786:::", + itemRarity = 4, + itemLevel = 415, + itemMinLevel = 120, + itemEquipLoc = "INVTYPE_WRIST", + itemClassID = 4, --LE_ITEM_CLASS_ARMOR + itemSubClassID = 1, --LE_ITEM_ARMOR_CLOTH + isCraftingReagent = false + }, +} + +_G.Items_Array = {} + +-- Create itemID indexes: +do + local add = {} + local add2 = {} + for itemstring, item in pairs(_G.Items) do + add[item.itemID] = item + add2[item.itemLink] = item + tinsert(_G.Items_Array, itemstring) + end + for a,b in pairs(add) do + _G.Items[a] = b + end + for a,b in pairs(add2) do + _G.Items[a] = b + end +end +printtable(_G.Items) From 91fc846b03fb8a1e14ed8fb9090d023b646d89bf Mon Sep 17 00:00:00 2001 From: evil_morfar Date: Thu, 22 Aug 2019 00:25:56 +0200 Subject: [PATCH 2/5] More wow API updates --- __tests/wow_api.lua | 10 ++++++++++ __tests/wow_item_api.lua | 1 - 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/__tests/wow_api.lua b/__tests/wow_api.lua index aafdd9f6..8ee5ace5 100644 --- a/__tests/wow_api.lua +++ b/__tests/wow_api.lua @@ -186,6 +186,16 @@ function IsInGroup () return _G.IsInGroupVal end +function IsInInstance () + local type = "none" + if _G.IsInGroupVal then + type = "party" + elseif _G.IsInRaidVal then + type = "raid" + end + return (IsInGroup() or IsInRaid()), type +end + function getglobal(k) return _G[k] end diff --git a/__tests/wow_item_api.lua b/__tests/wow_item_api.lua index 3671aa22..cffc22bd 100644 --- a/__tests/wow_item_api.lua +++ b/__tests/wow_item_api.lua @@ -145,4 +145,3 @@ do _G.Items[a] = b end end -printtable(_G.Items) From dcd2814b96b3d2f0c8d12ba5a2ade12da6f44263 Mon Sep 17 00:00:00 2001 From: evil_morfar Date: Thu, 22 Aug 2019 00:30:41 +0200 Subject: [PATCH 3/5] Fixed issue with ClearOldVerTestCandidates when upgrading from old < 2.7 --- changelog.md | 5 +++++ core.lua | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/changelog.md b/changelog.md index ca57210d..f85f0b01 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,8 @@ +### v2.13.1 +--- +###### Bugfixes +* *Fixed issues when upgrading from a pre 2.7 version to 2.13 (#391-394).* + ### v2.13.0 --- * **Loot History** diff --git a/core.lua b/core.lua index 8b206b8e..9bd3278d 100644 --- a/core.lua +++ b/core.lua @@ -2218,7 +2218,8 @@ end function RCLootCouncil:ClearOldVerTestCandidates() local oneWeekAgo = time() - 604800 for name, data in pairs(self.db.global.verTestCandidates) do - if data[3] < oneWeekAgo then + if not data[3] -- Doesn't exist for ooold versions + or data[3] < oneWeekAgo then self.db.global.verTestCandidates[name] = nil end end From 006e2c82f245779decb0210da87ac058ef09ed0e Mon Sep 17 00:00:00 2001 From: evil_morfar Date: Thu, 22 Aug 2019 00:39:28 +0200 Subject: [PATCH 4/5] do compat func with pcall. Extra check if version exists --- Utils/BackwardsCompat.lua | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Utils/BackwardsCompat.lua b/Utils/BackwardsCompat.lua index c1cfe3d3..c1d99bf7 100644 --- a/Utils/BackwardsCompat.lua +++ b/Utils/BackwardsCompat.lua @@ -13,10 +13,15 @@ addon.Compat = Compat -- Each compat can only be run once per login, so feel free to call it again. function Compat:Run() for k,v in ipairs(self.list) do - if v.version == "always" or addon:VersionCompare(addon.db.global.version, v.version) and not v.executed then + if v.version == "always" + or (addon:VersionCompare(addon.db.global.version, v.version) or not addon.db.global.version) + and not v.executed then addon:Debug("", "Executing:", k, v.name or "no_name") - v.func(addon, addon.version, addon.db.global.version, addon.db.global.oldVersion) + local check = pcall(v.func, addon, addon.version, addon.db.global.version, addon.db.global.oldVersion) v.executed = true + if not check then + addon:Debug("", "", "Failed to execute:", v.name) + end end end From 3fb4ad35aa58e19d92856b14184b26306ae508be Mon Sep 17 00:00:00 2001 From: evil_morfar Date: Thu, 22 Aug 2019 00:45:50 +0200 Subject: [PATCH 5/5] v2.13.1 push --- RCLootCouncil.toc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/RCLootCouncil.toc b/RCLootCouncil.toc index 6a28a6ed..7f54b61a 100644 --- a/RCLootCouncil.toc +++ b/RCLootCouncil.toc @@ -1,8 +1,8 @@ ## Author: Potdisc ## Interface: 80200 -## Notes: Interface for running a Loot Council v2.13.0 +## Notes: Interface for running a Loot Council v2.13.1 ## Title: RCLootCouncil -## Version: 2.13.0 +## Version: 2.13.1 ## SavedVariables: RCLootCouncilDB, RCLootCouncilLootDB ## OptionalDeps: LibStub, CallbackHandler-1.0, Ace3, lib-st, LibWindow-1.1, LibDialog-1.0