Exemplo n.º 1
0
 public void Unregister(PObject obj)
 {
     if (nameDict.ContainsKey(obj))
     {
         nameDict.Remove(obj);
     }
 }
Exemplo n.º 2
0
        public void TestFailure_from_long_string_should_produce_diff()
        {
            var obj1 = new PObject {
                Field    = "Item",
                Property = 420,
                Value    = new PValueObject(),
            };
            var obj2 = new PObject {
                Field    = "Different Item",
                Property = 999,
            };
            var subj    = new MemberwiseEqualMatcher <PObject>(obj1);
            var failure = TestMatcherLocalizer.Failure(subj, obj2);

            Assert.NotNull(failure.UserData.Diff);

            var diff = failure.UserData.Diff.ToString().Split(new [] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries);

            Assert.Equal(new [] { "@@@ -1,5 +1,5",
                                  " {",
                                  "-  Property = 420",
                                  "+  Property = 999",
                                  "@@@ -2,6 +2,6",
                                  "   Property = 420",
                                  "   Value = PValueObject {  }",
                                  "-  Field = Item",
                                  "+  Field = Different Item", }, diff); // last line contains } which is removed
        }
Exemplo n.º 3
0
        void TestExecuteTask(PDictionary input, PropertyListEditorAction action, string entry, string type, string value, PObject expected)
        {
            var task = CreateTask <PropertyListEditor> ();

            task.PropertyList = Path.Combine(Cache.CreateTemporaryDirectory(), "propertyList.plist");
            task.Action       = action.ToString();
            task.Entry        = entry;
            task.Type         = type;
            task.Value        = value;
            input.Save(task.PropertyList);

            if (expected == null)
            {
                Assert.IsFalse(task.Execute(), "Task was expected to fail.");
                return;
            }

            Assert.IsTrue(task.Execute(), "Task was expected to execute successfully.");

            var output = PObject.FromFile(task.PropertyList);

            Assert.AreEqual(expected.Type, output.Type, "Task produced the incorrect plist output.");

            CheckValue(output, expected);
        }
Exemplo n.º 4
0
		public ClosableExpander AddListItem (string name, Widget widget, PObject obj)
		{
			if (noContentLabel != null) {
				contentBox.Remove (noContentLabel);
				noContentLabel.Destroy ();
				noContentLabel = null;
			}
			
			var expander = new ClosableExpander ();
			expanders++;
			expander.ContentLabel = name;
			expander.SetWidget (widget);
			expander.BorderWidth = 4;
			expander.Closed += delegate(object sender, EventArgs e) {
				expanders--;
				var expanderWidget = (ClosableExpander)sender;
				obj.Remove ();
				contentBox.Remove (expanderWidget);
				expanderWidget.Destroy ();
				if (expanders == 0)
					Clear ();
			};
			contentBox.PackStart (expander, true, true, 0);
			contentBox.Show ();
			expander.Expanded = false;
			return expander;
		}
Exemplo n.º 5
0
 public PInjureTag(PPlayer FromPlayer, PPlayer ToPlayer, int Injure, PObject InjureSource) : base(TagName)
 {
     AppendField(FromPlayerFieldName, FromPlayer);
     AppendField(ToPlayerFieldName, ToPlayer);
     AppendField(InjureFieldName, Injure);
     AppendField(InjureSourceFieldName, InjureSource);
 }
Exemplo n.º 6
0
 /// <summary>添加到上传列表</summary>
 public void UL(PObject pObject, int slot)
 {
     lock (pobjectLists[slot])
     {
         pobjectLists[slot].Add(pObject);
     }
 }
Exemplo n.º 7
0
        void LogErrorsFromOutput(string output)
        {
            try {
                if (string.IsNullOrEmpty(output))
                {
                    return;
                }

                var plist   = PObject.FromString(output) as PDictionary;
                var errors  = PObject.Create(PObjectType.Array) as PArray;
                var message = PObject.Create(PObjectType.String) as PString;

                if ((plist?.TryGetValue("product-errors", out errors) == true))
                {
                    foreach (var error in errors)
                    {
                        var dict = error as PDictionary;
                        if (dict?.TryGetValue("message", out message) == true)
                        {
                            Log.LogError(ToolName, null, null, null, 0, 0, 0, 0, "{0}", message.Value);
                        }
                    }
                }
            } catch (Exception ex) {
                Log.LogWarning($"Failed to parse altool output: {ex.Message}. \nOutput: {output}");
            }
        }
Exemplo n.º 8
0
        bool Clear(ref PObject plist)
        {
            if (Type != null)
            {
                switch (Type.ToLowerInvariant())
                {
                case "string": plist = new PString(string.Empty); break;

                case "array": plist = new PArray(); break;

                case "dict": plist = new PDictionary(); break;

                case "bool": plist = new PBoolean(false); break;

                case "real": plist = new PReal(0); break;

                case "integer": plist = new PNumber(0); break;

                case "date": plist = new PDate(DateTime.Now); break;

                case "data": plist = new PData(new byte[1]); break;

                default:
                    Log.LogError(7045, null, $"Unrecognized Type: {Type}");
                    return(false);
                }
            }
            else
            {
                plist = PObject.Create(plist.Type);
            }

            return(true);
        }
Exemplo n.º 9
0
        protected override Stream LoadResource(string resourceFullPath, string assemblyName)
        {
            var fileStream = base.LoadResource(resourceFullPath, assemblyName);

            var resourceFileName = Path.GetFileName(resourceFullPath);

            //HACK: CFBundleExecutable is invalid in bundle plists but some downloaded libraries contain it. remove it.
            if (resourceFileName == "Info.plist")
            {
                var po = PObject.FromStream(fileStream) as PDictionary;
                if (po != null && po.Remove("CFBundleExecutable"))
                {
                    var memoryStream = new MemoryStream();

                    using (var ctx = PropertyListFormat.Binary.StartWriting(memoryStream))
                        ctx.WriteObject(po);

                    fileStream.Dispose();
                    memoryStream.Position = 0;
                    return(memoryStream);
                }
            }

            return(fileStream);
        }
Exemplo n.º 10
0
        static void WriteXcent(PObject doc, string path)
        {
            var buf = doc.ToByteArray(false);

            using (var stream = new MemoryStream()) {
                stream.Write(buf, 0, buf.Length);

                var  src = stream.ToArray();
                bool save;

                // Note: if the destination file already exists, only re-write it if the content will change
                if (File.Exists(path))
                {
                    var dest = File.ReadAllBytes(path);

                    save = !AreEqual(src, dest);
                }
                else
                {
                    save = true;
                }

                if (save)
                {
                    File.WriteAllBytes(path, src);
                }
            }
        }
Exemplo n.º 11
0
        PDictionary MergeEntitlementDictionary(PDictionary dict, MobileProvision profile)
        {
            var result = new PDictionary();

            foreach (var item in dict)
            {
                PObject value = item.Value;

                if (value is PDictionary)
                {
                    value = MergeEntitlementDictionary((PDictionary)value, profile);
                }
                else if (value is PString)
                {
                    value = MergeEntitlementString((PString)value, profile, false);
                }
                else if (value is PArray)
                {
                    value = MergeEntitlementArray((PArray)value, profile);
                }
                else
                {
                    value = value.Clone();
                }

                if (value != null)
                {
                    result.Add(item.Key, value);
                }
            }

            return(result);
        }
Exemplo n.º 12
0
 public PEntity(PObject obj) : this(PapillonPINVOKE.new_PEntity__SWIG_1(PObject.getCPtr(obj)), true)
 {
     if (PapillonPINVOKE.SWIGPendingException.Pending)
     {
         throw PapillonPINVOKE.SWIGPendingException.Retrieve();
     }
 }
        static void TestExecuteTask(PDictionary input, PropertyListEditorAction action, string entry, string type, string value, PObject expected)
        {
            var task = new PropertyListEditor {
                PropertyList = Path.GetTempFileName(),
                BuildEngine  = new TestEngine(),
                Action       = action.ToString(),
                Entry        = entry,
                Type         = type,
                Value        = value
            };

            input.Save(task.PropertyList);

            try {
                if (expected == null)
                {
                    Assert.IsFalse(task.Execute(), "Task was expected to fail.");
                    return;
                }

                Assert.IsTrue(task.Execute(), "Task was expected to execute successfully.");

                var output = PObject.FromFile(task.PropertyList);

                Assert.AreEqual(expected.Type, output.Type, "Task produced the incorrect plist output.");

                CheckValue(output, expected);
            } finally {
                File.Delete(task.PropertyList);
            }
        }
Exemplo n.º 14
0
        /// <summary>
        /// Lit la liste des objets du jeu
        /// </summary>
        private static void ReadObjectList()
        {
            var currentObject = new PObject(FirstObject);

            //var currentObject = FirstObject;
            //var nextObject = FirstObject;

            while (currentObject.BaseAddress != uint.MinValue && currentObject.BaseAddress % 2 == uint.MinValue)
            {
                if (currentObject.GUID == LocalGUID)
                {
                    MyPlayer.BaseAddress = currentObject.BaseAddress;
                }

                if (!ObjectDictionary.ContainsKey(currentObject.GUID))
                {
                    PObject obj = null;
                    // Add the object based on it's *actual* type. Note: WoW's Object descriptors for OBJECT_FIELD_TYPE
                    // is a bitmask. We want to use the type at 0x14, as it's an 'absolute' type.

                    /* switch (currentObject.Type)
                     * {
                     *  // Belive it or not, the base Object class is hardly used in WoW.
                     *  case (int)Constants.ObjectType.Object:
                     *      obj = new PObject(currentObject.BaseAddress);
                     *      break;
                     *  case (int)Constants.ObjectType.Unit:
                     *      obj = new PUnit(currentObject.BaseAddress);
                     *      break;
                     *  case (int)Constants.ObjectType.Player:
                     *      obj = new PPlayer(currentObject.BaseAddress);
                     *      break;
                     *  case (int)Constants.ObjectType.GameObject:
                     *      obj = new PGameObject(currentObject.BaseAddress);
                     *      break;
                     *  case (int)Constants.ObjectType.Item:
                     *      obj = new PItem(currentObject.BaseAddress);
                     *      break;
                     *  case (int)Constants.ObjectType.Container:
                     *      obj = new PContainer(currentObject.BaseAddress);
                     *      break;
                     *  // These two aren't used in most bots, as they're fairly pointless.
                     *  // They are AI and area triggers for NPCs handled by the client itself.
                     *  case (int)Constants.ObjectType.AiGroup:
                     *  case (int)Constants.ObjectType.AreaTrigger:
                     *      break;
                     * } */
                    if (obj != null)
                    {
                        ObjectDictionary.Add(currentObject.GUID, obj);
                    }
                }
                else
                {
                    ObjectDictionary[currentObject.GUID].BaseAddress = currentObject.BaseAddress;
                }

                currentObject.BaseAddress = Wow.ReadUInt(currentObject.BaseAddress + (uint)Common.Offsets.ObjectManager.NextObject);
            }
        }
Exemplo n.º 15
0
        bool Merge(PObject plist, PObject value)
        {
            switch (plist.Type)
            {
            case PObjectType.Dictionary:
                if (value.Type == PObjectType.Array)
                {
                    Log.LogError(7057, PropertyList, "Merge: Can't Add array Entries to dict");
                    return(false);
                }

                var dict = (PDictionary)plist;

                if (value.Type == PObjectType.Dictionary)
                {
                    var import = (PDictionary)value;

                    foreach (var item in import)
                    {
                        if (dict.ContainsKey(item.Key))
                        {
                            Log.LogMessage(MessageImportance.Low, "Duplicate Entry Was Skipped: {0}", item.Key);
                            continue;
                        }

                        dict.Add(item.Key, item.Value.Clone());
                    }
                }
                else if (!dict.ContainsKey(string.Empty))
                {
                    dict.Add(string.Empty, value);
                }
                break;

            case PObjectType.Array:
                var array = (PArray)plist;

                if (value.Type == PObjectType.Array)
                {
                    var import = (PArray)value;

                    for (int i = 0; i < import.Count; i++)
                    {
                        array.Add(import[i].Clone());
                    }
                }
                else
                {
                    array.Add(value);
                }
                break;

            default:
                Log.LogError(7058, PropertyList, "Merge: Specified Entry Must Be a Container");
                return(false);
            }

            return(true);
        }
Exemplo n.º 16
0
        bool Merge(PObject plist, PObject value)
        {
            switch (plist.Type)
            {
            case PObjectType.Dictionary:
                if (value.Type == PObjectType.Array)
                {
                    Log.LogError(7057, PropertyList, MSBStrings.E7057);
                    return(false);
                }

                var dict = (PDictionary)plist;

                if (value.Type == PObjectType.Dictionary)
                {
                    var import = (PDictionary)value;

                    foreach (var item in import)
                    {
                        if (dict.ContainsKey(item.Key))
                        {
                            Log.LogMessage(MessageImportance.Low, MSBStrings.M0162, item.Key);
                            continue;
                        }

                        dict.Add(item.Key, item.Value.Clone());
                    }
                }
                else if (!dict.ContainsKey(string.Empty))
                {
                    dict.Add(string.Empty, value);
                }
                break;

            case PObjectType.Array:
                var array = (PArray)plist;

                if (value.Type == PObjectType.Array)
                {
                    var import = (PArray)value;

                    for (int i = 0; i < import.Count; i++)
                    {
                        array.Add(import[i].Clone());
                    }
                }
                else
                {
                    array.Add(value);
                }
                break;

            default:
                Log.LogError(7058, PropertyList, MSBStrings.E7058);
                return(false);
            }

            return(true);
        }
Exemplo n.º 17
0
 public void SetObject(PObject obj)
 {
     PapillonPINVOKE.PEntity_SetObject(swigCPtr, PObject.getCPtr(obj));
     if (PapillonPINVOKE.SWIGPendingException.Pending)
     {
         throw PapillonPINVOKE.SWIGPendingException.Retrieve();
     }
 }
Exemplo n.º 18
0
 public static void Unblacklist(PObject target)
 {
     if (target == null)
     {
         return;
     }
     Unblacklist(target.GUID + "");
 }
Exemplo n.º 19
0
 public void Swap(PObject other)
 {
     PapillonPINVOKE.PObject_Swap(swigCPtr, PObject.getCPtr(other));
     if (PapillonPINVOKE.SWIGPendingException.Pending)
     {
         throw PapillonPINVOKE.SWIGPendingException.Retrieve();
     }
 }
Exemplo n.º 20
0
 public static void Blacklist(PObject target, uint length, bool writeText)
 {
     if (target == null)
     {
         return;
     }
     Blacklist(target.GUID + "", length, writeText);
 }
Exemplo n.º 21
0
		public void SetPListContainer (PObjectContainer value)
		{
			nsDictionary = value;
			nsDictionary.Changed += delegate {
				QueueDraw ();
			};
			RefreshTree ();
		}
Exemplo n.º 22
0
 public void SetDescriptor(PObject arg0)
 {
     PapillonPINVOKE.PDescriptor_SetDescriptor__SWIG_1(swigCPtr, PObject.getCPtr(arg0));
     if (PapillonPINVOKE.SWIGPendingException.Pending)
     {
         throw PapillonPINVOKE.SWIGPendingException.Retrieve();
     }
 }
Exemplo n.º 23
0
        public void ExpectTo_should_obtain_matcher()
        {
            var obj1 = new PObject();
            var obj2 = new PObject();

            Expect(obj1).To(Matchers.BeMemberwiseEqualTo(obj2));
            Assert.IsInstanceOf <MemberwiseEqualMatcher <PObject> >(Matchers.BeMemberwiseEqualTo(obj2));
        }
Exemplo n.º 24
0
        bool Delete(PObject plist)
        {
            var         path    = GetPropertyPath();
            var         current = plist;
            PDictionary dict;
            PArray      array;
            int         index;
            int         i = 0;

            if (path.Length == 0)
            {
                Log.LogError(7050, null, MSBStrings.E7050, Entry);
                return(false);
            }

            while (i < path.Length)
            {
                dict  = current as PDictionary;
                array = current as PArray;

                if (array != null)
                {
                    if (!int.TryParse(path[i], out index) || index < 0)
                    {
                        Log.LogError(7051, null, MSBStrings.E7051, Entry);
                        return(false);
                    }

                    if (index >= array.Count)
                    {
                        Log.LogError(7052, null, MSBStrings.E7052, Entry);
                        return(false);
                    }

                    current = array[index];
                }
                else if (dict != null)
                {
                    if (!dict.TryGetValue(path[i], out current))
                    {
                        Log.LogError(7052, null, MSBStrings.E7052, Entry);
                        return(false);
                    }
                }
                else
                {
                    Log.LogError(7052, null, MSBStrings.E7052, Entry);
                    return(false);
                }

                i++;
            }

            current.Remove();

            return(true);
        }
Exemplo n.º 25
0
        private void GlobalModels_UnRegistering(object sender, Guid e)
        {
            PObject obj = GlobalModels.GetModel <PObject>(e);

            if (obj is PTemplatePage template)
            {
                this.TemplateList.Remove(template);
            }
        }
Exemplo n.º 26
0
        private void GlobalModels_Registered(object sender, Guid e)
        {
            PObject obj = GlobalModels.GetModel <PObject>(e);

            if (obj is PTemplatePage template)
            {
                this.TemplateList.Add(template);
            }
        }
Exemplo n.º 27
0
        public static void SetColumn(PObject control, int value)
        {
            if (control == null)
            {
                throw new ArgumentNullException("element");
            }

            control.SetValue(ColumnProperty, value);
        }
Exemplo n.º 28
0
        public string GetName(PObject obj)
        {
            if (nameDict.ContainsKey(obj))
            {
                return(nameDict[obj]);
            }

            return(null);
        }
Exemplo n.º 29
0
        bool Delete(PObject plist)
        {
            var         path    = GetPropertyPath();
            var         current = plist;
            PDictionary dict;
            PArray      array;
            int         index;
            int         i = 0;

            if (path.Length == 0)
            {
                Log.LogError(7050, null, $"Delete: Can't Delete Entry, \"{Entry}\", from Parent");
                return(false);
            }

            while (i < path.Length)
            {
                dict  = current as PDictionary;
                array = current as PArray;

                if (array != null)
                {
                    if (!int.TryParse(path[i], out index) || index < 0)
                    {
                        Log.LogError(7051, null, $"Delete: Entry, \"{Entry}\", Contains Invalid Array Index");
                        return(false);
                    }

                    if (index >= array.Count)
                    {
                        Log.LogError(7052, null, $"Delete: Entry, \"{Entry}\", Does Not Exist");
                        return(false);
                    }

                    current = array[index];
                }
                else if (dict != null)
                {
                    if (!dict.TryGetValue(path[i], out current))
                    {
                        Log.LogError(7052, null, $"Delete: Entry, \"{Entry}\", Does Not Exist");
                        return(false);
                    }
                }
                else
                {
                    Log.LogError(7052, null, $"Delete: Entry, \"{Entry}\", Does Not Exist");
                    return(false);
                }

                i++;
            }

            current.Remove();

            return(true);
        }
Exemplo n.º 30
0
        public void Matches_should_detect_same_reference()
        {
            var sameReference = new PObject();
            var subj          = new MemberwiseEqualMatcher <PObject>(
                sameReference
                );

            Assert.True(subj.Matches(sameReference));
        }
Exemplo n.º 31
0
 private static void HasToldAbout(PObject target)
 {
     if (target == null)
         return;
     lock (IsMarkedDictionary)
     {
         IsMarkedDictionary["GUID" + target.GUID] = DateTime.Now.AddSeconds(30);
     }
 }
Exemplo n.º 32
0
        private void GlobalModels_Registered(object sender, Guid e)
        {
            PObject obj = GlobalModels.GetModel <PObject>(e);

            if (obj is PContentPage page)
            {
                this.PageList.Add(page);
            }
        }
Exemplo n.º 33
0
        private void GlobalModels_UnRegistering(object sender, Guid e)
        {
            PObject obj = GlobalModels.GetModel <PObject>(e);

            if (obj is PContentPage page)
            {
                this.PageList.Remove(page);
            }
        }
Exemplo n.º 34
0
 public static bool IsSchool(PObject node)
 {
     switch (node.Type)
     {
         case (int) Constants.ObjectType.GameObject:
             if (((PGameObject) node).GameObjectType == 25)
             {
                 return true;
             }
             break;
     }
     return false;
 }
Exemplo n.º 35
0
 public static bool IsMine(PObject node)
 {
     switch (node.Type)
     {
         case (int) Constants.ObjectType.GameObject:
             if (_mines.Contains(((PGameObject) node).Name))
             {
                 return true;
             }
             break;
     }
     return false;
 }
Exemplo n.º 36
0
 private static bool IsBadNode(PObject checkNode)
 {
     if (checkNode != null)
     {
         try
         {
             lock (BadNodes)
             {
                 if (BadNodes.Any(node => FindNode.GetLocation(checkNode).GetDistanceTo(node) < 5))
                     return true;
             }
         }
         catch
         {
         }
     }
     return false;
 }
Exemplo n.º 37
0
        public void Run(TestConfig config)
        {
            int count = config.Count;
            var res = new TestGcResult();
            config.Result = res;
            IDatabase db = config.GetDatabase();
            Root root = new Root();
            IIndex<string, PObject> strIndex = root.strIndex = db.CreateIndex<string, PObject>(IndexType.Unique);
            IIndex<long, PObject> intIndex = root.intIndex = db.CreateIndex<long, PObject>(IndexType.Unique);
            db.Root = root;
            long insKey = 1999;
            long remKey = 1999;

            for (int i = 0; i < count; i++)
            {
                if (i > nObjectsInTree)
                {
                    remKey = (3141592621L * remKey + 2718281829L) % 1000000007L;
                    intIndex.Remove(new Key(remKey));
                    strIndex.Remove(new Key(remKey.ToString()));
                }
                PObject obj = new PObject();
                insKey = (3141592621L * insKey + 2718281829L) % 1000000007L;
                obj.intKey = insKey;
                obj.strKey = insKey.ToString();
                obj.next = new PObject();
                intIndex[obj.intKey] = obj;
                strIndex[obj.strKey] = obj;
                if (i > 0)
                {
                    Tests.Assert(root.list.intKey == i - 1);
                }
                root.list = new PObject();
                root.list.intKey = i;
                root.Store();
                if (i % 1000 == 0)
                    db.Commit();
            }
            db.Close();
        }
Exemplo n.º 38
0
 public static void Unblacklist(PObject target)
 {
     if (target == null)
         return;
     Unblacklist(target.GUID);
     FlyingEngine.CurrentProfile.RemoveBadNode(target.Location);
     FlyingEngine.CurrentProfile.SaveFile(FlyingEngine.CurrentProfile.FileName);
 }
Exemplo n.º 39
0
    public static void Main(string[] args)
    {
        Storage db = StorageFactory.Instance.CreateStorage();

        for (int i = 0; i < args.Length; i++)
        {
            if ("background".Equals(args[i]))
            {
                db.SetProperty("perst.background.gc", true);
            }
            else if ("altbtree".Equals(args[i]))
            {
                db.SetProperty("perst.alternative.btree", true);
            }
            else
            {
                Console.Error.WriteLine("Unrecognized option: " + args[i]);
            }
        }

        db.Open("testgc.dbs");
        db.GcThreshold = 1000000;
        StorageRoot root = new StorageRoot();
        root.strIndex = db.CreateIndex(typeof(string), true);
        root.intIndex = db.CreateIndex(typeof(long), true);
        db.SetRoot(root);
        Index intIndex = root.intIndex;
        Index strIndex = root.strIndex;
        long insKey = 1999;
        long remKey = 1999;
        int i2;

        for (i2 = 0; i2 < nIterations; i2++)
        {
            if (i2 > nObjectsInTree)
            {
                remKey = (3141592621L * remKey + 2718281829L) % 1000000007L;
                intIndex.Remove(new Key(remKey));
                strIndex.Remove(new Key(Convert.ToString(remKey)));
            }
            PObject obj = new PObject();
            insKey = (3141592621L * insKey + 2718281829L) % 1000000007L;
            obj.intKey = insKey;
            obj.strKey = Convert.ToString(insKey);
            obj.next = new PObject();
            intIndex.Put(new Key(obj.intKey), obj);
            strIndex.Put(new Key(obj.strKey), obj);
            if (i2 > 0)
            {
                Assert.That(root.list.intKey == i2 - 1);
            }
            root.list = new PObject();
            root.list.intKey = i2;
            root.Store();
            if (i2 % 1000 == 0)
            {
                Console.Out.Write("Iteration " + i2 + "\r");
                Console.Out.Flush();
                db.Commit();
            }
        }
        db.Close();
    }
Exemplo n.º 40
0
 public static void Blacklist(PObject target, uint length, bool writeText)
 {
     Blacklist(target.GUID, length, writeText);
 }
Exemplo n.º 41
0
 public static void AddBadNode(PObject pObject)
 {
     AddBadNode(pObject.Location);
 }
Exemplo n.º 42
0
 public static Location GetLocation(PObject node)
 {
     switch (node.Type)
     {
         case (int) Constants.ObjectType.GameObject:
             return (node).Location;
         case (int) Constants.ObjectType.Unit:
             return (node).Location;
     }
     return new Location(0, 0, 0);
 }
Exemplo n.º 43
0
 public static void Unblacklist(PObject target)
 {
     if (target == null)
         return;
     Unblacklist(target.GUID + "");
 }
Exemplo n.º 44
0
 public static void Blacklist(PObject target, uint length, bool writeText)
 {
     if (target == null)
         return;
     Blacklist(target.GUID + "", length, writeText);
 }
Exemplo n.º 45
0
 public static string GetName(PObject node)
 {
     switch (node.Type)
     {
         case (int) Constants.ObjectType.Unit:
             return ((PUnit) node).Name;
         case (int) Constants.ObjectType.GameObject:
             return ((PGameObject) node).Name;
     }
     return "";
 }
		void AddToTree (Gtk.TreeStore treeStore, Gtk.TreeIter iter, PObject current, Dictionary<PObject, PListScheme.SchemaItem> tree)
		{
			foreach (var item in PObject.ToEnumerable (current)) {
				var subIter = FindOrAddPObject (iter, item.Key, item.Value, tree);
				AddToTree (treeStore, subIter, item.Value, tree);
			}
		}
Exemplo n.º 47
0
 private static void ReadObjectList()
 {
     var currentObject = new PObject(Memory.Read<uint>(CurrentManager + (uint) Pointers.ObjectManager.FirstObject));
     LocalGUID = Memory.Read<UInt64>(CurrentManager + (uint) Pointers.ObjectManager.LocalGUID);
     while (currentObject.BaseAddress != UInt32.MinValue &&
            currentObject.BaseAddress%2 == UInt32.MinValue)
     {
         // Keep the static reference to the local player updated... at all times.
         if (currentObject.GUID == LocalGUID)
         {
             //MessageBox.Show("Found localplayer! 0x" + currentObject.ToString("X8"));
             MyPlayer.UpdateBaseAddress(currentObject.BaseAddress);
         }
         if (!ObjectDictionary.ContainsKey(currentObject.GUID))
         {
             PObject obj = null;
             // Add the object based on it's *actual* type. Note: WoW's Object descriptors for OBJECT_FIELD_TYPE
             // is a bitmask. We want to use the type at 0x14, as it's an 'absolute' type.
             switch (currentObject.Type)
             {
                     // Belive it or not, the base Object class is hardly used in WoW.
                 case (int) Constants.ObjectType.Object:
                     obj = new PObject(currentObject.BaseAddress);
                     break;
                 case (int) Constants.ObjectType.Unit:
                     obj = new PUnit(currentObject.BaseAddress);
                     break;
                 case (int) Constants.ObjectType.Player:
                     obj = new PPlayer(currentObject.BaseAddress);
                     break;
                 case (int) Constants.ObjectType.GameObject:
                     obj = new PGameObject(currentObject.BaseAddress);
                     break;
                 case (int) Constants.ObjectType.Item:
                     obj = new PItem(currentObject.BaseAddress);
                     break;
                 case (int) Constants.ObjectType.Container:
                     obj = new PContainer(currentObject.BaseAddress);
                     break;
                     // These two aren't used in most bots, as they're fairly pointless.
                     // They are AI and area triggers for NPCs handled by the client itself.
                 case (int) Constants.ObjectType.AiGroup:
                 case (int) Constants.ObjectType.AreaTrigger:
                     break;
             }
             if (obj != null)
             {
                 // We have a valid object that isn't in the object list already.
                 // So lets add it.
                 ObjectDictionary.Add(currentObject.GUID, obj);
             }
         }
         else
         {
             // The object already exists, just update the pointer.
             ObjectDictionary[currentObject.GUID].UpdateBaseAddress(currentObject.BaseAddress);
         }
         // We need the next object.
         currentObject.BaseAddress =
             Memory.Read<uint>(currentObject.BaseAddress + (uint) Pointers.ObjectManager.NextObject);
     }
 }
Exemplo n.º 48
0
        static void WriteXcent(PObject doc, string path)
        {
            var buf = doc.ToByteArray (false);

            using (var stream = File.Open (path, FileMode.Create)) {
                if (AppleSdkSettings.XcodeVersion < new Version (4, 4, 1)) {
                    // write the xcent file with the magic header, length, and the plist
                    var length = Mono.DataConverter.BigEndian.GetBytes ((uint) buf.Length + 8); // 8 = magic.length + magicLen.Length

                    stream.Write (XcentMagic, 0, XcentMagic.Length);
                    stream.Write (length, 0, length.Length);
                }

                stream.Write (buf, 0, buf.Length);
            }
        }
		TreeIter FindOrAddPObject (TreeIter iter, string id, PObject item, Dictionary<PObject, PListScheme.SchemaItem> tree)
		{
			TreeIter subIter;
			if (CurrentTree.ContainsKey (item)) {
				if (iter.Equals (TreeIter.Zero) ? treeStore.IterChildren (out subIter) : treeStore.IterChildren (out subIter, iter)) {
					do {
						if (treeStore.GetValue (subIter, 1) == item) {
							// If we have modified the value of an existing PObject, such
							// as changing the value of a PNumber from '1' to '2', we will
							// need to refresh the value in the treestore.
							treeStore.SetValue (subIter, 0, id);
							break;
						}
					} while (treeStore.IterNext (ref subIter));
				}
			} else {
				subIter = treeStore.InsertNodeBefore (FindOrAddNewEntry (iter));
				treeStore.SetValues (subIter, id, item, tree [item]);
				if (CurrentTree.Count > 0) {
					treeview.ExpandToPath (treeStore.GetPath (subIter));
					this.treeview.Selection.SelectIter (subIter);
				}
				
				if (item is PArray || item is PDictionary) {
					var newEntryIter = FindOrAddNewEntry (subIter);
					if (CurrentTree.Count > 0)
						treeview.ExpandToPath (treeStore.GetPath (newEntryIter));
				}
			}
			
			return subIter;
		}