[HELP] Error

05/28/2009 01:52 Pete1990#1
Ok yes im useing LOTF but this error is starting to get old now iv tried to fix it but wont work? maybe soemone else can tell me how to here is the error
at COServer_Project.World.SurroundDroppedItems(Charac ter Me, Boolean Check) in C:\Dex~Co\COServerProjectv1\COServerProject\World. cs:line 388
at COServer_Project.Client.GetPacket(Byte[] data) in C:\Dex~Co\COServerProjectv1\COServerProject\Client .cs:line 9852
System.InvalidOperationException: Collection was modified; enumeration operation may not execute.
at System.Collections.Hashtable.HashtableEnumerator.M oveNext()

Here is the code
HTML Code:
        public static void SurroundDroppedItems(Character Me, bool Check)
        {
            foreach (DictionaryEntry DE in DroppedItems.AllDroppedItems)
            {
                DroppedItem item = (DroppedItem)DE.Value;

                if (item.Map == Me.LocMap)
                    if (MyMath.CanSee(Me.LocX, Me.LocY, item.X, item.Y))
                        if (!MyMath.CanSee(Me.PrevX, Me.PrevY, item.X, item.Y) || Check == false)
                        {
                            Me.MyClient.SendPacket(General.MyPackets.ItemDrop(item.UID, item.ItemId, item.X, item.Y));
                        }
            }
        }
05/28/2009 02:03 Zeroxelli#2
Looks like you're trying to directly modify the enumeration, you'd have to modify the data in a different way for it to work.

Also, use something like IList<> or List<> :p
05/28/2009 02:04 Pete1990#3
Well i was thinking just thinking if this is missing it could mess it up right?
try
{

}
catch (Exception Exc) { General.WriteLine(Exc.ToString()); }
}
05/28/2009 02:07 damianpesta#4
Quote:
Originally Posted by Pete1990 View Post
Well i was thinking just thinking if this is missing it could mess it up right?
try
{

}
catch (Exception Exc) { General.WriteLine(Exc.ToString()); }
}
too many exceptions gonna do really bad.So try not to use them as much.
05/28/2009 04:37 PeTe Ninja#5
what did you try to do when the error came up?

Code:
        public static void SurroundDroppedItems(Character Me, bool Check)
        {
            foreach (DictionaryEntry DE in DroppedItems.AllDroppedItems)
            {
                DroppedItem item = (DroppedItem)DE.Value;

                if (item.Map == Me.LocMap)
                    if (MyMath.CanSee(Me.LocX, Me.LocY, item.X, item.Y))
                        if (!MyMath.CanSee(Me.PrevX, Me.PrevY, item.X, item.Y) || Check == false)
                        {
                            Me.MyClient.SendPacket(General.MyPackets.ItemDrop(item.UID, item.ItemId, item.X, item.Y));
                        }
            }
        }
thats mine.
05/28/2009 04:38 Pete1990#6
Same Thing as mine:)