本文整理汇总了C#中PacketReader.ReadAscii方法的典型用法代码示例。如果您正苦于以下问题:C# PacketReader.ReadAscii方法的具体用法?C# PacketReader.ReadAscii怎么用?C# PacketReader.ReadAscii使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PacketReader
的用法示例。
在下文中一共展示了PacketReader.ReadAscii方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HandlePacket
public override void HandlePacket(Client context, byte flags, byte[] data, uint position, uint size)
{
PacketReader reader = new PacketReader(data);
reader.ReadBytes(12); // Padding MAYBE???????????
ObjectHeader srcObject = reader.ReadStruct<ObjectHeader>();
byte[] someBytes = reader.ReadBytes(4); // Dunno what this is yet.
ObjectHeader dstObject = reader.ReadStruct<ObjectHeader>(); // Could be wrong
reader.ReadBytes(16); // Not sure what this is yet
string command = reader.ReadAscii(0xD711, 0xCA);
PSOObject srcObj;
if(srcObject.EntityType == EntityType.Object)
{
srcObj = ObjectManager.Instance.getObjectByID(context.CurrentZone.Name, srcObject.ID);
}
else if(srcObject.EntityType == EntityType.Player)
{
srcObj = new PSOObject();
srcObj.Header = srcObject;
srcObj.Name = "Player";
}
else
{
srcObj = null;
}
Logger.WriteInternal("[OBJ] {0} (ID {1}) <{2}> --> Ent {3} (ID {4})", srcObj.Name, srcObj.Header.ID, command, (EntityType)dstObject.EntityType, dstObject.ID);
// TODO: Delete this code and do this COMPLETELY correctly!!!
if (command == "Transfer" && context.CurrentZone.Name == "lobby")
{
// Try and get the teleport definition for the object...
using (var db = new PolarisEf())
{
db.Configuration.AutoDetectChangesEnabled = true;
var teleporterEndpoint = db.Teleports.Find("lobby", (int)srcObject.ID);
if (teleporterEndpoint == null)
{
Logger.WriteError("[OBJ] Teleporter for {0} in {1} does not contain a destination!", srcObj.Header.ID, "lobby");
// Teleport Player to default point
context.SendPacket(new TeleportTransferPacket(srcObj, new PSOLocation(0f, 1f, 0f, -0.000031f, -0.417969f, 0.000031f, 134.375f)));
// Unhide player
context.SendPacket(new ObjectActionPacket(dstObject, srcObject, new ObjectHeader(), new ObjectHeader(), "Forwarded"));
}
else
{
PSOLocation endpointLocation = new PSOLocation()
{
RotX = teleporterEndpoint.RotX,
RotY = teleporterEndpoint.RotY,
RotZ = teleporterEndpoint.RotZ,
RotW = teleporterEndpoint.RotW,
PosX = teleporterEndpoint.PosX,
PosY = teleporterEndpoint.PosY,
PosZ = teleporterEndpoint.PosZ,
};
// Teleport Player
context.SendPacket(new TeleportTransferPacket(srcObj, endpointLocation));
// Unhide player
context.SendPacket(new ObjectActionPacket(dstObject, srcObject, new ObjectHeader(), new ObjectHeader(), "Forwarded"));
}
}
}
if (command == "READY")
{
context.SendPacket(new ObjectActionPacket(new ObjectHeader((uint)context.User.PlayerId, EntityType.Player), srcObj.Header, srcObj.Header,
new ObjectHeader(), "FavsNeutral"));
context.SendPacket(new ObjectActionPacket(new ObjectHeader((uint)context.User.PlayerId, EntityType.Player), srcObj.Header, srcObj.Header,
new ObjectHeader(), "AP")); // Short for Appear, Thanks Zapero!
}
if (command == "Sit")
{
foreach (var client in Server.Instance.Clients)
{
if (client.Character == null || client == context)
continue;
client.SendPacket(new ObjectActionPacket(new ObjectHeader((uint)client.User.PlayerId, EntityType.Player), srcObj.Header,
new ObjectHeader(dstObject.ID, EntityType.Player), new ObjectHeader(), "SitSuccess"));
}
}
}
示例2: HandlePacket
public override void HandlePacket(Client context, byte flags, byte[] data, uint position, uint size)
{
PacketReader reader = new PacketReader(data);
reader.ReadStruct<ObjectHeader>(); // Skip blank entity header.
var preformer = reader.ReadStruct<ObjectHeader>(); // Preformer
byte[] preData = reader.ReadBytes(40);
string command = reader.ReadAscii(0x922D, 0x45);
byte[] rest = reader.ReadBytes(4);
uint thingCount = reader.ReadMagic(0x922D, 0x45);
byte[] things;
PacketWriter thingWriter = new PacketWriter();
for (int i = 0; i < thingCount; i++)
{
thingWriter.Write(reader.ReadBytes(4));
}
things = thingWriter.ToArray();
byte[] final = reader.ReadBytes(4);
Logger.WriteInternal("[ACT] {0} is preforming {1}", context.Character.Name, command);
foreach (var c in Server.Instance.Clients)
{
if (c == context || c.Character == null || c.CurrentZone != context.CurrentZone)
continue;
PacketWriter output = new PacketWriter();
output.WriteStruct(new ObjectHeader((uint)context.User.PlayerId, EntityType.Player));
output.WriteStruct(preformer);
output.Write(preData);
output.WriteAscii(command, 0x4315, 0x7A);
output.Write(rest);
output.WriteMagic(thingCount, 0x4315, 0x7A);
output.Write(things);
output.Write(final);
c.SendPacket(0x4, 0x80, 0x44, output.ToArray());
}
}