RunUO Community

This is a sample guest message. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

Emitter bug

arul

Sorceror
Emitter bug

When you use a sort of 'multi' command with a conditional clause it stops at first erroneous object.

I mean, for example I want to search for all players whose combatant is named "JohnDoe", so I use a command like this

[global interface where playermobile combatant.name = 'JohnDoe'

As soon as I run this command a nullref exception pops out.

The problem is that not every playermobile has a combatant, so their combatant is null, the method call to get_Name fails and an exception is thrown.

I did a little research on this issue:
Code:
  public void FinishCall()
  {
   CallInfo call = m_Calls.Pop();
   if ( ( call.type.IsValueType || call.type.IsByRef ) && call.method.DeclaringType != call.type )
    m_Generator.Emit( OpCodes.Constrained, call.type );
 
   if ( call.method.DeclaringType.IsValueType || call.method.IsStatic )
    m_Generator.Emit( OpCodes.Call, call.method );
   else
    [COLOR=red][B]m_Generator.Emit( OpCodes.Callvirt, call.method );[/B][/COLOR]
 
   for ( int i = call.parms.Length - 1; i >= 0; --i )
    Pop( call.parms[i].ParameterType );
   if ( ( call.method.CallingConvention & CallingConventions.HasThis ) != 0 )
    Pop( call.method.DeclaringType );
   if ( call.method.ReturnType != typeof( void ) )
    Push( call.method.ReturnType );
  }

The code in red is the problem, it assumes that the TOS contains a reference to an object, which, as mentioned above, is null.
So, my suggestion is to check the TOS for a null value before the Callvirt or implement a different sanity check somewhere else.

EDIT: Removed some code, it didn't work.

It could probably be fixed by a try-catch somewhere where the conditions are interpreted.
 
Top