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!

Lucid Nagual's << OWLTR & FS Taming Plugin | Carpenter & Fletcher BODs >>

Gyges

Wanderer
Bulk Order Book Crashes

Hey there,

I seem to be having some problems with the Bulk Order Books. Whenever I try to apply a filter it crashes my server.

Here's the Crash log:
HTML:
Server Crash Report
===================

RunUO Version 1.0.0, Build 36918
Operating System: Microsoft Windows NT 5.1.2600.0
.NET Framework: 1.1.4322.2032
Time: 6/3/2006 5:37:23 PM
Mobiles: 35561
Items: 248548
Clients:
- Count: 1
+ 192.168.1.100: (account = Gyges) (mobile = 0x92F 'Gyges')

Exception:
System.NullReferenceException: Object reference not set to an instance of an object.
   at Server.Gumps.LevelControlStoneGump..ctor()
   at Server.LevelSystem.LevelControlStone.OnDoubleClick(Mobile from)
   at Server.Mobile.Use(Item item)
   at Server.Network.PacketHandlers.UseReq(NetState state, PacketReader pvSrc)
   at Server.Network.MessagePump.HandleReceive(NetState ns)
   at Server.Network.MessagePump.Slice()
   at Server.Core.Main(String[] args)

Anyone else have this problem?
 
Gyges

Bulk Order Book Crashes
Hey there,

I seem to be having some problems with the Bulk Order Books. Whenever I try to apply a filter it crashes my server.

Here's the Crash log:
HTML Code:
Server Crash Report===================RunUO Version 1.0.0, Build 36918Operating System: Microsoft Windows NT 5.1.2600.0.NET Framework: 1.1.4322.2032Time: 6/3/2006 5:37:23 PMMobiles: 35561Items: 248548Clients:- Count: 1+ 192.168.1.100: (account = Gyges) (mobile = 0x92F 'Gyges')Exception:System.NullReferenceException: Object reference not set to an instance of an object. at Server.Gumps.LevelControlStoneGump..ctor() at Server.LevelSystem.LevelControlStone.OnDoubleClick(Mobile from) at Server.Mobile.Use(Item item) at Server.Network.PacketHandlers.UseReq(NetState state, PacketReader pvSrc) at Server.Network.MessagePump.HandleReceive(NetState ns) at Server.Network.MessagePump.Slice() at Server.Core.Main(String[] args)​


Anyone else have this problem?
Next time try to recreate the crash in debug mode cause it will tell me the exact area that has the problem. BUT, this issue you have is from the LevelControlStone from the Easy Level System. It seems as though you upgraded and still use the stone. Please delete it cause it is no longer needed.
 

Rosey1

Wanderer
Ok I got the same thing too..oops!

This is what I got

Code:
Exception:
System.NullReferenceException: Object reference not set to an instance of an object.
   at Server.Engines.BulkOrders.BOBFilterGump.OnResponse(NetState sender, RelayInfo info)
   at Server.Network.PacketHandlers.DisplayGumpResponse(NetState state, PacketReader pvSrc)
   at Server.Network.MessagePump.HandleReceive(NetState ns)
   at Server.Network.MessagePump.Slice()
   at Server.Core.Main(String[] args)
 
Rosey1

Ok I got the same thing too..oops!

This is what I got

Code:
Exception:System.NullReferenceException: Object reference not set to an instance of an object. at Server.Engines.BulkOrders.BOBFilterGump.OnResponse(NetState sender, RelayInfo info) at Server.Network.PacketHandlers.DisplayGumpResponse(NetState state, PacketReader pvSrc) at Server.Network.MessagePump.HandleReceive(NetState ns) at Server.Network.MessagePump.Slice() at Server.Core.Main(String[] args)​
You need to run it in debug mode.
 

Turmoil

Wanderer
Running in Debug mode...

For those still not sure on how to run in "debug" mode in order to analyse a crash report correctly, do the following:

1- Create a shortcut for your Server.exe

2- From the shortcut, right click on it and go to properties

3- At the top of the properties window, go to where it indicates "Target". At the end of the location in target, put a space and add -debug. Press OK to save the changes to the edit in the target location.
Example: "F:\RunUO\Server.exe" -debug

4- Launch your server from the edited Shortcut. When the crash will produce, it will generate the usual crash report but in this report, it will indicate which file, and which line caused the crash. Running in "Debug" mode helps the scripter understand precisely what is happening without the guess work. gluck
 

Rosey1

Wanderer
thank you so much! This is what I got:

Code:
System.NullReferenceException: Object reference not set to an instance of an object.
   at Server.Engines.BulkOrders.BOBFilterGump.OnResponse(NetState sender, RelayInfo info) in c:\Documents and Settings\Owner\My Documents\RunUO 1.0\Scripts\Engines\BulkOrders\Books\BOBFilterGump.cs:line 321
   at Server.Network.PacketHandlers.DisplayGumpResponse(NetState state, PacketReader pvSrc)
   at Server.Network.MessagePump.HandleReceive(NetState ns)
   at Server.Network.MessagePump.Slice()
   at Server.Core.Main(String[] args)


The line is red is line 321:

Code:
if ( bod_mod == null && m_From == null )
				return;
			[color=red]
			BOBFilter f = (bod_mod.UseMyOwnFilter ? bod_mod.BOBFilter : m_Book.Filter);[/color]
			
			int index = info.ButtonID;
 
Rosey1

thank you so much! This is what I got:

Code:
System.NullReferenceException: Object reference not set to an instance of an object. at Server.Engines.BulkOrders.BOBFilterGump.OnResponse(NetState sender, RelayInfo info) in c:\Documents and Settings\Owner\My Documents\RunUO 1.0\Scripts\Engines\BulkOrders\Books\BOBFilterGump.cs:line 321 at Server.Network.PacketHandlers.DisplayGumpResponse(NetState state, PacketReader pvSrc) at Server.Network.MessagePump.HandleReceive(NetState ns) at Server.Network.MessagePump.Slice() at Server.Core.Main(String[] args)​



The line is red is line 321:

Code:
if ( bod_mod == null && m_From == null ) return; BOBFilter f = (bod_mod.UseMyOwnFilter ? bod_mod.BOBFilter : m_Book.Filter); int index = info.ButtonID;​
Sorry I am working 3rd shift now and just got home. I am happy to see that you got me the crash report in debug mode :) I will look it over after I get some sleep. Thank you.
 
Attention:

Running in Debug mode...
For those still not sure on how to run in "debug" mode in order to analyse a crash report correctly, do the following:

1- Create a shortcut for your Server.exe

2- From the shortcut, right click on it and go to properties

3- At the top of the properties window, go to where it indicates "Target". At the end of the location in target, put a space and add -debug. Press OK to save the changes to the edit in the target location.
Example: "F:\RunUO\Server.exe" -debug

4- Launch your server from the edited Shortcut. When the crash will produce, it will generate the usual crash report but in this report, it will indicate which file, and which line caused the crash. Running in "Debug" mode helps the scripter understand precisely what is happening without the guess work. gluck
Thanks Turmoil :)
--------------------------------------------------
thank you so much! This is what I got:


Code:
System.NullReferenceException: Object reference not set to an instance of an object. at Server.Engines.BulkOrders.BOBFilterGump.OnResponse(NetState sender, RelayInfo info) in c:\Documents and Settings\Owner\My Documents\RunUO 1.0\Scripts\Engines\BulkOrders\Books\BOBFilterGump.cs:line 321 at Server.Network.PacketHandlers.DisplayGumpResponse(NetState state, PacketReader pvSrc) at Server.Network.MessagePump.HandleReceive(NetState ns) at Server.Network.MessagePump.Slice() at Server.Core.Main(String[] args)​



The line is red is line 321:


Code:
if ( bod_mod == null && m_From == null ) return; BOBFilter f = (bod_mod.UseMyOwnFilter ? bod_mod.BOBFilter : m_Book.Filter); int index = info.ButtonID;​
I found the problem and updated the system. Please reinstall this is a very important update.

~Updated v[4].0.1 (b)~
Fixed all BOB gumps.
 

Rosey1

Wanderer
This is what I'm getting now (when you open a bod book, it crashes).

Code:
Error:
System.NullReferenceException: Object reference not set to an instance of an obj
ect.
   at Server.Engines.BulkOrders.BOBGump.CheckFilter(BulkMaterialType mat, Int32
amountMax, Boolean isLarge, Boolean reqExc, BODType deedType, Type itemType) in
c:\Documents and Settings\Owner\My Documents\RunUO 1.0\Scripts\Engines\BulkOrder
s\Books\BOBGump.cs:line 61
   at Server.Engines.BulkOrders.BOBGump.CheckFilter(Object obj) in c:\Documents
and Settings\Owner\My Documents\RunUO 1.0\Scripts\Engines\BulkOrders\Books\BOBGu
mp.cs:line 41
   at Server.Engines.BulkOrders.BOBGump..ctor(PlayerMobile from, BulkOrderBook b
ook, Int32 page, ArrayList list) in c:\Documents and Settings\Owner\My Documents
\RunUO 1.0\Scripts\Engines\BulkOrders\Books\BOBGump.cs:line 466
   at Server.Engines.BulkOrders.BOBGump..ctor(PlayerMobile from, BulkOrderBook b
ook) in c:\Documents and Settings\Owner\My Documents\RunUO 1.0\Scripts\Engines\B
ulkOrders\Books\BOBGump.cs:line 284
   at Server.Engines.BulkOrders.BulkOrderBook.OnDoubleClick(Mobile from) in c:\D
ocuments and Settings\Owner\My Documents\RunUO 1.0\Scripts\Engines\BulkOrders\Bo
oks\BulkOrderBook.cs:line 62
   at Server.Mobile.Use(Item item)
   at Server.Network.PacketHandlers.UseReq(NetState state, PacketReader pvSrc)
   at Server.Network.MessagePump.HandleReceive(NetState ns)
   at Server.Network.MessagePump.Slice()
   at Server.Core.Main(String[] args)
Crash: Backing up...done
Crash: Generating report...done
Crash: Restarting...done
Warning:
System.Threading.ThreadAbortException: Thread was being aborted.
   at System.Threading.Thread.Sleep(Int32 millisecondsTimeout)
   at Server.TimerThread.TimerMain()
 

Gyges

Wanderer
I'm also having the same problem as Rosey1.

I'm wondering if the Bacaw's Easy level system is causing the problem. Earlier you stated that the Level Control stone is no longer needed with that system. However the latest files posted in that thread still contain the Level control Stone script...

I'm thinking this weekend I will try removing the Easy Level System and see if that helps...
 
Gyges

I'm also having the same problem as Rosey1.

I'm wondering if the Bacaw's Easy level system is causing the problem. Earlier you stated that the Level Control stone is no longer needed with that system. However the latest files posted in that thread still contain the Level control Stone script...

I'm thinking this weekend I will try removing the Easy Level System and see if that helps...
No that is not it.
System.NullReferenceException: Object reference not set to an instance of an object.
at Server.Gumps.LevelControlStoneGump..ctor()
at Server.LevelSystem.LevelControlStone.OnDoubleClick(Mobile from)
Your previous crash clearly stated that it was not the BOD system. As you can see it states that in your crash report. If all your orbs have been converted you can remove the stone but there are many references in many scripts and could give you a hard time. The report also states that you had it spawned and double-clicked it. The solution for that is simple DO NOT USE the stone. The next release will have it removed and if people haven't converted by that time they will be left in the dark.

And....I had to leave the old scripts in cause previous users had to upgrade their Orbs to Modules. If I had took the stone out there would have been several errors cause the scripts that functioned around the orbs had references to the stone. Does that make better sense now? This crash is coming from the module reference and if you two aren't up to date and don't use the module system this issue will occur. The module system is not optional and is inforced for this version and all future updates. You will see why when u try to upgrade your RunUo to 2.0. If you don't know how to unserilize your PlayerMobile you are going to be screwed. With that thought you might better appreciate the module systems I have been releasing.

But anyway, I need to know if you have the module system before I can look into this further. If you don't have it installed then that is what is causing the crash.
 

Rosey1

Wanderer
Lucid Nagual said:
Do you have the current update with the BODModule? I tested the book and tried to get thids crash and can't :(

Yeah I took the files from CFTB and overwrote them to mine.

I tried again and still a no go. I'm not sure what I'm doing wrong but I have the module installed and I don't have the levelstone.

I might be missing something huge but I'm so sick tonight :(

This is my line 61 in Bobgump:

Code:
BOBFilter f = ( bod_mod.UseMyOwnFilter ? bod_mod.BOBFilter : m_Book.Filter );
			//BOBFilter f = ( m_From.UseOwnFilter ? m_From.BOBFilter : m_Book.Filter );

Line 41:

Code:
return CheckFilter( e.Material, e.AmountMax, true, e.RequireExceptional, e.DeedType, ( e.Entries.Length > 0 ? e.Entries[0].ItemType : null ) );

line 466

Code:
for ( int i = 0; i < book.Entries.Count; ++i )
				{
					object obj = book.Entries[i];

					[color=red]if ( CheckFilter( obj ) )[/color]
						list.Add( obj );
				}

line 284

Code:
public BOBGump( PlayerMobile from, BulkOrderBook book ) : this( from, book, 0, null )

line 62 from bulkorderbook.cs

Code:
	else if ( m_Entries.Count == 0 )
				from.SendLocalizedMessage( 1062381 ); // The book is empty.
			else if ( from is PlayerMobile )
				[color=red]from.SendGump( new BOBGump( (PlayerMobile)from, this ) );[/color]
		}
 

Turmoil

Wanderer
Rosey1...:)

Rosey1 said:
You rock Lucid! Thank Turmoil for the debug mode :)

No prob Rosey1. I always try to help when I have free time which lately just doesn't seem to happen.

As for the crash's, sorry can't help with that at this moment because I haven't updated since v[3].0.2b so I didn't have time to install the ACC and Central Memory and not running with the BOD Module. Hope you find the answer soon but will try to set it up on my test server to see what's happening.
 
No prob Rosey1. I always try to help when I have free time which lately just doesn't seem to happen.

As for the crash's, sorry can't help with that at this moment because I haven't updated since v[3].0.2b so I didn't have time to install the ACC and Central Memory and not running with the BOD Module. Hope you find the answer soon but will try to set it up on my test server to see what's happening.
I have tried to recreate this crash many times and have had no luck. I have added carp, fletcher, smith and tailor BODs to the BOB and have opened it every time and have hit every imaginable button. However, there still is no crash. Rosey post your whole BobGump.cs. Thanks.
 

Rosey1

Wanderer
It only works when my player character does it or someone else, not the admin.

This one crashes the server even when you open the bod book.
Code:
using System;
using System.Collections;
using Server;
using Server.Gumps;
using Server.Items;
using Server.Mobiles;
using Server.Prompts;
using Server.ACC.CM;


namespace Server.Engines.BulkOrders
{
	public class BOBGump : Gump
	{
		private PlayerMobile m_From;
		private BulkOrderBook m_Book;
		private ArrayList m_List;

		private int m_Page;

		private const int LabelColor = 0x7FFF;

		public Item Reconstruct( object obj )
		{
			Item item = null;

			if ( obj is BOBLargeEntry )
				item = ((BOBLargeEntry)obj).Reconstruct();
			else if ( obj is BOBSmallEntry )
				item = ((BOBSmallEntry)obj).Reconstruct();

			return item;
		}

		public bool CheckFilter( object obj )
		{
			if ( obj is BOBLargeEntry )
			{
				BOBLargeEntry e = (BOBLargeEntry)obj;

				return CheckFilter( e.Material, e.AmountMax, true, e.RequireExceptional, e.DeedType, ( e.Entries.Length > 0 ? e.Entries[0].ItemType : null ) );
			}
			else if ( obj is BOBSmallEntry )
			{
				BOBSmallEntry e = (BOBSmallEntry)obj;

				return CheckFilter( e.Material, e.AmountMax, false, e.RequireExceptional, e.DeedType, e.ItemType );
			}

			return false;
		}

		public bool CheckFilter( BulkMaterialType mat, int amountMax, bool isLarge, bool reqExc, BODType deedType, Type itemType )
		{
			BODModule BOD = ( BODModule )CentralMemory.GetModule( m_From.Serial, typeof( BODModule ) );
			BODModule bod_mod = BOD as BODModule;
			
			if ( bod_mod == null && m_From == null )
				return false;
		
			BOBFilter f = ( bod_mod.UseMyOwnFilter ? bod_mod.BOBFilter : m_Book.Filter );
			//BOBFilter f = ( m_From.UseOwnFilter ? m_From.BOBFilter : m_Book.Filter );

			if ( f.IsDefault )
				return true;

			if ( f.Quality == 1 && reqExc )
				return false;
			else if ( f.Quality == 2 && !reqExc )
				return false;

			if ( f.Quantity == 1 && amountMax != 10 )
				return false;
			else if ( f.Quantity == 2 && amountMax != 15 )
				return false;
			else if ( f.Quantity == 3 && amountMax != 20 )
				return false;

			if ( f.Type == 1 && isLarge )
				return false;
			else if ( f.Type == 2 && !isLarge )
				return false;

			switch ( f.Material )
			{
				default:
				case  0: return true;
				case  1: return ( deedType == BODType.Smith );
				case  2: return ( deedType == BODType.Tailor );
				case  3: return ( deedType == BODType.Carpenter );

				case  4: return ( mat == BulkMaterialType.None && BGTClassifier.Classify( deedType, itemType ) == BulkGenericType.Iron );
				case  5: return ( mat == BulkMaterialType.DullCopper );
				case  6: return ( mat == BulkMaterialType.ShadowIron );
				case  7: return ( mat == BulkMaterialType.Copper );
				case  8: return ( mat == BulkMaterialType.Bronze );
				case  9: return ( mat == BulkMaterialType.Gold );
				case 10: return ( mat == BulkMaterialType.Agapite );
				case 11: return ( mat == BulkMaterialType.Verite );
				case 12: return ( mat == BulkMaterialType.Valorite );
				case 13: return ( mat == BulkMaterialType.Blaze );
				case 14: return ( mat == BulkMaterialType.Ice );
				case 15: return ( mat == BulkMaterialType.Toxic );
				case 16: return ( mat == BulkMaterialType.Electrum );
				case 17: return ( mat == BulkMaterialType.Platinum );

				case 18: return ( mat == BulkMaterialType.None && BGTClassifier.Classify( deedType, itemType ) == BulkGenericType.Cloth );
				case 19: return ( mat == BulkMaterialType.None && BGTClassifier.Classify( deedType, itemType ) == BulkGenericType.Leather );
				case 20: return ( mat == BulkMaterialType.Spined );
				case 21: return ( mat == BulkMaterialType.Horned );
				case 22: return ( mat == BulkMaterialType.Barbed );
				case 23: return ( mat == BulkMaterialType.Polar );
				case 24: return ( mat == BulkMaterialType.Synthetic );
				case 25: return ( mat == BulkMaterialType.BlazeL );
				case 26: return ( mat == BulkMaterialType.Daemonic );
				case 27: return ( mat == BulkMaterialType.Shadow );
				case 28: return ( mat == BulkMaterialType.Frost );
				case 29: return ( mat == BulkMaterialType.Ethereal );
/////////////////////////////////////
//     All Crafts [Start] Edit 1/2 //
/////////////////////////////////////	
				case 30: return ( mat == BulkMaterialType.None && BGTClassifier.Classify( deedType, itemType ) == BulkGenericType.Wood );
				case 31: return ( mat == BulkMaterialType.Pine );
				case 32: return ( mat == BulkMaterialType.Ash );
				case 33: return ( mat == BulkMaterialType.Mohogany );
				case 34: return ( mat == BulkMaterialType.Yew );
				case 35: return ( mat == BulkMaterialType.Oak );
				case 36: return ( mat == BulkMaterialType.Zircote );
				case 37: return ( mat == BulkMaterialType.Ebony );
				case 38: return ( mat == BulkMaterialType.Bamboo );
				case 39: return ( mat == BulkMaterialType.PurpleHeart );
				case 40: return ( mat == BulkMaterialType.Redwood );
				case 41: return ( mat == BulkMaterialType.Petrified );
/////////////////////////////////////
//       All Crafts [End] Edit 1/2 //
/////////////////////////////////////	
			}
		}

		public int GetIndexForPage( int page )
		{
			int index = 0;

			while ( page-- > 0 )
				index += GetCountForIndex( index );

			return index;
		}

		public int GetCountForIndex( int index )
		{
			int slots = 0;
			int count = 0;

			ArrayList list = m_List;

			for ( int i = index; i >= 0 && i < list.Count; ++i )
			{
				object obj = list[i];

				if ( CheckFilter( obj ) )
				{
					int add;

					if ( obj is BOBLargeEntry )
						add = ((BOBLargeEntry)obj).Entries.Length;
					else
						add = 1;

					if ( (slots + add) > 10 )
						break;

					slots += add;
				}

				++count;
			}

			return count;
		}

		public object GetMaterialName( BulkMaterialType mat, BODType type, Type itemType )
		{
			switch ( type )
			{
				case BODType.Smith:
				{
					switch ( mat )
					{
						case BulkMaterialType.None: return 1062226;
						case BulkMaterialType.DullCopper: return 1018332;
						case BulkMaterialType.ShadowIron: return 1018333;
						case BulkMaterialType.Copper: return 1018334;
						case BulkMaterialType.Bronze: return 1018335;
						case BulkMaterialType.Gold: return 1018336;
						case BulkMaterialType.Agapite: return 1018337;
						case BulkMaterialType.Verite: return 1018338;
						case BulkMaterialType.Valorite: return 1018339;
						case BulkMaterialType.Blaze: return "Blaze";
						case BulkMaterialType.Ice: return "Ice";
						case BulkMaterialType.Toxic: return "Toxic";
						case BulkMaterialType.Electrum: return "Electrum";
						case BulkMaterialType.Platinum: return "Platinum";
					}

					break;
				}
				case BODType.Tailor:
				{
					switch ( mat )
					{
						case BulkMaterialType.None:
						{
							if ( itemType.IsSubclassOf( typeof( BaseArmor ) ) || itemType.IsSubclassOf( typeof( BaseShoes ) ) )
								return 1062235;

							return 1044286;
						}
						case BulkMaterialType.Spined: return 1062236;
						case BulkMaterialType.Horned: return 1062237;
						case BulkMaterialType.Barbed: return 1062238;
						case BulkMaterialType.Polar: return "Polar";
						case BulkMaterialType.Synthetic: return "Synthetic";
						case BulkMaterialType.BlazeL: return "Blaze";
						case BulkMaterialType.Daemonic: return "Daemonic";
						case BulkMaterialType.Shadow: return "Shadow";
						case BulkMaterialType.Frost: return "Frost";
						case BulkMaterialType.Ethereal: return "Ethereal";
/////////////////////////////////////
//     All Crafts [Start] Edit 2/2 //
/////////////////////////////////////	
					}

					break;
				}
				case BODType.Carpenter:
				{
					switch ( mat )
					{
						case BulkMaterialType.None: return "Wood";
						case BulkMaterialType.Pine: return "Pine";
						case BulkMaterialType.Ash: return "Ash";
						case BulkMaterialType.Mohogany: return "Mohogany";
						case BulkMaterialType.Yew: return "Yew";
						case BulkMaterialType.Oak: return "Oak";
						case BulkMaterialType.Zircote: return "Zircote";
						case BulkMaterialType.Ebony: return "Ebony";
						case BulkMaterialType.Bamboo: return "Bamboo";
						case BulkMaterialType.PurpleHeart: return "PurpleHeart";
						case BulkMaterialType.Redwood: return "Redwood";
						case BulkMaterialType.Petrified: return "Petrified";
					}

					break;
				}
				case BODType.Fletcher:
				{
					switch ( mat )
					{
						case BulkMaterialType.None: return "Wood";
						case BulkMaterialType.Pine: return "Pine";
						case BulkMaterialType.Ash: return "Ash";
						case BulkMaterialType.Mohogany: return "Mohogany";
						case BulkMaterialType.Yew: return "Yew";
						case BulkMaterialType.Oak: return "Oak";
						case BulkMaterialType.Zircote: return "Zircote";
						case BulkMaterialType.Ebony: return "Ebony";
						case BulkMaterialType.Bamboo: return "Bamboo";
						case BulkMaterialType.PurpleHeart: return "PurpleHeart";
						case BulkMaterialType.Redwood: return "Redwood";
						case BulkMaterialType.Petrified: return "Petrified";
/////////////////////////////////////
//       All Crafts [End] Edit 2/2 //
/////////////////////////////////////			
					}

					break;
				}
			}

			return "Invalid";
		}

		public BOBGump( PlayerMobile from, BulkOrderBook book ) : this( from, book, 0, null )
		{
		}

		public override void OnResponse( Server.Network.NetState sender, RelayInfo info )
		{
			int index = info.ButtonID;

			switch ( index )
			{
				case 0: // EXIT
				{
					break;
				}
				case 1: // Set Filter
				{
					m_From.SendGump( new BOBFilterGump( m_From, m_Book ) );

					break;
				}
				case 2: // Previous page
				{
					if ( m_Page > 0 )
						m_From.SendGump( new BOBGump( m_From, m_Book, m_Page - 1, m_List ) );

					return;
				}
				case 3: // Next page
				{
					if ( GetIndexForPage( m_Page + 1 ) < m_List.Count )
						m_From.SendGump( new BOBGump( m_From, m_Book, m_Page + 1, m_List ) );

					break;
				}
				default:
				{
					bool canDrop = m_Book.IsChildOf( m_From.Backpack );
					bool canPrice = canDrop || (m_Book.RootParent is PlayerVendor);

					index -= 4;

					int type = index % 2;
					index /= 2;

					if ( index < 0 || index >= m_List.Count )
						break;

					object obj = m_List[index];

					if ( !m_Book.Entries.Contains( obj ) )
					{
						m_From.SendLocalizedMessage( 1062382 ); // The deed selected is not available.
						break;
					}

					if ( type == 0 ) // Drop
					{
						if ( m_Book.IsChildOf( m_From.Backpack ) )
						{
							Item item = Reconstruct( obj );

							if ( item != null )
							{
								m_From.AddToBackpack( item );
								m_From.SendLocalizedMessage( 1045152 ); // The bulk order deed has been placed in your backpack.

								m_Book.Entries.Remove( obj );
								m_Book.InvalidateProperties();

								if ( m_Book.Entries.Count > 0 )
									m_From.SendGump( new BOBGump( m_From, m_Book, 0, null ) );
								else
									m_From.SendLocalizedMessage( 1062381 ); // The book is empty.
							}
							else
							{
								m_From.SendMessage( "Internal error. The bulk order deed could not be reconstructed." );
							}
						}
					}
					else // Set Price | Buy
					{
						if ( m_Book.IsChildOf( m_From.Backpack ) )
						{
							m_From.Prompt = new SetPricePrompt( m_Book, obj, m_Page, m_List );
							m_From.SendLocalizedMessage( 1062383 ); // Type in a price for the deed:
						}
						else if ( m_Book.RootParent is PlayerVendor )
						{
							PlayerVendor pv = (PlayerVendor)m_Book.RootParent;

							VendorItem vi = pv.GetVendorItem( m_Book );

							int price = 0;

							if ( vi != null && !vi.IsForSale )
							{
								if ( obj is BOBLargeEntry )
									price = ((BOBLargeEntry)obj).Price;
								else if ( obj is BOBSmallEntry )
									price = ((BOBSmallEntry)obj).Price;
							}

							if ( price == 0 )
								m_From.SendLocalizedMessage( 1062382 ); // The deed selected is not available.
							else
								m_From.SendGump( new BODBuyGump( m_From, m_Book, obj, price ) );
						}
					}

					break;
				}
			}
		}

		private class SetPricePrompt : Prompt
		{
			private BulkOrderBook m_Book;
			private object m_Object;
			private int m_Page;
			private ArrayList m_List;

			public SetPricePrompt( BulkOrderBook book, object obj, int page, ArrayList list )
			{
				m_Book = book;
				m_Object = obj;
				m_Page = page;
				m_List = list;
			}

			public override void OnResponse( Mobile from, string text )
			{
				if ( !m_Book.Entries.Contains( m_Object ) )
				{
					from.SendLocalizedMessage( 1062382 ); // The deed selected is not available.
					return;
				}

				int price = Utility.ToInt32( text );

				if ( price < 0 || price > 250000000 )
				{
					from.SendLocalizedMessage( 1062390 ); // The price you requested is outrageous!
				}
				else if ( m_Object is BOBLargeEntry )
				{
					((BOBLargeEntry)m_Object).Price = price;

					from.SendLocalizedMessage( 1062384 ); // Deed price set.

					if ( from is PlayerMobile )
						from.SendGump( new BOBGump( (PlayerMobile)from, m_Book, m_Page, m_List ) );
				}
				else if ( m_Object is BOBSmallEntry )
				{
					((BOBSmallEntry)m_Object).Price = price;

					from.SendLocalizedMessage( 1062384 ); // Deed price set.

					if ( from is PlayerMobile )
						from.SendGump( new BOBGump( (PlayerMobile)from, m_Book, m_Page, m_List ) );
				}
			}
		}

		public BOBGump( PlayerMobile from, BulkOrderBook book, int page, ArrayList list ) : base( 12, 24 )
		{
			from.CloseGump( typeof( BOBGump ) );
			from.CloseGump( typeof( BOBFilterGump ) );

			m_From = from;
			m_Book = book;
			m_Page = page;

			if ( list == null )
			{
				list = new ArrayList( book.Entries.Count );

				for ( int i = 0; i < book.Entries.Count; ++i )
				{
					object obj = book.Entries[i];

					if ( CheckFilter( obj ) )
						list.Add( obj );
				}
			}

			m_List = list;

			int index = GetIndexForPage( page );
			int count = GetCountForIndex( index );

			int tableIndex = 0;

			PlayerVendor pv = book.RootParent as PlayerVendor;

			bool canDrop = book.IsChildOf( from.Backpack );
			bool canBuy = ( pv != null );
			bool canPrice = ( canDrop || canBuy );

			if ( canBuy )
			{
				VendorItem vi = pv.GetVendorItem( book );

				canBuy = ( vi != null && !vi.IsForSale );
			}

			int width = 600;

			if ( !canPrice )
				width = 516;

			X = (624 - width) / 2;

			AddPage( 0 );

			AddBackground( 10, 10, width, 439, 5054 );
			AddImageTiled( 18, 20, width - 17, 420, 2624 );

			if ( canPrice )
			{
				AddImageTiled( 573, 64, 24, 352, 200 );
				AddImageTiled( 493, 64, 78, 352, 1416 );
			}

			if ( canDrop )
				AddImageTiled( 24, 64, 32, 352, 1416 );

			AddImageTiled( 58, 64, 36, 352, 200 );
			AddImageTiled( 96, 64, 133, 352, 1416 );
			AddImageTiled( 231, 64, 80, 352, 200 );
			AddImageTiled( 313, 64, 100, 352, 1416 );
			AddImageTiled( 415, 64, 76, 352, 200 );

			for ( int i = index; i < (index + count) && i >= 0 && i < list.Count; ++i )
			{
				object obj = list[i];

				if ( !CheckFilter( obj ) )
					continue;

				AddImageTiled( 24, 94 + (tableIndex * 32), canPrice ? 573 : 489, 2, 2624 );

				if ( obj is BOBLargeEntry )
					tableIndex += ((BOBLargeEntry)obj).Entries.Length;
				else if ( obj is BOBSmallEntry )
					++tableIndex;
			}

			AddAlphaRegion( 18, 20, width - 17, 420 );
			AddImage( 5, 5, 10460 );
			AddImage( width - 15, 5, 10460 );
			AddImage( 5, 424, 10460 );
			AddImage( width - 15, 424, 10460 );

			AddHtmlLocalized( canPrice ? 266 : 224, 32, 200, 32, 1062220, LabelColor, false, false ); // Bulk Order Book
			AddHtmlLocalized( 63, 64, 200, 32, 1062213, LabelColor, false, false ); // Type
			AddHtmlLocalized( 147, 64, 200, 32, 1062214, LabelColor, false, false ); // Item
			AddHtmlLocalized( 246, 64, 200, 32, 1062215, LabelColor, false, false ); // Quality
			AddHtmlLocalized( 336, 64, 200, 32, 1062216, LabelColor, false, false ); // Material
			AddHtmlLocalized( 429, 64, 200, 32, 1062217, LabelColor, false, false ); // Amount

			AddButton( 35, 32, 4005, 4007, 1, GumpButtonType.Reply, 0 );
			AddHtmlLocalized( 70, 32, 200, 32, 1062476, LabelColor, false, false ); // Set Filter

			BODModule BOD = ( BODModule )CentralMemory.GetModule( from.Serial, typeof( BODModule ) );
			BODModule bod_mod = BOD as BODModule;
			
			if ( bod_mod == null && from == null )
				return;
			
			BOBFilter f = ( bod_mod.UseMyOwnFilter ? bod_mod.BOBFilter : book.Filter );
			//BOBFilter f = ( from.UseOwnFilter ? from.BOBFilter : book.Filter );
			
			if ( f.IsDefault )
				AddHtmlLocalized( canPrice ? 470 : 386, 32, 120, 32, 1062475, 16927, false, false ); // Using No Filter
			else if ( bod_mod.UseMyOwnFilter )
				AddHtmlLocalized( canPrice ? 470 : 386, 32, 120, 32, 1062451, 16927, false, false ); // Using Your Filter
			else
				AddHtmlLocalized( canPrice ? 470 : 386, 32, 120, 32, 1062230, 16927, false, false ); // Using Book Filter

			AddButton( 375, 416, 4017, 4018, 0, GumpButtonType.Reply, 0 );
			AddHtmlLocalized( 410, 416, 120, 20, 1011441, LabelColor, false, false ); // EXIT

			if ( canDrop )
				AddHtmlLocalized( 26, 64, 50, 32, 1062212, LabelColor, false, false ); // Drop

			if ( canPrice )
			{
				AddHtmlLocalized( 516, 64, 200, 32, 1062218, LabelColor, false, false ); // Price

				if ( canBuy )
					AddHtmlLocalized( 576, 64, 200, 32, 1062219, LabelColor, false, false ); // Buy
				else
					AddHtmlLocalized( 576, 64, 200, 32, 1062227, LabelColor, false, false ); // Set
			}

			tableIndex = 0;

			if ( page > 0 )
			{
				AddButton( 75, 416, 4014, 4016, 2, GumpButtonType.Reply, 0 );
				AddHtmlLocalized( 110, 416, 150, 20, 1011067, LabelColor, false, false ); // Previous page
			}

			if ( GetIndexForPage( page + 1 ) < list.Count )
			{
				AddButton( 225, 416, 4005, 4007, 3, GumpButtonType.Reply, 0 );
				AddHtmlLocalized( 260, 416, 150, 20, 1011066, LabelColor, false, false ); // Next page
			}

			for ( int i = index; i < (index + count) && i >= 0 && i < list.Count; ++i )
			{
				object obj = list[i];

				if ( !CheckFilter( obj ) )
					continue;

				if ( obj is BOBLargeEntry )
				{
					BOBLargeEntry e = (BOBLargeEntry)obj;

					int y = 96 + (tableIndex * 32);

					if ( canDrop )
						AddButton( 35, y + 2, 5602, 5606, 4 + (i * 2), GumpButtonType.Reply, 0 );

					if ( canDrop || (canBuy && e.Price > 0) )
					{
						AddButton( 579, y + 2, 2117, 2118, 5 + (i * 2), GumpButtonType.Reply, 0 );
						AddLabel( 495, y, 1152, e.Price.ToString() );
					}

					AddHtmlLocalized( 61, y, 50, 32, 1062225, LabelColor, false, false ); // Large

					for ( int j = 0; j < e.Entries.Length; ++j )
					{
						BOBLargeSubEntry sub = e.Entries[j];

						AddHtmlLocalized( 103, y, 130, 32, sub.Number, LabelColor, false, false );

						if ( e.RequireExceptional )
							AddHtmlLocalized( 235, y, 80, 20, 1060636, LabelColor, false, false ); // exceptional
						else
							AddHtmlLocalized( 235, y, 80, 20, 1011542, LabelColor, false, false ); // normal

						object name = GetMaterialName( e.Material, e.DeedType, sub.ItemType );

						if ( name is int )
							AddHtmlLocalized( 316, y, 100, 20, (int)name, LabelColor, false, false );
						else if ( name is string )
							AddLabel( 316, y, 1152, (string)name );

						AddLabel( 421, y, 1152, String.Format( "{0} / {1}", sub.AmountCur, e.AmountMax ) );

						++tableIndex;
						y += 32;
					}
				}
				else if ( obj is BOBSmallEntry )
				{
					BOBSmallEntry e = (BOBSmallEntry)obj;

					int y = 96 + (tableIndex++ * 32);

					if ( canDrop )
						AddButton( 35, y + 2, 5602, 5606, 4 + (i * 2), GumpButtonType.Reply, 0 );

					if ( canDrop || (canBuy && e.Price > 0) )
					{
						AddButton( 579, y + 2, 2117, 2118, 5 + (i * 2), GumpButtonType.Reply, 0 );
						AddLabel( 495, y, 1152, e.Price.ToString() );
					}

					AddHtmlLocalized( 61, y, 50, 32, 1062224, LabelColor, false, false ); // Small

					AddHtmlLocalized( 103, y, 130, 32, e.Number, LabelColor, false, false );

					if ( e.RequireExceptional )
						AddHtmlLocalized( 235, y, 80, 20, 1060636, LabelColor, false, false ); // exceptional
					else
						AddHtmlLocalized( 235, y, 80, 20, 1011542, LabelColor, false, false ); // normal

					object name = GetMaterialName( e.Material, e.DeedType, e.ItemType );

					if ( name is int )
						AddHtmlLocalized( 316, y, 100, 20, (int)name, LabelColor, false, false );
					else if ( name is string )
						AddLabel( 316, y, 1152, (string)name );

					AddLabel( 421, y, 1152, String.Format( "{0} / {1}", e.AmountCur, e.AmountMax ) );
				}
			}
		}
	}
}

This one crashes the server upon filtering.

Code:
using System;
using System.Collections;
using Server;
using Server.Gumps;
using Server.Items;
using Server.Mobiles;
using Server.Prompts;

namespace Server.Engines.BulkOrders
{
	public class BOBGump : Gump
	{
		private PlayerMobile m_From;
		private BulkOrderBook m_Book;
		private ArrayList m_List;

		private int m_Page;

		private const int LabelColor = 0x7FFF;

		public Item Reconstruct( object obj )
		{
			Item item = null;

			if ( obj is BOBLargeEntry )
				item = ((BOBLargeEntry)obj).Reconstruct();
			else if ( obj is BOBSmallEntry )
				item = ((BOBSmallEntry)obj).Reconstruct();

			return item;
		}

		public bool CheckFilter( object obj )
		{
			if ( obj is BOBLargeEntry )
			{
				BOBLargeEntry e = (BOBLargeEntry)obj;

				return CheckFilter( e.Material, e.AmountMax, true, e.RequireExceptional, e.DeedType, ( e.Entries.Length > 0 ? e.Entries[0].ItemType : null ) );
			}
			else if ( obj is BOBSmallEntry )
			{
				BOBSmallEntry e = (BOBSmallEntry)obj;

				return CheckFilter( e.Material, e.AmountMax, false, e.RequireExceptional, e.DeedType, e.ItemType );
			}

			return false;
		}

		public bool CheckFilter( BulkMaterialType mat, int amountMax, bool isLarge, bool reqExc, BODType deedType, Type itemType )
		{
			BOBFilter f = ( m_From.UseOwnFilter ? m_From.BOBFilter : m_Book.Filter );

			if ( f.IsDefault )
				return true;

			if ( f.Quality == 1 && reqExc )
				return false;
			else if ( f.Quality == 2 && !reqExc )
				return false;

			if ( f.Quantity == 1 && amountMax != 10 )
				return false;
			else if ( f.Quantity == 2 && amountMax != 15 )
				return false;
			else if ( f.Quantity == 3 && amountMax != 20 )
				return false;

			if ( f.Type == 1 && isLarge )
				return false;
			else if ( f.Type == 2 && !isLarge )
				return false;

			switch ( f.Material )
			{
				default:
				case  0: return true;
				case  1: return ( deedType == BODType.Smith );
				case  2: return ( deedType == BODType.Tailor );
				case  3: return ( deedType == BODType.Carpenter );

				case  4: return ( mat == BulkMaterialType.None && BGTClassifier.Classify( deedType, itemType ) == BulkGenericType.Iron );
				case  5: return ( mat == BulkMaterialType.DullCopper );
				case  6: return ( mat == BulkMaterialType.ShadowIron );
				case  7: return ( mat == BulkMaterialType.Copper );
				case  8: return ( mat == BulkMaterialType.Bronze );
				case  9: return ( mat == BulkMaterialType.Gold );
				case 10: return ( mat == BulkMaterialType.Agapite );
				case 11: return ( mat == BulkMaterialType.Verite );
				case 12: return ( mat == BulkMaterialType.Valorite );
				case 13: return ( mat == BulkMaterialType.Blaze );
				case 14: return ( mat == BulkMaterialType.Ice );
				case 15: return ( mat == BulkMaterialType.Toxic );
				case 16: return ( mat == BulkMaterialType.Electrum );
				case 17: return ( mat == BulkMaterialType.Platinum );

				case 18: return ( mat == BulkMaterialType.None && BGTClassifier.Classify( deedType, itemType ) == BulkGenericType.Cloth );
				case 19: return ( mat == BulkMaterialType.None && BGTClassifier.Classify( deedType, itemType ) == BulkGenericType.Leather );
				case 20: return ( mat == BulkMaterialType.Spined );
				case 21: return ( mat == BulkMaterialType.Horned );
				case 22: return ( mat == BulkMaterialType.Barbed );
				case 23: return ( mat == BulkMaterialType.Polar );
				case 24: return ( mat == BulkMaterialType.Synthetic );
				case 25: return ( mat == BulkMaterialType.BlazeL );
				case 26: return ( mat == BulkMaterialType.Daemonic );
				case 27: return ( mat == BulkMaterialType.Shadow );
				case 28: return ( mat == BulkMaterialType.Frost );
				case 29: return ( mat == BulkMaterialType.Ethereal );
/////////////////////////////////////
//     All Crafts [Start] Edit 1/2 //
/////////////////////////////////////	
				case 30: return ( mat == BulkMaterialType.None && BGTClassifier.Classify( deedType, itemType ) == BulkGenericType.Wood );
				case 31: return ( mat == BulkMaterialType.Pine );
				case 32: return ( mat == BulkMaterialType.Ash );
				case 33: return ( mat == BulkMaterialType.Mohogany );
				case 34: return ( mat == BulkMaterialType.Yew );
				case 35: return ( mat == BulkMaterialType.Oak );
				case 36: return ( mat == BulkMaterialType.Zircote );
				case 37: return ( mat == BulkMaterialType.Ebony );
				case 38: return ( mat == BulkMaterialType.Bamboo );
				case 39: return ( mat == BulkMaterialType.PurpleHeart );
				case 40: return ( mat == BulkMaterialType.Redwood );
				case 41: return ( mat == BulkMaterialType.Petrified );
/////////////////////////////////////
//       All Crafts [End] Edit 1/2 //
/////////////////////////////////////	
			}
		}

		public int GetIndexForPage( int page )
		{
			int index = 0;

			while ( page-- > 0 )
				index += GetCountForIndex( index );

			return index;
		}

		public int GetCountForIndex( int index )
		{
			int slots = 0;
			int count = 0;

			ArrayList list = m_List;

			for ( int i = index; i >= 0 && i < list.Count; ++i )
			{
				object obj = list[i];

				if ( CheckFilter( obj ) )
				{
					int add;

					if ( obj is BOBLargeEntry )
						add = ((BOBLargeEntry)obj).Entries.Length;
					else
						add = 1;

					if ( (slots + add) > 10 )
						break;

					slots += add;
				}

				++count;
			}

			return count;
		}

		public object GetMaterialName( BulkMaterialType mat, BODType type, Type itemType )
		{
			switch ( type )
			{
				case BODType.Smith:
				{
					switch ( mat )
					{
						case BulkMaterialType.None: return 1062226;
						case BulkMaterialType.DullCopper: return 1018332;
						case BulkMaterialType.ShadowIron: return 1018333;
						case BulkMaterialType.Copper: return 1018334;
						case BulkMaterialType.Bronze: return 1018335;
						case BulkMaterialType.Gold: return 1018336;
						case BulkMaterialType.Agapite: return 1018337;
						case BulkMaterialType.Verite: return 1018338;
						case BulkMaterialType.Valorite: return 1018339;
						case BulkMaterialType.Blaze: return "Blaze";
						case BulkMaterialType.Ice: return "Ice";
						case BulkMaterialType.Toxic: return "Toxic";
						case BulkMaterialType.Electrum: return "Electrum";
						case BulkMaterialType.Platinum: return "Platinum";
					}

					break;
				}
				case BODType.Tailor:
				{
					switch ( mat )
					{
						case BulkMaterialType.None:
						{
							if ( itemType.IsSubclassOf( typeof( BaseArmor ) ) || itemType.IsSubclassOf( typeof( BaseShoes ) ) )
								return 1062235;

							return 1044286;
						}
						case BulkMaterialType.Spined: return 1062236;
						case BulkMaterialType.Horned: return 1062237;
						case BulkMaterialType.Barbed: return 1062238;
						case BulkMaterialType.Polar: return "Polar";
						case BulkMaterialType.Synthetic: return "Synthetic";
						case BulkMaterialType.BlazeL: return "Blaze";
						case BulkMaterialType.Daemonic: return "Daemonic";
						case BulkMaterialType.Shadow: return "Shadow";
						case BulkMaterialType.Frost: return "Frost";
						case BulkMaterialType.Ethereal: return "Ethereal";
/////////////////////////////////////
//     All Crafts [Start] Edit 2/2 //
/////////////////////////////////////	
					}

					break;
				}
				case BODType.Carpenter:
				{
					switch ( mat )
					{
						case BulkMaterialType.None: return "Wood";
						case BulkMaterialType.Pine: return "Pine";
						case BulkMaterialType.Ash: return "Ash";
						case BulkMaterialType.Mohogany: return "Mohogany";
						case BulkMaterialType.Yew: return "Yew";
						case BulkMaterialType.Oak: return "Oak";
						case BulkMaterialType.Zircote: return "Zircote";
						case BulkMaterialType.Ebony: return "Ebony";
						case BulkMaterialType.Bamboo: return "Bamboo";
						case BulkMaterialType.PurpleHeart: return "PurpleHeart";
						case BulkMaterialType.Redwood: return "Redwood";
						case BulkMaterialType.Petrified: return "Petrified";
					}

					break;
				}
				case BODType.Fletcher:
				{
					switch ( mat )
					{
						case BulkMaterialType.None: return "Wood";
						case BulkMaterialType.Pine: return "Pine";
						case BulkMaterialType.Ash: return "Ash";
						case BulkMaterialType.Mohogany: return "Mohogany";
						case BulkMaterialType.Yew: return "Yew";
						case BulkMaterialType.Oak: return "Oak";
						case BulkMaterialType.Zircote: return "Zircote";
						case BulkMaterialType.Ebony: return "Ebony";
						case BulkMaterialType.Bamboo: return "Bamboo";
						case BulkMaterialType.PurpleHeart: return "PurpleHeart";
						case BulkMaterialType.Redwood: return "Redwood";
						case BulkMaterialType.Petrified: return "Petrified";
/////////////////////////////////////
//       All Crafts [End] Edit 2/2 //
/////////////////////////////////////			
					}

					break;
				}
			}

			return "Invalid";
		}

		public BOBGump( PlayerMobile from, BulkOrderBook book ) : this( from, book, 0, null )
		{
		}

		public override void OnResponse( Server.Network.NetState sender, RelayInfo info )
		{
			int index = info.ButtonID;

			switch ( index )
			{
				case 0: // EXIT
				{
					break;
				}
				case 1: // Set Filter
				{
					m_From.SendGump( new BOBFilterGump( m_From, m_Book ) );

					break;
				}
				case 2: // Previous page
				{
					if ( m_Page > 0 )
						m_From.SendGump( new BOBGump( m_From, m_Book, m_Page - 1, m_List ) );

					return;
				}
				case 3: // Next page
				{
					if ( GetIndexForPage( m_Page + 1 ) < m_List.Count )
						m_From.SendGump( new BOBGump( m_From, m_Book, m_Page + 1, m_List ) );

					break;
				}
				default:
				{
					bool canDrop = m_Book.IsChildOf( m_From.Backpack );
					bool canPrice = canDrop || (m_Book.RootParent is PlayerVendor);

					index -= 4;

					int type = index % 2;
					index /= 2;

					if ( index < 0 || index >= m_List.Count )
						break;

					object obj = m_List[index];

					if ( !m_Book.Entries.Contains( obj ) )
					{
						m_From.SendLocalizedMessage( 1062382 ); // The deed selected is not available.
						break;
					}

					if ( type == 0 ) // Drop
					{
						if ( m_Book.IsChildOf( m_From.Backpack ) )
						{
							Item item = Reconstruct( obj );

							if ( item != null )
							{
								m_From.AddToBackpack( item );
								m_From.SendLocalizedMessage( 1045152 ); // The bulk order deed has been placed in your backpack.

								m_Book.Entries.Remove( obj );
								m_Book.InvalidateProperties();

								if ( m_Book.Entries.Count > 0 )
									m_From.SendGump( new BOBGump( m_From, m_Book, 0, null ) );
								else
									m_From.SendLocalizedMessage( 1062381 ); // The book is empty.
							}
							else
							{
								m_From.SendMessage( "Internal error. The bulk order deed could not be reconstructed." );
							}
						}
					}
					else // Set Price | Buy
					{
						if ( m_Book.IsChildOf( m_From.Backpack ) )
						{
							m_From.Prompt = new SetPricePrompt( m_Book, obj, m_Page, m_List );
							m_From.SendLocalizedMessage( 1062383 ); // Type in a price for the deed:
						}
						else if ( m_Book.RootParent is PlayerVendor )
						{
							PlayerVendor pv = (PlayerVendor)m_Book.RootParent;

							VendorItem vi = pv.GetVendorItem( m_Book );

							int price = 0;

							if ( vi != null && !vi.IsForSale )
							{
								if ( obj is BOBLargeEntry )
									price = ((BOBLargeEntry)obj).Price;
								else if ( obj is BOBSmallEntry )
									price = ((BOBSmallEntry)obj).Price;
							}

							if ( price == 0 )
								m_From.SendLocalizedMessage( 1062382 ); // The deed selected is not available.
							else
								m_From.SendGump( new BODBuyGump( m_From, m_Book, obj, price ) );
						}
					}

					break;
				}
			}
		}

		private class SetPricePrompt : Prompt
		{
			private BulkOrderBook m_Book;
			private object m_Object;
			private int m_Page;
			private ArrayList m_List;

			public SetPricePrompt( BulkOrderBook book, object obj, int page, ArrayList list )
			{
				m_Book = book;
				m_Object = obj;
				m_Page = page;
				m_List = list;
			}

			public override void OnResponse( Mobile from, string text )
			{
				if ( !m_Book.Entries.Contains( m_Object ) )
				{
					from.SendLocalizedMessage( 1062382 ); // The deed selected is not available.
					return;
				}

				int price = Utility.ToInt32( text );

				if ( price < 0 || price > 250000000 )
				{
					from.SendLocalizedMessage( 1062390 ); // The price you requested is outrageous!
				}
				else if ( m_Object is BOBLargeEntry )
				{
					((BOBLargeEntry)m_Object).Price = price;

					from.SendLocalizedMessage( 1062384 ); // Deed price set.

					if ( from is PlayerMobile )
						from.SendGump( new BOBGump( (PlayerMobile)from, m_Book, m_Page, m_List ) );
				}
				else if ( m_Object is BOBSmallEntry )
				{
					((BOBSmallEntry)m_Object).Price = price;

					from.SendLocalizedMessage( 1062384 ); // Deed price set.

					if ( from is PlayerMobile )
						from.SendGump( new BOBGump( (PlayerMobile)from, m_Book, m_Page, m_List ) );
				}
			}
		}

		public BOBGump( PlayerMobile from, BulkOrderBook book, int page, ArrayList list ) : base( 12, 24 )
		{
			from.CloseGump( typeof( BOBGump ) );
			from.CloseGump( typeof( BOBFilterGump ) );

			m_From = from;
			m_Book = book;
			m_Page = page;

			if ( list == null )
			{
				list = new ArrayList( book.Entries.Count );

				for ( int i = 0; i < book.Entries.Count; ++i )
				{
					object obj = book.Entries[i];

					if ( CheckFilter( obj ) )
						list.Add( obj );
				}
			}

			m_List = list;

			int index = GetIndexForPage( page );
			int count = GetCountForIndex( index );

			int tableIndex = 0;

			PlayerVendor pv = book.RootParent as PlayerVendor;

			bool canDrop = book.IsChildOf( from.Backpack );
			bool canBuy = ( pv != null );
			bool canPrice = ( canDrop || canBuy );

			if ( canBuy )
			{
				VendorItem vi = pv.GetVendorItem( book );

				canBuy = ( vi != null && !vi.IsForSale );
			}

			int width = 600;

			if ( !canPrice )
				width = 516;

			X = (624 - width) / 2;

			AddPage( 0 );

			AddBackground( 10, 10, width, 439, 5054 );
			AddImageTiled( 18, 20, width - 17, 420, 2624 );

			if ( canPrice )
			{
				AddImageTiled( 573, 64, 24, 352, 200 );
				AddImageTiled( 493, 64, 78, 352, 1416 );
			}

			if ( canDrop )
				AddImageTiled( 24, 64, 32, 352, 1416 );

			AddImageTiled( 58, 64, 36, 352, 200 );
			AddImageTiled( 96, 64, 133, 352, 1416 );
			AddImageTiled( 231, 64, 80, 352, 200 );
			AddImageTiled( 313, 64, 100, 352, 1416 );
			AddImageTiled( 415, 64, 76, 352, 200 );

			for ( int i = index; i < (index + count) && i >= 0 && i < list.Count; ++i )
			{
				object obj = list[i];

				if ( !CheckFilter( obj ) )
					continue;

				AddImageTiled( 24, 94 + (tableIndex * 32), canPrice ? 573 : 489, 2, 2624 );

				if ( obj is BOBLargeEntry )
					tableIndex += ((BOBLargeEntry)obj).Entries.Length;
				else if ( obj is BOBSmallEntry )
					++tableIndex;
			}

			AddAlphaRegion( 18, 20, width - 17, 420 );
			AddImage( 5, 5, 10460 );
			AddImage( width - 15, 5, 10460 );
			AddImage( 5, 424, 10460 );
			AddImage( width - 15, 424, 10460 );

			AddHtmlLocalized( canPrice ? 266 : 224, 32, 200, 32, 1062220, LabelColor, false, false ); // Bulk Order Book
			AddHtmlLocalized( 63, 64, 200, 32, 1062213, LabelColor, false, false ); // Type
			AddHtmlLocalized( 147, 64, 200, 32, 1062214, LabelColor, false, false ); // Item
			AddHtmlLocalized( 246, 64, 200, 32, 1062215, LabelColor, false, false ); // Quality
			AddHtmlLocalized( 336, 64, 200, 32, 1062216, LabelColor, false, false ); // Material
			AddHtmlLocalized( 429, 64, 200, 32, 1062217, LabelColor, false, false ); // Amount

			AddButton( 35, 32, 4005, 4007, 1, GumpButtonType.Reply, 0 );
			AddHtmlLocalized( 70, 32, 200, 32, 1062476, LabelColor, false, false ); // Set Filter

			BOBFilter f = ( from.UseOwnFilter ? from.BOBFilter : book.Filter );

			if ( f.IsDefault )
				AddHtmlLocalized( canPrice ? 470 : 386, 32, 120, 32, 1062475, 16927, false, false ); // Using No Filter
			else if ( from.UseOwnFilter )
				AddHtmlLocalized( canPrice ? 470 : 386, 32, 120, 32, 1062451, 16927, false, false ); // Using Your Filter
			else
				AddHtmlLocalized( canPrice ? 470 : 386, 32, 120, 32, 1062230, 16927, false, false ); // Using Book Filter

			AddButton( 375, 416, 4017, 4018, 0, GumpButtonType.Reply, 0 );
			AddHtmlLocalized( 410, 416, 120, 20, 1011441, LabelColor, false, false ); // EXIT

			if ( canDrop )
				AddHtmlLocalized( 26, 64, 50, 32, 1062212, LabelColor, false, false ); // Drop

			if ( canPrice )
			{
				AddHtmlLocalized( 516, 64, 200, 32, 1062218, LabelColor, false, false ); // Price

				if ( canBuy )
					AddHtmlLocalized( 576, 64, 200, 32, 1062219, LabelColor, false, false ); // Buy
				else
					AddHtmlLocalized( 576, 64, 200, 32, 1062227, LabelColor, false, false ); // Set
			}

			tableIndex = 0;

			if ( page > 0 )
			{
				AddButton( 75, 416, 4014, 4016, 2, GumpButtonType.Reply, 0 );
				AddHtmlLocalized( 110, 416, 150, 20, 1011067, LabelColor, false, false ); // Previous page
			}

			if ( GetIndexForPage( page + 1 ) < list.Count )
			{
				AddButton( 225, 416, 4005, 4007, 3, GumpButtonType.Reply, 0 );
				AddHtmlLocalized( 260, 416, 150, 20, 1011066, LabelColor, false, false ); // Next page
			}

			for ( int i = index; i < (index + count) && i >= 0 && i < list.Count; ++i )
			{
				object obj = list[i];

				if ( !CheckFilter( obj ) )
					continue;

				if ( obj is BOBLargeEntry )
				{
					BOBLargeEntry e = (BOBLargeEntry)obj;

					int y = 96 + (tableIndex * 32);

					if ( canDrop )
						AddButton( 35, y + 2, 5602, 5606, 4 + (i * 2), GumpButtonType.Reply, 0 );

					if ( canDrop || (canBuy && e.Price > 0) )
					{
						AddButton( 579, y + 2, 2117, 2118, 5 + (i * 2), GumpButtonType.Reply, 0 );
						AddLabel( 495, y, 1152, e.Price.ToString() );
					}

					AddHtmlLocalized( 61, y, 50, 32, 1062225, LabelColor, false, false ); // Large

					for ( int j = 0; j < e.Entries.Length; ++j )
					{
						BOBLargeSubEntry sub = e.Entries[j];

						AddHtmlLocalized( 103, y, 130, 32, sub.Number, LabelColor, false, false );

						if ( e.RequireExceptional )
							AddHtmlLocalized( 235, y, 80, 20, 1060636, LabelColor, false, false ); // exceptional
						else
							AddHtmlLocalized( 235, y, 80, 20, 1011542, LabelColor, false, false ); // normal

						object name = GetMaterialName( e.Material, e.DeedType, sub.ItemType );

						if ( name is int )
							AddHtmlLocalized( 316, y, 100, 20, (int)name, LabelColor, false, false );
						else if ( name is string )
							AddLabel( 316, y, 1152, (string)name );

						AddLabel( 421, y, 1152, String.Format( "{0} / {1}", sub.AmountCur, e.AmountMax ) );

						++tableIndex;
						y += 32;
					}
				}
				else if ( obj is BOBSmallEntry )
				{
					BOBSmallEntry e = (BOBSmallEntry)obj;

					int y = 96 + (tableIndex++ * 32);

					if ( canDrop )
						AddButton( 35, y + 2, 5602, 5606, 4 + (i * 2), GumpButtonType.Reply, 0 );

					if ( canDrop || (canBuy && e.Price > 0) )
					{
						AddButton( 579, y + 2, 2117, 2118, 5 + (i * 2), GumpButtonType.Reply, 0 );
						AddLabel( 495, y, 1152, e.Price.ToString() );
					}

					AddHtmlLocalized( 61, y, 50, 32, 1062224, LabelColor, false, false ); // Small

					AddHtmlLocalized( 103, y, 130, 32, e.Number, LabelColor, false, false );

					if ( e.RequireExceptional )
						AddHtmlLocalized( 235, y, 80, 20, 1060636, LabelColor, false, false ); // exceptional
					else
						AddHtmlLocalized( 235, y, 80, 20, 1011542, LabelColor, false, false ); // normal

					object name = GetMaterialName( e.Material, e.DeedType, e.ItemType );

					if ( name is int )
						AddHtmlLocalized( 316, y, 100, 20, (int)name, LabelColor, false, false );
					else if ( name is string )
						AddLabel( 316, y, 1152, (string)name );

					AddLabel( 421, y, 1152, String.Format( "{0} / {1}", e.AmountCur, e.AmountMax ) );
				}
			}
		}
	}
}
 
Top