-
Notifications
You must be signed in to change notification settings - Fork 10
/
Developer.lua
164 lines (138 loc) · 4.62 KB
/
Developer.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
--[[----------------------------------------------------------------------------
LiteMount/Developer.lua
Copyright 2011 Mike Battersby
----------------------------------------------------------------------------]]--
local _, LM = ...
local C_Spell = LM.C_Spell or C_Spell
local MAX_SPELL_ID = 500000
LM.Developer = CreateFrame("Frame")
function LM.Developer:Initialize()
self.usableOnSurface = self.usableOnSurface or {}
self.usableUnderWater = self.usableUnderWater or {}
end
local function CoPartialUpdate(t)
local i = #t + 1
while true do
if i > MAX_SPELL_ID then return end
t[i] = C_Spell.IsSpellUsable(i)
if i % 50000 == 0 then
LM.Print(i)
coroutine.yield()
end
i = i + 1
end
end
function LM.Developer:CompareUsability()
for i = 1, #self.usableOnSurface do
if self.usableOnSurface[i] ~= self.usableUnderWater[i] then
LM.Print("Found a spell with a difference!")
LM.Print(i .. ": " .. C_Spell.GetSpellName(i))
LM.Print("")
end
if i % 50000 == 0 then
LM.Print(i)
coroutine.yield()
end
end
end
function LM.Developer:OnUpdate(elapsed)
if not self.thread or coroutine.status(self.thread) == "dead" then
self:SetScript("OnUpdate", nil)
else
coroutine.resume(self.thread)
end
end
function LM.Developer:UpdateUsability()
if GetMirrorTimerInfo(2) == "BREATH" then
LM.Print("Updating underwater usability table.")
wipe(self.usableUnderWater)
self.thread = coroutine.create(
function ()
CoPartialUpdate(self.usableUnderWater)
end)
elseif IsSwimming() then
LM.Print("Updating on surface usability table.")
wipe(self.usableOnSurface)
self.thread = coroutine.create(
function ()
CoPartialUpdate(self.usableOnSurface)
end)
else
LM.Print("Comparing usability.")
self.thread = coroutine.create(
function ()
self:CompareUsability()
end)
end
self:SetScript("OnUpdate", self.OnUpdate)
end
function LM.Developer:Profile(n)
self.profileCount = self.profileCount or 0
if n == nil then
LM.Print("Profile count = " .. self.profileCount)
elseif n == 0 then
self.profileCount = 0
else
self.profileCount = self.profileCount + n
end
end
function LM.Developer:ExportMockData()
LiteMountDB.data = table.wipe(LiteMountDB.data or {})
local data = LiteMountDB.data
data.GetMountInfoByID = {}
data.GetMountInfoExtraByID = {}
data.GetSpellInfo = {}
for name, spellID in pairs(LM.SPELL) do
data.GetSpellInfo[spellID] = C_Spell.GetSpellInfo(spellID)
end
for _,mountID in ipairs(C_MountJournal.GetMountIDs()) do
data.GetMountInfoByID[mountID] = { C_MountJournal.GetMountInfoByID(mountID) }
data.GetMountInfoExtraByID[mountID] = { C_MountJournal.GetMountInfoExtraByID(mountID) }
local spellID = select(2, C_MountJournal.GetMountInfoByID(mountID))
data.GetSpellInfo[spellID] = C_Spell.GetSpellInfo(spellID)
end
data.GetItemInfo = {}
data.GetItemSpell = {}
for name, itemID in pairs(LM.ITEM) do
data.GetItemInfo[itemID] = { C_Item.GetItemInfo(itemID) }
local spellName, spellID = C_Item.GetItemSpell(itemID)
if spellName then
data.GetItemSpell[itemID] = { spellName, spellID }
data.GetSpellInfo[spellID] = C_Spell.GetSpellInfo(spellID)
end
end
data.GetMapInfo = {}
data.GetMapGroupID = {}
data.IsMapValidForNavBarDropdown = {}
for i = 1, 10000 do
local info = C_Map.GetMapInfo(i)
if info then
data.GetMapInfo[i] = info
data.GetMapGroupID[i] = C_Map.GetMapGroupID(i)
if C_Map.IsMapValidForNavBarDropdown(i) then
data.IsMapValidForNavBarDropdown[i] = true
end
end
end
data.GetClassInfo = {}
local classIndex = 1
while true do
local info = { GetClassInfo(classIndex) }
if info[1] then
data.GetClassInfo[classIndex] = info
classIndex = classIndex + 1
else
break
end
end
data.GetRaceInfo = {}
for i = 1, 100 do
data.GetRaceInfo[i] = C_CreatureInfo.GetRaceInfo(i)
end
data.GlobalStrings = {}
for k,v in pairs(_G) do
if type(k) == 'string' and type(v) == 'string' then
data.GlobalStrings[k] = v
end
end
end