Server.Network.PacketHandlers.UnicodeSpeech C# (CSharp) Méthode

UnicodeSpeech() public static méthode

public static UnicodeSpeech ( NetState state, PacketReader pvSrc ) : void
state NetState
pvSrc PacketReader
Résultat void
        public static void UnicodeSpeech( NetState state, PacketReader pvSrc )
        {
            Mobile from = state.Mobile;

            MessageType type = (MessageType)pvSrc.ReadByte();
            int hue = pvSrc.ReadInt16();
            pvSrc.ReadInt16(); // font
            string lang = pvSrc.ReadString( 4 );
            string text;

            bool isEncoded = (type & MessageType.Encoded) != 0;
            int[] keywords;

            if ( isEncoded )
            {
                int value = pvSrc.ReadInt16();
                int count = (value & 0xFFF0) >> 4;
                int hold = value & 0xF;

                if ( count < 0 || count > 50 )
                    return;

                KeywordList keyList = m_KeywordList;

                for ( int i = 0; i < count; ++i )
                {
                    int speechID;

                    if ( (i & 1) == 0 )
                    {
                        hold <<= 8;
                        hold |= pvSrc.ReadByte();
                        speechID = hold;
                        hold = 0;
                    }
                    else
                    {
                        value = pvSrc.ReadInt16();
                        speechID = (value & 0xFFF0) >> 4;
                        hold = value & 0xF;
                    }

                    if ( !keyList.Contains( speechID ) )
                        keyList.Add( speechID );
                }

                text = pvSrc.ReadUTF8StringSafe();

                keywords = keyList.ToArray();
            }
            else
            {
                text = pvSrc.ReadUnicodeStringSafe();

                keywords = m_EmptyInts;
            }

            text = text.Trim();

            if ( text.Length <= 0 || text.Length > 128 )
                return;

            type &= ~MessageType.Encoded;

            if ( !Enum.IsDefined( typeof( MessageType ), type ) )
                type = MessageType.Regular;

            from.Language = lang;
            from.DoSpeech( text, keywords, type, Utility.ClipDyedHue( hue ) );
        }
PacketHandlers