本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}