From ff0992f38ad82aae3eb74e04e7ee3bea937ccac1 Mon Sep 17 00:00:00 2001 From: "Nathanial.C.Jones" Date: Sat, 22 Jan 2011 01:45:43 +0000 Subject: [PATCH] More structural changes to the data collection. Reduced the size of the spec bolus to conserve memory and rekeyed the talents to use the talent name as the key. --- QuestHelper/collect_quest.lua | 34 ++++++++++++++++++++++------------ QuestHelper/collect_spec.lua | 34 +++++++++++++++++++--------------- 2 files changed, 41 insertions(+), 27 deletions(-) diff --git a/QuestHelper/collect_quest.lua b/QuestHelper/collect_quest.lua index 5305a24..e011e55 100644 --- a/QuestHelper/collect_quest.lua +++ b/QuestHelper/collect_quest.lua @@ -78,10 +78,14 @@ local function ScanQuests() RegisterQuestData("choice", QHCQ[id], GetQuestLogChoiceInfo) --QuestHelper:TextOut(string.format("%d", GetNumQuestLeaderBoards(index))) + if not QHCQ[id][criteria] then QHCQ[id][criteria] = {} end + for i = 1, GetNumQuestLeaderBoards(index) do - local desc, type = GetQuestLogLeaderBoard(i, index) - QHCQ[id][string.format("criteria_%d_text", i)] = desc - QHCQ[id][string.format("criteria_%d_type", i)] = type + local desc, typ = GetQuestLogLeaderBoard(i, index) + local criterion = { text = desc, type = typ } + QHCQ[id][criteria][tostring(i)] = criterion + --QHCQ[id][string.format("criteria_%d_text", i)] = desc + --QHCQ[id][string.format("criteria_%d_type", i)] = type --QuestHelper:TextOut(string.format("%s, %s", desc, type)) end @@ -296,10 +300,12 @@ local function UpdateQuests() if not ttok["Cdc"] then ttok["Cdc"] = {} end table.insert(ttok["Cdc"], noobey[k][i] - deebey[k][i]) end + + if not QHCQ[k]["criteria"] then QHCQ[k]["criteria"] = {} end - if not QHCQ[k]["criteria_satisfied"] then QHCQ[k]["criteria_satisfied"] = {} end - if not QHCQ[k]["criteria_satisfied"][i] then QHCQ[k]["criteria_satisfied"][i] = {} end - table.insert(QHCQ[k]["criteria_satisfied"][i], ttok) + if not QHCQ[k]["criteria"][tostring(i)] then QHCQ[k]["criteria"][tostring(i)] = {} end + if not QHCQ[k]["criteria"][tostring(i)]["satisfied"] then QHCQ[k]["criteria"][tostring(i)]["satisfied"] = {} end + table.insert(QHCQ[k]["criteria"][tostring(i)]["satisfied"], ttok) --AppendMember(QHCQ[k], string.format("criteria_%d_satisfied", i), ttok) if debug_output then QuestHelper:TextOut(string.format("Updated! Questid %d item %d count %d tok %s", k, i, noobey[k][i] - deebey[k][i], debugtok)) end @@ -333,12 +339,15 @@ local function MouseoverUnit() for _, v in pairs(qlookups) do for _, block in pairs(v) do for _, tv in ipairs(block) do - if not QHCQ[tv.qid][string.format("criteria_%d_monster_true", tv.obj)] then - QHCQ[tv.qid][string.format("criteria_%d_monster_true", tv.obj)] = {} - QHCQ[tv.qid][string.format("criteria_%d_monster_false", tv.obj)] = {} + if not QHCQ[tv.qid]["criteria"] then QHCQ[tv.qid]["criteria"] = {} end + if not QHCQ[tv.qid]["criteria"][tostring(tv.obj)] then QHCQ[tv.qid]["criteria"][tostring(tv.obj)] = {} end + if not QHCQ[tv.qid]["criteria"][tostring(tv.obj)]["monster"] then QHCQ[tv.qid]["criteria"][tostring(tv.obj)] = {} end + if not QHCQ[tv.qid]["criteria"][tostring(tv.obj)]["monster"]["true"] then + QHCQ[tv.qid]["criteria"][tostring(tv.obj)]["monster"]["true"] = {} + QHCQ[tv.qid]["criteria"][tostring(tv.obj)]["monster"]["false"] = {} end - QHCQ[tv.qid][string.format("criteria_%d_monster_false", tv.obj)][guid] = (QHCQ[tv.qid][string.format("criteria_%d_monster_false", tv.obj)][guid] or 0) + 1 + QHCQ[tv.qid]["criteria"][tostring(tv.obj)]["monster"]["false"][guid] = (QHCQ[tv.qid]["criteria"][tostring(tv.obj)]["monster"]["false"][guid] or 0) + 1 end end end @@ -374,8 +383,9 @@ local function MouseoverUnit() if cquest and cquest[lin] then local titem_block = cquest[lin] for _, titem in pairs(titem_block) do - QHCQ[titem.qid][string.format("criteria_%d_monster_false", titem.obj)][guid] = (QHCQ[titem.qid][string.format("criteria_%d_monster_false", titem.obj)][guid] or 0) - 1 - QHCQ[titem.qid][string.format("criteria_%d_monster_true", titem.obj)][guid] = (QHCQ[titem.qid][string.format("criteria_%d_monster_true", titem.obj)][guid] or 0) + 1 + local tv = titem + QHCQ[tv.qid]["criteria"][tostring(tv.obj)]["monster"]["false"][guid] = (QHCQ[tv.qid]["criteria"][tostring(tv.obj)]["monster"]["false"][guid] or 0) - 1 + QHCQ[tv.qid]["criteria"][tostring(tv.obj)]["monster"]["false"][guid] = (QHCQ[tv.qid]["criteria"][tostring(tv.obj)]["monster"]["true"][guid] or 0) + 1 end elseif qlookups[lin] then cquest = qlookups[lin] diff --git a/QuestHelper/collect_spec.lua b/QuestHelper/collect_spec.lua index 98ac0df..74427dd 100644 --- a/QuestHelper/collect_spec.lua +++ b/QuestHelper/collect_spec.lua @@ -43,24 +43,28 @@ local function GetSpecBolus() --local bso = Bitstream.Output(8) local talents = {} - for t = 1, GetNumTalentTabs() do -- come on. Is this ever not going to be 3? Seriously? - local tkey = tostring(t) - talents[tkey] = {} - for ta = 1, GetNumTalents(t) do - local _, _, _, _, rank, _ = GetTalentInfo(t, ta) - local takey = tostring(ta) - talents[tkey][takey] = rank - --bso:append(rank, 3) + local points = (GetUnspentTalentPoints() or 0) + local talents_learned = false + for t = 1, GetNumTalentTabs() do -- come on. Is this ever not going to be 3? Seriously? Perhaps someday, but not as of Cat. + local _, tab, _, _, p, _, _, yn = GetTalentTabInfo(t) + p = p or 0 + if not yn or p == 0 then talents[tab] = 0 -- No point if locked or no points spent (assuming unlocked even if all possible points spent [available and/or max points for tab]), so we set it to a scalar value of 0, to tell the compiler that it can just assume that everything is 0. I suppose I should collect all talents, but meh. + else + talents_learned = true + talents[tab] = {} + for ta = 1, GetNumTalents(t) do + local talent, _, _, _, rank, _ = GetTalentInfo(t, ta) + if rank > 0 then talents[tab][talent] = rank end -- Let's limit to actual talents + end end - --bso:append(6, 3) -- no 6-point talents, so we use this as an end-of-tree market end - --bso:append(7, 3) -- end-of-spec! because of *all of those 4-tree classes* - - --return string.format("2%s%s%02d", classlookup[id], racelookup[race] or "", level) .. bso:finish() + local spec = {} - spec.talents = talents - spec.class = classlookup[id] - spec.race = racelookup[race] or "" + if talents_learned then spec.talents = talents -- If any talent tree has a talent that has been learned, then keep our work. + else spec.talents = 0 -- Otherwise, ditch our work to save space. + end + spec.class = id + spec.race = race spec.level = level --return string.format("(2%s,%s,%02d)", classlookup[id], racelookup[race] or "", level) .. talstr return spec