11 [9]="Dustwallow Marsh",
18 [16]="Stonetalon Mountains",
23 [21]="Thousand Needles",
25 [23]="Un'Goro Crater",
27 {[0]="Eastern Kingdoms",
28 [1]="Alterac Mountains",
29 [2]="Arathi Highlands",
32 [5]="Burning Steppes",
36 [9]="Eastern Plaguelands",
38 [11]="Eversong Woods",
40 [13]="Hillsbrad Foothills",
42 [15]="Isle of Quel'Danas",
44 [17]="Redridge Mountains",
46 [19]="Silvermoon City",
47 [20]="Silverpine Forest",
48 [21]="Stormwind City",
49 [22]="Stranglethorn Vale",
50 [23]="Swamp of Sorrows",
51 [24]="The Hinterlands",
52 [25]="Tirisfal Glades",
54 [27]="Western Plaguelands",
58 [1]="Blade's Edge Mountains",
59 [2]="Hellfire Peninsula",
62 [5]="Shadowmoon Valley",
64 [7]="Terokkar Forest",
67 -- This will be translated to [LOCALE_NAME] = INDEX by QuestHelper_BuildZoneLookup.
68 -- Additionally, [CONT_INDEX][ZONE_INDEX] = INDEX will also be added.
69 QuestHelper_IndexLookup
=
70 {["Hinterlands"] = {42, 2, 24},
71 ["Moonglade"] = {20, 1, 12},
72 ["ThousandNeedles"] = {14, 1, 21},
73 ["Winterspring"] = {19, 1, 24},
74 ["BloodmystIsle"] = {9, 1, 4},
75 ["TerokkarForest"] = {55, 3, 7},
76 ["Arathi"] = {39, 2, 2},
77 ["EversongWoods"] = {41, 2, 11},
78 ["Dustwallow"] = {10, 1, 9},
79 ["Badlands"] = {27, 2, 3},
80 ["Darkshore"] = {16, 1, 5},
81 ["Ogrimmar"] = {1, 1, 14},
82 ["BladesEdgeMountains"] = {54, 3, 1},
83 ["Undercity"] = {45, 2, 26},
84 ["Desolace"] = {4, 1, 7},
85 ["Netherstorm"] = {59, 3, 4},
86 ["Barrens"] = {11, 1, 19},
87 ["Tanaris"] = {8, 1, 17},
88 ["Stormwind"] = {36, 2, 21},
89 ["Zangarmarsh"] = {57, 3, 8},
90 ["Durotar"] = {7, 1, 8},
91 ["Hellfire"] = {56, 3, 2},
92 ["Silithus"] = {5, 1, 15},
93 ["ShattrathCity"] = {60, 3, 6},
94 ["ShadowmoonValley"] = {53, 3, 5},
95 ["SwampOfSorrows"] = {46, 2, 23},
96 ["SilvermoonCity"] = {52, 2, 19},
97 ["Darnassis"] = {21, 1, 6},
98 ["AzuremystIsle"] = {3, 1, 3},
99 ["Elwynn"] = {37, 2, 10},
100 ["Stranglethorn"] = {38, 2, 22},
101 ["EasternPlaguelands"] = {34, 2, 9},
102 ["Duskwood"] = {31, 2, 8},
103 ["WesternPlaguelands"] = {50, 2, 27},
104 ["Westfall"] = {49, 2, 28},
105 ["Ashenvale"] = {2, 1, 1},
106 ["Teldrassil"] = {24, 1, 18},
107 ["Redridge"] = {30, 2, 17},
108 ["UngoroCrater"] = {18, 1, 23},
109 ["Mulgore"] = {22, 1, 13},
110 ["Ironforge"] = {25, 2, 14},
111 ["Felwood"] = {13, 1, 10},
112 ["Hilsbrad"] = {48, 2, 13},
113 ["DeadwindPass"] = {47, 2, 6},
114 ["BurningSteppes"] = {40, 2, 5},
115 ["Ghostlands"] = {44, 2, 12},
116 ["Tirisfal"] = {43, 2, 25},
117 ["TheExodar"] = {12, 1, 20},
118 ["Wetlands"] = {51, 2, 29},
119 ["SearingGorge"] = {32, 2, 18},
120 ["BlastedLands"] = {33, 2, 4},
121 ["Silverpine"] = {35, 2, 20},
122 ["LochModan"] = {29, 2, 16},
123 ["Feralas"] = {17, 1, 11},
124 ["DunMorogh"] = {28, 2, 7},
125 ["Alterac"] = {26, 2, 1},
126 ["ThunderBluff"] = {23, 1, 22},
127 ["Aszhara"] = {15, 1, 2},
128 ["StonetalonMountains"] = {6, 1, 16},
129 ["Nagrand"] = {58, 3, 3},
130 ["Kalimdor"] = {61, 1, 0},
131 ["Azeroth"] = {62, 2, 0},
132 ["Expansion01"] = {63, 3, 0},
133 ["Sunwell"] = {64, 2, 15}}
136 for i
, j
in pairs(QuestHelper_IndexLookup
) do next_index
= math
.max(next_index
, j
[1]+1) end
138 -- Maps zone names and indexes to a two element array, containing zone index a continent/zone
139 QuestHelper_ZoneLookup
= {}
141 -- Maps indexes to zone names.
142 QuestHelper_NameLookup
= {}
146 function QuestHelper_BuildZoneLookup()
147 if built
then return end
150 if GetMapContinents
and GetMapZones
then
151 -- Called from inside the WoW client.
153 local original_lookup
, original_zones
= QuestHelper_IndexLookup
, QuestHelper_Zones
154 QuestHelper_IndexLookup
= {}
155 QuestHelper_Zones
= {}
157 for c
, cname
in pairs({GetMapContinents()}) do
158 QuestHelper_Zones
[c
] = {}
159 for z
, zname
in pairs({[0] = cname
, GetMapZones(c
)}) do
161 local base_name
= GetMapInfo()
163 local index
= original_lookup
[base_name
] and original_lookup
[base_name
][1]
166 QuestHelper
:TextOut(QHFormat("ALTERED_INDEX", base_name
, next_index
, c
, z
))
167 next_index
= next_index
+ 1
169 if QuestHelper_Locale
== "enUS" then
170 if original_lookup
[base_name
][2] ~= c
or original_lookup
[base_name
][3] ~= z
then
171 QuestHelper
:TextOut(QHFormat("ALTERED_INDEX", base_name
, index
, c
, z
))
174 if original_zones
[c
][z
] ~= zname
then
175 QuestHelper
:TextOut(QHFormat("ALTERED_ZONE", c
, z
, zname
, original_zones
[c
][z
] or "missing"))
180 if not QuestHelper_IndexLookup
[c
] then QuestHelper_IndexLookup
[c
] = {} end
181 QuestHelper_IndexLookup
[c
][z
] = index
182 QuestHelper_IndexLookup
[zname
] = index
184 QuestHelper_NameLookup
[index
] = zname
186 QuestHelper_ZoneLookup
[zname
] = pair
187 QuestHelper_ZoneLookup
[index
] = pair
189 QuestHelper_Zones
[c
][z
] = zname
194 -- Called from some lua script.
195 local original_lookup
= QuestHelper_IndexLookup
196 QuestHelper_IndexLookup
= {}
198 for base_name
, i
in pairs(original_lookup
) do
200 local pair
= {i
[2], i
[3]}
201 local name
= QuestHelper_Zones
[pair
[1]]
[pair
[2]]
203 assert(index
and name
)
205 if not QuestHelper_IndexLookup
[pair
[1]]
then QuestHelper_IndexLookup
[pair
[1]]
= {} end
206 QuestHelper_IndexLookup
[pair
[1]]
[pair
[2]]
= index
207 QuestHelper_IndexLookup
[name
] = index
209 QuestHelper_NameLookup
[index
] = name
211 QuestHelper_ZoneLookup
[name
] = pair
212 QuestHelper_ZoneLookup
[index
] = pair
217 local convert_lookup
=
218 {{2, 15, 3, 9, 16, 21, 4, 7, 10, 13, 17, 20, 22, 1, 5, 6, 8, 24, 11, 12, 14, 23, 18, 19},
219 {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},
220 {54, 56, 58, 59, 53, 60, 55, 57}}
222 function QuestHelper_ValidPosition(c
, z
, x
, y
)
223 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
226 function QuestHelper_PrunePositionList(list
)
227 if type(list
) ~= "table" then
234 if QuestHelper_ValidPosition(unpack(list
[i
])) and type(pos
[5]) == "number" and pos
[5] >= 1 then
237 local rem
= table.remove(list
, i
)
241 return #list
> 0 and list
or nil
244 local function QuestHelper_ConvertPosition(pos
)
245 pos
[2] = convert_lookup
[pos
[1]]
[pos
[2]]
249 local function QuestHelper_ConvertPositionList(list
)
251 for i
, pos
in pairs(list
) do
252 QuestHelper_ConvertPosition(pos
)
257 local function QuestHelper_ConvertFaction(locale
, faction
)
258 if faction
== 1 or faction
== "Alliance" or faction
== FACTION_ALLIANCE
then return 1
259 elseif faction
== 2 or faction
== "Horde" or faction
== FACTION_HORDE
then return 2
261 if locale
== "enUS" then
262 if faction
== "Alliance" then return 1
263 elseif faction
== "Horde" then return 2 end
264 elseif locale
== "frFR" then
265 if faction
== "Alliance" then return 1
266 elseif faction
== "Horde" then return 2 end
267 elseif locale
== "deDE" then
268 if faction
== "Alliance" then return 1
269 elseif faction
== "Horde" then return 2 end
272 assert(false, "Unknown faction: "..locale
.."/'"..faction
.."'")
276 function QuestHelper_UpgradeDatabase(data
)
277 if data
.QuestHelper_SaveVersion
== 1 then
279 -- Reputation objectives weren't parsed correctly before.
280 if data
.QuestHelper_Objectives
["reputation"] then
281 for faction
, objective
in pairs(data
.QuestHelper_Objectives
["reputation"]) do
282 local real_faction
= string.find(faction
, "%s*(.+)%s*:%s*") or faction
283 if faction
~= real_faction
then
284 data
.QuestHelper_Objectives
["reputation"][real_faction
] = data
.QuestHelper_Objectives
["reputation"][faction
]
285 data
.QuestHelper_Objectives
["reputation"][faction
] = nil
290 -- Items that wern't in the local cache when I read the quest log ended up with empty names.
291 if data
.QuestHelper_Objectives
["item"] then
292 data
.QuestHelper_Objectives
["item"][" "] = nil
295 data
.QuestHelper_SaveVersion
= 2
298 if data
.QuestHelper_SaveVersion
== 2 then
300 -- The hashes for the quests were wrong. Damnit!
301 for faction
, level_list
in pairs(data
.QuestHelper_Quests
) do
302 for level
, quest_list
in pairs(level_list
) do
303 for quest_name
, quest_data
in pairs(quest_list
) do
304 quest_data
.hash
= nil
310 -- None of the information I collected about quest items previously can be trusted.
311 -- I also didn't properly mark quest items as such, so I'll have to remove the information for non
314 if data
.QuestHelper_Objectives
["item"] then
315 for item
, item_data
in pairs(data
.QuestHelper_Objectives
["item"]) do
316 -- I'll remerge the bad data later if I find out its not used solely for quests.
317 item_data
.bad_pos
= item_data
.bad_pos
or item_data
.pos
318 item_data
.bad_drop
= item_data
.bad_drop
or item_data
.drop
322 -- In the future i'll delete the bad_x data.
323 -- When I do, either just delete it, or of all the monsters or positions match the monsters and positions of the
324 -- quest, merge them into that.
328 data
.QuestHelper_SaveVersion
= 3
331 if data
.QuestHelper_SaveVersion
== 3 then
332 -- We'll go through this and make sure all the position lists are correct.
333 for faction
, level_list
in pairs(data
.QuestHelper_Quests
) do
334 for level
, quest_list
in pairs(level_list
) do
335 for quest_name
, quest_data
in pairs(quest_list
) do
336 quest_data
.pos
= QuestHelper_PrunePositionList(quest_data
.pos
)
337 if quest_data
.item
then for name
, data
in pairs(quest_data
.item
) do
338 data
.pos
= QuestHelper_PrunePositionList(data
.pos
)
340 if quest_data
.alt
then for hash
, data
in pairs(quest_data
.alt
) do
341 data
.pos
= QuestHelper_PrunePositionList(data
.pos
)
342 if data
.item
then for name
, data
in pairs(data
.item
) do
343 data
.pos
= QuestHelper_PrunePositionList(data
.pos
)
350 for cat
, list
in pairs(data
.QuestHelper_Objectives
) do
351 for name
, data
in pairs(list
) do
352 data
.pos
= QuestHelper_PrunePositionList(data
.pos
)
356 if data
.QuestHelper_ZoneTransition
then
357 for c
, z1list
in pairs(data
.QuestHelper_ZoneTransition
) do
358 for z1
, z2list
in pairs(z1list
) do
359 for z2
, poslist
in pairs(z2list
) do
360 z2list
[z2
] = QuestHelper_PrunePositionList(poslist
)
366 data
.QuestHelper_SaveVersion
= 4
369 if data
.QuestHelper_SaveVersion
== 4 then
370 -- Zone transitions have been obsoleted by a bug.
371 data
.QuestHelper_ZoneTransition
= nil
372 data
.QuestHelper_SaveVersion
= 5
375 if data
.QuestHelper_SaveVersion
== 5 then
376 -- For version 6, I'm converting area positions from a continent/zone index pair to a single index.
378 if data
.QuestHelper_FlightRoutes
then
379 local old_routes
= data
.QuestHelper_FlightRoutes
380 data
.QuestHelper_FlightRoutes
= {}
381 for c
, value
in pairs(old_routes
) do
382 data
.QuestHelper_FlightRoutes
[QuestHelper_IndexLookup
[c
][0]]
= value
386 for faction
, level_list
in pairs(data
.QuestHelper_Quests
) do
387 for level
, quest_list
in pairs(level_list
) do
388 for quest_name
, quest_data
in pairs(quest_list
) do
389 QuestHelper_ConvertPositionList(quest_data
.pos
)
390 if quest_data
.item
then for name
, data
in pairs(quest_data
.item
) do
391 QuestHelper_ConvertPositionList(data
.pos
)
393 if quest_data
.alt
then for hash
, data
in pairs(quest_data
.alt
) do
394 QuestHelper_ConvertPositionList(data
.pos
)
395 if data
.item
then for name
, data
in pairs(data
.item
) do
396 QuestHelper_ConvertPositionList(data
.pos
)
403 for cat
, list
in pairs(data
.QuestHelper_Objectives
) do
404 for name
, data
in pairs(list
) do
405 QuestHelper_ConvertPositionList(data
.pos
)
409 data
.QuestHelper_SaveVersion
= 6
412 if data
.QuestHelper_SaveVersion
== 6 then
413 -- Redoing how flightpaths work, previously collected flightpath data is now obsolete.
414 data
.QuestHelper_FlightRoutes
= {}
416 -- FlightInstructors table should be fine, will leave it.
417 -- Upgrading per-character data is handled in main.lua.
419 -- Also converting factions to numbers, 1 for Alliance, 2 for Horde.
420 local replacement
= {}
421 for faction
, dat
in pairs(data
.QuestHelper_Quests
) do
422 replacement
[QuestHelper_ConvertFaction(data
.QuestHelper_Locale
, faction
)] = dat
424 data
.QuestHelper_Quests
= replacement
427 if data
.QuestHelper_FlightInstructors
then for faction
, dat
in pairs(data
.QuestHelper_FlightInstructors
) do
428 replacement
[QuestHelper_ConvertFaction(data
.QuestHelper_Locale
, faction
)] = dat
430 data
.QuestHelper_FlightInstructors
= replacement
432 for cat
, list
in pairs(data
.QuestHelper_Objectives
) do
433 for name
, obj
in pairs(list
) do
435 obj
.faction
= QuestHelper_ConvertFaction(data
.QuestHelper_Locale
, obj
.faction
)
440 data
.QuestHelper_SaveVersion
= 7
444 function QuestHelper_UpgradeComplete()
445 -- This function deletes everything related to upgrading, as it isn't going to be needed again.
449 QuestHelper_BuildZoneLookup
= nil
450 QuestHelper_ValidPosition
= nil
451 QuestHelper_PrunePositionList
= nil
452 QuestHelper_ConvertPosition
= nil
453 QuestHelper_ConvertPositionList
= nil
454 QuestHelper_ConvertFaction
= nil
455 QuestHelper_UpgradeDatabase
= nil
456 QuestHelper_UpgradeComplete
= nil