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!

Bug Fix - Handlers.cs (ViewEquip command)

Z3r0

Sorceror
Bug Fix - Handlers.cs (ViewEquip command)

If someone uses ViewEquip and targets something other than a mobile, server crashes.

In class ViewEqTarget...

Code
Code:
			protected override void OnTarget( Mobile from, object targeted )
			{
                Mobile targ = (Mobile)targeted;
                if (from.AccessLevel <= targ.AccessLevel && from.AccessLevel < AccessLevel.Administrator)
                {
                    from.SendMessage("You do not have the required access level to do this.");
                    return;
                }
				if ( !BaseCommand.IsAccessible( from, targeted ) )
				{
					from.SendMessage( "That is not accessible." );
					return;
				}

				if ( targeted is Mobile )
					from.SendMenu( new EquipMenu( from, (Mobile)targeted, GetEquip( (Mobile)targeted ) ) );
			}

Fix
Code:
			protected override void OnTarget( Mobile from, object targeted )
			{
                if (targeted is Mobile)
                {
                    Mobile targ = (Mobile)targeted;
                    if (from.AccessLevel <= targ.AccessLevel && from.AccessLevel < AccessLevel.Administrator)
                    {
                        from.SendMessage("You do not have the required access level to do this.");
                        return;
                    }
                    if (!BaseCommand.IsAccessible(from, targeted))
                    {
                        from.SendMessage("That is not accessible.");
                        return;
                    }
                    from.SendMenu(new EquipMenu(from, (Mobile)targeted, GetEquip((Mobile)targeted)));
                }
                else
                {
                    from.SendMessage("This command only works on mobiles.");
                }
			}
 
which runuo version is that from?
because in 2.0 Final it is nothing like you are showing and checks 1st if target is a mobile
 
because a not mobile is an item, and an item does not have layers or most of the mobile based things it is looking for in the code
 
and that is the way it is, items can not have things equiped
all critters, players, etc are mobiles
so basicaly only items & mobiles in game
and items do not have layers
and items can not be treated as mobiles, else crash liek he said
 

Jeff

Lord
Why are we arguing? The current SVN code for this looks like this

Code:
			protected override void OnTarget( Mobile from, object targeted )
			{
				if ( !BaseCommand.IsAccessible( from, targeted ) )
				{
					from.SendMessage( "That is not accessible." );
					return;
				}

				if ( targeted is Mobile )
					from.SendMenu( new EquipMenu( from, (Mobile)targeted, GetEquip( (Mobile)targeted ) ) );
			}

This is not a bug fix, because a bug doesn't exist. Chances are this guy added the AccessLevel code, and caused the bug himself.
 
Top