Full Version : jail system crash
xmlspawner >>Scripting Support >>jail system crash
<< Prev | Next >>
Galfaroth- 02-09-2006
Okay here is my crash -debug report for those crashes:

CODE
Exception: System.ArgumentNullException: Key cannot be null. Parameter name: key at System.Collections.Hashtable.get_Item(Object key) at Server.Accounting.Accounts.GetAccount(String username) in d:\Ultima Online\Tools\WoG(Moj)\Scripts\Accounting\Accounts.cs:line 32
at Server.Scripts.Commands.JailSystem.get_Prisoner() in d:\Ultima Online\Tools\WoG(Moj)\Scripts\WOG\Komendy\Wiezienie\Jail.cs:line 803
at Server.Scripts.Commands.JailAdminGump.buildReviews() in d:\Ultima Online\Tools\WoG(Moj)\Scripts\WOG\Komendy\Wiezienie\Jail.cs:line 2733
at Server.Scripts.Commands.JailAdminGump.buildit(AdminJailGumpPage page, Int32 subpage, Int32 id) in d:\Ultima Online\Tools\WoG(Moj)\Scripts\WOG\Komendy\Wiezienie\Jail.cs:line 2555
at Server.Scripts.Commands.JailAdminGump..ctor() in d:\Ultima Online\Tools\WoG(Moj)\Scripts\WOG\Komendy\Wiezienie\Jail.cs:line 2490
at Server.Scripts.Commands.JailSystem.adminJail_OnCommand(CommandEventArgs e) in d:\Ultima Online\Tools\WoG(Moj)\Scripts\WOG\Komendy\Wiezienie\Jail.cs:line 1362
at Server.Commands.Handle(Mobile from, String text)
at Server.Mobile.DoSpeech(String text, Int32[] keywords, MessageType type, Int32 hue)
at Server.Network.PacketHandlers.UnicodeSpeech(NetState state, PacketReader pvSrc)
at Server.Network.MessagePump.HandleReceive(NetState ns)
at Server.Network.MessagePump.Slice()
at Server.Core.Main(String[] args)

It uses default jail.cs (Cat's Jail) and Accounts.cs (default runuo). What is bad here... It is too difficult for me.
ArteGordon- 02-09-2006
Online\Tools\WoG(Moj)\Scripts\Accounting\Accounts.cs:line 32
at Server.Scripts.Commands.JailSystem.get_Prisoner() in d:\Ultima
get_Prisoner() is calling the GetAccount method with a null username. This is causing your crash. You need to check to make sure that it is not null first. Here is a mod in jail.cs that will fix that

CODE
public Account Prisoner { get { if (Name != null)
return Accounts.GetAccount(Name);
else
return null;
}
}

to be honest, this script has lots of potential crashes in it. It is not careful about checking for null references. Making that fix will probably just lead to a different crash when it hits code that doesnt check for null accounts.
I am moving this to a separate thread in the scripting forum, since this has nothing to do with xmlspawner.
Galfaroth- 02-10-2006
Your code does the same thing like without this condition... Because if there is no player name it gives null, and without it, it gives null too...
ArteGordon- 02-10-2006
well, as I said

QUOTE
Making that fix will probably just lead to a different crash when it hits code that doesnt check for null accounts.

so you are now getting a different crash because of the null Account that is returned and not properly handled.
Post the crash log for that and you can fix this additional problem.