Skip to content

Commit

Permalink
fixed "Unknown" players
Browse files Browse the repository at this point in the history
- If for any reason players were created before their info were received (ex: players named "Unknown"), we attempt to fix them with this approach.
- Added stripping realm name from player's name in case of cross-realm feature.
  • Loading branch information
bkader committed Jan 12, 2021
1 parent fc2934a commit eeb6017
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion Skada/Skada.lua
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ local wasinparty, wasininstance, wasinpvp = false
-- cache frequently used globlas
local tsort, tinsert, tremove, tmaxn = table.sort, table.insert, table.remove, table.maxn
local next, pairs, ipairs, type = next, pairs, ipairs, type
local tonumber, tostring, format = tonumber, tostring, string.format
local tonumber, tostring, format, strsplit = tonumber, tostring, string.format, strsplit
local math_floor, math_max = math.floor, math.max
local band, time = bit.band, time
local GetNumPartyMembers, GetNumRaidMembers = GetNumPartyMembers, GetNumRaidMembers
Expand Down Expand Up @@ -1148,9 +1148,25 @@ function Skada:get_player(set, playerid, playername, playerflag)
end
end

-- strip realm name in case of cross-realm feature
local pname, realm = strsplit("-", playername, 2)
player.name = pname or playername

tinsert(set.players, player)
end

-- fix players created before had their info
if player.name == UNKNOWN and playername == UNKNOWN then
local pname, _ = strsplit("-", playername, 2) -- cross-realm
player.name = pname or playername
if not player.class then
player.class = select(2, UnitClass(playername))
end
if not player.role then
player.role = self:UnitGroupRolesAssigned(playername)
end
end

player.first = player.first or now
player.last = now
changed = true
Expand Down

0 comments on commit eeb6017

Please sign in to comment.