Ejemplo n.º 1
0
        public static bool Send(Objects.Client client, string textId, Location location, Color color, ClientFont font, string text)
        {
            DisplayTextPacket p = new DisplayTextPacket(client);

            p.TextId = textId;
            p.Location = location;
            p.Color = color;
            p.Font = font;
            p.Text = text;

            return p.Send();
        }
        public static bool Send(Objects.Client client, uint creatureId , string creatureName, Location location, Color color, ClientFont font, string text)
        {
            DisplayCreatureTextPacket p = new DisplayCreatureTextPacket(client);

            p.CreatureId = creatureId;
            p.CreatureName = creatureName;
            p.Location = location;
            p.Color = color;
            p.Font = font;
            p.Text = text;

            return p.Send();
        }
Ejemplo n.º 3
0
        public bool UpdateIcon(uint iconId, ushort posX, ushort posY, ushort size, ushort itemId, ushort itemCount, ClientFont font, Color color)
        {
            if (client.Dll.Pipe == null)
            {
                client.Dll.InitializePipe();
                client.Dll.PipeIsReady.WaitOne();
            }

            if (!iconIds.Contains(iconId) || color == null)
                return false;

            return Packets.Pipes.UpdateIconPacket.Send(client, iconId, posX, posY, size, itemId, itemCount, font, color);
        }
Ejemplo n.º 4
0
        public bool DrawCreatureText(string creatureName, Location loc, Color color, ClientFont font, string text)
        {
            //Testing that user has given valid values
            if (creatureName == string.Empty || text == string.Empty)
                return false;

            if (client.Dll.Pipe == null)
            {
                client.Dll.InitializePipe();
                client.Dll.PipeIsReady.WaitOne();
            }

            return Packets.Pipes.DisplayCreatureTextPacket.Send(client, 0, creatureName, loc, color, font, text);
        }
Ejemplo n.º 5
0
        public static DisplayTextPacket Create(ConnectionProvider connection, string textId, Location loc, Color color, ClientFont font, string text)
        {
            PipePacketBuilder p = new PipePacketBuilder(connection, PipePacketType.DisplayText);
            p.AddString(textId);
            p.AddInt(loc.X.ToInt32());
            p.AddInt(loc.Y.ToInt32());
            p.AddInt(color.R);
            p.AddInt(color.G);
            p.AddInt(color.B);
            p.AddInt((int)font);
            p.AddString(text);

            return new DisplayTextPacket(connection, p.GetPacket());
        }
Ejemplo n.º 6
0
        public bool DrawCreatureText(uint CreatureID, Location loc, Color color, ClientFont font, string Text)
        {
            //Testing that user has given valid values
            if (CreatureID == 0 || Text == string.Empty)
                return false;

            if (client.Dll.Pipe == null)
            {
                client.Dll.InitializePipe();
                client.Dll.PipeIsReady.WaitOne();
            }

            return Packets.Pipes.DisplayCreatureTextPacket.Send(client, CreatureID, "MyChar", loc, color, font, Text);
        }
        public static DisplayCreatureTextPacket Create(ConnectionProvider connection, int creatureID, string creatureName, Location loc, Color color, ClientFont font, string text)
        {
            PipePacketBuilder p = new PipePacketBuilder(connection, PipePacketType.DisplayCreatureText);
            p.AddLong(creatureID);
            p.AddString(creatureName);
            p.AddShort(loc.X);
            p.AddShort(loc.Y);
            p.AddInt(color.R);
            p.AddInt(color.G);
            p.AddInt(color.B);
            p.AddInt((int)font);
            p.AddString(text);

            return new DisplayCreatureTextPacket(connection, p.GetPacket());
        }
Ejemplo n.º 8
0
        public static new bool Send(Objects.Client client, uint iconId, ushort posX, ushort posY, ushort size, ushort itemId, ushort itemCount, ClientFont font, Color color)
        {
            UpdateIconPacket p = new UpdateIconPacket(client);

            p.IconId = iconId;
            p.PosX = posX;
            p.PosY = posY;
            p.Size = size;
            p.ItemId = itemId;
            p.ItemCount = itemCount;
            p.Font = font;
            p.Color = color;

            return p.Send();
        }
Ejemplo n.º 9
0
        public bool DrawCreatureText(uint CreatureID, Location loc, Color color, ClientFont font, string Text)
        {
            //Testing that user has given valid values
            if (CreatureID == 0 || Text == string.Empty)
            {
                return(false);
            }

            if (client.Dll.Pipe == null)
            {
                client.Dll.InitializePipe();
                client.Dll.PipeIsReady.WaitOne();
            }

            return(Packets.Pipes.DisplayCreatureTextPacket.Send(client, CreatureID, "MyChar", loc, color, font, Text));
        }
Ejemplo n.º 10
0
        public bool DrawCreatureText(string creatureName, Location loc, Color color, ClientFont font, string text)
        {
            //Testing that user has given valid values
            if (creatureName == string.Empty || text == string.Empty)
            {
                return(false);
            }

            if (client.Dll.Pipe == null)
            {
                client.Dll.InitializePipe();
                client.Dll.PipeIsReady.WaitOne();
            }

            return(Packets.Pipes.DisplayCreatureTextPacket.Send(client, 0, creatureName, loc, color, font, text));
        }
Ejemplo n.º 11
0
 /// <summary>
 /// Draws the creature text.
 /// </summary>
 /// <param name="creatureName">Name of the creature.</param>
 /// <param name="loc">The loc.</param>
 /// <param name="color">The color.</param>
 /// <param name="font">The font.</param>
 /// <param name="text">The text.</param>
 public void DrawCreatureText(string creatureName, Location loc, Color color, ClientFont font, string text)
 {
     Connection.Pipe.Send(DisplayCreatureTextPacket.Create(Connection, 0, creatureName, loc, color, font, text));
 }
Ejemplo n.º 12
0
        public static bool Send(Objects.Client client, uint iconId, ushort posX, ushort posY, ushort size, ushort itemId, ushort itemCount, ClientFont font, Color color)
        {
            AddIconPacket p = new AddIconPacket(client);

            p.IconId    = iconId;
            p.PosX      = posX;
            p.PosY      = posY;
            p.Size      = size;
            p.ItemId    = itemId;
            p.ItemCount = itemCount;
            p.Font      = font;
            p.Color     = color;

            return(p.Send());
        }
Ejemplo n.º 13
0
        public static bool Send(Objects.Client client, string textId, Location location, Color color, ClientFont font, string text)
        {
            DisplayTextPacket p = new DisplayTextPacket(client);

            p.TextId   = textId;
            p.Location = location;
            p.Color    = color;
            p.Font     = font;
            p.Text     = text;

            return(p.Send());
        }
Ejemplo n.º 14
0
        public override void OnAfterPacket(IClient client, IPacket packet)
        {
            if (packet.Id == (byte)AresId.MSG_CHAT_ADVANCED_FEATURES_PROTOCOL)
            {
                if (!(((Advanced)packet).Payload is AdvancedPacket advanced))
                {
                    return;// could be "Unknown" type
                }
                switch ((AdvancedId)advanced.Id)
                {
                case AdvancedId.MSG_CHAT_CLIENT_CUSTOM_ADD_TAGS:
                    break;

                case AdvancedId.MSG_CHAT_CLIENT_CUSTOM_REM_TAGS:
                    break;

                case AdvancedId.MSG_CHAT_CLIENT_CUSTOM_FONT:
                    ClientFont font     = (ClientFont)advanced;
                    ServerFont userfont = (ServerFont)client.Extended["CustomFont"];

                    if (userfont == null)
                    {
                        userfont = new ServerFont();
                        client.Extended["CustomFont"] = userfont;
                    }

                    userfont.Username   = client.Name;
                    userfont.Size       = font.Size;
                    userfont.Name       = font.Name;
                    userfont.NameColor  = font.NameColor;
                    userfont.TextColor  = font.TextColor;
                    userfont.NameColor2 = font.NameColor2;
                    userfont.TextColor2 = font.TextColor2;

                    if (string.IsNullOrEmpty(userfont.NameColor2))
                    {
                        userfont.NameColor2 = userfont.NameColor.ToHtmlColor();
                    }

                    if (string.IsNullOrEmpty(userfont.TextColor2))
                    {
                        userfont.TextColor2 = userfont.TextColor.ToHtmlColor();
                    }

                    Server.SendPacket((s) => s.Vroom == client.Vroom, new Advanced(userfont));

                    if (String.IsNullOrWhiteSpace(font.Name))
                    {
                        client.Extended["CustomFont"] = null;
                    }

                    break;

                case AdvancedId.MSG_CHAT_CLIENT_VC_SUPPORTED:
                    ClientVoiceSupport vcs = (ClientVoiceSupport)advanced;

                    if (vcs.Public)
                    {
                        client.Features |= ClientFlags.VOICE;
                    }

                    if (vcs.Private)
                    {
                        client.Features |= ClientFlags.PRIVATE_VOICE;
                    }

                    Server.SendPacket((s) => s.Vroom == client.Vroom,
                                      new Advanced(new ServerVoiceSupportUser()
                    {
                        Username = client.Name,
                        Public   = vcs.Public,
                        Private  = vcs.Private,
                    }));
                    break;

                case AdvancedId.MSG_CHAT_CLIENT_VC_FIRST:
                    ClientVoiceFirst vcf = (ClientVoiceFirst)advanced;

                    Server.SendPacket((s) =>
                                      (s.Vroom == client.Vroom) &&
                                      (s.Features & ClientFlags.VOICE) == ClientFlags.VOICE &&
                                      !((List <String>)s.Extended["VoiceIgnore"]).Contains(client.Name),

                                      new Advanced(new ServerVoiceFirst()
                    {
                        Username = client.Name,
                        Data     = vcf.Data
                    }));

                    break;

                case AdvancedId.MSG_CHAT_CLIENT_VC_FIRST_TO: {
                    ClientVoiceFirstTo vcf2 = (ClientVoiceFirstTo)advanced;

                    IClient target = Server.FindUser((s) =>
                                                     s.Name == vcf2.Username &&
                                                     s.Vroom == client.Vroom);

                    if (target == null)
                    {
                        return;
                    }

                    if ((client.Features & ClientFlags.PRIVATE_VOICE) != ClientFlags.PRIVATE_VOICE)
                    {
                        client.SendPacket(new Advanced(new ServerVoiceNoPrivate()
                            {
                                Username = target.Name
                            }));
                    }

                    else if (((List <String>)target.Extended["VoiceIgnore"]).Contains(client.Name))
                    {
                        client.SendPacket(new Advanced(new ServerVoiceIgnore()
                            {
                                Username = target.Name
                            }));
                    }

                    else
                    {
                        target.SendPacket(new Advanced(new ServerVoiceFirstFrom()
                            {
                                Username = client.Name,
                                Data     = vcf2.Data
                            }));
                    }
                }
                break;

                case AdvancedId.MSG_CHAT_CLIENT_VC_CHUNK:
                    ClientVoiceChunk vcc = (ClientVoiceChunk)advanced;

                    Server.SendPacket((s) =>
                                      (s.Vroom == client.Vroom) &&
                                      (s.Features & ClientFlags.VOICE) == ClientFlags.VOICE &&
                                      !((List <String>)s.Extended["VoiceIgnore"]).Contains(client.Name),

                                      new Advanced(new ServerVoiceChunk()
                    {
                        Username = client.Name,
                        Data     = vcc.Data
                    }));

                    break;

                case AdvancedId.MSG_CHAT_CLIENT_VC_CHUNK_TO: {
                    ClientVoiceChunkTo vcc2 = (ClientVoiceChunkTo)advanced;

                    IClient target = Server.FindUser((s) =>
                                                     s.Name == vcc2.Username &&
                                                     s.Vroom == client.Vroom);

                    if (target == null)
                    {
                        return;
                    }

                    if ((client.Features & ClientFlags.PRIVATE_VOICE) == ClientFlags.PRIVATE_VOICE)
                    {
                        client.SendPacket(new Advanced(new ServerVoiceNoPrivate()
                            {
                                Username = target.Name
                            }));
                    }

                    else if (((List <String>)target.Extended["VoiceIgnore"]).Contains(client.Name))
                    {
                        client.SendPacket(new Advanced(new ServerVoiceIgnore()
                            {
                                Username = target.Name
                            }));
                    }

                    else
                    {
                        target.SendPacket(new Advanced(new ServerVoiceFirstFrom()
                            {
                                Username = client.Name,
                                Data     = vcc2.Data
                            }));
                    }
                }
                break;

                case AdvancedId.MSG_CHAT_CLIENT_VC_IGNORE:
                    ClientVoiceIgnore vci     = (ClientVoiceIgnore)advanced;
                    List <String>     ignores = (List <String>)client.Extended["VoiceIgnore"];

                    if (ignores.Contains(vci.Username))
                    {
                        ignores.RemoveAll((s) => s == vci.Username);
                        Server.SendAnnounce(client, String.Format("You are now allowing voice chat from {0}", vci.Username));
                    }
                    else
                    {
                        ignores.Add(vci.Username);
                        Server.SendAnnounce(client, String.Format("You are now ignoring voice chat from {0}", vci.Username));
                    }
                    break;

                case AdvancedId.MSG_CHAT_CLIENT_SUPPORTS_CUSTOM_EMOTES:
                    client.Extended["SupportEmote"] = true;

                    foreach (var user in Server.Users)
                    {
                        if (user.Vroom == client.Vroom)
                        {
                            var emotes = (List <ClientEmoteItem>)client.Extended["CustomEmote"];

                            if (emotes.Count > 0)
                            {
                                foreach (var emote in emotes)
                                {
                                    client.SendPacket(new Advanced(new ServerEmoteItem()
                                    {
                                        Username = user.Name,
                                        Shortcut = emote.Shortcut,
                                        Size     = emote.Size,
                                        Image    = emote.Image,
                                    }));
                                }
                            }
                        }
                    }
                    break;

                case AdvancedId.MSG_CHAT_SERVER_CUSTOM_EMOTES_ITEM: {
                    client.Extended["SupportEmote"] = true;
                    ClientEmoteItem item = (ClientEmoteItem)advanced;

                    ((List <ClientEmoteItem>)client.Extended["CustomEmote"]).Add(item);

                    if (client.Cloaked)
                    {
                        Server.SendPacket((s) =>
                                          s.Admin >= client.Admin &&
                                          s.Vroom == client.Vroom &&
                                          (bool)s.Extended["SupportEmote"],
                                          new Advanced(new ServerEmoteItem()
                            {
                                Username = client.Name,
                                Shortcut = item.Shortcut,
                                Size     = item.Size,
                                Image    = item.Image,
                            }));
                    }
                    else
                    {
                        Server.SendPacket((s) =>
                                          s.Vroom == client.Vroom &&
                                          (bool)s.Extended["SupportEmote"],
                                          new Advanced(new ServerEmoteItem()
                            {
                                Username = client.Name,
                                Shortcut = item.Shortcut,
                                Size     = item.Size,
                                Image    = item.Image,
                            }));
                    }
                }
                break;

                case AdvancedId.MSG_CHAT_CLIENT_CUSTOM_EMOTE_DELETE: {
                    ClientEmoteDelete item = (ClientEmoteDelete)advanced;

                    var emotes = ((List <ClientEmoteItem>)client.Extended["CustomEmote"]);
                    int index  = emotes.FindIndex(s => s.Shortcut == item.Shortcut);

                    if (index > -1)
                    {
                        emotes.RemoveAt(index);

                        Server.SendPacket((s) => s.Vroom == client.Vroom && (bool)s.Extended["SupportEmote"],
                                          new Advanced(new ServerEmoteDelete()
                            {
                                Username = client.Name,
                                Shortcut = item.Shortcut,
                            }));
                    }
                }
                break;

                case AdvancedId.MSG_CHAT_CLIENT_ROOM_SCRIBBLE_FIRST:
                    OnScribbleFirst(client, (ClientScribbleFirst)advanced);
                    break;

                case AdvancedId.MSG_CHAT_CLIENT_ROOM_SCRIBBLE_CHUNK:
                    OnScribbleChunk(client, (ClientScribbleChunk)advanced);
                    break;
                }
            }
        }
Ejemplo n.º 15
0
 /// <summary>
 /// Draws the screen text.
 /// </summary>
 /// <param name="TextName">Name of the text.</param>
 /// <param name="loc">The loc.</param>
 /// <param name="color">The color.</param>
 /// <param name="font">The font.</param>
 /// <param name="text">The text.</param>
 public void DrawScreenText(string TextName, Location loc, Color color, ClientFont font, string text)
 {
     Connection.Pipe.Send(DisplayTextPacket.Create(Connection, TextName, loc, color, font, text));
 }
Ejemplo n.º 16
0
        public bool UpdateIcon(uint iconId, ushort posX, ushort posY, ushort size, ushort itemId, ushort itemCount, ClientFont font, Color color)
        {
            if (client.Dll.Pipe == null)
            {
                client.Dll.InitializePipe();
                client.Dll.PipeIsReady.WaitOne();
            }

            if (!iconIds.Contains(iconId) || color == null)
            {
                return(false);
            }

            return(Packets.Pipes.UpdateIconPacket.Send(client, iconId, posX, posY, size, itemId, itemCount, font, color));
        }
Ejemplo n.º 17
0
        public new bool ParseData(byte[] packet)
        {
            if (base.ParseData(packet)) {
                if (pipetype != PipePacketType.DisplayText) { return false; }
                PipePacketBuilder p = new PipePacketBuilder(ConnectionSource, packet, 3);
                textname = p.GetString();
                loc.X = p.GetInt();
                loc.Y = p.GetInt();
                loc.Z = 0; // No need
                red = p.GetInt();
                green = p.GetInt();
                blue = p.GetInt();
                color = Color.FromArgb(red, green, blue);
                font = (ClientFont)p.GetInt();
                text = p.GetString();

                index = p.Index;
                return true;
            }
            else {
                return false;
            }
        }
        public static bool Send(Objects.Client client, uint creatureId, string creatureName, Location location, Color color, ClientFont font, string text)
        {
            DisplayCreatureTextPacket p = new DisplayCreatureTextPacket(client);

            p.CreatureId   = creatureId;
            p.CreatureName = creatureName;
            p.Location     = location;
            p.Color        = color;
            p.Font         = font;
            p.Text         = text;

            return(p.Send());
        }
Ejemplo n.º 19
0
 /// <summary>
 /// Draws the creature text.
 /// </summary>
 /// <param name="CreatureID">The creature ID.</param>
 /// <param name="loc">The loc.</param>
 /// <param name="color">The color.</param>
 /// <param name="font">The font.</param>
 /// <param name="Text">The text.</param>
 public void DrawCreatureText(int CreatureID, Location loc, Color color, ClientFont font, string Text)
 {
     Connection.Pipe.Send(DisplayCreatureTextPacket.Create(Connection, CreatureID, "MyChar", loc, color, font, Text));
 }