Exemplo n.º 1
0
        private int CommandExtract(string line, int index, TemplateContext tc, string commandname, string param)
        {
            ObjectDictionary args     = ObjectDictionary.FromString(param);
            string           variable = null;

            if (args.ContainsKey("0"))
            {
                variable = args["0"].ToString();
            }
            else if (args.ContainsKey("var"))
            {
                variable = args["var"].ToString();
            }

            if (string.IsNullOrEmpty(variable))
            {
                LOG_ERR(string.Format("Error: Invalid syntax, should be '{0}{1} var-name{2}'", m_commandprefix, commandname, m_commandpostfix));
                return(index);
            }
            object obj = tc.dict.GetObject(variable);

            if (obj == null)
            {
                LOG_ERR(string.Format("Error: Object {0} is not assigned.", variable));
                return(index);
            }
            Dispatch(tc, obj.ToString());
            return(index);
        }
Exemplo n.º 2
0
        private int CommandDef(string line, int index, TemplateContext tc, string commandname, string param)
        {
            string contents;

            index = Capture(line, index, m_commandprefix + commandname, m_commandprefix + "end" + commandname + m_commandpostfix, out contents);
            ObjectDictionary args     = ObjectDictionary.FromString(param);
            string           variable = null;

            if (args.ContainsKey("0"))
            {
                variable = args["0"].ToString();
            }
            else if (args.ContainsKey("var"))
            {
                variable = args["var"].ToString();
            }

            if (string.IsNullOrEmpty(variable))
            {
                LOG_ERR(string.Format("Error: Invalid syntax, should be '{0}{1} var-name{2}'", m_commandprefix, commandname, m_commandpostfix));
                return(index);
            }
            tc.dict[variable] = contents;
            return(index);
        }
Exemplo n.º 3
0
        private int CommandAssign(string line, int index, TemplateContext tc, string commandname, string param)
        {
            ObjectDictionary args     = ObjectDictionary.FromString(param);
            string           variable = null;

            if (args.ContainsKey("0"))
            {
                variable = args["0"].ToString();
            }
            else if (args.ContainsKey("var"))
            {
                variable = args["var"].ToString();
            }

            string value = null;

            if (args.ContainsKey("1"))
            {
                value = args["1"].ToString();
            }
            else if (args.ContainsKey("value"))
            {
                value = args["value"].ToString();
            }

            if ((variable == null) || (value == null))
            {
                LOG_ERR(string.Format("Error: Invalid syntax, should be '{0}{1} var-name expression{2}'", m_commandprefix, commandname, m_commandpostfix));
                return(index);
            }
            tc.dict[variable] = GetExpr(tc.dict, value);
            return(index);
        }
Exemplo n.º 4
0
 public override IodineObject GetIndex(VirtualMachine vm, IodineObject key)
 {
     if (!dict.ContainsKey(key))
     {
         vm.RaiseException(new IodineKeyNotFound());
         return(null);
     }
     return(dict [key] as IodineObject);
 }
Exemplo n.º 5
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.º 6
0
    private bool DrawAddField()
    {
        bool added = false;

        EditorGUILayout.BeginVertical(GUI.skin.box);
        EditorGUILayout.BeginHorizontal();
        GUILayout.Label("Key");
        GUILayout.Label("Value");
        GUILayout.Space(buttonWidth);
        EditorGUILayout.EndHorizontal();
        EditorGUILayout.BeginHorizontal();
        newKey   = (TKey)EditorGUILayout.ObjectField(newKey, typeof(TKey), false, GUILayout.ExpandWidth(true));
        newValue = (TValue)EditorGUILayout.ObjectField(newValue, typeof(TValue), false, GUILayout.ExpandWidth(true));

        if (GUILayout.Button("+", GUILayout.Width(buttonWidth), GUILayout.Height(15)))
        {
            if (newKey && newValue)
            {
                if (store.ContainsKey(newKey))
                {
                    Debug.LogError("Dictionary contains already a key with value " + newKey);
                }
                else
                {
                    keysProperty.EXT_AddToObjectArray <TKey>(newKey);
                    valuesProperty.EXT_AddToObjectArray <TValue>(newValue);
                    added = true;
                }
            }
        }

        EditorGUILayout.EndHorizontal();
        EditorGUILayout.EndVertical();
        return(added);
    }
Exemplo n.º 7
0
 /// <summary>
 /// Make sure that properties decorated with an ignorable
 /// custom attribute are NOT included for serialization.
 /// </summary>
 /// <param name="obj">The object to scan.</param>
 /// <returns>
 /// An initialized instance of the <see cref="ObjectDictionary"/> class if
 /// there are properties to be ignored; otherwise, <paramref name="obj"/>.
 /// </returns>
 public static object RemoveIgnoredPropertiesFromObjectToBeSerialized(this object obj)
 {
     if (obj != null && obj.GetType().TryGetMetadata(out var metadata))
     {
         var dic       = new ObjectDictionary(obj);
         var different = false;
         foreach (var group in metadata)
         {
             foreach (var item in group.Items)
             {
                 var attr = item.Attribute;
                 var name = attr.GetProperty().Name;
                 if (attr.Ignore && dic.ContainsKey(name))
                 {
                     dic.Remove(name);
                     different = true;
                 }
             }
         }
         if (different)
         {
             return(dic);
         }
     }
     return(obj);
 }
Exemplo n.º 8
0
        ///////////////////////////////////////////////////////////////////////

        public bool SetMark(
            bool mark,
            string name,
            object value
            )
        {
            CheckDisposed();

            //
            // NOTE: Null and/or empty string tag names are not allowed.
            //
            if (!String.IsNullOrEmpty(name))
            {
                if (tags != null)
                {
                    if (mark && !tags.ContainsKey(name))
                    {
                        //
                        // NOTE: Try to add the tag.
                        //
                        tags.Add(name, value);

                        //
                        // NOTE: Yes, we added the tag.
                        //
                        return(true);
                    }
                    else if (!mark && tags.ContainsKey(name))
                    {
                        //
                        // NOTE: Try to remove the tag.
                        //
                        tags.Remove(name);

                        //
                        // NOTE: Yes, we removed the tag.
                        //
                        return(true);
                    }
                }
            }

            //
            // NOTE: For whatever reason, we did not add/remove the tag.
            //
            return(false);
        }
Exemplo n.º 9
0
        public string GetColumn(object property)
        {
            string proName = property.ToString().ToLower();

            if (ObjectDictionary.ContainsKey(proName))
            {
                return(ObjectDictionary[proName]);
            }
            return(null);
        }
Exemplo n.º 10
0
        private int CommandInclude(string line, int index, TemplateContext tc, string commandname, string param)
        {
            ObjectDictionary args  = ObjectDictionary.FromString(param);
            string           fname = null;

            if (args.ContainsKey("0"))
            {
                fname = args["0"].ToString();
            }
            else if (args.ContainsKey("file"))
            {
                fname = args["file"].ToString();
            }
            if (string.IsNullOrEmpty(fname))
            {
                LOG_ERR(string.Format("Error: {0}{1}{2} directive must have filename argument.", m_commandprefix, commandname, m_commandpostfix));
                return(index);
            }
            RenderTemplateAux(tc, Path.Combine(m_dir, fname));
            return(index);
        }
Exemplo n.º 11
0
 private void ClientOnGetAllSecurityGroupsCompleted(object sender, GetAllSecurityGroupsCompletedEventArgs e)
 {
     if (e.UserState is Guid)
     {
         var guid = (Guid)e.UserState;
         if (ObjectDictionary.ContainsKey(guid) && GetAllSecurityGroupsCompletedEventHandlers.ContainsKey(guid))
         {
             GetAllSecurityGroupsCompletedEventHandlers[guid](ObjectDictionary[guid], e);
             GetAllSecurityGroupsCompletedEventHandlers.Remove(guid);
             ObjectDictionary.Remove(guid);
         }
     }
 }
Exemplo n.º 12
0
 private void ClientOnUpdateSecurityAssociationsCompleted(object sender, UpdateSecurityAssociationsCompletedEventArgs e)
 {
     if (e.UserState is Guid)
     {
         var guid = (Guid)e.UserState;
         if (ObjectDictionary.ContainsKey(guid) &&
             UpdateSecurityAssociationsCompletedEventHandlers.ContainsKey(guid))
         {
             UpdateSecurityAssociationsCompletedEventHandlers[guid](ObjectDictionary[guid], e);
             UpdateSecurityAssociationsCompletedEventHandlers.Remove(guid);
             ObjectDictionary.Remove(guid);
         }
     }
 }
Exemplo n.º 13
0
 private void ClientOnRestoreRootMapInheritanceCompleted(object sender, RestoreRootMapInheritanceCompletedEventArgs e)
 {
     if (e.UserState is Guid)
     {
         var guid = (Guid)e.UserState;
         if (ObjectDictionary.ContainsKey(guid) &&
             RestoreRootMapInheritanceCompletedEventHandlers.ContainsKey(guid))
         {
             RestoreRootMapInheritanceCompletedEventHandlers[guid](ObjectDictionary[guid], e);
             RestoreRootMapInheritanceCompletedEventHandlers.Remove(guid);
             ObjectDictionary.Remove(guid);
         }
     }
 }
Exemplo n.º 14
0
 private void ClientOnSetProjectManagerGroupAssociationsCompleted(object sender, SetProjectManagerGroupAssociationsCompletedEventArgs e)
 {
     if (e.UserState is Guid)
     {
         var guid = (Guid)e.UserState;
         if (ObjectDictionary.ContainsKey(guid) &&
             SetProjectManagerGroupAssociationsCompletedEventHandlers.ContainsKey(guid))
         {
             SetProjectManagerGroupAssociationsCompletedEventHandlers[guid](ObjectDictionary[guid], e);
             SetProjectManagerGroupAssociationsCompletedEventHandlers.Remove(guid);
             ObjectDictionary.Remove(guid);
         }
     }
 }
Exemplo n.º 15
0
 internal void Create(Vector3 pos, Transform RailTransformation, double StartingDistance, double EndingDistance)
 {
     if (!Exists)
     {
         return;
     }
     if (Direction <= 0)
     {
         if (leftObjects.ContainsKey(Type))
         {
             leftObjects[Type].CreateObject(pos, RailTransformation, StartingDistance, EndingDistance, StartingDistance);
         }
     }
     if (Direction >= 0)
     {
         if (rightObjects.ContainsKey(Type))
         {
             rightObjects[Type].CreateObject(pos, RailTransformation, StartingDistance, EndingDistance, StartingDistance);
         }
     }
 }
Exemplo n.º 16
0
 private void ClientOnGetPermissionNameForObjectCompleted(object sender, GetPermissionNameForObjectCompletedEventArgs e)
 {
     if (e.UserState is Guid)
     {
         var guid = (Guid)e.UserState;
         if (ObjectDictionary.ContainsKey(guid) &&
             GetPermissionNameForObjectCompletedEventHandlers.ContainsKey(guid))
         {
             //back compatibility with old version
             if (App.PermissionLevel == PermissionLevel.OldReader)
             {
                 e.Result.Result = PermissionLevel.Reader.ToString();
             }
             else if (App.PermissionLevel == PermissionLevel.OldAuthor)
             {
                 e.Result.Result = PermissionLevel.Author.ToString();
             }
             GetPermissionNameForObjectCompletedEventHandlers[guid](ObjectDictionary[guid], e);
             GetPermissionNameForObjectCompletedEventHandlers.Remove(guid);
             ObjectDictionary.Remove(guid);
         }
     }
 }
Exemplo n.º 17
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.º 18
0
        ///////////////////////////////////////////////////////////////////////

        public ReturnCode AddImport(
            INamespace targetNamespace,
            string qualifiedImportName,
            string qualifiedExportName,
            ref Result error
            )
        {
            CheckDisposed();

            if (qualifiedImportName == null)
            {
                error = "invalid import name";
                return(ReturnCode.Error);
            }

            if (qualifiedExportName == null)
            {
                error = "invalid export name";
                return(ReturnCode.Error);
            }

            if (interpreter == null)
            {
                error = "invalid interpreter";
                return(ReturnCode.Error);
            }

            if (imports == null)
            {
                error = String.Format(
                    "imports not available in namespace \"{0}\"",
                    GetDisplayName());

                return(ReturnCode.Error);
            }

            IAlias alias       = null;
            Result localResult = null;

            if (interpreter.AddAlias(
                    qualifiedImportName, CommandFlags.None,
                    AliasFlags.NamespaceImport, _Public.ClientData.Empty,
                    interpreter, null, new ArgumentList(qualifiedExportName),
                    null, 0, ref alias, ref localResult) == ReturnCode.Ok)
            {
                alias.SourceNamespace = this;
                alias.TargetNamespace = targetNamespace;
            }
            else
            {
                error = localResult;
                return(ReturnCode.Error);
            }

            string nameToken = alias.NameToken;

            if (nameToken == null)
            {
                //
                // NOTE: This should not happen as the alias was successfully
                //       added to the interpreter and the name token cannot be
                //       null in that case.
                //
                error = "invalid alias name";
                return(ReturnCode.Error);
            }

            if (imports.ContainsKey(qualifiedImportName))
            {
                Result     localError = null;
                ResultList errors     = new ResultList();

                errors.Add(String.Format(
                               "can't add import \"{0}\" in \"{1}\": already exists",
                               nameToken, GetDisplayName()));

                if (interpreter.RemoveAliasAndCommand(
                        nameToken, null, false,
                        ref localError) != ReturnCode.Ok)
                {
                    errors.Add(localError);
                }

                error = errors;
                return(ReturnCode.Error);
            }

            imports.Add(qualifiedImportName, alias);
            return(ReturnCode.Ok);
        }
Exemplo n.º 19
0
        private int CommandFor(string line, int index, TemplateContext tc, string commandname, string param)
        {
            string contents;

            index = Capture(line, index, m_commandprefix + commandname, m_commandprefix + "end" + commandname + m_commandpostfix, out contents);
            ObjectDictionary args     = ObjectDictionary.FromString(param);
            string           variable = null;

            if (args.ContainsKey("0"))
            {
                variable = args["0"].ToString();
            }
            else if (args.ContainsKey("var"))
            {
                variable = args["var"].ToString();
            }

            string list = null;

            if (args.ContainsKey("1") && (args["1"].ToString() == "in") && args.ContainsKey("2"))
            {
                list = args["2"].ToString();
            }
            else if (args.ContainsKey("list"))
            {
                list = args["list"].ToString();
            }

            string countvar = null;

            if (args.ContainsKey("count"))
            {
                countvar = args["count"].ToString();
            }
            int countstart = 1;

            if (args.ContainsKey("countstart"))
            {
                object countstartobj = tc.dict.GetObject(args["countstart"].ToString());
                if (countstartobj != null)
                {
                    countstart = StringUtil.ToInt(countstartobj.ToString(), countstart);
                }
            }
            string indexvar = null;

            if (args.ContainsKey("index"))
            {
                indexvar = args["index"].ToString();
            }
            string evenvar = null;

            if (args.ContainsKey("even"))
            {
                evenvar = args["even"].ToString();
            }
            string oddvar = null;

            if (args.ContainsKey("odd"))
            {
                oddvar = args["odd"].ToString();
            }

            if (string.IsNullOrEmpty(variable) || string.IsNullOrEmpty(list))
            {
                LOG_ERR(string.Format("Error: Invalid syntax, should be '{0}{1} var-name in list-variable {2}'", m_commandprefix, commandname, m_commandpostfix));
                return(index);
            }
            object listobj = tc.dict.GetObject(list);

            if (listobj == null)
            {
                LOG_ERR(string.Format("Error: Object {0} is not assigned.", list));
                return(index);
            }
            if (!(listobj is IEnumerable))
            {
                LOG_ERR(string.Format("Error: Object {0} is not an Enumerable.", list));
                return(index);
            }
            TemplateContext innertc = new TemplateContext(tc.sb, tc.dict);
            int             i       = 0;

            foreach (object obj in (listobj as IEnumerable))
            {
                innertc.dict[variable] = obj;
                if (!String.IsNullOrEmpty(countvar))
                {
                    innertc.dict[countvar] = i + countstart;
                }
                if (!String.IsNullOrEmpty(indexvar))
                {
                    innertc.dict[indexvar] = i;
                }
                if (!String.IsNullOrEmpty(evenvar))
                {
                    innertc.dict[evenvar] = ((i % 2) == 0);
                }
                if (!String.IsNullOrEmpty(oddvar))
                {
                    innertc.dict[oddvar] = ((i % 2) == 1);
                }
                Dispatch(innertc, contents);
                i++;
            }
            return(index);
        }
Exemplo n.º 20
0
        private static void ReadObjectList()
        {
            var localPlayerGuid =
                Memory.ReadAtOffset <ulong>(CurrentManager, (uint)Offsets.ObjectManager.LocalGUID);
            var current =
                Memory.ReadAtOffset <IntPtr>(CurrentManager, (uint)Offsets.ObjectManager.FirstObject);

            if (current == IntPtr.Zero || ((uint)current & 1) == 1)
            {
                Reset(WowProcess);
                return;
            }

            while (current != IntPtr.Zero && ((uint)current & 1) != 1)
            {
                var guid = WowObject.GetStorageField <ulong>(current,
                                                             (uint)Descriptors.WowObjectFields.OBJECT_FIELD_GUID);

                if (!ObjectDictionary.ContainsKey(guid))
                {
                    var oType =
                        (Offsets.ObjectType)Memory.ReadAtOffset <uint>(current, (uint)Offsets.ObjectManager.ObjectType);

                    WowObject wowObject = null;

                    switch (oType)
                    {
                    case Offsets.ObjectType.GameObject:
                        wowObject = new WowGameObject(current);
                        break;

                    case Offsets.ObjectType.Object:
                        wowObject = new WowObject(current);
                        break;

                    case Offsets.ObjectType.Player:
                        wowObject = new WowPlayer(current);
                        break;

                    case Offsets.ObjectType.Unit:
                        wowObject = new WowUnit(current);
                        break;

                    default:
                        break;
                    }

                    if (wowObject != null)
                    {
                        ObjectDictionary.Add(guid, wowObject);
                    }
                }
                else
                {
                    ObjectDictionary[guid].BaseAddress = current;
                }

                //  Keep the local player's GUID up-to-date
                if (localPlayerGuid == guid)
                {
                    Me.BaseAddress = current;
                }

                current = Memory.ReadAtOffset <IntPtr>(current, (uint)Offsets.ObjectManager.NextObject);
            }
        }