示例#1
0
        public static void Load()
        {
            Parallel.Invoke(
                () => {
                Items = new GameDataMap <ushort, ItemStructure>(ItemStructure.Load(XDocument.Parse(RawObjectsXML)));
                PluginUtils.Log("GameData", "Mapped {0} items.", Items.Map.Count);
            },
                () => {
                Tiles = new GameDataMap <ushort, TileStructure>(TileStructure.Load(XDocument.Parse(RawTilesXML)));
                PluginUtils.Log("GameData", "Mapped {0} tiles.", Tiles.Map.Count);
            },
                () => {
                Objects = new GameDataMap <ushort, ObjectStructure>(ObjectStructure.Load(XDocument.Parse(RawObjectsXML)));
                PluginUtils.Log("GameData", "Mapped {0} objects.", Objects.Map.Count);
            },
                () => {
                Packets = new GameDataMap <byte, PacketStructure>(PacketStructure.Load(XDocument.Parse(RawPacketsXML)));
                PluginUtils.Log("GameData", "Mapped {0} packets.", Packets.Map.Count);
            },
                () => {
                Servers = new GameDataMap <string, ServerStructure>(ServerStructure.Load(XDocument.Load("http://realmofthemadgodhrd.appspot.com/char/list")));
                PluginUtils.Log("GameData", "Mapped {0} servers.", Servers.Map.Count);
            });

            PluginUtils.Log("GameData", "Successfully loaded game data.");
        }
示例#2
0
        public static void Load()
        {
            Parallel.Invoke(
                () => {
                Items = new GameDataMap <ushort, ItemStructure>(ItemStructure.Load(XDocument.Parse(RawObjectsXML)));
                PluginUtils.Log("GameData", "Mapped {0} items.", Items.Map.Count);
            },
                () => {
                Tiles = new GameDataMap <ushort, TileStructure>(TileStructure.Load(XDocument.Parse(RawTilesXML)));
                PluginUtils.Log("GameData", "Mapped {0} tiles.", Tiles.Map.Count);
            },
                () => {
                Objects = new GameDataMap <ushort, ObjectStructure>(ObjectStructure.Load(XDocument.Parse(RawObjectsXML)));
                PluginUtils.Log("GameData", "Mapped {0} objects.", Objects.Map.Count);
            },
                () => {
                Packets = new GameDataMap <byte, PacketStructure>(PacketStructure.Load(XDocument.Parse(RawPacketsXML)));
                PluginUtils.Log("GameData", "Mapped {0} packets.", Packets.Map.Count);
            },
                () => {
                const string CHAR_LIST_FILE = "char_list.xml";

                XDocument charList = null;

                try
                {
                    charList = XDocument.Load("http://realmofthemadgodhrd.appspot.com/char/list");
                }
                catch (Exception) { }

                // If the char list doesn't contain an error
                if (charList != null && charList.Element("Error") == null)
                {
                    // Make a backup of the char list
                    charList.Save(CHAR_LIST_FILE);
                }
                // If the backup char list file exists
                else if (System.IO.File.Exists(CHAR_LIST_FILE))
                {
                    charList = XDocument.Load(CHAR_LIST_FILE);
                }
                // The retrieved char list contains an error and a backup char list doesn't exist
                else
                {
                    PluginUtils.Log("GameData", "Error! Unable to retrieve server list.");
                    return;
                }

                Servers = new GameDataMap <string, ServerStructure>(ServerStructure.Load(charList));
                PluginUtils.Log("GameData", "Mapped {0} servers.", Servers.Map.Count);
            });

            PluginUtils.Log("GameData", "Successfully loaded game data.");
        }
示例#3
0
        public static void Load()
        {
            Parallel.Invoke(
                () =>
            {
                try
                {
                    Items = new GameDataMap <ushort, ItemStructure>(ItemStructure.Load(XDocument.Load("Objects.xml")));
                    PluginUtils.Log("GameData", "loaded items from file!");
                }
                catch
                {
                    Items = new GameDataMap <ushort, ItemStructure>(ItemStructure.Load(XDocument.Parse(RawObjectsXML)));
                }
                PluginUtils.Log("GameData", "Mapped {0} items.", Items.Map.Count);
            },
                () =>
            {
                try
                {
                    Tiles = new GameDataMap <ushort, TileStructure>(TileStructure.Load(XDocument.Load("Tiles.xml")));
                    PluginUtils.Log("GameData", "loaded tiles from file!");
                }
                catch
                {
                    Tiles = new GameDataMap <ushort, TileStructure>(TileStructure.Load(XDocument.Parse(RawTilesXML)));
                }
                PluginUtils.Log("GameData", "Mapped {0} tiles.", Tiles.Map.Count);
            },
                () =>
            {
                try
                {
                    Objects = new GameDataMap <ushort, ObjectStructure>(ObjectStructure.Load(XDocument.Load("Objects.xml")));
                    PluginUtils.Log("GameData", "loaded objects from file!");
                }
                catch
                {
                    Objects = new GameDataMap <ushort, ObjectStructure>(ObjectStructure.Load(XDocument.Parse(RawObjectsXML)));
                }
                PluginUtils.Log("GameData", "Mapped {0} objects.", Objects.Map.Count);
            },
                () =>
            {
                try
                {
                    Packets = new GameDataMap <byte, PacketStructure>(PacketStructure.Load(XDocument.Load("Packets.xml")));
                    PluginUtils.Log("GameData", "loaded packets from file!");
                }
                catch
                {
                    Packets = new GameDataMap <byte, PacketStructure>(PacketStructure.Load(XDocument.Parse(RawPacketsXML)));
                }
                PluginUtils.Log("GameData", "Mapped {0} packets.", Packets.Map.Count);
            },
                () =>
            {
                const string CHAR_LIST_FILE = "char_list.xml";

                XDocument charList = null;

                try
                {
                    charList = XDocument.Load("http://realmofthemadgodhrd.appspot.com/char/list");
                }
                catch (Exception)
                {
                }

                if (charList != null && charList.Element("Error") == null)
                {
                    charList.Save(CHAR_LIST_FILE);
                }
                else if (System.IO.File.Exists(CHAR_LIST_FILE))
                {
                    charList = XDocument.Load(CHAR_LIST_FILE);
                }
                else
                {
                    PluginUtils.Log("GameData", "Error! Unable to retrieve server list.");
                    return;
                }

                Servers = new GameDataMap <string, ServerStructure>(ServerStructure.Load(charList));
                PluginUtils.Log("GameData", "Mapped {0} servers.", Servers.Map.Count);
            });

            PluginUtils.Log("GameData", "Successfully loaded game data.");
        }
示例#4
0
        public static void Load()
        {
            bool hadError = false;

            Parallel.Invoke(
                () =>
            {
                try
                {
                    Items = new GameDataMap <ushort, ItemStructure>(ItemStructure.Load(XDocument.Load("Objects.xml")));
                    PluginUtils.Log("GameData", "Mapped {0} items.", Items.Map.Count);
                }
                catch (Exception e)
                {
                    hadError = true;
                    PluginUtils.Log("GameData", "Error while reading Objects.xml file: {0}", e.Message);
                }
            },
                () =>
            {
                try
                {
                    Tiles = new GameDataMap <ushort, TileStructure>(TileStructure.Load(XDocument.Load("Tiles.xml")));
                    PluginUtils.Log("GameData", "Mapped {0} tiles.", Tiles.Map.Count);
                }
                catch (Exception e)
                {
                    hadError = true;
                    PluginUtils.Log("GameData", "Error while reading Tiles.xml file: {0}", e.Message);
                }
            },
                () =>
            {
                try
                {
                    Objects = new GameDataMap <ushort, ObjectStructure>(ObjectStructure.Load(XDocument.Load("Objects.xml")));
                    PluginUtils.Log("GameData", "Mapped {0} objects.", Objects.Map.Count);
                }
                catch (Exception e)
                {
                    hadError = true;
                    PluginUtils.Log("GameData", "Error while reading Objects.xml file: {0}", e.Message);
                }
            },
                () =>
            {
                try
                {
                    Packets = new GameDataMap <byte, PacketStructure>(PacketStructure.Load(XDocument.Load("Packets.xml")));
                    PluginUtils.Log("GameData", "Mapped {0} packets.", Packets.Map.Count);
                }
                catch (Exception e)
                {
                    hadError = true;
                    PluginUtils.Log("GameData", "Error while reading Packets.xml file: {0}", e.Message);
                }
            },
                () =>
            {
                const string CHAR_LIST_FILE = "char_list.xml";

                XDocument charList = null;

                try
                {
                    charList = XDocument.Load("https://www.realmofthemadgod.com/char/list");
                }
                catch (Exception e)
                {
                    hadError = true;
                    PluginUtils.Log("GameData", "Error while fetching /char/list: {0}", e.Message);
                }

                // If the char list doesn't contain an error
                if (charList != null && charList.Element("Error") == null)
                {
                    // Make a backup of the char list
                    charList.Save(CHAR_LIST_FILE);
                }
                // If the backup char list file exists
                else if (System.IO.File.Exists(CHAR_LIST_FILE))
                {
                    charList = XDocument.Load(CHAR_LIST_FILE);
                }
                // The retrieved char list contains an error and a backup char list doesn't exist
                else
                {
                    PluginUtils.Log("GameData", "Cannot retrieve server list and no cache exists.");
                    hadError = true;
                    return;
                }

                Servers = new GameDataMap <string, ServerStructure>(ServerStructure.Load(charList));
                PluginUtils.Log("GameData", "Mapped {0} servers.", Servers.Map.Count);
            });

            if (hadError)
            {
                PluginUtils.Log("GameData", "One or more game data files could not be loaded.");
            }
            else
            {
                PluginUtils.Log("GameData", "Successfully loaded game data.");
            }
        }
示例#5
0
        public static void Load()
        {
            List <string> errors = new List <string>();

            Parallel.Invoke(
                () => {
                try
                {
                    Items = new GameDataMap <ushort, ItemStructure>(ItemStructure.Load(XDocument.Load(Path.Combine("Resources", "Objects.xml"))));
                } catch
                {
                    // If Objects.xml is missing the error is reported later on, so don't report it here.
                    Items = new GameDataMap <ushort, ItemStructure>(ItemStructure.Load(XDocument.Parse(RawObjectsXML)));
                }
                PluginUtils.Log("GameData", "Mapped {0} items.", Items.Map.Count);
            },
                () => {
                try
                {
                    Tiles = new GameDataMap <ushort, TileStructure>(TileStructure.Load(XDocument.Load(Path.Combine("Resources", "Tiles.xml"))));
                    PluginUtils.Log("GameData", "Loaded Tiles from Tiles.xml");
                }
                catch (Exception e)
                {
                    errors.Add(string.Format("(Tiles.xml) {0}", e.Message));
                    PluginUtils.Log("GameData", "Using Tiles.xml resource fallback.");
                    Tiles = new GameDataMap <ushort, TileStructure>(TileStructure.Load(XDocument.Parse(RawTilesXML)));
                }
                PluginUtils.Log("GameData", "Mapped {0} tiles.", Tiles.Map.Count);
            },
                () => {
                try
                {
                    Objects = new GameDataMap <ushort, ObjectStructure>(ObjectStructure.Load(XDocument.Load(Path.Combine("Resources", "Objects.xml"))));
                    PluginUtils.Log("GameData", "Loaded Objects from Objects.xml");
                }
                catch (Exception e)
                {
                    errors.Add(string.Format("(Objects.xml) {0}", e.Message));
                    PluginUtils.Log("GameData", "Using Objects.xml resource fallback.");
                    Objects = new GameDataMap <ushort, ObjectStructure>(ObjectStructure.Load(XDocument.Parse(RawObjectsXML)));
                }
                PluginUtils.Log("GameData", "Mapped {0} objects.", Objects.Map.Count);
            },
                () => {
                try
                {
                    Packets = new GameDataMap <byte, PacketStructure>(PacketStructure.Load(XDocument.Load(Path.Combine("Resources", "Packets.xml"))));
                    PluginUtils.Log("GameData", "Loaded Packets from Packets.xml");
                }
                catch (Exception e)
                {
                    errors.Add(string.Format("(Packets.xml) {0}", e.Message));
                    PluginUtils.Log("GameData", "Using Packets.xml resource fallback.");
                    Packets = new GameDataMap <byte, PacketStructure>(PacketStructure.Load(XDocument.Parse(RawPacketsXML)));
                }
                PluginUtils.Log("GameData", "Mapped {0} packets.", Packets.Map.Count);
            },
                () => {
                const string CHAR_LIST_FILE = "char_list.xml";

                XDocument charList = null;

                try
                {
                    charList = XDocument.Load("http://realmofthemadgodhrd.appspot.com/char/list");
                }
                catch (Exception) { }

                // If the char list doesn't contain an error
                if (charList != null && charList.Element("Error") == null)
                {
                    // Make a backup of the char list
                    charList.Save(CHAR_LIST_FILE);
                }
                // If the backup char list file exists
                else if (System.IO.File.Exists(CHAR_LIST_FILE))
                {
                    charList = XDocument.Load(CHAR_LIST_FILE);
                }
                // The retrieved char list contains an error and a backup char list doesn't exist
                else
                {
                    PluginUtils.Log("GameData", "Error! Unable to retrieve server list.");
                    return;
                }

                Servers = new GameDataMap <string, ServerStructure>(ServerStructure.Load(charList));
                PluginUtils.Log("GameData", "Mapped {0} servers.", Servers.Map.Count);
            });

            if (errors.Count == 0)
            {
                PluginUtils.Log("GameData", "Successfully loaded game data.");
            }
            else
            {
                Console.WriteLine();
                PluginUtils.Log("GameData", "{0} Error{1} encountered while loading game data.", errors.Count, errors.Count == 1 ? "" : "s");
                PluginUtils.Log("GameData", "It is recommended to fix these issues before using KRelay.");
                for (int i = 0; i < errors.Count; i++)
                {
                    PluginUtils.Log("GD Error", "\t{0}: {1}", i + 1, errors[i]);
                }
                Console.WriteLine();
            }
        }
示例#6
0
        public static void Load()
        {
            Parallel.Invoke(
                // Items
                () =>
            {
                try
                {
                    Items = new GameDataMap <ushort, ItemStructure>(ItemStructure.Load(XDocument.Load(OBJECTS_FILE)));
                    GameDataLog($"Loaded items from file \"{OBJECTS_FILE}\".");
                }
                catch
                {
                    Items = new GameDataMap <ushort, ItemStructure>(ItemStructure.Load(XDocument.Parse(RawObjectsXML)));
                    GameDataLog("Loaded items from \"Resources.Objects\".");
                }

                GameDataLog("Mapped {0} items.", Items.Map.Count);
            },
                // Tiles
                () =>
            {
                try
                {
                    Tiles = new GameDataMap <ushort, TileStructure>(TileStructure.Load(XDocument.Load(TILES_FILE)));
                    GameDataLog($"Loaded tiles from file \"{TILES_FILE}\".");
                }
                catch
                {
                    Tiles = new GameDataMap <ushort, TileStructure>(TileStructure.Load(XDocument.Parse(RawTilesXML)));
                    GameDataLog("Loaded tiles from \"Resources.Tiles\".");
                }

                GameDataLog("Mapped {0} tiles.", Tiles.Map.Count);
            },
                // Objects
                () =>
            {
                try
                {
                    Objects = new GameDataMap <ushort, ObjectStructure>(ObjectStructure.Load(XDocument.Load(OBJECTS_FILE)));
                    GameDataLog($"Loaded objects from file \"{OBJECTS_FILE}\".");
                }
                catch
                {
                    Objects = new GameDataMap <ushort, ObjectStructure>(ObjectStructure.Load(XDocument.Parse(RawObjectsXML)));
                    GameDataLog("Loaded objects from \"Resources.Objects\".");
                }

                GameDataLog("Mapped {0} objects.", Objects.Map.Count);
            },
                // Packets
                () =>
            {
                try
                {
                    Packets = new GameDataMap <byte, PacketStructure>(PacketStructure.Load(XDocument.Load(PACKETS_FILE)));
                    GameDataLog($"Loaded packets from file \"{PACKETS_FILE}\".");
                }
                catch
                {
                    Packets = new GameDataMap <byte, PacketStructure>(PacketStructure.Load(XDocument.Parse(RawPacketsXML)));
                    GameDataLog("Loaded packets from \"Resources.Packets\".");
                }

                GameDataLog("Mapped {0} packets.", Packets.Map.Count);
            },
                // char/list
                () =>
            {
                const string CHAR_LIST_FILE = "char_list.xml";

                XDocument charList = null;

                try
                {
                    charList = XDocument.Load("http://realmofthemadgodhrd.appspot.com/char/list");
                }
                catch (Exception)
                {
                }

                // If the char list doesn't contain an error
                if (charList != null && charList.Element("Error") == null)
                {
                    // Make a backup of the char list
                    charList.Save(CHAR_LIST_FILE);
                }
                // If the backup char list file exists
                else if (File.Exists(CHAR_LIST_FILE))
                {
                    charList = XDocument.Load(CHAR_LIST_FILE);
                }
                // The retrieved char list contains an error and a backup char list doesn't exist
                else
                {
                    GameDataLog("Error! Unable to retrieve server list.");
                    return;
                }

                Servers = new GameDataMap <string, ServerStructure>(ServerStructure.Load(charList));
                GameDataLog("Mapped {0} servers.", Servers.Map.Count);
            });

            GameDataLog("Successfully loaded game data.");
        }