Skip to content

Commit

Permalink
More debugging tools
Browse files Browse the repository at this point in the history
  • Loading branch information
Tercioo committed Aug 2, 2024
1 parent 09e8c80 commit 2480e33
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 14 deletions.
3 changes: 2 additions & 1 deletion Definitions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,8 @@
---@field DefaultTooltipIconSize number default size of the icons in the tooltip, this also dictates the size of each line in the tooltip
---@field
---@field
---@field
---@field GenerateActorInfo fun(self: details, actor: actor, errorText:string, bIncludeStack:boolean) : table<string, boolean|string|number> generates a table with the main attributes of the actor, this is mainly for debug purposes
---@field DumpActorInfo fun(self: details, actor: actor) open a window showig the main attributes of an actor, this is mainly for debug purposes
---@field GetDisplayClassByDisplayId fun(self: details, displayId: number) : table -return the class object for the given displayId (attributeId)
---@field GetTextureAtlas fun(self: details, atlasName: atlasname) : df_atlasinfo return the texture atlas data
---@field GetTextureAtlasTable fun(self: details) : table<atlasname, df_atlasinfo>[] return the table with the texture atlas data
Expand Down
4 changes: 2 additions & 2 deletions boot.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
local addonName, Details222 = ...
local version, build, date, tvs = GetBuildInfo()

Details.build_counter = 12825
Details.alpha_build_counter = 12825 --if this is higher than the regular counter, use it instead
Details.build_counter = 12826
Details.alpha_build_counter = 12826 --if this is higher than the regular counter, use it instead
Details.dont_open_news = true
Details.game_version = version
Details.userversion = version .. " " .. Details.build_counter
Expand Down
12 changes: 10 additions & 2 deletions classes/class_damage.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3414,9 +3414,17 @@ function Details:SetClassIcon(texture, instance, class) --[[exported]] --~icons
end
end

local localizedClass, englishClass
local englishClass
if (self.serial ~= "") then
localizedClass, englishClass = GetPlayerInfoByGUID(self.serial or "")
local bResult, sResult = pcall(function() local lClass, eClass = GetPlayerInfoByGUID(self.serial or "") return eClass end) --will error with: nil, table and boolean
if (bResult) then
englishClass = sResult
else
local bIncludeStackTrace = true
--[[GLOBAL]] DETAILS_FAILED_ACTOR = Details:GenerateActorInfo(self, sResult, bIncludeStackTrace) --avoid the game gc and details gc from destroying the actor info
Details:Msg("Bug happend on GetPlayerInfoByGUID() class_damage.lua:3419. Use command '/details bug' to report.")
englishClass = "UNKNOW"
end
end

if (englishClass) then
Expand Down
51 changes: 42 additions & 9 deletions classes/class_instance.lua
Original file line number Diff line number Diff line change
Expand Up @@ -603,21 +603,54 @@ local instanceMixins = {
GetActorInfoFromLineIndex = function(self, index)
local actor = self.barras[index] and self.barras[index].minha_tabela
if (actor) then
local tableToDump = {}
for k, v in pairs(actor) do
if (type(k) == "string") then
if (type(v) == "number" or type(v) == "string"or type(v) == "boolean") then
tableToDump[k] = v
end
end
end
dumpt(tableToDump)
Details:DumpActorInfo(actor)
else
Details:Msg("no actor found in line index", index)
end
end,
}

function Details:DumpActorInfo(actor)
local tableToDump = Details:GenerateActorInfo(actor)
dumpt(tableToDump)
end

local tablesToIgnore = {
["pets"] = "type = table",
["friendlyfire"] = "type = table",
["damage_from"] = "type = table",
["targets"] = "type = table",
["raid_targets"] = "type = table",
["minha_barra"] = "type = table",
["__index"] = "type = table",
["spells"] = "type = table",
}

function Details:GenerateActorInfo(actor, errorText, bIncludeStack)
local tableToDump = {}
for k, v in pairs(actor) do
if (not tablesToIgnore[k]) then
if (type(k) == "string") then
if (type(v) == "number" or type(v) == "string"or type(v) == "boolean") then
tableToDump[k] = v
elseif (type(v) == "table") then
tableToDump[k] = "table{}"
end
end
end
end

if (errorText) then
tableToDump["__ERRORTEXT"] = errorText
end

if (bIncludeStack) then
tableToDump["__STACKCALL"] = debugstack(2)
end

return tableToDump
end

---get the table with all instances, these instance could be not initialized yet, some might be open, some not in use
---@return instance[]
function Details:GetAllInstances()
Expand Down
3 changes: 3 additions & 0 deletions functions/slash.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1536,6 +1536,9 @@ function SlashCmdList.DETAILS (msg, editbox)
elseif (msg == "generateracialslist") then
Details.GenerateRacialSpellList()

elseif (msg == "bug") then
dumpt(DETAILS_FAILED_ACTOR or {"No bug to report here."})

elseif (msg == "spellcat") then
Details.Survey.OpenSurveyPanel()

Expand Down

0 comments on commit 2480e33

Please sign in to comment.