Commit ba476fb7 authored by Ivaria's avatar Ivaria
Browse files

Update Classic compatability layer to not modify globals

parent 90ea42c8
......@@ -91,18 +91,18 @@ local UnitIsAFK = UnitIsAFK;
local UnitIsConnected = UnitIsConnected;
local UnitIsCharmed = UnitIsCharmed;
local UnitInRaid = UnitInRaid;
local UnitHasVehicleUI = UnitHasVehicleUI;
local VUHDO_unitHasVehicleUI = VUHDO_unitHasVehicleUI;
local UnitTargetsVehicleInRaidUI = UnitTargetsVehicleInRaidUI;
local UnitCanAttack = UnitCanAttack;
local GetNumGroupMembers = GetNumGroupMembers;
local UnitName = UnitName;
local UnitPower = UnitPower;
local UnitPowerMax = UnitPowerMax;
local UnitThreatSituation = UnitThreatSituation;
local VUHDO_unitThreatSituation = VUHDO_unitThreatSituation;
local UnitClass = UnitClass;
local UnitPowerType = UnitPowerType;
local UnitHasVehicleUI = UnitHasVehicleUI;
local UnitGroupRolesAssigned = UnitGroupRolesAssigned;
local VUHDO_unitHasVehicleUI = VUHDO_unitHasVehicleUI;
local VUHDO_unitGroupRolesAssigned = VUHDO_unitGroupRolesAssigned;
local GetRaidRosterInfo = GetRaidRosterInfo;
local InCombatLockdown = InCombatLockdown;
local IsInRaid = IsInRaid;
......@@ -349,9 +349,9 @@ function VUHDO_setHealth(aUnit, aMode)
tInfo["dead"] = tIsDead;
tInfo["afk"] = tIsAfk;
tInfo["connected"] = tIsConnected;
tInfo["threat"] = UnitThreatSituation(aUnit) or 0;
tInfo["threat"] = VUHDO_unitThreatSituation(aUnit) or 0;
tInfo["threatPerc"] = 0;
tInfo["isVehicle"] = UnitHasVehicleUI(aUnit);
tInfo["isVehicle"] = VUHDO_unitHasVehicleUI(aUnit);
tInfo["className"] = tLocalClass or "";
tInfo["petUnit"] = VUHDO_OWNER_2_PET[aUnit];
tInfo["targetUnit"] = VUHDO_getTargetUnit(aUnit);
......@@ -536,7 +536,7 @@ end
--
local tRole;
local function VUHDO_addUnitToSpecial(aUnit)
if VUHDO_CONFIG["OMIT_DFT_MTS"] and "TANK" == (UnitGroupRolesAssigned(aUnit)) then
if VUHDO_CONFIG["OMIT_DFT_MTS"] and "TANK" == (VUHDO_unitGroupRolesAssigned(aUnit)) then
tinsert(VUHDO_GROUPS[41], aUnit); -- VUHDO_ID_MAINTANKS
return;
end
......@@ -861,7 +861,7 @@ function VUHDO_refreshRaidMembers()
else
tInfo["group"] = VUHDO_getUnitGroup(tPlayer, false);
tInfo["isVehicle"] = UnitHasVehicleUI(tPlayer);
tInfo["isVehicle"] = VUHDO_unitHasVehicleUI(tPlayer);
if ( tInfo["isVehicle"] ) then
local tRaidId = UnitInRaid(tPlayer);
......@@ -902,7 +902,7 @@ function VUHDO_refreshRaidMembers()
VUHDO_setHealth(bossUnitId, 1); -- VUHDO_UPDATE_ALL
else
tInfo["group"] = VUHDO_getUnitGroup(bossUnitId, false);
tInfo["isVehicle"] = UnitHasVehicleUI(bossUnitId);
tInfo["isVehicle"] = VUHDO_unitHasVehicleUI(bossUnitId);
tInfo["afk"] = false;
tInfo["connected"] = true;
......
--
local UnitPower = UnitPower;
local UnitGetIncomingHeals = UnitGetIncomingHeals;
local pairs = pairs;
local ipairs = ipairs;
local floor = floor;
......@@ -269,7 +268,7 @@ local function VUHDO_aoeGetIncHeals(aUnit, aCastTime)
return 0;
end
return (UnitGetIncomingHeals(aUnit) or 0) - (UnitGetIncomingHeals(aUnit, "player") or 0);
return (VUHDO_unitGetIncomingHeals(aUnit) or 0) - (VUHDO_unitGetIncomingHeals(aUnit, "player") or 0);
end
......
......@@ -205,7 +205,7 @@ end
--
local function VUHDO_isPhasedValidator(anInfo, _)
if UnitIsWarModePhased(anInfo["unit"]) or not UnitInPhase(anInfo["unit"]) then
if VUHDO_unitIsWarModePhased(anInfo["unit"]) or not UnitInPhase(anInfo["unit"]) then
return true, "Interface\\TargetingFrame\\UI-PhasingIcon",
-1, -1, -1, nil, nil, 0.15625, 0.84375, 0.15625, 0.84375;
else
......@@ -217,7 +217,7 @@ end
--
local function VUHDO_isWarModePhasedValidator(anInfo, _)
if UnitIsWarModePhased(anInfo["unit"]) then
if VUHDO_unitIsWarModePhased(anInfo["unit"]) then
return true, "Interface\\TargetingFrame\\UI-PhasingIcon",
-1, -1, -1, nil, nil, 0.15625, 0.84375, 0.15625, 0.84375;
else
......@@ -779,7 +779,7 @@ end
local function VUHDO_statusExcessAbsorbValidator(anInfo, _)
local healthmax = anInfo["healthmax"];
local excessAbsorb = (UnitGetTotalAbsorbs(anInfo["unit"]) or 0) + anInfo["health"] - healthmax;
local excessAbsorb = (VUHDO_unitGetTotalAbsorbs(anInfo["unit"]) or 0) + anInfo["health"] - healthmax;
if excessAbsorb < 0 then
return true, nil, 0, -1, healthmax;
......@@ -792,7 +792,7 @@ end
--
local function VUHDO_statusTotalAbsorbValidator(anInfo, _)
return true, nil, UnitGetTotalAbsorbs(anInfo["unit"]) or 0, -1, anInfo["healthmax"];
return true, nil, VUHDO_unitGetTotalAbsorbs(anInfo["unit"]) or 0, -1, anInfo["healthmax"];
end
......
......@@ -52,7 +52,7 @@ local UnitIsTrivial = UnitIsTrivial;
local GetSpellCooldown = GetSpellCooldown;
local HasFullControl = HasFullControl;
local pairs = pairs;
local UnitThreatSituation = UnitThreatSituation;
local VUHDO_unitThreatSituation = VUHDO_unitThreatSituation;
local InCombatLockdown = InCombatLockdown;
local type = type;
......@@ -198,7 +198,7 @@ local tEmpty = {};
local function VUHDO_updateThreat(aUnit)
tInfo = (VUHDO_RAID or tEmpty)[aUnit];
if tInfo then
tInfo["threat"] = UnitThreatSituation(aUnit) or 0;
tInfo["threat"] = VUHDO_unitThreatSituation(aUnit) or 0;
if VUHDO_INTERNAL_TOGGLES[17] then -- VUHDO_UPDATE_THREAT_LEVEL
VUHDO_updateBouquetsForEvent(aUnit, 17); -- VUHDO_UPDATE_THREAT_LEVEL
......@@ -695,7 +695,7 @@ function VUHDO_OnEvent(_, anEvent, anArg1, anArg2, anArg3, anArg4, anArg5, anArg
elseif "PLAYER_SPECIALIZATION_CHANGED" == anEvent then
if VUHDO_VARIABLES_LOADED and not InCombatLockdown() then
if "player" == anArg1 then
local tSpecNum = tostring(GetSpecialization()) or "1";
local tSpecNum = tostring(VUHDO_getSpecialization()) or "1";
-- event sometimes fires multiple times so we must de-dupe
if VUHDO_SPEC_LAYOUTS["selected"] ~= VUHDO_SPEC_LAYOUTS[tSpecNum] then
......@@ -1090,7 +1090,7 @@ local function VUHDO_updateAllRange()
end
-- Check if unit is phased
if UnitIsWarModePhased(tUnit) or not UnitInPhase(tUnit) then
if VUHDO_unitIsWarModePhased(tUnit) or not UnitInPhase(tUnit) then
tIsInRange = false;
else
-- Check if unit is in range
......
----------------------------------------------------
local UnitGetIncomingHeals = UnitGetIncomingHeals;
local sIsOthers, sIsOwn, sIsNoInc;
function VUHDO_healCommAdapterInitLocalOverrides()
sIsOthers = VUHDO_CONFIG["SHOW_INCOMING"];
......@@ -27,12 +26,12 @@ function VUHDO_determineIncHeal(aUnit)
if sIsOthers then
if sIsOwn then
VUHDO_INC_HEAL[aUnit] = UnitGetIncomingHeals(aUnit);
VUHDO_INC_HEAL[aUnit] = VUHDO_unitGetIncomingHeals(aUnit);
else
tAllIncoming = (UnitGetIncomingHeals(aUnit) or 0) - (UnitGetIncomingHeals(aUnit, "player") or 0);
tAllIncoming = (VUHDO_unitGetIncomingHeals(aUnit) or 0) - (VUHDO_unitGetIncomingHeals(aUnit, "player") or 0);
VUHDO_INC_HEAL[aUnit] = tAllIncoming < 0 and 0 or tAllIncoming;
end
else
VUHDO_INC_HEAL[aUnit] = UnitGetIncomingHeals(aUnit, "player");
VUHDO_INC_HEAL[aUnit] = VUHDO_unitGetIncomingHeals(aUnit, "player");
end
end
......@@ -1999,7 +1999,7 @@ end
--
local tSpec;
function VUHDO_getBestProfileAfterSpecChange()
tSpec = GetSpecialization();
tSpec = VUHDO_getSpecialization();
return VUHDO_getBestProfileForSpecAndSize(tSpec, VUHDO_GROUP_SIZE)
or VUHDO_getBestProfileForSpec(tSpec)
or VUHDO_getBestProfileForSize(VUHDO_GROUP_SIZE);
......@@ -2009,7 +2009,7 @@ end
--
function VUHDO_getBestProfileAfterSizeChange()
tSpec = GetSpecialization();
tSpec = VUHDO_getSpecialization();
return VUHDO_getBestProfileForSpecAndSize(tSpec, VUHDO_GROUP_SIZE)
or VUHDO_getBestProfileForSize(VUHDO_GROUP_SIZE)
or VUHDO_getBestProfileForSpec(tSpec);
......
......@@ -83,7 +83,7 @@ function VUHDO_keyLayoutInitSpecCheckButton(aCheckButton, aSpecId)
end
if tIndexName then
local _, tSpecName = GetSpecializationInfo(tSpecId);
local _, tSpecName = VUHDO_getSpecializationInfo(tSpecId);
if tSpecName then
_G[aCheckButton:GetName() .. "Label"]:SetText(tIndexName .. "\n(" .. string.sub(tSpecName,1,4) .. ")");
......
......@@ -121,7 +121,7 @@ function VUHDO_skinsInitAutoCheckButton(aButton, anIndex)
end
if tIndexName then
local _, tSpecName = GetSpecializationInfo(tSpecId);
local _, tSpecName = VUHDO_getSpecializationInfo(tSpecId);
if tSpecName then
_G[aButton:GetName() .. "Label"]:SetText(tIndexName .. "\n(" .. string.sub(tSpecName,1,4) .. ")");
......
......@@ -14,10 +14,10 @@ local twipe = table.wipe;
local CheckInteractDistance = CheckInteractDistance;
local UnitIsUnit = UnitIsUnit;
local NotifyInspect = NotifyInspect;
local GetSpecializationInfo = GetSpecializationInfo;
local VUHDO_getSpecializationInfo = VUHDO_getSpecializationInfo;
local ClearInspectPlayer = ClearInspectPlayer;
local UnitStat = UnitStat;
local UnitGroupRolesAssigned = UnitGroupRolesAssigned;
local VUHDO_unitGroupRolesAssigned = VUHDO_unitGroupRolesAssigned;
local UnitLevel = UnitLevel;
local UnitPowerType = UnitPowerType;
local VUHDO_isUnitInModel;
......@@ -138,18 +138,18 @@ function VUHDO_inspectLockRole()
if not tInfo then VUHDO_NEXT_INSPECT_UNIT = nil; return; end
if "player" == VUHDO_NEXT_INSPECT_UNIT then
tActiveTree = GetSpecialization();
tActiveTree = VUHDO_getSpecialization();
if not tActiveTree then
VUHDO_INSPECTED_ROLES[tInfo["name"]] = VUHDO_ID_UNDEFINED;
VUHDO_NEXT_INSPECT_UNIT = nil;
return;
end
tTreeId, _, _, _, _, tRole = GetSpecializationInfo(tActiveTree, false, false);
tTreeId, _, _, _, _, tRole = VUHDO_getSpecializationInfo(tActiveTree, false, false);
else
tTreeId = GetInspectSpecialization(VUHDO_NEXT_INSPECT_UNIT);
tRole = GetSpecializationRoleByID(tTreeId);
tTreeId = VUHDO_getInspectSpecialization(VUHDO_NEXT_INSPECT_UNIT);
tRole = VUHDO_getSpecializationRoleByID(tTreeId);
end
if (tTreeId or 0) == 0 then
......@@ -218,7 +218,7 @@ local tDfRole, tOldRole, tReturnRole, tName;
local function VUHDO_determineDfToolRole(anInfo)
tName = anInfo["name"];
tOldRole = VUHDO_DF_TOOL_ROLES[tName];
tDfRole = UnitGroupRolesAssigned(anInfo["unit"]);
tDfRole = VUHDO_unitGroupRolesAssigned(anInfo["unit"]);
if "NONE" == tDfRole then
VUHDO_DF_TOOL_ROLES[tName] = nil;
......
......@@ -2,7 +2,7 @@ local _;
local select = select;
local type = type;
local UnitGetTotalAbsorbs = UnitGetTotalAbsorbs;
local VUHDO_unitGetTotalAbsorbs = VUHDO_unitGetTotalAbsorbs;
local VUHDO_SHIELDS = {
[17] = 15, -- VUHDO_SPELL_ID.POWERWORD_SHIELD -- ok
......@@ -265,7 +265,7 @@ end
--
local tSummeLeft;
function VUHDO_getUnitOverallShieldRemain(aUnit)
return UnitGetTotalAbsorbs(aUnit) or 0;
return VUHDO_unitGetTotalAbsorbs(aUnit) or 0;
end
......
......@@ -21,7 +21,7 @@ local GetTime = GetTime;
local GetRealZoneText = GetRealZoneText;
local GetSpellInfo = GetSpellInfo;
local SetMapToCurrentZone = SetMapToCurrentZone;
local UnitAlternatePowerInfo = UnitAlternatePowerInfo;
local VUHDO_unitAlternatePowerInfo = VUHDO_unitAlternatePowerInfo;
local WorldMapFrame = WorldMapFrame;
local GetMouseFocus = GetMouseFocus;
local GetPlayerFacing = GetPlayerFacing;
......@@ -285,7 +285,7 @@ function VUHDO_isInRange(aUnit)
return true;
elseif VUHDO_isSpecialUnit(aUnit) then
return VUHDO_isTargetInRange(aUnit);
elseif UnitIsWarModePhased(aUnit) or not UnitInPhase(aUnit) then
elseif VUHDO_unitIsWarModePhased(aUnit) or not UnitInPhase(aUnit) then
return false;
elseif (sIsGuessRange) then
return UnitInRange(aUnit);
......@@ -540,7 +540,7 @@ end
local tResurrectionSpells;
local tKnownResurrectionSpells;
function VUHDO_getResurrectionSpells()
tResurrectionSpells = (VUHDO_RESURRECTION_SPELLS[VUHDO_PLAYER_CLASS] or sEmpty)[GetSpecialization() or 0];
tResurrectionSpells = (VUHDO_RESURRECTION_SPELLS[VUHDO_PLAYER_CLASS] or sEmpty)[VUHDO_getSpecialization() or 0];
if tResurrectionSpells then
tKnownResurrectionSpells = { };
......@@ -752,7 +752,7 @@ end
--
function VUHDO_isAltPowerActive(aUnit)
local tBarType, _, _, _, _, tIsHideFromOthers = UnitAlternatePowerInfo(aUnit);
local tBarType, _, _, _, _, tIsHideFromOthers = VUHDO_unitAlternatePowerInfo(aUnit);
return tBarType and (not tIsHideFromOthers or "player" == aUnit);
end
......@@ -998,98 +998,145 @@ end
---------------------------------
-- CLASSIC COMPATIBILITY LAYER --
---------------------------------
function GetSpecialization()
function VUHDO_getSpecialization()
return 1;
if not GetSpecialization then
return 1;
else
return GetSpecialization();
end
end
function GetSpecializationInfo()
function VUHDO_getSpecializationInfo(...)
return 1, "Unknown", _, _, _, "NONE";
if not GetSpecializationInfo then
return 1, "Unknown", _, _, _, "NONE";
else
return GetSpecializationInfo(...);
end
end
function GetInspectSpecialization()
function VUHDO_getInspectSpecialization(...)
return 0;
if not GetInspectSpecialization then
return 0;
else
return GetInspectSpecialization(...);
end
end
function GetSpecializationRoleByID()
function VUHDO_getSpecializationRoleByID(...)
return "NONE";
if not GetSpecializationRoleByID then
return "NONE";
else
return GetSpecializationRoleByID(...);
end
end
function UnitGetIncomingHeals()
function VUHDO_unitGetIncomingHeals(...)
return 0;
if not UnitGetIncomingHeals then
return 0;
else
return UnitGetIncomingHeals(...);
end
end
function UnitGetTotalAbsorbs()
function VUHDO_unitGetTotalAbsorbs(...)
return 0;
if not UnitGetTotalAbsorbs then
return 0;
else
return UnitGetTotalAbsorbs(...);
end
end
function UnitThreatSituation()
function VUHDO_unitThreatSituation(...)
return 0;
if not UnitThreatSituation then
return 0;
else
return UnitThreatSituation(...);
end
end
function UnitIsWarModePhased()
function VUHDO_unitIsWarModePhased(...)
return false;
if not UnitIsWarModePhased then
return false;
else
return UnitIsWarModePhased(...);
end
end
function UnitHasVehicleUI()
function VUHDO_unitHasVehicleUI(...)
return false;
if not UnitHasVehicleUI then
return false;
else
return UnitHasVehicleUI(...);
end
end
function UnitGroupRolesAssigned()
function VUHDO_unitGroupRolesAssigned(...)
return "NONE";
if not UnitGroupRolesAssigned then
return "NONE";
else
return UnitGroupRolesAssigned(...);
end
end
function UnitAlternatePowerInfo()
function VUHDO_unitAlternatePowerInfo(...)
return false;
if not UnitAlternatePowerInfo then
return false;
else
return UnitAlternatePowerInfo(...);
end
end
C_IncomingSummon = { };
function C_IncomingSummon.HasIncomingSummon()
function VUHDO_hasIncomingSummon(...)
return false;
if not C_IncomingSummon or not C_IncomingSummon.HasIncomingSummon then
return false;
else
return C_IncomingSummon.HasIncomingSummon(...);
end
end
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment