diff --git a/DeathLog.lua b/DeathLog.lua index cf167c65..78aa7b57 100644 --- a/DeathLog.lua +++ b/DeathLog.lua @@ -510,7 +510,8 @@ function selfDeathAlert(death_source_str) death_source = npc_to_id[death_source_str] end - msg = encodeMessage(UnitName("player"), guildName, death_source, race_id, class_id, UnitLevel("player"), instance_id, map, position) + local name, realm = UnitFullName("player") + msg = encodeMessage(name .. "-" .. realm, guildName, death_source, race_id, class_id, UnitLevel("player"), instance_id, map, position) if msg == nil then return end local channel_num = GetChannelName(death_alerts_channel) @@ -609,7 +610,14 @@ end local function deathlogReceiveChannelMessage(sender, data) if data == nil then return end local decoded_player_data = decodeMessage(data) - if sender ~= decoded_player_data["name"] then return end + local my_realm = GetNormalizedRealmName() + local sender_name, sender_realm = string.split("-", sender) + -- check for local or connected realms and handle backward compat + if sender_realm == nil then + sender_realm = my_realm + sender = sender_name .. "-" .. my_realm + end + if sender ~= decoded_player_data["name"] and sender ~= decoded_player_data["name"] .. "-" .. my_realm then return end if isValidEntry(decoded_player_data) == false then return end local checksum = fletcher16(decoded_player_data) @@ -626,10 +634,9 @@ local function deathlogReceiveChannelMessage(sender, data) local guildName, guildRankName, guildRankIndex = GetGuildInfo("player"); if decoded_player_data['guild'] == guildName then - local name_long = sender .. "-" .. GetNormalizedRealmName() for i = 1, GetNumGuildMembers() do local name, _, _, level, class_str, _, _, _, _, _, class = GetGuildRosterInfo(i) - if name_long == name and level == decoded_player_data["level"] then + if sender == name and level == decoded_player_data["level"] then death_ping_lru_cache_tbl[checksum]["player_data"]["in_guild"] = 1 local delay = math.random(0,10) C_Timer.After(delay, function() diff --git a/Hardcore.lua b/Hardcore.lua index 793cac39..2c15b103 100644 --- a/Hardcore.lua +++ b/Hardcore.lua @@ -2454,8 +2454,7 @@ function Hardcore:CHAT_MSG_ADDON(prefix, datastr, scope, sender) return end if command == COMM_COMMANDS[5] then -- Received request for hc character data - local name, _ = string.split("-", sender) - Hardcore:SendCharacterData(name) + Hardcore:SendCharacterData(sender) return end if command == COMM_COMMANDS[14] then @@ -2466,7 +2465,6 @@ function Hardcore:CHAT_MSG_ADDON(prefix, datastr, scope, sender) end end if command == COMM_COMMANDS[4] then -- Received hc character data - local name, _ = string.split("-", sender) local version_str, creation_time, achievements_str, _, party_mode_str, _, _, team_str, hc_tag, passive_achievements_str, verif_status, verif_details = string.split(COMM_FIELD_DELIM, data) local achievements_l = { string.split(COMM_SUBFIELD_DELIM, achievements_str) } @@ -2496,7 +2494,7 @@ function Hardcore:CHAT_MSG_ADDON(prefix, datastr, scope, sender) verif_details = "(unknown - version not supported)" end - other_hardcore_character_cache[name] = { + other_hardcore_character_cache[sender] = { first_recorded = creation_time, achievements = other_achievements_ds, passive_achievements = other_passive_achievements_ds, @@ -2508,7 +2506,7 @@ function Hardcore:CHAT_MSG_ADDON(prefix, datastr, scope, sender) verification_status = verif_status, verification_details = verif_details } - hardcore_modern_menu_state.changeset[string.split("-", name)] = 1 + hardcore_modern_menu_state.changeset[sender] = 1 return end if command == COMM_COMMANDS[9] then -- Appeal achievement @@ -2667,7 +2665,7 @@ function Hardcore:GUILD_ROSTER_UPDATE(...) level = level, classDisplayName = classDisplayName, } - hardcore_modern_menu_state.changeset[(string.split("-", name))] = 1 + hardcore_modern_menu_state.changeset[name] = 1 end end @@ -3711,7 +3709,7 @@ function Hardcore:CheckVersionsAndUpdate(playername, versionstring) guild_versions[playername] = versionstring hardcore_modern_menu_state.guild_versions[playername] = versionstring hardcore_modern_menu_state.guild_versions_status[playername] = guild_versions_status[playername] - hardcore_modern_menu_state.changeset[(string.split("-", playername))] = 1 + hardcore_modern_menu_state.changeset[playername] = 1 end function Hardcore:UpdateGuildRosterRows() diff --git a/MainMenu.lua b/MainMenu.lua index 36c8e07b..8bbc28ee 100644 --- a/MainMenu.lua +++ b/MainMenu.lua @@ -86,38 +86,34 @@ local sort_functions = { return t1 < t2 end, ["simpledate"] = function(t, a, b) - local player_name_short = string.split("-", a) local t1 = "" - if other_hardcore_character_cache[player_name_short] == nil then + if other_hardcore_character_cache[a] == nil then t1 = "" else - t1 = other_hardcore_character_cache[player_name_short].first_recorded or "" + t1 = other_hardcore_character_cache[a].first_recorded or "" end local t2 = "" - player_name_short = string.split("-", b) - if other_hardcore_character_cache[player_name_short] == nil then + if other_hardcore_character_cache[b] == nil then t2 = "" else - t2 = other_hardcore_character_cache[player_name_short].first_recorded or "" + t2 = other_hardcore_character_cache[b].first_recorded or "" end return t1 > t2 end, ["rsimpledate"] = function(t, a, b) - local player_name_short = string.split("-", a) local t1 = "" - if other_hardcore_character_cache[player_name_short] == nil then + if other_hardcore_character_cache[a] == nil then t1 = "" else - t1 = other_hardcore_character_cache[player_name_short].first_recorded or "" + t1 = other_hardcore_character_cache[a].first_recorded or "" end local t2 = "" - player_name_short = string.split("-", b) - if other_hardcore_character_cache[player_name_short] == nil then + if other_hardcore_character_cache[b] == nil then t2 = "" else - t2 = other_hardcore_character_cache[player_name_short].first_recorded or "" + t2 = other_hardcore_character_cache[b].first_recorded or "" end return t1 < t2 end, @@ -128,110 +124,98 @@ local sort_functions = { return t[b]["playedtime"] < t[a]["playedtime"] end, ["achievements"] = function(t, a, b) - local player_name_short = string.split("-", a) local t1 = 0 - if other_hardcore_character_cache[player_name_short] == nil then + if other_hardcore_character_cache[a] == nil then t1 = 0 else - t1 = #other_hardcore_character_cache[player_name_short].achievements or 0 + t1 = #other_hardcore_character_cache[a].achievements or 0 end local t2 = 0 - player_name_short = string.split("-", b) - if other_hardcore_character_cache[player_name_short] == nil then + if other_hardcore_character_cache[b] == nil then t2 = 0 else - t2 = #other_hardcore_character_cache[player_name_short].achievements or 0 + t2 = #other_hardcore_character_cache[b].achievements or 0 end return t1 > t2 end, ["rachievements"] = function(t, a, b) - local player_name_short = string.split("-", a) local t1 = 0 - if other_hardcore_character_cache[player_name_short] == nil then + if other_hardcore_character_cache[a] == nil then t1 = 0 else - t1 = #other_hardcore_character_cache[player_name_short].achievements or 0 + t1 = #other_hardcore_character_cache[a].achievements or 0 end local t2 = 0 - player_name_short = string.split("-", b) - if other_hardcore_character_cache[player_name_short] == nil then + if other_hardcore_character_cache[b] == nil then t2 = 0 else - t2 = #other_hardcore_character_cache[player_name_short].achievements or 0 + t2 = #other_hardcore_character_cache[b].achievements or 0 end return t1 < t2 end, ["mode"] = function(t, a, b) - local player_name_short = string.split("-", a) local t1 = "None" - if other_hardcore_character_cache[player_name_short] == nil then + if other_hardcore_character_cache[a] == nil then t1 = "None" else - t1 = other_hardcore_character_cache[player_name_short].party_mode or "None" + t1 = other_hardcore_character_cache[a].party_mode or "None" end local t2 = "None" - player_name_short = string.split("-", b) - if other_hardcore_character_cache[player_name_short] == nil then + if other_hardcore_character_cache[b] == nil then t2 = "None" else - t2 = other_hardcore_character_cache[player_name_short].party_mode or "None" + t2 = other_hardcore_character_cache[b].party_mode or "None" end return t1 > t2 end, ["rmode"] = function(t, a, b) - local player_name_short = string.split("-", a) local t1 = "None" - if other_hardcore_character_cache[player_name_short] == nil then + if other_hardcore_character_cache[a] == nil then t1 = "None" else - t1 = other_hardcore_character_cache[player_name_short].party_mode or "None" + t1 = other_hardcore_character_cache[a].party_mode or "None" end local t2 = "None" - player_name_short = string.split("-", b) - if other_hardcore_character_cache[player_name_short] == nil then + if other_hardcore_character_cache[b] == nil then t2 = "None" else - t2 = other_hardcore_character_cache[player_name_short].party_mode or "None" + t2 = other_hardcore_character_cache[b].party_mode or "None" end return t1 < t2 end, ["hctag"] = function(t, a, b) - local player_name_short = string.split("-", a) local t1 = "None" - if other_hardcore_character_cache[player_name_short] == nil then + if other_hardcore_character_cache[a] == nil then t1 = "None" else - t1 = other_hardcore_character_cache[player_name_short].hardcore_player_name or "None" + t1 = other_hardcore_character_cache[a].hardcore_player_name or "None" end local t2 = "None" - player_name_short = string.split("-", b) - if other_hardcore_character_cache[player_name_short] == nil then + if other_hardcore_character_cache[b] == nil then t2 = "None" else - t2 = other_hardcore_character_cache[player_name_short].hardcore_player_name or "None" + t2 = other_hardcore_character_cache[b].hardcore_player_name or "None" end return t1 > t2 end, ["rhctag"] = function(t, a, b) - local player_name_short = string.split("-", a) local t1 = "None" - if other_hardcore_character_cache[player_name_short] == nil then + if other_hardcore_character_cache[a] == nil then t1 = "None" else - t1 = other_hardcore_character_cache[player_name_short].hardcore_player_name or "None" + t1 = other_hardcore_character_cache[a].hardcore_player_name or "None" end local t2 = "None" - player_name_short = string.split("-", b) - if other_hardcore_character_cache[player_name_short] == nil then + if other_hardcore_character_cache[b] == nil then t2 = "None" else - t2 = other_hardcore_character_cache[player_name_short].hardcore_player_name or "None" + t2 = other_hardcore_character_cache[b].hardcore_player_name or "None" end return t1 < t2 end, @@ -1332,20 +1316,20 @@ local function GetSpacelessRealmName() end local function DrawAccountabilityTab(container) - local function updateLabelData(_label_tbls, player_name_short) - if other_hardcore_character_cache[player_name_short] ~= nil then - _label_tbls["party_mode_label"]:SetText(other_hardcore_character_cache[player_name_short].party_mode) + local function updateLabelData(_label_tbls, player_name) + if other_hardcore_character_cache[player_name] ~= nil then + _label_tbls["party_mode_label"]:SetText(other_hardcore_character_cache[player_name].party_mode) _label_tbls["first_recorded_label"]:SetText( - date("%m/%d/%y", other_hardcore_character_cache[player_name_short].first_recorded or 0) + date("%m/%d/%y", other_hardcore_character_cache[player_name].first_recorded or 0) ) if - other_hardcore_character_cache[player_name_short].achievements == nil - or #other_hardcore_character_cache[player_name_short].achievements > 0 - or #other_hardcore_character_cache[player_name_short].passive_achievements > 0 + other_hardcore_character_cache[player_name].achievements == nil + or #other_hardcore_character_cache[player_name].achievements > 0 + or #other_hardcore_character_cache[player_name].passive_achievements > 0 then local inline_text = "" - for i, achievement_name in ipairs(other_hardcore_character_cache[player_name_short].achievements) do + for i, achievement_name in ipairs(other_hardcore_character_cache[player_name].achievements) do if _G.achievements[achievement_name] then inline_text = inline_text .. "|T" @@ -1354,7 +1338,7 @@ local function DrawAccountabilityTab(container) end end for i, achievement_name in - ipairs(other_hardcore_character_cache[player_name_short].passive_achievements) + ipairs(other_hardcore_character_cache[player_name].passive_achievements) do if _G.passive_achievements[achievement_name] then inline_text = inline_text @@ -1373,7 +1357,7 @@ local function DrawAccountabilityTab(container) end end for i, achievement_name in - ipairs(other_hardcore_character_cache[player_name_short].passive_achievements) + ipairs(other_hardcore_character_cache[player_name].passive_achievements) do if _G.passive_achievements[achievement_name] then GameTooltip:AddLine(_G.passive_achievements[achievement_name].title) @@ -1388,26 +1372,25 @@ local function DrawAccountabilityTab(container) _label_tbls["achievement_label"]:SetText("") end _label_tbls["hc_tag_label"]:SetText( - other_hardcore_character_cache[player_name_short].hardcore_player_name or "" + other_hardcore_character_cache[player_name].hardcore_player_name or "" ) end - local player_name_long = player_name_short .. "-" .. GetSpacelessRealmName() - if hardcore_modern_menu_state.guild_online[player_name_long] ~= nil then + if hardcore_modern_menu_state.guild_online[player_name] ~= nil then local version_text if ( - hardcore_modern_menu_state.online_pulsing[player_name_long] - and hardcore_modern_menu_state.guild_online[player_name_long] - ) or player_name_short == UnitName("player") + hardcore_modern_menu_state.online_pulsing[player_name] + and hardcore_modern_menu_state.guild_online[player_name] + ) or player_name == UnitName("player") .. "-" .. GetSpacelessRealmName() then - if player_name_short == UnitName("player") then + if player_name == UnitName("player") .. "-" .. GetSpacelessRealmName() then version_text = GetAddOnMetadata("Hardcore", "Version") else - version_text = hardcore_modern_menu_state.guild_versions[player_name_long] + version_text = hardcore_modern_menu_state.guild_versions[player_name] end - if hardcore_modern_menu_state.guild_versions_status[player_name_long] == "updated" then + if hardcore_modern_menu_state.guild_versions_status[player_name] == "updated" then version_text = "|c0000ff00" .. version_text .. "|r" else version_text = "|c00ffff00" .. version_text .. "|r" @@ -1417,11 +1400,12 @@ local function DrawAccountabilityTab(container) end _label_tbls["version_label"]:SetText(version_text) - _label_tbls["level_label"]:SetText(hardcore_modern_menu_state.guild_online[player_name_long].level) + _label_tbls["level_label"]:SetText(hardcore_modern_menu_state.guild_online[player_name].level) end end - local function addEntry(_scroll_frame, player_name_short, _self_name) + local function addEntry(_scroll_frame, player_name, _self_name) --local _player_name = player_name_short .. "-" .. GetSpacelessRealmName() + local player_name_short = string.split("-", player_name) local entry = AceGUI:Create("SimpleGroup") entry:SetLayout("Flow") entry:SetFullWidth(true) @@ -1432,45 +1416,45 @@ local function DrawAccountabilityTab(container) name_label:SetText(player_name_short) name_label:SetFont("Fonts\\FRIZQT__.TTF", 12, "") entry:AddChild(name_label) - hardcore_modern_menu_state.entry_tbl[player_name_short] = {} + hardcore_modern_menu_state.entry_tbl[player_name] = {} local level_label = AceGUI:Create("Label") level_label:SetWidth(50) level_label:SetFont("Fonts\\FRIZQT__.TTF", 12, "") entry:AddChild(level_label) - hardcore_modern_menu_state.entry_tbl[player_name_short]["level_label"] = level_label + hardcore_modern_menu_state.entry_tbl[player_name]["level_label"] = level_label local version_label = AceGUI:Create("Label") version_label:SetWidth(80) version_label:SetFont("Fonts\\FRIZQT__.TTF", 12, "") entry:AddChild(version_label) - hardcore_modern_menu_state.entry_tbl[player_name_short]["version_label"] = version_label + hardcore_modern_menu_state.entry_tbl[player_name]["version_label"] = version_label local party_mode_label = AceGUI:Create("Label") party_mode_label:SetWidth(75) party_mode_label:SetFont("Fonts\\FRIZQT__.TTF", 12, "") entry:AddChild(party_mode_label) - hardcore_modern_menu_state.entry_tbl[player_name_short]["party_mode_label"] = party_mode_label + hardcore_modern_menu_state.entry_tbl[player_name]["party_mode_label"] = party_mode_label local first_recorded_label = AceGUI:Create("Label") first_recorded_label:SetWidth(85) first_recorded_label:SetFont("Fonts\\FRIZQT__.TTF", 12, "") entry:AddChild(first_recorded_label) - hardcore_modern_menu_state.entry_tbl[player_name_short]["first_recorded_label"] = first_recorded_label + hardcore_modern_menu_state.entry_tbl[player_name]["first_recorded_label"] = first_recorded_label local achievement_label = AceGUI:Create("InteractiveLabel") achievement_label:SetWidth(320) achievement_label:SetFont("Fonts\\FRIZQT__.TTF", 12, "") entry:AddChild(achievement_label) - hardcore_modern_menu_state.entry_tbl[player_name_short]["achievement_label"] = achievement_label + hardcore_modern_menu_state.entry_tbl[player_name]["achievement_label"] = achievement_label local hc_tag_label = AceGUI:Create("Label") hc_tag_label:SetWidth(75) hc_tag_label:SetFont("Fonts\\FRIZQT__.TTF", 12, "") entry:AddChild(hc_tag_label) - hardcore_modern_menu_state.entry_tbl[player_name_short]["hc_tag_label"] = hc_tag_label + hardcore_modern_menu_state.entry_tbl[player_name]["hc_tag_label"] = hc_tag_label - updateLabelData(hardcore_modern_menu_state.entry_tbl[player_name_short], player_name_short) -- , _player_name) + updateLabelData(hardcore_modern_menu_state.entry_tbl[player_name], player_name) -- , _player_name) end local scroll_container = AceGUI:Create("SimpleGroup") @@ -1628,8 +1612,7 @@ local function DrawAccountabilityTab(container) sort_functions[hardcore_modern_menu_state.accountability_sort_state] ) do - local player_name_short = string.split("-", _player_name) - addEntry(scroll_frame, player_name_short, self_name) + addEntry(scroll_frame, _player_name, self_name) end hardcore_modern_menu_state.ticker_handler = C_Timer.NewTicker(0.1, function() @@ -1661,9 +1644,8 @@ local function DrawAccountabilityTab(container) sort_functions[hardcore_modern_menu_state.accountability_sort_state] ) do - local player_name_short = string.split("-", _player_name) - if other_hardcore_character_cache[player_name_short] == nil then - RequestHCData(player_name_short) + if other_hardcore_character_cache[player_name] == nil then + RequestHCData(player_name) end end end)