Prevent fully expired crafting data from beaing read in and causing a crash
His Dad [12-28-14 - 18:14]
Prevent fully expired crafting data from beaing read in and causing a crash
diff --git a/lua/CraftResearchTimer.lua b/lua/CraftResearchTimer.lua
index 3e58cdc..2499c58 100644
--- a/lua/CraftResearchTimer.lua
+++ b/lua/CraftResearchTimer.lua
@@ -22,7 +22,9 @@ function CRT.Init(eventCode, addOnName)
-- SavedVariables
CRT.SV.Settings = ZO_SavedVars:New(CRT.svName, CRT.svVersion*100, nil, CRT.svDefaults, nil)
CRT.SV.data = ZO_SavedVars:NewAccountWide(CRT.svName, 2, nil, CRT.data_defaults,nil )
- CRT.InitialiseLanguage()
+ CRT.GRID_Remove_Expired()
+
+ CRT.InitialiseLanguage()
--get rid of bad "version" key from CRT releases prior to this one
-- CRT.SV.data.Craft.versionx = nil
-- CRT.SV.Hireling_data.versionxx = nil
@@ -31,7 +33,7 @@ function CRT.Init(eventCode, addOnName)
SLASH_COMMANDS[CRT.cmdsetup] = CRT.CommandText_setup
-- Default sort
- CRT.SortFunction = SortTimeA
+ CRT.SortFunction = SortTimeA
@@ -512,7 +514,7 @@ function CRT.CommandText_setup(lparam)
CRT.SortFunction = SortAlphaD
CRT.GRID_Sort()
elseif (lparam == "sortT") then
- CRT.SortFunction = SortTimeA
+ CRT.SortFunction = SortTimeT
CRT.GRID_Sort()
else
CRT.ToggleUI()
diff --git a/lua/GRID.lua b/lua/GRID.lua
index 24a50b6..543bcc5 100644
--- a/lua/GRID.lua
+++ b/lua/GRID.lua
@@ -4,6 +4,18 @@
local num_char --track character number drawing for, for positioning
local k,v
+function CRT.GRID_Remove_Expired() --- Prevent display for completely expired crafting chars.
+ for k, _ in pairs(CRT.SV.data.Craft) do
+
+ if ((CRT.SV.data.Craft[k][0].Simu_craft == 0 and
+ CRT.SV.data.Craft[k][1].Simu_craft == 0 and
+ CRT.SV.data.Craft[k][2].Simu_craft == 0))
+ then
+ CRT.SV.data.Craft[k] = nil
+ end
+ end
+end
+
function CRT.GRID_Create()
-- Fenetre de base
@@ -47,7 +59,6 @@ function CRT.GRID_Create_Character(k)
if (num_char == nil) then
num_char = 0
end
- if ((CRT.SV.data.Craft[k][0].Simu_craft ~= 0 or CRT.SV.data.Craft[k][1].Simu_craft ~= 0 or CRT.SV.data.Craft[k][2].Simu_craft ~= 0)) then
CRT.UI.GRID_WD[k] = {}
-- Containing window for character data. We can then move it as a group
@@ -185,7 +196,6 @@ function CRT.GRID_Create_Character(k)
end
num_char = num_char+1
CRT.UI.GRID_TLW:SetDimensions(width,CRT.UI.GRID_WD[k].panel:GetHeight()*num_char)
- end
end
function CRT.GRID_Update(timestamp)
@@ -251,7 +261,7 @@ function CRT.GRID_Sort()
CRT.Char_sort()
panelheight = CRT.UI.GRID_WD[CRT.CharsInOrder[1]].panel:GetHeight() -- after scaling
for k, v in ipairs(CRT.CharsInOrder) do
- CRT.UI.GRID_WD[v].panel:SetAnchor(TOPLEFT,CRT.UI.GRID_TLW,TOPLEFT,0,panelheight*(k-1))
+ CRT.UI.GRID_WD[v].panel:SetAnchor(TOPLEFT,CRT.UI.GRID_TLW,TOPLEFT,0,panelheight*(k-1))
end
-- We shouldn't have to manually set the height of the TLW and scale it, but we do. Bug perhaps??
CRT.UI.GRID_TLW:SetHeight(table.getn(CRT.CharsInOrder) * panelheight / CRT.UI.GRID_TLW:GetScale())