Modified collect.lua
Put all session info into a tab delimited string containing, in order, svnversion (QH build), realm, buildInfo (WoW version), locale and faction. This string is inserted into a sub-table of QuestHelper_Collector called sessions, with a key of session time. Put all data into a sub-table of QuestHelper_Collector called data. Creates session data table on the new data sub-table and sets the key to session time. QH_Collector_SetupData now returns QuestHelper_Collector.data[sessiontime] Changed Collector Current Version to 9... This might be useful for future changes to data layout. Modified collect_location Made BolusizeLocation accept the right arguments. Calculated the distance from either Azeroth map center or Outland map center to the provided point for inclusion. (See comments in code for what is collected and why.) Converted the information into a string. If we couldn't compute a distance to either map center, we leave it out for now, since we are probably in an instance.
Cette révision appartient à :
Parent
1daf6d747c
révision
63efdfe2a2
|
@ -1,321 +1,303 @@
|
||||||
|
|
||||||
local GetTime = QuestHelper_GetTime
|
local GetTime = QuestHelper_GetTime
|
||||||
|
|
||||||
QuestHelper_File["collect.lua"] = "4.0.1.$svnversion$"
|
QuestHelper_File["collect.lua"] = "4.0.1.$svnversion$"
|
||||||
QuestHelper_Loadtime["collect.lua"] = GetTime()
|
QuestHelper_Loadtime["collect.lua"] = GetTime()
|
||||||
|
|
||||||
local --[[ static ]] MINSVNVERSION = 255
|
local --[[ static ]] MINSVNVERSION = 283
|
||||||
local --[[ static ]] PURGEDEV = true
|
local --[[ static ]] PURGEDEV = true
|
||||||
local debug_output = false
|
local debug_output = false
|
||||||
if QuestHelper_File["collect.lua"] == "Development Version" then debug_output = true end
|
if QuestHelper_File["collect.lua"] == "Development Version" then debug_output = true end
|
||||||
|
|
||||||
local QuestHelper_Collector_Version_Current = 8
|
local QuestHelper_Collector_Version_Current = 9
|
||||||
|
|
||||||
QuestHelper_Collector = {}
|
QuestHelper_Collector = {}
|
||||||
QuestHelper_Collector_Version = QuestHelper_Collector_Version_Current
|
QuestHelper_Collector_Version = QuestHelper_Collector_Version_Current
|
||||||
|
|
||||||
local OnUpdateRegistrar = {}
|
local OnUpdateRegistrar = {}
|
||||||
local TooltipRegistrar = {}
|
local TooltipRegistrar = {}
|
||||||
|
|
||||||
local function OnUpdateHookRegistrar(func)
|
local function OnUpdateHookRegistrar(func)
|
||||||
QuestHelper: Assert(func)
|
QuestHelper: Assert(func)
|
||||||
table.insert(OnUpdateRegistrar, func)
|
table.insert(OnUpdateRegistrar, func)
|
||||||
end
|
end
|
||||||
|
|
||||||
local suppress = false
|
local suppress = false
|
||||||
|
|
||||||
-- real tooltips don't use this function
|
-- real tooltips don't use this function
|
||||||
local SetTextScript = GameTooltip.SetText
|
local SetTextScript = GameTooltip.SetText
|
||||||
GameTooltip.SetText = function (...)
|
GameTooltip.SetText = function (...)
|
||||||
suppress = true
|
suppress = true
|
||||||
SetTextScript(...)
|
SetTextScript(...)
|
||||||
suppress = false
|
suppress = false
|
||||||
end
|
end
|
||||||
|
|
||||||
local function CollectTooltippery(self)
|
local function CollectTooltippery(self)
|
||||||
if not self then self = GameTooltip end
|
if not self then self = GameTooltip end
|
||||||
|
|
||||||
for k, v in pairs(TooltipRegistrar) do
|
for k, v in pairs(TooltipRegistrar) do
|
||||||
v(self)
|
v(self)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- anything past here is not my fault
|
-- anything past here is not my fault
|
||||||
end
|
end
|
||||||
|
|
||||||
local ottsu = GameTooltip:GetScript("OnTooltipSetUnit")
|
local ottsu = GameTooltip:GetScript("OnTooltipSetUnit")
|
||||||
QH_Hook(GameTooltip, "OnTooltipSetUnit", function (self, ...)
|
QH_Hook(GameTooltip, "OnTooltipSetUnit", function (self, ...)
|
||||||
CollectTooltippery(self)
|
CollectTooltippery(self)
|
||||||
if ottsu then return QH_Hook_NotMyFault(ottsu, self, ...) end
|
if ottsu then return QH_Hook_NotMyFault(ottsu, self, ...) end
|
||||||
end, "collection OnTooltipSetUnit")
|
end, "collection OnTooltipSetUnit")
|
||||||
|
|
||||||
local ottsi = GameTooltip:GetScript("OnTooltipSetItem")
|
local ottsi = GameTooltip:GetScript("OnTooltipSetItem")
|
||||||
QH_Hook(GameTooltip, "OnTooltipSetItem", function (self, ...)
|
QH_Hook(GameTooltip, "OnTooltipSetItem", function (self, ...)
|
||||||
CollectTooltippery(self)
|
CollectTooltippery(self)
|
||||||
if ottsi then return QH_Hook_NotMyFault(ottsi, self, ...) end
|
if ottsi then return QH_Hook_NotMyFault(ottsi, self, ...) end
|
||||||
end, "collection OnTooltipSetItem")
|
end, "collection OnTooltipSetItem")
|
||||||
|
|
||||||
local ottsh = GameTooltip:GetScript("OnShow")
|
local ottsh = GameTooltip:GetScript("OnShow")
|
||||||
QH_Hook(GameTooltip, "OnShow", function (self, ...)
|
QH_Hook(GameTooltip, "OnShow", function (self, ...)
|
||||||
CollectTooltippery(self)
|
CollectTooltippery(self)
|
||||||
if ottsh then return QH_Hook_NotMyFault(ottsh, self, ...) end
|
if ottsh then return QH_Hook_NotMyFault(ottsh, self, ...) end
|
||||||
end, "collection OnShow")
|
end, "collection OnShow")
|
||||||
|
|
||||||
|
|
||||||
local function TooltipHookRegistrar(func)
|
local function TooltipHookRegistrar(func)
|
||||||
QuestHelper: Assert(func)
|
QuestHelper: Assert(func)
|
||||||
table.insert(TooltipRegistrar, func)
|
table.insert(TooltipRegistrar, func)
|
||||||
end
|
end
|
||||||
|
|
||||||
local API = {
|
local API = {
|
||||||
Registrar_OnUpdateHook = OnUpdateHookRegistrar,
|
Registrar_OnUpdateHook = OnUpdateHookRegistrar,
|
||||||
Registrar_TooltipHook = TooltipHookRegistrar,
|
Registrar_TooltipHook = TooltipHookRegistrar,
|
||||||
Callback_Location_Raw = function () return QuestHelper:Location_RawRetrieve() end,
|
Callback_Location_Raw = function () return QuestHelper:Location_RawRetrieve() end,
|
||||||
Callback_Location_Absolute = function () return QuestHelper:Location_AbsoluteRetrieve() end,
|
Callback_Location_Absolute = function () return QuestHelper:Location_AbsoluteRetrieve() end,
|
||||||
}
|
}
|
||||||
|
|
||||||
-- We do these early, because some things that aren't in collect may rely on these. Yes I realize that avoiding this was one of my main goals in the separate collect system, shut up go away I hate you (in all seriousness: crunch mode + lazy = some nasty bits.)
|
-- We do these early, because some things that aren't in collect may rely on these. Yes I realize that avoiding this was one of my main goals in the separate collect system, shut up go away I hate you (in all seriousness: crunch mode + lazy = some nasty bits.)
|
||||||
-- TODO: Make a common collect/mainmodule system, then rely on that better.
|
-- TODO: Make a common collect/mainmodule system, then rely on that better.
|
||||||
QH_Collect_Util_Init(nil, API) -- Some may actually add their own functions to the API, and should go first. There's no real formalized order, I just know which depend on others, and it's heavily asserted so it will break if it goes in the wrong order.
|
QH_Collect_Util_Init(nil, API) -- Some may actually add their own functions to the API, and should go first. There's no real formalized order, I just know which depend on others, and it's heavily asserted so it will break if it goes in the wrong order.
|
||||||
QH_Collect_Merger_Init(nil, API)
|
QH_Collect_Merger_Init(nil, API)
|
||||||
QH_Collect_Bitstream_Init(nil, API)
|
QH_Collect_Bitstream_Init(nil, API)
|
||||||
QH_Collect_Location_Init(nil, API)
|
QH_Collect_Location_Init(nil, API)
|
||||||
QH_Collect_Patterns_Init(nil, API)
|
QH_Collect_Patterns_Init(nil, API)
|
||||||
QH_Collect_Notifier_Init(nil, API)
|
QH_Collect_Notifier_Init(nil, API)
|
||||||
QH_Collect_Spec_Init(nil, API)
|
QH_Collect_Spec_Init(nil, API)
|
||||||
QH_Collect_LZW_Init(nil, API)
|
QH_Collect_LZW_Init(nil, API)
|
||||||
|
|
||||||
local CompressCollection
|
local CompressCollection
|
||||||
|
|
||||||
function QH_Collector_SetupData()
|
function QH_Collector_SetupData()
|
||||||
local svnversion = "$svnversion$"
|
local svnversion = "$svnversion$"
|
||||||
local buildInfo, locale, faction = GetBuildInfo(), GetLocale(), QuestHelper:PlayerFaction()
|
local buildInfo, locale, faction = GetBuildInfo(), GetLocale(), QuestHelper:PlayerFaction()
|
||||||
local altfaction = ""
|
local altfaction = ""
|
||||||
if faction == "Alliance" then
|
if faction == "Alliance" then
|
||||||
altfaction = "Alliance"
|
altfaction = "Alliance"
|
||||||
elseif faction == "Horde" then
|
elseif faction == "Horde" then
|
||||||
altfaction = "Horde"
|
altfaction = "Horde"
|
||||||
else
|
else
|
||||||
altfaction = "Neutral"
|
altfaction = "Neutral"
|
||||||
end
|
end
|
||||||
local realm = GetRealmName()
|
local realm = GetRealmName()
|
||||||
|
|
||||||
if not QuestHelper_Collector.created then
|
if not QuestHelper_Collector.created then
|
||||||
QuestHelper_Collector.created = time();
|
QuestHelper_Collector.created = time();
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Swap buildInfo and svnversion once first alteration is complete.
|
local session = string.format("%q\t%q\t%q\t%q\t%q", svnversion, realm, buildInfo, locale, altfaction)
|
||||||
-- Perhaps move locale out of the "signature"
|
|
||||||
if not QuestHelper_Collector[svnversion] then
|
if not QuestHelper_Collector.sessions then QuestHelper_Collector.sessions = {} end
|
||||||
QuestHelper_Collector[svnversion] = {}
|
|
||||||
end
|
QuestHelper_Collector.sessions[sessiontime] = session
|
||||||
|
|
||||||
if not QuestHelper_Collector[svnversion][realm] then
|
if not QuestHelper_Collector.data then QuestHelper_Collector.data = {} end
|
||||||
QuestHelper_Collector[svnversion][realm] = {}
|
|
||||||
end
|
QuestHelper_Collector.data[sessiontime] = {}
|
||||||
|
|
||||||
if not QuestHelper_Collector[svnversion][realm][buildInfo] then
|
return QuestHelper_Collector.data[sessiontime]
|
||||||
QuestHelper_Collector[svnversion][realm][buildInfo] = {}
|
end
|
||||||
end
|
|
||||||
|
function QH_Collector_FactionChange()
|
||||||
if not QuestHelper_Collector[svnversion][realm][buildInfo][locale] then
|
local QHCData = QH_Collector_SetupData()
|
||||||
QuestHelper_Collector[svnversion][realm][buildInfo][locale] = {}
|
|
||||||
end
|
QH_Collect_Achievement_FactionChange(QHCData, API)
|
||||||
|
QH_Collect_Zone_FactionChange(QHCData, API)
|
||||||
if not QuestHelper_Collector[svnversion][realm][buildInfo][locale][altfaction] then
|
QH_Collect_Hearth_FactionChange(QHCData, API)
|
||||||
QuestHelper_Collector[svnversion][realm][buildInfo][locale][altfaction] = {}
|
QH_Collect_Monster_FactionChange(QHCData, API)
|
||||||
end
|
QH_Collect_Item_FactionChange(QHCData, API)
|
||||||
|
QH_Collect_Object_FactionChange(QHCData, API)
|
||||||
local sessiontime = time()
|
QH_Collect_Flight_FactionChange(QHCData, API)
|
||||||
if not QuestHelper_Collector[svnversion][realm][buildInfo][locale][altfaction][sessiontime] then
|
QH_Collect_Quest_FactionChange(QHCData, API)
|
||||||
QuestHelper_Collector[svnversion][realm][buildInfo][locale][altfaction][sessiontime] = {}
|
QH_Collect_Warp_FactionChange(QHCData, API)
|
||||||
end
|
end
|
||||||
|
|
||||||
--if not QuestHelper_Collector[sig] or QuestHelper_Collector[sig].compressed then QuestHelper_Collector[sig] = {version = QuestHelper_Collector_Version} end -- fuckin' bullshit, man
|
function QH_Collector_Init()
|
||||||
return QuestHelper_Collector[svnversion][realm][buildInfo][locale][altfaction][sessiontime]
|
-- Dunno why, but these statements cause the 1% issue.
|
||||||
end
|
--[[
|
||||||
|
QH_Collector_UpgradeAll(QuestHelper_Collector)
|
||||||
function QH_Collector_FactionChange()
|
|
||||||
local QHCData = QH_Collector_SetupData()
|
for _, v in pairs(QuestHelper_Collector) do
|
||||||
|
if not v.modified then v.modified = time() - 7 * 24 * 60 * 60 end -- eugh. Yeah, we set it to be a week ago. It's pretty grim.
|
||||||
QH_Collect_Achievement_FactionChange(QHCData, API)
|
end
|
||||||
QH_Collect_Zone_FactionChange(QHCData, API)
|
--]]
|
||||||
QH_Collect_Hearth_FactionChange(QHCData, API)
|
QuestHelper_Collector_Version = QuestHelper_Collector_Version_Current
|
||||||
QH_Collect_Monster_FactionChange(QHCData, API)
|
|
||||||
QH_Collect_Item_FactionChange(QHCData, API)
|
local remove_sigs = {}
|
||||||
QH_Collect_Object_FactionChange(QHCData, API)
|
for k, v in pairs(QuestHelper_Collector) do
|
||||||
QH_Collect_Flight_FactionChange(QHCData, API)
|
local sig = k:match("^(%d)a$") or k:match("^(%d)b$") or k:match("^(%d)r$")
|
||||||
QH_Collect_Quest_FactionChange(QHCData, API)
|
if sig then
|
||||||
QH_Collect_Warp_FactionChange(QHCData, API)
|
if tonumber(sig) < MINSVNVERSION then
|
||||||
end
|
table.insert(remove_sigs, sig)
|
||||||
|
end
|
||||||
function QH_Collector_Init()
|
elseif k ~= svnversion then
|
||||||
-- Dunno why, but these statements cause the 1% issue.
|
table.insert(remove_sigs, k)
|
||||||
--[[
|
elseif k == "$svnversion\$" and PURGEDEV then
|
||||||
QH_Collector_UpgradeAll(QuestHelper_Collector)
|
table.insert(remove_sigs, k)
|
||||||
|
end
|
||||||
for _, v in pairs(QuestHelper_Collector) do
|
end
|
||||||
if not v.modified then v.modified = time() - 7 * 24 * 60 * 60 end -- eugh. Yeah, we set it to be a week ago. It's pretty grim.
|
|
||||||
end
|
for _, v in ipairs(remove_sigs) do
|
||||||
--]]
|
QuestHelper_Collector[v] = nil
|
||||||
QuestHelper_Collector_Version = QuestHelper_Collector_Version_Current
|
end
|
||||||
|
|
||||||
local remove_sigs = {}
|
local QHCData = QH_Collector_SetupData()
|
||||||
for k, v in pairs(QuestHelper_Collector) do
|
QuestHelper: Assert(not QHCData.compressed)
|
||||||
local sig = k:match("^(%d)a$") or k:match("^(%d)b$") or k:match("^(%d)r$")
|
|
||||||
if sig then
|
|
||||||
if tonumber(sig) < MINSVNVERSION then
|
QH_Collect_Achievement_Init(QHCData, API)
|
||||||
table.insert(remove_sigs, sig)
|
QH_Collect_Traveled_Init(QHCData, API)
|
||||||
end
|
QH_Collect_Zone_Init(QHCData, API)
|
||||||
elseif k ~= svnversion then
|
QH_Collect_Hearth_Init(QHCData, API)
|
||||||
table.insert(remove_sigs, k)
|
QH_Collect_Monster_Init(QHCData, API)
|
||||||
elseif k == "$svnversion\$" and PURGEDEV then
|
QH_Collect_Item_Init(QHCData, API)
|
||||||
table.insert(remove_sigs, k)
|
QH_Collect_Object_Init(QHCData, API)
|
||||||
end
|
QH_Collect_Flight_Init(QHCData, API)
|
||||||
end
|
QH_Collect_Quest_Init(QHCData, API)
|
||||||
|
QH_Collect_Warp_Init(QHCData, API)
|
||||||
for _, v in ipairs(remove_sigs) do
|
|
||||||
QuestHelper_Collector[v] = nil
|
QH_Collect_Loot_Init(QHCData, API)
|
||||||
end
|
QH_Collect_Equip_Init(QHCData, API)
|
||||||
|
QH_Collect_Merchant_Init(QHCData, API)
|
||||||
local QHCData = QH_Collector_SetupData()
|
|
||||||
QuestHelper: Assert(not QHCData.compressed)
|
if false then -- this will be disabled in most public releases, or set to a very rare probabalistic thing
|
||||||
|
if not QHCData.routing_dump then QHCData.routing_dump = {} end
|
||||||
|
local nt = {}
|
||||||
QH_Collect_Achievement_Init(QHCData, API)
|
table.insert(QHCData.routing_dump, nt)
|
||||||
QH_Collect_Traveled_Init(QHCData, API)
|
QH_Collect_Routing_Dump = nt
|
||||||
QH_Collect_Zone_Init(QHCData, API)
|
end
|
||||||
QH_Collect_Hearth_Init(QHCData, API)
|
|
||||||
QH_Collect_Monster_Init(QHCData, API)
|
-- So, why do we delay it?
|
||||||
QH_Collect_Item_Init(QHCData, API)
|
-- It's simple. People are gonna update to this version, and then they're going to look at the memory usage. Then they will panic because omg this version uses so much more memory, I bet that will somehow hurt my framerates in a way which is not adequately explained!
|
||||||
QH_Collect_Object_Init(QHCData, API)
|
-- So instead, we just wait half an hour before compressing. Compression will still get done, and I won't have to deal with panicked comments about how bloated QH has gotten.
|
||||||
QH_Collect_Flight_Init(QHCData, API)
|
-- addendum: yeah naturally I'm getting all sorts of panicked comments about how bloated qh has gotten, sigh
|
||||||
QH_Collect_Quest_Init(QHCData, API)
|
--API.Utility_Notifier(GetTime() + (debug_output and 0 or (30 * 60)), function() CompressCollection(QHCData, QuestHelper_Collector[sig_altfaction], API.Utility_Merger, API.Utility_LZW.Compress) end)
|
||||||
QH_Collect_Warp_Init(QHCData, API)
|
QH_Event("NEUTRAL_FACTION_SELECT_RESULT", QH_Collector_FactionChange)
|
||||||
|
end
|
||||||
QH_Collect_Loot_Init(QHCData, API)
|
|
||||||
QH_Collect_Equip_Init(QHCData, API)
|
QH_OnUpdate(function ()
|
||||||
QH_Collect_Merchant_Init(QHCData, API)
|
local tstart = GetTime()
|
||||||
|
for _, v in pairs(OnUpdateRegistrar) do
|
||||||
if false then -- this will be disabled in most public releases, or set to a very rare probabalistic thing
|
v()
|
||||||
if not QHCData.routing_dump then QHCData.routing_dump = {} end
|
end
|
||||||
local nt = {}
|
QH_Timeslice_Increment(GetTime() - tstart, "collect_update")
|
||||||
table.insert(QHCData.routing_dump, nt)
|
end)
|
||||||
QH_Collect_Routing_Dump = nt
|
|
||||||
end
|
|
||||||
|
|
||||||
-- So, why do we delay it?
|
--- I've tossed the compression stuff down here just 'cause I don't feel like making an entire file for it (even though I probably should.)
|
||||||
-- It's simple. People are gonna update to this version, and then they're going to look at the memory usage. Then they will panic because omg this version uses so much more memory, I bet that will somehow hurt my framerates in a way which is not adequately explained!
|
|
||||||
-- So instead, we just wait half an hour before compressing. Compression will still get done, and I won't have to deal with panicked comments about how bloated QH has gotten.
|
local noncompressible = {
|
||||||
-- addendum: yeah naturally I'm getting all sorts of panicked comments about how bloated qh has gotten, sigh
|
modified = true,
|
||||||
--API.Utility_Notifier(GetTime() + (debug_output and 0 or (30 * 60)), function() CompressCollection(QHCData, QuestHelper_Collector[sig_altfaction], API.Utility_Merger, API.Utility_LZW.Compress) end)
|
version = true,
|
||||||
QH_Event("NEUTRAL_FACTION_SELECT_RESULT", QH_Collector_FactionChange)
|
}
|
||||||
end
|
|
||||||
|
local squarify
|
||||||
QH_OnUpdate(function ()
|
|
||||||
local tstart = GetTime()
|
local seritem
|
||||||
for _, v in pairs(OnUpdateRegistrar) do
|
|
||||||
v()
|
local serializers = {
|
||||||
end
|
["nil"] = function(item, add)
|
||||||
QH_Timeslice_Increment(GetTime() - tstart, "collect_update")
|
add("nil")
|
||||||
end)
|
end,
|
||||||
|
["number"] = function(item, add)
|
||||||
|
add(tostring(item))
|
||||||
|
end,
|
||||||
--- I've tossed the compression stuff down here just 'cause I don't feel like making an entire file for it (even though I probably should.)
|
["string"] = function(item, add)
|
||||||
|
add(string.format("%q", item))
|
||||||
local noncompressible = {
|
end,
|
||||||
modified = true,
|
["boolean"] = function(item, add)
|
||||||
version = true,
|
add(item and "true" or "false")
|
||||||
}
|
end,
|
||||||
|
["table"] = function(item, add)
|
||||||
local squarify
|
add("{")
|
||||||
|
local first = true
|
||||||
local seritem
|
for k, v in pairs(item) do
|
||||||
|
if not first then add(",") end
|
||||||
local serializers = {
|
first = false
|
||||||
["nil"] = function(item, add)
|
add("[")
|
||||||
add("nil")
|
seritem(k, add)
|
||||||
end,
|
add("]=")
|
||||||
["number"] = function(item, add)
|
seritem(v, add)
|
||||||
add(tostring(item))
|
end
|
||||||
end,
|
add("}")
|
||||||
["string"] = function(item, add)
|
end,
|
||||||
add(string.format("%q", item))
|
}
|
||||||
end,
|
|
||||||
["boolean"] = function(item, add)
|
seritem = function(item, add)
|
||||||
add(item and "true" or "false")
|
QH_Timeslice_Yield()
|
||||||
end,
|
serializers[type(item)](item, add)
|
||||||
["table"] = function(item, add)
|
end
|
||||||
add("{")
|
|
||||||
local first = true
|
local function DoCompress(item, merger, comp)
|
||||||
for k, v in pairs(item) do
|
if debug_output then QuestHelper: TextOut("Item condensing") end
|
||||||
if not first then add(",") end
|
local ts = GetTime()
|
||||||
first = false
|
|
||||||
add("[")
|
local target = {}
|
||||||
seritem(k, add)
|
for k, v in pairs(item) do
|
||||||
add("]=")
|
if not noncompressible[k] then
|
||||||
seritem(v, add)
|
target[k] = v
|
||||||
end
|
end
|
||||||
add("}")
|
end
|
||||||
end,
|
|
||||||
}
|
local mg = {}
|
||||||
|
seritem(target, function(dat) merger.Add(mg, dat) end)
|
||||||
seritem = function(item, add)
|
|
||||||
QH_Timeslice_Yield()
|
local tg = merger.Finish(mg)
|
||||||
serializers[type(item)](item, add)
|
if debug_output then QuestHelper: TextOut(string.format("Item condensed to %d bytes, %f taken so far", #tg, GetTime() - ts)) end
|
||||||
end
|
mg = nil
|
||||||
|
|
||||||
local function DoCompress(item, merger, comp)
|
local cmp = {}
|
||||||
if debug_output then QuestHelper: TextOut("Item condensing") end
|
local cmptot = 0
|
||||||
local ts = GetTime()
|
|
||||||
|
local doublecheck = ""
|
||||||
local target = {}
|
for chunk = 1, #tg, 1048576 do
|
||||||
for k, v in pairs(item) do
|
local fragment = tg:sub(chunk, chunk + 1048575)
|
||||||
if not noncompressible[k] then
|
doublecheck = doublecheck .. fragment
|
||||||
target[k] = v
|
local ite = comp(fragment, 256, 8)
|
||||||
end
|
cmptot = cmptot + #ite
|
||||||
end
|
table.insert(cmp, ite)
|
||||||
|
end
|
||||||
local mg = {}
|
QuestHelper: Assert(doublecheck == tg)
|
||||||
seritem(target, function(dat) merger.Add(mg, dat) end)
|
|
||||||
|
if #cmp == 1 then cmp = cmp[1] end
|
||||||
local tg = merger.Finish(mg)
|
|
||||||
if debug_output then QuestHelper: TextOut(string.format("Item condensed to %d bytes, %f taken so far", #tg, GetTime() - ts)) end
|
for k, v in pairs(target) do
|
||||||
mg = nil
|
if not noncompressible[k] then
|
||||||
|
item[k] = nil
|
||||||
local cmp = {}
|
end
|
||||||
local cmptot = 0
|
end
|
||||||
|
item.compressed = cmp
|
||||||
local doublecheck = ""
|
|
||||||
for chunk = 1, #tg, 1048576 do
|
if debug_output then QuestHelper: TextOut(string.format("Item compressed to %d bytes in %d shards (previously %d), %f taken", cmptot, type(cmp) == "table" and #cmp or 1, #tg, GetTime() - ts)) end
|
||||||
local fragment = tg:sub(chunk, chunk + 1048575)
|
end
|
||||||
doublecheck = doublecheck .. fragment
|
|
||||||
local ite = comp(fragment, 256, 8)
|
CompressCollection = function(active, active2, merger, comp)
|
||||||
cmptot = cmptot + #ite
|
for _, v in pairs(QuestHelper_Collector) do
|
||||||
table.insert(cmp, ite)
|
if v ~= active and v ~= active2 and not v.compressed then
|
||||||
end
|
QH_Timeslice_Add(function ()
|
||||||
QuestHelper: Assert(doublecheck == tg)
|
DoCompress(v, merger, comp)
|
||||||
|
CompressCollection(active, active2, merger, comp)
|
||||||
if #cmp == 1 then cmp = cmp[1] end
|
end, "compress")
|
||||||
|
break
|
||||||
for k, v in pairs(target) do
|
end
|
||||||
if not noncompressible[k] then
|
end
|
||||||
item[k] = nil
|
end
|
||||||
end
|
|
||||||
end
|
|
||||||
item.compressed = cmp
|
|
||||||
|
|
||||||
if debug_output then QuestHelper: TextOut(string.format("Item compressed to %d bytes in %d shards (previously %d), %f taken", cmptot, type(cmp) == "table" and #cmp or 1, #tg, GetTime() - ts)) end
|
|
||||||
end
|
|
||||||
|
|
||||||
CompressCollection = function(active, active2, merger, comp)
|
|
||||||
for _, v in pairs(QuestHelper_Collector) do
|
|
||||||
if v ~= active and v ~= active2 and not v.compressed then
|
|
||||||
QH_Timeslice_Add(function ()
|
|
||||||
DoCompress(v, merger, comp)
|
|
||||||
CompressCollection(active, active2, merger, comp)
|
|
||||||
end, "compress")
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
|
@ -73,24 +73,44 @@ local function float(c)
|
||||||
return ret
|
return ret
|
||||||
end
|
end
|
||||||
|
|
||||||
local function BolusizeLocation(delayed, c, z, x, y, dl, mid, mf, f)
|
local function rep_comma(val)
|
||||||
-- c and z are *signed* integers that fit within an 8-bit int.
|
return string.gsub(tostring(val), ",", ".")
|
||||||
-- x and y are floating-point values, generally between 0 and 1. We'll dedicate 24 bits to the fractional part, largely because we can.
|
end
|
||||||
-- Overall we're using a weird 11 bytes on this. Meh.
|
|
||||||
-- Also, any nil values are being turned into MIN_WHATEVER.
|
local function BolusizeLocation(m, f, x, y)
|
||||||
local float_x = x
|
-- m and f are positive integers.
|
||||||
local float_y = y
|
-- x and y are floating-point values, generally between 0 and 1. We'll convert to string and then replace any "," decimal separator (because it'll be easier later to import on an enUS machine).
|
||||||
local loc = {}
|
local str_x = rep_comma(x)
|
||||||
--local locStr = (delayed and 1 or 0) .. lgToHex(mid) .. tohex(dl) .. float(x) .. float(y)
|
local str_y = rep_comma(y)
|
||||||
loc["delayed"] = (delayed and 1 or 0)
|
|
||||||
loc["c"] = c
|
-- Next, we are going to calculate the distance this point is from either Azeroth 50,50 or Outland 50,50.
|
||||||
loc["z"] = z
|
-- We will only keep the dx and dy values, since we can compute distance from those (dist = sqrt(dx*dx + dy*dy)). We can also compute a bearing from dx and dy, since we are going relative to (50,50)
|
||||||
loc["x"] = float_x
|
-- Said bearing is the inverse tangent of dy/dx, trig people, trig. SOHCAHTOA. I have all three values, so I could use any pair, but dx and dy make the most sense.
|
||||||
loc["y"] = float_y
|
-- Of course, the bearing DOES need adjusting, since WoW sets 0 to be north. Normally, angles increase counter-clockwise, WoW does the same... SO, all we'd have to do is add 90 degrees, or pi/2 radians to the result of the inverse tangent.
|
||||||
loc["dungeonLevel"] = dl
|
-- This discourse is of no real consequence, beyond explaining the WHY of collecting dx and dy, rather than just the distance.
|
||||||
loc["mapid"] = mid
|
local _, dxAz, dyAz = QuestHelper.Astrolabe:ComputeDistance( 0, 0, 0.5, 0.5, m, f, x, y)
|
||||||
loc["mapfile"] = mf
|
local _, dxOl, dyOl = QuestHelper.Astrolabe:ComputeDistance(466, 0, 0.5, 0.5, m, f, x, y)
|
||||||
loc["facing"] = f
|
|
||||||
|
local dx_str, dy_str
|
||||||
|
local dist_rel
|
||||||
|
if dxAz then
|
||||||
|
dx_str = rep_comma(dxAz)
|
||||||
|
dy_str = rep_comma(dyAz)
|
||||||
|
dist_rel = "A"
|
||||||
|
elseif dxOl then
|
||||||
|
dx_str = rep_comma(dxOl)
|
||||||
|
dy_str = rep_comma(dyOl)
|
||||||
|
dist_rel = "A"
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Finally, we are going to go back to doing a string for the location bolus, but it will be tab delimited in the form "m\tf\tx\t\y\tA\tdx\tdy" or "m\tf\tx\t\y\tO\tdx\tdy" where A means dx,dy are relative to Azeroth (50,50) (in yards) and O means they are relative to Outland (50,50)
|
||||||
|
-- Note: if only four values are present, then we couldn't compute a distance... Probably because we are in an instance of some kind.
|
||||||
|
|
||||||
|
local loc = string.format("%d\t%d\t%s\t%s", m, f, str_x, str_y)
|
||||||
|
if dxAz or dxOl then
|
||||||
|
loc = string.format("%s\t%s\t%s\t%s", loc, dist_rel, dx_str, dy_str)
|
||||||
|
end
|
||||||
|
|
||||||
return loc;
|
return loc;
|
||||||
--return string.format("%s,%s,%s,%s,%s", signed(delayed and 1 or 0), signed(c), signed(z), float_x, float_y)
|
--return string.format("%s,%s,%s,%s,%s", signed(delayed and 1 or 0), signed(c), signed(z), float_x, float_y)
|
||||||
--return signed(delayed and 1 or 0) .. signed(c) .. signed(z) .. float_x .. float_y
|
--return signed(delayed and 1 or 0) .. signed(c) .. signed(z) .. float_x .. float_y
|
||||||
|
|
Référencer dans un nouveau ticket