Automated update from: http://smariot.no-ip.org/translate
[QuestHelper.git] / collect_upgrade.lua
blob2db3d40d1594295a330d061c9fb18bfe7013302a
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
80 if chunk.version == 7 then
81 -- botched the achievement code, fixed the achievement code (maybe?)
82 chunk.achievement = nil
84 chunk.version = 8
85 end
86 end
88 function QH_Collector_UpgradeAll(Collector)
89 -- 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.
90 for _, v in pairs(Collector) do
91 QuestHelper:Assert(type(v) == "table")
92 if not v.version then
93 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.
94 v.version = QuestHelper_Collector_Version
95 end
97 if not v.compressed then
98 QH_Collector_Upgrade(v)
99 end