Skip to content

Commit

Permalink
rewrite callbacks args and fix enemies lua error
Browse files Browse the repository at this point in the history
  • Loading branch information
bkader committed Jan 9, 2023
1 parent aa3df73 commit dd4e7d8
Show file tree
Hide file tree
Showing 20 changed files with 273 additions and 273 deletions.
26 changes: 13 additions & 13 deletions Skada/Core/Core.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1641,7 +1641,7 @@ function Skada:GetPlayer(set, guid, name, flag)

set.actors[#set.actors + 1] = player

-- not all modules provide playerflags
-- not all modules provide flags
if player.flag == nil and flag then
player.flag = flag
end
Expand Down Expand Up @@ -1791,10 +1791,10 @@ do
end

-- attempts to find the player guid on Russian clients.
local function find_name_declension(text, playername)
local function find_name_declension(text, actorname)
for gender = 2, 3 do
for decset = 1, GetNumDeclensionSets(playername, gender) do
local ownerName = DeclineName(playername, gender, decset)
for decset = 1, GetNumDeclensionSets(actorname, gender) do
local ownerName = DeclineName(actorname, gender, decset)
if validate_pet_owner(text, ownerName) or find(text, ownerName) then
return true
end
Expand Down Expand Up @@ -1873,27 +1873,27 @@ do
action.petname = nil -- clear it

-- 1: group member / true: player / false: everything else
if is_player(action.playerid, action.playername, action.playerflags) ~= false then return end
if is_player(action.actorid, action.actorname, action.actorflags) ~= false then return end

local owner = fix_pets_handler(action.playerid, action.playerflags)
local owner = fix_pets_handler(action.actorid, action.actorflags)
if owner then
if P.mergepets then
action.petname = action.playername
action.playerid = owner.id
action.playername = owner.name
action.petname = action.actorname
action.actorid = owner.id
action.actorname = owner.name

if action.spellname and action.playername then
if action.spellname and action.actorname then
action.spellname = format("%s (%s)", action.spellname, action.petname)
end
else
-- just append the creature id to the player
action.playerid = format("%s%s", owner.id, GetCreatureId(action.playerid))
action.playername = format("%s <%s>", action.playername, owner.name)
action.actorid = format("%s%s", owner.id, GetCreatureId(action.actorid))
action.actorname = format("%s <%s>", action.actorname, owner.name)
end
else
-- if for any reason we fail to find the pets, we simply
-- adds them separately as a single entry.
action.playerid = action.playername
action.actorid = action.actorname
end
end

Expand Down
12 changes: 6 additions & 6 deletions Skada/Libs/SpecializedLibBars-1.0/SpecializedLibBars-1.0.lua
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,9 @@ end
do
local function anchorOnMouseDown(self, button)
local p = self:GetParent()
if p.locked then
stretchOnMouseDown(p.stretcher, button)
elseif not p.locked and not p.isMoving then
if p.locked or button == "MiddleButton" then
stretchOnMouseDown(p.stretcher, "LeftButton")
elseif button == "LeftButton" and not p.locked and not p.isMoving then
p.isMoving = true

self.startX = p:GetLeft()
Expand All @@ -227,9 +227,9 @@ do

local function anchorOnMouseUp(self, button)
local p = self:GetParent()
if p.locked then
stretchOnMouseUp(p.stretcher, button)
elseif not p.locked and p.isMoving then
if p.locked or button == "MiddleButton" then
stretchOnMouseUp(p.stretcher, "LeftButton")
elseif button == "LeftButton" and not p.locked and p.isMoving then
p.isMoving = nil
p:StopMovingOrSizing()

Expand Down
46 changes: 23 additions & 23 deletions Skada/Modules/Absorbs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -262,43 +262,43 @@ Skada:RegisterModule("Absorbs", function(L, P)
end
end

local function log_spellcast(set, playerid, playername, playerflags, spellid, spellschool)
local function log_spellcast(set, actorid, actorname, actorflags, spellid, spellschool)
if not set or (set == Skada.total and not P.totalidc) then return end

local player = Skada:FindPlayer(set, playerid, playername, playerflags)
if player and player.absorbspells and player.absorbspells[spellid] then
player.absorbspells[spellid].casts = (player.absorbspells[spellid].casts or 1) + 1
local actor = Skada:FindPlayer(set, actorid, actorname, actorflags)
if actor and actor.absorbspells and actor.absorbspells[spellid] then
actor.absorbspells[spellid].casts = (actor.absorbspells[spellid].casts or 1) + 1

-- fix possible missing spell school.
if not player.absorbspells[spellid].school and spellschool then
player.absorbspells[spellid].school = spellschool
if not actor.absorbspells[spellid].school and spellschool then
actor.absorbspells[spellid].school = spellschool
end
end
end

local function log_absorb(set, nocount)
if not absorb.spellid or not absorb.amount or absorb.amount == 0 then return end

local player = Skada:GetPlayer(set, absorb.playerid, absorb.playername)
if not player then
local actor = Skada:GetPlayer(set, absorb.actorid, absorb.actorname)
if not actor then
return
elseif player.role ~= "DAMAGER" and not passiveSpells[absorb.spellid] and not nocount then
Skada:AddActiveTime(set, player, absorb.dstName)
elseif actor.role ~= "DAMAGER" and not passiveSpells[absorb.spellid] and not nocount then
Skada:AddActiveTime(set, actor, absorb.dstName)
end

-- add absorbs amount
player.absorb = (player.absorb or 0) + absorb.amount
actor.absorb = (actor.absorb or 0) + absorb.amount
set.absorb = (set.absorb or 0) + absorb.amount

-- saving this to total set may become a memory hog deluxe.
if set == Skada.total and not P.totalidc then return end

-- record the spell
local spell = player.absorbspells and player.absorbspells[absorb.spellid]
local spell = actor.absorbspells and actor.absorbspells[absorb.spellid]
if not spell then
player.absorbspells = player.absorbspells or {}
actor.absorbspells = actor.absorbspells or {}
spell = {school = absorb.school, amount = absorb.amount, count = 1}
player.absorbspells[absorb.spellid] = spell
actor.absorbspells[absorb.spellid] = spell
else
if not spell.school and absorb.school then
spell.school = absorb.school
Expand Down Expand Up @@ -647,9 +647,9 @@ Skada:RegisterModule("Absorbs", function(L, P)
-- a previous shield, we attributed dumbly to it.
-- the "true" at the end is so we don't update the spell count or active time.
if absorbed > 0 and pshield then
absorb.playerid = pshield.srcGUID
absorb.playername = pshield.srcName
absorb.playerflags = pshield.srcFlags
absorb.actorid = pshield.srcGUID
absorb.actorname = pshield.srcName
absorb.actorflags = pshield.srcFlags
absorb.dstName = dstName

absorb.spellid = pshield.spellid
Expand All @@ -676,9 +676,9 @@ Skada:RegisterModule("Absorbs", function(L, P)
shields[dstName][s.spellid][s.srcName].amount = s.amount - absorbed
shields[dstName][s.spellid][s.srcName].full = nil

absorb.playerid = s.srcGUID
absorb.playername = s.srcName
absorb.playerflags = s.srcFlags
absorb.actorid = s.srcGUID
absorb.actorname = s.srcName
absorb.actorflags = s.srcFlags
absorb.dstName = dstName

absorb.spellid = s.spellid
Expand All @@ -697,9 +697,9 @@ Skada:RegisterModule("Absorbs", function(L, P)
shields[dstName][s.spellid][s.srcName] = del(shields[dstName][s.spellid][s.srcName])
end

absorb.playerid = s.srcGUID
absorb.playername = s.srcName
absorb.playerflags = s.srcFlags
absorb.actorid = s.srcGUID
absorb.actorname = s.srcName
absorb.actorflags = s.srcFlags
absorb.dstName = dstName

absorb.spellid = s.spellid
Expand Down
24 changes: 12 additions & 12 deletions Skada/Modules/Auras.lua
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,10 @@ do

-- 3. retrieve the actor.
if is_enemy then -- enemy?
return Skada:GetEnemy(set, info.playername, info.playerid, info.playerflags, true)
return Skada:GetEnemy(set, info.actorname, info.actorid, info.actorflags, true)
end

return Skada:GetPlayer(set, info.playerid, info.playername, info.playerflags) -- player?
return Skada:GetPlayer(set, info.actorid, info.actorname, info.actorflags) -- player?
end

-- handles SPELL_AURA_APPLIED event
Expand Down Expand Up @@ -568,9 +568,9 @@ Skada:RegisterModule("Buffs", function(_, P, _, C)

local function handle_buff(_, event, srcGUID, srcName, srcFlags, dstGUID, dstName, dstFlags, spellid, _, school, auratype)
if spellid and not ignored_buffs[spellid] and (auratype == "BUFF" or special_buffs[spellid]) then
aura.playerid = dstGUID
aura.playername = dstName
aura.playerflags = dstFlags
aura.actorid = dstGUID
aura.actorname = dstName
aura.actorflags = dstFlags
aura.dstName = nil

aura.spellid = spellid
Expand Down Expand Up @@ -737,7 +737,7 @@ Skada:RegisterModule("Debuffs", function(_, _, _, C)
local function handle_debuff(_, event, srcGUID, srcName, srcFlags, dstGUID, dstName, dstFlags, spellid, _, school, auratype)
if not spellid or ignored_debuffs[spellid] or auratype ~= "DEBUFF" then return end

aura.playerid, aura.playername, aura.playerflags = Skada:FixMyPets(srcGUID, srcName, srcFlags)
aura.actorid, aura.actorname, aura.actorflags = Skada:FixMyPets(srcGUID, srcName, srcFlags)
aura.dstName = Skada:FixPetsName(dstGUID, dstName, dstFlags)
aura.spellid = -spellid
aura.school = school
Expand Down Expand Up @@ -895,9 +895,9 @@ Skada:RegisterModule("Enemy Buffs", function(_, P, _, C)

local function handle_buff(_, event, _, _, _, dstGUID, dstName, dstFlags, spellid, _, school, auratype)
if spellid and not ignored_buffs[spellid] and (auratype == "BUFF" or special_buffs[spellid]) then
aura.playerid = dstGUID
aura.playername = dstName
aura.playerflags = dstFlags
aura.actorid = dstGUID
aura.actorname = dstName
aura.actorflags = dstFlags
aura.dstName = nil

aura.spellid = spellid
Expand Down Expand Up @@ -977,9 +977,9 @@ Skada:RegisterModule("Enemy Debuffs", function(_, _, _, C)
local function handle_debuff(_, event, srcGUID, srcName, srcFlags, dstGUID, dstName, dstFlags, spellid, _, school, auratype)
if not spellid or ignored_debuffs[spellid] or auratype ~= "DEBUFF" then return end

aura.playerid = srcGUID
aura.playername = srcName
aura.playerflags = srcFlags
aura.actorid = srcGUID
aura.actorname = srcName
aura.actorflags = srcFlags
aura.dstName = Skada:FixPetsName(dstGUID, dstName, dstFlags)

aura.spellid = -spellid
Expand Down
56 changes: 28 additions & 28 deletions Skada/Modules/Damage.lua
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ Skada:RegisterModule("Damage", function(L, P)
-- no matter their role or damage amount, since pets aren't considered.
local whitelist = {}

local function log_spellcast(set, playerid, playername, playerflags, spellname, spellschool)
local function log_spellcast(set, actorid, actorname, actorflags, spellname, spellschool)
if not set or (set == Skada.total and not P.totalidc) then return end

local player = Skada:FindPlayer(set, playerid, playername, playerflags)
if not player or not player.damagespells then return end
local actor = Skada:FindPlayer(set, actorid, actorname, actorflags)
if not actor or not actor.damagespells then return end

local spell = player.damagespells[spellname] or player.damagespells[spellname..L["DoT"]]
local spell = actor.damagespells[spellname] or actor.damagespells[spellname..L["DoT"]]
if not spell then return end

-- because some DoTs don't have an initial damage
Expand All @@ -74,28 +74,28 @@ Skada:RegisterModule("Damage", function(L, P)
local function log_damage(set, isdot)
if not dmg.spellid or not dmg.amount then return end

local player = Skada:GetPlayer(set, dmg.playerid, dmg.playername, dmg.playerflags)
if not player then
local actor = Skada:GetPlayer(set, dmg.actorid, dmg.actorname, dmg.actorflags)
if not actor then
return
elseif dmg.amount > 0 and not dmg.petname then
add_actor_time(set, player, dmg.spellid, dmg.dstName)
add_actor_time(set, actor, dmg.spellid, dmg.dstName)
end

player.damage = (player.damage or 0) + dmg.amount
actor.damage = (actor.damage or 0) + dmg.amount
set.damage = (set.damage or 0) + dmg.amount

-- add pet damage
if dmg.petname then
player.petdamage = (player.petdamage or 0) + dmg.amount
actor.petdamage = (actor.petdamage or 0) + dmg.amount
end

-- absorbed damage
local absorbed = dmg.absorbed or 0

if player.totaldamage then
player.totaldamage = player.totaldamage + dmg.amount + absorbed
if actor.totaldamage then
actor.totaldamage = actor.totaldamage + dmg.amount + absorbed
elseif absorbed > 0 then
player.totaldamage = player.damage + absorbed
actor.totaldamage = actor.damage + absorbed
end

if set.totaldamage then
Expand All @@ -104,39 +104,39 @@ Skada:RegisterModule("Damage", function(L, P)
set.totaldamage = set.damage + absorbed
end

if dmg.petname and player.pettotaldamage then
player.pettotaldamage = player.pettotaldamage + dmg.amount + absorbed
if dmg.petname and actor.pettotaldamage then
actor.pettotaldamage = actor.pettotaldamage + dmg.amount + absorbed
elseif dmg.petname and absorbed > 0 then
player.pettotaldamage = player.petdamage + absorbed
actor.pettotaldamage = actor.petdamage + absorbed
end

-- add the damage overkill
local overkill = (dmg.overkill and dmg.overkill > 0) and dmg.overkill or nil
if overkill then
set.overkill = (set.overkill or 0) + dmg.overkill
player.overkill = (player.overkill or 0) + dmg.overkill
actor.overkill = (actor.overkill or 0) + dmg.overkill
end

-- saving this to total set may become a memory hog deluxe.
if set == Skada.total and not P.totalidc then return end

-- spell
local spellname = dmg.spellname .. (isdot and L["DoT"] or "")
local spell = player.damagespells and player.damagespells[spellname]
local spell = actor.damagespells and actor.damagespells[spellname]
if not spell then
player.damagespells = player.damagespells or {}
actor.damagespells = actor.damagespells or {}
spell = {id = dmg.spellid, school = dmg.school, amount = 0}
player.damagespells[spellname] = spell
actor.damagespells[spellname] = spell
elseif dmg.spellid and dmg.spellid ~= spell.id then
if dmg.school and dmg.school ~= spell.school then
spellname = spellname .. " (" .. (spellschools[dmg.school] and spellschools[dmg.school].name or L["Other"]) .. ")"
else
spellname = GetSpellInfo(dmg.spellid)
end
if not player.damagespells[spellname] then
player.damagespells[spellname] = {id = dmg.spellid, school = dmg.school, amount = 0}
if not actor.damagespells[spellname] then
actor.damagespells[spellname] = {id = dmg.spellid, school = dmg.school, amount = 0}
end
spell = player.damagespells[spellname]
spell = actor.damagespells[spellname]
elseif not spell.school and dmg.school then
spell.school = dmg.school
end
Expand Down Expand Up @@ -273,9 +273,9 @@ Skada:RegisterModule("Damage", function(L, P)
end

if dmg.spellid and dmg.spellname and not ignoredSpells[dmg.spellid] then
dmg.playerid = srcGUID
dmg.playername = srcName
dmg.playerflags = srcFlags
dmg.actorid = srcGUID
dmg.actorname = srcName
dmg.actorflags = srcFlags
dmg.dstName = dstName
dmg.misstype = nil

Expand All @@ -297,9 +297,9 @@ Skada:RegisterModule("Damage", function(L, P)
end

if dmg.spellid and dmg.spellname and not ignoredSpells[dmg.spellid] then
dmg.playerid = srcGUID
dmg.playername = srcName
dmg.playerflags = srcFlags
dmg.actorid = srcGUID
dmg.actorname = srcName
dmg.actorflags = srcFlags
dmg.dstName = dstName

dmg.amount = 0
Expand Down
Loading

0 comments on commit dd4e7d8

Please sign in to comment.