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


C# GSTCPPacketOut.WriteStringBytes方法代码示例

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


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

示例1: SendQuestWindow

		protected override void SendQuestWindow(GameNPC questNPC, GamePlayer player, DataQuest quest, bool offer)
		{
			GSTCPPacketOut pak = new GSTCPPacketOut(GetPacketCode(eServerPackets.Dialog));
			ushort QuestID = quest.ClientQuestID;
			pak.WriteShort((offer) ? (byte)0x22 : (byte)0x21); // Dialog
			pak.WriteShort(QuestID);
			pak.WriteShort((ushort)questNPC.ObjectID);
			pak.WriteByte(0x00); // unknown
			pak.WriteByte(0x00); // unknown
			pak.WriteByte(0x00); // unknown
			pak.WriteByte(0x00); // unknown
			pak.WriteByte((offer) ? (byte)0x02 : (byte)0x01); // Accept/Decline or Finish/Not Yet
			pak.WriteByte(0x01); // Wrap
			pak.WritePascalString(quest.Name);

			String personalizedSummary = BehaviourUtils.GetPersonalizedMessage(quest.Description, player);
			if (personalizedSummary.Length > 255)
			{
				pak.WritePascalString(personalizedSummary.Substring(0, 255)); // Summary is max 255 bytes !
			}
			else
			{
				pak.WritePascalString(personalizedSummary);
			}

			if (offer)
			{
				//String personalizedStory = BehaviourUtils.GetPersonalizedMessage(quest.Story, player);
				pak.WriteShort((ushort)quest.Story.Length);
				pak.WriteStringBytes(quest.Story);
			}
			else
			{
				pak.WriteShort((ushort)quest.FinishText.Length);
				pak.WriteStringBytes(quest.FinishText);
			}
			pak.WriteShort(QuestID);
			pak.WriteByte((byte)quest.StepTexts.Count); // #goals count
			foreach (string text in quest.StepTexts)
			{
				pak.WritePascalString(String.Format("{0}\r", text));
			}
			pak.WriteInt((uint)(0));
			pak.WriteByte((byte)0);
			pak.WriteByte((byte)quest.FinalRewards.Count);
			foreach (ItemTemplate reward in quest.FinalRewards)
			{
				WriteItemData(pak, GameInventoryItem.Create<ItemTemplate>(reward));
			}
			pak.WriteByte((byte)quest.NumOptionalRewardsChoice);
			pak.WriteByte((byte)quest.OptionalRewards.Count);
			foreach (ItemTemplate reward in quest.OptionalRewards)
			{
				WriteItemData(pak, GameInventoryItem.Create<ItemTemplate>(reward));
			}
			SendTCP(pak);
		}
开发者ID:boscorillium,项目名称:dol,代码行数:57,代码来源:PacketLib194.cs

示例2: SendQuestWindow

		protected override void SendQuestWindow(GameNPC questNPC, GamePlayer player, RewardQuest quest,	bool offer)
		{
			GSTCPPacketOut pak = new GSTCPPacketOut(GetPacketCode(eServerPackets.Dialog));
			ushort QuestID = QuestMgr.GetIDForQuestType(quest.GetType());
			pak.WriteShort((offer) ? (byte)0x22 : (byte)0x21); // Dialog
			pak.WriteShort(QuestID);
			pak.WriteShort((ushort)questNPC.ObjectID);
			pak.WriteByte(0x00); // unknown
			pak.WriteByte(0x00); // unknown
			pak.WriteByte(0x00); // unknown
			pak.WriteByte(0x00); // unknown
			pak.WriteByte((offer) ? (byte)0x02 : (byte)0x01); // Accept/Decline or Finish/Not Yet
			pak.WriteByte(0x01); // Wrap
			pak.WritePascalString(quest.Name);
			if (quest.Summary.Length > 255)
				pak.WritePascalString(quest.Summary.Substring(0,255));
			else
				pak.WritePascalString(quest.Summary);
			if (offer)
			{
				pak.WriteShort((ushort)quest.Story.Length);
				pak.WriteStringBytes(quest.Story);
			}
			else
			{
				pak.WriteShort((ushort)quest.Conclusion.Length);
				pak.WriteStringBytes(quest.Conclusion);
			}
			pak.WriteShort(QuestID);
			pak.WriteByte((byte)quest.Goals.Count); // #goals count
			foreach (RewardQuest.QuestGoal goal in quest.Goals)
			{
				pak.WritePascalString(String.Format("{0}\r", goal.Description));
			}
			pak.WriteByte((byte)quest.Level);
			pak.WriteByte((byte)quest.Rewards.MoneyPercent);
			pak.WriteByte((byte)quest.Rewards.ExperiencePercent(player));
			pak.WriteByte((byte)quest.Rewards.BasicItems.Count);
			foreach (ItemTemplate reward in quest.Rewards.BasicItems)
				WriteTemplateData(pak, reward, 1);
			pak.WriteByte((byte)quest.Rewards.ChoiceOf);
			pak.WriteByte((byte)quest.Rewards.OptionalItems.Count);
			foreach (ItemTemplate reward in quest.Rewards.OptionalItems)
				WriteTemplateData(pak, reward, 1);
			SendTCP(pak);
		}
开发者ID:boscorillium,项目名称:dol,代码行数:46,代码来源:PacketLib187.cs

示例3: SendQuestPacket

		protected override void SendQuestPacket(AbstractQuest q, int index)
		{
			if (q == null || !(q is RewardQuest))
			{
				base.SendQuestPacket(q, index);
				return;
			}

			RewardQuest quest = q as RewardQuest;
			GSTCPPacketOut pak = new GSTCPPacketOut(GetPacketCode(eServerPackets.QuestEntry));
			pak.WriteByte((byte)index);
			pak.WriteByte((byte)quest.Name.Length);
			pak.WriteShort(0x00); // unknown
			pak.WriteByte((byte)quest.Goals.Count);
			pak.WriteByte((byte)quest.Level);
			pak.WriteStringBytes(quest.Name);
			pak.WritePascalString(quest.Description);
			foreach (RewardQuest.QuestGoal goal in quest.Goals)
			{
				String goalDesc = String.Format("{0}\r", goal.Description);
				pak.WriteShortLowEndian((ushort)goalDesc.Length);
				pak.WriteStringBytes(goalDesc);
				pak.WriteShortLowEndian((ushort)goal.ZoneID2);
				pak.WriteShortLowEndian((ushort)goal.XOffset2);
				pak.WriteShortLowEndian((ushort)goal.YOffset2);
				pak.WriteShortLowEndian(0x00);	// unknown
				pak.WriteShortLowEndian((ushort)goal.Type);
				pak.WriteShortLowEndian(0x00);	// unknown
				pak.WriteShortLowEndian((ushort)goal.ZoneID1);
				pak.WriteShortLowEndian((ushort)goal.XOffset1);
				pak.WriteShortLowEndian((ushort)goal.YOffset1);
				pak.WriteByte((byte)((goal.IsAchieved) ? 0x01 : 0x00));
				if (goal.QuestItem == null)
					pak.WriteByte(0x00);
				else
				{
					pak.WriteByte(0x01);
					WriteTemplateData(pak, goal.QuestItem, 1);
				}
			}
			SendTCP(pak);
		}
开发者ID:boscorillium,项目名称:dol,代码行数:42,代码来源:PacketLib187.cs

示例4: SendPlayerTitleUpdate

		public override void SendPlayerTitleUpdate(GamePlayer player)
		{
			using (GSTCPPacketOut pak = new GSTCPPacketOut(GetPacketCode(eServerPackets.VisualEffect)))
			{
				pak.WriteShort((ushort)player.ObjectID);
				pak.WriteByte(0x0B); // subcode
				IPlayerTitle title = player.CurrentTitle;
				if (title == PlayerTitleMgr.ClearTitle)
				{
					pak.WriteByte(0); // flag
					pak.WriteInt(0); // unk1 + str len
				}
				else
				{
					pak.WriteByte(1); // flag
					string val = GameServer.ServerRules.GetPlayerTitle(m_gameClient.Player, player);
					pak.WriteShort((ushort) val.Length);
					pak.WriteShort(0); // unk1
					pak.WriteStringBytes(val);
				}
				SendTCP(pak);
			}
		}
开发者ID:mynew4,项目名称:DAoC,代码行数:23,代码来源:PacketLib175.cs

示例5: SendQuestPacket

		protected override void SendQuestPacket(AbstractQuest quest, int index)
		{
			using (GSTCPPacketOut pak = new GSTCPPacketOut(GetPacketCode(eServerPackets.QuestEntry)))
			{

				pak.WriteByte((byte)index);
				if (quest.Step <= 0)
				{
					pak.WriteByte(0);
					pak.WriteByte(0);
					pak.WriteByte(0);
				}
				else
				{
					string name = quest.Name;
					string desc = quest.Description;
					if (name.Length > byte.MaxValue)
					{
						if (log.IsWarnEnabled) log.Warn(quest.GetType().ToString() + ": name is too long for 1.71 clients (" + name.Length + ") '" + name + "'");
						name = name.Substring(0, byte.MaxValue);
					}
					if (desc.Length > ushort.MaxValue)
					{
						if (log.IsWarnEnabled) log.Warn(quest.GetType().ToString() + ": description is too long for 1.71 clients (" + desc.Length + ") '" + desc + "'");
						desc = desc.Substring(0, ushort.MaxValue);
					}
					if (name.Length + desc.Length > 2048 - 10)
					{
						if (log.IsWarnEnabled) log.Warn(quest.GetType().ToString() + ": name + description length is too long and would have crashed the client.\nName (" + name.Length + "): '" + name + "'\nDesc (" + desc.Length + "): '" + desc + "'");
						name = name.Substring(0, 32);
						desc = desc.Substring(0, 2048 - 10 - name.Length); // all that's left
					}
					pak.WriteByte((byte)name.Length);
					pak.WriteShort((ushort)desc.Length);
					pak.WriteStringBytes(name); //Write Quest Name without trailing 0
					pak.WriteStringBytes(desc); //Write Quest Description without trailing 0
				}
				SendTCP(pak);
			}
		}
开发者ID:dudemanvox,项目名称:Dawn-of-Light-Server,代码行数:40,代码来源:PacketLib171.cs

示例6: SendTaskInfo

		protected override void SendTaskInfo()
		{
			string name = BuildTaskString();

			using (GSTCPPacketOut pak = new GSTCPPacketOut(GetPacketCode(eServerPackets.QuestEntry)))
			{
				pak.WriteByte(0); //index
				pak.WriteShortLowEndian((ushort)name.Length);
				pak.WriteByte((byte)0);
				pak.WriteStringBytes(name); //Write Quest Name without trailing 0
				pak.WriteStringBytes(""); //Write Quest Description without trailing 0
				SendTCP(pak);
			}
		}
开发者ID:dol-leodagan,项目名称:DOLSharp,代码行数:14,代码来源:PacketLib173.cs

示例7: SendQuestWindow

		protected override void SendQuestWindow(GameNPC questNPC, GamePlayer player, RewardQuest quest,	bool offer)
		{
			using (GSTCPPacketOut pak = new GSTCPPacketOut(GetPacketCode(eServerPackets.Dialog)))
			{
				ushort QuestID = QuestMgr.GetIDForQuestType(quest.GetType());
				pak.WriteShort((offer) ? (byte)0x22 : (byte)0x21); // Dialog
				pak.WriteShort(QuestID);
				pak.WriteShort((ushort)questNPC.ObjectID);
				pak.WriteByte(0x00); // unknown
				pak.WriteByte(0x00); // unknown
				pak.WriteByte(0x00); // unknown
				pak.WriteByte(0x00); // unknown
				pak.WriteByte((offer) ? (byte)0x02 : (byte)0x01); // Accept/Decline or Finish/Not Yet
				pak.WriteByte(0x01); // Wrap
				pak.WritePascalString(quest.Name);
	
				String personalizedSummary = BehaviourUtils.GetPersonalizedMessage(quest.Summary, player);
				if (personalizedSummary.Length > 255)
					pak.WritePascalString(personalizedSummary.Substring(0, 255)); // Summary is max 255 bytes !
				else
					pak.WritePascalString(personalizedSummary);
	
				if (offer)
				{
					String personalizedStory = BehaviourUtils.GetPersonalizedMessage(quest.Story, player);
	
					if (personalizedStory.Length > ServerProperties.Properties.MAX_REWARDQUEST_DESCRIPTION_LENGTH)
					{
						pak.WriteShort((ushort)ServerProperties.Properties.MAX_REWARDQUEST_DESCRIPTION_LENGTH);
						pak.WriteStringBytes(personalizedStory.Substring(0, ServerProperties.Properties.MAX_REWARDQUEST_DESCRIPTION_LENGTH));
					}
					else
					{
						pak.WriteShort((ushort)personalizedStory.Length);
						pak.WriteStringBytes(personalizedStory);
					}
				}
				else
				{
					if (quest.Conclusion.Length > (ushort)ServerProperties.Properties.MAX_REWARDQUEST_DESCRIPTION_LENGTH)
					{
						pak.WriteShort((ushort)ServerProperties.Properties.MAX_REWARDQUEST_DESCRIPTION_LENGTH);
						pak.WriteStringBytes(quest.Conclusion.Substring(0, (ushort)ServerProperties.Properties.MAX_REWARDQUEST_DESCRIPTION_LENGTH));
					}
					else
					{
						pak.WriteShort((ushort)quest.Conclusion.Length);
						pak.WriteStringBytes(quest.Conclusion);
					}
				}
	
				pak.WriteShort(QuestID);
				pak.WriteByte((byte)quest.Goals.Count); // #goals count
				foreach (RewardQuest.QuestGoal goal in quest.Goals)
				{
					pak.WritePascalString(String.Format("{0}\r", goal.Description));
				}
				pak.WriteInt((uint)(quest.Rewards.Money)); // unknown, new in 1.94
				pak.WriteByte((byte)quest.Rewards.ExperiencePercent(player));
				pak.WriteByte((byte)quest.Rewards.BasicItems.Count);
				foreach (ItemTemplate reward in quest.Rewards.BasicItems)
				{
					WriteItemData(pak, GameInventoryItem.Create<ItemTemplate>(reward));
				}
				pak.WriteByte((byte)quest.Rewards.ChoiceOf);
				pak.WriteByte((byte)quest.Rewards.OptionalItems.Count);
				foreach (ItemTemplate reward in quest.Rewards.OptionalItems)
				{
					WriteItemData(pak, GameInventoryItem.Create<ItemTemplate>(reward));
				}
				SendTCP(pak);
			}
		}
开发者ID:andyhebear,项目名称:DOLSharp,代码行数:73,代码来源:PacketLib194.cs

示例8: SendQuestPacket

		protected virtual void SendQuestPacket(AbstractQuest quest, int index)
		{
			using (var pak = new GSTCPPacketOut(GetPacketCode(eServerPackets.QuestEntry)))
			{
				pak.WriteByte((byte) index);

				if (quest.Step <= 0)
				{
					pak.WriteByte(0);
					pak.WriteByte(0);
					pak.WriteByte(0);
				}
				else
				{
					string name = quest.Name;
					string desc = quest.Description;
					if (name.Length > byte.MaxValue)
					{
						if (log.IsWarnEnabled)
							log.Warn(quest.GetType() + ": name is too long for 1.68+ clients (" + name.Length + ") '" + name + "'");
						name = name.Substring(0, byte.MaxValue);
					}
					if (desc.Length > byte.MaxValue)
					{
						if (log.IsWarnEnabled)
							log.Warn(quest.GetType() + ": description is too long for 1.68+ clients (" + desc.Length + ") '" + desc + "'");
						desc = desc.Substring(0, byte.MaxValue);
					}
					pak.WriteByte((byte) name.Length);
					pak.WriteByte((byte) desc.Length);
					pak.WriteByte(0);
					pak.WriteStringBytes(name); //Write Quest Name without trailing 0
					pak.WriteStringBytes(desc); //Write Quest Description without trailing 0
				}

				SendTCP(pak);
			}
		}
开发者ID:SkyFire,项目名称:Dawn-of-Light-core,代码行数:38,代码来源:PacketLib168.cs

示例9: SendQuestPacket

		protected override void SendQuestPacket(AbstractQuest quest, int index)
		{
			using (GSTCPPacketOut pak = new GSTCPPacketOut(GetPacketCode(eServerPackets.QuestEntry)))
			{
				pak.WriteByte((byte) index);
				if (quest == null)
				{
					pak.WriteByte(0);
					pak.WriteByte(0);
					pak.WriteByte(0);
					pak.WriteByte(0);
					pak.WriteByte(0);
				}
				else
				{
					string name = string.Format("{0} (Level {1})", quest.Name, quest.Level);
					string desc = string.Format("[Step #{0}]: {1}", quest.Step,	quest.Description);
					if (name.Length > byte.MaxValue)
					{
						if (log.IsWarnEnabled) log.Warn(quest.GetType().ToString() + ": name is too long for 1.68+ clients (" + name.Length + ") '" + name + "'");
						name = name.Substring(0, byte.MaxValue);
					}
					if (desc.Length > byte.MaxValue)
					{
						if (log.IsWarnEnabled) log.Warn(quest.GetType().ToString() + ": description is too long for 1.68+ clients (" + desc.Length + ") '" + desc + "'");
						desc = desc.Substring(0, byte.MaxValue);
					}
					pak.WriteByte((byte)name.Length);
					pak.WriteShortLowEndian((ushort)desc.Length);
					pak.WriteByte(0); // Quest Zone ID ?
					pak.WriteByte(0);
					pak.WriteStringBytes(name); //Write Quest Name without trailing 0
					pak.WriteStringBytes(desc); //Write Quest Description without trailing 0
				}
				
				SendTCP(pak);
			}
		}
开发者ID:mynew4,项目名称:DOLSharp,代码行数:38,代码来源:PacketLib184.cs

示例10: SendQuestWindow

        const ushort MAX_STORY_LENGTH = 1000;   // Via trial and error, 1.108 client. 
                                                // Often will cut off text around 990 but longer strings do not result in any errors. -Tolakram

		protected override void SendQuestWindow(GameNPC questNPC, GamePlayer player, DataQuest quest, bool offer)
		{
			using (GSTCPPacketOut pak = new GSTCPPacketOut(GetPacketCode(eServerPackets.Dialog)))
			{
				ushort QuestID = quest.ClientQuestID;
				pak.WriteShort((offer) ? (byte)0x22 : (byte)0x21); // Dialog
				pak.WriteShort(QuestID);
				pak.WriteShort((ushort)questNPC.ObjectID);
				pak.WriteByte(0x00); // unknown
				pak.WriteByte(0x00); // unknown
				pak.WriteByte(0x00); // unknown
				pak.WriteByte(0x00); // unknown
				pak.WriteByte((offer) ? (byte)0x02 : (byte)0x01); // Accept/Decline or Finish/Not Yet
				pak.WriteByte(0x01); // Wrap
				pak.WritePascalString(quest.Name);
	
				String personalizedSummary = BehaviourUtils.GetPersonalizedMessage(quest.Description, player);
				if (personalizedSummary.Length > 255)
				{
					pak.WritePascalString(personalizedSummary.Substring(0, 255)); // Summary is max 255 bytes or client will crash !
				}
				else
				{
					pak.WritePascalString(personalizedSummary);
				}
	
				if (offer)
				{
	                String personalizedStory = BehaviourUtils.GetPersonalizedMessage(quest.Story, player);
	
	                if (personalizedStory.Length > MAX_STORY_LENGTH)
					{
	                    pak.WriteShort(MAX_STORY_LENGTH);
	                    pak.WriteStringBytes(personalizedStory.Substring(0, MAX_STORY_LENGTH));
					}
					else
					{
	                    pak.WriteShort((ushort)personalizedStory.Length);
	                    pak.WriteStringBytes(personalizedStory);
					}
				}
				else
				{
	                if (quest.FinishText.Length > MAX_STORY_LENGTH)
					{
	                    pak.WriteShort(MAX_STORY_LENGTH);
	                    pak.WriteStringBytes(quest.FinishText.Substring(0, MAX_STORY_LENGTH));
					}
					else
					{
						pak.WriteShort((ushort)quest.FinishText.Length);
						pak.WriteStringBytes(quest.FinishText);
					}
				}
	
				pak.WriteShort(QuestID);
				pak.WriteByte((byte)quest.StepTexts.Count); // #goals count
				foreach (string text in quest.StepTexts)
				{
	                string t = text;
	
	                // Need to protect for any text length > 255.  It does not crash client but corrupts RewardQuest display -Tolakram
	                if (text.Length > 253)
	                {
	                    t = text.Substring(0, 253);
	                }
	
					pak.WritePascalString(String.Format("{0}\r", t));
				}
				pak.WriteInt((uint)(0));
				pak.WriteByte((byte)0);
				pak.WriteByte((byte)quest.FinalRewards.Count);
				foreach (ItemTemplate reward in quest.FinalRewards)
				{
					WriteItemData(pak, GameInventoryItem.Create(reward));
				}
				pak.WriteByte((byte)quest.NumOptionalRewardsChoice);
				pak.WriteByte((byte)quest.OptionalRewards.Count);
				foreach (ItemTemplate reward in quest.OptionalRewards)
				{
					WriteItemData(pak, GameInventoryItem.Create(reward));
				}
				SendTCP(pak);
			}
		}
开发者ID:dudemanvox,项目名称:Dawn-of-Light-Server,代码行数:88,代码来源:PacketLib194.cs


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