-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate.lua
More file actions
229 lines (173 loc) · 4.85 KB
/
update.lua
File metadata and controls
229 lines (173 loc) · 4.85 KB
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
--I do not play alliance, so i have no alliance data.
local oldGetTaxiMapID = GetTaxiMapID
local inflight,conversion,data,extra, dataFaction
local playerfaction
local L_destparse = ", (.+)" -- removes main zone name, leaving only subzone
function ShortenName(name) -- shorten name to lighten saved vars and display
return gsub(name, L_destparse, "")
end
local paths = {}
local function shrink(value)
--shrink the values, just enough.
return tonumber(string.format("%.4f", value)) * 10000
end
local function GetTaxiPositionID(i)
local x, y = TaxiNodePosition(i)
--by replacing all saved
--variable names with this ID,
--you can do away with all
--language specific localization
--**all Horde data has been converted
return tonumber(shrink(x) .. shrink(y))
end
local names = {}
--these lists are populated, as you visit each continent.
local ids = {}
local function GetNameFromPositionID(id)
return names[id]
end
local function GetPositionIDFromName(name)
return ids[name]
end
--previous 2 functions
--are quick reference
--to help convert names
--into ids
local once
local function ReversFill()
-- most paths take the same
--amount of time going both
--ways, so this bit will
--reverse fill in the data
--created by the second section below
--note to self: if all paths
--take same amount of time
--going both ways, could allow
--for less stored data, if
--all calls are weighted
--the right way...
local Flight = dataFaction
if not Flight then
-- return
end
local count = 0
for continent, paths in pairs(Flight) do
for start, destinations in pairs(paths) do
for destination, _time in pairs(destinations) do
if _time ~= 0 then
local _reverse = paths[destination]
if _reverse[start] and _reverse[start] == 0 then
_reverse[start] = _time
count = count + 1
end
end
end
end
end
extra[playerfaction] = Flight
if count ~= 0 then
print(count) --neat to know how many times were reverse filled
end
end
function GenerateConversionList()
--makes full id to name list
--for conversion of user
--submitted data.
conversion = conversion or {}
conversion[playerfaction] = conversion[playerfaction] or {}
local playerfaction = conversion[playerfaction]
local id = oldGetTaxiMapID()
--allows you to store data
--on a per continent basis
if playerfaction[id] then
return id
end
playerfaction[id] = playerfaction[id] or {}
local paths = playerfaction[id]
local num = NumTaxiNodes()
for i = 1, num, 1 do
local name, useable = ShortenName(TaxiNodeName(i))
if useable == 1 then
local id = GetTaxiPositionID(i)
paths[name] = id
end
end
return id
end
local internalCall
--as you visit a flight master
--on each continent, this function
--will convert all name based
--variables into IDs, automatically
function GetStuff()
playerfaction = UnitFactionGroup("player")
if not InFlightVars then
return GetStuff()
end
inflight = InFlightVars
IFU_Conversion = IFU_Conversion or {}
conversion = IFU_Conversion
IFU_Data = IFU_Data or {}
data = IFU_Data
IFU_Extra = IFU_Extra or {}
extra = IFU_Extra
data[playerfaction] = data[playerfaction] or {}
dataFaction = data[playerfaction]
GenerateConversionList()
ReversFill()
--i'm good at making spaghetti code...
if internalCall then
return --hate this, but simple
end
local faction = dataFaction
local id = oldGetTaxiMapID()
--allows you to store data
--on a per continent basis
if faction[id] then
-- return id --if we've already collected data for this continent, don't do it again.
end
faction[id] = faction[id] or {}
local paths = faction[id]
internalCall = true --prevents looped function calling, don't like it, but simple enough
local num = NumTaxiNodes()
internalCall = nil
for i = 1, num, 1 do
local name, useable = ShortenName(TaxiNodeName(i))
if useable == 1 then
local id = GetTaxiPositionID(i)
names[id] = name
--this fills in the data
--for the two above functions
--that let us convert from
--names to id, and back.
ids[name] = id
paths[id] = {} -- path time list
end
end
--fill in all possible destinations for each path
for source, destinationList in pairs(paths) do
for i, b in pairs(paths) do
if i ~= source then
destinationList[i] = 0
end
end
end
local Flight = inflight[playerfaction]
--fill in known times from name based saved variables
for source, destinationList in pairs(paths) do
sourceName = GetNameFromPositionID(source)
if Flight[sourceName] then
for destination, _time in pairs(Flight[sourceName]) do
destinationID = GetPositionIDFromName(destination)
if destinationList[destinationID] then
destinationList[destinationID] = _time
end
end
end
end
return id
--]]
end
GetTaxiMapID = GetStuff
--one function fires for the FlightMap, and the other for the TaxiRouteMap
hooksecurefunc("NumTaxiNodes", GetStuff)