本文整理汇总了C#中RealmPacketOut.WriteByte方法的典型用法代码示例。如果您正苦于以下问题:C# RealmPacketOut.WriteByte方法的具体用法?C# RealmPacketOut.WriteByte怎么用?C# RealmPacketOut.WriteByte使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RealmPacketOut
的用法示例。
在下文中一共展示了RealmPacketOut.WriteByte方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateChatPacket
/// <summary>
/// Creates a packet
/// </summary>
public static RealmPacketOut CreateChatPacket(ChatMsgType type, ChatLanguage language, string msg, ChatTag tag)
{
var packet = new RealmPacketOut(RealmServerOpCode.SMSG_MESSAGECHAT, 23 + msg.Length);
packet.WriteByte((byte)type); // 1
packet.WriteUInt((uint)language); // 5
packet.WriteUIntPascalString(msg); // 22 + msg.Length
packet.WriteByte((byte)tag); // 23 + msg.Length
return packet;
}
示例2: SendSystemStatus
public static void SendSystemStatus(Character chr, VoiceSystemStatus status)
{
using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_FEATURE_SYSTEM_STATUS))
{
packet.WriteByte(2); // what is this
packet.WriteByte((byte)status);
chr.Client.Send(packet);
}
}
示例3: CreateAchievementEarnedToGuild
public static RealmPacketOut CreateAchievementEarnedToGuild(AchievementEntryId achievementEntryId, Character chr)
{
// Must be a better way to do this.
const string msg = "|Hplayer:$N|h[$N]|h has earned the achievement $a!";
var packet = new RealmPacketOut(RealmServerOpCode.SMSG_MESSAGECHAT);
packet.WriteByte((byte) ChatMsgType.Achievment);
packet.WriteUInt((uint) ChatLanguage.Universal);
packet.Write(chr.EntityId);
packet.WriteUInt(5);
packet.Write(chr.EntityId);
packet.WriteUIntPascalString(msg);
packet.WriteByte(0);
packet.WriteUInt((uint) achievementEntryId);
return packet;
}
示例4: SendBattlegroundWindow
/// <summary>
/// Sends the packet to show the battleground window
/// </summary>
/// <param name="client"></param>
/// <param name="speaker"></param>
/// <param name="character"></param>
/// <returns></returns>
public bool SendBattlegroundWindow(IRealmClient client, NPC speaker, Character character)
{
using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_BATTLEFIELD_LIST))
{
packet.WriteULong(speaker != null ? speaker.EntityId.Full : 0);
packet.WriteUInt((uint)m_bgqueue.Template.BgID);
packet.WriteByte(m_battlegroupId); //Battle group
// TODO: Add sync'ing?
//m_syncLock.EnterReadLock();
try
{
packet.WriteUInt(m_battlegrounds.Count); //Count
foreach (var bg in m_battlegrounds.Values)
{
packet.WriteUInt(bg.InstanceId);
}
}
finally
{
//m_syncLock.ExitReadLock();
}
client.Send(packet);
return true;
}
}
示例5: SendWhoList
/// <summary>
/// Sends to the specified client the Who List based on the given characters
/// </summary>
/// <param name="client">The client to send the list</param>
/// <param name="characters">The list of characters that matched the Who List search</param>
public static void SendWhoList(IPacketReceiver client, ICollection<Character> characters)
{
using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_WHO))
{
packet.Write(characters.Count);
packet.Write(characters.Count);
foreach (Character character in characters)
{
packet.WriteCString(character.Name);
packet.WriteCString(character.Guild != null ? character.Guild.Name : string.Empty); //TODO: Add Guild name here
packet.Write(character.Level);
packet.WriteUInt((byte)character.Class);
packet.WriteUInt((byte)character.Race);
packet.WriteByte(0); //New in 2.4.x
packet.Write(character.Zone != null ? (uint)character.Zone.Id : 0);
}
client.Send(packet);
}
}
示例6: SendCharEnum
/// <summary>
/// Sends the character list to the client.
/// </summary>
/// <param name="client">the client to send to</param>
/// <remarks>They probably meant 'enumeration,' but 'list' would have made so much more sense. :)</remarks>
public static void SendCharEnum(IRealmClient client)
{
CharacterRecord curRecord = null;
try
{
using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_CHAR_ENUM))
{
var chrs = client.Account.Characters;
packet.WriteByte(chrs.Count);
foreach (var record in chrs)
{
curRecord = record;
packet.Write(EntityId.GetPlayerId(record.EntityLowId)); // 8
packet.WriteCString(record.Name); // 9 + namelength
packet.Write((byte)record.Race); // 10 + namelength
packet.Write((byte)record.Class); // 11 + namelength
packet.Write((byte)record.Gender); // 12 + namelength
packet.Write(record.Skin); // 13 + namelength
packet.Write(record.Face); // 14 + namelength
packet.Write(record.HairStyle); // 15 + namelength
packet.Write(record.HairColor); // 16 + namelength
packet.Write(record.FacialHair); // 17 + namelength
packet.Write((byte)record.Level); // 18 + namelength
packet.Write((int)record.Zone); // 22 + namelength
packet.Write((int)record.MapId); // 26 + namelength
packet.Write(record.PositionX); // 30 + namelength
packet.Write(record.PositionY); // 34 + namelength
packet.Write(record.PositionZ); // 38 + namelength
packet.WriteUInt(record.GuildId); // guild id // 42 + namelength
packet.Write((int)record.CharacterFlags); // 46 + namelength
packet.Write(0); // TOOD: Customization flags
packet.Write((byte)1); // NEW 3.2.0 - first login y/n - set to 1 for now
// Deprecated: Rest State
// var restState = record.RestXp > 0 ? RestState.Resting : RestState.Normal;
// packet.WriteByte((byte)restState); // 47 + namelength
// pet info (51 - 63)
var petEntry = record.PetEntry;
if (petEntry != null)
{
packet.Write(petEntry.DisplayIds[0]);
packet.Write(record.Level); // liars!
packet.Write((int)petEntry.FamilyId);
}
else
{
packet.Write(0); // 51 + namelength
packet.Write(0); // 55 + namelength
packet.Write(0); // 59 + namelength
}
var itemOffset = packet.Position;
//packet.TotalLength += CharEnumItemCount * CharEnumItemBytes; // 239 + namelength
packet.Zero(CharEnumItemCount * CharEnumItemBytes);
packet.Position = itemOffset;
if (record.JustCreated)
{
var archetype = ArchetypeMgr.GetArchetype(record.Race, record.Class);
if (archetype != null)
{
var items = archetype.GetInitialItems(record.Gender);
foreach (var item in items)
{
var template = item.Template;
if (template.EquipmentSlots != null)
{
packet.Position = itemOffset + ((int)template.EquipmentSlots[0] * CharEnumItemBytes);
packet.Write(template.DisplayId);
packet.Write((byte)template.InventorySlotType);
packet.Write(0);
}
}
}
else
{
log.Warn("Invalid Race/Class combination " +
"({0} {1}) in CharacterRecord {2}.",
record.Race, record.Class, record);
}
}
else
{
foreach (var item in record.GetOrLoadItems())
{
if (!item.IsOwned)
//.........这里部分代码省略.........
示例7: SendCharCreateReply
/// <summary>
/// Sends a character creation reply to the client.
/// </summary>
/// <param name="client">the client to send to</param>
/// <param name="error">the error code</param>
public static void SendCharCreateReply(IPacketReceiver client, LoginErrorCode error)
{
using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_CHAR_CREATE, 1))
{
packet.WriteByte((byte)error);
client.Send(packet);
}
}
示例8: TestParsedSegment
public void TestParsedSegment()
{
PacketDefinition def = new PacketDefinition(RealmServerOpCode.CMSG_PLAYER_AI_CHEAT, PacketSender.Client,
new PacketSegmentStructure(SimpleType.UInt, "SpellAttributes", typeof(SpellAttributes)),
new ListPacketSegmentStructure(SimpleType.Byte, "Members",
new PacketSegmentStructure(SimpleType.Guid, "MemberId"),
new PacketSegmentStructure(SimpleType.CString, "Name")
),
new SwitchPacketSegmentStructure("Attribute Switch", "SpellAttributes",
new SwitchCase(ComparisonType.And, SpellAttributes.CannotBeCastInCombat,
new PacketSegmentStructure(SimpleType.CString, "NoCombatString")
),
new SwitchCase(ComparisonType.And, SpellAttributes.CannotBeCastInCombat | SpellAttributes.CastableWhileMounted,
new PacketSegmentStructure(SimpleType.CString, "NoCombatNoDismountString")
)
),
new SwitchPacketSegmentStructure("List Switch", "Members",
new SwitchCase(ComparisonType.Equal, (byte)0,
new PacketSegmentStructure(SimpleType.Byte, "Status", "CharacterStatus"),
new SwitchPacketSegmentStructure("Nested Switch", "Status",
new SwitchCase(ComparisonType.AndNot, CharacterStatus.OFFLINE,
new PacketSegmentStructure(SimpleType.UInt, "NumX")
)
)
),
new SwitchCase(ComparisonType.GreaterThan, (byte)0,
new PacketSegmentStructure(SimpleType.CString, "Info")
)
),
new StaticListPacketSegmentStructure(1, "StaticList1",
new PacketSegmentStructure(SimpleType.Int, "Number1")
),
new StaticListPacketSegmentStructure(2, "StaticList2",
new PacketSegmentStructure(SimpleType.Int, "Number2")
),
new PacketSegmentStructure(SimpleType.Byte, "ListLength"),
new ListPacketSegmentStructure("SomeList3", "ListLength",
new PacketSegmentStructure(SimpleType.Int, "SomeListEle")
)
);
def.Init();
using (var packet = new RealmPacketOut(RealmServerOpCode.CMSG_PLAYER_AI_CHEAT))
{
packet.WriteUInt((uint)(SpellAttributes.CastableWhileMounted | SpellAttributes.CannotBeCastInCombat));
packet.WriteByte(2);
packet.Write(EntityId.Zero);
packet.WriteCString("Member1Name");
packet.Write(new EntityId(10));
packet.WriteCString("Member2Name");
packet.WriteCString("NoCombat");
packet.WriteCString("NoCombatNoDismount");
packet.WriteCString("lotsofinfo");
// StaticList1
packet.WriteInt(10);
// StaticList2
packet.WriteInt(20);
packet.WriteInt(30);
// SomeList3's length
packet.WriteByte(2);
// SomeList3
packet.WriteInt(5);
packet.WriteInt(7);
var parsedPacket = PacketParser.Parse(packet, PacketSender.Client, def);
Assert.AreEqual("NoCombat", parsedPacket["NoCombatString"].StringValue);
Assert.AreEqual("NoCombatNoDismount", parsedPacket["NoCombatNoDismountString"].StringValue);
var members = parsedPacket["Members"];
Assert.AreEqual(EntityId.Zero, members[0]["MemberId"].EntityIdValue);
Assert.AreEqual("Member1Name", members[0]["Name"].StringValue);
Assert.AreEqual("Member2Name", members[1]["Name"].StringValue);
Assert.AreEqual("lotsofinfo", parsedPacket["Info"].StringValue);
CheckRemainder(parsedPacket);
}
using (var packet = new RealmPacketOut(RealmServerOpCode.CMSG_PLAYER_AI_CHEAT))
{
packet.WriteUInt((uint)SpellAttributes.None);
packet.WriteByte(0);
packet.Write((byte)CharacterStatus.ONLINE);
packet.Write((uint)1234);
packet.WriteInt(10);
//.........这里部分代码省略.........
示例9: SendNameInvalid
public static void SendNameInvalid(IPacketReceiver receiver, PetNameInvalidReason reason, string name)
{
using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_PET_NAME_INVALID))
{
packet.Write((uint)reason);
packet.WriteCString(name);
packet.WriteByte(0);
receiver.Send(packet);
}
}
示例10: SendAuthQueueStatus
/// <summary>
/// Sends the number of currently queued clients.
/// </summary>
/// <param name="client">the client to send to</param>
public static void SendAuthQueueStatus(IRealmClient client)
{
using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_AUTH_RESPONSE))
{
packet.WriteByte((byte)LoginErrorCode.AUTH_WAIT_QUEUE);
packet.Write(AuthQueue.QueuedClients + 1);
client.Send(packet);
}
}
示例11: SendSpellCooldown
/// <summary>
/// Send a custom cooldown time to the client
/// </summary>
public static void SendSpellCooldown(WorldObject caster, IRealmClient client, uint spellId, ushort cooldown)
{
using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_SPELL_COOLDOWN, 14))
{
packet.Write(caster.EntityId.Full);
packet.WriteByte(0x00);// 1 = use category cooldown
packet.Write(spellId);
packet.Write((uint)cooldown); // if > 0, use this. If 0, use spell.RecoveryTime
client.Send(packet);
}
}
示例12: SendAuthSessionErrorReply
/// <summary>
/// Sends an auth session error response to the client.
/// </summary>
/// <param name="client">the client to send to</param>
/// <param name="error">the error code</param>
public static void SendAuthSessionErrorReply(IPacketReceiver client, LoginErrorCode error)
{
using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_AUTH_RESPONSE, 1))
{
packet.WriteByte((byte)error);
client.Send(packet);
}
}
示例13: SendAuthSuccessful
public static void SendAuthSuccessful(IRealmClient client)
{
using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_AUTH_RESPONSE, 11))
{
packet.WriteByte((byte)LoginErrorCode.AUTH_OK);
//BillingTimeRemaining
packet.Write(0);
packet.Write((byte)0x02);// BillingPlan Flags
// 0x2, 0x4, 0x10 mutually exclusive. Order of Precedence: 0x2 > 0x4 > 0x10
// 0x2 -> No Time left?
// 0x20
// 0x8
// BillingTimeRested
packet.Write(0);
packet.Write((byte)client.Account.ClientId);
client.Send(packet);
}
ClientAddonHandler.SendAddOnInfoPacket(client);
RealmServer.Instance.OnClientAccepted(null, null);
}
示例14: SendCharacterRename
public static void SendCharacterRename(IPacketReceiver client, EntityId guid, string newName)
{
using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_CHAR_RENAME, 10 + newName.Length))
{
packet.WriteByte((byte)LoginErrorCode.RESPONSE_SUCCESS);
packet.Write(guid);
packet.WriteCString(newName);
client.Send(packet);
}
}
示例15: SendCharacterRenameError
public static void SendCharacterRenameError(IPacketReceiver client, LoginErrorCode error)
{
using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_CHAR_RENAME, 1))
{
packet.WriteByte((byte)error);
client.Send(packet);
}
}