[FIXED] TurnTowrd function crashed UOx3.

Here we stuff all the bugs we've managed to squash/squish/squelch.
Post Reply
stranf
UOX3 Guru
Posts: 939
Joined: Wed Jan 04, 2006 3:59 pm
Has thanked: 0
Been thanked: 0

TurnTowrd function crashed UOx3.

Post 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!
User avatar
Xuri
Site Admin
Posts: 3704
Joined: Mon Jun 02, 2003 9:11 am
Location: Norway
Has thanked: 48 times
Been thanked: 8 times
Contact:

Post 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!" ); 
}
-= Ho Eyo He Hum =-
stranf
UOX3 Guru
Posts: 939
Joined: Wed Jan 04, 2006 3:59 pm
Has thanked: 0
Been thanked: 0

Post 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.
User avatar
Xuri
Site Admin
Posts: 3704
Joined: Mon Jun 02, 2003 9:11 am
Location: Norway
Has thanked: 48 times
Been thanked: 8 times
Contact:

Post by Xuri »

Crash confirmed, btw.
-= Ho Eyo He Hum =-
giwo
Developer
Posts: 1780
Joined: Fri Jun 18, 2004 4:17 pm
Location: California
Has thanked: 0
Been thanked: 0

Post by giwo »

Yup, a ValidateObject() call in that Method should fix the problem.

Done
User avatar
Xuri
Site Admin
Posts: 3704
Joined: Mon Jun 02, 2003 9:11 am
Location: Norway
Has thanked: 48 times
Been thanked: 8 times
Contact:

Post by Xuri »

Verified fixed. Console will output JS errors when you try to use the TurnToward method with an invalid object.
-= Ho Eyo He Hum =-
Post Reply