Full Version : Change the GetMethod call in BaseXmlSpawner.cs
xmlspawner >>XMLSpawner Feature Request's >>Change the GetMethod call in BaseXmlSpawner.cs
<< Prev | Next >>
cheetah2003- 10-01-2006
In BaseXmlSpawner.cs, when using the LOOT keyword to generate a random item from one of Loot.cs's method, it looks for any method matching the string.
However, in RunUO 2.0, many of these methods are overloaded, throwing an AmbigiousMatchException.
This can be alleviated and allow XML Spawners to use the method that takes no parameters.
I think there's multiple places, but the original code looks like this:

CODE
try { method = ltype.GetMethod(itemkeywordargs[1]); } catch { }

In mine, I changed it to this:

CODE
try { Type[] types = new Type[0]; method = ltype.GetMethod(itemkeywordsargs[1], types); }
catch { }

which instructs GetMethod to only return a matching method that take zero args.
ArteGordon- 10-02-2006
good point. I'll add that to the next update.