Example #1
0
        public void SendCpeMessage(CpeMessageType id, string message, bool colorParse = true)
        {
            if (id != CpeMessageType.Normal && !HasCpeExt(CpeExt.MessageTypes))
            {
                if (id == CpeMessageType.Announcement)
                {
                    id = CpeMessageType.Normal;
                }
                else
                {
                    return;
                }
            }
            message = ConvertMessage(message, colorParse);

            byte[] buffer = new byte[66];
            buffer[0] = Opcode.Message;
            buffer[1] = (byte)id;
            if (HasCpeExt(CpeExt.FullCP437))
            {
                NetUtils.WriteCP437(message, buffer, 2);
            }
            else
            {
                NetUtils.WriteAscii(message, buffer, 2);
            }
            SendRaw(buffer);
        }
Example #2
0
 /// <summary> Sends a raw message without performing any token resolving, emoticon parsing, or color parsing. </summary>
 public void SendRawMessage(CpeMessageType id, string message)
 {
     byte[] buffer = new byte[66];
     buffer[0] = Opcode.Message;
     buffer[1] = (byte)id;
     NetUtils.Write(message, buffer, 2, HasCpeExt(CpeExt.FullCP437));
     Send(buffer);
 }
Example #3
0
 public static byte[] Message(string message, CpeMessageType type, bool hasCp437)
 {
     byte[] buffer = new byte[66];
     buffer[0] = Opcode.Message;
     buffer[1] = (byte)type;
     NetUtils.Write(message, buffer, 2, hasCp437);
     return(buffer);
 }
Example #4
0
 /// <summary>
 /// Sends a CpeMessage to all players on the specified level
 /// </summary>
 /// <param name="level"></param>
 /// <param name="type"></param>
 /// <param name="message"></param>
 public static void CpeMessageLevel(Level level, CpeMessageType type, string message)
 {
     Server.Players.ForEach(player => { if (player.Level == level)
                                        {
                                            player.SendCpeMessage(type, message);
                                        }
                            });
 }
Example #5
0
 void SendLevelRaw(string message, bool announce = false)
 {
     Player[] players = PlayerInfo.Online.Items;
     foreach (Player p in players)
     {
         if (p.level != CurLevel)
         {
             continue;
         }
         CpeMessageType type = announce && p.HasCpeExt(CpeExt.MessageTypes)
             ? CpeMessageType.Announcement : CpeMessageType.Normal;
         p.SendRawMessage(type, message);
     }
 }
Example #6
0
        void SendLevelRaw(string message, bool announce = false)
        {
            Player[] players = PlayerInfo.Online.Items;
            foreach (Player p in players)
            {
                if (p.level != Map)
                {
                    continue;
                }
                CpeMessageType type = announce && p.Supports(CpeExt.MessageTypes)
                    ? CpeMessageType.Announcement : CpeMessageType.Normal;

                p.Send(Packet.Message(message, type, p.hasCP437));
            }
        }
Example #7
0
        void UpdateAllStatus(CpeMessageType status)
        {
            Player[] online = PlayerInfo.Online.Items;
            foreach (Player p in online)
            {
                if (p.level != Map)
                {
                    continue;
                }

                string msg = status == CpeMessageType.Status1 ? FormatStatus1(p) :
                             (status == CpeMessageType.Status2 ? FormatStatus2(p) : FormatStatus3(p));
                p.SendCpeMessage(status, msg);
            }
        }
Example #8
0
 public void SendCpeMessage(CpeMessageType id, string message, bool colorParse = true)
 {
     if (id != CpeMessageType.Normal && !HasCpeExt(CpeExt.MessageTypes))
     {
         if (id == CpeMessageType.Announcement)
         {
             id = CpeMessageType.Normal;
         }
         else
         {
             return;
         }
     }
     message = Chat.Format(message, this, colorParse);
     SendRawMessage(id, message);
 }
Example #9
0
 public void SendCpeMessage(CpeMessageType type, string message, bool colorParse = true)
 {
     if (type != CpeMessageType.Normal && !Supports(CpeExt.MessageTypes))
     {
         if (type == CpeMessageType.Announcement)
         {
             type = CpeMessageType.Normal;
         }
         else
         {
             return;
         }
     }
     message = Chat.Format(message, this, colorParse);
     Send(Packet.Message(message, type, hasCP437));
 }
Example #10
0
        /// <summary> Sends a raw message without performing any token resolving, emoticon parsing, or color parsing. </summary>
        public void SendRawMessage(CpeMessageType id, string message)
        {
            byte[] buffer = new byte[66];
            buffer[0] = Opcode.Message;
            buffer[1] = (byte)id;

            if (HasCpeExt(CpeExt.FullCP437))
            {
                NetUtils.WriteCP437(message, buffer, 2);
            }
            else
            {
                NetUtils.WriteAscii(message, buffer, 2);
            }
            SendRaw(buffer);
        }
Example #11
0
 static void MessageAll(ZombieGame game, CpeMessageType type, string message)
 {
     if (!game.Running)
     {
         return;
     }
     Player[] online = PlayerInfo.Online.Items;
     foreach (Player p in online)
     {
         if (!p.level.name.CaselessEq(game.CurLevelName))
         {
             continue;
         }
         p.SendCpeMessage(type, message);
     }
 }
Example #12
0
        public void SendCpeMessage(CpeMessageType type, string message)
        {
            if (type != CpeMessageType.Normal && !Supports(CpeExt.MessageTypes))
            {
                if (type == CpeMessageType.Announcement)
                {
                    type = CpeMessageType.Normal;
                }
                else
                {
                    return;
                }
            }

            message = Chat.Format(message, this);
            Session.SendMessage(type, message);
        }
        /// <summary>
        /// Sends a CpeMessage to the client
        /// <para>NOTE: CpeMessages are single lined, therefore cannot be wrapped</para>
        /// </summary>
        public void SendCpeMessage(CpeMessageType type, string message)
        {
            if (type == CpeMessageType.Chat)
            {
                SendMessage(message); return;
            }
            if (message.Length > 64)
            {
                message = message.Substring(0, 64);
            }

            ByteBuffer buffer = new ByteBuffer(Opcodes.Message);

            buffer.WriteByte((byte)type);
            buffer.WriteString(message, UseCP437 ? Server.CP437 : Encoding.ASCII);
            SendRaw(buffer.Data);
        }
Example #14
0
        public void MessageMap(CpeMessageType type, string message)
        {
            if (!Running)
            {
                return;
            }
            Player[] online = PlayerInfo.Online.Items;

            foreach (Player p in online)
            {
                if (p.level != Map)
                {
                    continue;
                }
                p.SendCpeMessage(type, message);
            }
        }
        public void SendCpeMessage(CpeMessageType type, string message)
        {
            if (type != CpeMessageType.Normal && !Supports(CpeExt.MessageTypes))
            {
                if (type == CpeMessageType.Announcement)
                {
                    type = CpeMessageType.Normal;
                }
                else
                {
                    return;
                }
            }

            message = Chat.Format(message, this);
            message = LineWrapper.CleanupColors(message, this);
            Send(Packet.Message(message, type, hasCP437));
        }
Example #16
0
        protected void DoCountdown(string format, int delay, int minThreshold)
        {
            const CpeMessageType type = CpeMessageType.Announcement;

            for (int i = delay; i > 0 && Running; i--)
            {
                if (i == 1)
                {
                    MessageMap(type, String.Format(format, i)
                               .Replace("seconds", "second"));
                }
                else if (i < minThreshold || (i % 10) == 0)
                {
                    MessageMap(type, String.Format(format, i));
                }
                Thread.Sleep(1000);
            }
            MessageMap(type, "");
        }
Example #17
0
 /// <summary>
 /// Sends a CpeMessage to all players currently online
 /// </summary>
 /// <param name="type"></param>
 /// <param name="message"></param>
 public static void CpeMessageAll(CpeMessageType type, string message)
 {
     Server.Players.ForEach(player => player.SendCpeMessage(type, message));
 }
Example #18
0
 public override void SendMessage(CpeMessageType type, string message)
 {
     message = CleanupColors(message);
     Send(Packet.Message(message, type, player.hasCP437));
 }
Example #19
0
 public static byte[] Message(string message, CpeMessageType type, bool hasCp437)
 {
     byte[] buffer = new byte[66];
     WriteMessage(message, (byte)type, hasCp437, buffer, 0);
     return(buffer);
 }
Example #20
0
 public override void SendMessage(CpeMessageType type, string message)
 {
 }
Example #21
0
 public void SendMessage(CpeMessageType type, string message)
 {
     Send(Packet.Message(message, type, player.hasCP437));
 }
Example #22
0
 /// <summary> Sends a message packet to the client </summary>
 public abstract void SendMessage(CpeMessageType type, string message);