Page 1 of 1

TurnTowrd function crashed UOx3.

Posted: Sat Jun 30, 2007 12:52 am
by stranf
The TurnToward( obj) function crashes UOx3 when an invalid object is selected.

An easy work around is to just put an If statement infront of the function to only fire it if the target is a valid item or NPC.

It is easily repeatable. Set up a function where a GM can select a target for the TurnToward. Select a piece of dirt on the map, UOx3 will crash.

While probably not a serious issue, functions like WalkTo, TextMessage, Follow, etc, just print a waring in Uox3 that says "blah blah blah is an invalid object." or "TextMessage contains no valid <whatever>"

I have never seen Uox3 crash when a bad object type is sent to a function, so I thought I'd post this.

Keep up the good work!

Posted: Mon Jul 02, 2007 9:46 pm
by Xuri
A crash fix is always a good thing, but take a leaf from the book of other commands, and do something like this for avoiding the crash:

Code: Select all

function onCallback0( socket, ourObj) 
{    
   if( !socket.GetWord( 1 ) && ourObj.isChar ) 
   { 
         socket.tempObj = ourObj; 
         socket.CustomTarget(1, "Select location"); 
   } 
   else 
      socket.SysMessage8 "You must target a character!" ); 
}

Posted: Mon Jul 02, 2007 11:09 pm
by stranf
Thanks xu....

I basically added that code, and also added a check for an item, so now a GM can make a NPC look at an item. I'll post the following script in a bit.

Posted: Tue Oct 09, 2007 3:00 am
by Xuri
Crash confirmed, btw.

Posted: Sat Jun 21, 2008 8:46 am
by giwo
Yup, a ValidateObject() call in that Method should fix the problem.

Done

Posted: Sun Jan 18, 2009 8:23 pm
by Xuri
Verified fixed. Console will output JS errors when you try to use the TurnToward method with an invalid object.