Closed GoogleCodeExporter closed 9 years ago
Original comment by proost.t...@gmail.com
on 27 Jan 2013 at 3:30
Can you explain how its possible to login on all characters after an upgrade if
the LoadSavedData routine bombs out at line 1150
Message: ..\AddOns\Accountant\Accountant.lua line 1150:
attempt to index field '?' (a nil value)
Debug:
[C]: ?
Accountant\Accountant.lua:1150: LoadSavedData()
Accountant\Accountant.lua:967: OnLoad()
Accountant\Accountant.lua:1541: OnEvent()
[string "*:OnEvent"]:1:
[string "*:OnEvent"]:1
Since the key value its looking for in LoadSavedData doesn't exist then the
addon fails and is unable to continue thus it doesn't seem to be possible to
"log in to all characters" to fix the issue.
What you may consider is a user transparent fix. I can supply some code I've
used in addons in the past the code basically prevents these saved variable
nulls by preloading the arrays with default values.
This means as you add new features all you need to do is specify the default
value then the user can ALWAYS seamlessly upgrade as if the value doesn't exist
it uses your default.
BTW what is with all the ; in the code??? LUA doesn't use semi-colons and just
ignores them. Blizzard have previously said this slows down their parser and
recommends removal.
Original comment by ShammyLe...@gmail.com
on 28 Jan 2013 at 10:56
A fix that prevents the LUA error on load where its simply a case of a
character hasn't had a key intitalised.
At line 1150
-- Quel's modifications to track income/expense across all characters relies on the savedata structure,
-- so we have to reset the session totals for all players each time we log in, only for chars on this server.
for player in next,Accountant_SaveData do
if (MatchRealm(player, SC.Realm) ~= nil) then
-- SC.Print2("Blanking session data for: "..player..", "..key);
Accountant_SaveData[player]["data"][key]["Session"].In = 0;
Accountant_SaveData[player]["data"][key]["Session"].Out = 0;
end
end
becomes
-- Quel's modifications to track income/expense across all characters relies on the savedata structure,
-- so we have to reset the session totals for all players each time we log in, only for chars on this server.
for player in next,Accountant_SaveData do
if MatchRealm(player, SC.Realm) then
--SC.Print("Blanking session data for: "..player..", "..key);
if Accountant_SaveData[player]["data"][key] then
Accountant_SaveData[player]["data"][key]["Session"] = { In = 0, Out = 0 }
else
Accountant_SaveData[player]["data"][key] = { Session = { In = 0, Out = 0 }, Total = { In = 0, Out = 0 }, Day = { In = 0, Out = 0 }, Week = { In = 0, Out = 0 } }
end
end
end
ie: it checks the key is valid and if not intialises the key. You could easily
do this for Player too, however I'd recommend that if it fails to find player
you simply remove that data from the table as it probably means the character
is deleted or realm transfer or some such issue.
Original comment by ShammyLe...@gmail.com
on 28 Jan 2013 at 11:35
Thanks for the code; I will check it out and implement it if I find some time
Original comment by proost.t...@gmail.com
on 6 Feb 2013 at 1:53
Ok tested your code and no errors on my client,
Can't tell for sure if others Might bug but i implemented it and uploaded the
new files. (left a thank you note in the code for you)
About the ; in the code. I took over accountant in in august. I left most of
teh code as is. i plan to clean it up some day but honestly i havn't found the
time. I have a full time job and a wife as well and accountant is just a fun
side project. I hope i can keep it working in the future and hope you guys keep
enjoying your favorite gold tracking addon. but we ll se where we get.
The code will get cleaned up. but i m still trying to find the time to do it.
Original comment by proost.t...@gmail.com
on 6 Feb 2013 at 3:34
Original comment by proost.t...@gmail.com
on 20 Feb 2013 at 2:27
Original issue reported on code.google.com by
proost.t...@gmail.com
on 27 Jan 2013 at 12:26