本文整理汇总了C#中PacketWriter.WriteStruct方法的典型用法代码示例。如果您正苦于以下问题:C# PacketWriter.WriteStruct方法的具体用法?C# PacketWriter.WriteStruct怎么用?C# PacketWriter.WriteStruct使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PacketWriter
的用法示例。
在下文中一共展示了PacketWriter.WriteStruct方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Build
public override byte[] Build()
{
PacketWriter writer = new PacketWriter();
writer.Write(0x753A); // Unknown
writer.Write((int)0); // Unknown
writer.WriteStruct<QuestDefiniton>(data);
writer.WriteStruct<QuestDifficultyPacket.QuestDifficulty>(difficulty);
return writer.ToArray();
}
示例2: Build
public override byte[] Build()
{
PacketWriter writer = new PacketWriter();
writer.WriteStruct(headerA);
writer.WriteStruct(headerB);
writer.Write((uint)0); // Padding
writer.WriteStruct(headerC);
writer.WriteStruct(headerD);
writer.Write((uint)0); // Padding
writer.WriteAscii(command, 0x5CCF, 0x15);
return writer.ToArray();
}
示例3: HandlePacket
public override void HandlePacket(Client context, byte flags, byte[] data, uint position, uint size)
{
if (context.User == null)
return;
var writer = new PacketWriter();
using (var db = new PolarisEf())
{
var chars = db.Characters
.Where(w => w.Player.PlayerId == context.User.PlayerId)
.OrderBy(o => o.CharacterId) // TODO: Order by last played
.Select(s => s);
writer.Write((uint)chars.Count()); // Number of characters
for (var i = 0; i < 0x4; i++) // Whatever this is
writer.Write((byte)0);
foreach (var ch in chars)
{
writer.Write((uint)ch.CharacterId);
writer.Write((uint)context.User.PlayerId);
for (var i = 0; i < 0x10; i++)
writer.Write((byte)0);
writer.WriteFixedLengthUtf16(ch.Name, 16);
writer.Write((uint)0);
writer.WriteStruct(ch.Looks); // Note: Pre-Episode 4 created looks doesn't seem to work anymore
writer.WriteStruct(ch.Jobs);
for (var i = 0; i < 0xFC; i++)
writer.Write((byte)0);
}
}
// Ninji note: This packet may be followed by extra data,
// after a fixed-length array of character data structures.
// Needs more investigation at some point.
// ---
// CK note: Extra data is likely current equipment, playtime, etc.
// All of that data is currently unaccounted for at the moment.
context.SendPacket(0x11, 0x03, 0, writer.ToArray());
}
示例4: Build
public override byte[] Build()
{
PacketWriter writer = new PacketWriter();
writer.Write(new byte[12]);
writer.WriteStruct(src.Header);
writer.WritePosition(dst);
writer.Write(new byte[2]);
return writer.ToArray();
}
示例5: Build
public override byte[] Build()
{
PacketWriter writer = new PacketWriter();
writer.WriteMagic((uint)questdefs.Length, 0x1DB0, 0xC5);
foreach (QuestDefiniton d in questdefs)
{
writer.WriteStruct(d);
}
return writer.ToArray();
}
示例6: Build
public override byte[] Build()
{
PacketWriter writer = new PacketWriter();
writer.WriteStruct(player);
writer.Write(-1); // Dunno what goes here
writer.WriteMagic(0x20, 0xE80C, 0xED); // 20 Things
writer.Write(new Byte[16 * 0x20]); // 16 Bytes each
return writer.ToArray();
}
示例7: Build
public override byte[] Build()
{
PacketWriter writer = new PacketWriter();
writer.WriteMagic((uint)questdiffs.Length, 0x292C, 0x5B);
foreach (QuestDifficulty d in questdiffs)
{
writer.WriteStruct(d);
}
return writer.ToArray();
}
示例8: HandlePacket
public override void HandlePacket(Client context, byte flags, byte[] data, uint position, uint size)
{
if (context.User == null)
return;
var writer = new PacketWriter();
using (var db = new PolarisEf())
{
var chars = from c in db.Characters
where c.Player.PlayerId == context.User.PlayerId
select c;
writer.Write((uint)chars.Count());
foreach (var ch in chars)
{
writer.Write((uint)ch.CharacterId);
writer.Write((uint)context.User.PlayerId);
for (var i = 0; i < 0xC; i++)
writer.Write((byte)0);
writer.WriteFixedLengthUtf16(ch.Name, 16);
writer.Write((uint)0);
writer.WriteStruct(ch.Looks);
writer.WriteStruct(ch.Jobs);
for (var i = 0; i < 0x44; i++)
writer.Write((byte)0);
}
}
// Ninji note: This packet may be followed by extra data,
// after a fixed-length array of character data structures.
// Needs more investigation at some point.
// ---
// CK note: Extra data is likely current equipment, playtime, etc.
// All of that data is currently unaccounted for at the moment.
context.SendPacket(0x11, 0x03, 0, writer.ToArray());
}
示例9: Build
public override byte[] Build()
{
PacketWriter writer = new PacketWriter();
// TODO: This sub/xor needs to be checked, it's more than likely wrong
// writer.WriteMagic((uint)questdiffs.Length, 0x1DB0, 0xC5);
writer.Write((int)0x294D); // Just directly write the sub/xor for now
foreach (QuestDifficulty d in questdiffs)
{
writer.WriteStruct(d);
}
return writer.ToArray();
}
示例10: Build
public override byte[] Build()
{
var writer = new PacketWriter();
// Player header
writer.WritePlayerHeader((uint) _character.Player.PlayerId);
// Spawn position
writer.Write(Position);
writer.Write((ushort) 0); // padding?
writer.WriteFixedLengthASCII("Character", 32);
writer.Write((ushort) 1); // 0x44
writer.Write((ushort) 0); // 0x46
writer.Write((uint) 602); // 0x48
writer.Write((uint) 1); // 0x4C
writer.Write((uint) 53); // 0x50
writer.Write((uint) 0); // 0x54
writer.Write((uint) (IsItMe ? 47 : 39)); // 0x58
writer.Write((ushort) 559); // 0x5C
writer.Write((ushort) 306); // 0x5E
writer.Write((uint) _character.Player.PlayerId); // player ID copy
writer.Write((uint) 0); // "char array ugggghhhhh" according to PolarisLegacy
writer.Write((uint) 0); // "voiceParam_unknown4"
writer.Write((uint) 0); // "voiceParam_unknown8"
writer.WriteFixedLengthUtf16(_character.Name, 16);
writer.Write((uint) 0); // 0x90
writer.WriteStruct(_character.Looks);
writer.WriteStruct(_character.Jobs);
writer.WriteFixedLengthUtf16("", 32); // title?
writer.Write((uint) 0); // 0x204
writer.Write((uint) 0); // gmflag?
writer.WriteFixedLengthUtf16(_character.Player.Nickname, 16); // nickname, maybe not 16 chars?
for (var i = 0; i < 64; i++)
writer.Write((byte) 0);
return writer.ToArray();
}
示例11: Build
public override byte[] Build()
{
var resp = new PacketWriter();
resp.Write((uint)((userid == 0) ? 1 : 0)); // Status flag: 0=success, 1=error
resp.WriteUtf16(error, 0x8BA4, 0xB6);
if (userid == 0)
{
for (var i = 0; i < 0xEC; i++)
resp.Write((byte)0);
return resp.ToArray();
}
// TODO: Explore this data! Some if it seems really important. (May contain level cap setting + more)
resp.WriteStruct(new ObjectHeader(userid, EntityType.Player));
resp.WriteFixedLengthUtf16(blockName, 0x20); // This is right
// Set things to "default" values; Dunno these purposes yet.
resp.Write(0x42700000); //0
resp.Write(7); //4
resp.Write(0xA); //8 - Level Cap!
resp.Write(1); //C
resp.Write(0x41200000); //10
resp.Write(0x40A00000); //14
resp.Write(11); //18
resp.Write(0x3F800000); //1C (1 as a float)
resp.Write(0x42960000); //20
resp.Write(40); //24
resp.Write(0x41200000); //28
resp.Write(1); //2C?
resp.Write(1120403456); //30
//WHAT
for (int i = 0; i < 10; i++)
{
resp.Write(1065353216);
}
//ARE
for (int i = 0; i < 21; i++)
{
resp.Write(1120403456);
}
//THESE?
resp.Write(0x91A2B); //B0
resp.Write(0x91A2B); //B4
resp.WriteBytes(0, 12);
return resp.ToArray();
}
示例12: Build
public override byte[] Build()
{
PacketWriter writer = new PacketWriter();
writer.Write(questdef.questNameString);
writer.Write(0);
writer.Write((ushort)0);
writer.Write((ushort)0);
writer.Write((ushort)0);
writer.Write((ushort)1);
writer.WriteStruct(new ObjectHeader((uint)p.PlayerId, EntityType.Player));
writer.Write(0);
writer.Write((ushort)0);
writer.Write((ushort)0);
writer.Write((ushort)0);
writer.Write((ushort)0);
writer.Write(0);
writer.Write(0);
return writer.ToArray();
}
示例13: HandlePacket
public override void HandlePacket(Client context, byte flags, byte[] data, uint position, uint size)
{
PacketReader reader = new PacketReader(data);
FullMovementData movData = reader.ReadStruct<FullMovementData>();
if (movData.entity1.ID == 0 && movData.entity2.ID != 0)
movData.entity1 = movData.entity2;
movData.timestamp = 0;
// This could be simplified
PacketWriter writer = new PacketWriter();
writer.WriteStruct(movData);
Logger.WriteInternal("[MOV] {0} stopped moving at ({1}, {2}, {3})", context.Character.Name,
Helper.FloatFromHalfPrecision(movData.currentPos.x), Helper.FloatFromHalfPrecision(movData.currentPos.y),
Helper.FloatFromHalfPrecision(movData.currentPos.z));
foreach (var c in Server.Instance.Clients)
{
if (c == context || c.Character == null || c.CurrentZone != context.CurrentZone)
continue;
c.SendPacket(0x04, 0x71, 0x40, writer.ToArray());
}
}
示例14: Build
public override byte[] Build()
{
if (members.Length < 1)
return new byte[0];
// xor: 0xD863, sub: 0xA9
PacketWriter writer = new PacketWriter();
writer.WriteBytes(0, 12); // Unknown 12 bytes, not obj header
writer.WriteStruct(new ObjectHeader((uint)members[0].Player.PlayerId, EntityType.Player)); // Player receiving the thing
writer.WriteStruct(members.Length); // Likely partymembercount
for(int i = 0; i < members.Length; i++)
{
writer.WriteStruct(new ObjectHeader((uint)members[i].Player.PlayerId, EntityType.Player)); // Header of player
writer.WriteUtf16(members[i].Name, 0xD863, 0xA9);
writer.WriteUtf16(members[i].Player.Nickname, 0xD863, 0xA9);
writer.Write((byte)members[i].Jobs.entries.hunter.level); // Active class level
writer.Write((byte)0); // idk
writer.Write((byte)4); // idk
writer.Write((byte)0xFF); // idk
writer.Write((byte)0); // idk
writer.Write((byte)0); // idk
writer.Write((byte)0); // idk
writer.Write((byte)0xFF); // idk
writer.Write((byte)0xFF); // idk
writer.Write((byte)0); // idk
writer.Write((ushort)0);
writer.Write((ushort)0);
writer.Write((ushort)0);
writer.Write((ushort)0);
writer.Write((ushort)0);
writer.WriteBytes(0, 12);
writer.Write(0);
writer.Write(0);
}
for(int i = 0; i < 4 - members.Length; i++) // Empty entries
{
writer.WriteStruct(new ObjectHeader(0, 0)); // Header of player
writer.WriteMagic(0, 0xD863, 0xA9);
writer.WriteMagic(0, 0xD863, 0xA9);
writer.Write((byte)0); // Active class level
writer.Write((byte)0); // idk
writer.Write((byte)0); // idk
writer.Write((byte)0); // idk
writer.Write((byte)0); // idk
writer.Write((byte)0); // idk
writer.Write((byte)0); // idk
writer.Write((byte)0); // idk
writer.Write((byte)0); // idk
writer.Write((byte)0); // idk
writer.Write((ushort)0);
writer.Write((ushort)0);
writer.Write((ushort)0);
writer.Write((ushort)0);
writer.Write((ushort)0);
writer.WriteBytes(0, 12);
writer.Write(0);
}
return writer.ToArray();
}
示例15: Build
public override byte[] Build()
{
PacketWriter pw = new PacketWriter();
pw.WriteStruct(data);
return pw.ToArray();
}