generic conversions
This commit is contained in:
parent
fa1df8eae5
commit
0eeb0c0c31
6 changed files with 29 additions and 25 deletions
|
|
@ -1,5 +1,5 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Server;
|
||||
using Server.Mobiles;
|
||||
using Server.Factions;
|
||||
|
|
@ -48,7 +48,9 @@ namespace Server
|
|||
if ( m_Table == null )
|
||||
LoadTable();
|
||||
|
||||
SpeedInfo sp = (SpeedInfo)m_Table[obj.GetType()];
|
||||
SpeedInfo sp = null;
|
||||
|
||||
m_Table.TryGetValue(obj.GetType(), out sp);
|
||||
|
||||
return ( sp != null );
|
||||
}
|
||||
|
|
@ -61,7 +63,9 @@ namespace Server
|
|||
if ( m_Table == null )
|
||||
LoadTable();
|
||||
|
||||
SpeedInfo sp = (SpeedInfo)m_Table[obj.GetType()];
|
||||
SpeedInfo sp = null;
|
||||
|
||||
m_Table.TryGetValue(obj.GetType(), out sp);
|
||||
|
||||
if ( sp == null )
|
||||
return false;
|
||||
|
|
@ -74,7 +78,7 @@ namespace Server
|
|||
|
||||
private static void LoadTable()
|
||||
{
|
||||
m_Table = new Hashtable();
|
||||
m_Table = new Dictionary<Type, SpeedInfo>();
|
||||
|
||||
for ( int i = 0; i < m_Speeds.Length; ++i )
|
||||
{
|
||||
|
|
@ -86,7 +90,7 @@ namespace Server
|
|||
}
|
||||
}
|
||||
|
||||
private static Hashtable m_Table;
|
||||
private static Dictionary<Type, SpeedInfo> m_Table;
|
||||
|
||||
private static SpeedInfo[] m_Speeds = new SpeedInfo[]
|
||||
{
|
||||
|
|
|
|||
|
|
@ -710,7 +710,7 @@ namespace Server.Mobiles
|
|||
{
|
||||
IShopSellInfo[] info = GetSellInfo();
|
||||
|
||||
Hashtable table = new Hashtable();
|
||||
Dictionary<Item, SellItemState> table = new Dictionary<Item, SellItemState>();
|
||||
|
||||
foreach ( IShopSellInfo ssi in info )
|
||||
{
|
||||
|
|
@ -730,7 +730,7 @@ namespace Server.Mobiles
|
|||
{
|
||||
SendPacksTo( from );
|
||||
|
||||
from.Send( new VendorSellList( this, table ) );
|
||||
from.Send( new VendorSellList( this, table.Values ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using Server;
|
||||
|
|
@ -276,7 +275,7 @@ namespace Server.Mobiles
|
|||
|
||||
public class PlayerVendor : Mobile
|
||||
{
|
||||
private Hashtable m_SellItems;
|
||||
private Dictionary<Item, VendorItem> m_SellItems;
|
||||
|
||||
private Mobile m_Owner;
|
||||
private BaseHouse m_House;
|
||||
|
|
@ -309,7 +308,7 @@ namespace Server.Mobiles
|
|||
|
||||
ShopName = "Shop Not Yet Named";
|
||||
|
||||
m_SellItems = new Hashtable();
|
||||
m_SellItems = new Dictionary<Item, VendorItem>();
|
||||
|
||||
CantWalk = true;
|
||||
|
||||
|
|
@ -384,9 +383,10 @@ namespace Server.Mobiles
|
|||
m_BankAccount = reader.ReadInt();
|
||||
m_HoldGold = reader.ReadInt();
|
||||
|
||||
m_SellItems = new Hashtable();
|
||||
|
||||
int count = reader.ReadInt();
|
||||
|
||||
m_SellItems = new Dictionary<Item, VendorItem>(count);
|
||||
|
||||
for ( int i = 0; i < count; i++ )
|
||||
{
|
||||
Item item = reader.ReadItem();
|
||||
|
|
@ -779,7 +779,9 @@ namespace Server.Mobiles
|
|||
|
||||
public VendorItem GetVendorItem( Item item )
|
||||
{
|
||||
return (VendorItem) m_SellItems[item];
|
||||
VendorItem v = null;
|
||||
m_SellItems.TryGetValue(item, out v);
|
||||
return v;
|
||||
}
|
||||
|
||||
private VendorItem SetVendorItem( Item item, int price, string description )
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue