forked from Questie/Questie
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli.lua
More file actions
329 lines (276 loc) · 9.62 KB
/
cli.lua
File metadata and controls
329 lines (276 loc) · 9.62 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
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
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
WOW_PROJECT_ID = 2
WOW_PROJECT_CLASSIC = 2
WOW_PROJECT_BURNING_CRUSADE_CLASSIC = 5
WOW_PROJECT_WRATH_CLASSIC = 11
WOW_PROJECT_MAINLINE = 1
QUEST_MONSTERS_KILLED = "QUEST_MONSTERS_KILLED"
QUEST_ITEMS_NEEDED = "QUEST_ITEMS_NEEDED"
QUEST_OBJECTS_FOUND = "QUEST_OBJECTS_FOUND"
ERR_QUEST_ACCEPTED_S = "ERR_QUEST_ACCEPTED_S"
ERR_QUEST_COMPLETE_S = "ERR_QUEST_COMPLETE_S"
tremove = table.remove
tinsert = table.insert
local _EmptyDummyFunction = function() end
local _TableDummyFunction = function() return {} end
coroutine.yield = _EmptyDummyFunction -- 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")
hooksecurefunc = _EmptyDummyFunction
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
IsAddOnLoaded = function() return false, true end
UnitFactionGroup = function()
return arg[1] or "Horde"
end
UnitClass = function()
return "Druid", "DRUID", 11
end
GetLocale = function()
return "enUS"
end
GetQuestGreenRange = function()
return 10
end
UnitName = function()
return "QuestieNPC"
end
LibStub = {
NewLibrary = _EmptyDummyFunction,
GetLibrary = _TableDummyFunction,
}
setmetatable(LibStub, { __call = function(_, ...)
return {NewAddon = _TableDummyFunction, New = _TableDummyFunction }
end})
StaticPopupDialogs = {}
CreateFrame = function()
return {
Show = _EmptyDummyFunction,
SetScript = _EmptyDummyFunction,
RegisterEvent = _EmptyDummyFunction,
}
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
}
C_Seasons = {
HasActiveSeason = function() return false end,
}
ItemRefTooltip = {
SetHyperlink = _EmptyDummyFunction,
IsShown = _EmptyDummyFunction,
SetOwner = _EmptyDummyFunction,
Show = _EmptyDummyFunction,
Hide = _EmptyDummyFunction,
AddLine = _EmptyDummyFunction,
HookScript = _EmptyDummyFunction,
}
C_Map = {}
-- WoW addon namespace
local addonName = "Questie"
local addonTable = {}
local function print(text)
io.stderr:write(tostring(text) .. "\n")
end
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 and (not string.find(line, ".xml")) then
line = line:gsub("\\", "/")
line = line:gsub("%s+", "")
local pcallResult, errorMessage
local chunck = loadfile(line)
if chunck then
pcallResult, errorMessage = pcall(chunck, addonName, addonTable)
end
if pcallResult then
--print("Loaded " .. line)
else
if errorMessage then
print("Error loading " .. line .. ": " .. errorMessage)
else
print("Error loading " .. line .. " - No errorMessage")
end
end
end
end
end
local function _Debug(_, ...)
--print(...)
end
local function _ErrorOrWarning(_, text, ...)
io.stderr:write(tostring(text) .. "\n")
end
local function _CheckClassicDatabase()
GetBuildInfo = function()
return "1.14.3", "44403", "Jun 27 2022", 11403
end
print("\n\27[36mCompiling Classic database...\27[0m")
loadTOC("Questie-Classic.toc")
Questie.Debug = _Debug
Questie.Error = _ErrorOrWarning
Questie.Warning = _ErrorOrWarning
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.objectData = loadstring(QuestieDB.objectData)()
QuestieDB.questData = loadstring(QuestieDB.questData)()
QuestieDB.itemData = loadstring(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")
Questie.db.global.debugEnabled = true
QuestieDBCompiler:Compile(function() end)
print("\n\27[36mValidating objects...\27[0m")
QuestieDBCompiler:ValidateObjects()
print("\n\27[36mValidating items...\27[0m")
QuestieDBCompiler:ValidateItems()
print("\n\27[36mValidating NPCs...\27[0m")
QuestieDBCompiler:ValidateNPCs()
print("\n\27[36mValidating quests...\27[0m")
QuestieDBCompiler:ValidateQuests()
print("\n\27[32mClassic database compiled successfully\27[0m")
end
_CheckClassicDatabase()
Questie = nil -- Reset for second test
local function _CheckTBCDatabase()
GetBuildInfo = function()
return "2.5.1", "38644", "May 11 2021", 20501
end
WOW_PROJECT_ID = 5
print("\n\27[36mCompiling TBC database...\27[0m")
loadTOC("Questie-BCC.toc")
Questie.Debug = _Debug
Questie.Error = _ErrorOrWarning
Questie.Warning = _ErrorOrWarning
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.objectData = loadstring(QuestieDB.objectData)()
QuestieDB.questData = loadstring(QuestieDB.questData)()
QuestieDB.itemData = loadstring(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("\n\27[36mValidating objects...\27[0m")
QuestieDBCompiler:ValidateObjects()
print("\n\27[36mValidating items...\27[0m")
QuestieDBCompiler:ValidateItems()
print("\n\27[36mValidating NPCs...\27[0m")
QuestieDBCompiler:ValidateNPCs()
print("\n\27[36mValidating quests...\27[0m")
QuestieDBCompiler:ValidateQuests()
print("\n\27[32mTBC database compiled successfully\27[0m\n")
end
_CheckTBCDatabase()
Questie = nil -- Reset for thrid test
local function _CheckWotlkDatabase()
GetBuildInfo = function()
return "3.4.0", "44644", "Jun 12 2022", 30400
end
WOW_PROJECT_ID = 11
print("\n\27[36mCompiling Wotlk database...\27[0m")
loadTOC("Questie-WOTLKC.toc")
Questie.Debug = _Debug
Questie.Error = _ErrorOrWarning
Questie.Warning = _ErrorOrWarning
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.objectData = loadstring(QuestieDB.objectData)()
QuestieDB.questData = loadstring(QuestieDB.questData)()
QuestieDB.itemData = loadstring(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")
Questie.db.global.debugEnabled = true
QuestieDBCompiler:Compile(function() end)
print("\n\27[36mValidating objects...\27[0m")
QuestieDBCompiler:ValidateObjects()
print("\n\27[36mValidating items...\27[0m")
QuestieDBCompiler:ValidateItems()
print("\n\27[36mValidating NPCs...\27[0m")
QuestieDBCompiler:ValidateNPCs()
print("\n\27[36mValidating quests...\27[0m")
QuestieDBCompiler:ValidateQuests()
print("\n\27[32mWotlk database compiled successfully\27[0m\n")
end
_CheckWotlkDatabase()