Skip to content

Commit

Permalink
Re-re-added option to set scanning speed
Browse files Browse the repository at this point in the history
  • Loading branch information
AcidWeb committed Nov 29, 2020
1 parent 0dd9d75 commit a5bbad3
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 50 deletions.
4 changes: 3 additions & 1 deletion Locale/enUS.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,6 @@ L["WARNING! This operation is not reversible!"] = true
L["Previous scan"] = true
L["Next scan available in"] = true
L["Now"] = true
L["Items in database"] = true
L["Items in database"] = true
L["Scanning speed"] = true
L["Decrease this value if scanning is causing disconnects."] = true
100 changes: 52 additions & 48 deletions RECrystallize.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ _G.RECrystallize = RE
local time, collectgarbage, hooksecurefunc, strsplit, next, select, pairs, tonumber, floor, print, date = _G.time, _G.collectgarbage, _G.hooksecurefunc, _G.strsplit, _G.next, _G.select, _G.pairs, _G.tonumber, _G.floor, _G.print, _G.date
local sMatch, sFormat = _G.string.match, _G.string.format
local tConcat = _G.table.concat
local Item = _G.Item
local mFmod = _G.math.fmod
local Round = _G.Round
local PlaySound = _G.PlaySound
local After = _G.C_Timer.After
local GetCVar = _G.GetCVar
local GetItemInfo = _G.GetItemInfo
local GetItemCount = _G.GetItemCount
Expand All @@ -33,10 +34,12 @@ local ElvUI = _G.ElvUI

local PETCAGEID = 82800

RE.DefaultConfig = {["LastScan"] = 0, ["GuildChatPC"] = false, ["DatabaseCleanup"] = 432000, ["AlwaysShowAll"] = false, ["DatabaseVersion"] = 1}
RE.DefaultConfig = {["LastScan"] = 0, ["GuildChatPC"] = false, ["DatabaseCleanup"] = 432000, ["AlwaysShowAll"] = false, ["DatabaseVersion"] = 1, ["BatchSize"] = 100}
RE.GUIInitialized = false
RE.RecipeLock = false
RE.ScanFinished = false
RE.ScanInProgress = 0
RE.ScanProgress = 0
RE.ScanSize = 0
RE.BlockTooltip = 0
RE.TooltipLink = ""
RE.TooltipItemVariant = ""
Expand Down Expand Up @@ -206,19 +209,31 @@ function RE:OnEvent(self, event, ...)
set = function(_, val) RE.Config.DatabaseCleanup = val * 86400 end,
get = function(_) return RE.Config.DatabaseCleanup / 86400 end
},
batchsize = {
name = L["Scanning speed"],
desc = L["Decrease this value if scanning is causing disconnects."],
type = "range",
width = "double",
order = 3,
min = 10,
max = 1000,
step = 10,
set = function(_, val) RE.Config.BatchSize = val end,
get = function(_) return RE.Config.BatchSize end
},
dbpurge = {
name = L["Purge this server database"],
desc = L["WARNING! This operation is not reversible!"],
type = "execute",
width = "double",
order = 3,
order = 4,
confirm = true,
func = function() RE.DB[RE.RealmString] = {}; collectgarbage("collect") end
},
separator = {
type = "header",
name = _G.STATISTICS,
order = 4
order = 5
},
description = {
type = "description",
Expand All @@ -234,7 +249,7 @@ function RE:OnEvent(self, event, ...)

return s
end,
order = 5
order = 6
}
}
}
Expand Down Expand Up @@ -357,54 +372,43 @@ function RE:StartScan()
end

function RE:Scan()
RE.ScanFinished = false
local num = GetNumReplicateItems()
local progress = 0
local inProgress = {}

for i = 0, num - 1 do
local link
local count, quality, _, _, _, _, _, price, _, _, _, _, _, _, itemID, status = select(3, GetReplicateItemInfo(i))

if status and count and price and itemID and type(quality) == "number" and count > 0 and price > 0 and itemID > 0 then
link = GetReplicateItemLink(i)
if link then
progress = progress + 1
RE.AHButton:SetText(progress.." / "..num)
RE.DBScan[i] = {["Price"] = price / count, ["ItemID"] = itemID, ["ItemLink"] = link, ["Quality"] = quality}
end
else
local item = Item:CreateFromItemID(itemID)
inProgress[item] = true

item:ContinueOnItemLoad(function()
count, quality, _, _, _, _, _, price, _, _, _, _, _, _, itemID, status = select(3, GetReplicateItemInfo(i))
inProgress[item] = nil
if status and count and price and itemID and type(quality) == "number" and count > 0 and price > 0 and itemID > 0 then
link = GetReplicateItemLink(i)
if link then
progress = progress + 1
RE.AHButton:SetText(progress.." / "..num)
RE.DBScan[i] = {["Price"] = price / count, ["ItemID"] = itemID, ["ItemLink"] = link, ["Quality"] = quality}
end
end
if not next(inProgress) then
inProgress = {}
RE:EndScan()
end
end)
if RE.ScanInProgress > 2 then
RE.ScanInProgress = 0
RE:EndScan()
else
if RE.ScanInProgress == 0 then
RE.ScanInProgress = 1
RE.ScanSize = GetNumReplicateItems() - 1
RE.ScanProgress = 0
end
end

if not next(inProgress) then
RE:EndScan()
for i = RE.ScanProgress, RE.ScanSize do
local link
local count, quality, _, _, _, _, _, price, _, _, _, _, _, _, itemID, status = select(3, GetReplicateItemInfo(i))

RE.ScanProgress = RE.ScanProgress + 1
RE.AHButton:SetText(floor((RE.ScanProgress / (RE.ScanSize * 2)) * 100) + (RE.ScanInProgress == 1 and 0 or 50) .. "%")
if status and count and price and itemID and type(quality) == "number" and count > 0 and price > 0 and itemID > 0 then
link = GetReplicateItemLink(i)
if link then
RE.DBScan[i] = {["Price"] = price / count, ["ItemID"] = itemID, ["ItemLink"] = link, ["Quality"] = quality}
end
end

if RE.ScanProgress > RE.ScanSize then
RE.ScanInProgress = RE.ScanInProgress + 1
RE.ScanProgress = 0
RE:Scan()
break
elseif mFmod(RE.ScanProgress, RE.Config.BatchSize) == 0 then
After(0, RE.Scan)
break
end
end
end
end

function RE:EndScan()
if RE.ScanFinished then return end
RE.ScanFinished = true

RE:ParseDatabase()
RE:SyncDatabase()
RE:CleanDatabase()
Expand Down
2 changes: 1 addition & 1 deletion RECrystallize.toc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## Interface: 90002
## Title: |cFF74D06CRE|rCrystallize
## Notes: Provide Auction House scanner and add item prices to tooltips.
## Version: 1.8.1
## Version: 1.9.0
## Author: AcidWeb
## SavedVariables: RECrystallizeSettings, RECrystallizeDatabase
## X-Website: https://www.curseforge.com/wow/addons/recrystallize-auction-house-scanner
Expand Down

0 comments on commit a5bbad3

Please sign in to comment.