Scrolls are removed at wrong place in the casting process

Found a bug in UOX3? Or experienced a server crash? Perhaps you've noticed a broken feature? Post the details here!
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:

Scrolls are removed at wrong place in the casting process

Post by Xuri »

Tested in UOX3 0.98-4.0 (running on WinXP Pro 32bit) using UO Client 6.0.12.3 (running on Vista 64bit).
Test-case:
1. 'ADD ITEM 0x1f31
2. Target your own character to add the item to your backpack
3. Double-click the "Heal"-scroll that was added to your backpack
4. Observe that the scroll vanishes the moment you double-click it, when it should have vanished when you successfully targeted a valid target.
The scrolls are getting removed in bool CPIDblClick::Handle( void ) (cPlayerAction.cpp)...

Code: Select all

	//	Begin Scrolls check
	if( iUsed->GetID( 1 ) == 0x1F && ( iUsed->GetID( 2 ) > 0x2C && iUsed->GetID( 2 ) < 0x6D ) )
	{
		bool success = false;
		tSock->CurrentSpellType( 1 );	// spell from scroll
		if( iUsed->GetID( 2 ) == 0x2D )	// Reactive Armor spell scrolls
			success = Magic->SelectSpell( tSock, 7 );
		if( iUsed->GetID( 2 ) >= 0x2E && iUsed->GetID( 2 ) <= 0x34 )  // first circle spell scrolls
			success = Magic->SelectSpell( tSock, iUsed->GetID( 2 ) - 0x2D );
		else if( iUsed->GetID( 2 ) >= 0x35 && iUsed->GetID( 2 ) <= 0x6C )  // 2 to 8 circle spell scrolls
			success = Magic->SelectSpell( tSock, iUsed->GetID( 2 ) - 0x2D + 1 );

		if( success )
			[color=red]iUsed->IncAmount( -1 );[/color]
		return true;
	}
When they should be removed in... say... void cMagic::CastSpell( CSocket *s, CChar *caster )
(magic.cpp), after a valid target has been verified?
-= 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 »

The reason it's removed in DoubleClick is the client doesn't know the serial of the item we used, so when we get to CastSpell() we wouldn't know what item to remove.

We could add code to look for a scroll matching that spell type in the characters pack but that's problematic. Alternatively we could do something similar to what we do for house deeds (we use the SpeechItem temporary storage on CChar), but frankly I don't care for that implementation in the house code, let alone have the desire to reproduce it elsewhere.
Post Reply