[FIXED] UseResource JS Method incapable of handling amounts > 65535

Here we stuff all the bugs we've managed to squash/squish/squelch.
Locked
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:

UseResource JS Method incapable of handling amounts > 65535

Post by Xuri »

To reproduce: Add 2 piles with 60k ingots in each pile and place them in your backpack. Then run the following script.

Code: Select all

function onUse( pUser, iUsed )
{
	pUser.UseResource( 70000, 0x1bf2, 0 );
	return false;
}
Only 4464 ingots will be removed.
Last edited by Xuri on Mon Sep 11, 2006 1:02 am, edited 1 time in total.
-= Ho Eyo He Hum =-
Maarc
Developer
Posts: 576
Joined: Sat Mar 27, 2004 6:22 am
Location: Fleet, UK
Has thanked: 0
Been thanked: 0
Contact:

Post by Maarc »

Should be a simple fix:

Code: Select all

Index: UOXJSMethods.cpp
===================================================================
RCS file: /cvsroot/openuo/projects/uox3/source/UOXJSMethods.cpp,v
retrieving revision 1.67
diff -u -r1.67 UOXJSMethods.cpp
--- UOXJSMethods.cpp	18 Jul 2006 07:59:30 -0000	1.67
+++ UOXJSMethods.cpp	18 Aug 2006 02:31:59 -0000
@@ -2276,9 +2276,9 @@
 		return JS_FALSE;
 	}
 
-	UI16 realID = (UI16)JSVAL_TO_INT( argv[1] );
+	UI16 realID		= (UI16)JSVAL_TO_INT( argv[1] );
 	UI16 itemColour = 0;
-	UI16 amount = (UI16)JSVAL_TO_INT( argv[0] );	
+	UI32 amount		= (UI32)JSVAL_TO_INT( argv[0] );	
 
 	// Min. 2 Arguments (amount + id) or 3
 	if(( argc <2> 3 ))
I can compile atm, but my cvs access is still a little funky, and my primary boot drive went south this week, so no working UO install or anything like that.
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 »

Yup, seems to do the trick =)
-= Ho Eyo He Hum =-
Locked