try to debug another issue
[QuestHelper.git] / upgrade.lua
blob17670ddbb8958b75086825667b3e5e92b3783e4d
1 QuestHelper_File["upgrade.lua"] = "Development Version"
2 QuestHelper_Loadtime["upgrade.lua"] = GetTime()
4 QuestHelper_Zones =
5 {{[0]="Kalimdor",
6 [1]="Ashenvale",
7 [2]="Azshara",
8 [3]="Azuremyst Isle",
9 [4]="Bloodmyst Isle",
10 [5]="Darkshore",
11 [6]="Darnassus",
12 [7]="Desolace",
13 [8]="Durotar",
14 [9]="Dustwallow Marsh",
15 [10]="Felwood",
16 [11]="Feralas",
17 [12]="Moonglade",
18 [13]="Mulgore",
19 [14]="Orgrimmar",
20 [15]="Silithus",
21 [16]="Stonetalon Mountains",
22 [17]="Tanaris",
23 [18]="Teldrassil",
24 [19]="The Barrens",
25 [20]="The Exodar",
26 [21]="Thousand Needles",
27 [22]="Thunder Bluff",
28 [23]="Un'Goro Crater",
29 [24]="Winterspring"},
30 {[0]="Eastern Kingdoms",
31 [1]="Alterac Mountains",
32 [2]="Arathi Highlands",
33 [3]="Badlands",
34 [4]="Blasted Lands",
35 [5]="Burning Steppes",
36 [6]="Deadwind Pass",
37 [7]="Dun Morogh",
38 [8]="Duskwood",
39 [9]="Eastern Plaguelands",
40 [10]="Elwynn Forest",
41 [11]="Eversong Woods",
42 [12]="Ghostlands",
43 [13]="Hillsbrad Foothills",
44 [14]="Ironforge",
45 [15]="Isle of Quel'Danas",
46 [16]="Loch Modan",
47 [17]="Redridge Mountains",
48 [18]="Searing Gorge",
49 [19]="Silvermoon City",
50 [20]="Silverpine Forest",
51 [21]="Stormwind City",
52 [22]="Stranglethorn Vale",
53 [23]="Swamp of Sorrows",
54 [24]="The Hinterlands",
55 [25]="Tirisfal Glades",
56 [26]="Undercity",
57 [27]="Western Plaguelands",
58 [28]="Westfall",
59 [29]="Wetlands"},
60 {[0]="Outland",
61 [1]="Blade's Edge Mountains",
62 [2]="Hellfire Peninsula",
63 [3]="Nagrand",
64 [4]="Netherstorm",
65 [5]="Shadowmoon Valley",
66 [6]="Shattrath City",
67 [7]="Terokkar Forest",
68 [8]="Zangarmarsh"},
69 {[0]="Northrend",
70 [1]="Borean Tundra",
71 [2]="Crystalsong Forest",
72 [3]="Dalaran",
73 [4]="Dragonblight",
74 [5]="Grizzly Hills",
75 [6]="Howling Fjord",
76 [7]="Hrothgar's Landing",
77 [8]="Icecrown",
78 [9]="Sholazar Basin",
79 [10]="The Storm Peaks",
80 [11]="Wintergrasp",
81 [12]="Zul'Drak",},
83 [-77]={[0]="ScarletEnclave_Continent", [1]="ScarletEnclave"},
85 [-80]={[0]="UtgardeKeep1_Continent", [1]="UtgardeKeep1"},
86 [-81]={[0]="UtgardeKeep2_Continent", [1]="UtgardeKeep2"},
87 [-82]={[0]="UtgardeKeep3_Continent", [1]="UtgardeKeep3"},
89 [-83]={[0]="TheNexus_Continent", [1]="TheNexus"},
91 [-84]={[0]="AzjolNerub1_Continent", [1]="AzjolNerub1"},
92 [-85]={[0]="AzjolNerub2_Continent", [1]="AzjolNerub2"},
93 [-86]={[0]="AzjolNerub3_Continent", [1]="AzjolNerub3"},
95 [-87]={[0]="Ahnkahet_Continent", [1]="Ahnkahet"},
97 [-88]={[0]="DrakTharonKeep1_Continent", [1]="DrakTharonKeep1"},
98 [-89]={[0]="DrakTharonKeep2_Continent", [1]="DrakTharonKeep2"},
100 [-90]={[0]="VioletHold_Continent", [1]="VioletHold"},
102 [-91]={[0]="Gundrak_Continent", [1]="Gundrak"},
104 [-92]={[0]="Ulduar77_Continent", [1]="Ulduar77"},
106 [-93]={[0]="HallsofLightning1_Continent", [1]="HallsofLightning1"},
107 [-94]={[0]="HallsofLightning2_Continent", [1]="HallsofLightning2"},
109 [-95]={[0]="Nexus801_Continent", [1]="Nexus801"},
110 [-96]={[0]="Nexus802_Continent", [1]="Nexus802"},
111 [-97]={[0]="Nexus803_Continent", [1]="Nexus803"},
112 [-98]={[0]="Nexus804_Continent", [1]="Nexus804"},
114 [-99]={[0]="CoTStratholme1_Continent", [1]="CoTStratholme1"},
115 [-100]={[0]="CoTStratholme2_Continent", [1]="CoTStratholme2"},
117 [-101]={[0]="UtgardePinnacle1_Continent", [1]="UtgardePinnacle1"},
118 [-102]={[0]="UtgardePinnacle2_Continent", [1]="UtgardePinnacle2"},
120 [-103]={[0]="VaultofArchavon_Continent", [1]="VaultofArchavon"},
122 [-104]={[0]="Naxxramas1_Continent", [1]="Naxxramas1"},
123 [-105]={[0]="Naxxramas2_Continent", [1]="Naxxramas2"},
124 [-106]={[0]="Naxxramas3_Continent", [1]="Naxxramas3"},
125 [-107]={[0]="Naxxramas4_Continent", [1]="Naxxramas4"},
126 [-108]={[0]="Naxxramas5_Continent", [1]="Naxxramas5"},
127 [-109]={[0]="Naxxramas6_Continent", [1]="Naxxramas6"},
129 [-110]={[0]="TheObsidianSanctum_Continent", [1]="TheObsidianSanctum"},
131 [-111]={[0]="TheEyeOfEternity_Continent", [1]="TheEyeOfEternity"},
133 [-112]={[0]="Ulduar_Continent", [1]="Ulduar"},
134 [-113]={[0]="Ulduar1_Continent", [1]="Ulduar1"},
135 [-114]={[0]="Ulduar2_Continent", [1]="Ulduar2"},
136 [-115]={[0]="Ulduar3_Continent", [1]="Ulduar3"},
137 [-116]={[0]="Ulduar4_Continent", [1]="Ulduar4"},
139 [-117]={[0]="TheForgeofSouls_Continent", [1]="TheForgeofSouls"},
140 [-118]={[0]="PitofSaron_Continent", [1]="PitofSaron"},
144 -- This will be translated to [LOCALE_NAME] = INDEX by QuestHelper_BuildZoneLookup.
145 -- Additionally, [CONT_INDEX][ZONE_INDEX] = INDEX will also be added.
146 QuestHelper_IndexLookup =
147 {["Hinterlands"] = {42, 2, 24},
148 ["Moonglade"] = {20, 1, 12},
149 ["ThousandNeedles"] = {14, 1, 21},
150 ["Winterspring"] = {19, 1, 24},
151 ["BloodmystIsle"] = {9, 1, 4},
152 ["TerokkarForest"] = {55, 3, 7},
153 ["Arathi"] = {39, 2, 2},
154 ["EversongWoods"] = {41, 2, 11},
155 ["Dustwallow"] = {10, 1, 9},
156 ["Badlands"] = {27, 2, 3},
157 ["Darkshore"] = {16, 1, 5},
158 ["Ogrimmar"] = {1, 1, 14},
159 ["BladesEdgeMountains"] = {54, 3, 1},
160 ["Undercity"] = {45, 2, 26},
161 ["Desolace"] = {4, 1, 7},
162 ["Netherstorm"] = {59, 3, 4},
163 ["Barrens"] = {11, 1, 19},
164 ["Tanaris"] = {8, 1, 17},
165 ["Stormwind"] = {36, 2, 21},
166 ["Zangarmarsh"] = {57, 3, 8},
167 ["Durotar"] = {7, 1, 8},
168 ["Hellfire"] = {56, 3, 2},
169 ["Silithus"] = {5, 1, 15},
170 ["ShattrathCity"] = {60, 3, 6},
171 ["ShadowmoonValley"] = {53, 3, 5},
172 ["SwampOfSorrows"] = {46, 2, 23},
173 ["SilvermoonCity"] = {52, 2, 19},
174 ["Darnassis"] = {21, 1, 6},
175 ["AzuremystIsle"] = {3, 1, 3},
176 ["Elwynn"] = {37, 2, 10},
177 ["Stranglethorn"] = {38, 2, 22},
178 ["EasternPlaguelands"] = {34, 2, 9},
179 ["Duskwood"] = {31, 2, 8},
180 ["WesternPlaguelands"] = {50, 2, 27},
181 ["Westfall"] = {49, 2, 28},
182 ["Ashenvale"] = {2, 1, 1},
183 ["Teldrassil"] = {24, 1, 18},
184 ["Redridge"] = {30, 2, 17},
185 ["UngoroCrater"] = {18, 1, 23},
186 ["Mulgore"] = {22, 1, 13},
187 ["Ironforge"] = {25, 2, 14},
188 ["Felwood"] = {13, 1, 10},
189 ["Hilsbrad"] = {48, 2, 13},
190 ["DeadwindPass"] = {47, 2, 6},
191 ["BurningSteppes"] = {40, 2, 5},
192 ["Ghostlands"] = {44, 2, 12},
193 ["Tirisfal"] = {43, 2, 25},
194 ["TheExodar"] = {12, 1, 20},
195 ["Wetlands"] = {51, 2, 29},
196 ["SearingGorge"] = {32, 2, 18},
197 ["BlastedLands"] = {33, 2, 4},
198 ["Silverpine"] = {35, 2, 20},
199 ["LochModan"] = {29, 2, 16},
200 ["Feralas"] = {17, 1, 11},
201 ["DunMorogh"] = {28, 2, 7},
202 ["Alterac"] = {26, 2, 1},
203 ["ThunderBluff"] = {23, 1, 22},
204 ["Aszhara"] = {15, 1, 2},
205 ["StonetalonMountains"] = {6, 1, 16},
206 ["Nagrand"] = {58, 3, 3},
207 ["Kalimdor"] = {61, 1, 0},
208 ["Azeroth"] = {62, 2, 0},
209 ["Expansion01"] = {63, 3, 0},
210 ["Sunwell"] = {64, 2, 15},
212 ["Northrend"] = {76, 4, 0},
213 ["BoreanTundra"] = {65, 4, 1},
214 ["CrystalsongForest"] = {66, 4, 2},
215 ["Dalaran"] = {67, 4, 3},
216 ["Dragonblight"] = {68, 4, 4},
217 ["GrizzlyHills"] = {69, 4, 5},
218 ["HowlingFjord"] = {70, 4, 6},
219 ["HrothgarsLanding"] = {153, 4, 7}, -- wooo consecutive numbering
220 ["IcecrownGlacier"] = {71, 4, 8},
221 ["SholazarBasin"] = {72, 4, 9},
222 ["TheStormPeaks"] = {73, 4, 10},
223 ["LakeWintergrasp"] = {74, 4, 11},
224 ["ZulDrak"] = {75, 4, 12},
226 ["ScarletEnclave_Continent"] = {77, -77, 0}, ["ScarletEnclave"] = {78, -77, 1},
228 ["UtgardeKeep1_Continent"] = {79, -80, 0}, ["UtgardeKeep1"] = {80, -80, 1},
229 ["UtgardeKeep2_Continent"] = {81, -81, 0}, ["UtgardeKeep2"] = {82, -81, 1},
230 ["UtgardeKeep3_Continent"] = {83, -82, 0}, ["UtgardeKeep3"] = {84, -82, 1},
232 ["TheNexus_Continent"] = {85, -83, 0}, ["TheNexus"] = {86, -83, 1},
234 ["AzjolNerub1_Continent"] = {87, -84, 0}, ["AzjolNerub1"] = {88, -84, 1},
235 ["AzjolNerub2_Continent"] = {89, -85, 0}, ["AzjolNerub2"] = {90, -85, 1},
236 ["AzjolNerub3_Continent"] = {91, -86, 0}, ["AzjolNerub3"] = {92, -86, 1},
238 ["Ahnkahet_Continent"] = {93, -87, 0}, ["Ahnkahet"] = {94, -87, 1},
240 ["DrakTharonKeep1_Continent"] = {95, -88, 0}, ["DrakTharonKeep1"] = {96, -88, 1},
241 ["DrakTharonKeep2_Continent"] = {97, -89, 0}, ["DrakTharonKeep2"] = {98, -89, 1},
243 ["VioletHold_Continent"] = {99, -90, 0}, ["VioletHold"] = {100, -90, 1},
245 ["Gundrak_Continent"] = {101, -91, 0}, ["Gundrak"] = {102, -91, 1},
247 ["Ulduar77_Continent"] = {103, -92, 0}, ["Ulduar77"] = {104, -92, 1}, -- HoS
249 ["HallsofLightning1_Continent"] = {105, -93, 0}, ["HallsofLightning1"] = {106, -93, 1},
250 ["HallsofLightning2_Continent"] = {107, -94, 0}, ["HallsofLightning2"] = {108, -94, 1},
252 ["Nexus801_Continent"] = {109, -95, 0}, ["Nexus801"] = {110 , -95, 1},
253 ["Nexus802_Continent"] = {111, -96, 0}, ["Nexus802"] = {112, -96, 1},
254 ["Nexus803_Continent"] = {113, -97, 0}, ["Nexus803"] = {114, -97, 1},
255 ["Nexus804_Continent"] = {115, -98, 0}, ["Nexus804"] = {116, -98, 1},
257 ["CoTStratholme1_Continent"] = {117, -99, 0}, ["CoTStratholme1"] = {118, -99, 1},
258 ["CoTStratholme2_Continent"] = {119, -100, 0}, ["CoTStratholme2"] = {120, -100, 1},
260 ["UtgardePinnacle1_Continent"] = {121, -101, 0}, ["UtgardePinnacle1"] = {122, -101, 1},
261 ["UtgardePinnacle2_Continent"] = {123, -102, 0}, ["UtgardePinnacle2"] = {124, -102, 1},
263 ["VaultofArchavon_Continent"] = {125, -103, 0}, ["VaultofArchavon"] = {126, -103, 1},
265 ["Naxxramas1_Continent"] = {127, -104, 0}, ["Naxxramas1"] = {128, -104, 1},
266 ["Naxxramas2_Continent"] = {129, -105, 0}, ["Naxxramas2"] = {130, -105, 1},
267 ["Naxxramas3_Continent"] = {131, -106, 0}, ["Naxxramas3"] = {132, -106, 1},
268 ["Naxxramas4_Continent"] = {133, -107, 0}, ["Naxxramas4"] = {134, -107, 1},
269 ["Naxxramas5_Continent"] = {135, -108, 0}, ["Naxxramas5"] = {136, -108, 1},
270 ["Naxxramas6_Continent"] = {137, -109, 0}, ["Naxxramas6"] = {138, -109, 1},
272 ["TheObsidianSanctum_Continent"] = {139, -110, 0}, ["TheObsidianSanctum"] = {140, -110, 1},
274 ["TheEyeOfEternity_Continent"] = {141, -111, 0}, ["TheEyeOfEternity"] = {142, -111, 1},
276 ["Ulduar_Continent"] = {143, -112, 0}, ["Ulduar"] = {144, -112, 1},
277 ["Ulduar1_Continent"] = {145, -113, 0}, ["Ulduar1"] = {146, -113, 1},
278 ["Ulduar2_Continent"] = {147, -114, 0}, ["Ulduar2"] = {148, -114, 1},
279 ["Ulduar3_Continent"] = {149, -115, 0}, ["Ulduar3"] = {150, -115, 1},
280 ["Ulduar4_Continent"] = {151, -116, 0}, ["Ulduar4"] = {152, -116, 1},
282 ["TheForgeofSouls_Continent"] = {154, -117, 0}, ["TheForgeofSouls"] = {155, -117, 1},
283 ["PitofSaron_Continent"] = {156, -118, 0}, ["PitofSaron"] = {157, -118, 1},
285 -- yes virginia 156 is currently the end
288 QuestHelper_RestrictedZones = { -- Everything defaults to "nil"
289 [78] = 1,
292 local next_index = 1
293 for i, j in pairs(QuestHelper_IndexLookup) do next_index = math.max(next_index, j[1]+1) end
295 -- Maps zone names and indexes to a two element array, containing zone index a continent/zone
296 QuestHelper_ZoneLookup = {}
298 -- Maps indexes to zone names.
299 QuestHelper_NameLookup = {}
301 -- Maps plane indexes to the ultimate continent parents
302 QuestHelper_ParentLookup = {}
304 local built = false
306 function QuestHelper_BuildZoneLookup()
307 if built then return end
308 built = true
310 local cartugh
311 if Cartographer_Notes and not Cartographer_Notes.fixed_that_bug_that_causes_POI_to_crash_when_you_change_to_hrothgars_landing then
312 cartugh = Cartographer_Notes.SetNote
313 Cartographer_Notes.SetNote = function () end -- cartographer why are you terrible
316 if GetMapContinents and GetMapZones then
317 -- Called from inside the WoW client.
319 local original_lookup, original_zones = QuestHelper_IndexLookup, QuestHelper_Zones
320 QuestHelper_IndexLookup = {}
321 QuestHelper_Zones = {}
323 for c, cname in pairs(QuestHelper.Astrolabe:GetMapVirtualContinents()) do
324 QuestHelper_Zones[c] = {}
325 local tpx = QuestHelper.Astrolabe:GetMapVirtualZones(c)
326 tpx[0] = cname
327 for z, zname in pairs(tpx) do
329 local base_name = QuestHelper.Astrolabe:GetMapTexture(c, z)
331 local index = original_lookup[base_name] and original_lookup[base_name][1]
333 local altered_index = "!!! QuestHelper_IndexLookup entry needs update: [%q] = {%s, %s, %s}"
334 local altered_zone = "!!! QuestHelper_Zones entry needs update: [%s][%s] = %q -- was %s"
336 if not index then
337 QuestHelper:TextOut(altered_index:format(tostring(base_name), tostring(next_index), tostring(c), tostring(z)))
338 next_index = next_index + 1
339 else
340 if QuestHelper_Locale == "enUS" then
341 if original_lookup[base_name][2] ~= c or original_lookup[base_name][3] ~= z then
342 QuestHelper:TextOut(altered_index:format(base_name, index, c, z))
345 if not original_zones[c] or original_zones[c][z] ~= zname then
346 QuestHelper:TextOut(altered_zone:format(c, z, zname, original_zones[c] and original_zones[c][z] or "missing"))
350 local pair = {c, z}
351 if not QuestHelper_IndexLookup[c] then QuestHelper_IndexLookup[c] = {} end
352 QuestHelper_IndexLookup[c][z] = index
353 QuestHelper_IndexLookup[zname] = index
355 QuestHelper_NameLookup[index] = zname
357 QuestHelper_ZoneLookup[zname] = pair
358 QuestHelper_ZoneLookup[index] = pair
360 QuestHelper_Zones[c][z] = zname
365 for name, index in pairs(original_lookup) do
366 if index[2] == -1 then
367 assert(not QuestHelper_IndexLookup[name])
368 QuestHelper_IndexLookup[name] = index[1]
372 for k, v in pairs(QuestHelper_ZoneLookup) do
373 if type(k) == "number" then
374 if v[1] == 1 or v[1] == 2 or v[1] == 4 then -- weh
375 QuestHelper_ParentLookup[k] = 0
376 else
377 QuestHelper_ParentLookup[k] = v[1]
381 else
382 -- Called from some lua script.
383 local original_lookup = QuestHelper_IndexLookup
384 QuestHelper_IndexLookup = {}
386 for base_name, i in pairs(original_lookup) do
387 local index = i[1]
388 local pair = {i[2], i[3]}
389 local name = QuestHelper_Zones[pair[1]][pair[2]]
391 assert(index and name)
393 if not QuestHelper_IndexLookup[pair[1]] then QuestHelper_IndexLookup[pair[1]] = {} end
394 QuestHelper_IndexLookup[pair[1]][pair[2]] = index
395 QuestHelper_IndexLookup[name] = index
397 QuestHelper_NameLookup[index] = name
399 QuestHelper_ZoneLookup[name] = pair
400 QuestHelper_ZoneLookup[index] = pair
404 if Cartographer_Notes and not Cartographer_Notes.fixed_that_bug_that_causes_POI_to_crash_when_you_change_to_hrothgars_landing then
405 Cartographer_Notes.SetNote = cartugh
409 local convert_lookup =
410 {{2, 15, 3, 9, 16, 21, 4, 7, 10, 13, 17, 20, 22, 1, 5, 6, 8, 24, 11, 12, 14, 23, 18, 19},
411 {26, 39, 27, 33, 40, 47, 28, 31, 34, 37, 41, 44, 48, 25, 29, 30, 32, 52, 35, 36, 38, 46, 42, 43, 45, 50, 49, 51},
412 {54, 56, 58, 59, 53, 60, 55, 57}}
414 function QuestHelper_ValidPosition(c, z, x, y)
415 return type(x) == "number" and type(y) == "number" and x > -0.1 and y > -0.1 and x < 1.1 and y < 1.1 and c and convert_lookup[c] and z and convert_lookup[c][z] and true
418 function QuestHelper_PrunePositionList(list)
419 if type(list) ~= "table" then
420 return nil
423 local i = 1
424 while i <= #list do
425 local pos = list[i]
426 if QuestHelper_ValidPosition(unpack(list[i])) and type(pos[5]) == "number" and pos[5] >= 1 then
427 i = i + 1
428 else
429 local rem = table.remove(list, i)
433 return #list > 0 and list or nil
436 local function QuestHelper_ConvertPosition(pos)
437 pos[2] = convert_lookup[pos[1]][pos[2]]
438 table.remove(pos, 1)
441 local function QuestHelper_ConvertPositionList(list)
442 if list then
443 for i, pos in pairs(list) do
444 QuestHelper_ConvertPosition(pos)
449 local function QuestHelper_ConvertFaction(faction)
450 if faction == 1 or faction == "Alliance" or faction == FACTION_ALLIANCE then return 1
451 elseif faction == 2 or faction == "Horde" or faction == FACTION_HORDE then return 2
452 else
453 assert(false, "Unknown faction: "..faction.."'")
457 function QuestHelper_UpgradeDatabase(data)
458 if data.QuestHelper_SaveVersion == 1 then
460 -- Reputation objectives weren't parsed correctly before.
461 if data.QuestHelper_Objectives["reputation"] then
462 for faction, objective in pairs(data.QuestHelper_Objectives["reputation"]) do
463 local real_faction = string.find(faction, "%s*(.+)%s*:%s*") or faction
464 if faction ~= real_faction then
465 data.QuestHelper_Objectives["reputation"][real_faction] = data.QuestHelper_Objectives["reputation"][faction]
466 data.QuestHelper_Objectives["reputation"][faction] = nil
471 -- Items that wern't in the local cache when I read the quest log ended up with empty names.
472 if data.QuestHelper_Objectives["item"] then
473 data.QuestHelper_Objectives["item"][" "] = nil
476 data.QuestHelper_SaveVersion = 2
479 if data.QuestHelper_SaveVersion == 2 then
481 -- The hashes for the quests were wrong. Damnit!
482 for faction, level_list in pairs(data.QuestHelper_Quests) do
483 for level, quest_list in pairs(level_list) do
484 for quest_name, quest_data in pairs(quest_list) do
485 quest_data.hash = nil
486 quest_data.alt = nil
491 -- None of the information I collected about quest items previously can be trusted.
492 -- I also didn't properly mark quest items as such, so I'll have to remove the information for non
493 -- quest items also.
495 if data.QuestHelper_Objectives["item"] then
496 for item, item_data in pairs(data.QuestHelper_Objectives["item"]) do
497 -- I'll remerge the bad data later if I find out its not used solely for quests.
498 item_data.bad_pos = item_data.bad_pos or item_data.pos
499 item_data.bad_drop = item_data.bad_drop or item_data.drop
500 item_data.pos = nil
501 item_data.drop = nil
503 -- In the future i'll delete the bad_x data.
504 -- When I do, either just delete it, or of all the monsters or positions match the monsters and positions of the
505 -- quest, merge them into that.
509 data.QuestHelper_SaveVersion = 3
512 if data.QuestHelper_SaveVersion == 3 then
513 -- We'll go through this and make sure all the position lists are correct.
514 for faction, level_list in pairs(data.QuestHelper_Quests) do
515 for level, quest_list in pairs(level_list) do
516 for quest_name, quest_data in pairs(quest_list) do
517 quest_data.pos = QuestHelper_PrunePositionList(quest_data.pos)
518 if quest_data.item then for name, data in pairs(quest_data.item) do
519 data.pos = QuestHelper_PrunePositionList(data.pos)
520 end end
521 if quest_data.alt then for hash, data in pairs(quest_data.alt) do
522 data.pos = QuestHelper_PrunePositionList(data.pos)
523 if data.item then for name, data in pairs(data.item) do
524 data.pos = QuestHelper_PrunePositionList(data.pos)
525 end end
526 end end
531 for cat, list in pairs(data.QuestHelper_Objectives) do
532 for name, data in pairs(list) do
533 data.pos = QuestHelper_PrunePositionList(data.pos)
537 if data.QuestHelper_ZoneTransition then
538 for c, z1list in pairs(data.QuestHelper_ZoneTransition) do
539 for z1, z2list in pairs(z1list) do
540 for z2, poslist in pairs(z2list) do
541 z2list[z2] = QuestHelper_PrunePositionList(poslist)
547 data.QuestHelper_SaveVersion = 4
550 if data.QuestHelper_SaveVersion == 4 then
551 -- Zone transitions have been obsoleted by a bug.
552 data.QuestHelper_ZoneTransition = nil
553 data.QuestHelper_SaveVersion = 5
556 if data.QuestHelper_SaveVersion == 5 then
557 -- For version 6, I'm converting area positions from a continent/zone index pair to a single index.
559 if data.QuestHelper_FlightRoutes then
560 local old_routes = data.QuestHelper_FlightRoutes
561 data.QuestHelper_FlightRoutes = {}
562 for c, value in pairs(old_routes) do
563 data.QuestHelper_FlightRoutes[QuestHelper_IndexLookup[c][0]] = value
567 for faction, level_list in pairs(data.QuestHelper_Quests) do
568 for level, quest_list in pairs(level_list) do
569 for quest_name, quest_data in pairs(quest_list) do
570 QuestHelper_ConvertPositionList(quest_data.pos)
571 if quest_data.item then for name, data in pairs(quest_data.item) do
572 QuestHelper_ConvertPositionList(data.pos)
573 end end
574 if quest_data.alt then for hash, data in pairs(quest_data.alt) do
575 QuestHelper_ConvertPositionList(data.pos)
576 if data.item then for name, data in pairs(data.item) do
577 QuestHelper_ConvertPositionList(data.pos)
578 end end
579 end end
584 for cat, list in pairs(data.QuestHelper_Objectives) do
585 for name, data in pairs(list) do
586 QuestHelper_ConvertPositionList(data.pos)
590 data.QuestHelper_SaveVersion = 6
593 if data.QuestHelper_SaveVersion == 6 then
594 -- Redoing how flightpaths work, previously collected flightpath data is now obsolete.
595 data.QuestHelper_FlightRoutes = {}
597 -- FlightInstructors table should be fine, will leave it.
598 -- Upgrading per-character data is handled in main.lua.
600 -- Also converting factions to numbers, 1 for Alliance, 2 for Horde.
601 local replacement = {}
602 for faction, dat in pairs(data.QuestHelper_Quests) do
603 replacement[QuestHelper_ConvertFaction(faction)] = dat
605 data.QuestHelper_Quests = replacement
607 replacement = {}
608 if data.QuestHelper_FlightInstructors then for faction, dat in pairs(data.QuestHelper_FlightInstructors) do
609 replacement[QuestHelper_ConvertFaction(faction)] = dat
610 end end
611 data.QuestHelper_FlightInstructors = replacement
613 for cat, list in pairs(data.QuestHelper_Objectives) do
614 for name, obj in pairs(list) do
615 if obj.faction then
616 obj.faction = QuestHelper_ConvertFaction(obj.faction)
621 data.QuestHelper_SaveVersion = 7
624 if data.QuestHelper_SaveVersion == 7 then
625 -- It sure took me long enough to discover that I broke vendor objectives.
626 -- their factions were strings and didn't match the number value of QuestHelper.faction
628 for cat, list in pairs(data.QuestHelper_Objectives) do
629 for name, obj in pairs(list) do
630 if type(obj.faction) == "string" then
631 obj.faction = (obj.faction == "Alliance" and 1) or (obj.faction == "Horde" and 2) or nil
636 data.QuestHelper_SaveVersion = 8
639 if data.QuestHelper_SaveVersion == 8 then
640 -- Two things we're doing here
641 -- First, wrath-ize Stormwind coordinates
643 --[[
644 for cat, list in pairs(QuestHelper_Objectives) do
645 for name, obj in pairs(list) do
646 if obj.pos then
647 for i, cpos in pairs(obj.pos) do
648 QuestHelper_ConvertCoordsToWrath(cpos, true)
652 end]] -- okay we're not actually doing this, coordinates are staying native
654 -- Second, split up the entire thing into versions
655 local function versionize(item)
656 --if not item or type(item) ~= "table" then return end -- blue magician doesn't know what the fuck
658 local temp = {}
659 local foundthings = false
660 for k, v in pairs(item) do
661 temp[k] = v
662 foundthings = true
664 if not foundthings then return end -- just to avoid extra keys hanging around in people's tables
666 for key in pairs(item) do
667 item[key] = nil
670 item["unknown on unknown"] = temp
673 versionize(data.QuestHelper_Quests)
674 versionize(data.QuestHelper_Objectives)
675 versionize(data.QuestHelper_FlightInstructors)
676 versionize(data.QuestHelper_FlightRoutes)
678 data.QuestHelper_SaveVersion = 9
681 if data.QuestHelper_SaveVersion == 9 then
682 -- The only thing we're doing here is moving the QuestHelper_ErrorList into QuestHelper_Errors
683 data.QuestHelper_Errors = {}
684 data.QuestHelper_Errors.crashes = {}
686 if data.QuestHelper_ErrorList then
687 for k, v in pairs(data.QuestHelper_ErrorList) do
688 data.QuestHelper_Errors.crashes[k] = v
692 data.QuestHelper_ErrorList = nil
694 data.QuestHelper_SaveVersion = 10
698 function QuestHelper_UpgradeComplete()
699 -- This function deletes everything related to upgrading, as it isn't going to be needed again.
700 built = nil
701 next_index = nil
702 convert_lookup = nil
703 QuestHelper_BuildZoneLookup = nil
704 QuestHelper_ValidPosition = nil
705 QuestHelper_PrunePositionList = nil
706 QuestHelper_ConvertPosition = nil
707 QuestHelper_ConvertPositionList = nil
708 QuestHelper_ConvertFaction = nil
709 QuestHelper_UpgradeDatabase = nil
710 QuestHelper_UpgradeComplete = nil
713 -- These are used to convert coordinates back and forth from "Wrath" to "Native". "Force" is used to convert back and forth from "Wrath" to "BC".
714 -- Both changes the data in-place and returns the data.
715 function QuestHelper_ConvertCoordsToWrath(data, force)
716 if force then
717 if data[1] == 36 then -- Stormwind
718 data[2] = data[2] * 0.77324 + 0.197
719 data[3] = data[3] * 0.77324 + 0.245
720 elseif data[1] == 34 then -- EPL
721 data[2] = data[2] * 0.960 - 0.0254
722 data[3] = data[3] * 0.960 - 0.03532
725 return data
728 function QuestHelper_ConvertCoordsFromWrath(data, force)
729 if force then
730 if data[1] == 36 then -- Stormwind
731 data[2] = (data[2] - 0.197) / 0.77324
732 data[3] = (data[3] - 0.245) / 0.77324
733 elseif data[1] == 34 then -- EPL
734 data[2] = (data[2] + 0.0254) / 0.960
735 data[3] = (data[3] + 0.03532) / 0.960
738 return data
741 local QuestHelper_PrivateServerBlacklist_Find = {
742 "WoWFusion",
743 "WoWgasm",
744 "Egyéb",
745 "Reagens/",
748 local QuestHelper_PrivateServerBlacklist_Exact = {
749 "WarcraftMMO",
750 "TAXI",
751 "GeNiuS",
752 "Columbian Drug Dealer",
753 "PlayBoy Fun Vendor",
754 "Gm Vendor",
755 "Accessories Vendor",
756 "General Goods Vendor",
757 "Party Vendor",
758 "Potion Vendor",
759 "Totem Vendor",
760 "Gm Vendor",
761 "Misc",
762 "Off-Hands Vendor",
763 "Ore Vendor",
764 "Enchanting Vendor",
765 "Gem Vendor",
766 "Fooooood and Drinks!",
767 "I Sell Consumables",
768 "Armor Raid Tier V",
769 "world translate",
770 "Bobby", -- I have no idea if this is an actual private server NPC
771 "Nejeib", -- same
772 "Shaman Set Vendor",
773 "Warrior Set Vendor",
774 "Priest Set Vendor",
775 "Warlock Set Vendor",
776 "Paladin Set Vendor",
777 "Hunter Set Vendor",
778 "Mage Set Vendor", -- yeah yeah this isn't everyone whatever
781 local matchstring = nil
783 function QuestHelper_IsPolluted(input)
784 if not input then input = _G end
786 for version, data in pairs(input.QuestHelper_Objectives) do
787 for cat, name_list in pairs(data) do
788 for name, obj in pairs(name_list) do
789 for k, v in pairs(QuestHelper_PrivateServerBlacklist_Find) do
790 if string.find(name, v) then
791 for _, __ in pairs(obj) do
792 return true -- if there's nothing actually in the object, the player may not have contributed data, he may have just gotten smacked by old corrupted data.
796 for k, v in pairs(QuestHelper_PrivateServerBlacklist_Exact) do
797 if name == v then
798 for _, __ in pairs(obj) do
799 return true -- if there's nothing actually in the object, the player may not have contributed data, he may have just gotten smacked by old corrupted data.