generic town criers, misc generics, region cleanups, container generic, yadda yadda

This commit is contained in:
mark 2006-06-24 17:56:49 +00:00
parent 03adafb13e
commit 90c2233e4c
16 changed files with 114 additions and 167 deletions

View file

@ -329,13 +329,11 @@ namespace Server.Commands
public static void ReplaceBankers_OnCommand( CommandEventArgs e ) public static void ReplaceBankers_OnCommand( CommandEventArgs e )
{ {
ArrayList list = new ArrayList(); List<Mobile> list = new List<Mobile>();
foreach ( Mobile m in World.Mobiles.Values ) foreach ( Mobile m in World.Mobiles.Values )
{
if ( (m is Banker) && !(m is BaseCreature) ) if ( (m is Banker) && !(m is BaseCreature) )
list.Add( m ); list.Add( m );
}
foreach ( Mobile m in list ) foreach ( Mobile m in list )
{ {
@ -1312,24 +1310,22 @@ namespace Server.Commands
{ {
Mobile m = e.Mobile; Mobile m = e.Mobile;
ArrayList list = new ArrayList(); List<CommandEntry> list = new List<CommandEntry>();
foreach ( CommandEntry entry in CommandSystem.Entries.Values ) foreach ( CommandEntry entry in CommandSystem.Entries.Values )
{
if ( m.AccessLevel >= entry.AccessLevel ) if ( m.AccessLevel >= entry.AccessLevel )
list.Add( entry ); list.Add( entry );
}
list.Sort(); list.Sort();
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
if ( list.Count > 0 ) if ( list.Count > 0 )
sb.Append( ((CommandEntry)list[0]).Command ); sb.Append( list[0].Command );
for ( int i = 1; i < list.Count; ++i ) for ( int i = 1; i < list.Count; ++i )
{ {
string v = ((CommandEntry)list[i]).Command; string v = list[i].Command;
if ( (sb.Length + 1 + v.Length) >= 256 ) if ( (sb.Length + 1 + v.Length) >= 256 )
{ {

View file

@ -1,13 +1,13 @@
using System; using System;
using System.Reflection; using System.Reflection;
using System.Collections; using System.Collections;
using System.Collections.Generic;
using Server.Network; using Server.Network;
using Server.Prompts; using Server.Prompts;
using Server.Mobiles; using Server.Mobiles;
using Server.Multis; using Server.Multis;
using Server.Multis.Deeds; using Server.Multis.Deeds;
using Server.Items; using Server.Items;
using System.Collections.Generic;
namespace Server.Gumps namespace Server.Gumps
{ {
@ -756,8 +756,8 @@ namespace Server.Gumps
house.MovingCrate = null; house.MovingCrate = null;
} }
ArrayList items = house.GetItems(); List<Item> items = house.GetItems();
ArrayList mobiles = house.GetMobiles(); List<Mobile> mobiles = house.GetMobiles();
newHouse.MoveToWorld( new Point3D( house.X + house.ConvertOffsetX, house.Y + house.ConvertOffsetY, house.Z + house.ConvertOffsetZ ), house.Map ); newHouse.MoveToWorld( new Point3D( house.X + house.ConvertOffsetX, house.Y + house.ConvertOffsetY, house.Z + house.ConvertOffsetZ ), house.Map );
house.Delete(); house.Delete();

View file

@ -1,6 +1,6 @@
using System; using System;
using System.Text; using System.Text;
using System.Collections; using System.Collections.Generic;
using Server; using Server;
using Server.Prompts; using Server.Prompts;
using Server.Gumps; using Server.Gumps;
@ -13,7 +13,7 @@ namespace Server.Mobiles
{ {
public interface ITownCrierEntryList public interface ITownCrierEntryList
{ {
ArrayList Entries{ get; } List<TownCrierEntry> Entries{ get; }
TownCrierEntry GetRandomEntry(); TownCrierEntry GetRandomEntry();
TownCrierEntry AddEntry( string[] lines, TimeSpan duration ); TownCrierEntry AddEntry( string[] lines, TimeSpan duration );
void RemoveEntry( TownCrierEntry entry ); void RemoveEntry( TownCrierEntry entry );
@ -52,9 +52,9 @@ namespace Server.Mobiles
{ {
} }
private ArrayList m_Entries; private List<TownCrierEntry> m_Entries;
public ArrayList Entries public List<TownCrierEntry> Entries
{ {
get{ return m_Entries; } get{ return m_Entries; }
} }
@ -69,7 +69,7 @@ namespace Server.Mobiles
if ( i >= m_Entries.Count ) if ( i >= m_Entries.Count )
continue; continue;
TownCrierEntry tce = (TownCrierEntry)m_Entries[i]; TownCrierEntry tce = m_Entries[i];
if ( tce.Expired ) if ( tce.Expired )
RemoveEntry( tce ); RemoveEntry( tce );
@ -78,22 +78,22 @@ namespace Server.Mobiles
if ( m_Entries == null || m_Entries.Count == 0 ) if ( m_Entries == null || m_Entries.Count == 0 )
return null; return null;
return (TownCrierEntry)m_Entries[Utility.Random( m_Entries.Count )]; return m_Entries[Utility.Random( m_Entries.Count )];
} }
public TownCrierEntry AddEntry( string[] lines, TimeSpan duration ) public TownCrierEntry AddEntry( string[] lines, TimeSpan duration )
{ {
if ( m_Entries == null ) if ( m_Entries == null )
m_Entries = new ArrayList(); m_Entries = new List<TownCrierEntry>();
TownCrierEntry tce = new TownCrierEntry( lines, duration ); TownCrierEntry tce = new TownCrierEntry( lines, duration );
m_Entries.Add( tce ); m_Entries.Add( tce );
ArrayList instances = TownCrier.Instances; List<TownCrier> instances = TownCrier.Instances;
for ( int i = 0; i < instances.Count; ++i ) for ( int i = 0; i < instances.Count; ++i )
((TownCrier)instances[i]).ForceBeginAutoShout(); instances[i].ForceBeginAutoShout();
return tce; return tce;
} }
@ -158,7 +158,7 @@ namespace Server.Mobiles
from.SendMessage( "Duration set to: {0}", ts ); from.SendMessage( "Duration set to: {0}", ts );
from.SendMessage( "Enter the first line to shout:" ); from.SendMessage( "Enter the first line to shout:" );
from.Prompt = new TownCrierLinesPrompt( m_Owner, null, new ArrayList(), ts ); from.Prompt = new TownCrierLinesPrompt( m_Owner, null, new List<String>(), ts );
} }
public override void OnCancel( Mobile from ) public override void OnCancel( Mobile from )
@ -172,10 +172,10 @@ namespace Server.Mobiles
{ {
private ITownCrierEntryList m_Owner; private ITownCrierEntryList m_Owner;
private TownCrierEntry m_Entry; private TownCrierEntry m_Entry;
private ArrayList m_Lines; private List<String> m_Lines;
private TimeSpan m_Duration; private TimeSpan m_Duration;
public TownCrierLinesPrompt( ITownCrierEntryList owner, TownCrierEntry entry, ArrayList lines, TimeSpan duration ) public TownCrierLinesPrompt( ITownCrierEntryList owner, TownCrierEntry entry, List<String> lines, TimeSpan duration )
{ {
m_Owner = owner; m_Owner = owner;
m_Entry = entry; m_Entry = entry;
@ -198,7 +198,7 @@ namespace Server.Mobiles
if ( m_Lines.Count > 0 ) if ( m_Lines.Count > 0 )
{ {
m_Owner.AddEntry( (string[])m_Lines.ToArray( typeof( string ) ), m_Duration ); m_Owner.AddEntry( m_Lines.ToArray(), m_Duration );
from.SendMessage( "Message has been set." ); from.SendMessage( "Message has been set." );
} }
else else
@ -227,12 +227,12 @@ namespace Server.Mobiles
} }
else if ( info.ButtonID > 1 ) else if ( info.ButtonID > 1 )
{ {
ArrayList entries = m_Owner.Entries; List<TownCrierEntry> entries = m_Owner.Entries;
int index = info.ButtonID - 2; int index = info.ButtonID - 2;
if ( entries != null && index < entries.Count ) if ( entries != null && index < entries.Count )
{ {
TownCrierEntry tce = (TownCrierEntry)entries[index]; TownCrierEntry tce = entries[index];
TimeSpan ts = tce.ExpireTime - DateTime.Now; TimeSpan ts = tce.ExpireTime - DateTime.Now;
if ( ts < TimeSpan.Zero ) if ( ts < TimeSpan.Zero )
@ -240,7 +240,7 @@ namespace Server.Mobiles
m_From.SendMessage( "Editing entry #{0}.", index + 1 ); m_From.SendMessage( "Editing entry #{0}.", index + 1 );
m_From.SendMessage( "Enter the first line to shout:" ); m_From.SendMessage( "Enter the first line to shout:" );
m_From.Prompt = new TownCrierLinesPrompt( m_Owner, tce, new ArrayList(), ts ); m_From.Prompt = new TownCrierLinesPrompt( m_Owner, tce, new List<String>(), ts );
} }
} }
} }
@ -254,7 +254,7 @@ namespace Server.Mobiles
AddPage( 0 ); AddPage( 0 );
ArrayList entries = owner.Entries; List<TownCrierEntry> entries = owner.Entries;
owner.GetRandomEntry(); // force expiration checks owner.GetRandomEntry(); // force expiration checks
@ -323,11 +323,11 @@ namespace Server.Mobiles
public class TownCrier : Mobile, ITownCrierEntryList public class TownCrier : Mobile, ITownCrierEntryList
{ {
private ArrayList m_Entries; private List<TownCrierEntry> m_Entries;
private Timer m_NewsTimer; private Timer m_NewsTimer;
private Timer m_AutoShoutTimer; private Timer m_AutoShoutTimer;
public ArrayList Entries public List<TownCrierEntry> Entries
{ {
get{ return m_Entries; } get{ return m_Entries; }
} }
@ -342,7 +342,7 @@ namespace Server.Mobiles
if ( i >= m_Entries.Count ) if ( i >= m_Entries.Count )
continue; continue;
TownCrierEntry tce = (TownCrierEntry)m_Entries[i]; TownCrierEntry tce = m_Entries[i];
if ( tce.Expired ) if ( tce.Expired )
RemoveEntry( tce ); RemoveEntry( tce );
@ -354,7 +354,7 @@ namespace Server.Mobiles
TownCrierEntry entry = GlobalTownCrierEntryList.Instance.GetRandomEntry(); TownCrierEntry entry = GlobalTownCrierEntryList.Instance.GetRandomEntry();
if ( entry == null || Utility.RandomBool() ) if ( entry == null || Utility.RandomBool() )
entry = (TownCrierEntry)m_Entries[Utility.Random( m_Entries.Count )]; entry = m_Entries[Utility.Random( m_Entries.Count )];
return entry; return entry;
} }
@ -368,7 +368,7 @@ namespace Server.Mobiles
public TownCrierEntry AddEntry( string[] lines, TimeSpan duration ) public TownCrierEntry AddEntry( string[] lines, TimeSpan duration )
{ {
if ( m_Entries == null ) if ( m_Entries == null )
m_Entries = new ArrayList(); m_Entries = new List<TownCrierEntry>();
TownCrierEntry tce = new TownCrierEntry( lines, duration ); TownCrierEntry tce = new TownCrierEntry( lines, duration );
@ -472,9 +472,9 @@ namespace Server.Mobiles
} }
} }
private static ArrayList m_Instances = new ArrayList(); private static List<TownCrier> m_Instances = new List<TownCrier>();
public static ArrayList Instances public static List<TownCrier> Instances
{ {
get{ return m_Instances; } get{ return m_Instances; }
} }

View file

@ -623,20 +623,16 @@ namespace Server.Mobiles
} }
} }
protected ArrayList GetItems() protected List<Item> GetItems()
{ {
ArrayList list = new ArrayList(); List<Item> list = new List<Item>();
foreach ( Item item in this.Items ) foreach ( Item item in this.Items )
{
if ( item.Movable && item != this.Backpack && item.Layer != Layer.Hair && item.Layer != Layer.FacialHair ) if ( item.Movable && item != this.Backpack && item.Layer != Layer.Hair && item.Layer != Layer.FacialHair )
list.Add( item ); list.Add( item );
}
if ( this.Backpack != null ) if ( this.Backpack != null )
{
list.AddRange( this.Backpack.Items ); list.AddRange( this.Backpack.Items );
}
return list; return list;
} }
@ -661,7 +657,7 @@ namespace Server.Mobiles
* -> do nothing (we can't do anything). * -> do nothing (we can't do anything).
*/ */
ArrayList list = GetItems(); List<Item> list = GetItems();
if ( list.Count > 0 || HoldGold > 0 ) // No case 1 if ( list.Count > 0 || HoldGold > 0 ) // No case 1
{ {

View file

@ -543,9 +543,9 @@ namespace Server.Multis
} }
} }
public ArrayList GetHouseEntities() public List<IEntity> GetHouseEntities()
{ {
ArrayList list = new ArrayList(); List<IEntity> list = new List<IEntity>();
if ( MovingCrate != null ) if ( MovingCrate != null )
MovingCrate.Hide(); MovingCrate.Hide();
@ -725,40 +725,38 @@ namespace Server.Multis
MovingCrate.DropItem( item ); MovingCrate.DropItem( item );
} }
public ArrayList GetItems() public List<Item> GetItems()
{ {
if( this.Map == null || this.Map == Map.Internal ) if( this.Map == null || this.Map == Map.Internal )
return new ArrayList(); return new List<Item>();
Point2D start = new Point2D( this.X + Components.Min.X, this.Y + Components.Min.Y ); Point2D start = new Point2D( this.X + Components.Min.X, this.Y + Components.Min.Y );
Point2D end = new Point2D( this.X + Components.Max.X + 1, this.Y + Components.Max.Y + 1 ); Point2D end = new Point2D( this.X + Components.Max.X + 1, this.Y + Components.Max.Y + 1 );
Rectangle2D rect = new Rectangle2D( start, end ); Rectangle2D rect = new Rectangle2D( start, end );
ArrayList list = new ArrayList(); List<Item> list = new List<Item>();
IPooledEnumerable eable = this.Map.GetItemsInBounds( rect ); IPooledEnumerable eable = this.Map.GetItemsInBounds( rect );
foreach ( Item item in eable ) foreach ( Item item in eable )
{
if ( item.Movable && IsInside( item ) ) if ( item.Movable && IsInside( item ) )
list.Add( item ); list.Add( item );
}
eable.Free(); eable.Free();
return list; return list;
} }
public ArrayList GetMobiles() public List<Mobile> GetMobiles()
{ {
if( this.Map == null || this.Map == Map.Internal ) if( this.Map == null || this.Map == Map.Internal )
return new ArrayList(); return new List<Mobile>();
ArrayList list = new ArrayList(); List<Mobile> list = new List<Mobile>();
foreach ( Mobile mobile in Region.GetMobiles() ) foreach ( Mobile mobile in Region.GetMobiles() )
{
if ( IsInside( mobile ) ) if ( IsInside( mobile ) )
list.Add( mobile ); list.Add( mobile );
}
return list; return list;
} }

View file

@ -1,5 +1,6 @@
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Generic;
using Server; using Server;
using Server.Items; using Server.Items;
using Server.Movement; using Server.Movement;
@ -144,9 +145,9 @@ namespace Server.Multis
public virtual BaseDockedBoat DockedBoat{ get{ return null; } } public virtual BaseDockedBoat DockedBoat{ get{ return null; } }
private static ArrayList m_Instances = new ArrayList(); private static List<BaseBoat> m_Instances = new List<BaseBoat>();
public static ArrayList Boats{ get{ return m_Instances; } } public static List<BaseBoat> Boats{ get{ return m_Instances; } }
public BaseBoat() : base( 0x4000 ) public BaseBoat() : base( 0x4000 )
{ {
@ -1642,7 +1643,7 @@ namespace Server.Multis
public static void UpdateAllComponents() public static void UpdateAllComponents()
{ {
for ( int i = m_Instances.Count - 1; i >= 0; --i ) for ( int i = m_Instances.Count - 1; i >= 0; --i )
((BaseBoat)m_Instances[i]).UpdateComponents(); m_Instances[i].UpdateComponents();
} }
public static void Initialize() public static void Initialize()

View file

@ -200,17 +200,13 @@ namespace Server.Multis
m_InternalizeTimer = null; m_InternalizeTimer = null;
} }
ArrayList toRemove = new ArrayList(); List<Item> toRemove = new List<Item>();
foreach ( Item item in this.Items ) foreach ( Item item in this.Items )
{
if ( item is PackingBox && item.Items.Count == 0 ) if ( item is PackingBox && item.Items.Count == 0 )
toRemove.Add( item ); toRemove.Add( item );
}
foreach ( Item item in toRemove ) foreach ( Item item in toRemove )
{
item.Delete(); item.Delete();
}
if ( this.TotalItems == 0 ) if ( this.TotalItems == 0 )
Delete(); Delete();

View file

@ -1,8 +1,8 @@
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Generic;
using System.Xml; using System.Xml;
using Server; using Server;
using System.Collections.Generic;
namespace Server.Regions namespace Server.Regions
{ {
@ -127,8 +127,8 @@ namespace Server.Regions
private int[] m_RectangleWeights; private int[] m_RectangleWeights;
private int m_TotalWeight; private int m_TotalWeight;
private static ArrayList m_Buffer1 = new ArrayList(); private static List<Rectangle3D> m_RectBuffer1 = new List<Rectangle3D>();
private static ArrayList m_Buffer2 = new ArrayList(); private static List<Rectangle3D> m_RectBuffer2 = new List<Rectangle3D>();
private void InitRectangles() private void InitRectangles()
{ {
@ -138,55 +138,55 @@ namespace Server.Regions
// Test if area rectangles are overlapping, and in that case break them into smaller non overlapping rectangles // Test if area rectangles are overlapping, and in that case break them into smaller non overlapping rectangles
for ( int i = 0; i < this.Area.Length; i++ ) for ( int i = 0; i < this.Area.Length; i++ )
{ {
m_Buffer2.Add( this.Area[i] ); m_RectBuffer2.Add( this.Area[i] );
for ( int j = 0; j < m_Buffer1.Count && m_Buffer2.Count > 0; j++ ) for ( int j = 0; j < m_RectBuffer1.Count && m_RectBuffer2.Count > 0; j++ )
{ {
Rectangle3D comp = (Rectangle3D) m_Buffer1[j]; Rectangle3D comp = m_RectBuffer1[j];
for ( int k = m_Buffer2.Count - 1; k >= 0; k-- ) for ( int k = m_RectBuffer2.Count - 1; k >= 0; k-- )
{ {
Rectangle3D rect = (Rectangle3D) m_Buffer2[k]; Rectangle3D rect = m_RectBuffer2[k];
int l1 = rect.Start.X, r1 = rect.End.X, t1 = rect.Start.Y, b1 = rect.End.Y; int l1 = rect.Start.X, r1 = rect.End.X, t1 = rect.Start.Y, b1 = rect.End.Y;
int l2 = comp.Start.X, r2 = comp.End.X, t2 = comp.Start.Y, b2 = comp.End.Y; int l2 = comp.Start.X, r2 = comp.End.X, t2 = comp.Start.Y, b2 = comp.End.Y;
if ( l1 < r2 && r1 > l2 && t1 < b2 && b1 > t2 ) if ( l1 < r2 && r1 > l2 && t1 < b2 && b1 > t2 )
{ {
m_Buffer2.RemoveAt( k ); m_RectBuffer2.RemoveAt( k );
int sz = rect.Start.Z; int sz = rect.Start.Z;
int ez = rect.End.X; int ez = rect.End.X;
if ( l1 < l2 ) if ( l1 < l2 )
{ {
m_Buffer2.Add( new Rectangle3D( new Point3D( l1, t1, sz ), new Point3D( l2, b1, ez ) ) ); m_RectBuffer2.Add( new Rectangle3D( new Point3D( l1, t1, sz ), new Point3D( l2, b1, ez ) ) );
} }
if ( r1 > r2 ) if ( r1 > r2 )
{ {
m_Buffer2.Add( new Rectangle3D( new Point3D( r2, t1, sz ), new Point3D( r1, b1, ez ) ) ); m_RectBuffer2.Add( new Rectangle3D( new Point3D( r2, t1, sz ), new Point3D( r1, b1, ez ) ) );
} }
if ( t1 < t2 ) if ( t1 < t2 )
{ {
m_Buffer2.Add( new Rectangle3D( new Point3D( Math.Max( l1, l2 ), t1, sz ), new Point3D( Math.Min( r1, r2 ), t2, ez ) ) ); m_RectBuffer2.Add( new Rectangle3D( new Point3D( Math.Max( l1, l2 ), t1, sz ), new Point3D( Math.Min( r1, r2 ), t2, ez ) ) );
} }
if ( b1 > b2 ) if ( b1 > b2 )
{ {
m_Buffer2.Add( new Rectangle3D( new Point3D( Math.Max( l1, l2 ), b2, sz ), new Point3D( Math.Min( r1, r2 ), b1, ez ) ) ); m_RectBuffer2.Add( new Rectangle3D( new Point3D( Math.Max( l1, l2 ), b2, sz ), new Point3D( Math.Min( r1, r2 ), b1, ez ) ) );
} }
} }
} }
} }
m_Buffer1.AddRange( m_Buffer2 ); m_RectBuffer1.AddRange( m_RectBuffer2 );
m_Buffer2.Clear(); m_RectBuffer2.Clear();
} }
m_Rectangles = (Rectangle3D[]) m_Buffer1.ToArray( typeof( Rectangle3D ) ); m_Rectangles = m_RectBuffer1.ToArray();
m_Buffer1.Clear(); m_RectBuffer1.Clear();
m_RectangleWeights = new int[m_Rectangles.Length]; m_RectangleWeights = new int[m_Rectangles.Length];
for ( int i = 0; i < m_Rectangles.Length; i++ ) for ( int i = 0; i < m_Rectangles.Length; i++ )
@ -199,6 +199,9 @@ namespace Server.Regions
} }
} }
private static List<Int32> m_SpawnBuffer1 = new List<Int32>();
private static List<Item> m_SpawnBuffer2 = new List<Item>();
public Point3D RandomSpawnLocation( int spawnHeight, bool land, bool water, Point3D home, int range ) public Point3D RandomSpawnLocation( int spawnHeight, bool land, bool water, Point3D home, int range )
{ {
Map map = this.Map; Map map = this.Map;
@ -266,7 +269,6 @@ namespace Server.Regions
if ( x < 0 || y < 0 || x >= map.Width || y >= map.Height ) if ( x < 0 || y < 0 || x >= map.Width || y >= map.Height )
continue; continue;
Tile lt = map.Tiles.GetLandTile( x, y ); Tile lt = map.Tiles.GetLandTile( x, y );
int ltLowZ = 0, ltAvgZ = 0, ltTopZ = 0; int ltLowZ = 0, ltAvgZ = 0, ltTopZ = 0;
@ -276,18 +278,11 @@ namespace Server.Regions
bool ltImpassable = ( (ltFlags & TileFlag.Impassable) != 0 ); bool ltImpassable = ( (ltFlags & TileFlag.Impassable) != 0 );
if ( !lt.Ignored && ltAvgZ >= minZ && ltAvgZ < maxZ ) if ( !lt.Ignored && ltAvgZ >= minZ && ltAvgZ < maxZ )
{
if ( (ltFlags & TileFlag.Wet) != 0 ) if ( (ltFlags & TileFlag.Wet) != 0 )
{
if ( water ) if ( water )
m_Buffer1.Add( ltAvgZ ); m_SpawnBuffer1.Add( ltAvgZ );
}
else if ( land && !ltImpassable ) else if ( land && !ltImpassable )
{ m_SpawnBuffer1.Add( ltAvgZ );
m_Buffer1.Add( ltAvgZ );
}
}
Tile[] staticTiles = map.Tiles.GetStaticTiles( x, y, true ); Tile[] staticTiles = map.Tiles.GetStaticTiles( x, y, true );
@ -298,17 +293,11 @@ namespace Server.Regions
int tileZ = tile.Z + id.CalcHeight; int tileZ = tile.Z + id.CalcHeight;
if ( tileZ >= minZ && tileZ < maxZ ) if ( tileZ >= minZ && tileZ < maxZ )
{
if ( (id.Flags & TileFlag.Wet) != 0 ) if ( (id.Flags & TileFlag.Wet) != 0 )
{
if ( water ) if ( water )
m_Buffer1.Add( tileZ ); m_SpawnBuffer1.Add( tileZ );
}
else if ( land && id.Surface && !id.Impassable ) else if ( land && id.Surface && !id.Impassable )
{ m_SpawnBuffer1.Add( tileZ );
m_Buffer1.Add( tileZ );
}
}
} }
@ -320,7 +309,7 @@ namespace Server.Regions
if ( item.ItemID < 0x4000 && item.AtWorldPoint( x, y ) ) if ( item.ItemID < 0x4000 && item.AtWorldPoint( x, y ) )
{ {
m_Buffer2.Add( item ); m_SpawnBuffer2.Add( item );
if ( !item.Movable ) if ( !item.Movable )
{ {
@ -328,26 +317,20 @@ namespace Server.Regions
int itemZ = item.Z + id.CalcHeight; int itemZ = item.Z + id.CalcHeight;
if ( itemZ >= minZ && itemZ < maxZ ) if ( itemZ >= minZ && itemZ < maxZ )
{
if ( (id.Flags & TileFlag.Wet) != 0 ) if ( (id.Flags & TileFlag.Wet) != 0 )
{
if ( water ) if ( water )
m_Buffer1.Add( itemZ ); m_SpawnBuffer1.Add( itemZ );
}
else if ( land && id.Surface && !id.Impassable ) else if ( land && id.Surface && !id.Impassable )
{ m_SpawnBuffer1.Add( itemZ );
m_Buffer1.Add( itemZ );
}
}
} }
} }
} }
if ( m_Buffer1.Count == 0 ) if ( m_SpawnBuffer1.Count == 0 )
{ {
m_Buffer1.Clear(); m_SpawnBuffer1.Clear();
m_Buffer2.Clear(); m_SpawnBuffer2.Clear();
continue; continue;
} }
@ -358,9 +341,9 @@ namespace Server.Regions
{ {
z = int.MaxValue; z = int.MaxValue;
for ( int j = 0; j < m_Buffer1.Count; j++ ) for ( int j = 0; j < m_SpawnBuffer1.Count; j++ )
{ {
int l = (int) m_Buffer1[j]; int l = m_SpawnBuffer1[j];
if ( l < z ) if ( l < z )
z = l; z = l;
@ -372,9 +355,9 @@ namespace Server.Regions
{ {
z = int.MinValue; z = int.MinValue;
for ( int j = 0; j < m_Buffer1.Count; j++ ) for ( int j = 0; j < m_SpawnBuffer1.Count; j++ )
{ {
int l = (int) m_Buffer1[j]; int l = m_SpawnBuffer1[j];
if ( l > z ) if ( l > z )
z = l; z = l;
@ -384,29 +367,28 @@ namespace Server.Regions
} }
default: // SpawnZLevel.Random default: // SpawnZLevel.Random
{ {
int index = Utility.Random( m_Buffer1.Count ); int index = Utility.Random( m_SpawnBuffer1.Count );
z = (int) m_Buffer1[index]; z = m_SpawnBuffer1[index];
break; break;
} }
} }
m_Buffer1.Clear(); m_SpawnBuffer1.Clear();
if ( !Region.Find( new Point3D( x, y, z ), map ).AcceptsSpawnsFrom( this ) ) if ( !Region.Find( new Point3D( x, y, z ), map ).AcceptsSpawnsFrom( this ) )
{ {
m_Buffer2.Clear(); m_SpawnBuffer2.Clear();
continue; continue;
} }
int top = z + spawnHeight; int top = z + spawnHeight;
bool ok = true; bool ok = true;
for ( int j = 0; j < m_Buffer2.Count; j++ ) for ( int j = 0; j < m_SpawnBuffer2.Count; j++ )
{ {
Item item = (Item) m_Buffer2[j]; Item item = m_SpawnBuffer2[j];
ItemData id = item.ItemData; ItemData id = item.ItemData;
if ( ( id.Surface || id.Impassable ) && item.Z + id.CalcHeight > z && item.Z < top ) if ( ( id.Surface || id.Impassable ) && item.Z + id.CalcHeight > z && item.Z < top )
@ -416,16 +398,14 @@ namespace Server.Regions
} }
} }
m_Buffer2.Clear(); m_SpawnBuffer2.Clear();
if ( !ok ) if ( !ok )
continue; continue;
if ( ltImpassable && ltAvgZ > z && ltLowZ < top ) if ( ltImpassable && ltAvgZ > z && ltLowZ < top )
continue; continue;
for ( int j = 0; j < staticTiles.Length; j++ ) for ( int j = 0; j < staticTiles.Length; j++ )
{ {
Tile tile = staticTiles[j]; Tile tile = staticTiles[j];
@ -441,22 +421,18 @@ namespace Server.Regions
if ( !ok ) if ( !ok )
continue; continue;
for ( int j = 0; j < sector.Mobiles.Count; j++ ) for ( int j = 0; j < sector.Mobiles.Count; j++ )
{ {
Mobile m = (Mobile) sector.Mobiles[j]; Mobile m = sector.Mobiles[j];
if ( m.X == x && m.Y == y && ( m.AccessLevel == AccessLevel.Player || !m.Hidden ) ) if ( m.X == x && m.Y == y && ( m.AccessLevel == AccessLevel.Player || !m.Hidden ) )
{
if ( m.Z + 16 > z && m.Z < top ) if ( m.Z + 16 > z && m.Z < top )
{ {
ok = false; ok = false;
break; break;
} }
}
} }
if ( ok ) if ( ok )
return new Point3D( x, y, z ); return new Point3D( x, y, z );
} }

View file

@ -1,5 +1,5 @@
using System; using System;
using System.Collections; using System.Collections.Generic;
using Server.Network; using Server.Network;
using Server.Items; using Server.Items;
using Server.Engines.CannedEvil; using Server.Engines.CannedEvil;
@ -67,13 +67,11 @@ namespace Server.Spells.Necromancy
if( map != null ) if( map != null )
{ {
ArrayList targets = new ArrayList(); List<Mobile> targets = new List<Mobile>();
foreach( Mobile m in r.ChampionSpawn.GetMobilesInRange( Range ) ) foreach( Mobile m in r.ChampionSpawn.GetMobilesInRange( Range ) )
{
if( IsValidTarget( m ) ) if( IsValidTarget( m ) )
targets.Add( m ); targets.Add( m );
}
//Effects.PlaySound( Caster.Location, map, 0x1FB ); //Effects.PlaySound( Caster.Location, map, 0x1FB );
//Effects.PlaySound( Caster.Location, map, 0x10B ); //Effects.PlaySound( Caster.Location, map, 0x10B );
@ -81,7 +79,7 @@ namespace Server.Spells.Necromancy
for( int i = 0; i < targets.Count; ++i ) for( int i = 0; i < targets.Count; ++i )
{ {
Mobile m = (Mobile)targets[i]; Mobile m = targets[i];
//m.FixedParticles( 0x374A, 1, 15, 9502, 97, 3, (EffectLayer)255 ); //m.FixedParticles( 0x374A, 1, 15, 9502, 97, 3, (EffectLayer)255 );

View file

@ -1,5 +1,5 @@
using System; using System;
using System.Collections; using System.Collections.Generic;
using Server.Network; using Server.Network;
using Server.Items; using Server.Items;
using Server.Targeting; using Server.Targeting;
@ -52,17 +52,15 @@ namespace Server.Spells.Necromancy
if ( map != null ) if ( map != null )
{ {
ArrayList targets = new ArrayList(); List<Mobile> targets = new List<Mobile>();
foreach ( Mobile targ in m.GetMobilesInRange( 2 ) ) foreach ( Mobile targ in m.GetMobilesInRange( 2 ) )
{
if ( (Caster == targ || SpellHelper.ValidIndirectTarget( Caster, targ )) && Caster.CanBeHarmful( targ, false ) ) if ( (Caster == targ || SpellHelper.ValidIndirectTarget( Caster, targ )) && Caster.CanBeHarmful( targ, false ) )
targets.Add( targ ); targets.Add( targ );
}
for ( int i = 0; i < targets.Count; ++i ) for ( int i = 0; i < targets.Count; ++i )
{ {
Mobile targ = (Mobile)targets[i]; Mobile targ = targets[i];
int num; int num;

View file

@ -1,5 +1,5 @@
using System; using System;
using System.Collections; using System.Collections.Generic;
using Server.Network; using Server.Network;
using Server.Items; using Server.Items;
using Server.Targeting; using Server.Targeting;
@ -39,13 +39,11 @@ namespace Server.Spells.Necromancy
if ( map != null ) if ( map != null )
{ {
ArrayList targets = new ArrayList(); List<Mobile> targets = new List<Mobile>();
foreach ( Mobile m in Caster.GetMobilesInRange( 5 ) ) foreach ( Mobile m in Caster.GetMobilesInRange( 5 ) )
{
if ( Caster != m && Caster.InLOS( m ) && SpellHelper.ValidIndirectTarget( Caster, m ) && Caster.CanBeHarmful( m, false ) ) if ( Caster != m && Caster.InLOS( m ) && SpellHelper.ValidIndirectTarget( Caster, m ) && Caster.CanBeHarmful( m, false ) )
targets.Add( m ); targets.Add( m );
}
Effects.PlaySound( Caster.Location, map, 0x1FB ); Effects.PlaySound( Caster.Location, map, 0x1FB );
Effects.PlaySound( Caster.Location, map, 0x10B ); Effects.PlaySound( Caster.Location, map, 0x10B );
@ -53,7 +51,7 @@ namespace Server.Spells.Necromancy
for ( int i = 0; i < targets.Count; ++i ) for ( int i = 0; i < targets.Count; ++i )
{ {
Mobile m = (Mobile)targets[i]; Mobile m = targets[i];
Caster.DoHarmful( m ); Caster.DoHarmful( m );
m.FixedParticles( 0x374A, 1, 15, 9502, 97, 3, (EffectLayer)255 ); m.FixedParticles( 0x374A, 1, 15, 9502, 97, 3, (EffectLayer)255 );

View file

@ -1,5 +1,5 @@
using System; using System;
using System.Collections; using System.Collections.Generic;
using Server.Network; using Server.Network;
using Server.Items; using Server.Items;
using Server.Targeting; using Server.Targeting;
@ -44,7 +44,7 @@ namespace Server.Spells.Seventh
if ( p is Item ) if ( p is Item )
p = ((Item)p).GetWorldLocation(); p = ((Item)p).GetWorldLocation();
ArrayList targets = new ArrayList(); List<Mobile> targets = new List<Mobile>();
Map map = Caster.Map; Map map = Caster.Map;
@ -90,7 +90,7 @@ namespace Server.Spells.Seventh
for ( int i = 0; i < targets.Count; ++i ) for ( int i = 0; i < targets.Count; ++i )
{ {
Mobile m = (Mobile)targets[i]; Mobile m = targets[i];
double toDeal = damage; double toDeal = damage;

View file

@ -1,5 +1,5 @@
using System; using System;
using System.Collections; using System.Collections.Generic;
using Server.Misc; using Server.Misc;
using Server.Network; using Server.Network;
using Server.Items; using Server.Items;
@ -42,7 +42,7 @@ namespace Server.Spells.Seventh
SpellHelper.GetSurfaceTop( ref p ); SpellHelper.GetSurfaceTop( ref p );
ArrayList targets = new ArrayList(); List<Mobile> targets = new List<Mobile>();
Map map = Caster.Map; Map map = Caster.Map;
@ -51,17 +51,15 @@ namespace Server.Spells.Seventh
IPooledEnumerable eable = map.GetMobilesInRange( new Point3D( p ), 8 ); IPooledEnumerable eable = map.GetMobilesInRange( new Point3D( p ), 8 );
foreach ( Mobile m in eable ) foreach ( Mobile m in eable )
{
if ( m is BaseCreature && (m as BaseCreature).IsDispellable && Caster.CanBeHarmful( m, false ) ) if ( m is BaseCreature && (m as BaseCreature).IsDispellable && Caster.CanBeHarmful( m, false ) )
targets.Add( m ); targets.Add( m );
}
eable.Free(); eable.Free();
} }
for ( int i = 0; i < targets.Count; ++i ) for ( int i = 0; i < targets.Count; ++i )
{ {
Mobile m = (Mobile)targets[i]; Mobile m = targets[i];
BaseCreature bc = m as BaseCreature; BaseCreature bc = m as BaseCreature;

View file

@ -1,5 +1,5 @@
using System; using System;
using System.Collections; using System.Collections.Generic;
using Server.Network; using Server.Network;
using Server.Items; using Server.Items;
using Server.Targeting; using Server.Targeting;
@ -44,7 +44,7 @@ namespace Server.Spells.Seventh
if ( p is Item ) if ( p is Item )
p = ((Item)p).GetWorldLocation(); p = ((Item)p).GetWorldLocation();
ArrayList targets = new ArrayList(); List<Mobile> targets = new List<Mobile>();
Map map = Caster.Map; Map map = Caster.Map;
@ -89,7 +89,7 @@ namespace Server.Spells.Seventh
for ( int i = 0; i < targets.Count; ++i ) for ( int i = 0; i < targets.Count; ++i )
{ {
Mobile m = (Mobile)targets[i]; Mobile m = targets[i];
double toDeal = damage; double toDeal = damage;

View file

@ -642,13 +642,13 @@ namespace Server.Items
{ {
Item[] typedItems = FindItemsByType( types[i], recurse ); Item[] typedItems = FindItemsByType( types[i], recurse );
ArrayList groups = new ArrayList(); List<List<Item>> groups = new List<List<Item>>();
int idx = 0; int idx = 0;
while ( idx < typedItems.Length ) while ( idx < typedItems.Length )
{ {
Item a = typedItems[idx++]; Item a = typedItems[idx++];
ArrayList group = new ArrayList(); List<Item> group = new List<Item>();
group.Add( a ); group.Add( a );
@ -675,7 +675,7 @@ namespace Server.Items
for ( int j = 0; j < groups.Count; ++j ) for ( int j = 0; j < groups.Count; ++j )
{ {
items[i][j] = (Item[])(((ArrayList)groups[j]).ToArray( typeof( Item ) )); items[i][j] = groups[j].ToArray();
for ( int k = 0; k < items[i][j].Length; ++k ) for ( int k = 0; k < items[i][j].Length; ++k )
totals[i][j] += items[i][j][k].Amount; totals[i][j] += items[i][j][k].Amount;

View file

@ -536,34 +536,26 @@ namespace Server
} }
} }
public ArrayList GetTilesAt( Point2D p, bool items, bool land, bool statics ) public List<Tile> GetTilesAt( Point2D p, bool items, bool land, bool statics )
{ {
ArrayList list = new ArrayList(); List<Tile> list = new List<Tile>();
if ( this == Map.Internal ) if ( this == Map.Internal )
return list; return list;
if ( land ) if ( land )
{
list.Add( Tiles.GetLandTile( p.m_X, p.m_Y ) ); list.Add( Tiles.GetLandTile( p.m_X, p.m_Y ) );
}
if ( statics ) if ( statics )
{
list.AddRange( Tiles.GetStaticTiles( p.m_X, p.m_Y, true ) ); list.AddRange( Tiles.GetStaticTiles( p.m_X, p.m_Y, true ) );
}
if ( items ) if ( items )
{ {
Sector sector = GetSector( p ); Sector sector = GetSector( p );
foreach ( Item item in sector.Items ) foreach ( Item item in sector.Items )
{
if ( item.AtWorldPoint( p.m_X, p.m_Y ) ) if ( item.AtWorldPoint( p.m_X, p.m_Y ) )
{
list.Add( new Tile( (short) ( ( item.ItemID & 0x3FFF ) + 0x4000 ), (sbyte) item.Z ) ); list.Add( new Tile( (short) ( ( item.ItemID & 0x3FFF ) + 0x4000 ), (sbyte) item.Z ) );
}
}
} }
return list; return list;