fix account bug

His Dad [08-09-16 - 06:05]
fix account bug
Filename
Doc/Changelog.txt
HistOffline.lua
history.lua
history.txt
diff --git a/Doc/Changelog.txt b/Doc/Changelog.txt
index 4d0d803..f987c97 100644
--- a/Doc/Changelog.txt
+++ b/Doc/Changelog.txt
@@ -1,3 +1,7 @@
+2016-08-09 version 22
+	A BPB bug affecting users with more than 2 accounts
+
+
 2016-08-07 version 21
 	Internal changes in the save file to allow correct operation when the character is
 	Renamed
diff --git a/HistOffline.lua b/HistOffline.lua
index f25fffc..2858288 100644
--- a/HistOffline.lua
+++ b/HistOffline.lua
@@ -12,7 +12,7 @@ local Colour_Heading_Complete = "#58FA58"

 --iup.SetGlobal("UTF8MODE","YES")
 -- ========================
-version= "21"
+version= "22"
 require( "iuplua" )
 require( "iupluacontrols" )
 dofile "../../SavedVariables/History.lua"
@@ -100,12 +100,11 @@ end
 accounts = {}
 accounts_list = {}		-- String list for selection dialog
 playerNames = {}		-- Get name from ID.
-naccounts = 0
+
 for i,_ in pairs(History_SV["Default"]) do
 	accounts[i] = {}
 	accounts[i].playerIDs = {}	-- intermediate table for sorting. WIP. Array formatted.
 	accounts[i].playerIDs_vet= {}	--subset of names which are >L50
-	naccounts = naccounts +1
 	table.insert(accounts_list, i)
 end

@@ -263,7 +262,7 @@ end
 		local thischar = History_SV["Default"][acc]["$AccountWide"]["data"][playerID]	-- shorter reference: History DB
 		-- Pull in some char data for processing
 		if thischar.name == nil  then --	Old Format
-		    print("Old Format  " .. playerID)
+	--	    print("Old Format  " .. playerID)
 			me.name = playerID
 		else
 			me.name = thischar.name
@@ -993,7 +992,6 @@ iup.Append(accounts[acc].char_tabs, accounts[acc].log_tab)

 	--Create Columns for Chars
 	for i ,playerID in ipairs(accounts[acc].playerIDs) do
-	    print(playerID)
 		dung.Pub_box:setcell(0, i, playerNames[playerID])
 	end

@@ -1202,16 +1200,14 @@ end -- Accounts



-
-
 function select_account()
 	local selected
-		if naccounts > 1 then
+		if #accounts_list > 1 then
 			selected = iup.ListDialog (1, L.SelectA,
-					2,	--Size
+					#accounts_list,	--Size
 					accounts_list,
 					1, --Initial
-					1,naccounts	--MaxCol MaxLine
+					1,#accounts_list	--MaxCol MaxLine
 					)

 			if selected <0 then
diff --git a/history.lua b/history.lua
index e571378..529b562 100644
--- a/history.lua
+++ b/history.lua
@@ -1,6 +1,6 @@
 hist = {
 	name = "history",
-	version = "21",
+	version = "22",
 	initialised = false,
 	SV={},
 	L={},
@@ -8,7 +8,7 @@ hist = {
 	playerName = "",	-- might change
 	playerID = "",  	-- Unique through renames
 	tz_offset =0,
-	debug = true
+	debug = false
 }

 local function log_truncate(max)
@@ -314,7 +314,9 @@ function hist.Initialise(_, addOnName)
  --- hist.SV.version    -- Used by ZOS System

 	if hist.SV.data[hist.playerID] == nil then
-	  log("No data found for PlayerID")
+		if debug then
+			log("No data found for PlayerID")
+		end
 	-- Ok playerID may be nil, but we might still have data under player name
 	-- In which case we rename it, otherwise it is a new char.

diff --git a/history.txt b/history.txt
index e446d87..80c12ab 100644
--- a/history.txt
+++ b/history.txt
@@ -1,6 +1,6 @@
 ## Title: Dad's History
 ## APIVersion: 100016
-## Version: 21
+## Version: 22
 ## Author: HisDad
 ## Description: Record progress of all characters for offline viewing.
 ## SavedVariables: History_SV