Lots of little stuff..

Generics
Misc tweaks/fixes
This commit is contained in:
mark 2006-12-28 19:32:01 +00:00
parent 8da138d6ed
commit 455fa28f48
16 changed files with 99 additions and 219 deletions

View file

@ -1,7 +1,7 @@
using System; using System;
using System.Text; using System.Collections.Generic;
using System.Reflection; using System.Reflection;
using System.Collections; using System.Text;
using Server; using Server;
using Server.Items; using Server.Items;
using Server.Network; using Server.Network;
@ -25,7 +25,7 @@ namespace Server.Commands
Invoke( from, start, end, args, null ); Invoke( from, start, end, args, null );
} }
public static void Invoke( Mobile from, Point3D start, Point3D end, string[] args, ArrayList packs ) public static void Invoke( Mobile from, Point3D start, Point3D end, string[] args, List<Container> packs )
{ {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
@ -108,7 +108,7 @@ namespace Server.Commands
Array.Copy( old, 1, args, 0, args.Length ); Array.Copy( old, 1, args, 0, args.Length );
} }
public static int BuildObjects( Mobile from, Type type, Point3D start, Point3D end, string[] args, string[,] props, ArrayList packs ) public static int BuildObjects( Mobile from, Type type, Point3D start, Point3D end, string[] args, string[,] props, List<Container> packs )
{ {
Utility.FixPoints( ref start, ref end ); Utility.FixPoints( ref start, ref end );
@ -270,7 +270,7 @@ namespace Server.Commands
return built; return built;
} }
public static int Build( Mobile from, Point3D start, Point3D end, ConstructorInfo ctor, object[] values, string[,] props, PropertyInfo[] realProps, ArrayList packs ) public static int Build( Mobile from, Point3D start, Point3D end, ConstructorInfo ctor, object[] values, string[,] props, PropertyInfo[] realProps, List<Container> packs )
{ {
try try
{ {
@ -299,7 +299,7 @@ namespace Server.Commands
if ( built is Item ) if ( built is Item )
{ {
Container pack = (Container)packs[i]; Container pack = packs[i];
pack.DropItem( (Item)built ); pack.DropItem( (Item)built );
} }

View file

@ -1,5 +1,4 @@
using System; using System;
using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Reflection; using System.Reflection;
using Server; using Server;
@ -19,7 +18,7 @@ namespace Server.Commands
public static void Convert_OnCommand( CommandEventArgs e ) public static void Convert_OnCommand( CommandEventArgs e )
{ {
e.Mobile.SendMessage( "Converting all players to PlayerMobile. You will be disconnected. Please Restart the server after the world has finished saving." ); e.Mobile.SendMessage( "Converting all players to PlayerMobile. You will be disconnected. Please Restart the server after the world has finished saving." );
ArrayList mobs = new ArrayList( World.Mobiles.Values ); List<Mobile> mobs = new List<Mobile>( World.Mobiles.Values );
int count = 0; int count = 0;
foreach ( Mobile m in mobs ) foreach ( Mobile m in mobs )

View file

@ -368,7 +368,7 @@ namespace Server.Commands.Generic
if ( e.Arguments.Length == 0 ) if ( e.Arguments.Length == 0 )
return; return;
ArrayList packs = new ArrayList( list.Count ); List<Container> packs = new List<Container>( list.Count );
for ( int i = 0; i < list.Count; ++i ) for ( int i = 0; i < list.Count; ++i )
{ {

View file

@ -1125,10 +1125,6 @@ namespace Server.Commands
return; return;
} }
if ( GoGump.MoveToLocation( from, e.ArgString ) )
return;
if ( e.Length == 1 ) if ( e.Length == 1 )
{ {
try try

View file

@ -1,5 +1,5 @@
using System; using System;
using System.Collections; using System.Collections.Generic;
using Server; using Server;
namespace Server.Engines.Chat namespace Server.Engines.Chat
@ -8,7 +8,7 @@ namespace Server.Engines.Chat
{ {
private string m_Name; private string m_Name;
private string m_Password; private string m_Password;
private ArrayList m_Users, m_Banned, m_Moderators, m_Voices; private List<ChatUser> m_Users, m_Banned, m_Moderators, m_Voices;
private bool m_VoiceRestricted; private bool m_VoiceRestricted;
private bool m_AlwaysAvailable; private bool m_AlwaysAvailable;
@ -16,10 +16,10 @@ namespace Server.Engines.Chat
{ {
m_Name = name; m_Name = name;
m_Users = new ArrayList(); m_Users = new List<ChatUser>();
m_Banned = new ArrayList(); m_Banned = new List<ChatUser>();
m_Moderators = new ArrayList(); m_Moderators = new List<ChatUser>();
m_Voices = new ArrayList(); m_Voices = new List<ChatUser>();
} }
public Channel( string name, string password ) : this( name ) public Channel( string name, string password ) : this( name )
@ -381,7 +381,7 @@ namespace Server.Engines.Chat
{ {
for ( int i = 0; i < m_Users.Count; ++i ) for ( int i = 0; i < m_Users.Count; ++i )
{ {
ChatUser user = (ChatUser)m_Users[i]; ChatUser user = m_Users[i];
if ( user == initiator ) if ( user == initiator )
continue; continue;
@ -397,7 +397,7 @@ namespace Server.Engines.Chat
{ {
for ( int i = 0; i < m_Users.Count; ++i ) for ( int i = 0; i < m_Users.Count; ++i )
{ {
ChatUser user = (ChatUser)m_Users[i]; ChatUser user = m_Users[i];
if ( user.IsIgnored( from ) ) if ( user.IsIgnored( from ) )
continue; continue;
@ -438,7 +438,7 @@ namespace Server.Engines.Chat
{ {
for ( int i = 0; i < m_Users.Count; ++i ) for ( int i = 0; i < m_Users.Count; ++i )
{ {
ChatUser user = (ChatUser)m_Users[i]; ChatUser user = m_Users[i];
if ( user == initiator ) if ( user == initiator )
continue; continue;
@ -454,15 +454,15 @@ namespace Server.Engines.Chat
{ {
for ( int i = 0; i < m_Users.Count; ++i ) for ( int i = 0; i < m_Users.Count; ++i )
{ {
ChatUser user = (ChatUser)m_Users[i]; ChatUser user = m_Users[i];
ChatSystem.SendCommandTo( to.Mobile, ChatCommand.AddUserToChannel, user.GetColorCharacter() + user.Username ); ChatSystem.SendCommandTo( to.Mobile, ChatCommand.AddUserToChannel, user.GetColorCharacter() + user.Username );
} }
} }
private static ArrayList m_Channels = new ArrayList(); private static List<Channel> m_Channels = new List<Channel>();
public static ArrayList Channels public static List<Channel> Channels
{ {
get get
{ {
@ -474,7 +474,7 @@ namespace Server.Engines.Chat
{ {
for ( int i = 0; i < m_Channels.Count; ++i ) for ( int i = 0; i < m_Channels.Count; ++i )
{ {
Channel channel = (Channel)m_Channels[i]; Channel channel = m_Channels[i];
if ( !channel.IsBanned( user ) ) if ( !channel.IsBanned( user ) )
ChatSystem.SendCommandTo( user.Mobile, ChatCommand.AddChannel, channel.Name, "0" ); ChatSystem.SendCommandTo( user.Mobile, ChatCommand.AddChannel, channel.Name, "0" );
@ -526,7 +526,7 @@ namespace Server.Engines.Chat
{ {
for ( int i = 0; i < m_Channels.Count; ++i ) for ( int i = 0; i < m_Channels.Count; ++i )
{ {
Channel channel = (Channel)m_Channels[i]; Channel channel = m_Channels[i];
if ( channel.m_Name == name ) if ( channel.m_Name == name )
return channel; return channel;

View file

@ -1,8 +1,7 @@
using System; using System;
using System.Collections;
using Server; using Server;
using Server.Network;
using Server.Gumps; using Server.Gumps;
using Server.Network;
namespace Server.Gumps namespace Server.Gumps
{ {
@ -246,113 +245,5 @@ namespace Server.Gumps
} }
} }
} }
public static bool MoveToLocation( Mobile m, string text )
{
string[] args = text.Split( '.' );
if ( args.Length == 0 )
return false;
for ( int i = 0; i < args.Length; ++i )
args[i].Trim();
ArrayList trees = new ArrayList();
// The mobile's map is to be checked first.
if ( m.Map == Map.Ilshenar )
trees.Add( Ilshenar );
else if ( m.Map == Map.Felucca )
trees.Add( Felucca );
else if ( m.Map == Map.Trammel )
trees.Add( Trammel );
else if ( m.Map == Map.Malas )
trees.Add( Malas );
else
trees.Add( Tokuno );
// The other maps follow.
if ( !trees.Contains( Trammel ) )
trees.Add( Trammel );
if ( !trees.Contains( Felucca ) )
trees.Add( Felucca );
if ( !trees.Contains( Ilshenar ) )
trees.Add( Ilshenar );
if ( !trees.Contains( Malas ) )
trees.Add( Malas );
if ( !trees.Contains( Tokuno ) )
trees.Add( Tokuno );
LocationTree tree;
for ( int i = 0; i < trees.Count; ++i )
{
tree = (LocationTree)trees[i];
// If a specific tree was requested, it's the only one we need to parse.
if ( Insensitive.Equals( args[0], tree.Map.Name ) )
{
if ( args.Length < 2 )
return false;
return ParseNode( tree.Root, args, 1, m, tree.Map );
}
}
for ( int i = 0; i < trees.Count; ++i )
{
tree = (LocationTree)trees[i];
// Parse all trees.
if ( ParseNode( tree.Root, args, 0, m, tree.Map ) )
return true;
}
return false;
}
public static bool ParseNode( ParentNode node, string[] args, int argsIndex, Mobile m, Map map )
{
if ( args[argsIndex].Length == 0 )
return false;
for ( int i = 0; i < node.Children.Length; ++i )
{
object child = node.Children[i];
if ( child is ParentNode )
{
if ( Insensitive.Equals( ((ParentNode)child).Name, args[argsIndex] ) )
{
if ( (argsIndex + 1) >= args.Length )
return false;
if ( args[argsIndex + 1].Length == 0 )
return false;
return ParseNode( (ParentNode)child, args, argsIndex + 1, m, map );
}
else
{
if ( ParseNode( (ParentNode)child, args, argsIndex, m, map ) )
return true;
}
}
else if ( child is ChildNode )
{
if ( Insensitive.Equals( ((ChildNode)child).Name, args[argsIndex] ) )
{
m.MoveToWorld( ((ChildNode)child).Location, map );
return true;
}
}
}
return false;
}
} }
} }

View file

@ -75,7 +75,7 @@ namespace Server.Gumps
int givenToBankBox = 0; int givenToBankBox = 0;
for ( int i = inventory.Items.Count - 1; i >= 0; i-- ) for ( int i = inventory.Items.Count - 1; i >= 0; i-- )
{ {
Item item = (Item) inventory.Items[i]; Item item = inventory.Items[i];
if ( item.Deleted ) if ( item.Deleted )
{ {

View file

@ -109,12 +109,10 @@ namespace Server.Items
public bool CouldFit( IPoint3D p, Map map ) public bool CouldFit( IPoint3D p, Map map )
{ {
List<BaseHouse> houses = null; return ( CouldFit( p, map, null, null ) == AddonFitResult.Valid );
return ( CouldFit( p, map, null, ref houses ) == AddonFitResult.Valid );
} }
public AddonFitResult CouldFit( IPoint3D p, Map map, Mobile from, ref List<BaseHouse> houses ) public AddonFitResult CouldFit( IPoint3D p, Map map, Mobile from, ref BaseHouse house )
{ {
if ( Deleted ) if ( Deleted )
return AddonFitResult.Blocked; return AddonFitResult.Blocked;
@ -125,7 +123,7 @@ namespace Server.Items
if ( !map.CanFit( p3D.X, p3D.Y, p3D.Z, c.ItemData.Height, false, true, ( c.Z == 0 ) ) ) if ( !map.CanFit( p3D.X, p3D.Y, p3D.Z, c.ItemData.Height, false, true, ( c.Z == 0 ) ) )
return AddonFitResult.Blocked; return AddonFitResult.Blocked;
else if ( !CheckHouse( from, p3D, map, c.ItemData.Height, ref houses ) ) else if ( !CheckHouse( from, p3D, map, c.ItemData.Height, ref house ) )
return AddonFitResult.NotInHouse; return AddonFitResult.NotInHouse;
if ( c.NeedsWall ) if ( c.NeedsWall )
@ -137,44 +135,38 @@ namespace Server.Items
} }
} }
foreach ( BaseHouse house in houses ) ArrayList doors = house.Doors;
for ( int i = 0; i < doors.Count; ++i )
{ {
ArrayList doors = house.Doors; BaseDoor door = doors[i] as BaseDoor;
for ( int i = 0; i < doors.Count; ++i ) if ( door != null && door.Open )
return AddonFitResult.DoorsNotClosed;
Point3D doorLoc = door.GetWorldLocation();
int doorHeight = door.ItemData.CalcHeight;
foreach ( AddonComponent c in m_Components )
{ {
BaseDoor door = doors[i] as BaseDoor; Point3D addonLoc = new Point3D( p.X + c.Offset.X, p.Y + c.Offset.Y, p.Z + c.Offset.Z );
int addonHeight = c.ItemData.CalcHeight;
if ( door != null && door.Open )
return AddonFitResult.DoorsNotClosed; if ( Utility.InRange( doorLoc, addonLoc, 1 ) && (addonLoc.Z == doorLoc.Z || ((addonLoc.Z + addonHeight) > doorLoc.Z && (doorLoc.Z + doorHeight) > addonLoc.Z)) )
return AddonFitResult.DoorTooClose;
Point3D doorLoc = door.GetWorldLocation();
int doorHeight = door.ItemData.CalcHeight;
foreach ( AddonComponent c in m_Components )
{
Point3D addonLoc = new Point3D( p.X + c.Offset.X, p.Y + c.Offset.Y, p.Z + c.Offset.Z );
int addonHeight = c.ItemData.CalcHeight;
if ( Utility.InRange( doorLoc, addonLoc, 1 ) && (addonLoc.Z == doorLoc.Z || ((addonLoc.Z + addonHeight) > doorLoc.Z && (doorLoc.Z + doorHeight) > addonLoc.Z)) )
return AddonFitResult.DoorTooClose;
}
} }
} }
return AddonFitResult.Valid; return AddonFitResult.Valid;
} }
public static bool CheckHouse( Mobile from, Point3D p, Map map, int height, ref List<BaseHouse> list ) public static bool CheckHouse( Mobile from, Point3D p, Map map, int height, ref BaseHouse house )
{ {
BaseHouse house = BaseHouse.FindHouseAt( p, map, height ); house = BaseHouse.FindHouseAt( p, map, height );
if ( from == null || house == null || !house.IsOwner( from ) ) if ( from == null || house == null || !house.IsOwner( from ) )
return false; return false;
if ( !list.Contains( house ) )
list.Add( house );
return true; return true;
} }

View file

@ -73,9 +73,9 @@ namespace Server.Items
Server.Spells.SpellHelper.GetSurfaceTop( ref p ); Server.Spells.SpellHelper.GetSurfaceTop( ref p );
List<BaseHouse> houses = new List<BaseHouse>(); List<BaseHouse> house;
AddonFitResult res = addon.CouldFit( p, map, from, ref houses ); AddonFitResult res = addon.CouldFit( p, map, from, ref house );
if ( res == AddonFitResult.Valid ) if ( res == AddonFitResult.Valid )
addon.MoveToWorld( new Point3D( p ), map ); addon.MoveToWorld( new Point3D( p ), map );
@ -93,9 +93,7 @@ namespace Server.Items
if ( res == AddonFitResult.Valid ) if ( res == AddonFitResult.Valid )
{ {
m_Deed.Delete(); m_Deed.Delete();
house.Addons.Add( addon );
foreach ( BaseHouse h in houses )
h.Addons.Add( addon );
} }
else else
{ {

View file

@ -1,5 +1,5 @@
using System; using System;
using System.Collections; using System.Collections.Generic;
using Server; using Server;
using Server.Multis; using Server.Multis;
@ -14,7 +14,7 @@ namespace Server.Mobiles
private string m_ShopName; private string m_ShopName;
private Mobile m_Owner; private Mobile m_Owner;
private ArrayList m_Items; private List<Item> m_Items;
private int m_Gold; private int m_Gold;
private DateTime m_ExpireTime; private DateTime m_ExpireTime;
@ -27,7 +27,7 @@ namespace Server.Mobiles
m_VendorName = vendorName; m_VendorName = vendorName;
m_ShopName = shopName; m_ShopName = shopName;
m_Items = new ArrayList(); m_Items = new List<Item>();
m_ExpireTime = DateTime.Now + GracePeriod; m_ExpireTime = DateTime.Now + GracePeriod;
m_ExpireTimer = new ExpireTimer( this, GracePeriod ); m_ExpireTimer = new ExpireTimer( this, GracePeriod );
@ -58,7 +58,7 @@ namespace Server.Mobiles
set{ m_Owner = value; } set{ m_Owner = value; }
} }
public ArrayList Items public List<Item> Items
{ {
get{ return m_Items; } get{ return m_Items; }
} }
@ -104,7 +104,7 @@ namespace Server.Mobiles
writer.Write( (string) m_VendorName ); writer.Write( (string) m_VendorName );
writer.Write( (string) m_ShopName ); writer.Write( (string) m_ShopName );
writer.WriteItemList( m_Items, true ); writer.Write( m_Items, true );
writer.Write( (int) m_Gold ); writer.Write( (int) m_Gold );
writer.WriteDeltaTime( m_ExpireTime ); writer.WriteDeltaTime( m_ExpireTime );
@ -120,7 +120,7 @@ namespace Server.Mobiles
m_VendorName = reader.ReadString(); m_VendorName = reader.ReadString();
m_ShopName = reader.ReadString(); m_ShopName = reader.ReadString();
m_Items = reader.ReadItemList(); m_Items = reader.ReadStrongItemList();
m_Gold = reader.ReadInt(); m_Gold = reader.ReadInt();
m_ExpireTime = reader.ReadDeltaTime(); m_ExpireTime = reader.ReadDeltaTime();

View file

@ -1,6 +1,6 @@
using System; using System;
using System.Collections.Generic;
using System.IO; using System.IO;
using System.Collections;
namespace Server.Multis namespace Server.Multis
{ {
@ -142,7 +142,7 @@ namespace Server.Multis
for ( int i = 0; i < m_Columns.Length; ++i ) for ( int i = 0; i < m_Columns.Length; ++i )
m_Columns[i] = new ColumnInfo( i, types[i], names[i] ); m_Columns[i] = new ColumnInfo( i, types[i], names[i] );
ArrayList records = new ArrayList(); List<DataRecord> records = new List<DataRecord>();
string[] values; string[] values;
@ -172,7 +172,7 @@ namespace Server.Multis
records.Add( new DataRecord( this, data ) ); records.Add( new DataRecord( this, data ) );
} }
m_Records = (DataRecord[]) records.ToArray( typeof( DataRecord ) ); m_Records = records.ToArray();
} }
} }

View file

@ -1,14 +1,14 @@
using System; using System;
using System.Collections.Generic;
using System.IO; using System.IO;
using System.Threading; using System.Threading;
using System.Collections;
using Server; using Server;
using Server.Commands;
using Server.Gumps; using Server.Gumps;
using Server.Items; using Server.Items;
using Server.Mobiles; using Server.Mobiles;
using Server.Network; using Server.Network;
using Server.Targeting; using Server.Targeting;
using Server.Commands;
namespace Server.Multis namespace Server.Multis
{ {
@ -32,13 +32,13 @@ namespace Server.Multis
private Item m_Signpost; // Item supporting the hanger. private Item m_Signpost; // Item supporting the hanger.
private int m_SignpostGraphic; // ItemID number of the chosen signpost. private int m_SignpostGraphic; // ItemID number of the chosen signpost.
private int m_LastRevision; // Latest revision number. private int m_LastRevision; // Latest revision number.
private ArrayList m_Fixtures; // List of fixtures (teleporters and doors) associated with this house. private List<Item> m_Fixtures; // List of fixtures (teleporters and doors) associated with this house.
private FoundationType m_Type; // Graphic type of this foundation. private FoundationType m_Type; // Graphic type of this foundation.
private Mobile m_Customizer; // Who is currently customizing this -or- null if not customizing. private Mobile m_Customizer; // Who is currently customizing this -or- null if not customizing.
public FoundationType Type { get { return m_Type; } set { m_Type = value; } } public FoundationType Type { get { return m_Type; } set { m_Type = value; } }
public int LastRevision { get { return m_LastRevision; } set { m_LastRevision = value; } } public int LastRevision { get { return m_LastRevision; } set { m_LastRevision = value; } }
public ArrayList Fixtures { get { return m_Fixtures; } } public List<Item> Fixtures { get { return m_Fixtures; } }
public Item SignHanger { get { return m_SignHanger; } } public Item SignHanger { get { return m_SignHanger; } }
public Item Signpost { get { return m_Signpost; } } public Item Signpost { get { return m_Signpost; } }
public int SignpostGraphic { get { return m_SignpostGraphic; } set { m_SignpostGraphic = value; } } public int SignpostGraphic { get { return m_SignpostGraphic; } set { m_SignpostGraphic = value; } }
@ -126,7 +126,7 @@ namespace Server.Multis
for( int i = 0; i < m_Fixtures.Count; ++i ) for( int i = 0; i < m_Fixtures.Count; ++i )
{ {
Item item = (Item)m_Fixtures[i]; Item item = m_Fixtures[i];
if( item != null ) if( item != null )
item.Delete(); item.Delete();
@ -154,7 +154,7 @@ namespace Server.Multis
for( int i = 0; i < m_Fixtures.Count; ++i ) for( int i = 0; i < m_Fixtures.Count; ++i )
{ {
Item item = (Item)m_Fixtures[i]; Item item = m_Fixtures[i];
if( Doors.Contains( item ) ) if( Doors.Contains( item ) )
continue; continue;
@ -177,7 +177,7 @@ namespace Server.Multis
return; return;
for( int i = 0; i < m_Fixtures.Count; ++i ) for( int i = 0; i < m_Fixtures.Count; ++i )
((Item)m_Fixtures[i]).Map = this.Map; m_Fixtures[i].Map = this.Map;
} }
public void ClearFixtures( Mobile from ) public void ClearFixtures( Mobile from )
@ -189,7 +189,7 @@ namespace Server.Multis
for( int i = 0; i < m_Fixtures.Count; ++i ) for( int i = 0; i < m_Fixtures.Count; ++i )
{ {
((Item)m_Fixtures[i]).Delete(); m_Fixtures[i].Delete();
Doors.Remove( m_Fixtures[i] ); Doors.Remove( m_Fixtures[i] );
} }
@ -199,7 +199,7 @@ namespace Server.Multis
public void AddFixtures( Mobile from, MultiTileEntry[] list ) public void AddFixtures( Mobile from, MultiTileEntry[] list )
{ {
if( m_Fixtures == null ) if( m_Fixtures == null )
m_Fixtures = new ArrayList(); m_Fixtures = new List<Item>();
uint keyValue = 0; uint keyValue = 0;
@ -367,7 +367,7 @@ namespace Server.Multis
for( int i = 0; i < m_Fixtures.Count; ++i ) for( int i = 0; i < m_Fixtures.Count; ++i )
{ {
Item fixture = (Item)m_Fixtures[i]; Item fixture = m_Fixtures[i];
if( fixture is HouseTeleporter ) if( fixture is HouseTeleporter )
{ {
@ -575,7 +575,7 @@ namespace Server.Multis
{ {
m_SignpostGraphic = 9; m_SignpostGraphic = 9;
m_Fixtures = new ArrayList(); m_Fixtures = new List<Item>();
int x = Components.Min.X; int x = Components.Min.X;
int y = Components.Height - 1 - Components.Center.Y; int y = Components.Height - 1 - Components.Center.Y;
@ -647,7 +647,7 @@ namespace Server.Multis
writer.Write( m_SignHanger ); writer.Write( m_SignHanger );
writer.Write( (int)m_LastRevision ); writer.Write( (int)m_LastRevision );
writer.WriteItemList( m_Fixtures, true ); writer.Write( m_Fixtures, true );
CurrentState.Serialize( writer ); CurrentState.Serialize( writer );
DesignState.Serialize( writer ); DesignState.Serialize( writer );
@ -702,7 +702,7 @@ namespace Server.Multis
m_SignpostGraphic = 9; m_SignpostGraphic = 9;
m_LastRevision = reader.ReadInt(); m_LastRevision = reader.ReadInt();
m_Fixtures = reader.ReadItemList(); m_Fixtures = reader.ReadStrongItemList();
m_Current = new DesignState( this, reader ); m_Current = new DesignState( this, reader );
m_Design = new DesignState( this, reader ); m_Design = new DesignState( this, reader );
@ -1957,16 +1957,19 @@ namespace Server.Multis
m_Level = 1; m_Level = 1;
} }
private static Hashtable m_Table = new Hashtable(); private static Dictionary<Mobile, DesignContext> m_Table = new Dictionary<Mobile, DesignContext>();
public static Hashtable Table { get { return m_Table; } } public static Dictionary<Mobile, DesignContext> Table { get { return m_Table; } }
public static DesignContext Find( Mobile from ) public static DesignContext Find( Mobile from )
{ {
if( from == null ) if( from == null )
return null; return null;
return (DesignContext)m_Table[from]; DesignContext d;
m_Table.TryGetValue( from, out d );
return d;
} }
public static bool Check( Mobile m ) public static bool Check( Mobile m )
@ -1989,7 +1992,7 @@ namespace Server.Multis
m_Table[from] = c; m_Table[from] = c;
if( from is PlayerMobile ) if ( from is PlayerMobile )
((PlayerMobile)from).DesignContext = c; ((PlayerMobile)from).DesignContext = c;
foundation.Customizer = from; foundation.Customizer = from;
@ -2002,11 +2005,11 @@ namespace Server.Multis
if( state == null ) if( state == null )
return; return;
ArrayList fixtures = foundation.Fixtures; List<Item> fixtures = foundation.Fixtures;
for( int i = 0; fixtures != null && i < fixtures.Count; ++i ) for( int i = 0; fixtures != null && i < fixtures.Count; ++i )
{ {
Item item = (Item)fixtures[i]; Item item = fixtures[i];
state.Send( item.RemovePacket ); state.Send( item.RemovePacket );
} }
@ -2017,10 +2020,10 @@ namespace Server.Multis
public static void Remove( Mobile from ) public static void Remove( Mobile from )
{ {
if( from == null ) DesignContext context = Find( from );
return;
DesignContext context = (DesignContext)m_Table[from]; if ( context == null )
return;
m_Table.Remove( from ); m_Table.Remove( from );
@ -2037,11 +2040,11 @@ namespace Server.Multis
if( state == null ) if( state == null )
return; return;
ArrayList fixtures = context.Foundation.Fixtures; List<Item> fixtures = context.Foundation.Fixtures;
for( int i = 0; fixtures != null && i < fixtures.Count; ++i ) for( int i = 0; fixtures != null && i < fixtures.Count; ++i )
{ {
Item item = (Item)fixtures[i]; Item item = fixtures[i];
item.SendInfoTo( state ); item.SendInfoTo( state );
} }

View file

@ -73,10 +73,11 @@ namespace Server.Multis
Point3D start = new Point3D( center.X + mcl.Min.X, center.Y + mcl.Min.Y, center.Z ); Point3D start = new Point3D( center.X + mcl.Min.X, center.Y + mcl.Min.Y, center.Z );
// These are storage lists. They hold items and mobiles found in the map for further processing // These are storage lists. They hold items and mobiles found in the map for further processing
ArrayList items = new ArrayList(), mobiles = new ArrayList(); List<Item> items = new List<Item>();
List<Mobile> mobiles = new List<Mobile>();
// These are also storage lists. They hold location values indicating the yard and border locations. // These are also storage lists. They hold location values indicating the yard and border locations.
ArrayList yard = new ArrayList(), borders = new ArrayList(); List<Point2D> yard = new List<Point2D>(), borders = new List<Point2D>();
/* RULES: /* RULES:
* *
@ -132,7 +133,7 @@ namespace Server.Multis
for ( int i = 0; i < sector.Mobiles.Count; ++i ) for ( int i = 0; i < sector.Mobiles.Count; ++i )
{ {
Mobile m = (Mobile)sector.Mobiles[i]; Mobile m = sector.Mobiles[i];
if ( m.X == tileX && m.Y == tileY ) if ( m.X == tileX && m.Y == tileY )
mobiles.Add( m ); mobiles.Add( m );
@ -184,7 +185,7 @@ namespace Server.Multis
for ( int j = 0; j < items.Count; ++j ) for ( int j = 0; j < items.Count; ++j )
{ {
Item item = (Item)items[j]; Item item = items[j];
ItemData id = item.ItemData; ItemData id = item.ItemData;
if ( addTileTop > item.Z && (item.Z + id.CalcHeight) > addTileZ ) if ( addTileTop > item.Z && (item.Z + id.CalcHeight) > addTileZ )
@ -205,7 +206,7 @@ namespace Server.Multis
for ( int j = 0; j < mobiles.Count; ++j ) for ( int j = 0; j < mobiles.Count; ++j )
{ {
Mobile m = (Mobile)mobiles[j]; Mobile m = mobiles[j];
if ( addTileTop > m.Z && (m.Z + 16) > addTileZ ) if ( addTileTop > m.Z && (m.Z + 16) > addTileZ )
toMove.Add( m ); toMove.Add( m );
@ -272,7 +273,7 @@ namespace Server.Multis
for ( int i = 0; i < borders.Count; ++i ) for ( int i = 0; i < borders.Count; ++i )
{ {
Point2D borderPoint = (Point2D)borders[i]; Point2D borderPoint = borders[i];
Tile landTile = map.Tiles.GetLandTile( borderPoint.X, borderPoint.Y ); Tile landTile = map.Tiles.GetLandTile( borderPoint.X, borderPoint.Y );
int landID = landTile.ID & 0x3FFF; int landID = landTile.ID & 0x3FFF;
@ -316,7 +317,7 @@ namespace Server.Multis
for ( int i = 0; i < yard.Count; ++i ) for ( int i = 0; i < yard.Count; ++i )
{ {
Point2D yardPoint = (Point2D)yard[i]; Point2D yardPoint = yard[i];
IPooledEnumerable eable = map.GetMultiTilesAt( yardPoint.X, yardPoint.Y ); IPooledEnumerable eable = map.GetMultiTilesAt( yardPoint.X, yardPoint.Y );

View file

@ -557,7 +557,7 @@ namespace Server.Items
{ {
for ( int i = 0; i < entries.Length; ++i ) for ( int i = 0; i < entries.Length; ++i )
{ {
HousePlacementEntry e = (HousePlacementEntry)entries[i]; HousePlacementEntry e = entries[i];
object obj = m_Table[e.m_Type]; object obj = m_Table[e.m_Type];

View file

@ -19,9 +19,9 @@
***************************************************************************/ ***************************************************************************/
using System; using System;
using System.Collections; using System.Collections.Generic;
using Server.Network;
using System.Runtime.Serialization; using System.Runtime.Serialization;
using Server.Network;
namespace Server namespace Server
{ {
@ -37,9 +37,9 @@ namespace Server
public static Race Human { get { return m_Races[0]; } } public static Race Human { get { return m_Races[0]; } }
public static Race Elf { get { return m_Races[1]; } } public static Race Elf { get { return m_Races[1]; } }
private static ArrayList m_AllRaces = new ArrayList(); private static List<Race> m_AllRaces = new List<Race>( 2 );
public static ArrayList AllRaces { get { return m_AllRaces; } } public static List<Race> AllRaces { get { return m_AllRaces; } }
private int m_RaceID, m_RaceIndex; private int m_RaceID, m_RaceIndex;
@ -90,7 +90,7 @@ namespace Server
for( int i = 0; i < m_AllRaces.Count; ++i ) for( int i = 0; i < m_AllRaces.Count; ++i )
{ {
Race race = (Race)m_AllRaces[i]; Race race = m_AllRaces[i];
m_RaceNames[i] = race.Name; m_RaceNames[i] = race.Name;
m_RaceValues[i] = race; m_RaceValues[i] = race;

View file

@ -21,9 +21,9 @@
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics;
using System.IO; using System.IO;
using System.Threading; using System.Threading;
using System.Diagnostics;
namespace Server namespace Server
{ {