コード例 #1
0
        internal static void OnSpeech(Packet pvSrc, PacketHandlerEventArgs args)
        {
            MessageType   type      = (MessageType)pvSrc.ReadByte();
            ushort        hue       = pvSrc.ReadUInt16();
            ushort        font      = pvSrc.ReadUInt16();
            string        lang      = pvSrc.ReadString(4);
            string        text      = "";
            List <ushort> keys      = null;
            long          txtOffset = 0;

            World.Player.SpeechHue = hue;

            if ((type & MessageType.Encoded) != 0)
            {
                int value = pvSrc.ReadInt16();
                int count = (value & 0xFFF0) >> 4;
                keys = new List <ushort> {
                    (ushort)value
                };

                for (int i = 0; i < count; ++i)
                {
                    if ((i & 1) == 0)
                    {
                        keys.Add(pvSrc.ReadByte());
                    }
                    else
                    {
                        keys.Add(pvSrc.ReadByte());
                        keys.Add(pvSrc.ReadByte());
                    }
                }

                txtOffset = pvSrc.Position;
                text      = pvSrc.ReadUTF8StringSafe();
                type     &= ~MessageType.Encoded;
            }
            else
            {
                txtOffset = pvSrc.Position;
                text      = pvSrc.ReadUnicodeStringSafe();
            }

            if (RazorEnhanced.ScriptRecorder.OnRecord)
            {
                RazorEnhanced.ScriptRecorder.Record_UnicodeSpeech(text, hue);
            }

            text = text.Trim();

            if (text.Length <= 1)
            {
                return;
            }

            {
                if (text[0] == '-' && text[1] != '-')
                {
                    text = text.Substring(1).ToLower();
                    string[] split = text.Split(' ', '\t');
                    if (m_List.ContainsKey(split[0]))
                    {
                        CommandCallback call = (CommandCallback)m_List[split[0]];
                        if (call != null)
                        {
                            string[] param = new String[split.Length - 1];
                            for (int i = 0; i < param.Length; i++)
                            {
                                param[i] = split[i + 1];
                            }
                            call(param);

                            args.Block = true;
                        }
                    }
                }
                else if (text[0] == '-' && text[1] == '-')
                {
                    args.Block = true;
                    ClientCommunication.PostTextSend(text.Substring(2));
                }
            }
        }