Ejemplo n.º 1
0
        /// <summary>
        ///     Loads all of the group names defined in an XML document.
        /// </summary>
        /// <param name="layoutDocument">The XML document to load group names from.</param>
        /// <returns>The names that were loaded.</returns>
        public static PokingCollection LoadPointers(XDocument namesDocument)
        {
            // Make sure there is a root <poking> tag
            XContainer container = namesDocument.Element("poking");

            if (container == null)
            {
                throw new ArgumentException("Invalid poking document");
            }

            var result = new PokingCollection();

            foreach (XElement cl in container.Elements("version"))
            {
                string name = XMLUtil.GetStringAttribute(cl, "name");

                long headerPointer = XMLUtil.GetNumericAttribute(cl, "headerPointer", -1);

                long headerAddress      = XMLUtil.GetNumericAttribute(cl, "headerAddress", -1);
                long magicAddress       = XMLUtil.GetNumericAttribute(cl, "magicAddress", -1);
                long magicOffset        = XMLUtil.GetNumericAttribute(cl, "magicOffset", -1);
                long sharedMagicAddress = XMLUtil.GetNumericAttribute(cl, "sharedMagicAddress", -1);

                Version version = new Version(name);

                result.AddName(version, new PokingInformation(headerPointer, headerAddress, magicAddress, magicOffset, sharedMagicAddress));
            }
            return(result);
        }
Ejemplo n.º 2
0
        /// <summary>
        ///     Loads all of the class names defined in an XML document.
        /// </summary>
        /// <param name="layoutDocument">The XML document to load class names from.</param>
        /// <returns>The names that were loaded.</returns>
        public static PokingCollection LoadPointers(XDocument namesDocument)
        {
            // Make sure there is a root <poking> tag
            XContainer container = namesDocument.Element("poking");

            if (container == null)
            {
                throw new ArgumentException("Invalid poking document");
            }

            // Poking tags have the format:
            // <version name="(the version string)" address="(the pointer in the game module to the cache header in memory)" />
            var result = new PokingCollection();

            foreach (XElement cl in container.Elements("version"))
            {
                string name    = XMLUtil.GetStringAttribute(cl, "name");
                long   pointer = XMLUtil.GetNumericAttribute(cl, "address");

                Version version = new Version(name);

                result.AddName(version, pointer);
            }
            return(result);
        }