More development on the Coach packager feature, /details coach
This commit is contained in:
+20
-20
@@ -35,21 +35,21 @@ Details.Coach = {
|
||||
function Details.Coach.AskRLForCoachStatus(raidLeaderName)
|
||||
Details:SendCommMessage(_G.DETAILS_PREFIX_NETWORK, Details:Serialize(_G.DETAILS_PREFIX_COACH, UnitName("player"), GetRealmName(), Details.realversion, "CIEA"), "WHISPER", raidLeaderName)
|
||||
if (_detalhes.debug) then
|
||||
Details:Msg("asked the raid leader the coach status.")
|
||||
Details:Msg("[|cFFAAFFAADetails! Coach|r] asked the raid leader the coach status.")
|
||||
end
|
||||
end
|
||||
|
||||
function Details.Coach.SendRLCombatStartNotify(raidLeaderName)
|
||||
Details:SendCommMessage(_G.DETAILS_PREFIX_NETWORK, Details:Serialize(_G.DETAILS_PREFIX_COACH, UnitName("player"), GetRealmName(), Details.realversion, "CCS"), "WHISPER", raidLeaderName)
|
||||
if (_detalhes.debug) then
|
||||
Details:Msg("sent to raid leader a combat start notification.")
|
||||
Details:Msg("[|cFFAAFFAADetails! Coach|r] sent to raid leader a combat start notification.")
|
||||
end
|
||||
end
|
||||
|
||||
function Details.Coach.SendRLCombatEndNotify(raidLeaderName)
|
||||
Details:SendCommMessage(_G.DETAILS_PREFIX_NETWORK, Details:Serialize(_G.DETAILS_PREFIX_COACH, UnitName("player"), GetRealmName(), Details.realversion, "CCE"), "WHISPER", raidLeaderName)
|
||||
if (_detalhes.debug) then
|
||||
Details:Msg("sent to raid leader a combat end notification.")
|
||||
Details:Msg("[|cFFAAFFAADetails! Coach|r] sent to raid leader a combat end notification.")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -57,7 +57,7 @@ end
|
||||
function Details.Coach.SendRaidCoachEndNotify()
|
||||
Details:SendCommMessage(_G.DETAILS_PREFIX_NETWORK, Details:Serialize(_G.DETAILS_PREFIX_COACH, UnitName("player"), GetRealmName(), Details.realversion, "CE"), "RAID")
|
||||
if (_detalhes.debug) then
|
||||
Details:Msg("sent to raid a coach end notification.")
|
||||
Details:Msg("[|cFFAAFFAADetails! Coach|r] sent to raid a coach end notification.")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -65,7 +65,7 @@ end
|
||||
function Details.Coach.SendRaidCoachStartNotify()
|
||||
Details:SendCommMessage(_G.DETAILS_PREFIX_NETWORK, Details:Serialize(_G.DETAILS_PREFIX_COACH, UnitName("player"), GetRealmName(), Details.realversion, "CS"), "RAID")
|
||||
if (_detalhes.debug) then
|
||||
Details:Msg("sent to raid a coach start notification.")
|
||||
Details:Msg("[|cFFAAFFAADetails! Coach|r] sent to raid a coach start notification.")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -98,7 +98,7 @@ function Details.Coach.StartUp()
|
||||
if (raidLeaderName) then
|
||||
--client ask for the raid leader if the Coach is enabled, GetRaidLeader returns nil is the user isn't in raid
|
||||
if (_detalhes.debug) then
|
||||
Details:Msg("sent ask to raid leader, is coach?")
|
||||
Details:Msg("[|cFFAAFFAADetails! Coach|r] sent ask to raid leader, is coach?")
|
||||
end
|
||||
Details.Coach.AskRLForCoachStatus(raidLeaderName)
|
||||
end
|
||||
@@ -117,7 +117,7 @@ function Details.Coach.StartUp()
|
||||
local raidLeaderName = Details:GetRaidLeader()
|
||||
if (raidLeaderName) then
|
||||
if (_detalhes.debug) then
|
||||
Details:Msg("sent ask to raid leader, is coach?")
|
||||
Details:Msg("[|cFFAAFFAADetails! Coach|r] sent ask to raid leader, is coach?")
|
||||
end
|
||||
Details.Coach.AskRLForCoachStatus(raidLeaderName)
|
||||
end
|
||||
@@ -142,7 +142,7 @@ function Details.Coach.StartUp()
|
||||
local raidLeaderName = Details.Coach.Client.GetLeaderName()
|
||||
if (raidLeaderName) then
|
||||
if (_detalhes.debug) then
|
||||
Details:Msg("i'm a raid assistant, sent combat start notification to raid leader.")
|
||||
Details:Msg("[|cFFAAFFAADetails! Coach|r] i'm a raid assistant, sent combat start notification to raid leader.")
|
||||
end
|
||||
Details.Coach.SendRLCombatStartNotify(raidLeaderName)
|
||||
end
|
||||
@@ -165,7 +165,7 @@ function Details.Coach.StartUp()
|
||||
local raidLeaderName = Details.Coach.Client.GetLeaderName()
|
||||
if (raidLeaderName) then
|
||||
if (_detalhes.debug) then
|
||||
Details:Msg("i'm a raid assistant, sent combat end notification to raid leader.")
|
||||
Details:Msg("[|cFFAAFFAADetails! Coach|r] i'm a raid assistant, sent combat end notification to raid leader.")
|
||||
end
|
||||
Details.Coach.SendRLCombatEndNotify(raidLeaderName)
|
||||
end
|
||||
@@ -183,7 +183,7 @@ function Details.Coach.StartUp()
|
||||
--the raid leader entered a raid instance
|
||||
Details.Coach.Disable()
|
||||
if (_detalhes.debug) then
|
||||
Details:Msg("Coach feature stopped: you entered in a raid instance.")
|
||||
Details:Msg("[|cFFAAFFAADetails! Coach|r] Coach feature stopped: you entered in a raid instance.")
|
||||
end
|
||||
end
|
||||
return
|
||||
@@ -194,7 +194,7 @@ function Details.Coach.StartUp()
|
||||
if (not Details.Coach.Server.IsEnabled()) then --the coach feature isn't running
|
||||
Details.Coach.Server.EnableCoach()
|
||||
if (_detalhes.debug) then
|
||||
Details:Msg("Coach feature is now running, if this come as surprise, use '/details coach' to disable.")
|
||||
Details:Msg("[|cFFAAFFAADetails! Coach|r] Coach feature is now running, if this come as surprise, use '/details coach' to disable.")
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -210,7 +210,7 @@ function Details.Coach.StartUp()
|
||||
local raidLeaderName = Details:GetRaidLeader()
|
||||
if (raidLeaderName) then
|
||||
if (_detalhes.debug) then
|
||||
Details:Msg("sent ask to raid leader, is coach?")
|
||||
Details:Msg("[|cFFAAFFAADetails! Coach|r] sent ask to raid leader, is coach?")
|
||||
end
|
||||
Details.Coach.AskRLForCoachStatus(raidLeaderName)
|
||||
return
|
||||
@@ -267,7 +267,7 @@ end
|
||||
function Details.Coach.Server.EnableCoach(fromStartup)
|
||||
if (not IsInRaid()) then
|
||||
if (_detalhes.debug) then
|
||||
Details:Msg("cannot enabled coach: not in raid.")
|
||||
Details:Msg("[|cFFAAFFAADetails! Coach|r] cannot enabled coach: not in raid.")
|
||||
end
|
||||
Details.coach.enabled = false
|
||||
Details.Coach.Server.enabled = false
|
||||
@@ -275,7 +275,7 @@ function Details.Coach.Server.EnableCoach(fromStartup)
|
||||
|
||||
elseif (not UnitIsGroupLeader("player")) then
|
||||
if (_detalhes.debug) then
|
||||
Details:Msg("cannot enabled coach: you aren't the raid leader.")
|
||||
Details:Msg("[|cFFAAFFAADetails! Coach|r] cannot enabled coach: you aren't the raid leader.")
|
||||
end
|
||||
Details.coach.enabled = false
|
||||
Details.Coach.Server.enabled = false
|
||||
@@ -283,7 +283,7 @@ function Details.Coach.Server.EnableCoach(fromStartup)
|
||||
|
||||
elseif (isInRaidZone()) then
|
||||
if (_detalhes.debug) then
|
||||
Details:Msg("cannot enabled coach: you are inside a raid zone.")
|
||||
Details:Msg("[|cFFAAFFAADetails! Coach|r] cannot enabled coach: you are inside a raid zone.")
|
||||
end
|
||||
Details.coach.enabled = false
|
||||
Details.Coach.Server.enabled = false
|
||||
@@ -301,7 +301,7 @@ function Details.Coach.Server.EnableCoach(fromStartup)
|
||||
|
||||
if (fromStartup) then
|
||||
if (_detalhes.debug) then
|
||||
Details:Msg("coach feature enabled, welcome back captain!")
|
||||
Details:Msg("[|cFFAAFFAADetails! Coach|r] coach feature enabled, welcome back captain!")
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -335,7 +335,7 @@ function Details.Coach.Client.EnableCoach(raidLeaderName)
|
||||
Details.Coach.EventFrame:RegisterEvent("GROUP_ROSTER_UPDATE")
|
||||
|
||||
if (_detalhes.debug) then
|
||||
Details:Msg("there's a new coach: ", raidLeaderName)
|
||||
Details:Msg("[|cFFAAFFAADetails! Coach|r] there's a new coach: ", raidLeaderName)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -396,7 +396,7 @@ Details.Coach.EventFrame:SetScript("OnEvent", function(event, ...)
|
||||
if (_G.Ambiguate(unitName .. "-" .. GetRealmName(), "none") ~= Details.Coach.Client.coachName) then
|
||||
--the raid leader has changed, finish the coach feature on the client
|
||||
if (_detalhes.debug) then
|
||||
Details:Msg("raid leader has changed, coach feature has been disabled.")
|
||||
Details:Msg("[|cFFAAFFAADetails! Coach|r] raid leader has changed, coach feature has been disabled.")
|
||||
end
|
||||
Details.Coach.Client.CoachEnd()
|
||||
end
|
||||
@@ -413,7 +413,7 @@ Details.Coach.EventFrame:SetScript("OnEvent", function(event, ...)
|
||||
if (IsInRaid()) then
|
||||
if (not isInRaidZone()) then
|
||||
if (_detalhes.debug) then
|
||||
Details:Msg("you're now the coach of the group.")
|
||||
Details:Msg("[|cFFAAFFAADetails! Coach|r] you're now the coach of the group.")
|
||||
end
|
||||
--delay to set the new leader to give time for SendRaidCoachEndNotify()
|
||||
_G.C_Timer.After(3, Details.Coach.Server.EnableCoach)
|
||||
@@ -426,7 +426,7 @@ Details.Coach.EventFrame:SetScript("OnEvent", function(event, ...)
|
||||
if (Details.Coach.IsEnabled()) then
|
||||
if (Details.Coach.Server.IsEnabled()) then
|
||||
if (_detalhes.debug) then
|
||||
Details:Msg("you're not the raid leader, disabling the coach feature.")
|
||||
Details:Msg("[|cFFAAFFAADetails! Coach|r] you're not the raid leader, disabling the coach feature.")
|
||||
end
|
||||
Details.Coach.Disable()
|
||||
end
|
||||
|
||||
+213
-129
@@ -50,6 +50,8 @@ local TOTAL_INDEXES_FOR_COMBAT_INFORMATION = 6
|
||||
|
||||
local entitySerialCounter = 0
|
||||
|
||||
local isDebugging = true
|
||||
|
||||
function Dexport() --test case
|
||||
local combat = Details:GetCurrentCombat()
|
||||
local readyToSendData = Details.packFunctions.PackCombatData(combat, 0x1)
|
||||
@@ -62,6 +64,15 @@ function Details.packFunctions.GetAllData()
|
||||
return packedData
|
||||
end
|
||||
|
||||
--debug
|
||||
function Details.packFunctions.GetAllDataDebug()
|
||||
local combat = Details:GetCurrentCombat()
|
||||
local packedData = Details.packFunctions.PackCombatData(combat, 0x13)
|
||||
|
||||
--unpack data
|
||||
Details.packFunctions.DeployPackedCombatData(packedData)
|
||||
end
|
||||
|
||||
--pack the combat
|
||||
function Details.packFunctions.PackCombatData(combatObject, flags)
|
||||
|
||||
@@ -92,6 +103,11 @@ function Details.packFunctions.PackCombatData(combatObject, flags)
|
||||
isBossEncouter and isBossEncouter.encounter or "Unknown Enemy" --5
|
||||
}
|
||||
|
||||
--if there's no combat information, indexes for combat data is zero
|
||||
if (bit.band(flags, 0x10) ~= 0) then
|
||||
TOTAL_INDEXES_FOR_COMBAT_INFORMATION = 0
|
||||
end
|
||||
|
||||
if (bit.band(flags, 0x1) ~= 0) then
|
||||
Details.packFunctions.PackDamage(combatObject)
|
||||
end
|
||||
@@ -326,11 +342,11 @@ function Details.packFunctions.AddActorInformation(actor)
|
||||
local currentIndex = #actorInformation + 1
|
||||
|
||||
--calculate where this actor will be placed on the combatData table
|
||||
local indexOnCombatDataTable = TOTAL_INDEXES_FOR_COMBAT_INFORMATION + currentIndex
|
||||
local indexOnCombatDataTable = TOTAL_INDEXES_FOR_COMBAT_INFORMATION + currentIndex + 1
|
||||
|
||||
--add the actor start information index
|
||||
actorInformationIndexes[actor.nome] = indexOnCombatDataTable
|
||||
|
||||
|
||||
--index 1: actor name
|
||||
actorInformation[currentIndex] = actor.nome or "unnamed" --[1]
|
||||
|
||||
@@ -381,6 +397,10 @@ end
|
||||
--each player will also send an enemy, the enemy will be in order of raidIndex of the player
|
||||
function Details.packFunctions.PackDamage(combatObject)
|
||||
|
||||
if (isDebugging) then
|
||||
print("PackDamage(): START.")
|
||||
end
|
||||
|
||||
--store actorObjects to pack
|
||||
local actorsToPack = {}
|
||||
|
||||
@@ -388,6 +408,9 @@ function Details.packFunctions.PackDamage(combatObject)
|
||||
local playerName = UnitName("player")
|
||||
local playerObject = combatObject:GetActor(DETAILS_ATTRIBUTE_DAMAGE, playerName)
|
||||
if (not playerObject) then
|
||||
if (isDebugging) then
|
||||
print("PackDamage(): RETURN | no player object.")
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
@@ -404,10 +427,9 @@ function Details.packFunctions.PackDamage(combatObject)
|
||||
|
||||
local playerIndex
|
||||
--check if this player has to send information about an enemy npc
|
||||
if (IsInRaid()) then
|
||||
if (IsInGroup()) then
|
||||
for i = 1, GetNumGroupMembers() do
|
||||
local unitId = "raid" .. i
|
||||
local name, rank, subgroup, level, class, fileName, zone, online, isDead, role, isML = GetRaidRosterInfo(i)
|
||||
local name = GetRaidRosterInfo(i) --, rank, subgroup, level, class, fileName, zone, online, isDead, role, isML
|
||||
if (name == playerName) then
|
||||
playerIndex = i
|
||||
break
|
||||
@@ -416,6 +438,9 @@ function Details.packFunctions.PackDamage(combatObject)
|
||||
end
|
||||
|
||||
if (not playerIndex) then --no player index
|
||||
if (isDebugging) then
|
||||
print("PackDamage(): RETURN | no player index found.")
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
@@ -517,6 +542,10 @@ function Details.packFunctions.PackDamage(combatObject)
|
||||
--amount of indexes spells are using
|
||||
actorDamageInfo[reservedSpellSizeIndex] = totalSpellIndexes
|
||||
end
|
||||
|
||||
if (isDebugging) then
|
||||
print("PackDamage(): DONE.")
|
||||
end
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------------------------------------------------------------------
|
||||
@@ -526,6 +555,9 @@ end
|
||||
--@combatData: array with strings with combat information
|
||||
--@tablePosition: first index of the first damage actor
|
||||
function Details.packFunctions.UnPackDamage(currentCombat, combatData, tablePosition)
|
||||
if (isDebugging) then
|
||||
print("UnPackDamage(): START.")
|
||||
end
|
||||
|
||||
--get the damage container
|
||||
local damageContainer = currentCombat[DETAILS_ATTRIBUTE_DAMAGE]
|
||||
@@ -539,16 +571,23 @@ function Details.packFunctions.UnPackDamage(currentCombat, combatData, tablePosi
|
||||
local actorReference = tonumber(combatData[tablePosition]) --[1]
|
||||
local actorName, actorFlag, serialNumber, class, spec = Details.packFunctions.RetriveActorInformation(combatData, actorReference)
|
||||
|
||||
if (isDebugging) then
|
||||
print("UnPackDamage(): Retrivied Data From " .. actorReference .. ":", actorName, actorFlag, serialNumber, class, spec)
|
||||
end
|
||||
|
||||
--check if all damage actors has been processed
|
||||
--if there's no actor name it means it reached the end
|
||||
if (not actorName) then
|
||||
print("damage END index (debug):", i, actorReference, "tablePosition:", tablePosition, "value:", combatData[tablePosition])
|
||||
if (isDebugging) then
|
||||
print("UnPackDamage(): BREAK damage END index:", i, actorReference, "tablePosition:", tablePosition, "value:", combatData[tablePosition])
|
||||
end
|
||||
break
|
||||
end
|
||||
|
||||
--get or create the actor object
|
||||
local actorObject = damageContainer:GetOrCreateActor(serialNumber, actorName, actorFlag, true)
|
||||
--set the actor class, spec and group
|
||||
|
||||
actorObject.classe = class
|
||||
actorObject.spec = spec
|
||||
actorObject.grupo = isActorInGroup(class, actorFlag)
|
||||
@@ -586,10 +625,17 @@ function Details.packFunctions.UnPackDamage(currentCombat, combatData, tablePosi
|
||||
tablePosition = tablePosition + spellsSize --increase table position
|
||||
end
|
||||
|
||||
if (isDebugging) then
|
||||
print("UnPackDamage(): DONE.")
|
||||
end
|
||||
|
||||
return tablePosition
|
||||
end
|
||||
|
||||
function Details.packFunctions.PackHeal(combatObject)
|
||||
if (isDebugging) then
|
||||
print("PackHeal(): START.")
|
||||
end
|
||||
|
||||
--store actorObjects to pack
|
||||
local actorsToPack = {}
|
||||
@@ -598,6 +644,9 @@ function Details.packFunctions.PackHeal(combatObject)
|
||||
local playerName = UnitName("player")
|
||||
local playerObject = combatObject:GetActor(DETAILS_ATTRIBUTE_HEAL, playerName)
|
||||
if (not playerObject) then
|
||||
if (isDebugging) then
|
||||
print("PackHeal(): RETURN | no player object.")
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
@@ -614,10 +663,9 @@ function Details.packFunctions.PackHeal(combatObject)
|
||||
|
||||
local playerIndex
|
||||
--check if this player has to send information about an enemy npc
|
||||
if (IsInRaid()) then
|
||||
if (IsInGroup()) then
|
||||
for i = 1, GetNumGroupMembers() do
|
||||
local unitId = "raid" .. i
|
||||
local name, rank, subgroup, level, class, fileName, zone, online, isDead, role, isML = GetRaidRosterInfo(i)
|
||||
local name = GetRaidRosterInfo(i)
|
||||
if (name == playerName) then
|
||||
playerIndex = i
|
||||
break
|
||||
@@ -626,6 +674,9 @@ function Details.packFunctions.PackHeal(combatObject)
|
||||
end
|
||||
|
||||
if (not playerIndex) then
|
||||
if (isDebugging) then
|
||||
print("PackHeal(): RETURN | no player index found.")
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
@@ -726,7 +777,10 @@ function Details.packFunctions.PackHeal(combatObject)
|
||||
|
||||
--amount of indexes spells are using
|
||||
actorDamageInfo[reservedSpellSizeIndex] = totalSpellIndexes
|
||||
|
||||
end
|
||||
|
||||
if (isDebugging) then
|
||||
print("PackHeal(): DONE.")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -734,17 +788,28 @@ end
|
||||
--> unpack
|
||||
|
||||
function Details.packFunctions.UnPackHeal(currentCombat, combatData, tablePosition)
|
||||
--get the damage container
|
||||
|
||||
if (isDebugging) then
|
||||
print("UnPackHeal(): START.")
|
||||
end
|
||||
|
||||
--get the healing container
|
||||
local healContainer = currentCombat[DETAILS_ATTRIBUTE_HEAL]
|
||||
|
||||
for i = 1, 199 do
|
||||
--this is the same as damage, all comments for the code are there
|
||||
local actorInfoIndex = tonumber(combatData[tablePosition]) --[1]
|
||||
local actorName, actorFlag, serialNumber, class, spec = Details.packFunctions.RetriveActorInformation(combatData, actorInfoIndex)
|
||||
local actorReference = tonumber(combatData[tablePosition]) --[1]
|
||||
local actorName, actorFlag, serialNumber, class, spec = Details.packFunctions.RetriveActorInformation(combatData, actorReference)
|
||||
|
||||
if (isDebugging) then
|
||||
print("UnPackHeal(): Retrivied Data From " .. actorReference .. ":", actorName, actorFlag, serialNumber, class, spec)
|
||||
end
|
||||
|
||||
--if there's no actor name it means it reached the end
|
||||
if (not actorName) then
|
||||
print("Heal loop has been stopped", "index:", i, "tablePosition:", tablePosition, "value:", combatData[tablePosition])
|
||||
if (isDebugging) then
|
||||
print("UnPackHeal(): BREAK | Heal loop has been stopped", "index:", i, "tablePosition:", tablePosition, "value:", combatData[tablePosition])
|
||||
end
|
||||
break
|
||||
end
|
||||
|
||||
@@ -788,125 +853,19 @@ function Details.packFunctions.UnPackHeal(currentCombat, combatData, tablePositi
|
||||
tablePosition = tablePosition + spellsSize --increase table position
|
||||
end
|
||||
|
||||
if (isDebugging) then
|
||||
print("UnPackHeal(): DONE.")
|
||||
end
|
||||
|
||||
return tablePosition
|
||||
end
|
||||
|
||||
--what this function receives?
|
||||
--@packedCombatData: packed combat, ready to be unpacked
|
||||
function Details.packFunctions.UnPackCombatData(packedCombatData)
|
||||
|
||||
if (true) then
|
||||
print("Details is calling the wrong function UnPackCombatData()")
|
||||
return
|
||||
end
|
||||
|
||||
local LibDeflate = _G.LibStub:GetLibrary("LibDeflate")
|
||||
local dataCompressed = LibDeflate:DecodeForWoWAddonChannel(packedCombatData)
|
||||
local combatDataString = LibDeflate:DecompressDeflate(dataCompressed)
|
||||
|
||||
--[=
|
||||
local function count(text, pattern)
|
||||
return select(2, text:gsub(pattern, ""))
|
||||
end
|
||||
--]=]
|
||||
|
||||
local combatData = {}
|
||||
local amountOfIndexes = count(combatDataString, ",") + 1
|
||||
print ("amountOfIndexes (debug):", amountOfIndexes)
|
||||
|
||||
while (amountOfIndexes > 0) do
|
||||
|
||||
local splitPart = {strsplit(",", combatDataString, 4000)} --strsplit(): Stack overflow, max allowed: 4000
|
||||
|
||||
if (#splitPart == 4000 and amountOfIndexes > 4000) then
|
||||
|
||||
print ("#combatDataString (debug) must be > 4000:", amountOfIndexes)
|
||||
for i = 1, 3999 do
|
||||
combatData[#combatData+1] = splitPart[i]
|
||||
end
|
||||
|
||||
--get get part that couldn't be read this loop
|
||||
combatDataString = splitPart[4000]
|
||||
amountOfIndexes = amountOfIndexes - 3999
|
||||
|
||||
print ("#combatDataString (debug) left over:", amountOfIndexes)
|
||||
else
|
||||
for i = 1, #splitPart do
|
||||
combatData[#combatData+1] = splitPart[i]
|
||||
end
|
||||
|
||||
amountOfIndexes = amountOfIndexes - #splitPart
|
||||
end
|
||||
end
|
||||
|
||||
print("total indexes (debug):", #combatData)
|
||||
|
||||
--if true then return end
|
||||
|
||||
local flags = tonumber(combatData[INDEX_EXPORT_FLAG])
|
||||
|
||||
local tablePosition = TOTAL_INDEXES_FOR_COMBAT_INFORMATION + 1 --[[ +1 to jump to damage ]]
|
||||
--tablePosition now have the first index of the actorInfoTable
|
||||
|
||||
--stop the combat if already in one
|
||||
if (Details.in_combat) then
|
||||
Details:EndCombat()
|
||||
end
|
||||
|
||||
--start a new combat
|
||||
Details:StartCombat()
|
||||
--get the current combat
|
||||
local currentCombat = Details:GetCurrentCombat()
|
||||
|
||||
--check if this export has include damage info
|
||||
if (bit.band(flags, 0x1) ~= 0) then
|
||||
--find the index where the damage information start
|
||||
for i = tablePosition, #combatData do
|
||||
if (combatData[i] == "!D") then
|
||||
tablePosition = i + 1;
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
--unpack damage
|
||||
tablePosition = Details.packFunctions.UnPackDamage(currentCombat, combatData, tablePosition)
|
||||
end
|
||||
|
||||
if (bit.band(flags, 0x2) ~= 0) then
|
||||
--find the index where the heal information start
|
||||
for i = tablePosition, #combatData do
|
||||
if (combatData[i] == "!H") then
|
||||
tablePosition = i + 1;
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
--unpack heal
|
||||
Details.packFunctions.UnPackHeal(currentCombat, combatData, tablePosition)
|
||||
end
|
||||
|
||||
--all done, end combat
|
||||
Details:EndCombat()
|
||||
|
||||
--set the start and end of combat time and date
|
||||
currentCombat:SetStartTime(combatData[INDEX_COMBAT_START_TIME])
|
||||
currentCombat:SetEndTime(combatData[INDEX_COMBAT_END_TIME])
|
||||
currentCombat:SetDate(combatData[INDEX_COMBAT_START_DATE], combatData[INDEX_COMBAT_END_DATE])
|
||||
currentCombat.enemy = combatData[INDEX_COMBAT_NAME]
|
||||
|
||||
--debug: delete the segment just created (debug)
|
||||
--[[
|
||||
local combat2 = _detalhes.tabela_historico.tabelas[2]
|
||||
if (combat2) then
|
||||
tremove (_detalhes.tabela_historico.tabelas, 1)
|
||||
_detalhes.tabela_historico.tabelas[1] = combat2
|
||||
_detalhes.tabela_vigente = combat2
|
||||
end
|
||||
--]]
|
||||
end
|
||||
|
||||
--this function does the same as the function above but does not create a new combat, it just add new information
|
||||
function Details.packFunctions.DeployUnpackedCombatData(packedCombatData)
|
||||
function Details.packFunctions.DeployPackedCombatData(packedCombatData)
|
||||
|
||||
if (isDebugging) then
|
||||
print("DeployPackedCombatData(): START.")
|
||||
end
|
||||
|
||||
local LibDeflate = _G.LibStub:GetLibrary("LibDeflate")
|
||||
local dataCompressed = LibDeflate:DecodeForWoWAddonChannel(packedCombatData)
|
||||
@@ -942,6 +901,7 @@ function Details.packFunctions.DeployUnpackedCombatData(packedCombatData)
|
||||
|
||||
if (bit.band(flags, 0x10) ~= 0) then
|
||||
tablePosition = 2
|
||||
TOTAL_INDEXES_FOR_COMBAT_INFORMATION = 0 --there's no combat info, data starts after the dataFlag on position [1]
|
||||
else
|
||||
tablePosition = TOTAL_INDEXES_FOR_COMBAT_INFORMATION + 1
|
||||
end
|
||||
@@ -958,6 +918,11 @@ function Details.packFunctions.DeployUnpackedCombatData(packedCombatData)
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
if (isDebugging) then
|
||||
print("DeployPackedCombatData(): data has damage info, Damage Index:", tablePosition)
|
||||
end
|
||||
|
||||
--unpack damage
|
||||
tablePosition = Details.packFunctions.UnPackDamage(currentCombat, combatData, tablePosition)
|
||||
end
|
||||
@@ -970,6 +935,11 @@ function Details.packFunctions.DeployUnpackedCombatData(packedCombatData)
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
if (isDebugging) then
|
||||
print("DeployPackedCombatData(): data has healing info, Heal Index:", tablePosition)
|
||||
end
|
||||
|
||||
--unpack heal
|
||||
Details.packFunctions.UnPackHeal(currentCombat, combatData, tablePosition)
|
||||
end
|
||||
@@ -1039,3 +1009,117 @@ function Details.packFunctions.UnpackTable(table, index, isPair, valueAsTable, a
|
||||
|
||||
return result
|
||||
end
|
||||
|
||||
--what this function receives?
|
||||
--@packedCombatData: packed combat, ready to be unpacked
|
||||
function Details.packFunctions.UnPackCombatData(packedCombatData)
|
||||
|
||||
if (true) then
|
||||
print("Details is calling the wrong function UnPackCombatData()")
|
||||
return
|
||||
end
|
||||
|
||||
local LibDeflate = _G.LibStub:GetLibrary("LibDeflate")
|
||||
local dataCompressed = LibDeflate:DecodeForWoWAddonChannel(packedCombatData)
|
||||
local combatDataString = LibDeflate:DecompressDeflate(dataCompressed)
|
||||
|
||||
--[=
|
||||
local function count(text, pattern)
|
||||
return select(2, text:gsub(pattern, ""))
|
||||
end
|
||||
--]=]
|
||||
|
||||
local combatData = {}
|
||||
local amountOfIndexes = count(combatDataString, ",") + 1
|
||||
print ("amountOfIndexes (debug):", amountOfIndexes)
|
||||
|
||||
while (amountOfIndexes > 0) do
|
||||
|
||||
local splitPart = {strsplit(",", combatDataString, 4000)} --strsplit(): Stack overflow, max allowed: 4000
|
||||
|
||||
if (#splitPart == 4000 and amountOfIndexes > 4000) then
|
||||
|
||||
print ("#combatDataString (debug) must be > 4000:", amountOfIndexes)
|
||||
for i = 1, 3999 do
|
||||
combatData[#combatData+1] = splitPart[i]
|
||||
end
|
||||
|
||||
--get get part that couldn't be read this loop
|
||||
combatDataString = splitPart[4000]
|
||||
amountOfIndexes = amountOfIndexes - 3999
|
||||
|
||||
print ("#combatDataString (debug) left over:", amountOfIndexes)
|
||||
else
|
||||
for i = 1, #splitPart do
|
||||
combatData[#combatData+1] = splitPart[i]
|
||||
end
|
||||
|
||||
amountOfIndexes = amountOfIndexes - #splitPart
|
||||
end
|
||||
end
|
||||
|
||||
print("total indexes (debug):", #combatData)
|
||||
|
||||
--if true then return end
|
||||
|
||||
local flags = tonumber(combatData[INDEX_EXPORT_FLAG])
|
||||
|
||||
local tablePosition = TOTAL_INDEXES_FOR_COMBAT_INFORMATION + 1 --[[ +1 to jump to damage ]] --DEPRECATED FUNC
|
||||
--tablePosition now have the first index of the actorInfoTable
|
||||
|
||||
--stop the combat if already in one
|
||||
if (Details.in_combat) then
|
||||
Details:EndCombat()
|
||||
end
|
||||
|
||||
--start a new combat
|
||||
Details:StartCombat()
|
||||
--get the current combat
|
||||
local currentCombat = Details:GetCurrentCombat()
|
||||
|
||||
--check if this export has include damage info
|
||||
if (bit.band(flags, 0x1) ~= 0) then
|
||||
--find the index where the damage information start
|
||||
for i = tablePosition, #combatData do
|
||||
if (combatData[i] == "!D") then
|
||||
tablePosition = i + 1;
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
--unpack damage
|
||||
tablePosition = Details.packFunctions.UnPackDamage(currentCombat, combatData, tablePosition)
|
||||
end
|
||||
|
||||
if (bit.band(flags, 0x2) ~= 0) then
|
||||
--find the index where the heal information start
|
||||
for i = tablePosition, #combatData do
|
||||
if (combatData[i] == "!H") then
|
||||
tablePosition = i + 1;
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
--unpack heal
|
||||
Details.packFunctions.UnPackHeal(currentCombat, combatData, tablePosition)
|
||||
end
|
||||
|
||||
--all done, end combat
|
||||
Details:EndCombat()
|
||||
|
||||
--set the start and end of combat time and date
|
||||
currentCombat:SetStartTime(combatData[INDEX_COMBAT_START_TIME])
|
||||
currentCombat:SetEndTime(combatData[INDEX_COMBAT_END_TIME])
|
||||
currentCombat:SetDate(combatData[INDEX_COMBAT_START_DATE], combatData[INDEX_COMBAT_END_DATE])
|
||||
currentCombat.enemy = combatData[INDEX_COMBAT_NAME]
|
||||
|
||||
--debug: delete the segment just created (debug)
|
||||
--[[
|
||||
local combat2 = _detalhes.tabela_historico.tabelas[2]
|
||||
if (combat2) then
|
||||
tremove (_detalhes.tabela_historico.tabelas, 1)
|
||||
_detalhes.tabela_historico.tabelas[1] = combat2
|
||||
_detalhes.tabela_vigente = combat2
|
||||
end
|
||||
--]]
|
||||
end
|
||||
+4
-4
@@ -1594,10 +1594,10 @@ Damage Update Status: @INSTANCEDAMAGESTATUS
|
||||
Details.coach.enabled = not Details.coach.enabled
|
||||
|
||||
if (Details.coach.enabled) then
|
||||
Details:Msg("coach enabled, good luck!")
|
||||
Details:Msg("[raid leader] stay outside the raid.")
|
||||
Details:Msg("[assistants] at least one player inside the raid need to have assistant.")
|
||||
Details:Msg("[players] have an updated version of Details!.")
|
||||
Details:Msg("Details! Coach enabled, good luck commander!")
|
||||
Details:Msg("[|cFFAAFFAADetails! Coach|r] raid leader stay outside the raid.")
|
||||
Details:Msg("[|cFFAAFFAADetails! Coach|r] assistants, at least one player inside the raid need to have assistant.")
|
||||
Details:Msg("[|cFFAAFFAADetails! Coach|r] players have an updated version of Details!.")
|
||||
Details.Coach.Server.EnableCoach()
|
||||
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user