forked from Questie/Questie
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcli.lua
227 lines (196 loc) · 6.55 KB
/
cli.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
WOW_PROJECT_ID = 2
WOW_PROJECT_CLASSIC = 2
WOW_PROJECT_BURNING_CRUSADE_CLASSIC = 5
WOW_PROJECT_MAINLINE = 1
tremove = table.remove
tinsert = table.insert
coroutine.yield = function() end -- no need to yield in the cli (TODO: maybe find a less hacky fix)
mod = function(a, b)
return a % b
end
bit = require("bit32")
GetBuildInfo = function()
return "2.5.1", "38644", "May 11 2021", "20501"
end
GetAddOnInfo = function()
return "Questie", "|cFFFFFFFFQuestie|r|cFF00FF00 v6.3.9 (TBC B2)|r", "A standalone Classic QuestHelper", true, "INSECURE", false
end
GetAddOnMetadata = function()
return "6.6.0"
end
GetTime = function()
return os.time(os.date("!*t")) - 1616930000 -- convert unix time to wow time (actually accurate)
end
UnitFactionGroup = function()
return arg[1] or "Horde"
end
UnitClass = function()
return "Druid", "DRUID", 11
end
GetLocale = function()
return "enUS"
end
LibStub = function()
return {["NewAddon"] = function() return {} end}
end
CreateFrame = function()
return {}
end
C_QuestLog = {}
C_Timer = {
After = function(_, f)
f()
end,
NewTicker = function(_, f, times)
if times then
for _=1,times do
f()
end
else
-- hack
local finished = false
QuestieLoader:ImportModule("DBCompiler").ticker = {
Cancel = function()
finished = true
end
}
while not finished do
f()
end
end
end
}
-- WoW addon namespace
local addonName = "Questie"
local addonTable = {}
local function loadTOC(file)
local rfile = io.open(file, "r")
for line in rfile:lines() do
if string.len(line) > 1 and string.byte(line, 1) ~= 35 then
line = line:gsub("\\", "/")
local r
local chunck = loadfile(line)
if chunck then
r = pcall(chunck, addonName, addonTable)
end
if r then
--print("Loaded " .. line)
else
--print("Error loading " .. line .. ": " .. e)
end
end
end
end
local function _CheckClassicDatabase()
print("Compiling Classic database...")
loadTOC("Questie-Classic.toc")
function Questie:Debug(...)
--print(...)
end
function Questie:Error(text, ...)
io.stderr:write(tostring(text) .. "\n")
end
function Questie:Warning(text, ...)
io.stderr:write(tostring(text) .. "\n")
end
Questie.db = {
char = {
showEventQuests = false
},
global = {}
}
QuestieConfig = {}
local QuestieDB = QuestieLoader:ImportModule("QuestieDB")
local QuestieCorrections = QuestieLoader:ImportModule("QuestieCorrections")
local l10n = QuestieLoader:ImportModule("l10n")
print("\124cFF4DDBFF [1/7] " .. l10n("Loading database") .. "...")
QuestieDB.npcData = loadstring(QuestieDB.npcData)
QuestieDB.npcData = QuestieDB.npcData()
QuestieDB.objectData = loadstring(QuestieDB.objectData)
QuestieDB.objectData = QuestieDB.objectData()
QuestieDB.questData = loadstring(QuestieDB.questData)
QuestieDB.questData = QuestieDB.questData()
QuestieDB.itemData = loadstring(QuestieDB.itemData)
QuestieDB.itemData = QuestieDB.itemData()
print("\124cFF4DDBFF [2/7] " .. l10n("Applying database corrections") .. "...")
QuestieLoader:ImportModule("QuestieFramePool"):SetIcons()
QuestieLoader:ImportModule("ZoneDB"):Initialize()
QuestieCorrections:Initialize({
["npcData"] = QuestieDB.npcData,
["objectData"] = QuestieDB.objectData,
["itemData"] = QuestieDB.itemData,
["questData"] = QuestieDB.questData
})
local QuestieDBCompiler = QuestieLoader:ImportModule("DBCompiler")
QuestieDBCompiler:Compile(function() end)
print("Validating objects...")
QuestieDBCompiler:ValidateObjects()
print("Validating items...")
QuestieDBCompiler:ValidateItems()
print("Validating NPCs...")
QuestieDBCompiler:ValidateNPCs()
print("Validating quests...")
QuestieDBCompiler:ValidateQuests()
print("Classic database compiled successfully\n")
end
_CheckClassicDatabase()
Questie = nil -- Reset for second test
local function _CheckTBCDatabase()
print("Compiling TBC database...")
WOW_PROJECT_ID = 5
loadTOC("Questie-BCC.toc")
function Questie:Debug(...)
--print(...)
end
function Questie:Error(text, ...)
io.stderr:write(tostring(text) .. "\n")
end
function Questie:Warning(text, ...)
io.stderr:write(tostring(text) .. "\n")
end
Questie.db = {
char = {
showEventQuests = false
},
global = {}
}
QuestieConfig = {}
local QuestieDB = QuestieLoader:ImportModule("QuestieDB")
local QuestieCorrections = QuestieLoader:ImportModule("QuestieCorrections")
local l10n = QuestieLoader:ImportModule("l10n")
print("\124cFF4DDBFF [1/7] " .. l10n("Loading database") .. "...")
-- Classic fields need to be filled, because we only load the database and not all Questie files
QuestieDB.npcData = {}
QuestieDB.objectData = {}
QuestieDB.questData = {}
QuestieDB.itemData = {}
QuestieDB.npcDataTBC = loadstring(QuestieDB.npcDataTBC)
QuestieDB.npcDataTBC = QuestieDB.npcDataTBC()
QuestieDB.objectDataTBC = loadstring(QuestieDB.objectDataTBC)
QuestieDB.objectDataTBC = QuestieDB.objectDataTBC()
QuestieDB.questDataTBC = loadstring(QuestieDB.questDataTBC)
QuestieDB.questDataTBC = QuestieDB.questDataTBC()
QuestieDB.itemDataTBC = loadstring(QuestieDB.itemDataTBC)
QuestieDB.itemDataTBC = QuestieDB.itemDataTBC()
print("\124cFF4DDBFF [2/7] " .. l10n("Applying database corrections") .. "...")
QuestieLoader:ImportModule("QuestieFramePool"):SetIcons()
QuestieLoader:ImportModule("ZoneDB"):Initialize()
QuestieCorrections:Initialize({
["npcData"] = QuestieDB.npcDataTBC,
["objectData"] = QuestieDB.objectDataTBC,
["itemData"] = QuestieDB.itemDataTBC,
["questData"] = QuestieDB.questDataTBC
})
local QuestieDBCompiler = QuestieLoader:ImportModule("DBCompiler")
QuestieDBCompiler:Compile(function() end)
print("Validating objects...")
QuestieDBCompiler:ValidateObjects()
print("Validating items...")
QuestieDBCompiler:ValidateItems()
print("Validating NPCs...")
QuestieDBCompiler:ValidateNPCs()
print("Validating quests...")
QuestieDBCompiler:ValidateQuests()
print("TBC database compiled successfully")
end
_CheckTBCDatabase()