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


C# PacketWriter.WriteCString方法代码示例

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


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

示例1: HandleMessageOfTheDay

        public static void HandleMessageOfTheDay(ref WorldClass session)
        {
            PacketWriter motd = new PacketWriter(LegacyMessage.MessageOfTheDay);
            motd.WriteUInt32(3);

            motd.WriteCString("Arctium MoP test");
            motd.WriteCString("Welcome to our MoP server test.");
            motd.WriteCString("Your development team =)");
            session.Send(ref motd);
        }
开发者ID:Kinivus,项目名称:Arctium,代码行数:10,代码来源:MiscHandler.cs

示例2: HandleCreatureStats

        public static void HandleCreatureStats(ref PacketReader packet, ref WorldClass session)
        {
            int id = packet.ReadInt32();
            ulong guid = packet.ReadUInt64();

            Creature creature = DataMgr.FindCreature(id);
            if (creature != null)
            {
                CreatureStats stats = creature.Stats;

                PacketWriter creatureStats = new PacketWriter(LegacyMessage.CreatureStats);

                creatureStats.WriteInt32(stats.Id);
                creatureStats.WriteCString(stats.Name);

                for (int i = 0; i < 7; i++)
                    creatureStats.WriteCString("");

                creatureStats.WriteCString(stats.SubName);
                creatureStats.WriteCString("");
                creatureStats.WriteCString(stats.IconName);

                foreach (var v in stats.Flag)
                    creatureStats.WriteInt32(v);

                creatureStats.WriteInt32(stats.Type);
                creatureStats.WriteInt32(stats.Family);
                creatureStats.WriteInt32(stats.Rank);

                foreach (var v in stats.QuestKillNpcId)
                    creatureStats.WriteInt32(v);

                foreach (var v in stats.DisplayInfoId)
                    creatureStats.WriteInt32(v);

                creatureStats.WriteFloat(stats.HealthModifier);
                creatureStats.WriteFloat(stats.PowerModifier);

                creatureStats.WriteUInt8(stats.RacialLeader);

                foreach (var v in stats.QuestItemId)
                    creatureStats.WriteInt32(v);

                creatureStats.WriteInt32(stats.MovementInfoId);
                creatureStats.WriteInt32(stats.ExpansionRequired);

                session.Send(ref creatureStats);
            }
            else
                Log.Message(LogType.DEBUG, "Creature (Id: {0}) not found.", id);
        }
开发者ID:antiker,项目名称:Arctium,代码行数:51,代码来源:CacheHandler.cs

示例3: OnConnect

        public void OnConnect()
        {
            PacketWriter TransferInitiate = new PacketWriter(Message.TransferInitiate);
            TransferInitiate.WriteCString("RLD OF WARCRAFT CONNECTION - SERVER TO CLIENT");

            Send(TransferInitiate);

            clientSocket.BeginReceive(DataBuffer, 0, DataBuffer.Length, SocketFlags.None, Receive, null);
        }
开发者ID:boredtodeath,项目名称:Arctium,代码行数:9,代码来源:WorldClass.cs

示例4: HandleRealmCache

        public static void HandleRealmCache(ref PacketReader packet, ref WorldClass session)
        {
            Character pChar = session.Character;

            uint realmId = packet.ReadUInt32();

            SQLResult result = DB.Realms.Select("SELECT name FROM realms WHERE id = '{0}'", WorldConfig.RealmId);
            string realmName = result.Read<string>(0, "Name");

            PacketWriter nameCache = new PacketWriter(LegacyMessage.RealmCache);

            nameCache.WriteUInt32(realmId);
            nameCache.WriteUInt8(0);              // < 0 => End of packet
            nameCache.WriteUInt8(1);              // Unknown
            nameCache.WriteCString(realmName);
            nameCache.WriteCString(realmName);

            session.Send(nameCache);
        }
开发者ID:boredtodeath,项目名称:Arctium,代码行数:19,代码来源:CacheHandler.cs

示例5: HandleRealmSplitStateResponse

        public static void HandleRealmSplitStateResponse(ref PacketReader packet, ref WorldClass session)
        {
            uint realmSplitState = 0;

            PacketWriter realmSplitStateResp = new PacketWriter(LegacyMessage.RealmSplitStateResponse);

            realmSplitStateResp.WriteUInt32(packet.ReadUInt32());
            realmSplitStateResp.WriteUInt32(realmSplitState);
            realmSplitStateResp.WriteCString("01/01/01");

            session.Send(ref realmSplitStateResp);
        }
开发者ID:jesus01,项目名称:Arctium,代码行数:12,代码来源:TimeHandler.cs

示例6: 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

示例7: HandleNameCache

        public static void HandleNameCache(ref PacketReader packet, ref WorldClass session)
        {
            Character pChar = session.Character;

            ulong guid = packet.ReadUInt64();
            uint realmId = packet.ReadUInt32();

            PacketWriter nameCache = new PacketWriter(LegacyMessage.NameCache);

            nameCache.WriteGuid(guid);
            nameCache.WriteUInt8(0);
            nameCache.WriteCString(pChar.Name);
            nameCache.WriteUInt32(realmId);
            nameCache.WriteUInt8(pChar.Race);
            nameCache.WriteUInt8(pChar.Gender);
            nameCache.WriteUInt8(pChar.Class);
            nameCache.WriteUInt8(0);

            session.Send(nameCache);
        }
开发者ID:boredtodeath,项目名称:Arctium,代码行数:20,代码来源:CacheHandler.cs

示例8: 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

示例9: 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

示例10: 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

示例11: SendMessageByType

        public static void SendMessageByType(ref WorldClass session, MessageType type, int language, string chatMessage, bool Broadcast = false)
        {
            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);
            if (Broadcast)
            {
                Globals.WorldMgr.SendToInRangeCharacter(session.Character, messageChat);
                session.Send(ref messageChat);
            }
            else
                session.Send(ref messageChat);
        }
开发者ID:Mathias1000,项目名称:Arctium,代码行数:21,代码来源:ChatHandler.cs

示例12: HandleGameObjectStats

        public static void HandleGameObjectStats(ref PacketReader packet, ref WorldClass session)
        {
            int id = packet.ReadInt32();
            ulong guid = packet.ReadUInt64();

            GameObject gObject = DataMgr.FindGameObject(id);
            if (gObject != null)
            {
                GameObjectStats stats = gObject.Stats;

                PacketWriter gameObjectStats = new PacketWriter(LegacyMessage.GameObjectStats);

                gameObjectStats.WriteInt32(stats.Id);
                gameObjectStats.WriteInt32(stats.Type);
                gameObjectStats.WriteInt32(stats.DisplayInfoId);
                gameObjectStats.WriteCString(stats.Name);

                for (int i = 0; i < 3; i++)
                    gameObjectStats.WriteCString("");

                gameObjectStats.WriteCString(stats.IconName);
                gameObjectStats.WriteCString(stats.CastBarCaption);
                gameObjectStats.WriteCString("");

                foreach (var v in stats.Data)
                    gameObjectStats.WriteInt32(v);

                gameObjectStats.WriteFloat(stats.Size);

                foreach (var v in stats.QuestItemId)
                    gameObjectStats.WriteInt32(v);

                gameObjectStats.WriteInt32(stats.ExpansionRequired);

                session.Send(ref gameObjectStats);
            }
            else
                Log.Message(LogType.DEBUG, "Gameobject (Id: {0}) not found.", id);
        }
开发者ID:antiker,项目名称:Arctium,代码行数:39,代码来源:CacheHandler.cs

示例13: HandleNameCache

        public static void HandleNameCache(ref PacketReader packet, ref WorldClass session)
        {
            ulong guid = packet.ReadUInt64();
            uint realmId = packet.ReadUInt32();

            var pSession = WorldMgr.GetSession(guid);
            if (pSession != null)
            {
                var pChar = pSession.Character;

                if (pChar != null)
                {
                    PacketWriter nameCache = new PacketWriter(LegacyMessage.NameCache);

                    nameCache.WriteGuid(guid);
                    nameCache.WriteUInt8(0);
                    nameCache.WriteCString(pChar.Name);
                    nameCache.WriteUInt32(realmId);
                    nameCache.WriteUInt8(pChar.Race);
                    nameCache.WriteUInt8(pChar.Gender);
                    nameCache.WriteUInt8(pChar.Class);
                    nameCache.WriteUInt8(0);

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

示例14: HandleQueryCreature

        public static void HandleQueryCreature(ref PacketReader packet, ref WorldClass session)
        {
            var hasData = false;
            var id = packet.Read<int>();

            PacketWriter queryCreatureResponse = new PacketWriter(ServerMessage.QueryCreatureResponse);
            BitPack BitPack = new BitPack(queryCreatureResponse);

            queryCreatureResponse.WriteInt32(id);

            Creature creature = DataMgr.FindCreature(id);
            if (hasData = (creature != null))
            {
                CreatureStats stats = creature.Stats;

                BitPack.Write(hasData);
                BitPack.Write(stats.QuestItemId.Count, 22);
                BitPack.Write(0, 11);
                BitPack.Write(stats.RacialLeader);
                BitPack.Write(stats.IconName.Length + 1, 6);

                for (int i = 0; i < 8; i++)
                {
                    if (i == 1)
                        BitPack.Write(stats.Name.Length + 1, 11);
                    else
                        BitPack.Write(0, 11);
                }

                BitPack.Write(stats.SubName.Length != 0 ? stats.SubName.Length + 1 : 0, 11);
                BitPack.Flush();

                queryCreatureResponse.WriteInt32(stats.Rank);
                queryCreatureResponse.WriteInt32(stats.DisplayInfoId[2]);
                queryCreatureResponse.WriteInt32(stats.Type);

                foreach (var v in stats.Flag)
                    queryCreatureResponse.WriteInt32(v);

                queryCreatureResponse.WriteFloat(stats.PowerModifier);
                queryCreatureResponse.WriteInt32(stats.DisplayInfoId[0]);
                queryCreatureResponse.WriteFloat(1);

                queryCreatureResponse.WriteCString(stats.Name);

                if (stats.IconName != "")
                    queryCreatureResponse.WriteCString(stats.IconName);

                queryCreatureResponse.WriteInt32(stats.Family);
                queryCreatureResponse.WriteInt32(stats.QuestKillNpcId[0]);

                if (stats.SubName != "")
                    queryCreatureResponse.WriteCString(stats.SubName);

                queryCreatureResponse.WriteInt32(stats.MovementInfoId);
                queryCreatureResponse.WriteInt32(stats.DisplayInfoId[1]);
                queryCreatureResponse.WriteFloat(1);
                queryCreatureResponse.WriteFloat(stats.HealthModifier);
                queryCreatureResponse.WriteInt32(0);

                foreach (var v in stats.QuestItemId)
                    queryCreatureResponse.WriteInt32(v);

                queryCreatureResponse.WriteInt32(stats.DisplayInfoId[3]);
                queryCreatureResponse.WriteInt32(stats.QuestKillNpcId[1]);
                queryCreatureResponse.WriteInt32(stats.ExpansionRequired);

                session.Send(ref queryCreatureResponse);
            }
            else
            {
                BitPack.Write(hasData);
                Log.Message(LogType.DEBUG, "Creature (Id: {0}) not found.", id);
            }
        }
开发者ID:ArkantosWoW,项目名称:ArkantosEmu,代码行数:75,代码来源:CacheHandler.cs

示例15: HandleQueryGameObject

        public static void HandleQueryGameObject(ref PacketReader packet, ref WorldClass session)
        {
            byte[] guidMask = { 4, 6, 7, 5, 3, 2, 1, 0 };
            byte[] guidBytes = { 0, 2, 3, 5, 6, 1, 4, 7 };

            BitUnpack BitUnpack = new BitUnpack(packet);

            var hasData = false;
            var id = packet.Read<int>();
            var guid = BitUnpack.GetPackedValue(guidMask, guidBytes);

            PacketWriter queryGameObjectResponse = new PacketWriter(ServerMessage.QueryGameObjectResponse);
            BitPack BitPack = new BitPack(queryGameObjectResponse);

            GameObject gObject = DataMgr.FindGameObject(id);
            if (hasData = (gObject != null))
            {
                GameObjectStats stats = gObject.Stats;

                BitPack.Write(hasData);
                BitPack.Flush();

                queryGameObjectResponse.WriteInt32(stats.Id);
                queryGameObjectResponse.WriteInt32(0);
                queryGameObjectResponse.WriteInt32(stats.Type);
                queryGameObjectResponse.WriteInt32(stats.DisplayInfoId);

                queryGameObjectResponse.WriteCString(stats.Name);

                for (int i = 0; i < 3; i++)
                    queryGameObjectResponse.WriteCString("");

                queryGameObjectResponse.WriteCString(stats.IconName);
                queryGameObjectResponse.WriteCString(stats.CastBarCaption);
                queryGameObjectResponse.WriteCString("");

                foreach (var v in stats.Data)
                    queryGameObjectResponse.WriteInt32(v);

                queryGameObjectResponse.WriteFloat(stats.Size);
                queryGameObjectResponse.WriteUInt8((byte)stats.QuestItemId.Count);

                foreach (var v in stats.QuestItemId)
                    queryGameObjectResponse.WriteInt32(v);

                queryGameObjectResponse.WriteInt32(stats.ExpansionRequired);

                var size = (uint)queryGameObjectResponse.BaseStream.Length - 13;
                queryGameObjectResponse.WriteUInt32Pos(size, 9);

                session.Send(ref queryGameObjectResponse);
            }
            else
            {
                BitPack.Write(hasData);
                Log.Message(LogType.DEBUG, "Gameobject (Id: {0}) not found.", id);
            }
        }
开发者ID:ArkantosWoW,项目名称:ArkantosEmu,代码行数:58,代码来源:CacheHandler.cs


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