stop trying to communicate with people in other worlds
[QuestHelper.git] / collect_upgrade.lua
blobf1ea9f1e1ddfbf2f54ca2692746b5146c1cfb6f2
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
71 if chunk.version == 6 then
72 -- I just screwed this up really
73 -- Note that a few versions back (I'll have to check which) the standard bolus format changed. Since I can't actually *fix* it, I'm just ignoring it, but there's an implicit format change in there. I'll catch it and deal with it in the processing system.
74 chunk.warp = nil
75 chunk.routing_dump = nil -- and this shouldn't have been getting dumped anyway
77 chunk.version = 7
78 end
79 end
81 function QH_Collector_UpgradeAll(Collector)
82 -- 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.
83 for _, v in pairs(Collector) do
84 if not v.version then
85 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.
86 v.version = QuestHelper_Collector_Version
87 end
89 if not v.compressed then
90 QH_Collector_Upgrade(v)
91 end
92 end
93 end