Skip to content

Commit

Permalink
Shouldn't have any impact, but put in defensive coding to ensure that…
Browse files Browse the repository at this point in the history
… we have values for things that are required. (aka checking for nulls)
  • Loading branch information
Vapok committed Sep 4, 2020
1 parent 28a1270 commit 3a59023
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Core.lua
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ core.EncounterList = { -- Event IDs must be in the exact same order as core
core.CommDKPUI = {} -- global storing entire Configuration UI to hide/show UI
core.MonVersion = "v3.2.2";
core.BuildNumber = 30202;
core.ReleaseNumber = 58
core.ReleaseNumber = 59
core.defaultTable = "__default";
core.SemVer = core.MonVersion.."-r"..tostring(core.ReleaseNumber);
core.UpgradeSchema = false;
Expand Down
11 changes: 10 additions & 1 deletion Modules/Award.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,13 @@ local L = core.L;

local function SetItemPrice(cost, loot)
local itemName,itemLink,_,_,_,_,_,_,_,itemIcon = GetItemInfo(loot)
local _, _, Color, Ltype, itemID, Enchant, Gem1, Gem2, Gem3, Gem4, Suffix, Unique, LinkLvl, Name = string.find(itemLink,"|?c?f?f?(%x*)|?H?([^:]*):?(%d+):?(%d*):?(%d*):?(%d*):?(%d*):?(%d*):?(%-?%d*):?(%-?%d*):?(%d*):?(%d*):?(%-?%d*)|?h?%[?([^%[%]]*)%]?|?h?|?r?")
local _, _, Color, Ltype, itemID, Enchant, Gem1, Gem2, Gem3, Gem4, Suffix, Unique, LinkLvl, Name = string.find(loot,"|?c?f?f?(%x*)|?H?([^:]*):?(%d+):?(%d*):?(%d*):?(%d*):?(%d*):?(%d*):?(%-?%d*):?(%-?%d*):?(%d*):?(%d*):?(%-?%d*)|?h?%[?([^%[%]]*)%]?|?h?|?r?")
local cost = cost;

if itemName == nil and Name ~= nil then
itemName = Name;
end

local search = CommDKP:GetTable(CommDKP_MinBids, true)[itemID];
local newItem = {item=itemName, minbid=cost, link=itemLink, icon=itemIcon, disenchants=0, lastbid=cost, itemID = itemID}

Expand Down Expand Up @@ -163,6 +168,10 @@ local function AwardItem(player, cost, boss, zone, loot, reassign)

local _, _, Color, Ltype, itemID, Enchant, Gem1, Gem2, Gem3, Gem4, Suffix, Unique, LinkLvl, Name = string.find(loot,"|?c?f?f?(%x*)|?H?([^:]*):?(%d+):?(%d*):?(%d*):?(%d*):?(%d*):?(%d*):?(%-?%d*):?(%-?%d*):?(%d*):?(%d*):?(%-?%d*)|?h?%[?([^%[%]]*)%]?|?h?|?r?")

if itemName == nil and Name ~= nil then
itemName = Name;
end

local search = CommDKP:GetTable(CommDKP_MinBids, true)[itemID]
local minBidAmount = CommDKP_round(CommDKP:GetMinBid(loot), core.DB.modes.rounding);
local lastBidAmount = CommDKP_round(core.BiddingWindow.cost:GetNumber(), core.DB.modes.rounding);
Expand Down
6 changes: 5 additions & 1 deletion Modules/LootPriceTab.lua
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ end

function CommDKP:ProcessDisenchant(loot)
local itemName,itemLink,_,_,_,_,_,_,_,itemIcon = GetItemInfo(loot)
local _, _, Color, Ltype, itemID, Enchant, Gem1, Gem2, Gem3, Gem4, Suffix, Unique, LinkLvl, Name = string.find(itemLink,"|?c?f?f?(%x*)|?H?([^:]*):?(%d+):?(%d*):?(%d*):?(%d*):?(%d*):?(%d*):?(%-?%d*):?(%-?%d*):?(%d*):?(%d*):?(%-?%d*)|?h?%[?([^%[%]]*)%]?|?h?|?r?")
local _, _, Color, Ltype, itemID, Enchant, Gem1, Gem2, Gem3, Gem4, Suffix, Unique, LinkLvl, Name = string.find(loot,"|?c?f?f?(%x*)|?H?([^:]*):?(%d+):?(%d*):?(%d*):?(%d*):?(%d*):?(%d*):?(%-?%d*):?(%-?%d*):?(%d*):?(%d*):?(%-?%d*)|?h?%[?([^%[%]]*)%]?|?h?|?r?")

if itemName == nil and Name ~= nil then
itemName = Name;
end

local mode = core.DB.modes.mode;

Expand Down
17 changes: 15 additions & 2 deletions Modules/comm.lua
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,15 @@ function CommDKP.Sync:OnEnable()
CommDKP.Sync:RegisterComm("CDKProfileSend", CommDKP.Sync:OnCommReceived()) -- Broadcast Player Profile for Update or Create
end

function GetNameFromLink(link)
if link == nil then
return "Item Name Not Found - Bad Link";
end

local _, _, Color, Ltype, itemID, Enchant, Gem1, Gem2, Gem3, Gem4, Suffix, Unique, LinkLvl, Name = string.find(link,"|?c?f?f?(%x*)|?H?([^:]*):?(%d+):?(%d*):?(%d*):?(%d*):?(%d*):?(%d*):?(%-?%d*):?(%-?%d*):?(%d*):?(%d*):?(%-?%d*)|?h?%[?([^%[%]]*)%]?|?h?|?r?");
return Name;
end

function CommDKP.Sync:OnCommReceived(prefix, message, distribution, sender)

--local msgType = prefix or "nil";
Expand Down Expand Up @@ -431,7 +440,11 @@ function CommDKP.Sync:OnCommReceived(prefix, message, distribution, sender)

if _objReceived.Data.MinBids ~= nil then
table.sort(_objReceived.Data.MinBids, function(a, b)
return a["item"] < b["item"]
--Ensure that if there is a data issue, we detect and move on during syncs.
local aItem = a["item"] or GetNameFromLink(a["link"]);
local bItem = b["item"] or GetNameFromLink(b["link"]);

return aItem < bItem
end)
end

Expand Down Expand Up @@ -501,7 +514,7 @@ function CommDKP.Sync:OnCommReceived(prefix, message, distribution, sender)
end

CommDKP:SetTable(CommDKP_MinBids, true, newMinBidTable, _objReceived.CurrentTeam);

core.DB["teams"] = _objReceived.Teams;
CommDKP:SetCurrentTeam(_objReceived.CurrentTeam)
-- reset seeds since this is a fullbroadcast
Expand Down
5 changes: 5 additions & 0 deletions init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ CommDKP.Commands = {
local itemName,itemLink,_,_,_,_,_,_,_,_ = GetItemInfo(item)
local cost = 0;
local _, _, Color, Ltype, itemID, Enchant, Gem1, Gem2, Gem3, Gem4, Suffix, Unique, LinkLvl, Name = string.find(itemLink,"|?c?f?f?(%x*)|?H?([^:]*):?(%d+):?(%d*):?(%d*):?(%d*):?(%d*):?(%d*):?(%-?%d*):?(%-?%d*):?(%d*):?(%d*):?(%-?%d*)|?h?%[?([^%[%]]*)%]?|?h?|?r?")

if itemName == nil and Name ~= nil then
itemName = Name;
end

local search = CommDKP:GetTable(CommDKP_MinBids, true)[itemID];

if not search then
Expand Down

0 comments on commit 3a59023

Please sign in to comment.