Xeph

Initiate
Just started running a server today for me and my family, been going well so far. Trying for it to be UOR ish in nature and that is going alright, but I have to problems overall.

1. Players can't seem to receive BOD's, they are told one is available but nothing pops up.

2. The server seems to crash about every 15ish minutes. Error seems to point at treasure map chest and chests in brigand/orc camps.
Any help would be wonderful.

Server Crash Report
===================

RunUO Version 0.5, Build 5930.29457
Operating System: Microsoft Windows NT 6.2.9200.0
.NET Framework: 4.0.30319.42000
Time: 3/28/2016 3:45:32 AM
Mobiles: 6682
Items: 105424
Exception:
System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)
at Server.Items.TreasureMapChest.GetRandomRecipe()
at Server.Items.TreasureMapChest.GetRandomSpecial(Int32 level, Map map)
at Server.Items.TreasureMapChest.Fill(LockableContainer cont, Int32 luck, Int32 level, Boolean isSos)
at Server.Multis.BrigandCamp.AddCampChests()
at Server.Multis.BrigandCamp.AddComponents()
at Server.Timer.DelayCallTimer.OnTick() in c:\ServUO\ServUO-master\Server\Timer.cs:line 616
at Server.Timer.Slice() in c:\ServUO\ServUO-master\Server\Timer.cs:line 410
at Server.Core.Main(String[] args) in c:\ServUO\ServUO-master\Server\Main.cs:line 577

Clients:
- Count: 0

Server Crash Report
===================

RunUO Version 0.5, Build 5930.29457
Operating System: Microsoft Windows NT 6.2.9200.0
.NET Framework: 4.0.30319.42000
Time: 3/28/2016 3:30:21 AM
Mobiles: 6879
Items: 106136
Exception:
System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)
at Server.Items.TreasureMapChest.GetRandomRecipe()
at Server.Items.TreasureMapChest.GetRandomSpecial(Int32 level, Map map)
at Server.Items.TreasureMapChest.Fill(LockableContainer cont, Int32 luck, Int32 level, Boolean isSos)
at Server.Multis.OrcCamp.AddCampChests()
at Server.Multis.OrcCamp.AddComponents()
at Server.Timer.DelayCallTimer.OnTick() in c:\ServUO\ServUO-master\Server\Timer.cs:line 616
at Server.Timer.Slice() in c:\ServUO\ServUO-master\Server\Timer.cs:line 410
at Server.Core.Main(String[] args) in c:\ServUO\ServUO-master\Server\Main.cs:line 577

Clients:
- Count: 2
 
It would appear in Scripts/Items/Containers/TreasureMapChest.cs GetRandomRecipe() is using (or passing?) a value that exceeds the size of the list being worked with. Can you post your GetRandomRecipe()? SVN only shows:
Code:
public static Item GetRandomRecipe()
{
	List<Server.Engines.Craft.Recipe> recipes = new List<Server.Engines.Craft.Recipe>(Server.Engines.Craft.Recipe.Recipes.Values);
	return new RecipeScroll(recipes[Utility.Random(recipes.Count)]);
}
 
public static Item GetRandomRecipe()
{
List<Server.Engines.Craft.Recipe> recipes = new List<Server.Engines.Craft.Recipe>(Server.Engines.Craft.Recipe.Recipes.Values);

return new RecipeScroll(recipes[Utility.Random(recipes.Count)]);
}

And sadly I do not know where to look for the vendor code. I do know it was a for Blacksmith, haven't tested Tailor BoD's yet.

Thank you very much.
 
Probably because you are looking for a zero-based index, but using the actual size of the collection. Try subtracting one.

new RecipeScroll(recipes[Utility.Random(recipes.Count) - 1]);
 
Testing that change out.

Tested trying to get a BoD for tailoring and was unable to.

Thanks.
 
Well was working well for a while then crashed again.

Server Crash Report
===================

RunUO Version 0.5, Build 5931.33300
Operating System: Microsoft Windows NT 6.2.9200.0
.NET Framework: 4.0.30319.42000
Time: 3/29/2016 2:37:40 AM
Mobiles: 2598
Items: 98102
Exception:
System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)
at Server.Items.TreasureMapChest.GetRandomRecipe()
at Server.Items.TreasureMapChest.GetRandomSpecial(Int32 level, Map map)
at Server.Items.TreasureMapChest.Fill(LockableContainer cont, Int32 luck, Int32 level, Boolean isSos)
at Server.Multis.OrcCamp.AddCampChests()
at Server.Multis.OrcCamp.AddComponents()
at Server.Timer.DelayCallTimer.OnTick() in c:\ServUO\ServUO-master\Server\Timer.cs:line 616
at Server.Timer.Slice() in c:\ServUO\ServUO-master\Server\Timer.cs:line 410
at Server.Core.Main(String[] args) in c:\ServUO\ServUO-master\Server\Main.cs:line 577

Clients:
- Count: 2
 
I'm going to guess, for whatever reason, the crash is coming from "recipes[Utility.Random(recipes.Count)]", due to the Utility.Random(recipes.Count) returning a number above/below the actual number of recipes present, or perhaps it hits a recipe that is broken, so returns null when created. You're going to need to do some debugging, especially since the crash isn't immediately reproducible (so far). Outputting to console might not work/help, so you might need to write some debug stuff to a txt file every time GetRandomRecipe() is called, with perhaps the # of recipes present, and the random # the Utility.Random gave back, so you can see what data is being passed around, and maybe catch an idea of what the bad data is one time when it crashes the server.
 
Not sure how to write anything for debugging. My scripting knowledge is pretty much zero. Only thing I did was change some stuff in the configuration files before compiling and launching the server. I know I goofed the spawning of the world(although I thought I got it all wiped and respawned correctly) and wonder if that could be the cause. Starting to wonder if I should just start it all over. Haven't really done much on it so far yet.

Really wish I could be more helpful on my end. Thank you to everyone helping me try and getting this sorted. Really trying to get a renaissance era server running. Don't mind a few things that came later being on it like BoD's, champs, Taming changes, and monsters. But trying to keep skills/spells to that era.
 
The only way I can imagine this happening is that the list has a count of 0.

list[Utility.Random(list.Count)]; should never be out of bounds, since Utility.Random(2), for example, can only be 0 or 1.

If the count of the list is 0 or 1, the only number that Utility.Random(list.Count) can actually return is 0. If the count of the list is truly zero, it will cause an index out of bounds exception, because you are getting the list item at index 0 which doesn't exist.

Try putting in this code, then spawn a bunch of orc camps:

Code:
public static Item GetRandomRecipe()
{
   List<Server.Engines.Craft.Recipe> recipes = new List<Server.Engines.Craft.Recipe>(Server.Engines.Craft.Recipe.Recipes.Values);

   Utility.PushColor(ConsoleColor.Yellow);
   Console.WriteLine("Recipes count is: " + recipes.Count);
   Console.WriteLine("When you press a key the shard should crash");
   Utility.PopColor();
   Console.ReadKey();

   return new RecipeScroll(recipes[Utility.Random(recipes.Count)]);
}
 
Last edited:
Good suggestion, jack.

I would probably just catch every possible instance of the error and not let it crash:

Code:
public static Item GetRandomRecipe()
{
    try {
        List<Server.Engines.Craft.Recipe> recipes = new List<Server.Engines.Craft.Recipe>(Server.Engines.Craft.Recipe.Recipes.Values);
        return new RecipeScroll(recipes[Utility.Random(recipes.Count)]);
    }
    catch (Exception e)
    {
        Console.WriteLine(e.ToString());
        Console.WriteLine("recipes.Count was {0}", recipes.Count);
        return new RecipeScroll(0);
    }
}

The "catch" block will give you the exception and the count printed out to the Console, and prevent the crash.
 
I didn't see a reason to not let the shard crash, since it is just a test. Wrapping it in the try/catch block would not compile since the variable "recipes" would not exist within the catch block. It would have to be declared outside of the try/catch.
 
I didn't see a reason to not let the shard crash, since it is just a test. Wrapping it in the try/catch block would not compile since the variable "recipes" would not exist within the catch block. It would have to be declared outside of the try/catch.

Correct. I used Notepad to write that up, so missed the declaration. I find it useful to keep my test server running even through errors like this. It gives me a chance to tweak things on the fly, and keep testing things that might cause the same or other messages to appear.
 
So, my new code for this (thanks, Jack) would be something like this:

Code:
public static Item GetRandomRecipe()
{
    List<Server.Engines.Craft.Recipe> recipes = new List<Server.Engines.Craft.Recipe>(Server.Engines.Craft.Recipe.Recipes.Values);
    try {
        return new RecipeScroll(recipes[Utility.Random(recipes.Count)]);
    }
    catch (Exception e)
    {
        Console.WriteLine(e.ToString());
        Console.WriteLine("recipes.Count was {0}", recipes.Count);
        return new RecipeScroll(0);
    }
}
 

Active Shards

Donations

Total amount
$0.00
Goal
$1,000.00
Back