Here are the fixed scripts.
I tested many diffrent ButtonID's in RaZor Macros on every gump in the system, I replicated the crash on three diffrent gumps.
In two scripts I placed ButtonID's for the RaZor macro's that can cause a crash.
And in searchgump a change to the if ( info.TextEntries.
I spent about thirty minutes trying to crash the system after this with no luck so I'm quite sure that these were the only three gumps that could cause a crash.
Just replace the scripts with the following ones:
AuctionSearchGump.cs
BidViewGump.cs
AuctionListing.cs
Enjoy using the great Auction by Ayra again
I tested many diffrent ButtonID's in RaZor Macros on every gump in the system, I replicated the crash on three diffrent gumps.
In two scripts I placed ButtonID's for the RaZor macro's that can cause a crash.
And in searchgump a change to the if ( info.TextEntries.
I spent about thirty minutes trying to crash the system after this with no luck so I'm quite sure that these were the only three gumps that could cause a crash.
Just replace the scripts with the following ones:
AuctionSearchGump.cs
Code:
using System;
using System.Collections;
using Server;
using Server.Gumps;
using Server.Items;
namespace Arya.Auction
{
/// <summary>
/// Summary description for AuctionSearchGump.
/// </summary>
public class AuctionSearchGump : Gump
{
private const int LabelHue = 0x480;
private const int GreenHue = 0x40;
private const int RedHue = 0x20;
private ArrayList m_List;
private bool m_ReturnToAuction;
public AuctionSearchGump( Mobile m, ArrayList items, bool returnToAuction ) : base( 50, 50 )
{
m.CloseGump( typeof( AuctionSearchGump ) );
m_List = items;
m_ReturnToAuction = returnToAuction;
MakeGump();
}
private void MakeGump()
{
this.Closable=true;
this.Disposable=true;
this.Dragable=true;
this.Resizable=false;
this.AddPage(0);
this.AddImageTiled(49, 34, 402, 347, 3004);
this.AddImageTiled(50, 35, 400, 345, 2624);
this.AddAlphaRegion(50, 35, 400, 345);
this.AddImage(165, 65, 10452);
this.AddImage(0, 20, 10400);
this.AddImage(0, 320, 10402);
this.AddImage(35, 20, 10420);
this.AddImage(421, 20, 10410);
this.AddImage(410, 20, 10430);
this.AddImageTiled(90, 32, 323, 16, 10254);
this.AddLabel(185, 45, GreenHue, AuctionSystem.ST[ 32 ] );
this.AddImage(420, 320, 10412);
this.AddImage(0, 170, 10401);
this.AddImage(420, 170, 10411);
// TEXT 0 : Search text
this.AddLabel(70, 115, LabelHue, AuctionSystem.ST[ 33 ] );
this.AddImageTiled(145, 135, 200, 20, 3004);
this.AddImageTiled(146, 136, 198, 18, 2624);
this.AddAlphaRegion(146, 136, 198, 18);
this.AddTextEntry(146, 135, 198, 20, RedHue, 0, @"");
this.AddLabel(70, 160, LabelHue, AuctionSystem.ST[ 35 ] );
this.AddCheck(260, 221, 2510, 2511, false, 1);
this.AddLabel(280, 220, LabelHue, AuctionSystem.ST[ 35 ] );
if ( Core.AOS )
{
this.AddCheck(260, 261, 2510, 2511, false, 9);
this.AddLabel(280, 260, LabelHue, AuctionSystem.ST[ 36 ] );
this.AddCheck(260, 241, 2510, 2511, false, 4);
this.AddLabel(280, 240, LabelHue, AuctionSystem.ST[ 37 ] );
}
this.AddCheck(260, 201, 2510, 2511, false, 4);
this.AddLabel(280, 200, LabelHue, AuctionSystem.ST[ 38 ] );
this.AddCheck(260, 181, 2510, 2511, false, 5);
this.AddLabel(280, 180, LabelHue, AuctionSystem.ST[ 39 ] );
this.AddCheck(90, 181, 2510, 2511, false, 6);
this.AddLabel(110, 180, LabelHue, AuctionSystem.ST[ 40 ] );
this.AddCheck(90, 201, 2510, 2511, false, 7);
this.AddLabel(110, 200, LabelHue, AuctionSystem.ST[ 41 ] );
this.AddCheck(90, 221, 2510, 2511, false, 8);
this.AddLabel(110, 220, LabelHue, AuctionSystem.ST[ 42 ] );
this.AddCheck(90, 241, 2510, 2511, false, 2);
this.AddLabel(110, 240, LabelHue, AuctionSystem.ST[ 43 ] );
this.AddCheck(90, 261, 2510, 2511, false, 12);
this.AddLabel(110, 260, LabelHue, AuctionSystem.ST[ 44 ] );
if ( Core.AOS )
{
this.AddCheck(90, 280, 2510, 2511, false, 11);
this.AddLabel(110, 279, LabelHue, AuctionSystem.ST[ 45 ] );
this.AddCheck(260, 280, 2510, 2511, false, 10);
this.AddLabel(280, 279, LabelHue, AuctionSystem.ST[ 46 ] );
}
// BUTTON 1 : Search
this.AddButton(255, 350, 4005, 4006, 1, GumpButtonType.Reply, 0);
this.AddLabel(295, 350, LabelHue, AuctionSystem.ST[ 16 ] );
// BUTTON 0 : Cancel
this.AddButton(85, 350, 4017, 4018, 0, GumpButtonType.Reply, 0);
this.AddLabel(125, 350, LabelHue, AuctionSystem.ST[ 47 ] );
// CHECK 0: Search withing existing results
this.AddCheck(80, 310, 9721, 9724, false, 0);
this.AddLabel(115, 312, LabelHue, AuctionSystem.ST[ 48 ] );
}
public override void OnResponse(Server.Network.NetState sender, RelayInfo info)
{
if ( ! AuctionSystem.Running )
{
sender.Mobile.SendMessage( AuctionSystem.MessageHue, AuctionSystem.ST[ 15 ] );
return;
}
if ( info.ButtonID == 0 )
{
// Cancel
sender.Mobile.SendGump( new AuctionListing( sender.Mobile, m_List, true, m_ReturnToAuction ) );
return;
}
bool searchExisting = false;
bool artifacts = false;
bool commodity = false;
ArrayList types = new ArrayList();
string text = null;
//Crash fix -LDL
if ( info.TextEntries != null && info.TextEntries.Length > 0 && info.TextEntries[ 0 ].Text != null && info.TextEntries[ 0 ].Text.Length > 0 )
{
text = info.TextEntries[ 0 ].Text;
}
//Crash fix -LDL
foreach( int check in info.Switches )
{
switch ( check )
{
case 0 : searchExisting = true;
break;
case 1: types.Add( typeof( MapItem ) );
break;
case 2: types.Add( typeof( BaseReagent ) );
break;
case 3: commodity = true;
break;
case 4:
types.Add( typeof( StatCapScroll ) );
types.Add( typeof( PowerScroll ) );
break;
case 5: types.Add( typeof( BaseJewel ) );
break;
case 6: types.Add( typeof( BaseWeapon ) );
break;
case 7: types.Add( typeof( BaseArmor ) );
break;
case 8: types.Add( typeof( BaseShield ) );
break;
case 9: artifacts = true;
break;
case 10: types.Add( typeof( Server.Engines.BulkOrders.SmallBOD ) );
break;
case 11: types.Add( typeof( Server.Engines.BulkOrders.LargeBOD ) );
break;
case 12:
types.Add( typeof( BasePotion ) );
types.Add( typeof( PotionKeg ) );
break;
}
}
ArrayList source = null;
if ( searchExisting )
{
source = new ArrayList( m_List );
}
else
{
source = new ArrayList( AuctionSystem.Auctions );
}
ArrayList typeSearch = null;
ArrayList commoditySearch = null;
ArrayList artifactsSearch = null;
if ( types.Count > 0 )
{
typeSearch = AuctionSearch.ForTypes( source, types );
}
if ( commodity )
{
commoditySearch = AuctionSearch.ForCommodities( source );
}
if ( artifacts )
{
artifactsSearch = AuctionSearch.ForArtifacts( source );
}
ArrayList results = new ArrayList();
if ( typeSearch == null && artifactsSearch == null && commoditySearch == null )
{
results.AddRange( source );
}
else
{
if ( typeSearch != null )
results.AddRange( typeSearch );
if ( commoditySearch != null )
results = AuctionSearch.Merge( results, commoditySearch );
if ( artifactsSearch != null )
results = AuctionSearch.Merge( results, artifactsSearch );
}
// Perform search
if ( text != null )
{
results = AuctionSearch.SearchForText( results, text );
}
sender.Mobile.SendGump( new AuctionListing(
sender.Mobile,
results,
true,
m_ReturnToAuction ) );
}
}
}
BidViewGump.cs
Code:
using System;
using System.Collections;
using Server;
using Server.Gumps;
namespace Arya.Auction
{
/// <summary>
/// Summary description for BidViewGump.
/// </summary>
public class BidViewGump : Gump
{
private const int LabelHue = 0x480;
private const int GreenHue = 0x40;
private const int RedHue = 0x20;
private AuctionGumpCallback m_Callback;
private int m_Page;
private ArrayList m_Bids;
public BidViewGump( Mobile m, ArrayList bids, AuctionGumpCallback callback ) : this ( m, bids, callback, 0 )
{
}
public BidViewGump( Mobile m, ArrayList bids, AuctionGumpCallback callback, int page ) : base( 100, 100 )
{
m.CloseGump( typeof( BidViewGump ) );
m_Callback = callback;
m_Page = page;
m_Bids = new ArrayList( bids );
MakeGump();
}
private void MakeGump()
{
int numOfPages = ( m_Bids.Count - 1 ) / 10 + 1;
if ( m_Bids.Count == 0 )
numOfPages = 0;
this.Closable=true;
this.Disposable=true;
this.Dragable=true;
this.Resizable=false;
this.AddPage(0);
this.AddImageTiled(0, 0, 297, 282, 5174);
this.AddImageTiled(1, 1, 295, 280, 2702);
this.AddAlphaRegion(1, 1, 295, 280);
this.AddLabel(12, 5, RedHue, AuctionSystem.ST[ 86 ] );
this.AddLabel(160, 5, GreenHue, string.Format( AuctionSystem.ST[ 18 ] , m_Page + 1, numOfPages ) );
this.AddImageTiled(10, 30, 277, 221, 5174);
this.AddImageTiled(11, 31, 39, 19, 9274);
this.AddAlphaRegion(11, 31, 39, 19);
this.AddImageTiled(51, 31, 104, 19, 9274);
this.AddAlphaRegion(51, 31, 104, 19);
this.AddLabel(55, 30, GreenHue, AuctionSystem.ST[ 87 ] );
this.AddImageTiled(156, 31, 129, 19, 9274);
this.AddAlphaRegion(156, 31, 129, 19);
this.AddLabel(160, 30, GreenHue, AuctionSystem.ST[ 88 ] );
for ( int i = 0; i < 10; i++ )
{
this.AddImageTiled(11, 51 + i * 20, 39, 19, 9264);
this.AddAlphaRegion(11, 51 + i * 20, 39, 19);
this.AddImageTiled(51, 51 + i * 20, 104, 19, 9264);
this.AddAlphaRegion(51, 51 + i * 20, 104, 19);
this.AddImageTiled(156, 51 + i * 20, 129, 19, 9264);
this.AddAlphaRegion(156, 51 + i * 20, 129, 19);
if ( m_Page * 10 + i < m_Bids.Count )
{
Bid bid = m_Bids[ m_Page * 10 + i ] as Bid;
this.AddLabel(15, 50 + i * 20, LabelHue, ( m_Page * 10 + i + 1 ).ToString() );
this.AddLabelCropped( 55, 50 + i * 20, 100, 19, LabelHue, bid.Mobile != null ? bid.Mobile.Name : AuctionSystem.ST[ 78 ] );
this.AddLabel(160, 50 + i * 20, LabelHue, bid.Amount.ToString() );
}
}
this.AddButton(10, 255, 4011, 4012, 0, GumpButtonType.Reply, 0);
this.AddLabel(48, 257, LabelHue, AuctionSystem.ST[ 89 ] );
// PREV PAGE: 1
if ( m_Page > 0 )
this.AddButton(250, 8, 9706, 9707, 1, GumpButtonType.Reply, 0);
// NEXT PAGE: 2
if ( m_Page < numOfPages - 1 )
this.AddButton(270, 8, 9702, 9703, 2, GumpButtonType.Reply, 0);
}
public override void OnResponse(Server.Network.NetState sender, RelayInfo info)
{
if ( ! AuctionSystem.Running )
{
sender.Mobile.SendMessage( AuctionSystem.MessageHue, AuctionSystem.ST[ 15 ] );
return;
}
//Crash fix -LDL
if ( info.ButtonID == 1 )
{
// Someone is calling a button that is illegal - Must be a exploiter ?
return;
}
//Crash fix -LDL
switch ( info.ButtonID )
{
case 0:
if ( m_Callback != null )
{
try { m_Callback.DynamicInvoke( new object[] { sender.Mobile } ); }
catch {}
}
break;
case 1:
sender.Mobile.SendGump( new BidViewGump( sender.Mobile, m_Bids, m_Callback, m_Page - 1 ) );
break;
case 2:
sender.Mobile.SendGump( new BidViewGump( sender.Mobile, m_Bids, m_Callback, m_Page + 1 ) );
break;
}
}
}
}
AuctionListing.cs
Code:
using System;
using System.Collections;
using Server;
using Server.Gumps;
namespace Arya.Auction
{
/// <summary>
/// Lists auction items
/// </summary>
public class AuctionListing : Gump
{
private const int LabelHue = 0x480;
private const int GreenHue = 0x40;
private const int RedHue = 0x20;
private bool m_EnableSearch;
private int m_Page;
private ArrayList m_List;
private bool m_ReturnToAuction;
public AuctionListing( Mobile m, ArrayList items, bool searchEnabled, bool returnToAuction, int page ) : base( 50, 50 )
{
m.CloseGump( typeof( AuctionListing ) );
m_EnableSearch = searchEnabled;
m_Page = page;
m_List = new ArrayList( items );
m_ReturnToAuction = returnToAuction;
MakeGump();
}
public AuctionListing( Mobile m, ArrayList items, bool searchEnabled, bool returnToAuction ) : this( m, items, searchEnabled, returnToAuction, 0 )
{
}
private void MakeGump()
{
this.Closable=true;
this.Disposable=true;
this.Dragable=true;
this.Resizable=false;
this.AddPage(0);
this.AddImageTiled(49, 39, 402, 352, 3004);
this.AddImageTiled(50, 40, 400, 350, 2624);
this.AddAlphaRegion(50, 40, 400, 350);
this.AddImage(165, 65, 10452);
this.AddImage(0, 20, 10400);
this.AddImage(0, 330, 10402);
this.AddImage(35, 20, 10420);
this.AddImage(421, 20, 10410);
this.AddImage(410, 20, 10430);
this.AddImageTiled(90, 32, 323, 16, 10254);
this.AddLabel(160, 45, GreenHue, AuctionSystem.ST[ 8 ] );
this.AddImage(420, 330, 10412);
this.AddImage(420, 175, 10411);
this.AddImage(0, 175, 10401);
// Search: BUTTON 1
if ( m_EnableSearch )
{
this.AddLabel(305, 120, LabelHue, AuctionSystem.ST[ 16 ] );
this.AddButton(270, 120, 4005, 4006, 1, GumpButtonType.Reply, 0);
}
// Sort: BUTTON 2
this.AddLabel(395, 120, LabelHue, AuctionSystem.ST[ 17 ] );
this.AddButton(360, 120, 4005, 4006, 2, GumpButtonType.Reply, 0);
while ( m_Page * 10 >= m_List.Count )
m_Page--;
if ( m_List.Count > 0 )
{
// Display the page number
this.AddLabel( 360, 95, RedHue, string.Format( AuctionSystem.ST[ 18 ] , m_Page + 1, ( m_List.Count - 1 ) / 10 + 1 ) );
this.AddLabel(70, 120, RedHue, string.Format( AuctionSystem.ST[ 19 ] , m_List.Count ) );
}
else
this.AddLabel( 70, 120, RedHue, AuctionSystem.ST[ 20 ] );
// Display items: BUTTONS 10 + i
int lower = m_Page * 10;
if ( m_List.Count > 0 )
{
for ( int i = 0; i < 10 && ( m_Page * 10 + i ) < m_List.Count; i++ )
{
AuctionItem item = m_List[ m_Page * 10 + i ] as AuctionItem;
this.AddButton(115, 153 + i * 20, 5601, 5605, 10 + i, GumpButtonType.Reply, 0);
this.AddLabelCropped( 140, 150 + i * 20, 260, 20, LabelHue, item.ItemName );
}
}
// Next page: BUTTON 3
if ( ( m_Page + 1 ) * 10 < m_List.Count )
{
this.AddLabel(355, 360, LabelHue, AuctionSystem.ST[ 22 ] );
this.AddButton(315, 360, 4005, 4006, 3, GumpButtonType.Reply, 0);
}
// Previous page: BUTTON 4
if ( m_Page > 0 )
{
this.AddLabel(180, 360, LabelHue, AuctionSystem.ST[ 21 ] );
this.AddButton(280, 360, 4014, 4015, 4, GumpButtonType.Reply, 0);
}
// Close: BUTTON 0
this.AddLabel(115, 360, LabelHue, AuctionSystem.ST[ 7 ] );
this.AddButton(75, 360, 4017, 4018, 0, GumpButtonType.Reply, 0);
}
public override void OnResponse(Server.Network.NetState sender, RelayInfo info)
{
if ( ! AuctionSystem.Running )
{
sender.Mobile.SendMessage( AuctionSystem.MessageHue, AuctionSystem.ST[ 15 ] );
return;
}
//Crash fix -LDL
if ( info.ButtonID == 4 )
{
// Cancel
sender.Mobile.SendGump( new AuctionListing( sender.Mobile, m_List, true, m_ReturnToAuction ) );
return;
}
//Crash fix -LDL
switch( info.ButtonID )
{
case 0: // Exit
if ( m_ReturnToAuction )
sender.Mobile.SendGump( new AuctionGump( sender.Mobile ) );
else
sender.Mobile.SendGump( new MyAuctionGump( sender.Mobile, null ) );
break;
case 1: // Search
sender.Mobile.SendGump( new AuctionSearchGump(
sender.Mobile,
m_List,
m_ReturnToAuction ) );
break;
case 2: // Sort
sender.Mobile.SendGump( new AuctionSortGump(
sender.Mobile,
m_List,
m_ReturnToAuction,
m_EnableSearch ) );
break;
case 3: // Next page
sender.Mobile.SendGump( new AuctionListing( sender.Mobile, m_List, m_EnableSearch, m_ReturnToAuction, m_Page +1 ) );
break;
case 4: // Previous page
sender.Mobile.SendGump( new AuctionListing( sender.Mobile, m_List, m_EnableSearch, m_ReturnToAuction, m_Page - 1 ) );
break;
default:
int index = m_Page * 10 + info.ButtonID - 10;
if ( index < 0 || index >= m_List.Count )
{
// Apparently in some cases this can go out of bounds, investigating.
sender.Mobile.SendMessage( AuctionSystem.MessageHue, AuctionSystem.ST[ 23 ] );
if ( m_ReturnToAuction )
sender.Mobile.SendGump( new AuctionGump( sender.Mobile ) );
else
sender.Mobile.SendGump( new MyAuctionGump( sender.Mobile, null ) );
return;
}
AuctionItem item = m_List[ index ] as AuctionItem;
if ( item != null )
{
if ( ( ! item.Expired || item.Pending ) && ( AuctionSystem.Auctions.Contains( item ) || AuctionSystem.Pending.Contains( item ) ) )
{
sender.Mobile.SendGump( new AuctionViewGump( sender.Mobile, item, new AuctionGumpCallback( ViewCallback ) ) );
}
else
{
sender.Mobile.SendMessage( AuctionSystem.MessageHue, AuctionSystem.ST[ 24 ] );
sender.Mobile.SendGump( new AuctionListing( sender.Mobile, m_List, m_EnableSearch, m_ReturnToAuction, m_Page ) );
}
}
break;
}
}
private void ViewCallback( Mobile user )
{
user.SendGump( new AuctionListing( user, m_List, m_EnableSearch, m_ReturnToAuction, m_Page ) );
}
}
}
Enjoy using the great Auction by Ayra again