comparison Core.lua @ 158:7ebe0a85d539

Fixed the way ItemLinks are extracted so that ItemAuditor can handle negative UniqeIDs. I had two of the same item, but one had a negative unique id and was being tracked as if it were a different item.
author Asa Ayers <Asa.Ayers@Gmail.com>
date Wed, 15 Dec 2010 23:15:17 -0800
parents cbb427a8d5a5
children fbfd9dfa6d2b
comparison
equal deleted inserted replaced
157:091bae7bfca0 158:7ebe0a85d539
600 600
601 601
602 function ItemAuditor:GetSafeLink(link) 602 function ItemAuditor:GetSafeLink(link)
603 local newLink = nil 603 local newLink = nil
604 604
605 if link and link == string.match(link, '.-:[-0-9]+[:0-9]*') then 605 if link and link == string.match(link, '.-:[-0-9]+[-:0-9]*') then
606 newLink = link 606 newLink = link
607 elseif link then 607 elseif link then
608 newLink = link and string.match(link, "|H(.-):([-0-9]+):([0-9]+)|h") 608 newLink = link and string.match(link, "|H(.-):([-0-9]+):([-0-9]+)|h")
609 end 609 end
610 if newLink == nil then 610 if newLink == nil then
611 local itemID = self:GetItemID(link) 611 local itemID = self:GetItemID(link)
612 if itemID ~= nil then 612 if itemID ~= nil then
613 _, newLink = GetItemInfo(itemID) 613 _, newLink = GetItemInfo(itemID)
614 return self:GetSafeLink(newLink) 614 return self:GetSafeLink(newLink)
615 end 615 end
616 end 616 end
617 return newLink and string.gsub(newLink, ":0:0:0:0:0:0:[0-9]+", "") 617 return newLink and string.gsub(newLink, ":0:0:0:0:0:0:[-0-9]+", "")
618 end 618 end
619 619
620 function ItemAuditor:GetIDFromLink(link) 620 function ItemAuditor:GetIDFromLink(link)
621 local _, _, _, _, Id = string.find(link, "|?c?f?f?(%x*)|?H?([^:]*):?(%d+):?(%d*):?(%d*):?(%d*):?(%d*):?(%d*):?(%-?%d*):?(%-?%d*):?(%d*)|?h?%[?([^%[%]]*)%]?|?h?|?r?") 621 local _, _, _, _, Id = string.find(link, "|?c?f?f?(%x*)|?H?([^:]*):?(%d+):?(%d*):?(%d*):?(%d*):?(%d*):?(%d*):?(%-?%d*):?(%-?%d*):?(%d*)|?h?%[?([^%[%]]*)%]?|?h?|?r?")
622 return tonumber(Id) 622 return tonumber(Id)