Trying to script working double-doors - but at a dead end

Need help with your JScripts? Got questions concerning the DFNs? Come forward, step inside :)
Post Reply
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:

Trying to script working double-doors - but at a dead end

Post by Xuri »

So, I've been toying around with how to make double-doors "linked", and I thought I had finally found a way, by using the following bit of code at the end of the onUse function in doors.js:

Code: Select all

	if( iUsed.GetTag( "linked" ) == "true" )
	{
		if( pUser.socket.clickY == null || pUser.socket.clickY == -1 )
		{
			var LinkedDoor = CalcItemFromSer( iUsed.GetTag( "linkSer1"), iUsed.GetTag( "linkSer2"), iUsed.GetTag( "linkSer3"), iUsed.GetTag( "linkSer4"));
			if( LinkedDoor )
			{
				pUser.socket.clickY = 1;
				TriggerEvent( 4500, "onUse", pUser, LinkedDoor );
			}
		}
		else if( pUser.socket.clickY == 1 )
		{
			pUser.socket.clickY = null;
		}
	}
Now, a door will only have "linked == true" if a GM has set up two doors to be linked through the command I'm making called 'LINKDOORS, which will change their "linked" customtag to "true" (text, not boolean) and will save the serial number of the other door as 4 customtags. But anyway, on to the problem:

Both linked doors will open if you doubleclick on one of them - but there the fun stops and the problems start. When the second door opens (through TriggerEvent), the following message appears in the UOX3 console:
| Unhandled item type for item: #[1073764883] of type: 12
..and any attempts to open ANY doors whatsoever after this will result in the same console message and no open doors.

Additionally, using JS commands (I tried 'WIPE and 'RELOADJSFILE #) after this has happend usually results in a server crash (at least in the debug-version) with the following completely useless info given:

Code: Select all

NTDLL! 7c901230()
NTDLL! 7c96cd80()
NTDLL! 7c96df66()
NTDLL! 7c94a5d0()
NTDLL! 7c9268ad()
MSVCRT! 77c2c2de()
JS32! 1004f5b7()
8914518b()
12000a00()
00060000()
fb00a9fb()
00aa454c()
JS32! 1006aca8()
Help? =P
-= 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 »

Why are you using TriggerEvent if you are calling a function in the same script file?
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 »

Good question ;D
Okay, changed my code a little bit:

Code: Select all

	// The below block of code allows "linked" double-doors
	// to be opened at the same time, if they've been setup
	// using the 'LINKDOORS command
	if( iUsed.GetTag( "linked" ) == "true" )
	{
		if( pUser.socket.clickY == -1 )
		{
			var LinkedDoor = CalcItemFromSer( iUsed.GetTag( "linkSer1"), iUsed.GetTag( "linkSer2"), iUsed.GetTag( "linkSer3"),  iUsed.GetTag( "linkSer4"));
			if( LinkedDoor )
			{
				pUser.socket.clickY = 1;
				onUse( pUser, LinkedDoor );
			}
		}
		else if( pUser.socket.clickY == 1 )
		{
			pUser.socket.clickY = -1;
		}
	}
And now it seems to be working perfectly. In release-mode, that is.

In debug mode, UOX3 will crash with the useless info I posted in my original post (all the NTDLL stuff, and also a line saying "HEAP[UOX3.exe]: Invalid Address specified to RtlFreeHeap( 00370000, 15B37949 )" in the Debug window) if I try to use most of the JS commands after doubleclicking on a door. Or if I try to shut down UOX3 ;P

I don't know what it is about my code which does that to UOX3, it doesn't happen if I comment out my section of code and try the same.. :cry:
-= Ho Eyo He Hum =-
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 »

Hm. After a bit of deduction, I've found out it seems to be happening in my GetTags for some reason.
This...

Code: Select all

if( iUsed.GetTag( "linked" ) == "true" )
{
}
...will crash UOX3 if I do 'RELOADJSFILE 4500 after using the doors.
This...

Code: Select all

if( pUser )
{
}
...will not ;P

What gives? GetTag is used elsewhere in the script without causing this error :/
-= 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 »

Try reloading a different script that uses GetTag().

I don't have the source in front of me, but if we are storing a jsval, that could be the problem, the data it points to might be lost when we reload the JS file.

Also, ensure your JS Debug DLL's are the same version as your release DLL's. :)
giwo
Developer
Posts: 1780
Joined: Fri Jun 18, 2004 4:17 pm
Location: California
Has thanked: 0
Been thanked: 0

Post by giwo »

As another thought, I'd prefer you use GetTag( "linked" ) == true (I think that syntax will work, otherwise a 1/0 comparison should). This way you aren't comparing strings (less storage and less work for the script/UOX).
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 »

giwo wrote:Try reloading a different script that uses GetTag().

I don't have the source in front of me, but if we are storing a jsval, that could be the problem, the data it points to might be lost when we reload the JS file.

Also, ensure your JS Debug DLL's are the same version as your release DLL's.
Well, using true instead of "true" seems to have done the trick, now both my debug build and my release build will keep running as it should. But it's still a very peculiar crash, so I'll post the info I have in any case:

Scenario 1: (WORKING)
I use 'LINKDOORS to link two doors together.
They get the tag ( "linked", true ).
The door-script:
if( iUsed.GetTag( "linked" ) == true )
I use the doors, then try reload any JS files whatsoever. Works.

Scenario 2: (NOT WORKING)
I use 'LINKDOORS to link two doors together.
They get the tag ( "linked", "true" ).
The door-script:
if( iUsed.GetTag( "linked" ) == "true" )
I use the doors, then try reload any JS files whatsoever. BOOM. Crash.
And just in case it mattered, I tried replacing the string "true" with "bhaal". Same thing =P

Both DLLs are the same version, dated 18.09.2005.
-= Ho Eyo He Hum =-
Post Reply