a few generics and misc code cleanup

slight tweaks/opt
This commit is contained in:
mark 2007-01-19 19:33:13 +00:00
parent 83190372f8
commit 566de1c2cf
20 changed files with 125 additions and 164 deletions

View file

@ -1,9 +1,9 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Server;
using Server.Network;
using Server.Engines.Craft;
using Server.Factions;
using Server.Network;
namespace Server.Items
{
@ -637,7 +637,7 @@ namespace Server.Items
public override void OnSingleClick( Mobile from )
{
ArrayList attrs = new ArrayList();
List<EquipInfoAttribute> attrs = new List<EquipInfoAttribute>();
if ( DisplayLootType )
{
@ -670,7 +670,7 @@ namespace Server.Items
if ( attrs.Count == 0 && Crafter == null && Name != null )
return;
EquipmentInfo eqInfo = new EquipmentInfo( number, m_Crafter, false, (EquipInfoAttribute[])attrs.ToArray( typeof( EquipInfoAttribute ) ) );
EquipmentInfo eqInfo = new EquipmentInfo( number, m_Crafter, false, attrs.ToArray() );
from.Send( new DisplayEquipmentInfo( this, eqInfo ) );
}

View file

@ -1,5 +1,4 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Server.Commands;
using Server.Network;
@ -90,7 +89,7 @@ namespace Server.Items
[Description( "Chain-links two or more targeted doors together." )]
private static void ChainLink_OnCommand( CommandEventArgs e )
{
e.Mobile.BeginTarget( -1, false, TargetFlags.None, new TargetStateCallback( ChainLink_OnTarget ), new ArrayList() );
e.Mobile.BeginTarget( -1, false, TargetFlags.None, new TargetStateCallback( ChainLink_OnTarget ), new List<BaseDoor>() );
e.Mobile.SendMessage( "Target the first of a sequence of doors to link." );
}
@ -105,14 +104,14 @@ namespace Server.Items
}
else
{
ArrayList list = (ArrayList)state;
List<BaseDoor> list = (List<BaseDoor>)state;
if ( list.Count > 0 && list[0] == door )
{
if ( list.Count >= 2 )
{
for ( int i = 0; i < list.Count; ++i )
((BaseDoor)list[i]).Link = ((BaseDoor)list[(i + 1) % list.Count]);
list[i].Link = list[(i + 1) % list.Count];
from.SendMessage( "The chain of doors have been linked." );
}
@ -403,9 +402,9 @@ namespace Server.Items
public virtual bool UseChainedFunctionality{ get{ return false; } }
public ArrayList GetChain()
public List<BaseDoor> GetChain()
{
ArrayList list = new ArrayList();
List<BaseDoor> list = new List<BaseDoor>();
BaseDoor c = this;
do
@ -422,12 +421,12 @@ namespace Server.Items
if ( !UseChainedFunctionality )
return CanClose();
ArrayList list = GetChain();
List<BaseDoor> list = GetChain();
bool freeToClose = true;
for ( int i = 0; freeToClose && i < list.Count; ++i )
freeToClose = ((BaseDoor)list[i]).CanClose();
freeToClose = list[i].CanClose();
return freeToClose;
}
@ -490,10 +489,10 @@ namespace Server.Items
{
bool open = !m_Open;
ArrayList list = GetChain();
List<BaseDoor> list = GetChain();
for ( int i = 0; i < list.Count; ++i )
((BaseDoor)list[i]).Open = open;
list[i].Open = open;
}
else
{

View file

@ -1,5 +1,5 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Server;
using Server.Multis;
using Server.Network;
@ -152,7 +152,7 @@ namespace Server.Items
public Container ConvertToStandardContainer()
{
Container metalBox = new MetalBox();
ArrayList subItems = new ArrayList( Items );
List<Item> subItems = new List<Item>( Items );
foreach ( Item subItem in subItems )
{

View file

@ -1,12 +1,11 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Server;
using Server.ContextMenus;
using Server.Engines.PartySystem;
using Server.Gumps;
using Server.Multis;
using Server.Network;
using Server.ContextMenus;
using Server.Engines.PartySystem;
namespace Server.Items
{
@ -274,7 +273,7 @@ namespace Server.Items
}
}
private ArrayList m_Lifted = new ArrayList();
private List<Item> m_Lifted = new List<Item>();
private bool CheckLoot( Mobile m, bool criminalAction )
{
@ -365,7 +364,7 @@ namespace Server.Items
writer.Write( (int) m_Level );
writer.WriteDeltaTime( m_DeleteTime );
writer.WriteItemList( m_Lifted, true );
writer.Write( m_Lifted, true );
}
public override void Deserialize( GenericReader reader )
@ -393,7 +392,7 @@ namespace Server.Items
{
m_Level = reader.ReadInt();
m_DeleteTime = reader.ReadDeltaTime();
m_Lifted = reader.ReadItemList();
m_Lifted = reader.ReadStrongItemList();
if ( version < 2 )
m_Guardians = new List<Mobile>();

View file

@ -387,16 +387,16 @@ namespace Server.Items
writer.WriteDeltaTime( m_TimeOfDeath );
ArrayList list = ( m_RestoreTable == null ? null : new ArrayList( m_RestoreTable ) );
List<KeyValuePair<Item, Point3D>> list = ( m_RestoreTable == null ? null : new List<KeyValuePair<Item, Point3D>>( m_RestoreTable ) );
int count = ( list == null ? 0 : list.Count );
writer.Write( count );
for ( int i = 0; list != null && i < list.Count; ++i )
for ( int i = 0; i < list.Count; ++i )
{
DictionaryEntry de = (DictionaryEntry)list[i];
Item item = (Item)de.Key;
Point3D loc = (Point3D)de.Value;
KeyValuePair<Item, Point3D> kvp = list[i];
Item item = kvp.Key;
Point3D loc = kvp.Value;
writer.Write( item );
@ -644,20 +644,14 @@ namespace Server.Items
list.Add( new OpenCorpseEntry() );
}
private Hashtable m_RestoreTable;
private Dictionary<Item, Point3D> m_RestoreTable;
public bool GetRestoreInfo( Item item, ref Point3D loc )
{
if ( m_RestoreTable == null || item == null )
return false;
object obj = m_RestoreTable[item];
if ( obj == null )
return false;
loc = (Point3D)obj;
return true;
return m_RestoreTable.TryGetValue( item, out loc );
}
public void SetRestoreInfo( Item item, Point3D loc )
@ -666,7 +660,7 @@ namespace Server.Items
return;
if ( m_RestoreTable == null )
m_RestoreTable = new Hashtable();
m_RestoreTable = new Dictionary<Item, Point3D>();
m_RestoreTable[item] = loc;
}