EnumVisibleObjects problem menu

Shout-Out

User Tag List

Page 6 of 8 FirstFirst ... 2345678 LastLast
Results 76 to 90 of 113
  1. #76
    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)
    The problem with the Linq in the first place was just because of delayed execution. That means it is actually yield returning inside the Linq expression, which causes it to generate the collection modified exception. The safest way to solve this problem is either by iterating it yourself or by calling IEnumerable.ToList on returned IEnumerable<WoWObject> from the Linq expression.
    The fix you use, TOM_RUS, only works because of the 'ToArray' - you don't have to select 'o.Key'.
    [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

    EnumVisibleObjects problem
  2. #77
    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
    The fix you use, TOM_RUS, only works because of the 'ToArray' - you don't have to select 'o.Key'.
    Fix was taken from original thread and works fine: http://www.mmowned.com/forums/wow-me...ml#post1767140

  3. #78
    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
    Fix was taken from original thread and works fine: http://www.mmowned.com/forums/wow-me...ml#post1767140
    I know, where have I said it didn't?
    [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

  4. #79
    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)
    Code:
        public static class LinqExtensions
        {
            public static Dictionary<K, V> RemoveAll<K, V>(this Dictionary<K, V> dict, Predicate<V> predicate)
            {
                foreach (var kvp in dict.Where(_kvp => predicate(_kvp.Value)).ToArray())
                    dict.Remove(kvp.Key);
    
                return dict;
            }
        }
    There. Now Dictionary<K, V> has a RemoveAll<V>(Predicate<V>) function.

    For extra credit, you can add a key value pair version that lets you select based upon the keys, too, although this is probably useless for ObjectManager.

    For your use:

    myObjects.RemoveAll(o => !o.IsValid)

    Nothing magical there.

    Edit: edited it to return the dictionary instead of void; that way you can keep chaining it in LINQ calls if you want.
    Last edited by amadmonk; 03-03-2010 at 04:32 PM.
    Don't believe everything you think.

  5. #80
    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)
    That means that EnumVisibleObjects also doesn't work properly. Try to dig it.
    no it doesn't. I get a complete list of guids from the function. I can't check them of cause but i'm pretty sure it is right. but when i call getobjbyguid it always returns 0

  6. #81
    flo8464's Avatar Active Member
    Reputation
    30
    Join Date
    Apr 2009
    Posts
    434
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by YetiHunter View Post
    no it doesn't. I get a complete list of guids from the function. I can't check them of cause but i'm pretty sure it is right. but when i call getobjbyguid it always returns 0
    Maybe you are calling the filtered Version with a invalid filter?
    Hey, it compiles! Ship it!

  7. #82
    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 calling with -1. everything else crashes wow but i can't figure out y..

  8. #83
    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 just can't get getObjectbyGuid function to work =/. is there an alternative? the only thing i could think of would be searching for the guid in memory and having a "negative" offset to the object pointer but i think that would be inefficient and i could iterate through the objectlist manually instead of using enumvisobj and it would be the same. does anyone have a suggestion ?

  9. #84
    !@^^@!'s Avatar Active Member
    Reputation
    23
    Join Date
    Feb 2007
    Posts
    155
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    isen't that exactly the point why we store them in a dictionary so we can use
    Code:
     Objects[YourGUID]
    ?

  10. #85
    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)
    of cause but i'm using the enumVisibleObjects function which returns the guid, and since the guid to pointer function does not work i can't access the the object information by just adding the offsets, because i have no baseadress

  11. #86
    adaephon's Avatar Active Member
    Reputation
    76
    Join Date
    May 2009
    Posts
    167
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What is your function definition for GetObjectByGuid and what offset are you using? The following (approximate) code works fine for me:

    Delegate:
    Code:
            [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
            private delegate IntPtr ClntObjMgrGetObjectPtrDelegate(ulong guid, int filter);
    Offset:
    Code:
    getObjectPtrFunc = (ClntObjMgrGetObjectPtrDelegate)Marshal.GetDelegateForFunctionPointer(new IntPtr(0x0047BBC0), typeof(ClntObjMgrGetObjectPtrDelegate));

  12. #87
    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 using apocs whitemagic with:
    [CODE]
    ClntObjMgrGetObjectPtrWoW = Main.m.RegisterDelegate<ClntObjMgrGetObjectPtrDelegate>((uint)Offsets.ClntObjMgr ObjectPtr);

    [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
    private delegate IntPtr ClntObjMgrGetObjectPtrDelegate(ulong guid, int filter);

    ClntObjMgrObjectPtr = 0x0047BBC0
    [\CODE]
    Last edited by YetiHunter; 03-13-2010 at 09:47 AM.

  13. #88
    adaephon's Avatar Active Member
    Reputation
    76
    Join Date
    May 2009
    Posts
    167
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well it's very difficult to diagnose your problem when you claim you're doing everything right and aren't providing any additional information. Post more code / information and we might have more of a chance of helping. Presumably you are calling it something like
    Code:
    IntPtr obj = ClntObjMgrGetObjectPtrWoW(guid, -1);
    from within EnumVisibleObjects?

    Have you ensured that EnumVisibleObjects works? Have you tried logging out just a list of GUIDs without calling GetObjectByGuid to ensure you are getting valid GUIDs? Have you tried using a try { ... } catch { ... } in the crashing situations to see if it is a non fatal exception that you can log out?

  14. #89
    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)
    sorry was in a hurry when i posted the first answer.
    Code:
        public unsafe class ObjectManager
        {
            #region private stuff
            private static readonly EnumObjectsCallbackDelegate Callback;
            private static readonly IntPtr CallbackPtr;
            private static readonly ClntObjMgrGetObjectPtrDelegate ClntObjMgrGetObjectPtrWoW;
            private static readonly EnumVisibleObjectsDelegate EnumObjs;
            private static readonly ClntObjMgrGetActivePlayerDelegate GetActivePlayerDelegate;
            private static readonly Dictionary<ulong, WoWObject> RealObjects = new Dictionary<ulong, WoWObject>();
            #endregion
    
            internal static ActivePlayer Me { get; private set; }
            internal static List<WoWObject> ObjectList { get { return RealObjects.Values.Where(o => o.IsValid).ToList(); } }
            
            static ObjectManager()
            {
                Me = new ActivePlayer(IntPtr.Zero);
                Callback = EnumObjectsCallbackHandler;
                CallbackPtr = Marshal.GetFunctionPointerForDelegate(Callback);
                GetActivePlayerDelegate = Main.m.RegisterDelegate<ClntObjMgrGetActivePlayerDelegate>((uint)Offsets.ClntObjMgrGetActivePlayer);
                EnumObjs = Main.m.RegisterDelegate<EnumVisibleObjectsDelegate>((uint)Offsets.EnumVisibleObjects);
                ClntObjMgrGetObjectPtrWoW = Main.m.RegisterDelegate<ClntObjMgrGetObjectPtrDelegate>((uint)Offsets.ClntObjMgrObjectPtr);
            }
    
            internal static ulong ActivePlayer
            { get { return GetActivePlayerDelegate(); } }
            public static bool IsInWorld
            { get { return ActivePlayer != (ulong)IntPtr.Zero; } }
    
            public static void Pulse()
            {
                if (Me == IntPtr.Zero)
                {
                    Me = ClntObjMgrGetActivePlayerWow();
                    ObjectList.Add(Me);
                }
    
                foreach (WoWObject o in RealObjects.Values)
                { o.UpdateObjectPointer(IntPtr.Zero); }
               
                EnumObjs(CallbackPtr, 0);
             
                if (Main._frameCounter % 10 == 0)
                    RemoveInvalidEntries();
            }
            private static void RemoveInvalidEntries()
            {
                var guids = (from o in RealObjects where !o.Value.IsValid select o.Key).ToArray();
                foreach (var guid in guids)
                    RealObjects.Remove(guid);
                //IEnumerable<KeyValuePair<ulong, WoWObject>> r = from o in RealObjects where !o.Value.IsValid select o;
                //foreach (var pair in r)
                //{
                //    RealObjects.Remove(pair.Key);
                //}
            }
    
            private static int EnumObjectsCallbackHandler(ulong guid, int filter)
            {
                IntPtr objPtr = InternalGetObjectByGuid(guid);
                
                if (!RealObjects.ContainsKey(guid))
                {
                    var tmp = new WoWObject(objPtr);
    
                    switch (tmp.Type)
                    {
                        case ObjectType.Item:
                            tmp = new Item(objPtr);
                            break;
                        case ObjectType.Container:
                            tmp = new Container(objPtr);
                            break;
                        case ObjectType.Unit:
                            tmp = new Unit(objPtr);
                            break;
                        case ObjectType.Player:
                            tmp = new Player(objPtr);
                            break;
                        case ObjectType.GameObject:
                            tmp = new GameObject(objPtr);
                            break;
                        case ObjectType.Corpse:
                            tmp = new Corpse(objPtr);
                            break;
                        default:
                            return 1;
                    }
    
                    RealObjects.Add(guid, tmp);
                }
                else if (RealObjects[guid] != objPtr)
                { RealObjects[guid].UpdateObjectPointer(objPtr); }
                return 1;
            }
    
            internal static WoWObject GetObjectByGuid(ulong guid)
            {
                WoWObject ret;
                RealObjects.TryGetValue(guid, out ret);
    
                return ret ?? new WoWObject(IntPtr.Zero);
            }
    
            internal static IntPtr InternalGetObjectByGuid(ulong guid)
            { return ClntObjMgrGetObjectPtrWoW(guid, -1); }
    
            internal static ActivePlayer ClntObjMgrGetActivePlayerWow()
            { return new ActivePlayer(GetObjectByGuid(GetActivePlayerDelegate())); }
           
            
            #region delegates
            #region Nested type: ClntObjMgrGetActivePlayerDelegate
    
            [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
            private delegate ulong ClntObjMgrGetActivePlayerDelegate();
    
            #endregion
    
            #region Nested type: ClntObjMgrGetObjectPtrDelegate
    
            [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
            private delegate IntPtr ClntObjMgrGetObjectPtrDelegate(ulong guid, int filter);
    
            #endregion
    
            #region Nested type: EnumObjectsCallback
    
            [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
            private delegate int EnumObjectsCallbackDelegate(ulong guid, int filter);
    
            #endregion       
    
            #region Nested type: EnumVisibleObjectsDelegate
            [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
            private delegate int EnumVisibleObjectsDelegate(IntPtr callback, int filter);
            #endregion
            #endregion
        }
    }
    this is my complete code for the objectmanager. i get a list of guids out of it and with try {} catch {} it doesn't crash anymore is i filter for anything else than -1

  15. #90
    Cromon's Avatar Legendary


    Reputation
    840
    Join Date
    Mar 2008
    Posts
    714
    Thanks G/R
    0/7
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Are you sure about that:
    Code:
     [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
            private delegate IntPtr ClntObjMgrGetObjectPtrDelegate(ulong guid, int filter);
    Im using:
    Code:
    typedef DWORD (__cdecl* tGetObjectByGUID)(UINT64);
    and i get correct offsets to the objects in the EnumVisibleObjects-Callback.

Page 6 of 8 FirstFirst ... 2345678 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 09:20 AM. 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