示例#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 damage(Vector3 position, int amount, NetworkPlayer player)
    {
        NetworkUser user       = NetworkUserList.getUserFromPlayer(player);
        int         permission = UserList.getPermission(user.id);

        if (permission < 1)
        {
            Reference.Tell(player, "Building destroy not allowed!");
            return;
        }

        int num = 0;

        while (num < SpawnStructures.structures.Count)
        {
            if (SpawnStructures.structures[num].position != position)
            {
                num++;
            }
            else
            {
                ServerStructure item = SpawnStructures.structures[num];
                item.health = item.health - amount;
                if (SpawnStructures.structures[num].health <= 0)
                {
                    NetworkEffects.askEffect("Effects/debrisWood", position, Quaternion.Euler(-90f, 0f, 0f), -1f);
                    NetworkSounds.askSound("Sounds/Barricades/debrisWood", position, 1f, UnityEngine.Random.Range(0.9f, 1.1f), 1f);
                    SpawnStructures.tool.networkView.RPC("destroyStructure", RPCMode.All, new object[] { num });
                }
                break;
            }
        }
    }
示例#3
0
        private void ChangeServer(ServerStructure server)
        {
            Config.Default.DefaultServerName = server.Name;
            Config.Default.Save();

            // Update the server address in all the states
            foreach (var state in _proxy.States)
            {
                state.Value.ConTargetAddress = server.Address;
            }
        }
示例#4
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.");
        }
示例#5
0
        private void OnConnectCommand(Client client, string command, string[] args)
        {
            if (args.Length == 0)
            {
                /*
                 * string LastConnection = ((MapInfoPacket)client.State["MapInfo"]).Name;
                 * string Text = GameData.GameData.Servers.Map.Single(x => x.Value.Address == Proxy.DefaultServer).Value.Name + ", ";
                 *
                 * Text = LastConnection == "Realm of the Mad God" ? client.State.LastReconnect.Name.Split('.').Last() : LastConnection;
                 * Text += GameData.GameData.Servers.Map.Where(x => x.Value.Address == client.State.ConTargetAddress).Count() == 0 ? client.State.LastRealm.Name.Split('.').Last() : LastConnection;
                 *
                 * TextPacket tpacket = (TextPacket)Packet.Create(PacketType.TEXT);
                 * tpacket.BubbleTime = 184;
                 * tpacket.NumStars = -1;
                 * tpacket.ObjectId = -1;
                 * tpacket.Name = "";
                 * tpacket.Recipient = "";
                 * tpacket.CleanText = "";
                 * tpacket.Text = Text;
                 * client.SendToClient(tpacket);
                 */
            }
            else if (args.Length == 1)
            {
                string serverNameUpper = args[0].ToUpper();

                IEnumerable <ServerStructure> servers = GameData.GameData.Servers.Map.Where(x => x.Key == serverNameUpper || x.Value.Name.ToUpper() == serverNameUpper).Select(x => x.Value);

                if (servers.Count() == 1)
                {
                    ServerStructure server = servers.First();

                    ChangeDefault(server);

                    ReconnectPacket reconnect = (ReconnectPacket)Packet.Create(PacketType.RECONNECT);
                    reconnect.Host        = server.Address;
                    reconnect.Port        = 2050;
                    reconnect.GameId      = -2;
                    reconnect.Name        = "Nexus";
                    reconnect.IsFromArena = false;
                    reconnect.Key         = new byte[0];
                    reconnect.KeyTime     = 0;
                    reconnect.Stats       = string.Empty;
                    SendReconnect(client, reconnect);
                }
                else
                {
                    client.SendToClient(PluginUtils.CreateOryxNotification("K Relay", "Unknown server!"));
                }
            }
        }
示例#6
0
 public void askAllStructures(NetworkPlayer player)
 {
     for (int i = 0; i < SpawnStructures.structures.Count; i++)
     {
         ServerStructure item = SpawnStructures.structures[i];
         if (player != Network.player)
         {
             base.networkView.RPC("createStructure", player, new object[] { item.id, item.position, item.rotation });
         }
         else
         {
             this.createStructure(item.id, item.position, item.rotation);
         }
     }
 }
示例#7
0
    public static void save()
    {
        string structureString = string.Empty;

        for (int i = 0; i < SpawnStructures.structures.Count; i++)
        {
            ServerStructure item = SpawnStructures.structures[i];
            structureString = string.Concat(structureString, item.id, ":");
            structureString = string.Concat(structureString, item.health, ":");
            structureString = string.Concat(structureString, item.state, ":");
            structureString = string.Concat(structureString, Mathf.Floor(item.position.x * 100f) / 100f, ":");
            structureString = string.Concat(structureString, Mathf.Floor(item.position.y * 100f) / 100f, ":");
            structureString = string.Concat(structureString, Mathf.Floor(item.position.z * 100f) / 100f, ":");
            structureString = string.Concat(structureString, item.rotation, ":;");
        }

        //Database.provider.SaveStructures(structureString);
        Savedata.saveStructures(structureString);
    }
示例#8
0
        private void GetAllStructuresPositions(NetworkCommandArgs args)
        {
            string _pkg = String.Empty;

            try
            {
                ServerStructure[] structures = SpawnStructures.list_0.ToArray();
                for (int i = 0; i < structures.Length; i++)
                {
                    ServerStructure structure = structures[i];
                    _pkg += $"{Convert.ToInt32(structure.vector3_0.x)}|{Convert.ToInt32(structure.vector3_0.z)}/";
                }
                byte[] serverbuffer = Encoding.UTF8.GetBytes(_pkg);
                args.sender.SendBytes(serverbuffer);
            }
            catch
            {
                byte[] serverbuffer = Encoding.UTF8.GetBytes("An error occured with dumping animals");
                args.sender.SendBytes(serverbuffer);
            }
        }
示例#9
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.");
        }
示例#10
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.");
            }
        }
示例#11
0
 public static void ChangeDefaultServer(ServerStructure server)
 {
     ChangeDefault(server);
 }
示例#12
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();
            }
        }
示例#13
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.");
        }