-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClient.lua
More file actions
92 lines (84 loc) · 2.85 KB
/
Copy pathClient.lua
File metadata and controls
92 lines (84 loc) · 2.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
local lib = _G.LibTaxiData_Internal
if not lib then return end
local versionsByID = {}
for _, candidate in ipairs(lib.ClientVersions or {}) do
versionsByID[candidate.version] = candidate
end
local function DetectVersion(interface)
-- Project constants are authoritative and continue to work when a family
-- currently has no active profile/server in tools/profiles.json.
for _, candidate in ipairs(lib.ClientVersions or {}) do
local projectID = _G[candidate.projectConstant]
if projectID and projectID == _G.WOW_PROJECT_ID then
return candidate
end
end
-- Interface-major rules are a fallback for test clients and old clients
-- on which a project constant is missing.
local major = math.floor((tonumber(interface) or 0) / 10000)
for _, candidate in ipairs(lib.ClientVersions or {}) do
if candidate.interfaceMajor == major then
return candidate
end
end
for _, candidate in ipairs(lib.ClientVersions or {}) do
if candidate.minimumInterfaceMajor and major >= candidate.minimumInterfaceMajor then
return candidate
end
end
end
local versionString, buildNumber, _, interface
if _G.GetBuildInfo then
versionString, buildNumber, _, interface = GetBuildInfo()
end
local detectedBuild
if type(versionString) == "string" and
(type(buildNumber) == "string" or type(buildNumber) == "number") then
detectedBuild = versionString .. "." .. tostring(buildNumber)
end
local detectedVersion = DetectVersion(interface)
local selected
for _, profile in ipairs(lib.ClientProfiles or {}) do
if profile.build == detectedBuild and
(not detectedVersion or profile.version == detectedVersion.version) then
selected = profile
break
end
end
if selected and not detectedVersion then
detectedVersion = versionsByID[selected.version]
end
if not selected and detectedVersion then
for _, profile in ipairs(lib.ClientProfiles or {}) do
if profile.version == detectedVersion.version and profile.default then
selected = profile
break
end
end
end
lib.Client = {}
if detectedVersion then
for key, value in pairs(detectedVersion) do
lib.Client[key] = value
end
end
lib.Client.detectedBuild = detectedBuild
lib.Client.detectedInterface = interface
lib.Client.detectedVersion = detectedVersion and detectedVersion.version or nil
lib.Client.projectID = _G.WOW_PROJECT_ID
if not selected then
lib.Client.supported = false
return
end
local baseVersion = versionsByID[selected.version]
if baseVersion then
for key, value in pairs(baseVersion) do
lib.Client[key] = value
end
end
for key, value in pairs(selected) do
lib.Client[key] = value
end
lib.Client.exactBuild = detectedBuild == selected.build
lib.Client.fallback = not lib.Client.exactBuild
lib.Client.supported = true