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


C# PacketWriter.WriteUInt16方法代码示例

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


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

示例1: HandleDBQueryBulk

        public static void HandleDBQueryBulk(ref PacketReader packet, ref WorldClass session)
        {
            var type = (DBTypes)packet.ReadUInt32();
            var unknown = packet.ReadInt32();
            var id = packet.ReadInt32();

            switch (type)
            {
                case DBTypes.BroadcastText:
                {
                    var broadCastText = GossipMgr.GetBroadCastText<Creature>(id);

                    PacketWriter dbReply = new PacketWriter(JAMCMessage.DBReply);
                    BitPack BitPack = new BitPack(dbReply);

                    var textLength = broadCastText.Text.Length;
                    var alternativeTextLength = broadCastText.AlternativeText.Length;
                    var size = 48;

                    if (textLength == 0 || alternativeTextLength == 0)
                        size += 1;

                    size += textLength + alternativeTextLength;

                    dbReply.WriteUInt32((uint)size);
                    dbReply.WriteInt32(broadCastText.Id);
                    dbReply.WriteInt32(broadCastText.Language);

                    dbReply.WriteUInt16((ushort)broadCastText.Text.Length);
                    dbReply.WriteString(broadCastText.Text);

                    dbReply.WriteUInt16((ushort)broadCastText.AlternativeText.Length);
                    dbReply.WriteString(broadCastText.AlternativeText);

                    broadCastText.Emotes.ForEach(emote => dbReply.WriteInt32(emote));

                    dbReply.WriteUInt32(1);

                    dbReply.WriteUInt32(0);    // UnixTime, last change server side
                    dbReply.WriteUInt32((uint)DBTypes.BroadcastText);
                    dbReply.WriteInt32(broadCastText.Id);

                    session.Send(ref dbReply);
                    break;
                }
            }
        }
开发者ID:Mathias1000,项目名称:Arctium,代码行数:47,代码来源:GossipHandler.cs

示例2: HandleBroadcastText

        public static void HandleBroadcastText(ref WorldClass session, int id)
        {
            var broadCastText = GossipMgr.GetBroadCastText<Creature>(id);

            PacketWriter dbReply = new PacketWriter(ServerMessage.DBReply);
            BitPack BitPack = new BitPack(dbReply);

            var textLength = broadCastText.Text.Length;
            var alternativeTextLength = broadCastText.AlternativeText.Length;
            var size = 48;

            if (textLength == 0 || alternativeTextLength == 0)
                size += 1;

            size += textLength + alternativeTextLength;

            dbReply.WriteUInt32(0);    // UnixTime, last change server side
            dbReply.WriteUInt32((uint)DBTypes.BroadcastText);
            dbReply.WriteUInt32((uint)size);

            dbReply.WriteInt32(broadCastText.Id);
            dbReply.WriteInt32(broadCastText.Language);

            dbReply.WriteUInt16((ushort)broadCastText.Text.Length);
            dbReply.WriteString(broadCastText.Text);

            dbReply.WriteUInt16((ushort)broadCastText.AlternativeText.Length);
            dbReply.WriteString(broadCastText.AlternativeText);

            broadCastText.Emotes.ForEach(emote => dbReply.WriteInt32(emote));

            dbReply.WriteUInt32(1);

            dbReply.WriteInt32(broadCastText.Id);

            session.Send(ref dbReply);
        }
开发者ID:mansemino,项目名称:Arctium,代码行数:37,代码来源:CacheHandler.cs

示例3: HandleUpdateObjectValues

        public static void HandleUpdateObjectValues(ref WorldClass session)
        {
            WorldObject character = session.Character;
            PacketWriter updateObject = new PacketWriter(LegacyMessage.UpdateObject);

            updateObject.WriteUInt16((ushort)character.Map);
            updateObject.WriteUInt32(1);
            updateObject.WriteUInt8((byte)UpdateType.Values);
            updateObject.WriteGuid(character.Guid);

            character.WriteUpdateFields(ref updateObject);
            character.WriteDynamicUpdateFields(ref updateObject);

            session.Send(ref updateObject);
        }
开发者ID:Mathias1000,项目名称:Arctium,代码行数:15,代码来源:ObjectHandler.cs

示例4: SendMessageByType

        public static void SendMessageByType(ref WorldClass session, MessageType type, int language, string chatMessage)
        {
            PacketWriter messageChat = new PacketWriter(LegacyMessage.MessageChat);
            ulong guid = session.Character.Guid;

            messageChat.WriteUInt8((byte)type);
            messageChat.WriteInt32(language);
            messageChat.WriteUInt64(guid);
            messageChat.WriteUInt32(0);
            messageChat.WriteUInt64(guid);
            messageChat.WriteUInt32((uint)chatMessage.Length + 1);
            messageChat.WriteCString(chatMessage);
            messageChat.WriteUInt16(0);

            session.Send(ref messageChat);
        }
开发者ID:Krogonos,项目名称:Mop-5.1.0-Core,代码行数:16,代码来源:ChatHandler.cs

示例5: HandleUpdateObject

        public static void HandleUpdateObject(ref PacketReader packet, ref WorldClass session)
        {
            Character character = session.Character;
            PacketWriter updateObject = new PacketWriter(LegacyMessage.UpdateObject);

            updateObject.WriteUInt16((ushort)character.Map);
            updateObject.WriteUInt32(1);  // Grml sandbox style...
            updateObject.WriteUInt8(1);
            updateObject.WriteGuid(character.Guid);
            updateObject.WriteUInt8(4);

            UpdateFlag updateFlags = UpdateFlag.Alive | UpdateFlag.Rotation | UpdateFlag.Self | UpdateFlag.Unknown4;
            WorldMgr.WriteUpdateObjectMovement(ref updateObject, ref character, updateFlags);
            character.WriteUpdateFields(ref updateObject);

            session.Send(updateObject);
        }
开发者ID:Gargash,项目名称:Arctium,代码行数:17,代码来源:UpdateHandler.cs

示例6: HandleUpdateObjectCreate

        public static void HandleUpdateObjectCreate(ref WorldClass session)
        {
            WorldObject character = session.Character;
            PacketWriter updateObject = new PacketWriter(LegacyMessage.UpdateObject);

            updateObject.WriteUInt16((ushort)character.Map);
            updateObject.WriteUInt32(1);
            updateObject.WriteUInt8((byte)UpdateType.CreateObject);
            updateObject.WriteGuid(character.Guid);
            updateObject.WriteUInt8((byte)ObjectType.Player);

            UpdateFlag updateFlags = UpdateFlag.Alive | UpdateFlag.Rotation | UpdateFlag.Self;
            WorldMgr.WriteUpdateObjectMovement(ref updateObject, ref character, updateFlags);

            character.WriteUpdateFields(ref updateObject);
            character.WriteDynamicUpdateFields(ref updateObject);

            session.Send(ref updateObject);
        }
开发者ID:dwarfbloody,项目名称:Arctium,代码行数:19,代码来源:ObjectHandler.cs

示例7: HandleChatMessageSay

        public static void HandleChatMessageSay(ref PacketReader packet, ref WorldClass session)
        {
            BitUnpack BitUnpack = new BitUnpack(packet);

            int language = packet.ReadInt32();

            uint messageLength = BitUnpack.GetBits<uint>(9);
            string chatMessage = packet.ReadString(messageLength);

            PacketWriter messageChat = new PacketWriter(LegacyMessage.MessageChat);

            ulong guid = WorldMgr.Session.Character.Guid;

            messageChat.WriteUInt8(1);
            messageChat.WriteInt32(language);
            messageChat.WriteUInt64(guid);
            messageChat.WriteUInt32(0);
            messageChat.WriteUInt64(guid);
            messageChat.WriteUInt32(messageLength + 1);
            messageChat.WriteCString(chatMessage);
            messageChat.WriteUInt16(0);

            session.Send(messageChat);
        }
开发者ID:Gargash,项目名称:Arctium,代码行数:24,代码来源:ChatHandler.cs

示例8: HandleAuthLogonProof

        public void HandleAuthLogonProof(PacketReader data)
        {
            Log.Message(LogType.NORMAL, "AuthLogonProof");

            using (var logonProof = new PacketWriter())
            {
                var a = data.ReadBytes(32);
                var m1 = data.ReadBytes(20);

                SecureRemotePassword.CalculateU(a);
                SecureRemotePassword.CalculateM2(m1);
                SecureRemotePassword.CalculateK();

                foreach (var b in SecureRemotePassword.K)
                    if (b < 0x10)
                        account.SessionKey += "0" + String.Format(CultureInfo.InvariantCulture, "{0:X}", b);
                    else
                        account.SessionKey += String.Format(CultureInfo.InvariantCulture, "{0:X}", b);

                logonProof.WriteUInt8((byte)ClientLink.CMD_AUTH_LOGON_PROOF);
                logonProof.WriteUInt8(0);
                logonProof.WriteBytes(SecureRemotePassword.M2);
                logonProof.WriteUInt32(0x800000);
                logonProof.WriteUInt32(0);
                logonProof.WriteUInt16(0);

                SecureRemotePassword.Dispose();

                DB.Realms.Execute("UPDATE accounts SET sessionkey = ? WHERE id = ?", account.SessionKey, account.Id);

                Send(logonProof);
            }
        }
开发者ID:ArkantosWoW,项目名称:ArkantosEmu,代码行数:33,代码来源:RealmClass.cs

示例9: HandleRealmList

        public void HandleRealmList(RealmClass session, PacketReader data)
        {
            Log.Message(LogType.NORMAL, "RealmList");

            PacketWriter realmData = new PacketWriter();

            foreach (var r in Realms)
            {
                realmData.WriteUInt8(1);
                realmData.WriteUInt8(0);
                realmData.WriteUInt8(0);
                realmData.WriteCString(r.Name);
                realmData.WriteCString(r.IP + ":" + r.Port);
                realmData.WriteFloat(0);
                realmData.WriteUInt8(0);  // CharCount
                realmData.WriteUInt8(1);
                realmData.WriteUInt8(0x2C);
            }

            PacketWriter realmList = new PacketWriter();
            realmList.WriteUInt8((byte)ClientLink.CMD_REALM_LIST);
            realmList.WriteUInt16((ushort)(realmData.BaseStream.Length + 8));
            realmList.WriteUInt32(0);
            realmList.WriteUInt16((ushort)Realms.Count);
            realmList.WriteBytes(realmData.ReadDataToSend());
            realmList.WriteUInt8(0);
            realmList.WriteUInt8(0x10);

            session.Send(realmList);
        }
开发者ID:concept45,项目名称:Arctium-RT,代码行数:30,代码来源:RealmClass.cs

示例10: HandleAuthLogonProof

        public void HandleAuthLogonProof(RealmClass session, PacketReader data)
        {
            Log.Message(LogType.NORMAL, "AuthLogonProof");

            PacketWriter logonProof = new PacketWriter();

            byte[] a = new byte[32];
            byte[] m1 = new byte[20];

            Array.Copy(DataBuffer, 1, a, 0, 32);
            Array.Copy(DataBuffer, 33, m1, 0, 20);

            session.SecureRemotePassword.CalculateU(a);
            session.SecureRemotePassword.CalculateM2(m1);
            session.SecureRemotePassword.CalculateK();

            foreach (var b in session.SecureRemotePassword.K)
                if (b < 0x10)
                    account.SessionKey += "0" + String.Format("{0:X}", b);
                else
                    account.SessionKey += String.Format("{0:X}", b);

            logonProof.WriteUInt8((byte)ClientLink.CMD_AUTH_LOGON_PROOF);
            logonProof.WriteUInt8(0);
            logonProof.WriteBytes(session.SecureRemotePassword.M2);
            logonProof.WriteUInt32(0x800000);
            logonProof.WriteUInt32(0);
            logonProof.WriteUInt16(0);

            DB.Realms.Execute("UPDATE accounts SET sessionkey = '{0}' WHERE id = {1}", account.SessionKey, account.Id);

            session.Send(logonProof);
        }
开发者ID:concept45,项目名称:Arctium-RT,代码行数:33,代码来源:RealmClass.cs

示例11: HandleUpdateObject

        public static void HandleUpdateObject(ref WorldClass session)
        {
            WorldObject character = session.Character;
            PacketWriter updateObject = new PacketWriter(LegacyMessage.UpdateObject);

            updateObject.WriteUInt16((ushort)character.Map);
            updateObject.WriteUInt32(1);
            updateObject.WriteUInt8(1);
            updateObject.WriteGuid(character.Guid);
            updateObject.WriteUInt8(4);

            UpdateFlag updateFlags = UpdateFlag.Alive | UpdateFlag.Rotation | UpdateFlag.Self;
            WorldMgr.WriteUpdateObjectMovement(ref updateObject, ref character, updateFlags);

            character.WriteUpdateFields(ref updateObject);
            character.WriteDynamicUpdateFields(ref updateObject);
            session.Send(ref updateObject);

            var tempSessions = new Dictionary<ulong, WorldClass>(WorldMgr.Sessions);
            tempSessions.Remove(character.Guid);

            if (tempSessions != null)
            {
                foreach (var s in tempSessions)
                {
                    if (character.Map != s.Value.Character.Map)
                        continue;

                    updateObject = new PacketWriter(LegacyMessage.UpdateObject);

                    updateObject.WriteUInt16((ushort)character.Map);
                    updateObject.WriteUInt32(1);
                    updateObject.WriteUInt8(1);
                    updateObject.WriteGuid(character.Guid);
                    updateObject.WriteUInt8(4);

                    updateFlags = UpdateFlag.Alive | UpdateFlag.Rotation;
                    WorldMgr.WriteUpdateObjectMovement(ref updateObject, ref character, updateFlags);

                    character.WriteUpdateFields(ref updateObject);
                    character.WriteDynamicUpdateFields(ref updateObject);

                    s.Value.Send(ref updateObject);
                }

                foreach (var s in tempSessions)
                {
                    WorldObject pChar = s.Value.Character;

                    if (pChar.Map != character.Map)
                        continue;

                    updateObject = new PacketWriter(LegacyMessage.UpdateObject);

                    updateObject.WriteUInt16((ushort)pChar.Map);
                    updateObject.WriteUInt32(1);
                    updateObject.WriteUInt8(1);
                    updateObject.WriteGuid(pChar.Guid);
                    updateObject.WriteUInt8(4);

                    updateFlags = UpdateFlag.Alive | UpdateFlag.Rotation;
                    WorldMgr.WriteUpdateObjectMovement(ref updateObject, ref pChar, updateFlags);

                    pChar.WriteUpdateFields(ref updateObject);
                    pChar.WriteDynamicUpdateFields(ref updateObject);

                    session.Send(ref updateObject);
                }
            }

            character.AddCreatureSpawnsToWorld(ref session);
            character.AddGameObjectSpawnsToWorld(ref session);
        }
开发者ID:SgT-Fatality,项目名称:Arctium,代码行数:73,代码来源:ObjectHandler.cs

示例12: HandleUpdateObjectValues

        public static void HandleUpdateObjectValues(ref WorldClass session, bool broadcast = false, bool toself = true)
        {
            WorldObject character = session.Character;
            PacketWriter updateObject = new PacketWriter(ServerMessage.ObjectUpdate);

            updateObject.WriteUInt16((ushort)character.Map);
            updateObject.WriteUInt32(1);
            updateObject.WriteUInt8((byte)UpdateType.Values);
            updateObject.WriteGuid(character.Guid);

            character.WriteUpdateFields(ref updateObject);
            character.WriteDynamicUpdateFields(ref updateObject);

            if (toself)
                session.Send(ref updateObject);

            if (broadcast)
                WorldMgr.SendToInRangeCharacter(character as Character, updateObject);
        }
开发者ID:mansemino,项目名称:Arctium,代码行数:19,代码来源:ObjectHandler.cs

示例13: HandleUpdateObjectCreate

        public static void HandleUpdateObjectCreate(ref WorldClass session)
        {
            WorldObject character = session.Character;
            PacketWriter updateObject = new PacketWriter(LegacyMessage.UpdateObject);

            updateObject.WriteUInt16((ushort)character.Map);
            updateObject.WriteUInt32(1);
            updateObject.WriteUInt8((byte)UpdateType.CreateObject);
            updateObject.WriteGuid(character.Guid);
            updateObject.WriteUInt8((byte)ObjectType.Player);

            UpdateFlag updateFlags = UpdateFlag.Alive | UpdateFlag.Rotation | UpdateFlag.Self;
            WorldMgr.WriteUpdateObjectMovement(ref updateObject, ref character, updateFlags);

            character.WriteUpdateFields(ref updateObject);
            character.WriteDynamicUpdateFields(ref updateObject);

            session.Send(ref updateObject);

            var tempSessions = new Dictionary<ulong, WorldClass>(WorldMgr.Sessions);
            tempSessions.Remove(character.Guid);

            if (tempSessions != null)
            {
                foreach (var s in tempSessions)
                {
                    if (s.Value.Character.CheckUpdateDistance(character))
                    {
                        updateObject = new PacketWriter(LegacyMessage.UpdateObject);

                        updateObject.WriteUInt16((ushort)character.Map);
                        updateObject.WriteUInt32(1);
                        updateObject.WriteUInt8((byte)UpdateType.CreateObject);
                        updateObject.WriteGuid(character.Guid);
                        updateObject.WriteUInt8((byte)ObjectType.Player);

                        updateFlags = UpdateFlag.Alive | UpdateFlag.Rotation;
                        WorldMgr.WriteUpdateObjectMovement(ref updateObject, ref character, updateFlags);

                        character.WriteUpdateFields(ref updateObject);
                        character.WriteDynamicUpdateFields(ref updateObject);

                        s.Value.Send(ref updateObject);
                    }
                }

                foreach (var s in tempSessions)
                {
                    WorldObject pChar = s.Value.Character;

                    if (character.CheckUpdateDistance(pChar))
                    {
                        character.ToCharacter().InRangeObjects.Add(pChar.Guid, pChar);

                        updateObject = new PacketWriter(LegacyMessage.UpdateObject);

                        updateObject.WriteUInt16((ushort)pChar.Map);
                        updateObject.WriteUInt32(1);
                        updateObject.WriteUInt8((byte)UpdateType.CreateObject);
                        updateObject.WriteGuid(pChar.Guid);
                        updateObject.WriteUInt8((byte)ObjectType.Player);

                        updateFlags = UpdateFlag.Alive | UpdateFlag.Rotation;
                        WorldMgr.WriteUpdateObjectMovement(ref updateObject, ref pChar, updateFlags);

                        pChar.WriteUpdateFields(ref updateObject);
                        pChar.WriteDynamicUpdateFields(ref updateObject);

                        session.Send(ref updateObject);
                    }
                }
            }
        }
开发者ID:owner-gamers,项目名称:Arctium,代码行数:73,代码来源:ObjectHandler.cs

示例14: HandleRealmList

        public void HandleRealmList(PacketReader data)
        {
            Log.Message(LogType.NORMAL, "RealmList");

            using (var realmData = new PacketWriter())
            {
                Realms.ToList().ForEach(r =>
                {
                    using (var result = DB.Characters.Select("SELECT COUNT(*) as Count FROM characters WHERE AccountId = ? AND RealmId = ?", account.Id, r.Value.Id))
                    {
                        var charCount = result.Read<byte>(0, "Count");

                        realmData.WriteUInt8(1);
                        realmData.WriteUInt8(0);
                        realmData.WriteUInt8(0);
                        realmData.WriteCString(r.Key);
                        realmData.WriteCString(r.Value.IP + ":" + r.Value.Port);
                        realmData.WriteFloat(0);
                        realmData.WriteUInt8(charCount);
                        realmData.WriteUInt8(1);
                        realmData.WriteUInt8(0x2C);
                    }
                });

                using (var realmList = new PacketWriter())
                {
                    realmList.WriteUInt8((byte)ClientLink.CMD_REALM_LIST);
                    realmList.WriteUInt16((ushort)(realmData.BaseStream.Length + 8));
                    realmList.WriteUInt32(0);
                    realmList.WriteUInt16((ushort)Realms.Count);
                    realmList.WriteBytes(realmData.ReadDataToSend());
                    realmList.WriteUInt8(0);
                    realmList.WriteUInt8(0x10);

                    Send(realmList);
                }
            }
        }
开发者ID:ArkantosWoW,项目名称:ArkantosEmu,代码行数:38,代码来源:RealmClass.cs

示例15: AddToWorld

        public void AddToWorld()
        {
            CreateFullGuid();
            CreateData(GameObject);

            Globals.SpawnMgr.AddSpawn(this, ref GameObject);

            SetGameObjectFields();

            WorldObject obj = this;
            UpdateFlag updateFlags = UpdateFlag.Rotation | UpdateFlag.StationaryPosition;

            foreach (var v in Globals.WorldMgr.Sessions)
            {
                Character pChar = v.Value.Character;
                if (pChar.Map != Map)
                    continue;

                PacketWriter updateObject = new PacketWriter(LegacyMessage.UpdateObject);

                updateObject.WriteUInt16((ushort)Map);
                updateObject.WriteUInt32(1);
                updateObject.WriteUInt8(1);
                updateObject.WriteGuid(Guid);
                updateObject.WriteUInt8(5);

                Globals.WorldMgr.WriteUpdateObjectMovement(ref updateObject, ref obj, updateFlags);

                WriteUpdateFields(ref updateObject);
                WriteDynamicUpdateFields(ref updateObject);

                v.Value.Send(ref updateObject);
            }
        }
开发者ID:antiker,项目名称:Arctium,代码行数:34,代码来源:GameObjectSpawn.cs


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