EnumVisibleObjects problem menu

Shout-Out

User Tag List

Page 5 of 8 FirstFirst 12345678 LastLast
Results 61 to 75 of 113
  1. #61
    TOM_RUS's Avatar Legendary
    Reputation
    914
    Join Date
    May 2008
    Posts
    699
    Thanks G/R
    0/52
    Trade Feedback
    0 (0%)
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Robske View Post

    Haven't looked at the original code but I assume it's because ForEach cannot iterate over a modified collection.
    Exactly that.

    Originally Posted by skra View Post
    well that doesn't change anything about the fact that there are no objects getting stored in that list i changed it so it'll work when there are objects in it, but all the functions, the activeplayer as well as the enum objects funktion, are returning nothing.
    Are you sure that Pulse() method being called at all? Try to put some logging methods inside and check that it's being called.
    Last edited by TOM_RUS; 03-01-2010 at 12:08 PM.

    EnumVisibleObjects problem
  2. #62
    MaiN's Avatar Elite User
    Reputation
    335
    Join Date
    Sep 2006
    Posts
    1,047
    Thanks G/R
    0/10
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by TOM_RUS View Post
    Exactly that.
    And where again is he modifying the iterating collection?
    [16:15:41] Cypher: caus the CPU is a dick
    [16:16:07] kynox: CPU is mad
    [16:16:15] Cypher: CPU is all like
    [16:16:16] Cypher: whatever, i do what i want

  3. #63
    TOM_RUS's Avatar Legendary
    Reputation
    914
    Join Date
    May 2008
    Posts
    699
    Thanks G/R
    0/52
    Trade Feedback
    0 (0%)
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by MaiN View Post
    And where again is he modifying the iterating collection?
    No idea, but it's throwing exceptions :P I tested his code and it fails here.

  4. #64
    MaiN's Avatar Elite User
    Reputation
    335
    Join Date
    Sep 2006
    Posts
    1,047
    Thanks G/R
    0/10
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by TOM_RUS View Post
    No idea, but it's throwing exceptions :P I tested his code and it fails here.
    There shouldn't. What was the exception?
    [16:15:41] Cypher: caus the CPU is a dick
    [16:16:07] kynox: CPU is mad
    [16:16:15] Cypher: CPU is all like
    [16:16:16] Cypher: whatever, i do what i want

  5. #65
    TOM_RUS's Avatar Legendary
    Reputation
    914
    Join Date
    May 2008
    Posts
    699
    Thanks G/R
    0/52
    Trade Feedback
    0 (0%)
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by MaiN View Post
    There shouldn't. What was the exception?
    System.InvalidOperationException was unhandled
    Message="Collection was modified; enumeration operation may not execute."

  6. #66
    YetiHunter's Avatar Member
    Reputation
    6
    Join Date
    Aug 2006
    Posts
    57
    Thanks G/R
    0/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    curiously i have the exact same problem at the moment and i've been following the thread
    Originally Posted by TOM_RUS View Post
    Are you sure that Pulse() method being called at all? Try to put some logging methods inside and check that it's being called.
    that is interesting. like suggested im checking if i'm in world
    Code:
                if (ObjectManager.IsInWorld)
                    ObjectManager.Pulse();
    IsInWorld returns false, but the objectmanager.pulse() method is still called. i just put a 1 second sleep in there and the game starts "lagging" ...
    Last edited by YetiHunter; 03-01-2010 at 02:43 PM.

  7. #67
    MaiN's Avatar Elite User
    Reputation
    335
    Join Date
    Sep 2006
    Posts
    1,047
    Thanks G/R
    0/10
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by TOM_RUS View Post
    System.InvalidOperationException was unhandled
    Message="Collection was modified; enumeration operation may not execute."
    Well, that I didn't see coming.. I find that very strange. Oh well.
    [16:15:41] Cypher: caus the CPU is a dick
    [16:16:07] kynox: CPU is mad
    [16:16:15] Cypher: CPU is all like
    [16:16:16] Cypher: whatever, i do what i want

  8. #68
    Nesox's Avatar ★ Elder ★
    Reputation
    1280
    Join Date
    Mar 2007
    Posts
    1,238
    Thanks G/R
    0/3
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    do something like that, iterate it backwards and use RemoveAt and it shouldn't throw the InvalidOperationException.
    That's just a poor example don't think it will work properly but you get the idea (do it backwards)

    Code:
     private static void RemoveInvalidEntries()
            {
                var guids = (from o in RealObjects
                             where !o.Value.IsValid
                             select o.Key).ToArray();
    
                for(int i = guids.Length - 1; i >= 0; i--)
                { 
                    RealObjects.RemoveAt(i);
                }
            }

  9. #69
    Robske's Avatar Contributor
    Reputation
    305
    Join Date
    May 2007
    Posts
    1,062
    Thanks G/R
    3/4
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Nesox View Post
    do something like that, iterate it backwards and use RemoveAt and it shouldn't throw the InvalidOperationException.
    That's just a poor example don't think it will work properly but you get the idea (do it backwards)

    Code:
     private static void RemoveInvalidEntries()
            {
                var guids = (from o in RealObjects
                             where !o.Value.IsValid
                             select o.Key).ToArray();
    
                for(int i = guids.Length - 1; i >= 0; i--)
                { 
                    RealObjects.RemoveAt(i);
                }
            }
    Well that's wrong. There's no guarantee that the (n-i)'th guid in your guids collection was the i'th guid in the RealObjects collection.

    Did you perhaps mean

    Code:
    RealObjects.Remove(guids[i]);
    ?
    "Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - Martin Golding
    "I cried a little earlier when I had to poop" - Sku

  10. #70
    YetiHunter's Avatar Member
    Reputation
    6
    Join Date
    Aug 2006
    Posts
    57
    Thanks G/R
    0/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i made a litte bit of progress. i was able to trace the problem to the get object by guid function. i get the guid, but the getObjByGuid funktion returns 0. the address is correct and if i try to filter for a type (for example players, so i use 4 as filter) it crashes. TOM_RUS mentioned something that the filter isn't actually a int if i understood correct but a pointer to an int. I tried it, but no success and no crashing. am i doing it wrong or is the pointerapproach wrong?

  11. #71
    Nesox's Avatar ★ Elder ★
    Reputation
    1280
    Join Date
    Mar 2007
    Posts
    1,238
    Thanks G/R
    0/3
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Robske View Post
    Well that's wrong. There's no guarantee that the (n-i)'th guid in your guids collection was the i'th guid in the RealObjects collection.

    Did you perhaps mean

    Code:
    RealObjects.Remove(guids[i]);
    ?
    No.
    If ure gonna modify a collection while iterating it you need to do it backwards otherwise you would change the size of it and cause the "System.InvalidOperationException was unhandled
    Message="Collection was modified; enumeration operation may not execute."excetion to get thrown,

    Code:
    var guids = (from o in ObjectManager.ObjectList
                 where !o.IsValid
                 select o).ToArray();
    
    for (int i = ObjectManager.ObjectList.Count - 1; i >= 0; i--)
    {
        if(guids.Contains(ObjectManager.ObjectList[i]))
            ObjectManager.ObjectList.RemoveAt(i);
    }

  12. #72
    amadmonk's Avatar Active Member
    Reputation
    124
    Join Date
    Apr 2008
    Posts
    772
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Erm... you guys DO know about List<T>.RemoveAll, right?

    List(T).RemoveAll Method (System.Collections.Generic)

    This neatly bypasses all of the "modified collection" issues by simply removing all items that match a predicate (o => !o.IsValid, in this case).

    Otherwise, to sidestep the modified collection issue, I usually just clone the input collection as a source for invalids (in other words: I have a list, Foo. I clone it and make Foo2. Then, for each "bad" item in Foo2, I remove the corresponding item from Foo). For small lists -- like the list of "bad" objects in WoW -- this is perfectly reasonable.

    Still, RemoveAll is better.
    Don't believe everything you think.

  13. #73
    suicidity's Avatar Contributor
    Reputation
    207
    Join Date
    Oct 2006
    Posts
    1,439
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Now I didn't read the thread; Just this last page..

    But why would anyone try iterating a list and try removing everything themselves? Do what amadmonk said, List.RemoveAll with a predicate that you want removed.


  14. #74
    YetiHunter's Avatar Member
    Reputation
    6
    Join Date
    Aug 2006
    Posts
    57
    Thanks G/R
    0/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i'm sorry to interrupt the discussion but does anyone know why my getObjByGuid function call is not working properly?

  15. #75
    TOM_RUS's Avatar Legendary
    Reputation
    914
    Join Date
    May 2008
    Posts
    699
    Thanks G/R
    0/52
    Trade Feedback
    0 (0%)
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    ObjectList isn't List. It's Dictionary and doesn't have RemoveAll implementation.
    I already posted solution on previous page: http://www.mmowned.com/forums/wow-me...ml#post1820129

    Originally Posted by YetiHunter View Post
    i'm sorry to interrupt the discussion but does anyone know why my getObjByGuid function call is not working properly?
    That means that EnumVisibleObjects also doesn't work properly. Try to dig it.
    Last edited by TOM_RUS; 03-03-2010 at 03:09 AM.

Page 5 of 8 FirstFirst 12345678 LastLast

Similar Threads

  1. Problem with CE.
    By Eldretch in forum World of Warcraft General
    Replies: 1
    Last Post: 08-08-2006, 06:49 PM
  2. realm list problem
    By robtuner in forum World of Warcraft General
    Replies: 2
    Last Post: 07-21-2006, 09:08 AM
  3. I have problem with BHW 3.0
    By sunrize1 in forum World of Warcraft General
    Replies: 1
    Last Post: 07-17-2006, 08:49 AM
  4. wow emu problem
    By bezike in forum World of Warcraft General
    Replies: 0
    Last Post: 07-09-2006, 04:45 PM
  5. Site problems
    By Shanaar in forum Community Chat
    Replies: 10
    Last Post: 05-14-2006, 01:15 AM
All times are GMT -5. The time now is 12:47 PM. Powered by vBulletin® Version 4.2.3
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Google Authenticator verification provided by Two-Factor Authentication (Free) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search