From ea3030565c0c8f95fa26739d100e76d1b242cef4 Mon Sep 17 00:00:00 2001 From: Conrado Sampaio <102433904+sampconrad@users.noreply.github.com> Date: Thu, 5 Sep 2024 13:42:24 -0300 Subject: [PATCH] Fix: added ON_RETAIL_CLIENT check for non-existing APIs on Classic --- CombatMode/CombatMode.toc | 2 +- CombatMode/Config.lua | 5 ++++- CombatMode/Core.lua | 15 +++++++++++++-- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/CombatMode/CombatMode.toc b/CombatMode/CombatMode.toc index 0a7926b..da0be9c 100644 --- a/CombatMode/CombatMode.toc +++ b/CombatMode/CombatMode.toc @@ -1,5 +1,5 @@ ## Interface: 110002 -## Version: 2.4.3 +## Version: 2.4.4 ## Title: |A:::|a|TInterface\Addons\CombatMode\assets\cmtitle:22:95|t ## Author: justice7ca, sampconrad. diff --git a/CombatMode/Config.lua b/CombatMode/Config.lua index c65ed30..daaf003 100644 --- a/CombatMode/Config.lua +++ b/CombatMode/Config.lua @@ -5,6 +5,9 @@ local _G = _G local AceAddon = _G.LibStub("AceAddon-3.0") +-- Check if running on Retail or Classic +local ON_RETAIL_CLIENT = (_G.WOW_PROJECT_ID == _G.WOW_PROJECT_MAINLINE) + -- CACHING GLOBAL VARIABLES local GetBindingKey = _G.GetBindingKey local GetCurrentBindingSet = _G.GetCurrentBindingSet @@ -877,7 +880,7 @@ local ReticleTargetingOptions = { return CM.DB.char.crosshairPriority end, disabled = function() - return CM.DB.char.reticleTargeting ~= true + return CM.DB.char.reticleTargeting ~= true or ON_RETAIL_CLIENT == false end }, friendlyTargetingInCombat = { diff --git a/CombatMode/Core.lua b/CombatMode/Core.lua index 455368d..6f04143 100644 --- a/CombatMode/Core.lua +++ b/CombatMode/Core.lua @@ -9,6 +9,9 @@ local AceConfig = _G.LibStub("AceConfig-3.0") local AceConfigDialog = _G.LibStub("AceConfigDialog-3.0") local AceConfigCmd = _G.LibStub("AceConfigCmd-3.0") +-- Check if running on Retail or Classic +local ON_RETAIL_CLIENT = (_G.WOW_PROJECT_ID == _G.WOW_PROJECT_MAINLINE) + -- CACHING GLOBAL VARIABLES -- Slightly better performance than doing a global lookup every time local CreateFrame = _G.CreateFrame @@ -31,7 +34,6 @@ local loadstring = _G.loadstring local MouselookStart = _G.MouselookStart local MouselookStop = _G.MouselookStop local OpenToCategory = _G.Settings.OpenToCategory -local IsInBattle = _G.C_PetBattles.IsInBattle local ReloadUI = _G.ReloadUI local SaveBindings = _G.SaveBindings local SetBinding = _G.SetBinding @@ -266,6 +268,7 @@ function CM.SetShoulderOffset() end function CM.SetCrosshairPriority(enabled) + if ON_RETAIL_CLIENT == false then return end if enabled then SetCVar("enableMouseoverCast", 1) SetModifiedClick("MOUSEOVERCAST", "NONE") @@ -536,6 +539,14 @@ local function IsVendorMountOut() return false end +local function IsInPetBattle() + if ON_RETAIL_CLIENT then + return _G.C_PetBattles.IsInBattle() + else + return false + end +end + local function IsUnlockFrameVisible() local isGenericPanelOpen = (GetUIPanel("left") or GetUIPanel("right") or GetUIPanel("center")) and true or false return CursorUnlockFrameVisible(CM.Constants.FramesToCheck) or CursorUnlockFrameVisible(CM.DB.global.watchlist) or @@ -544,7 +555,7 @@ end local function ShouldFreeLookBeOff() local evaluate = FreeLookOverride or SpellIsTargeting() or InCinematic() or IsInCinematicScene() or - IsUnlockFrameVisible() or IsCustomConditionTrue() or IsVendorMountOut() or IsInBattle() + IsUnlockFrameVisible() or IsCustomConditionTrue() or IsVendorMountOut() or IsInPetBattle() return evaluate end