forked from illiath/EnhancedFlightMap
-
Notifications
You must be signed in to change notification settings - Fork 3
/
data.lua
271 lines (232 loc) · 8.25 KB
/
data.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
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
--[[
data.lua
Various data load functions.
]]
-- Function: Define the EFM data variable(s)
function EFM_DefineData()
---------------------------------
-- Global options data definition
if (EFM_MyConf == nil) then
EFM_MyConf = {};
end
if (EFM_MyConf.Timer == nil) then
EFM_MyConf.Timer = true;
end
if (EFM_MyConf.ZoneMarker == nil) then
EFM_MyConf.ZoneMarker = true;
end
if (EFM_MyConf.DruidPaths == nil) then
EFM_MyConf.DruidPaths = true;
end
if (EFM_MyConf.ShowTimerBar == nil) then
EFM_MyConf.ShowTimerBar = false;
end
if (EFM_MyConf.ShrinkStatusBar == nil) then
EFM_MyConf.ShrinkStatusBar = true;
end
if (EFM_MyConf.TimerPosition == nil) then
EFM_MyConf.TimerPosition = -150;
end
if (EFM_MyConf.LoadAll == nil) then
EFM_MyConf.LoadAll = true;
end
if (EFM_MyConf.ContinentOverlay == nil) then
EFM_MyConf.ContinentOverlay = true;
end
if (EFM_MyConf.WorldOverlay == nil) then
EFM_MyConf.WorldOverlay = true;
end
if (EFM_MyConf.UpdateRecorded == nil) then
EFM_MyConf.UpdateRecorded = false;
end
if (EFM_MyConf.ShowLargeBar ~= nil) then
if (EFM_MyConf.TimerSize ~= nil) then
if (EFM_MyConf.ShowLargeBar == true) then
EFM_MyConf.TimerSize = 1.5;
else
EFM_MyConf.TimerSize = 1.0;
end
end
end
EFM_MyConf.ShowLargeBar = nil;
if (EFM_MyConf.TimerSize == nil) then
EFM_MyConf.TimerSize = 1.0;
end
if (EFM_Data == nil) then
EFM_Data = {};
end
if (EFM_WaterNodes == nil) then
EFM_WaterNodes = {};
end
-- Glocal zone location "type"
EFM_LocTypes[1] = "worldMapLoc";
EFM_LocTypes[2] = "wmLoc";
EFM_LocTypes[3] = "zmLoc";
EFM_LocTypes[4] = "fmLoc";
end
-- Function: Import preloaded data into "live" EFM data
function EFM_Data_Import(faction)
local myLocale = GetLocale();
if (EFM_Data == nil) then
EFM_Data = {};
end
if (faction == FACTION_ALLIANCE) then
if (Default_EFM_FlightData[myLocale] ~= nil) then
if (Default_EFM_FlightData[myLocale][FACTION_ALLIANCE] ~= nil) then
if (EFM_Data[FACTION_ALLIANCE] == nil) then
EFM_Data[FACTION_ALLIANCE] = {};
end
EFM_SF_mergeTable(Default_EFM_FlightData[myLocale][FACTION_ALLIANCE], EFM_Data[FACTION_ALLIANCE]);
EFM_Message("announce", format(EFM_MSG_DATALOAD, FACTION_ALLIANCE));
return;
end
end
elseif (faction == FACTION_HORDE) then
if (Default_EFM_FlightData[myLocale] ~= nil) then
if (Default_EFM_FlightData[myLocale][FACTION_HORDE] ~= nil) then
if (EFM_Data[FACTION_HORDE] == nil) then
EFM_Data[FACTION_HORDE] = {};
end
EFM_SF_mergeTable(Default_EFM_FlightData[myLocale][FACTION_HORDE], EFM_Data[FACTION_HORDE]);
EFM_Message("announce", format(EFM_MSG_DATALOAD, FACTION_HORDE));
return;
end
end
else
if (Default_EFM_FlightData[myLocale] ~= nil) then
EFM_SF_mergeTable(Default_EFM_FlightData[myLocale], EFM_Data);
EFM_Message("announce", format(EFM_MSG_DATALOAD, "All Factions"));
return;
end
end
EFM_Shared_DebugMessage("EFM: No data available for locale "..myLocale.."!", Lys_Debug);
end
-- Function: Load times for known flight points from provided data set.
function EFM_Data_ImportTimes(faction)
local myLocale = GetLocale();
if (myLocale == "enGB") then
myLocale = "enUS";
end
if (faction == nil) then
EFM_Shared_DebugMessage("EFM: Faction not given for timers import!", Lys_Debug);
return;
end
if ((faction ~= FACTION_ALLIANCE) and (faction ~= FACTION_HORDE)) then
EFM_Shared_DebugMessage("EFM: Invalid faction given for timers import!", Lys_Debug);
return;
end
if (Default_EFM_FlightData[myLocale] ~= nil) then
for myContinent in pairs(EFM_Data[faction]) do
for myZone in pairs(EFM_Data[faction][myContinent]) do
for myNode in pairs(EFM_Data[faction][myContinent][myZone]) do
if (Default_EFM_FlightData[myLocale][faction] ~= nil) then
if (Default_EFM_FlightData[myLocale][faction][myContinent] ~= nil) then
if (Default_EFM_FlightData[myLocale][faction][myContinent][myZone] ~= nil) then
if (Default_EFM_FlightData[myLocale][faction][myContinent][myZone][myNode] ~= nil) then
if (Default_EFM_FlightData[myLocale][faction][myContinent][myZone][myNode]["timers"] ~= nil) then
if (EFM_Data[faction][myContinent][myZone][myNode]["timers"] == nil) then
EFM_Data[faction][myContinent][myZone][myNode]["timers"] = {};
end
EFM_SF_mergeTable(Default_EFM_FlightData[myLocale][faction][myContinent][myZone][myNode]["timers"], EFM_Data[faction][myContinent][myZone][myNode]["timers"]);
end
end
end
end
end
end
end
end
EFM_Message("announce", format(EFM_MSG_DATALOADTIMERS, faction));
return;
end
EFM_Shared_DebugMessage("EFM: No data available for locale "..myLocale.."!", Lys_Debug);
end
-- Function: Fixup for special blizzard nodes.
function EFM_Data_NodeFixup()
for orgZone, newZone in pairs (EFM_SearchZones) do
EFM_Shared_DebugMessage("EFM: orgZone="..orgZone, Lys_Debug);
EFM_Shared_DebugMessage("EFM: newZone="..newZone, Lys_Debug);
local continentNames, key, val = { GetMapContinents() } ;
for myContinent = 1, table.getn(continentNames) do
local continentName = EFM_Shared_GetContinentName(myContinent);
if (EFM_Data ~= nil) then
-- Fixup Alliance Nodes
if (EFM_Data[FACTION_ALLIANCE] ~= nil) then
if (EFM_Data[FACTION_ALLIANCE][continentName] ~= nil) then
if (EFM_Data[FACTION_ALLIANCE][continentName][orgZone] ~= nil) then
EFM_Data[FACTION_ALLIANCE][continentName][orgZone] = nil;
end
for myZone,myValue in pairs(EFM_Data[FACTION_ALLIANCE][continentName]) do
for mySubZone,mySubValue in pairs(EFM_Data[FACTION_ALLIANCE][continentName][myZone]) do
if (mySubZone == orgZone) then
if (myZone == newZone) then
EFM_Shared_DebugMessage("EFM: Correct Zone!", Lys_Debug);
else
EFM_Shared_DebugMessage("EFM: Incorrect Zone!!!! Deleting invalid entry!", Lys_Debug);
EFM_Data[FACTION_ALLIANCE][continentName][myZone][mySubZone] = nil;
end
end
end
end
end
end
-- Fixup Horde Nodes
if (EFM_Data[FACTION_HORDE] ~= nil) then
if (EFM_Data[FACTION_HORDE][continentName] ~= nil) then
if (EFM_Data[FACTION_HORDE][continentName][orgZone] ~= nil) then
EFM_Data[FACTION_HORDE][continentName][orgZone] = nil;
end
for myZone,myValue in pairs(EFM_Data[FACTION_HORDE][continentName]) do
for mySubZone,mySubValue in pairs(EFM_Data[FACTION_HORDE][continentName][myZone]) do
if (mySubZone == orgZone) then
if (myZone == newZone) then
EFM_Shared_DebugMessage("EFM: Correct Zone!", Lys_Debug);
else
EFM_Shared_DebugMessage("EFM: Incorrect Zone!!!! Deleting invalid entry!", Lys_Debug);
EFM_Data[FACTION_HORDE][continentName][myZone][mySubZone] = nil;
end
end
end
end
end
end
end
end
end
end
-- Function: This function removes invalid nodes from the flight map data entirely.
-- Not sure why this function was removed at one time, but probably because I don't like dangling code... but it needs to stick around *sigh*
function EFM_RemoveInvalidNode(nodeName)
local faction = UnitFactionGroup("player");
for myContinent in pairs(EFM_Data[faction]) do
for myZone in pairs(EFM_Data[faction][myContinent]) do
for myNode in pairs(EFM_Data[faction][myContinent][myZone]) do
if (myNode == nodeName) then
-- Woah, we found the node, delete it! DIE DIE DIE!!!!!
EFM_Data[faction][myContinent][myZone][myNode] = nil;
else
-- Clean the route list
local tempRoutes = {};
local routeList = EFM_Data[faction][myContinent][myZone][myNode]["routes"];
if (routeList) then
for index,value in pairs(routeList) do
if (value ~= nodeName) then
tinsert(tempRoutes, value);
end
end
end
EFM_Data[faction][myContinent][myZone][myNode]["routes"] = tempRoutes;
-- Clean the timer list
if (EFM_Data[faction][myContinent][myZone][myNode]["timers"]) then
for index,value in pairs(EFM_Data[faction][myContinent][myZone][myNode]["timers"]) do
if (value == nodeName) then
EFM_Data[faction][myContinent][myZone][myNode]["timers"][value] = nil;
end
end
end
end
end
end
end
EFM_Shared_DebugMessage(format(EFM_MSG_DELETENODE, nodeName));
end