update todo
[QuestHelper.git] / collect_upgrade.lua
blobb6f3685b34552a2d703317d04b407ff1c505c57b
1 QuestHelper_File["collect_upgrade.lua"] = "Development Version"
2 QuestHelper_Loadtime["collect_upgrade.lua"] = GetTime()
4 function QH_Collector_Upgrade(chunk)
5 QuestHelper: Assert(not chunk.compressed)
7 if chunk.version == 1 then
8 -- We basically just want to clobber all our old route data, it's not worth storing - it's all good data, it's just that we don't want to preserve relics of the old location system.
9 chunk.traveled = nil
11 chunk.version = 2
12 end
14 if chunk.version == 2 then
15 -- Originally I split the zones based on locale. Later I just split everything based on locale. Discarding old data rather than doing the gymnastics needed to preserve it.
16 -- This is turning into a routine. :D
17 chunk.zone = nil
19 chunk.version = 3
20 end
22 if chunk.version == 3 then
23 -- Screwed up the item collection code in instances. Obliterate old data, try again.
24 if chunk.item then
25 for id, dat in pairs(chunk.item) do
26 dat.equip_no = nil
27 dat.equip_yes = nil
28 end
29 end
31 chunk.version = 4
32 end
34 if chunk.version == 4 then
35 -- Munged the shops rather badly. Whoopsydaisy.
36 if chunk.monster then
37 local nv = {}
38 for id, dat in pairs(chunk.monster) do
39 if type(dat) == "table" then
40 nv[id] = dat
41 end
42 end
43 chunk.monster = nv
44 end
46 chunk.version = 5
47 end
49 if chunk.version == 5 then
50 -- Horrible things involving objects. Let's preserve what we can.
51 if chunk.object then
52 local new_obj = {}
53 for k, v in pairs(chunk.object) do
54 local keep = false
55 for tk, _ in pairs(v) do
56 if type(tk) == "string" and tk:match("[a-z]+_loot") then
57 keep = true
58 break
59 end
60 end
62 if keep then new_obj[k] = v end
63 end
65 chunk.object = new_obj
66 end
68 chunk.version = 6
69 end
70 end
72 function QH_Collector_UpgradeAll(Collector)
73 -- So, I screwed up the compression code, and there's no way to know what version was compressed . . . except that we thankfully didn't change the version number on that change. Any untagged compression will therefore be the version number that this was loaded with.
74 for _, v in pairs(Collector) do
75 if not v.version then
76 QuestHelper: Assert(QuestHelper_Collector_Version) -- This is going to fail somehow. I just know it. Seriously, this right here will be proof that, today, the gods hate me.
77 v.version = QuestHelper_Collector_Version
78 end
80 if not v.compressed then
81 QH_Collector_Upgrade(v)
82 end
83 end
84 end