Esempio n. 1
0
        public XmlWorld(DungeonDesc desc)
        {
            _d = desc;
            var json = new WebClient().DownloadString(desc.Json);

            Name          = desc.Name;
            Background    = desc.Background;
            AllowTeleport = desc.AllowTeleport;
            base.FromWorldMap(new MemoryStream(Json2Wmap.Convert(json)));
        }
Esempio n. 2
0
        public XmlWorld(DungeonDesc desc)
        {
            _d = desc;
            var json = new WebClient().DownloadString(desc.Json);

            Name = desc.Name;
            Background = desc.Background;
            AllowTeleport = desc.AllowTeleport;
            FromWorldMap(new MemoryStream(Json2Wmap.Convert(json)));
        }
    static void ProcessXml(Stream stream)
    {
        XElement root = XElement.Load(stream);

        foreach (var elem in root.Elements("Ground"))
        {
            short  type = (short)Utils.FromString(elem.Attribute("type").Value);
            string id   = elem.Attribute("id").Value;

            UsedIds.Add(type);

            TypeToId[type]      = id;
            IdToType[id]        = type;
            TypeToElement[type] = elem;

            TileDescs[type] = new TileDesc(elem);
        }
        foreach (var elem in root.Elements("Object"))
        {
            if (elem.Element("Class") == null)
            {
                continue;
            }
            string cls  = elem.Element("Class").Value;
            short  type = (short)Utils.FromString(elem.Attribute("type").Value);
            string id   = elem.Attribute("id").Value;

            UsedIds.Add(type);

            TypeToId[type]      = id;
            IdToType[id]        = type;
            TypeToElement[type] = elem;

            if (cls == "Equipment" || cls == "Dye" || cls == "Pet")
            {
                ItemDescs[type] = new Item(elem);
                if (elem.Element("Shop") != null)
                {
                    XElement shop = elem.Element("Shop");
                    ItemShops[type]  = shop.Element("Name").Value;
                    ItemPrices[type] = Utils.FromString(shop.Element("Price").Value);
                }
            }
            if (cls == "Character" || cls == "GameObject" || cls == "Wall" ||
                cls == "ConnectedWall" || cls == "CaveWall" || cls == "Portal")
            {
                ObjectDescs[type] = new ObjectDesc(elem);
            }
            if (cls == "Portal")
            {
                try
                {
                    PortalDescs[type] = new PortalDesc(elem);
                }
                catch (Exception e)
                {
                    Console.WriteLine("Error for portal: " + type + " id: " + id);

                    /*3392,1792,1795,1796,1805,1806,1810,1825 -- no location, assume nexus?*
                     *  Tomb Portal of Cowardice,  Dungeon Portal,  Portal of Cowardice,  Realm Portal,  Glowing Portal of Cowardice,  Glowing Realm Portal,  Nexus Portal,  Locked Wine Cellar Portal*/
                }
            }

            XElement key = elem.Element("Key");
            if (key != null)
            {
                Keys.Add(type);
                KeyPrices[type] = Utils.FromString(key.Value);
            }
        }
        foreach (var elem in root.Elements("Dungeon"))
        {
            string name     = elem.Attribute("name").Value;
            short  portalid = (short)Utils.FromString(elem.Attribute("type").Value);

            IdToDungeon[portalid] = name;
            DungeonDescs[name]    = new DungeonDesc(elem);
        }
    }
    public static string ProcessModXml(Stream stream, string dir)
    {
        XElement root = XElement.Load(stream);

        foreach (var elem in root.Elements("Ground"))
        {
            short  type = 0x3000;
            string id   = elem.Attribute("id").Value;

            if (!ItemIds.ContainsKey(id))
            {
                for (var i = 0x3001; i < 0xffff; i++)
                {
                    if (!UsedIds.Contains((short)i))
                    {
                        ItemIds.Add(id, (short)i);
                        UsedIds.Add((short)i);
                    }
                }
            }
            type = ItemIds[id];

            elem.SetAttributeValue("type", type);

            TypeToId[type]      = id;
            IdToType[id]        = type;
            TypeToElement[type] = elem;

            TileDescs[type] = new TileDesc(elem);
        }
        foreach (var elem in root.Elements("Object"))
        {
            if (elem.Element("Class") == null)
            {
                continue;
            }
            string cls  = elem.Element("Class").Value;
            short  type = 0x4000;
            string id   = elem.Attribute("id").Value;

            if (!ItemIds.ContainsKey(id))
            {
                for (var i = 0x4001; i < 0xffff; i++)
                {
                    if (!UsedIds.Contains((short)i))
                    {
                        ItemIds.Add(id, (short)i);
                        UsedIds.Add((short)i);
                        break;
                    }
                }
            }
            type = ItemIds[id];

            Console.Out.WriteLine("(" + new DirectoryInfo(dir).Name + ") Adding mod object: " + id + " (" + type.ToString() + ")");
            if (File.Exists(dir + ds + id + ".png"))
            {
                Console.Out.WriteLine("(" + new DirectoryInfo(dir).Name + ") Adding mod texture: " + id);

                if (elem.Element("RemoteTexture") != null)
                {
                    elem.Element("RemoteTexture").Remove();
                }
                if (elem.Element("Texture") != null)
                {
                    elem.Element("Texture").Remove();
                }

                XElement texElem = new XElement("RemoteTexture",
                                                new XElement("Instance",
                                                             new XText("production")
                                                             ),
                                                new XElement("Id",
                                                             new XText("mod:" + id)
                                                             )
                                                );

                elem.Add(texElem);

                try
                {
                    ModTextures.Add(id, File.ReadAllBytes(dir + ds + id + ".png"));
                }
                catch { Console.Out.WriteLine("(" + new DirectoryInfo(dir).Name + ") Error adding texture: " + id); }
            }

            elem.SetAttributeValue("type", type);

            TypeToId[type]      = id;
            IdToType[id]        = type;
            TypeToElement[type] = elem;

            if (cls == "Equipment" || cls == "Dye" || cls == "Pet")
            {
                ItemDescs[type] = new Item(elem);
                if (elem.Element("Shop") != null)
                {
                    XElement shop = elem.Element("Shop");
                    ItemShops[type]  = shop.Element("Name").Value;
                    ItemPrices[type] = Utils.FromString(shop.Element("Price").Value);
                }
            }
            if (cls == "Character" || cls == "GameObject" || cls == "Wall" ||
                cls == "ConnectedWall" || cls == "CaveWall" || cls == "Portal")
            {
                ObjectDescs[type] = new ObjectDesc(elem);
            }
            if (cls == "Portal")
            {
                try
                {
                    PortalDescs[type] = new PortalDesc(elem);
                }
                catch (Exception e)
                {
                    Console.WriteLine("Error for portal: " + type + " id: " + id);

                    /*3392,1792,1795,1796,1805,1806,1810,1825 -- no location, assume nexus?*
                     *  Tomb Portal of Cowardice,  Dungeon Portal,  Portal of Cowardice,  Realm Portal,  Glowing Portal of Cowardice,  Glowing Realm Portal,  Nexus Portal,  Locked Wine Cellar Portal*/
                }
            }

            XElement key = elem.Element("Key");
            if (key != null)
            {
                Keys.Add(type);
                KeyPrices[type] = Utils.FromString(key.Value);
            }
        }
        foreach (var elem in root.Elements("Dungeon"))
        {
            string name     = elem.Attribute("name").Value;
            short  portalid = (short)Utils.FromString(elem.Attribute("type").Value);

            IdToDungeon[portalid] = name;
            DungeonDescs[name]    = new DungeonDesc(elem);
        }
        using (StringWriter sw = new StringWriter())
        {
            root.Save(sw);
            return(sw.ToString());
        }
    }
Esempio n. 5
0
    static void ProcessXml(Stream stream)
    {
        XElement root = XElement.Load(stream);
        foreach (var elem in root.Elements("Ground"))
        {
            short type = (short)Utils.FromString(elem.Attribute("type").Value);
            string id = elem.Attribute("id").Value;

            TypeToId[type] = id;
            IdToType[id] = type;
            TypeToElement[type] = elem;

            TileDescs[type] = new TileDesc(elem);
        }
        foreach (var elem in root.Elements("Object"))
        {
            if (elem.Element("Class") == null) continue;
            string cls = elem.Element("Class").Value;
            short type = (short)Utils.FromString(elem.Attribute("type").Value);
            string id = elem.Attribute("id").Value;

            TypeToId[type] = id;
            IdToType[id] = type;
            TypeToElement[type] = elem;

            if (cls == "Equipment" || cls == "Dye" || cls == "Pet")
            {
                ItemDescs[type] = new Item(elem);
                if (elem.Element("Shop") != null)
                {
                    XElement shop = elem.Element("Shop");
                    ItemShops[type] = shop.Element("Name").Value;
                    ItemPrices[type] = Utils.FromString(shop.Element("Price").Value);
                }
            }
            if (cls == "Character" || cls == "GameObject" || cls == "Wall" ||
                cls == "ConnectedWall" || cls == "CaveWall" || cls == "Portal")
                ObjectDescs[type] = new ObjectDesc(elem);
            if (cls == "Portal")
            {
                try
                {
                    PortalDescs[type] = new PortalDesc(elem);
                }
                catch (Exception e)
                {
                    Console.WriteLine("Error for portal: " + type + " id: " + id);
                    /*3392,1792,1795,1796,1805,1806,1810,1825 -- no location, assume nexus?*
        *  Tomb Portal of Cowardice,  Dungeon Portal,  Portal of Cowardice,  Realm Portal,  Glowing Portal of Cowardice,  Glowing Realm Portal,  Nexus Portal,  Locked Wine Cellar Portal*/
                }
            }

            XElement key = elem.Element("Key");
            if (key != null)
            {
                Keys.Add(type);
                KeyPrices[type] = Utils.FromString(key.Value);
            }
        }
        foreach (var elem in root.Elements("Dungeon"))
        {
            string name = elem.Attribute("name").Value;
            short portalid = (short)Utils.FromString(elem.Attribute("type").Value);

            IdToDungeon[portalid] = name;
            DungeonDescs[name] = new DungeonDesc(elem);
        }
    }
Esempio n. 6
0
        private static void ProcessXml(Stream stream)
        {
            XElement root = XElement.Load(stream);

            foreach (XElement elem in root.Elements("Ground"))
            {
                var    type = (short)Utils.FromString(elem.Attribute("type").Value);
                string id   = elem.Attribute("id").Value;

                TypeToId[type]       = id;
                TypeToIdGround[type] = id;
                IdToType[id]         = type;
                TypeToElement[type]  = elem;

                TileDescs[type] = new TileDesc(elem);
            }
            foreach (XElement elem in root.Elements("Object"))
            {
                if (elem.Element("Class") == null)
                {
                    continue;
                }
                string cls  = elem.Element("Class").Value;
                var    type = (short)Utils.FromString(elem.Attribute("type").Value);
                string id   = elem.Attribute("id").Value;

                TypeToId[type]      = id;
                IdToType[id]        = type;
                TypeToElement[type] = elem;

                if (cls == "Equipment" || cls == "Dye" || cls == "Pet")
                {
                    ItemDescs[type] = new Item(elem);
                    if (elem.Element("Shop") != null)
                    {
                        XElement shop = elem.Element("Shop");
                        ItemShops[type]  = shop.Element("Name").Value;
                        ItemPrices[type] = Utils.FromString(shop.Element("Price").Value);
                    }
                }
                if (cls == "Character" || cls == "GameObject" || cls == "Wall" ||
                    cls == "ConnectedWall" || cls == "CaveWall" || cls == "Portal")
                {
                    ObjectDescs[type] = new ObjectDesc(elem);
                }
                if (cls == "Portal")
                {
                    try
                    {
                        PortalDescs[type] = new PortalDesc(elem);
                    }
                    catch
                    {
                        Console.WriteLine(@"Error for portal: " + type + @" id: " + id);

                        /*3392,1792,1795,1796,1805,1806,1810,1825 -- no location, assume nexus?*
                         *  Tomb Portal of Cowardice,  Dungeon Portal,  Portal of Cowardice,  Realm Portal,  Glowing Portal of Cowardice,  Glowing Realm Portal,  Nexus Portal,  Locked Wine Cellar Portal*/
                    }
                }

                if (elem.Element("RemoteTexture") != null)
                {
                    XElement rtElem = elem.Element("RemoteTexture");
                    if (rtElem.Element("Id") != null)
                    {
                        string rtId = rtElem.Element("Id").Value;
                        if (!RemoteTextures.ContainsKey(rtId))
                        {
                            if (rtId.StartsWith("draw:"))
                            {
                                RemoteTextures.Add(rtId,
                                                   new WebClient().DownloadData("http://realmofthemadgod.appspot.com/picture/get?id=" +
                                                                                new String(rtId.Skip(5).ToArray())));
                            }
                            else if (rtId.StartsWith("tdraw:"))
                            {
                                RemoteTextures.Add(rtId,
                                                   new WebClient().DownloadData("http://rotmgtesting.appspot.com/picture/get?id=" +
                                                                                new String(rtId.Skip(6).ToArray())));
                            }
                            else if (rtId.StartsWith("file:"))
                            {
                                RemoteTextures.Add(rtId,
                                                   File.ReadAllBytes("texture/" + new String(rtId.Skip(5).ToArray()) + ".png"));
                            }
                        }
                    }
                }


                XElement key = elem.Element("Key");
                if (key != null)
                {
                    Keys.Add(type);
                    KeyPrices[type] = Utils.FromString(key.Value);
                }
            }
            foreach (XElement elem in root.Elements("Dungeon"))
            {
                string name     = elem.Attribute("name").Value;
                var    portalid = (short)Utils.FromString(elem.Attribute("type").Value);

                IdToDungeon[portalid] = name;
                DungeonDescs[name]    = new DungeonDesc(elem);
            }
        }
Esempio n. 7
0
        private static void AddDungeon(XElement root)
        {
            foreach (var elem in root.XPathSelectElements("//Dungeon"))
            {
                var name = elem.Attribute("name").Value;
                var portalid = (short)Utils.FromString(elem.Attribute("type").Value);

                IdToDungeon[portalid] = name;
                Dungeons[name] = new DungeonDesc(elem);
            }
        }
Esempio n. 8
0
        private static void ProcessXml(Stream stream)
        {
            XElement root = XElement.Load(stream);
            foreach (XElement elem in root.Elements("Ground"))
            {
                var type = (short) Utils.FromString(elem.Attribute("type").Value);
                string id = elem.Attribute("id").Value;

                TypeToId[type] = id;
                TypeToIdGround[type] = id;
                IdToType[id] = type;
                TypeToElement[type] = elem;

                TileDescs[type] = new TileDesc(elem);
            }
            foreach (XElement elem in root.Elements("Object"))
            {
                if (elem.Element("Class") == null) continue;
                string cls = elem.Element("Class").Value;
                var type = (short) Utils.FromString(elem.Attribute("type").Value);
                string id = elem.Attribute("id").Value;

                TypeToId[type] = id;
                IdToType[id] = type;
                TypeToElement[type] = elem;

                if (cls == "Equipment" || cls == "Dye" || cls == "Pet")
                {
                    ItemDescs[type] = new Item(elem);
                    if (elem.Element("Shop") != null)
                    {
                        XElement shop = elem.Element("Shop");
                        ItemShops[type] = shop.Element("Name").Value;
                        ItemPrices[type] = Utils.FromString(shop.Element("Price").Value);
                    }
                }
                if (cls == "Character" || cls == "GameObject" || cls == "Wall" ||
                    cls == "ConnectedWall" || cls == "CaveWall" || cls == "Portal")
                    ObjectDescs[type] = new ObjectDesc(elem);
                if (cls == "Portal")
                {
                    try
                    {
                        PortalDescs[type] = new PortalDesc(elem);
                    }
                    catch
                    {
                        Console.WriteLine(@"Error for portal: " + type + @" id: " + id);
                        /*3392,1792,1795,1796,1805,1806,1810,1825 -- no location, assume nexus?* 
*  Tomb Portal of Cowardice,  Dungeon Portal,  Portal of Cowardice,  Realm Portal,  Glowing Portal of Cowardice,  Glowing Realm Portal,  Nexus Portal,  Locked Wine Cellar Portal*/
                    }
                }

                if (elem.Element("RemoteTexture") != null)
                {
                    XElement rtElem = elem.Element("RemoteTexture");
                    if (rtElem.Element("Id") != null)
                    {
                        string rtId = rtElem.Element("Id").Value;
                        if (!RemoteTextures.ContainsKey(rtId))
                            if (rtId.StartsWith("draw:"))
                                RemoteTextures.Add(rtId,
                                    new WebClient().DownloadData("http://realmofthemadgod.appspot.com/picture/get?id=" +
                                                                 new String(rtId.Skip(5).ToArray())));
                            else if (rtId.StartsWith("tdraw:"))
                                RemoteTextures.Add(rtId,
                                    new WebClient().DownloadData("http://rotmgtesting.appspot.com/picture/get?id=" +
                                                                 new String(rtId.Skip(5).ToArray())));
                            else if (rtId.StartsWith("file:"))
                                RemoteTextures.Add(rtId,
                                    File.ReadAllBytes("texture/" + new String(rtId.Skip(5).ToArray()) + ".png"));
                    }
                }

                XElement key = elem.Element("Key");
                if (key != null)
                {
                    Keys.Add(type);
                    KeyPrices[type] = Utils.FromString(key.Value);
                }
            }
            foreach (XElement elem in root.Elements("Dungeon"))
            {
                string name = elem.Attribute("name").Value;
                var portalid = (short) Utils.FromString(elem.Attribute("type").Value);

                IdToDungeon[portalid] = name;
                DungeonDescs[name] = new DungeonDesc(elem);
            }
        }
Esempio n. 9
0
    public static string ProcessModXml(Stream stream, string dir)
    {
        XElement root = XElement.Load(stream);
        foreach (var elem in root.Elements("Ground"))
        {
            short type = 0x3000;
            string id = elem.Attribute("id").Value;

            if (!ItemIds.ContainsKey(id))
                for (var i = 0x3001; i < 0xffff; i++)
                    if (!UsedIds.Contains((short)i))
                    {
                        ItemIds.Add(id, (short)i);
                        UsedIds.Add((short)i);
                    }
            type = ItemIds[id];

            elem.SetAttributeValue("type", type);

            TypeToId[type] = id;
            IdToType[id] = type;
            TypeToElement[type] = elem;

            TileDescs[type] = new TileDesc(elem);
        }
        foreach (var elem in root.Elements("Object"))
        {
            if (elem.Element("Class") == null) continue;
            string cls = elem.Element("Class").Value;
            short type = 0x4000;
            string id = elem.Attribute("id").Value;

            if (!ItemIds.ContainsKey(id))
                for (var i = 0x4001; i < 0xffff; i++)
                    if (!UsedIds.Contains((short)i))
                    {
                        ItemIds.Add(id, (short)i);
                        UsedIds.Add((short)i);
                        break;
                    }
            type = ItemIds[id];

            Console.Out.WriteLine("(" + new DirectoryInfo(dir).Name + ") Adding mod object: " + id + " (" + type.ToString() + ")");
            if (File.Exists(dir + ds + id + ".png"))
            {
                Console.Out.WriteLine("(" + new DirectoryInfo(dir).Name + ") Adding mod texture: " + id);

                if (elem.Element("RemoteTexture") != null)
                    elem.Element("RemoteTexture").Remove();
                if (elem.Element("Texture") != null)
                    elem.Element("Texture").Remove();

                XElement texElem = new XElement("RemoteTexture",
                    new XElement("Instance",
                        new XText("production")
                    ),
                    new XElement("Id",
                        new XText("mod:" + id)
                    )
                );

                elem.Add(texElem);

                try
                {
                    ModTextures.Add(id, File.ReadAllBytes(dir + ds + id + ".png"));
                }
                catch { Console.Out.WriteLine("(" + new DirectoryInfo(dir).Name + ") Error adding texture: " + id); }
            }

            elem.SetAttributeValue("type", type);

            TypeToId[type] = id;
            IdToType[id] = type;
            TypeToElement[type] = elem;

            if (cls == "Equipment" || cls == "Dye" || cls == "Pet")
            {
                ItemDescs[type] = new Item(elem);
                if (elem.Element("Shop") != null)
                {
                    XElement shop = elem.Element("Shop");
                    ItemShops[type] = shop.Element("Name").Value;
                    ItemPrices[type] = Utils.FromString(shop.Element("Price").Value);
                }
            }
            if (cls == "Character" || cls == "GameObject" || cls == "Wall" ||
                cls == "ConnectedWall" || cls == "CaveWall" || cls == "Portal" ||
                cls == "NPC")
                ObjectDescs[type] = new ObjectDesc(elem);
            if (cls == "Portal")
            {
                try
                {
                    PortalDescs[type] = new PortalDesc(elem);
                }
                catch (Exception e)
                {
                    Console.WriteLine("Error for portal: " + type + " id: " + id);
                    /*3392,1792,1795,1796,1805,1806,1810,1825 -- no location, assume nexus?*
        *  Tomb Portal of Cowardice,  Dungeon Portal,  Portal of Cowardice,  Realm Portal,  Glowing Portal of Cowardice,  Glowing Realm Portal,  Nexus Portal,  Locked Wine Cellar Portal*/
                }
            }

            XElement key = elem.Element("Key");
            if (key != null)
            {
                Keys.Add(type);
                KeyPrices[type] = Utils.FromString(key.Value);
            }
        }
        foreach (var elem in root.Elements("Dungeon"))
        {
            string name = elem.Attribute("name").Value;
            short portalid = (short)Utils.FromString(elem.Attribute("type").Value);

            IdToDungeon[portalid] = name;
            DungeonDescs[name] = new DungeonDesc(elem);
        }
        using (StringWriter sw = new StringWriter())
        {
            root.Save(sw);
            return sw.ToString();
        }
    }