diff --git a/HistOffline.lua b/HistOffline.lua
index 1eedea1..43ef707 100644
--- a/HistOffline.lua
+++ b/HistOffline.lua
@@ -387,12 +387,11 @@ btn_archive = iup.button{title="Archive", FGCOLOR = "#FF0000"}
iup.SetAttribute(accounts[acc].name[char].Map_box, "ALIGNMENT0", "ALEFT")
iup.SetAttribute(accounts[acc].name[char].Map_box, "WIDTH0", "100")
-
local map_names = {}
for map,_ in pairs(History_SV["Default"][acc]["$AccountWide"]["data"][char].maps) do
table.insert(map_names,map)
end
- -- print(dump(map_names))
+
table.sort(map_names)
local Line =1
for _, map in ipairs(map_names) do
diff --git a/history.lua b/history.lua
index b6fbd61..ac6c1c0 100644
--- a/history.lua
+++ b/history.lua
@@ -8,7 +8,7 @@ hist = {
player = "",
last="",
tz_offset =0,
- debug = false
+ debug = true
}
local function log_truncate(max)
@@ -130,26 +130,32 @@ local description
end
end
-
-local function Activated()
- hist.me.levels[hist.me.level].time = math.floor(GetSecondsPlayed() /60)
- local map = GetMapName()
+local function new_map()
+ local map = GetMapName()
if hist.me.maps[map] == nil then
hist.me.maps[map] = {}
- hist.me.maps[map].visit = 1
hist.me.maps[map].firstvisitdate = GetTimeStamp()
- else
+ if hist.debug then
+ d("New Map: " .. map )
+ end
+ log("New map: " .. map)
+ end
+ return map
+end
+
+local function Activated()
+ hist.me.levels[hist.me.level].time = math.floor(GetSecondsPlayed() /60)
- if hist.me.maps[map].visit == nil then
+ local map = new_map()
+ if hist.me.maps[map].visit == nil then
hist.me.maps[map].visit = 1
- else
+ else
hist.me.maps[map].visit = hist.me.maps[map].visit +1
- end
end
-
end
+
local function levelup(_, unitTag,_)
if unitTag == "player" then
local oldlevel = hist.me.level
@@ -161,7 +167,7 @@ local function levelup(_, unitTag,_)
Ach_Points = GetEarnedAchievementPoints(),
deaths = 0
}
- local map = GetMapName()
+ local map = new_map()
--Update Level data with map
if hist.me.levels[hist.me.level].map == nil then
hist.me.levels[hist.me.level].map = {}
@@ -174,10 +180,9 @@ local function levelup(_, unitTag,_)
else
hist.me.levels[hist.me.level].map[map] = hist.me.levels[hist.me.level].map[map] +1
end
- -- Update Map data with level
- if hist.me.maps[map] == nil then
- hist.me.maps[map] = {}
- end
+
+
+
-- Duplication of info, but easier to work with
if hist.me.maps[map].timeslevel == nil then
hist.me.maps[map].timeslevel = 1
@@ -236,11 +241,9 @@ local function Dead()
-- Per Level
hist.me.levels[hist.me.level].deaths = hist.me.levels[hist.me.level].deaths +1
-- Per Map
- local map = GetMapName()
- if hist.me.maps[map] == nil then
- hist.me.maps[map] = {}
- end
+ local map = new_map()
+
--Update map data with Deaths
if hist.me.maps[map].deaths == nil then
hist.me.maps[map].deaths = 0
@@ -252,7 +255,7 @@ local function Dead()
end
end
hist.me.maps[map].deaths = hist.me.maps[map].deaths +1
-
+
if hist.me.maps[map].firstdeathdate == nil then
hist.me.maps[map].firstdeathdate = GetTimeStamp()
end
@@ -307,9 +310,9 @@ function hist.Initialise(_, addOnName)
if hist.me.maps == nil then
hist.me.maps = {}
end
- if hist.me.ach_updates ~= nil then
- hist.me.ach_updates = nil
- end
+
+ hist.me.map = nil
+
if hist.debug then
log("Begin Duplicate tests, Saved -- Calculated" )
@@ -350,6 +353,7 @@ function hist.Initialise(_, addOnName)
EVENT_MANAGER:RegisterForEvent(hist.name, EVENT_PLAYER_ACTIVATED, Activated)
-- EVENT_MANAGER:RegisterForEvent(hist.name, EVENT_PLAYER_DEACTIVATED, Activated)
EVENT_MANAGER:RegisterForEvent(hist.name, EVENT_PLAYER_DEAD, Dead)
+ EVENT_MANAGER:RegisterForEvent(hist.name, EVEN_ZONE_CHANGED, new_map)
hist.initialised = true
end