RunUO Community

This is a sample guest message. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

VendorBuy and A Bug in DecayStock

jpmythic

Sorceror
VendorBuy and A Bug in DecayStock

:D

Well.. I just got done Merging latest RunUO with my Cutom Scripts
and I noticed this one possible Glitch in Vendors Reselling Non Normal
Stock Items:

BaseVendor.cs [ VendorBuy( Mobile from ) ] (stock script)

Code:
			ArrayList playerItems = cont.Items;

			for ( int i = playerItems.Count - 1; i >= 0; --i )
			{
				if ( i >= playerItems.Count )
					continue;

				Item item = (Item)playerItems[i];

				if ( (item.LastMoved + InventoryDecayTime) <= DateTime.Now )
					item.Delete();
			}
			
			for ( int i = 0; i < playerItems.Count; ++i )
			{
				Item item = (Item)playerItems[i];
				int price = 0;
				string name = null;
				foreach( IShopSellInfo ssi in sellInfo )
				{
					if ( ssi.IsSellable( item ) )
					{

Looking at this as I was getting ready to Add in more Items that
Vendors will buy that they Normally do NOT stock I saw that Even though
the PlayerSold Items (One previously bought and Not Restocked) from
Players and Placed in the BuyPack are Deleted.

Heres the Issue:
1: ) [First Check Deletes Decayed Items]
Decayed Stock is Deleted in the First Section.
ArrayList STILL contains a Reference to a Deleted Item

2: ) [Second Check gets Price for Item]
ArrayList STILL contains the Reference to the Item
No where does it Check to see if the Item is [ !item.Deleted() ]

And I do mean No Where does it check....
As it goes through it merely Checks to see if it can sell the Item. When
it goes through it's list of Items it can sell, It doesn't Test it for Deletion either.

What I can see happening here is:

Player says [ Vendor Buy OR Clicks on Buy ]

Vendor does a Stock Check, Decays several Items, BUT
he still offers to sell them to you...

It DOES correctly verify they Still have it to sell during the:
[ OnBuyItems(... ]

Code:
			foreach ( BuyItemResponse buy in list )
			{
				Serial ser = buy.Serial;
				int amount = buy.Amount;

				if ( ser.IsItem )
				{
					Item item = World.FindItem( ser );

					if ( item == null )
						continue;

					GenericBuyInfo gbi = LookupDisplayObject( item );

					if ( gbi != null )
					{

The only Problem with this is:

The Player will see Deleted Items in List and then NOT be Able to buy it
He can try, but it will just Ignore the Attempt.
Not until he calls a NEW list of Items for sale will it correct the Error.


This needs to be tested yet as I just noticed it.

Mythic
 
Top