55 lines
2.8 KiB
Lua
55 lines
2.8 KiB
Lua
-- Load the actual compatibility files with missing legacy globals, without client actions.
|
|
local count=0
|
|
local function check(value,why) count=count+1;assert(value,why) end
|
|
local function frame()
|
|
return {Hide=function(self)self.hidden=true end,IsShown=function(self)return not self.hidden end,
|
|
RegisterEvent=function()end,SetScript=function(self,k,v)self[k]=v end,
|
|
UnregisterAllEvents=function()end,GetChildren=function()end}
|
|
end
|
|
local function scenario(bad_hook)
|
|
local g={}
|
|
setmetatable(g,{__index=_G})
|
|
g._G=g
|
|
g.CreateFrame=frame
|
|
g.StaticPopupDialogs={}
|
|
g.GetBuildInfo=function()return '1.60.1','70334','date',16001 end
|
|
g.GetCVar=function()return '0' end
|
|
g.GetPlayerFacing=function()return 0 end
|
|
g.Minimap=frame();g.NUM_CHAT_WINDOWS=0
|
|
g.QUIT_NOW='Quit';g.CANCEL='Cancel'
|
|
g.geterrorhandler=function()return function(err)error(err)end end
|
|
g.SetAbandonQuest=bad_hook and true or nil
|
|
local rejected_hook=0
|
|
g.hooksecurefunc=function(a,b)
|
|
local fn=type(a)=='table' and a[b] or g[a]
|
|
if type(fn)~='function' then rejected_hook=rejected_hook+1;error('not a function') end
|
|
end
|
|
g.C_QuestLog={}
|
|
g.C_Map={GetBestMapForUnit=function()return 1453 end,
|
|
GetMapInfo=function(id)
|
|
if id==1453 then return {mapID=id,parentMapID=1415,name='Stormwind City'} end
|
|
if id==1415 then return {mapID=id,parentMapID=947,name='Eastern Kingdoms'} end
|
|
end,
|
|
GetMapChildrenInfo=function(id)if id==1415 then return {{mapID=1453,name='Stormwind City'}} else return {} end end}
|
|
g.Enum={UIMapType={Zone=3}}
|
|
local function load(path)
|
|
local fn=assert(loadfile(path));setfenv(fn,g);fn()
|
|
end
|
|
load('compat/forever.lua')
|
|
local env=g.pfQuestEnv
|
|
check(type(env)=='table','compat environment created')
|
|
check(type(env.GetCurrentMapContinent)=='function','map continent provider initialized')
|
|
check(type(env.GetCurrentMapZone)=='function','map zone provider initialized')
|
|
check(env.GetCurrentMapContinent()==2 and env.GetCurrentMapZone()==1,'providers consume native map data')
|
|
check(env.QuestWatchFrame and not env.QuestWatchFrame:IsShown(),'private quest-watch frame initialized hidden')
|
|
check(g.QuestWatchFrame==nil and g.GetCurrentMapContinent==nil,'legacy names not published globally')
|
|
load('compat/client.lua')
|
|
check(env.pfQuestCompat.QuestWatchFrame==env.QuestWatchFrame,'tracker receives private stand-in')
|
|
check(not env.pfQuestCompat.QuestWatchFrame:IsShown(),'reported tracker expression succeeds')
|
|
check(type(env.TEXT)=='function','TEXT initialized before client.lua')
|
|
if bad_hook then check(rejected_hook==1,'guarded hook rejection did not abort remaining initialization') end
|
|
end
|
|
scenario(false)
|
|
scenario(true)
|
|
print(count..' current-source compatibility initialization checks PASS')
|