Ejemplo n.º 1
0
        /// <summary>
        /// Sends chat server info to client
        /// </summary>
        /// <param name="client">
        /// Client that gets the info
        /// </param>
        public static void Send(IZoneClient client)
        {
            /* get chat settings from config */
            string    chatServerIp = string.Empty;
            IPAddress tempIp;

            if (IPAddress.TryParse(ConfigReadWrite.Instance.CurrentConfig.ChatIP, out tempIp))
            {
                chatServerIp = ConfigReadWrite.Instance.CurrentConfig.ChatIP;
            }
            else
            {
                IPHostEntry chatHost = Dns.GetHostEntry(ConfigReadWrite.Instance.CurrentConfig.ChatIP);
                foreach (IPAddress ip in chatHost.AddressList)
                {
                    if (ip.AddressFamily == AddressFamily.InterNetwork)
                    {
                        chatServerIp = ip.ToString();
                        break;
                    }
                }
            }

            int chatPort = Convert.ToInt32(ConfigReadWrite.Instance.CurrentConfig.ChatPort);

            var chatServerInfoMessage = new ChatServerInfoMessage {
                HostName = chatServerIp, Port = chatPort
            };

            client.SendCompressed(chatServerInfoMessage);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Sends chat server info to client
        /// </summary>
        /// <param name="client">
        /// Client that gets the info
        /// </param>
        public static void Send(IZoneClient client)
        {
            /* get chat settings from config */
            string chatServerIp = string.Empty;
            IPAddress tempIp;
            if (IPAddress.TryParse(ConfigReadWrite.Instance.CurrentConfig.ChatIP, out tempIp))
            {
                chatServerIp = ConfigReadWrite.Instance.CurrentConfig.ChatIP;
            }
            else
            {
                IPHostEntry chatHost = Dns.GetHostEntry(ConfigReadWrite.Instance.CurrentConfig.ChatIP);
                foreach (IPAddress ip in chatHost.AddressList)
                {
                    if (ip.AddressFamily == AddressFamily.InterNetwork)
                    {
                        chatServerIp = ip.ToString();
                        break;
                    }
                }
            }

            int chatPort = Convert.ToInt32(ConfigReadWrite.Instance.CurrentConfig.ChatPort);

            var chatServerInfoMessage = new ChatServerInfoMessage { HostName = chatServerIp, Port = chatPort };
            client.SendCompressed(chatServerInfoMessage);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// </summary>
        /// <param name="client">
        /// </param>
        /// <param name="item">
        /// </param>
        public static void Send(IZoneClient client, Item item)
        {
            var message = new AddTemplateMessage
                              {
                                  Identity = client.Character.Identity,
                                  Unknown = 0x00,
                                  LowId = item.LowID,
                                  HighId = item.HighID,
                                  Quality = item.Quality,
                                  Count = item.MultipleCount
                              };

            client.SendCompressed(message);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// </summary>
        /// <param name="client">
        /// </param>
        /// <param name="item">
        /// </param>
        public static void Send(IZoneClient client, Item item)
        {
            var message = new AddTemplateMessage
            {
                Identity = client.Character.Identity,
                Unknown  = 0x00,
                LowId    = item.LowID,
                HighId   = item.HighID,
                Quality  = item.Quality,
                Count    = item.MultipleCount
            };

            client.SendCompressed(message);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// </summary>
        /// <param name="client">
        /// </param>
        /// <param name="statsToUpdate">
        /// </param>
        public static void SendBulk(IZoneClient client, Dictionary <int, uint> statsToUpdate)
        {
            if (statsToUpdate.Count == 0)
            {
                return;
            }

            var toPlayfieldIds = new List <int>();

            foreach (KeyValuePair <int, uint> keyValuePair in statsToUpdate)
            {
                if (client.Controller.Character.Stats[keyValuePair.Key].AnnounceToPlayfield)
                {
                    toPlayfieldIds.Add(keyValuePair.Key);
                }
            }

            var toPlayfield = new List <GameTuple <CharacterStat, uint> >();
            var toClient    = new List <GameTuple <CharacterStat, uint> >();

            foreach (KeyValuePair <int, uint> keyValuePair in statsToUpdate)
            {
                var statValue = new GameTuple <CharacterStat, uint>
                {
                    Value1 = (CharacterStat)keyValuePair.Key,
                    Value2 = keyValuePair.Value
                };
                toClient.Add(statValue);

                if (toPlayfieldIds.Contains(keyValuePair.Key))
                {
                    toPlayfield.Add(statValue);
                }
            }

            var message = new StatMessage
            {
                Identity = client.Controller.Character.Identity,
                Stats    = toClient.ToArray()
            };

            client.SendCompressed(message);

            /* announce to playfield? */
            if (toPlayfieldIds.Count > 0)
            {
                message.Stats = toPlayfield.ToArray();
                client.Controller.Character.Playfield.AnnounceOthers(message, client.Controller.Character.Identity);
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// </summary>
        /// <param name="client">
        /// </param>
        /// <param name="stat">
        /// </param>
        /// <param name="value">
        /// </param>
        /// <param name="announce">
        /// </param>
        public static void SendDirect(IZoneClient client, int stat, uint value, bool announce)
        {
            var statMessage = new StatMessage
            {
                Identity = client.Character.Identity,
                Stats    =
                    new[]
                {
                    new GameTuple <CharacterStat, uint>
                    {
                        Value1 =
                            (CharacterStat)stat,
                        Value2 = value
                    }
                }
            };

            client.SendCompressed(statMessage);
        }
Ejemplo n.º 7
0
 /// <summary>
 /// </summary>
 /// <param name="client">
 /// </param>
 public static void Send(IZoneClient client)
 {
     // TODO: Let this in for now, it needs to be removed when Character login is rewritten
     client.SendCompressed(Create(client));
 }
Ejemplo n.º 8
0
 /// <summary>
 /// </summary>
 /// <param name="client">
 /// </param>
 /// <param name="stat">
 /// </param>
 /// <param name="value">
 /// </param>
 /// <param name="announce">
 /// </param>
 public static void SendDirect(IZoneClient client, int stat, uint value, bool announce)
 {
     var statMessage = new StatMessage
                       {
                           Identity = client.Character.Identity,
                           Stats =
                               new[]
                               {
                                   new GameTuple<CharacterStat, uint>
                                   {
                                       Value1 =
                                           (CharacterStat)stat,
                                       Value2 = value
                                   }
                               }
                       };
     client.SendCompressed(statMessage);
 }
Ejemplo n.º 9
0
        /// <summary>
        /// </summary>
        /// <param name="client">
        /// </param>
        /// <param name="statsToUpdate">
        /// </param>
        public static void SendBulk(IZoneClient client, Dictionary<int, uint> statsToUpdate)
        {
            if (statsToUpdate.Count == 0)
            {
                return;
            }

            var toPlayfieldIds = new List<int>();
            foreach (KeyValuePair<int, uint> keyValuePair in statsToUpdate)
            {
                if (client.Character.Stats[keyValuePair.Key].AnnounceToPlayfield)
                {
                    toPlayfieldIds.Add(keyValuePair.Key);
                }
            }

            var toPlayfield = new List<GameTuple<CharacterStat, uint>>();
            var toClient = new List<GameTuple<CharacterStat, uint>>();

            foreach (KeyValuePair<int, uint> keyValuePair in statsToUpdate)
            {
                var statValue = new GameTuple<CharacterStat, uint>
                                {
                                    Value1 = (CharacterStat)keyValuePair.Key,
                                    Value2 = keyValuePair.Value
                                };
                toClient.Add(statValue);

                if (toPlayfieldIds.Contains(keyValuePair.Key))
                {
                    toPlayfield.Add(statValue);
                }
            }

            var message = new StatMessage { Identity = client.Character.Identity, Stats = toClient.ToArray() };

            client.SendCompressed(message);

            /* announce to playfield? */
            if (toPlayfieldIds.Count > 0)
            {
                message.Stats = toPlayfield.ToArray();
                client.Character.Playfield.AnnounceOthers(message, client.Character.Identity);
            }
        }
 /// <summary>
 /// </summary>
 /// <param name="client">
 /// </param>
 public static void Send(IZoneClient client)
 {
     PlayfieldAnarchyFMessage message = Create(client);
     client.SendCompressed(message);
 }
        /// <summary>
        /// </summary>
        /// <param name="client">
        /// </param>
        public static void Send(IZoneClient client)
        {
            PlayfieldAnarchyFMessage message = Create(client);

            client.SendCompressed(message);
        }
Ejemplo n.º 12
0
 /// <summary>
 /// </summary>
 /// <param name="client">
 /// </param>
 public static void Send(IZoneClient client)
 {
     // TODO: Let this in for now, it needs to be removed when Character login is rewritten
     client.SendCompressed(Create(client));
 }