From 2d243d13b5a25e46184615e7480ee73b77c95616 Mon Sep 17 00:00:00 2001 From: Tercio Jose Date: Thu, 8 Apr 2021 11:00:16 -0300 Subject: [PATCH] Make sure the arena unit exists before continuing --- classes/container_actors.lua | 18 +++++------ core/control.lua | 8 ++--- startup.lua | 60 +++++++++++++++++++++++++++++++++++- 3 files changed, 72 insertions(+), 14 deletions(-) diff --git a/classes/container_actors.lua b/classes/container_actors.lua index bbf033c6f..b0e29758b 100644 --- a/classes/container_actors.lua +++ b/classes/container_actors.lua @@ -270,7 +270,7 @@ if (_detalhes.is_in_arena) then - local my_team_color = GetBattlefieldArenaFaction() + local my_team_color = GetBattlefieldArenaFaction and GetBattlefieldArenaFaction() or 0 if (novo_objeto.grupo) then --> is ally novo_objeto.arena_ally = true @@ -287,18 +287,18 @@ novo_objeto.role = arena_props.role if (arena_props.role == "NONE") then - local role = UnitGroupRolesAssigned (nome) - if (role ~= "NONE") then + local role = UnitGroupRolesAssigned and UnitGroupRolesAssigned(nome) + if (role and role ~= "NONE") then novo_objeto.role = role end end else - local oponentes = GetNumArenaOpponentSpecs() + local oponentes = GetNumArenaOpponentSpecs and GetNumArenaOpponentSpecs() or 5 local found = false for i = 1, oponentes do local name = GetUnitName ("arena" .. i, true) if (name == nome) then - local spec = GetArenaOpponentSpec (i) + local spec = GetArenaOpponentSpec and GetArenaOpponentSpec (i) if (spec) then local id, name, description, icon, role, class = DetailsFramework.GetSpecializationInfoByID (spec) --thanks pas06 novo_objeto.role = role @@ -310,15 +310,15 @@ end end - local role = UnitGroupRolesAssigned (nome) - if (role ~= "NONE") then + local role = UnitGroupRolesAssigned and UnitGroupRolesAssigned (nome) + if (role and role ~= "NONE") then novo_objeto.role = role found = true end - if (not found and nome == _detalhes.playername) then + if (not found and nome == _detalhes.playername) then local role = UnitGroupRolesAssigned ("player") - if (role ~= "NONE") then + if (role and role ~= "NONE") then novo_objeto.role = role end end diff --git a/core/control.lua b/core/control.lua index 8e424e4a0..405be6adc 100644 --- a/core/control.lua +++ b/core/control.lua @@ -927,21 +927,21 @@ function Details:GetPlayersInArena() local aliados = GetNumGroupMembers() -- LE_PARTY_CATEGORY_HOME for i = 1, aliados-1 do - local role = UnitGroupRolesAssigned ("party" .. i) - if (role ~= "NONE") then + local role = UnitGroupRolesAssigned and UnitGroupRolesAssigned("party" .. i) or "DAMAGER" + if (role ~= "NONE" and UnitExists("party" .. i)) then local name = GetUnitName ("party" .. i, true) Details.arena_table [name] = {role = role} end end - local role = UnitGroupRolesAssigned ("player") + local role = UnitGroupRolesAssigned and UnitGroupRolesAssigned("player") or "DAMAGER" if (role ~= "NONE") then local name = GetUnitName ("player", true) Details.arena_table [name] = {role = role} end --enemies - local enemiesAmount = GetNumArenaOpponentSpecs() + local enemiesAmount = GetNumArenaOpponentSpecs and GetNumArenaOpponentSpecs() or 5 table.wipe(_detalhes.arena_enemies) for i = 1, enemiesAmount do diff --git a/startup.lua b/startup.lua index 9dc0f015a..294cf1669 100644 --- a/startup.lua +++ b/startup.lua @@ -532,9 +532,67 @@ function Details:StartMeUp() --I'll never stop! end if (DetailsFramework.IsTimewalkWoW()) then - Details:Msg("TBC Beta Version: 0008") + Details:Msg("TBC Beta Version: 0009") end + if (DetailsFramework.IsTBCWow()) then + local originalPosition + local isOnOriginalPosition = true + + local taintWarning = CreateFrame ("frame", nil, UIParent, "BackdropTemplate") + taintWarning:SetSize (500, 35) + taintWarning:SetFrameStrata ("low") + + DetailsFramework:ApplyStandardBackdrop(taintWarning) + + local warningMessage = taintWarning:CreateFontString (nil, "overlay", "GameFontNormal") + warningMessage:SetText ("< right click and choose 'Enter Battle' if 'Enter Battle' button does not work") + + C_Timer.NewTicker(1, function() + if (StaticPopup1:IsShown()) then + if (StaticPopup1.which == "CONFIRM_BATTLEFIELD_ENTRY") then + + if (StaticPopup2:IsShown()) then + if (StaticPopup2.which == "ADDON_ACTION_FORBIDDEN") then + StaticPopup_Hide("ADDON_ACTION_FORBIDDEN") + end + end + + taintWarning:Show() + taintWarning:SetPoint ("topleft", StaticPopup1, "bottomleft", 0, -10) + if (MiniMapBattlefieldFrame:IsShown())then + if (not originalPosition) then + local a = {} + for i = 1, MiniMapBattlefieldFrame:GetNumPoints() do + a[#a + 1] = {MiniMapBattlefieldFrame:GetPoint(i)} + end + originalPosition = a + end + + MiniMapBattlefieldFrame:ClearAllPoints() + MiniMapBattlefieldFrame:SetPoint("left", taintWarning, "left", 10, -2) + warningMessage:SetPoint ("left", MiniMapBattlefieldFrame, "right", 9, 0) + MiniMapBattlefieldFrame:SetFrameStrata("HIGH") + + -- + + isOnOriginalPosition = false + end + end + else + if (originalPosition and not isOnOriginalPosition) then + MiniMapBattlefieldFrame:ClearAllPoints() + for i = 1, #originalPosition do + MiniMapBattlefieldFrame:SetPoint(unpack (originalPosition[i])) + end + taintWarning:Hide() + isOnOriginalPosition = true + end + end + end) + end + + function Details:InstallOkey() return true end