3.4.4 fixed startup error again

manavortex [06-28-18 - 13:31]
3.4.4 fixed startup error again
Filename
00_startup.lua
DailyAutoShare.txt
diff --git a/00_startup.lua b/00_startup.lua
index ec9d96a..166afe3 100644
--- a/00_startup.lua
+++ b/00_startup.lua
@@ -2,22 +2,22 @@ DailyAutoShare              = DailyAutoShare or {}
 DAS                         = DailyAutoShare

 DAS.name                    = "DailyAutoShare"
-DAS.version                 = "3.4.3"
+DAS.version                 = "3.4.4"
 DAS.author                  = "manavortex"
 DAS.settings                = {}
 DAS.globalSettings          = {}

-DAS.shareables   	        = {}
-DAS.bingo 			        = {}
+DAS.shareables              = {}
+DAS.bingo                   = {}
 DAS.bingoFallback           = {}
-DAS.subzones 		        = {}
+DAS.subzones                = {}
 DAS.activeZoneQuests        = {}

 DAS.questFinisher           = {}
 DAS.questStarter            = {}
 DAS.questIds                = {}
 DAS.activeBingoIndices      = {}
-DAS.channelTypes 	        = {
+DAS.channelTypes            = {
     [CHAT_CHANNEL_PARTY]    = true,
     [CHAT_CHANNEL_SAY ]     = false,
     [CHAT_CHANNEL_YELL]     = false,
@@ -25,14 +25,14 @@ DAS.channelTypes 	        = {
     [CHAT_CHANNEL_WHISPER]  = true,
 }

-DAS.locale 			    = GetCVar("language.2")
+DAS.locale              = GetCVar("language.2")
 DAS.autoInviting        = false
 DAS.guildInviteText     = nil

-DAS_STATUS_COMPLETE 	= 0
-DAS_STATUS_OPEN 		= 1
-DAS_STATUS_ACTIVE		= 2
-DAS_STATUS_TRACKED	    = 3
+DAS_STATUS_COMPLETE     = 0
+DAS_STATUS_OPEN         = 1
+DAS_STATUS_ACTIVE       = 2
+DAS_STATUS_TRACKED      = 3

 local activeInCurrentZone   = false
 DAS.fullBingoString         = ""
@@ -41,102 +41,102 @@ local fullBingoString       = DAS.fullBingoString
 UNITTAG_PLAYER              = UNITTAG_PLAYER or "player"

 local defaults = {
-
-	debugging		   			= false,
-	keepInviteUpOnDegroup 		= false,
-
-	["DasControl"] = {
-		["x"] = 0,
-		["y"] = 0,
-	},
-	["DasButton"] = {
-		["x"] = 0,
-		["y"] = 0,
-	},
-	["inactiveZones"]			= {
-		["hide"]				= true,
-	},
-	[849] = {
-		["relic"] = {
-			["invisible"] = false,
-			["active"] = true,
-		},
-		["hunt"] = {
-			["invisible"] = false,
-			["active"] = true,
-		},
-		["delve"] = {
-			["invisible"] = false,
-			["active"] = true,
-		},
-		["boss"] = {
-			["invisible"] = false,
-			["active"] = true,
-		},
-	},
-	[980] = {
-		["crow"] = {
-			["invisible"] = false,
-			["active"] = true,
-		},
-		["craft"] = {
-			["invisible"] = false,
-			["active"] = true,
-		},
-		["delve"] = {
-			["invisible"] = false,
-			["active"] = true,
-		},
-		["boss"] = {
-			["invisible"] = false,
-			["active"] = true,
-		},
-	},
+
+    debugging                   = false,
+    keepInviteUpOnDegroup       = false,
+
+    ["DasControl"] = {
+        ["x"] = 0,
+        ["y"] = 0,
+    },
+    ["DasButton"] = {
+        ["x"] = 0,
+        ["y"] = 0,
+    },
+    ["inactiveZones"]           = {
+        ["hide"]                = true,
+    },
+    [849] = {
+        ["relic"] = {
+            ["invisible"] = false,
+            ["active"] = true,
+        },
+        ["hunt"] = {
+            ["invisible"] = false,
+            ["active"] = true,
+        },
+        ["delve"] = {
+            ["invisible"] = false,
+            ["active"] = true,
+        },
+        ["boss"] = {
+            ["invisible"] = false,
+            ["active"] = true,
+        },
+    },
+    [980] = {
+        ["crow"] = {
+            ["invisible"] = false,
+            ["active"] = true,
+        },
+        ["craft"] = {
+            ["invisible"] = false,
+            ["active"] = true,
+        },
+        ["delve"] = {
+            ["invisible"] = false,
+            ["active"] = true,
+        },
+        ["boss"] = {
+            ["invisible"] = false,
+            ["active"] = true,
+        },
+    },

     questShareString            = "I can give a DailyAutoShare for <<1>>, type <<2>> for an instant invite",
-	autoAcceptInvite 			= false,
-	autoAcceptInviteInterval 	= 5,
-
-	autoAcceptQuest		        = true,
-	autoAcceptShared 			= true,
-
-	autoDeclineShared 			= false,
-
-	autoHide 					= false,
-	autoMinimize 				= false,
-
-	minimised 					= false,
-	locked 						= false,
-	hidden 						= false,
-
-	autoShare 					= true,
-	autoInvite 					= false,
-	autoLeave 					= false,
-
-	useGlobalSettings 			= true,
-
-	fontScale					= 0.8,
-	tooltipRight 				= false,
-	upsideDown 					= false,
-    hideCompleted				= false,
-	startupMinimized			= true,
-	resetAutoShareOnNewGroup    = true,
-	lastLookingFor 				= "",
-	guildInviteNumber 			= 1,
-	groupInviteDelay			= 500,
-	questShareDelay				= 500,
-	guildInviteText,
+    autoAcceptInvite            = false,
+    autoAcceptInviteInterval    = 5,
+
+    autoAcceptQuest             = true,
+    autoAcceptShared            = true,
+
+    autoDeclineShared           = false,
+
+    autoHide                    = false,
+    autoMinimize                = false,
+
+    minimised                   = false,
+    locked                      = false,
+    hidden                      = false,
+
+    autoShare                   = true,
+    autoInvite                  = false,
+    autoLeave                   = false,
+
+    useGlobalSettings           = true,
+
+    fontScale                   = 0.8,
+    tooltipRight                = false,
+    upsideDown                  = false,
+    hideCompleted               = false,
+    startupMinimized            = true,
+    resetAutoShareOnNewGroup    = true,
+    lastLookingFor              = "",
+    guildInviteNumber           = 1,
+    groupInviteDelay            = 500,
+    questShareDelay             = 500,
+    guildInviteText,
     questShareString            = "I can give a DailyAutoShare for <<1>>, type <<2>> for an instant invite",
-	listenInGuilds,
+    listenInGuilds,
     whisperOnly                 = false,
     whisperString               = "whisper + for an instant invite",
     tracked = {
-		[684]  = true,
-		[823]  = true,
-		[849]  = true,	    -- Vvardenfell
-		[181]  = false,
-		[1011] = true,     -- Summerset
-	},
+        [684]  = true,
+        [823]  = true,
+        [849]  = true,      -- Vvardenfell
+        [181]  = false,
+        [1011] = true,     -- Summerset
+    },
 }

 local function pointerUpSubzones()
@@ -236,7 +236,7 @@ DAS.DebugOut = debugOut
 local p = debugOut

 function DAS.Report(text)
-	if not DAS.GetShutUp() then d(text) end
+    if not DAS.GetShutUp() then d(text) end
 end

 --==============================
@@ -244,7 +244,7 @@ end
 --==============================

 local function OnGroupTypeChanged(eventCode, unitTag)
-	if IsUnitGrouped(UNITTAG_PLAYER) then
+    if IsUnitGrouped(UNITTAG_PLAYER) then
         if not DAS.GetAutoShare() and DAS.GetResetAutoShareOnNewGroup() then
             DAS.SetAutoShare(true)
         end
@@ -260,19 +260,19 @@ local function forceRefreshControl()
 end

 local function OnQuestAdded(eventCode, journalIndex, questName, objectiveName)
-
-	local zoneId = DAS.GetZoneId()
-	if not DAS.GetActiveIn(zoneId) 			then return end
-	if not GetIsQuestSharable(journalIndex) then return end
-
+
+    local zoneId = DAS.GetZoneId()
+    if not DAS.GetActiveIn(zoneId)          then return end
+    if not GetIsQuestSharable(journalIndex) then return end
+
     local shareables = DAS.shareables[zoneId] or {}
     local bingoIndex = DAS.GetBingoIndexFromQuestName(questName) or 0
     DAS.activeBingoIndices[bingoIndex] = true
-
+
     if nil ~= shareables[questName] then
-		DAS.LogQuest(questName, false)
-		zo_callLater(forceRefreshControl, 700)
-	end
+        DAS.LogQuest(questName, false)
+        zo_callLater(forceRefreshControl, 700)
+    end
 end

 local questSharePending = false
@@ -300,10 +300,10 @@ local function OnQuestShared(eventCode, questId)
     if not DAS.settings.autoAcceptShared or not questId then return end
     local questName =  GetOfferedQuestShareInfo(questId)
     p(zo_strformat("<<1>> \t <<2>>", questId, questName))
-	local zoneQuestIds = DAS.questIds[DAS.GetZoneId()] or {}
-	if not (zoneQuestIds[questName] or DAS_QUEST_IDS[questId]) and DAS.GetActiveIn(zoneId) then return end
+    local zoneQuestIds = DAS.questIds[DAS.GetZoneId()] or {}
+    if not (zoneQuestIds[questName] or DAS_QUEST_IDS[questId]) and DAS.GetActiveIn(zoneId) then return end

-	if zoneQuestIds[questId] then
+    if zoneQuestIds[questId] then
         AcceptSharedQuest(questId)
         em:RegisterForEvent(DAS.name, EVENT_QUEST_ADDED, stopAcceptQuestLoop)
         zo_callLater(forceRefreshControl, 500)
@@ -315,8 +315,8 @@ local function OnChatMessage(eventCode, channelType, fromName, messageText, _, f
 end

 local function OnPlayerActivated(eventCode)
-	local active 		= DAS.GetActiveIn()
-	DAS.SetHidden(not active)
+    local active        = DAS.GetActiveIn()
+    DAS.SetHidden(not active)
     DAS.SetAutoInvite(DAS.GetAutoInvite()) -- disables if we aren't group lead
     DAS.SetChatListenerStatus(DAS.autoInviting)
     DAS.guildInviteText = DAS.GetGuildInviteText()
@@ -331,20 +331,20 @@ local function OnUnitCreated(eventCode, unitTag)
 end

 local function OnQuestToolUpdate()
-	forceRefreshControl()
+    forceRefreshControl()
 end

-local function OnQuestRemoved(eventCode, isCompleted, journalIndex, questName, zoneIndex, poiIndex, questId)
-
+local function OnQuestRemoved(eventCode, isCompleted, journalIndex, questName, zoneIndex, poiIndex, questId)
+
     local zoneId = DAS.GetZoneId()
     local zoneIds = DAS.questIds[zoneId] or {}
     -- is it a daily quest, and are we logging?
-    if not ((zoneIds[questName] or DAS_QUEST_IDS[questId]) and DAS.GetActiveIn(zoneId)) then return end
+    if not ((zoneIds[questName] or DAS_QUEST_IDS[questId]) and DAS.GetActiveIn(zoneId)) then return end

-	DAS.LogQuest(questName, isCompleted)
+    DAS.LogQuest(questName, isCompleted)

     -- set auto invite off until the questlog has refreshed
-	local autoInvite = DAS.GetAutoInvite()
+    local autoInvite = DAS.GetAutoInvite()
     DAS.SetAutoInvite(false)

     local bingoIndex = DAS.GetBingoIndexFromQuestName(questName) or 0
@@ -361,13 +361,13 @@ local function OnQuestRemoved(eventCode, isCompleted, journalIndex, questName, z
 end

 local function deleteYesterdaysLog()
-	-- kill yesterday's log, we don't need it
-	local currentDate = tonumber(GetDate())
-	if (nil ~= DAS.globalSettings and nil ~= DAS.globalSettings.lastLogDate) and (DAS.globalSettings.lastLogDate < currentDate) then
-	if nil == DAS.Log then DAS.Log = {} end
-		DAS.Log[DAS.globalSettings.lastLogDate] = nil
-		DAS.globalSettings.lastLogDate = currentDate
-	end
+    -- kill yesterday's log, we don't need it
+    local currentDate = tonumber(GetDate())
+    if (nil ~= DAS.globalSettings and nil ~= DAS.globalSettings.lastLogDate) and (DAS.globalSettings.lastLogDate < currentDate) then
+    if nil == DAS.Log then DAS.Log = {} end
+        DAS.Log[DAS.globalSettings.lastLogDate] = nil
+        DAS.globalSettings.lastLogDate = currentDate
+    end
 end

 local alreadyRefreshing = false
@@ -394,29 +394,29 @@ end

 local function RegisterEventHooks()

-	DailyAutoShare.Fragment 	= ZO_HUDFadeSceneFragment:New(DasControl)
-
-	SCENE_MANAGER:GetScene("hud"  ):AddFragment(DailyAutoShare.Fragment)
-	SCENE_MANAGER:GetScene("hudui"):AddFragment(DailyAutoShare.Fragment)
-	hookQuestTracker()
-
-	em:RegisterForEvent(DAS.name, EVENT_PLAYER_ACTIVATED, 		OnPlayerActivated)
-
-	em:RegisterForEvent(DAS.name, EVENT_QUEST_ADDED, 			OnQuestToolUpdate)
-	em:RegisterForEvent(DAS.name, EVENT_QUEST_REMOVED, 			OnQuestRemoved)
-	em:RegisterForEvent(DAS.name, EVENT_TRACKING_UPDATE, 		OnQuestToolUpdate)
-
-	em:RegisterForEvent(DAS.name, EVENT_QUEST_ADDED, 			OnQuestAdded)
-	em:RegisterForEvent(DAS.name, EVENT_QUEST_REMOVED, 			OnQuestRemoved)
-	em:RegisterForEvent(DAS.name, EVENT_QUEST_SHARED, 			OnQuestShared)
-
-	em:RegisterForEvent(DAS.name, EVENT_GROUP_TYPE_CHANGED,     OnGroupTypeChanged)
-	em:RegisterForEvent(DAS.name, EVENT_UNIT_CREATED,	 		OnUnitCreated)
-	em:RegisterForEvent(DAS.name, EVENT_UNIT_DESTROYED, 		OnGroupTypeChanged)
-
-	em:RegisterForEvent(DAS.name, EVENT_CHAT_MESSAGE_CHANNEL,   OnChatMessage)
-	-- DasControl:OnMoveStop
-	-- DailyAutoShare.SaveControlLocation(self)
+    DailyAutoShare.Fragment     = ZO_HUDFadeSceneFragment:New(DasControl)
+
+    SCENE_MANAGER:GetScene("hud"  ):AddFragment(DailyAutoShare.Fragment)
+    SCENE_MANAGER:GetScene("hudui"):AddFragment(DailyAutoShare.Fragment)
+    hookQuestTracker()
+
+    em:RegisterForEvent(DAS.name, EVENT_PLAYER_ACTIVATED,       OnPlayerActivated)
+
+    em:RegisterForEvent(DAS.name, EVENT_QUEST_ADDED,            OnQuestToolUpdate)
+    em:RegisterForEvent(DAS.name, EVENT_QUEST_REMOVED,          OnQuestRemoved)
+    em:RegisterForEvent(DAS.name, EVENT_TRACKING_UPDATE,        OnQuestToolUpdate)
+
+    em:RegisterForEvent(DAS.name, EVENT_QUEST_ADDED,            OnQuestAdded)
+    em:RegisterForEvent(DAS.name, EVENT_QUEST_REMOVED,          OnQuestRemoved)
+    em:RegisterForEvent(DAS.name, EVENT_QUEST_SHARED,           OnQuestShared)
+
+    em:RegisterForEvent(DAS.name, EVENT_GROUP_TYPE_CHANGED,     OnGroupTypeChanged)
+    em:RegisterForEvent(DAS.name, EVENT_UNIT_CREATED,           OnUnitCreated)
+    em:RegisterForEvent(DAS.name, EVENT_UNIT_DESTROYED,         OnGroupTypeChanged)
+
+    em:RegisterForEvent(DAS.name, EVENT_CHAT_MESSAGE_CHANNEL,   OnChatMessage)
+    -- DasControl:OnMoveStop
+    -- DailyAutoShare.SaveControlLocation(self)
 end


@@ -474,22 +474,25 @@ local function handleLog(forceNoAfterEight)

     if (not afterEight) and isEmpty(DAS.todaysLog) and lastDate ~= currentDate then
         local lastLog = DAS.globalSettings.completionLog[lastDate]
-        DAS.globalSettings.completionLog[currentDate] = ZO_DeepTableCopy(lastLog, {})
-        -- d(DAS.globalSettings.completionLog[currentDate])
-        for charName, charLog in pairs(DAS.globalSettings.completionLog[currentDate]) do
-            for questName, questData in pairs(charLog) do
-                questData.afterEight = false
+        if null ~= lastLog then
+            DAS.globalSettings.completionLog[currentDate] = ZO_DeepTableCopy(lastLog, {})
+            for charName, charLog in pairs(DAS.globalSettings.completionLog[currentDate]) do
+                for questName, questData in pairs(charLog) do
+                    questData.afterEight = false
+                end
             end
         end
+        -- d(DAS.globalSettings.completionLog[currentDate])
+
         characterName                   = characterName or GetUnitName(UNITTAG_PLAYER)
         DAS.todaysLog                   = DAS.globalSettings.completionLog[currentDate]
-	DAS.todaysCharacterLog              = DAS.todaysLog[characterName]
+    DAS.todaysCharacterLog              = DAS.todaysLog[characterName]
     end
 end
 DAS.handleLog = handleLog   -- expose this for debugging purpose

 local function minimiseOnStartup()
-	DAS.SetMinimized(DAS.GetSettings().startupMinimized)
+    DAS.SetMinimized(DAS.GetSettings().startupMinimized)
 end
 --==============================
 --===== Rise, my minion!  ======
@@ -497,17 +500,17 @@ end

 function DailyAutoShare_Initialize(eventCode, addonName)

-	if addonName ~= DAS.name then return end
+    if addonName ~= DAS.name then return end

-	DAS.settings        = ZO_SavedVars:New(             "DAS_Settings", 2, "DAS_Settings", defaults)
-	DAS.globalSettings  = ZO_SavedVars:NewAccountWide(  "DAS_Globals",  2, "DAS_Globals",  defaults)
+    DAS.settings        = ZO_SavedVars:New(             "DAS_Settings", 2, "DAS_Settings", defaults)
+    DAS.globalSettings  = ZO_SavedVars:NewAccountWide(  "DAS_Globals",  2, "DAS_Globals",  defaults)
     DAS.pdn = GetUnitDisplayName(UNITTAG_PLAYER)

     pointerUpSubzones()
-	RegisterEventHooks()
-
-	DAS.CreateMenu(DAS.settings, defaults)
-	DAS.CreateGui()
+    RegisterEventHooks()
+
+    DAS.CreateMenu(DAS.settings, defaults)
+    DAS.CreateGui()

     -- local timetoreset = (GetTimeStamp() - 60*60*7)%86400
     -- zo_callLater(resetQuests, timetoreset)
@@ -516,7 +519,7 @@ function DailyAutoShare_Initialize(eventCode, addonName)
     handleLog()
     zo_callLater(OnPlayerActivated, 5000)
     zo_callLater(minimiseOnStartup, 5500)
-	EVENT_MANAGER:UnregisterForEvent("DailyAutoShare", EVENT_ADD_ON_LOADED)
+    EVENT_MANAGER:UnregisterForEvent("DailyAutoShare", EVENT_ADD_ON_LOADED)

 end

diff --git a/DailyAutoShare.txt b/DailyAutoShare.txt
index c7d463d..d6148ab 100644
--- a/DailyAutoShare.txt
+++ b/DailyAutoShare.txt
@@ -1,6 +1,6 @@
 ## Title: DailyAutoShare
 ## Author: manavortex
-## Version: 3.4.3
+## Version: 3.4.4
 ## APIVersion: 100023
 ## SavedVariables: DAS_Settings DAS_Globals
 ## OptionalDependsOn: LibStub LibCustomMenu LibAddonMenu-2.0 LibMediaProvider-1.0 pchat