-
Notifications
You must be signed in to change notification settings - Fork 1
/
GatherZoneTokens.lua
221 lines (202 loc) · 6.92 KB
/
GatherZoneTokens.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
--[[
Gatherer Addon for World of Warcraft(tm).
Version: 3.1.2 (<%codename%>)
Revision: $Id: GatherZoneTokens.lua 697 2008-02-27 18:45:53Z Esamynn $
License:
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program(see GPL.txt); if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Note:
This AddOn's source code is specifically designed to work with
World of Warcraft's interpreted AddOn system.
You have an implicit licence to use this AddOn with these facilities
since that is it's designated purpose as per:
http://www.fsf.org/licensing/licenses/gpl-faq.html#InterpreterIncompat
Functions for converting to and from the locale independent zone tokens
--]]
Gatherer_RegisterRevision("$URL: http://svn.norganna.org/gatherer/trunk/Gatherer/GatherZoneTokens.lua $", "$Rev: 697 $")
-- reference to the Astrolabe mapping library
local Astrolabe = DongleStub(Gatherer.AstrolabeVersion)
local _tr = Gatherer.Locale.Tr
local _trC = Gatherer.Locale.TrClient
local _trL = Gatherer.Locale.TrLocale
local _G = getfenv(0)
local metatable = { __index = _G }
setmetatable( Gatherer.ZoneTokens, metatable )
setfenv(1, Gatherer.ZoneTokens)
local FileNameToTokenMap = {
-- Kalimdor
[1] = {
["Ashenvale"] = "ASHENVALE",
["Aszhara"] = "AZSHARA",
["AzuremystIsle"] = "AZUREMYST_ISLE",
["Barrens"] = "BARRENS",
["BloodmystIsle"] = "BLOODMYST_ISLE",
["Darkshore"] = "DARKSHORE",
["Darnassis"] = "DARNASSUS",
["Desolace"] = "DESOLACE",
["Durotar"] = "DUROTAR",
["Dustwallow"] = "DUSTWALLOW_MARSH",
["Felwood"] = "FELWOOD",
["Feralas"] = "FERALAS",
["Moonglade"] = "MOONGLADE",
["Mulgore"] = "MULGORE",
["Ogrimmar"] = "ORGRIMMAR",
["Silithus"] = "SILITHUS",
["StonetalonMountains"] = "STONETALON_MOUNTAINS",
["Tanaris"] = "TANARIS",
["Teldrassil"] = "TELDRASSIL",
["TheExodar"] = "EXODAR",
["ThousandNeedles"] = "THOUSAND_NEEDLES",
["ThunderBluff"] = "THUNDER_BLUFF",
["UngoroCrater"] = "UNGORO_CRATER",
["Winterspring"] = "WINTERSPRING",
},
-- Eastern Kingdoms
[2] = {
["Alterac"] = "ALTERAC_MOUNTAINS",
["Arathi"] = "ARATHI_HIGHLANDS",
["Badlands"] = "BADLANDS",
["BlastedLands"] = "BLASTED_LANDS",
["BurningSteppes"] = "BURNING_STEPPES",
["DeadwindPass"] = "DEADWIND_PASS",
["DunMorogh"] = "DUN_MOROGH",
["Duskwood"] = "DUSKWOOD",
["EasternPlaguelands"] = "EASTERN_PLAGUELANDS",
["Elwynn"] = "ELWYNN_FOREST",
["EversongWoods"] = "EVERSONG_WOODS",
["Ghostlands"] = "GHOSTLANDS",
["Hilsbrad"] = "HILLSBRAD_FOOTHILLS",
["Hinterlands"] = "HINTERLANDS",
["Ironforge"] = "IRONFORGE",
["LochModan"] = "LOCH_MODAN",
["Redridge"] = "REDRIDGE_MOUNTAINS",
["SearingGorge"] = "SEARING_GORGE",
["SilvermoonCity"] = "SILVERMOON",
["Silverpine"] = "SILVERPINE_FOREST",
["Stormwind"] = "STORMWIND",
["Stranglethorn"] = "STRANGLETHORN_VALE",
["Sunwell"] = "QUEL_DANAS",
["SwampOfSorrows"] = "SWAMP_OF_SORROWS",
["Tirisfal"] = "TIRISFAL_GLADES",
["Undercity"] = "UNDERCITY",
["WesternPlaguelands"] = "WESTERN_PLAGUELANDS",
["Westfall"] = "WESTFALL",
["Wetlands"] = "WETLANDS",
},
-- Outland
[3] = {
["BladesEdgeMountains"] = "BLADES_EDGE_MOUNTAINS",
["Hellfire"] = "HELLFIRE_PENINSULA",
["Nagrand"] = "NAGRAND",
["Netherstorm"] = "NETHERSTORM",
["ShadowmoonValley"] = "SHADOWMOON_VALLEY",
["ShattrathCity"] = "SHATTRATH",
["TerokkarForest"] = "TEROKKAR_FOREST",
["Zangarmarsh"] = "ZANGARMARSH",
},
}
Tokens = {}
TempTokens = {}
local unrecognizedZones = {}
for continent, zones in pairs(Astrolabe.ContinentList) do
local fileTokenMap = FileNameToTokenMap[continent];
local tokenMap = {}
for index, mapName in pairs(zones) do
if not ( fileTokenMap[mapName] ) then
-- use the map name as a temporary token and
-- mark the map name as such
Gatherer.ZoneTokens.TempTokens[mapName] = 1;
tokenMap[index] = mapName;
tokenMap[mapName] = index
table.insert(unrecognizedZones, (select(index, GetMapZones(continent))))
else
tokenMap[index] = fileTokenMap[mapName];
tokenMap[fileTokenMap[mapName]] = index;
end
end
Tokens[continent] = tokenMap
end
if ( next(unrecognizedZones) ) then
-- some zones were unrecognized, warn user
local zoneList = string.join(", ", unpack(unrecognizedZones))
Gatherer.Notifications.AddInfo(_tr("Gatherer was unable to identify the following zones: "..HIGHLIGHT_FONT_COLOR_CODE.."%1|r. \nIf these are new zones, then this is not a problem, and you can continue as normal. \nIf these are not new zones, then remain calm, "..HIGHLIGHT_FONT_COLOR_CODE.."your data IS NOT LOST!|r Your data for these zones is still intact, but you will need to update Gatherer in order to access it. Until then you can continue as normal and any new data you collect will be merged with your old data once you upgrade. \n\n"..HIGHLIGHT_FONT_COLOR_CODE.."Please upgrade Gatherer when convenient. |r", zoneList))
end
unrecognizedZones = nil
BCZones = {
-- Kalimdor
[1] = {
["AzuremystIsle"] = "AZUREMYST_ISLE",
["BloodmystIsle"] = "BLOODMYST_ISLE",
["TheExodar"] = "EXODAR",
},
-- Eastern Kingdoms
[2] = {
["EversongWoods"] = "EVERSONG_WOODS",
["Ghostlands"] = "GHOSTLANDS",
["SilvermoonCity"] = "SILVERMOON",
},
-- Outland
[3] = {
["BladesEdgeMountains"] = "BLADES_EDGE_MOUNTAINS",
["Hellfire"] = "HELLFIRE_PENINSULA",
["Nagrand"] = "NAGRAND",
["Netherstorm"] = "NETHERSTORM",
["ShadowmoonValley"] = "SHADOWMOON_VALLEY",
["ShattrathCity"] = "SHATTRATH",
["TerokkarForest"] = "TEROKKAR_FOREST",
["Zangarmarsh"] = "ZANGARMARSH",
},
}
function GetZoneToken( continent, zone )
if not ( Tokens[continent] ) then
return nil
end
local val = Tokens[continent][zone]
if ( val ) then
if ( type(zone) == "number" ) then
return val
else
return zone
end
end
end
function GetZoneIndex( continent, token )
if not ( Tokens[continent] ) then
return nil
end
local val = Tokens[continent][token]
if ( val ) then
if ( type(token) == "string" ) then
return val
else
return token
end
end
end
function IsTempZoneToken( continent, token )
if ( Gatherer.ZoneTokens.Tokens[continent][token] == nil or Gatherer.ZoneTokens.TempTokens[token] ) then
return true
else
return false
end
end
function GetTokenFromFileName( continent, fileName )
if ( FileNameToTokenMap[continent] ) then
return FileNameToTokenMap[continent][fileName]
else
for i, contData in pairs(FileNameToTokenMap) do
if ( contData[fileName] ) then
return contData[fileName]
end
end
end
end