From ba80fe475f1d5e5f6092db010b2c900b780b3873 Mon Sep 17 00:00:00 2001
From: Ivaria <ivaria@vuhdo.io>
Date: Wed, 8 Jul 2020 23:47:26 -0700
Subject: [PATCH] Migrate from LibThreatClassic2 to restored Blizzard APIs

---
 Libs/Libs.xml                 |  1 -
 VuhDo.lua                     |  4 +--
 VuhDo.toc                     |  2 +-
 VuhDoAddonAdapter.lua         |  1 -
 VuhDoEventHandler.lua         | 10 +++---
 VuhDoOptions/VuhDoOptions.toc |  2 +-
 VuhDoToolbox.lua              | 59 -----------------------------------
 changelog.txt                 |  3 +-
 8 files changed, 11 insertions(+), 71 deletions(-)

diff --git a/Libs/Libs.xml b/Libs/Libs.xml
index 995ee7f..52b96cc 100644
--- a/Libs/Libs.xml
+++ b/Libs/Libs.xml
@@ -22,7 +22,6 @@
 	<Include file="LibCustomGlow-1.0\LibCustomGlow-1.0.xml" />
 	<Include file="NickTag-1.0\NickTag-1.0.xml" />
 
-	<Include file="LibThreatClassic2\lib.xml" />
 	<Include file="!LibTotemInfo\embeds.xml" />
 	<Include file="LibClassicDurations\LibClassicDurations.xml" />
 	<Include file="LibHealComm-4.0\LibHealComm-4.0.xml" />
diff --git a/VuhDo.lua b/VuhDo.lua
index af77066..a778f98 100644
--- a/VuhDo.lua
+++ b/VuhDo.lua
@@ -98,7 +98,7 @@ local GetNumGroupMembers = GetNumGroupMembers;
 local UnitName = UnitName;
 local UnitPower = UnitPower;
 local UnitPowerMax = UnitPowerMax;
-local VUHDO_unitThreatSituation = VUHDO_unitThreatSituation;
+local UnitThreatSituation = UnitThreatSituation;
 local UnitClass = UnitClass;
 local UnitPowerType = UnitPowerType;
 local VUHDO_unitHasVehicleUI = VUHDO_unitHasVehicleUI;
@@ -349,7 +349,7 @@ function VUHDO_setHealth(aUnit, aMode)
 			tInfo["dead"] = tIsDead;
 			tInfo["afk"] = tIsAfk;
 			tInfo["connected"] = tIsConnected;
-			tInfo["threat"] = VUHDO_unitThreatSituation(aUnit) or 0;
+			tInfo["threat"] = UnitThreatSituation(aUnit) or 0;
 			tInfo["threatPerc"] = 0;
 			tInfo["isVehicle"] = VUHDO_unitHasVehicleUI(aUnit);
 			tInfo["className"] = tLocalClass or "";
diff --git a/VuhDo.toc b/VuhDo.toc
index 6175023..20f6361 100644
--- a/VuhDo.toc
+++ b/VuhDo.toc
@@ -1,4 +1,4 @@
-## Interface: 11304
+## Interface: 11305
 ## Title: VuhDo ['vu:du:]
 ## Author: Iza@Gilneas, humfras, Ivaria@Hyjal
 ## Version: 3.114-classic
diff --git a/VuhDoAddonAdapter.lua b/VuhDoAddonAdapter.lua
index 0c2c00f..98b50ba 100644
--- a/VuhDoAddonAdapter.lua
+++ b/VuhDoAddonAdapter.lua
@@ -24,7 +24,6 @@ if VUHDO_LibClassicDurations then
 	VUHDO_LibClassicDurations:Register("VuhDo");
 end
 
-VUHDO_LibThreatClassic = LibStub:GetLibrary("LibThreatClassic2");
 VUHDO_LibTotemInfo = LibStub("LibTotemInfo-1.0");
 
 VUHDO_LibSharedMedia:Register("font", "Arial Black", "Interface\\AddOns\\VuhDo\\Fonts\\ariblk.ttf");
diff --git a/VuhDoEventHandler.lua b/VuhDoEventHandler.lua
index fed1bc5..c5a6d0f 100644
--- a/VuhDoEventHandler.lua
+++ b/VuhDoEventHandler.lua
@@ -43,7 +43,7 @@ local GetTime = GetTime;
 local CheckInteractDistance = CheckInteractDistance;
 local UnitInRange = UnitInRange;
 local IsSpellInRange = IsSpellInRange;
-local VUHDO_unitDetailedThreatSituation = VUHDO_unitDetailedThreatSituation;
+local UnitDetailedThreatSituation = UnitDetailedThreatSituation;
 local UnitIsCharmed = UnitIsCharmed;
 local UnitCanAttack = UnitCanAttack;
 local UnitName = UnitName;
@@ -52,7 +52,7 @@ local UnitIsTrivial = UnitIsTrivial;
 local GetSpellCooldown = GetSpellCooldown;
 local HasFullControl = HasFullControl;
 local pairs = pairs;
-local VUHDO_unitThreatSituation = VUHDO_unitThreatSituation;
+local UnitThreatSituation = 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"] = VUHDO_unitThreatSituation(aUnit) or 0;
+		tInfo["threat"] = UnitThreatSituation(aUnit) or 0;
 
 		if VUHDO_INTERNAL_TOGGLES[17] then -- VUHDO_UPDATE_THREAT_LEVEL
 			VUHDO_updateBouquetsForEvent(aUnit, 17); -- VUHDO_UPDATE_THREAT_LEVEL
@@ -1052,7 +1052,7 @@ local function VUHDO_updateAllAggro()
 			tTarget = tInfo["targetUnit"];
 			if not UnitIsFriend(tUnit, tTarget) then
 				if VUHDO_INTERNAL_TOGGLES[14] then -- VUHDO_UPDATE_AGGRO
-					_, _, tThreatPerc = VUHDO_unitDetailedThreatSituation(tUnit, tTarget);
+					_, _, tThreatPerc = UnitDetailedThreatSituation(tUnit, tTarget);
 					tInfo["threatPerc"] = tThreatPerc or 0;
 				end
 
@@ -1060,7 +1060,7 @@ local function VUHDO_updateAllAggro()
 
 				if tAggroUnit then
 					if VUHDO_INTERNAL_TOGGLES[14] then -- VUHDO_UPDATE_AGGRO
-						_, _, tThreatPerc = VUHDO_unitDetailedThreatSituation(tAggroUnit, tTarget);
+						_, _, tThreatPerc = UnitDetailedThreatSituation(tAggroUnit, tTarget);
 						VUHDO_RAID[tAggroUnit]["threatPerc"] = tThreatPerc or 0;
 					end
 
diff --git a/VuhDoOptions/VuhDoOptions.toc b/VuhDoOptions/VuhDoOptions.toc
index 48f0ef6..da9dfbd 100644
--- a/VuhDoOptions/VuhDoOptions.toc
+++ b/VuhDoOptions/VuhDoOptions.toc
@@ -1,4 +1,4 @@
-## Interface: 11304
+## Interface: 11305
 ## Title: VuhDo ['vu:du:] - Options
 ## Author: Iza@Gilneas, humfras, Ivaria@Hyjal
 ## Version: 3.114-classic
diff --git a/VuhDoToolbox.lua b/VuhDoToolbox.lua
index 3441aae..ac8839a 100644
--- a/VuhDoToolbox.lua
+++ b/VuhDoToolbox.lua
@@ -1149,65 +1149,6 @@ end
 
 
 
-function VUHDO_unitThreatSituation(aUnit)
-
-	if not aUnit then 
-		return nil; 
-	end
-
-	if not UnitThreatSituation then
-		if VUHDO_LibThreatClassic then
-			local tOtherUnit = nil;
-
-			-- check target and boss unit threat
-			if UnitExists(aUnit .. "target") and UnitIsEnemy(aUnit, aUnit .. "target") then
-				tOtherUnit = aUnit .. "target";
-			elseif UnitExists("target") and UnitIsEnemy("player", "target") then
-				tOtherUnit = "target";
-			elseif UnitExists("boss1") and UnitIsEnemy("player", "boss1") then
-				tOtherUnit = "boss1";
-			elseif UnitExists("boss2") and UnitIsEnemy("player", "boss2") then
-				tOtherUnit = "boss2";
-			elseif UnitExists("boss3") and UnitIsEnemy("player", "boss3") then
-				tOtherUnit = "boss3";
-			elseif UnitExists("boss4") and UnitIsEnemy("player", "boss4") then
-				tOtherUnit = "boss4";
-			elseif UnitExists("boss5") and UnitIsEnemy("player", "boss5") then
-				tOtherUnit = "boss5";
-			end
-
-			return VUHDO_LibThreatClassic:UnitThreatSituation(aUnit, tOtherUnit);
-		else
-			return nil;
-		end
-	else
-		return UnitThreatSituation(aUnit);
-	end
-
-end
-
-
-
-function VUHDO_unitDetailedThreatSituation(aUnit, aOtherUnit)
-
-	if not aUnit or not aOtherUnit then 
-		return nil; 
-	end
-
-	if not UnitDetailedThreatSituation then
-		if VUHDO_LibThreatClassic then
-			return VUHDO_LibThreatClassic:UnitDetailedThreatSituation(aUnit, aOtherUnit);
-		else
-			return nil;
-		end
-	else
-		return UnitDetailedThreatSituation(aUnit, aOtherUnit);
-	end
-
-end
-
-
-
 function VUHDO_unitIsWarModePhased(...)
 
 	if not UnitIsWarModePhased then
diff --git a/changelog.txt b/changelog.txt
index 089250d..16ee3ab 100644
--- a/changelog.txt
+++ b/changelog.txt
@@ -15,7 +15,8 @@ Bugfixes:
   
   
 Improvements:  
--- Bump TOC interface for 1.13.4  
+-- Bump TOC interface for 1.13.5  
+-- Migrate from LibThreatClassic2 to restored Blizzard APIs  
   
   
 --------------------------------------------------------------  
-- 
GitLab