diff --git a/.luacheckrc b/.luacheckrc index 70bcf7c..2bbdbda 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -28,6 +28,7 @@ globals = { 'UnitFullName', 'GetUnitName', 'GetRealmName', + 'UnitNameUnmodified', 'GetNumGroupMembers', 'GetBattlefieldStatus', 'GetMaxBattlefieldID', diff --git a/BattlegroundTools.lua b/BattlegroundTools.lua index 6282b4a..7e50994 100644 --- a/BattlegroundTools.lua +++ b/BattlegroundTools.lua @@ -16,7 +16,7 @@ local CreateFrame = CreateFrame local GetTime = GetTime local ReplaceIconAndGroupExpressions = C_ChatInfo.ReplaceIconAndGroupExpressions local GetInstanceInfo = GetInstanceInfo -local GetUnitName = GetUnitName +local GetRealUnitName = Namespace.Utils.GetRealUnitName local PromoteToLeader = PromoteToLeader local PlaySound = PlaySound local UnitIsGroupLeader = UnitIsGroupLeader @@ -446,7 +446,7 @@ function Module:GetZoneId(zoneId) end function Private.OnAcknowledgeWantBattlegroundLead(_, _, _, sender) - if sender == GetUnitName('player', true) then return end + if sender == GetRealUnitName('player') then return end local mem = Memory.WantBattlegroundLead if not mem.ackTimer then return end @@ -482,7 +482,7 @@ function Private.SendAcknowledgeWantBattlegroundLead() end function Private.OnWantBattlegroundLead(_, _, _, sender) - if sender == GetUnitName('player', true) then return end + if sender == GetRealUnitName('player') then return end if not UnitIsGroupLeader('player') then return end local mem = Memory.WantBattlegroundLead @@ -529,7 +529,7 @@ function Private.SendWantBattlegroundLead() if channel == Channel.Whisper then return end if Namespace.Database.profile.BattlegroundTools.WantBattlegroundLead.enableManualRequest then - local groupLeader = GetUnitName(GetGroupLeaderUnit(), true) + local groupLeader = GetRealUnitName(GetGroupLeaderUnit()) if mem.ackLeader == nil or groupLeader ~= mem.ackLeader then -- re-buffer the timer each time the leader changes to give them enough time to reply if mem.ackTimer then Module:CancelTimer(mem.ackTimer) end diff --git a/Communication.lua b/Communication.lua index 77bb3e9..e120a69 100644 --- a/Communication.lua +++ b/Communication.lua @@ -7,7 +7,7 @@ local LibCompress = Namespace.Libs.LibCompress local Encoder = LibCompress:GetAddonEncodeTable() local GroupType = Namespace.Utils.GroupType -local GetUnitName = GetUnitName +local GetRealUnitName = Namespace.Utils.GetRealUnitName local Channel = { Raid = 'RAID', @@ -39,5 +39,5 @@ function Namespace.Communication.GetMessageDestination() if currentType == GroupType.Raid then return Channel.Raid, nil end if currentType == GroupType.Party then return Channel.Party, nil end - return Channel.Whisper, GetUnitName('player', true) + return Channel.Whisper, GetRealUnitName('player') end diff --git a/Debug.lua b/Debug.lua index c5e8d7c..4c70232 100644 --- a/Debug.lua +++ b/Debug.lua @@ -3,7 +3,7 @@ local Private, _, Namespace = {}, ... Namespace.Debug = {} --@debug@ Namespace.Debug.enabled = true -Namespace.Meta.version = '1.6.6-dev' +Namespace.Meta.version = '1.6.7-dev' --@end-debug@ local type, pairs, tostring, print, concat, select = type, pairs, tostring, print, table.concat, select diff --git a/PlayerData.lua b/PlayerData.lua index 66ed1f5..d28ee62 100644 --- a/PlayerData.lua +++ b/PlayerData.lua @@ -6,7 +6,7 @@ local ReadyCheckState = Namespace.Utils.ReadyCheckState local BattlegroundStatus = Namespace.Utils.BattlegroundStatus local GroupType = Namespace.Utils.GroupType local GetGroupType = Namespace.Utils.GetGroupType -local GetUnitName = GetUnitName +local GetRealUnitName = Namespace.Utils.GetRealUnitName local UnitIsPlayer = UnitIsPlayer local UnitGUID = UnitGUID local UnitExists = UnitExists @@ -69,7 +69,7 @@ function Namespace.PlayerData.RebuildPlayerData() local data = Memory.AllPlayerData[dataIndex] if not data then data = { - name = GetUnitName(unit, true), + name = GetRealUnitName(unit), readyState = ReadyCheckState.Nothing, deserterExpiry = -1, units = {primary = unit, [unit] = true}, @@ -79,7 +79,7 @@ function Namespace.PlayerData.RebuildPlayerData() Memory.AllPlayerData[dataIndex] = data else -- always refresh the name whenever possible - data.name = GetUnitName(unit, true) + data.name = GetRealUnitName(unit) if not data.units.primary then data.units.primary = unit @@ -106,7 +106,7 @@ function Namespace.PlayerData.GetPlayerDataByUnit(unit) -- fallback to getting the name of the unit in case of weird scenarios -- where "target" or "nameplate1" is sent - local name = GetUnitName(unit, true) + local name = GetRealUnitName(unit) if not name then return nil end return Namespace.PlayerData.GetPlayerDataByName(name) @@ -115,7 +115,7 @@ end function Namespace.PlayerData.GetPlayerDataByName(name) for _, data in pairs(Memory.AllPlayerData) do if data.units.primary and (data.name == UNKNOWNOBJECT or data.name == nil) then - data.name = GetUnitName(data.units.primary, true) + data.name = GetRealUnitName(data.units.primary) end if data.name == name then diff --git a/QueueTools.lua b/QueueTools.lua index dd81ed4..35adc10 100644 --- a/QueueTools.lua +++ b/QueueTools.lua @@ -29,7 +29,7 @@ local GetNumGroupMembers = GetNumGroupMembers local GetBattlefieldStatus = GetBattlefieldStatus local GetMaxBattlefieldID = GetMaxBattlefieldID local GetLFGRoleUpdate = GetLFGRoleUpdate -local GetUnitName = GetUnitName +local GetRealUnitName = Namespace.Utils.GetRealUnitName local CombatLogGetCurrentEventInfo = CombatLogGetCurrentEventInfo local UnitClass = UnitClass local UnitDebuff = UnitDebuff @@ -204,7 +204,7 @@ function Private.CreateTableRow(index, data) if data.name == UNKNOWNOBJECT or data.name == nil then -- try to update the name as it wasn't available on initial check - data.name = GetUnitName(data.units.primary, true) + data.name = GetRealUnitName(data.units.primary) end local name, color @@ -442,7 +442,7 @@ function Private.OnSyncData(_, text, _, sender) end function Private.OnReadyCheckHeartbeat(_, text, _, sender) - if sender == GetUnitName('player', true) then return end + if sender == GetRealUnitName('player') then return end local acceptReadyCheck = function (skipVisibility) if not skipVisibility and not _G.ReadyCheckFrameYesButton:IsVisible() then return end @@ -525,7 +525,7 @@ function Private.OnDeclineBattleground(_, _, _, sender) data.battlegroundStatus = BattlegroundStatus.Declined end - if sender ~= GetUnitName('player', true) and IsLeaderOrAssistant(data.units.primary) then + if sender ~= GetRealUnitName('player') and IsLeaderOrAssistant(data.units.primary) then Private.DisableEntryButton() end diff --git a/Utils.lua b/Utils.lua index 26e2fa7..21e7275 100644 --- a/Utils.lua +++ b/Utils.lua @@ -6,6 +6,7 @@ local IsInRaid = IsInRaid local IsInGroup = IsInGroup local UnitIsGroupLeader = UnitIsGroupLeader local UnitIsGroupAssistant = UnitIsGroupAssistant +local UnitNameUnmodified = UnitNameUnmodified local LE_PARTY_CATEGORY_HOME = LE_PARTY_CATEGORY_HOME local LE_PARTY_CATEGORY_INSTANCE = LE_PARTY_CATEGORY_INSTANCE local floor = math.floor @@ -135,3 +136,10 @@ end function Namespace.Utils.IsLeaderOrAssistant(unit) return UnitIsGroupLeader(unit) or UnitIsGroupAssistant(unit) end + +function Namespace.Utils.GetRealUnitName(unit) + local name, realm = UnitNameUnmodified(unit) + if realm == nil then return name end + + return name .. '-' .. realm +end