EnumVisibleObjects problem menu

Shout-Out

User Tag List

Page 4 of 8 FirstFirst 12345678 LastLast
Results 46 to 60 of 113
  1. #46
    !@^^@!'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)
    this is probably not the best way but delay the creation of your wpf window till endscene have been called once and copy that inptr? that's at least what im gonna try for now :P

    EnumVisibleObjects problem
  2. #47
    skra's Avatar Member
    Reputation
    1
    Join Date
    Apr 2009
    Posts
    33
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by !@^^@! View Post
    this is probably not the best way but delay the creation of your wpf window till endscene have been called once and copy that inptr? that's at least what im gonna try for now :P
    umm what intptr are you refering to?
    Last edited by skra; 02-27-2010 at 05:56 PM.

  3. #48
    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)
    try this:
    Code:
                if (!guiCreated)
                {
                    hash = Thread.CurrentThread.GetHashCode();
                    init_guiThread();
                    guiCreated = true;
                }
                if(hash == Thread.CurrentThread.GetHashCode())
                    globalPulse();
    thats the code i run in endscene. and globalPulse gets called every frame

  4. #49
    skra's Avatar Member
    Reputation
    1
    Join Date
    Apr 2009
    Posts
    33
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks works nice but i still get no usefull stuff for activeplayer or the enumobjdelegate =/

    and WOW resizing my wpf window doesn't crash wow anymore.. no idea y it did that in the first place Oo

  5. #50
    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)
    Originally Posted by skra View Post
    resizing doesn't crash wow anymore
    ROFL

  6. #51
    skra's Avatar Member
    Reputation
    1
    Join Date
    Apr 2009
    Posts
    33
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    alright, i triple checked my code and i can't find a logical reason why i don't get the objectlist or even the active player. I can do static readings for example the playername which shouldn't work if i'd be in the wpf endscene method, should it? So i'm in wow's mainthread, the addresses are correct and i can't find anything wrong about the delegates. has someone a hint for me?

  7. #52
    Apoc's Avatar Angry Penguin
    Reputation
    1388
    Join Date
    Jan 2008
    Posts
    2,750
    Thanks G/R
    0/13
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Reading/writing memory can be done from any thread, at any time.

    Calling engine functions usually need to be done from the main thread to avoid silly issues and whatnot.

  8. #53
    skra's Avatar Member
    Reputation
    1
    Join Date
    Apr 2009
    Posts
    33
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hmm ok but the functions i'm calling don't crash wow anymore. doesn't that mean that i'm calling them in the right spot?

  9. #54
    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)
    Post your code again. You probably did something wrong.

  10. #55
    skra's Avatar Member
    Reputation
    1
    Join Date
    Apr 2009
    Posts
    33
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks for looking over it again ^^ here it is:

    Code:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using Thor.Helper;
    using Thor.WoWObjects;
    using System.Runtime.InteropServices;
    using System.Diagnostics;
    
    namespace Thor
    {
        public static 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 = Thor_Main.m.RegisterDelegate<ClntObjMgrGetActivePlayerDelegate>((uint)Offsets.ClntObjMgrGetActivePlayer);
                EnumObjs = Thor_Main.m.RegisterDelegate<EnumVisibleObjectsDelegate>((uint)Offsets.EnumVisibleObjects);
                ClntObjMgrGetObjectPtrWoW = Thor_Main.m.RegisterDelegate<ClntObjMgrGetObjectPtrDelegate>((uint)Offsets.ClntObjMgrObjectPtr);
            }
    
            internal static ulong ActivePlayer
            { get { return GetActivePlayerDelegate(); } }
            public static bool IsInWorld
            { get { return ActivePlayer != 0; } }
    
            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 (Thor_Main._frameCounter % 10 == 0)
                { RemoveInvalidEntries(); }
    
            }
            private static void RemoveInvalidEntries()
            {
                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
        }
    }

  11. #56
    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)
    Code looks correct, except RemoveInvalidEntries(), which will throw exceptions. Replace it with:
    Code:
            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);
            }

  12. #57
    skra's Avatar Member
    Reputation
    1
    Join Date
    Apr 2009
    Posts
    33
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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.

  13. #58
    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
    Code looks correct, except RemoveInvalidEntries(), which will throw exceptions. Replace it with:
    Code:
            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);
            }
    Why would it throw exceptions?
    [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

  14. #59
    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 MaiN View Post
    Why would it throw exceptions?

    Haven't looked at the original code but I assume it's because ForEach cannot iterate over a modified collection.
    "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

  15. #60
    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 Robske View Post

    Haven't looked at the original code but I assume it's because ForEach cannot iterate over a modified collection.
    Code:
            private static void RemoveInvalidEntries()
            {
                IEnumerable<KeyValuePair<ulong, WoWObject>> r = from o in RealObjects where !o.Value.IsValid select o;
                foreach (var pair in r)
                {
                    RealObjects.Remove(pair.Key);
                }
            }
    The original code. It amazes me to see you write a post before you even use ctrl + F and search for "RemoveInvalidEntries" and check the code out - lazy ass. :P
    [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

Page 4 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