From 7709eb4c2c92fb61c2d370bbeba3364933b730ed Mon Sep 17 00:00:00 2001
From: Aviana <winblocker@gmx.de>
Date: Thu, 9 Jul 2020 13:36:15 +0200
Subject: [PATCH] Fix #724 , #716

---
 modules/incheal.lua | 18 +-----------------
 modules/units.lua   | 25 ++++++-------------------
 2 files changed, 7 insertions(+), 36 deletions(-)

diff --git a/modules/incheal.lua b/modules/incheal.lua
index 1e5c0560..25e646e3 100644
--- a/modules/incheal.lua
+++ b/modules/incheal.lua
@@ -233,17 +233,10 @@ function IncHeal:Update(frame)
 	self:PositionBar(frame)
 end
 
-function IncHeal:UpdateMod(frame)
-	frame.healValues.mod = HealComm:GetHealModifier(frame.unitGUID) or 1
-	
-	if( not frame.visibility.incHeal or not frame.visibility.healthBar ) then return end
-	self:PositionBar(frame)
-end
-
 function IncHeal:UpdateIncoming(...)
 	for frame in pairs(frames) do
 		for i=1, select("#", ...) do
-			if( select(i, ...) == frame.unitGUID ) and (UnitPlayerOrPetInParty(frame.unit) or UnitPlayerOrPetInRaid(frame.unit) or UnitIsUnit("player",frame.unit) or UnitIsUnit("pet",frame.unit)) then
+			if select(i, ...) == frame.unitGUID then
 				self:Update(frame)
 				break
 			end
@@ -251,15 +244,6 @@ function IncHeal:UpdateIncoming(...)
 	end
 end
 
-function IncHeal:UpdateModifier(guid)
-	for frame in pairs(frames) do
-		if( guid == frame.unitGUID ) and (UnitPlayerOrPetInParty(frame.unit) or UnitPlayerOrPetInRaid(frame.unit) or UnitIsUnit("player",frame.unit) or UnitIsUnit("pet",frame.unit)) then
-			self:UpdateMod(frame)
-			break
-		end
-	end
-end
-
 -- Handle callbacks from HealComm
 function IncHeal:HealComm_HealUpdated(event, casterGUID, spellID, healType, endTime, ...)
 	IncHeal:UpdateIncoming(...)
diff --git a/modules/units.lua b/modules/units.lua
index e6d966d3..ecc7c836 100644
--- a/modules/units.lua
+++ b/modules/units.lua
@@ -335,14 +335,6 @@ function Units:CheckUnitStatus(frame)
 	end
 end
 
--- The argument from UNIT_PET is the pets owner, so the player summoning a new pet gets "player", party1 summoning a new pet gets "party1" and so on
-function Units:CheckPetUnitUpdated(frame, event, unit)
-	if( unit == frame.unitRealOwner and UnitExists(frame.unit) ) then
-		frame.unitGUID = UnitGUID(frame.unit)
-		frame:FullUpdate()
-	end
-end
-
 function Units:CheckGroupedUnitStatus(frame)
 	frame.unitGUID = UnitGUID(frame.unit)
 	frame:FullUpdate()
@@ -402,18 +394,10 @@ OnAttributeChanged = function(self, name, unit)
 
 	-- Pet changed, going from pet -> vehicle for one
 	if( self.unitType == "pet" or self.unitType == "partypet" ) then
-		self.unitRealOwner = self.unit == "pet" and "player" or self.unitID and ("party"..self.unitID)
-		self:RegisterNormalEvent("UNIT_PET", Units, "CheckPetUnitUpdated")
+		self:RegisterNormalEvent("UNIT_PET", Units, "CheckUnitStatus")
 
 	elseif( self.unitType == "raidpet" ) then
-		if self.unit == "pet" then
-			self.unitRealOwner = "player"
-		elseif strmatch(self.unit,"^party.*") then
-			self.unitRealOwner = "party"..self.unitID
-		else
-			self.unitRealOwner = "raid"..self.unitID
-		end
-		self:RegisterNormalEvent("UNIT_PET", Units, "CheckPetUnitUpdated")
+		self:RegisterNormalEvent("UNIT_PET", Units, "CheckUnitStatus")
 
 	-- Automatically do a full update on target change
 	elseif( self.unitType == "target" ) then
@@ -441,6 +425,9 @@ OnAttributeChanged = function(self, name, unit)
 		self:RegisterUnitEvent("UNIT_OTHER_PARTY_CHANGED", self, "FullUpdate")
 		self:RegisterUnitEvent("UNIT_CONNECTION", self, "FullUpdate")
 		
+	elseif( string.match(self.unitType, "^maintank.*") or string.match(self.unitType, "^mainassist.*") ) then
+		self:RegisterNormalEvent("PLAYER_ROLES_ASSIGNED", Units, "CheckGroupedUnitStatus")
+		
 	end
 	-- *target units are not real units, thus they do not receive events and must be polled for data
 	if( LunaUF.fakeUnits[self.unitType] ) then
@@ -452,7 +439,7 @@ OnAttributeChanged = function(self, name, unit)
 			self:RegisterNormalEvent("PLAYER_TARGET_CHANGED", Units, "CheckUnitStatus")
 		end
 
-		self:RegisterNormalEvent("UNIT_TARGET", Units, "CheckPetUnitUpdated")
+		self:RegisterNormalEvent("UNIT_TARGET", Units, "CheckUnitStatus")
 	end
 
 	self:CheckModules()