Skip to content

Commit

Permalink
Use established constants for version checks
Browse files Browse the repository at this point in the history
  • Loading branch information
p3lim committed Nov 28, 2024
1 parent cd81cd6 commit 9494e4f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .luacheckrc
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ read_globals = {

-- FrameXML constants
'DEFAULT_CHAT_FRAME',
'WOW_PROJECT_ID',
'WOW_PROJECT_MAINLINE',
'WOW_PROJECT_CLASSIC',

-- GlobalStrings
'HEADER_COLON',
Expand Down
8 changes: 5 additions & 3 deletions modules/build.lua
Original file line number Diff line number Diff line change
@@ -1,27 +1,29 @@
local _, addon = ...

local _, buildVersion, _, interfaceVersion = GetBuildInfo()
--[[ namespace:IsRetail()
Checks if the current client is running the "retail" version.
--]]
function addon:IsRetail()
return interfaceVersion > 100000
return WOW_PROJECT_ID == WOW_PROJECT_MAINLINE
end

--[[ namespace:IsClassicEra()
Checks if the current client is running the "classic era" version (e.g. vanilla).
--]]
function addon:IsClassicEra()
return interfaceVersion < 20000
return WOW_PROJECT_ID == WOW_PROJECT_CLASSIC
end

--[[ namespace:IsClassic()
Checks if the current client is running the "classic" version.
--]]
function addon:IsClassic()
-- instead of using the floating constant for classic we'll just NOR the other two,
-- as they are static
return not addon:IsRetail() and not addon:IsClassicEra()
end

local _, buildVersion, _, interfaceVersion = GetBuildInfo()
--[[ namespace:HasBuild(_buildNumber_[, _interfaceVersion_])
Checks if the current client is running a build equal to or newer than the specified.
Optionally also check against the interface version.
Expand Down

0 comments on commit 9494e4f

Please sign in to comment.