当前位置: 首页>>代码示例>>C#>>正文


C# BitPack.WriteStringLength方法代码示例

本文整理汇总了C#中BitPack.WriteStringLength方法的典型用法代码示例。如果您正苦于以下问题:C# BitPack.WriteStringLength方法的具体用法?C# BitPack.WriteStringLength怎么用?C# BitPack.WriteStringLength使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BitPack的用法示例。


在下文中一共展示了BitPack.WriteStringLength方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SendMessage

        public static void SendMessage(ref WorldClass session, ChatMessageValues chatMessage, WorldClass pSession = null)
        {
            byte[] GuidMask = { 4, 1, 3, 6, 2, 5, 0, 7 };
            byte[] GuidMask3 = { 6, 1, 3, 5, 4, 2, 7, 0 };
            byte[] GuidBytes = { 7, 4, 0, 6, 3, 2, 5, 1 };
            byte[] GuidBytes3 = { 7, 4, 1, 3, 0, 6, 5, 2 };

            var pChar = session.Character;
            var guid = pChar.Guid;

            if (pSession != null)
                guid = pSession.Character.Guid;

            PacketWriter chat = new PacketWriter(ServerMessage.Chat);
            BitPack BitPack = new BitPack(chat, guid);

            BitPack.Write(!chatMessage.HasLanguage);
            BitPack.Write(1);
            BitPack.Write(1);
            BitPack.Write(0, 8);
            BitPack.Write(1);
            BitPack.Write(0);
            BitPack.Write(1);
            BitPack.Write(1);
            BitPack.Write(1);
            BitPack.Write(0, 8);
            BitPack.Write(0);

            BitPack.WriteGuidMask(GuidMask3);

            BitPack.Write(1);
            BitPack.Write(0);
            BitPack.Write(1);
            BitPack.Write(!chatMessage.HasRealmId);
            BitPack.Write(0);
            BitPack.WriteStringLength(chatMessage.Message, 12);
            BitPack.Write(0);

            BitPack.WriteGuidMask(GuidMask);

            BitPack.Write(0);
            BitPack.Write(8, 9);

            BitPack.Flush();

            BitPack.WriteGuidBytes(GuidBytes3);

            if (chatMessage.HasLanguage)
                chat.WriteUInt8(chatMessage.Language);

            BitPack.WriteGuidBytes(GuidBytes);

            chat.WriteString(chatMessage.Message, false);
            chat.WriteUInt8((byte)chatMessage.ChatType);

            chat.WriteInt32(0);

            if (chatMessage.HasRealmId)
                chat.WriteInt32(chatMessage.RealmId);

            switch (chatMessage.ChatType)
            {
                case MessageType.ChatMessageSay:
                    WorldMgr.SendByDist(pChar, chat, 625);
                    break;
                case MessageType.ChatMessageYell:
                    WorldMgr.SendByDist(pChar, chat, 90000);
                    break;
                default:
                    session.Send(ref chat);
                    break;
            }
        }
开发者ID:rodrigoalv,项目名称:Arctium-WoW,代码行数:73,代码来源:ChatHandler.cs


注:本文中的BitPack.WriteStringLength方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。