本文整理匯總了C#中ServerEngine.PacketEngine.Packet.GetBuffer方法的典型用法代碼示例。如果您正苦於以下問題:C# Packet.GetBuffer方法的具體用法?C# Packet.GetBuffer怎麽用?C# Packet.GetBuffer使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類ServerEngine.PacketEngine.Packet
的用法示例。
在下文中一共展示了Packet.GetBuffer方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Decrypt
/// <summary>
/// Decrypts the given packet
/// </summary>
/// <param name="p">The packet to decrypt</param>
public static Packet Decrypt(Packet p, int key)
{
byte[] data = p.GetBuffer();
int packetLength = data.Length - 4;
string value;
int Lenght;
byte BL, DL, CL;
long AL;
value = data[3].ToString("x2");
value += data[2].ToString("x2");
Lenght = Int32.Parse(value, NumberStyles.HexNumber);
BL = (byte)key;
CL = data[0];
AL = Lenght + 4;
DL = CL;
DL = (byte)(DL - AL);
DL = (byte)(DL - BL);
data[0] = DL;
DL = data[1];
BL = DL;
BL = (byte)(BL - AL);
BL = (byte)(BL - CL);
BL = (byte)(BL - key);
data[1] = BL;
for (int a = 0; a < Lenght; a++)
{
BL = data[a + 4];
BL = (byte)(BL - AL);
BL = (byte)(BL - DL);
BL = (byte)(BL - key);
DL = data[a + 4];
data[a + 4] = BL;
}
return new Packet(data);
}
示例2: Normal
public static Packet Normal(Packet p)
{
byte[] data = p.GetBuffer();
return new Packet(data);
}
示例3: HandlePacket
private void HandlePacket(Packet p)
{
int curByte = 0;
int maxByte = p.Length;
while (curByte < maxByte)
{
int parsedLength = p.ReadShort((curByte + 2)) + 4;
byte[] parsed = new byte[parsedLength];
// read bytes from buffer to parsed packets.
for (int i = 0; i < parsed.Length; i++)
{
parsed[i] = p.GetBuffer()[i + curByte];
}
// decrypt those bytes as a new real deal parsed packet
Packet Parsed = Packet.Decrypt(new Packet(parsed), key);
curByte += parsedLength;
PacketIds PI = (PacketIds)Parsed.ReadShort();
switch (PI)
{
#region Login Recvs
case PacketIds.Recv_GameLogin:
HandleRecvGameLogin(Parsed);
break;
case PacketIds.Recv_ConnectWorld:
HandleRecvConnectWorld(Parsed);
break;
#endregion
#region World Recvs
case PacketIds.RecvUnitLogin:
HandleRecvUnitLogin(Parsed);
break;
case PacketIds.RecvCreateCharacter:
HandleRecvCreateCharacter(Parsed);
break;
case PacketIds.RecvChannelRequest:
HandleRecvChannelRequest(Parsed);
break;
#endregion
#region Channel Recvs
case PacketIds.RecvPing:
// needs check if too fast or so :I
break;
case PacketIds.RecvChannelLogin:
HandleRecvChannelLogin(Parsed);
break;
case PacketIds.RecvChannelChange:
HandleRecvChannelChange(Parsed);
break;
case PacketIds.RecvChannelSomething:
HandleRecvChannelStuff(Parsed);
break;
case PacketIds.RecvLoadMap:
HandleRecvMapRequest(Parsed);
break;
case PacketIds.RecvRequestSkillList:
HandleRecvSkillRequest(Parsed);
break;
case PacketIds.RecvRequestInventory:
HandleRecvInventoryRequest(Parsed);
break;
case PacketIds.RecvMoveItem:
HandleRecvMoveItem(Parsed);
break;
case PacketIds.RecvDropItem:
HandleRecvDropItem(Parsed);
break;
case PacketIds.RecvPickItem:
HandleRecvPickItem(Parsed);
break;
case PacketIds.RecvImbueItem:
HandleRecvImbueItem(Parsed);
break;
case PacketIds.RecvAcceptImbueItem:
HandleRecvAcceptImbueItem(Parsed);
break;
case PacketIds.RecvNpcTrade:
//.........這裏部分代碼省略.........
示例4: Encrypt
/// <summary>
/// Encrypts the given packet
/// </summary>
/// <param name="p">The packet to encrypt</param>
public static Packet Encrypt(Packet p, int key)
{
byte[] buffer = p.GetBuffer();
int packetLength = buffer.Length - 4;
string value;
int Lenght;
byte AL, BL;
long CX, CL, DL;
value = buffer[3].ToString("x2");
value += buffer[2].ToString("x2");
Lenght = Int32.Parse(value, NumberStyles.HexNumber);
AL = (byte)key;
BL = buffer[0];
CX = Lenght + 4;
CL = CX;
DL = CL;
DL = (byte)(DL + AL);
BL = (byte)(BL + DL); // First encrypted byte
buffer[0] = BL;
DL = (byte)(BL); // DL = Packet first byte
DL = (byte)(DL + CL); // ADD DL, CL
DL = (byte)(AL + DL); // ADD DL, AL (gotta parse 1)
DL = (byte)(DL + buffer[1]);
buffer[1] = (byte)DL;
for (int i = 0; i < packetLength; i++)
{
BL = (byte)(CL);
BL = (byte)(DL + BL);
BL = (byte)(AL + BL);
BL = (byte)(BL + buffer[i + 4]);
buffer[i + 4] = BL;
DL = BL;
}
return new Packet(buffer);
}
示例5: HandlePacket
private void HandlePacket(Packet p)
{
int curByte = 0;
int maxByte = p.Length;
while (curByte < maxByte)
{
int parsedLength = p.ReadShort((curByte + 2)) + 4;
byte[] parsed = new byte[parsedLength];
// read bytes from buffer to parsed packets.
for (int i = 0; i < parsed.Length; i++)
{
parsed[i] = p.GetBuffer()[i + curByte];
}
// decrypt those bytes as a new real deal parsed packet
Packet Parsed = Packet.Decrypt(new Packet(parsed), key);
curByte += parsedLength;
PacketIds PI = (PacketIds)Parsed.ReadShort();
switch (PI)
{
#region Login Recvs
case PacketIds.Recv_GameLogin:
HandleRecvGameLogin(Parsed);
break;
case PacketIds.Recv_ConnectWorld:
HandleRecvConnectWorld(Parsed);
break;
#endregion
#region World Recvs
case PacketIds.RecvUnitLogin:
HandleRecvUnitLogin(Parsed);
break;
case PacketIds.RecvCreateCharacter:
HandleRecvCreateCharacter(Parsed);
break;
case PacketIds.RecvChannelRequest:
HandleRecvChannelRequest(Parsed);
break;
#endregion
#region Channel Recvs
case PacketIds.RecvPing:
// needs check if too fast or so :I
break;
case PacketIds.RecvChannelLogin:
HandleRecvChannelLogin(Parsed);
break;
case PacketIds.RecvChannelChange:
HandleRecvChannelChange(Parsed);
break;
case PacketIds.RecvChannelSomething:
HandleRecvChannelStuff(Parsed);
break;
case PacketIds.RecvLoadMap:
HandleRecvMapRequest(Parsed);
break;
case PacketIds.RecvRequestSkillList:
HandleRecvSkillRequest(Parsed);
break;
case PacketIds.RecvRequestInventory:
HandleRecvInventoryRequest(Parsed);
break;
case PacketIds.RecvRequestOpenWarehouse:
HandleRecvOpenWarehouse(Parsed);
break;
case PacketIds.RecvMoveWarehouseItemToBag:
HandleRecvMoveWarehouseItemToBag(Parsed);
break;
case PacketIds.RecvAddItemToWarehouse:
HandleRecvAddItemToWarehouse(Parsed);
break;
case PacketIds.RecvMoveWarehouseItem:
HandleRecvMoveWarehouseItem(Parsed);
break;
case PacketIds.RecvMoveItem:
HandleRecvMoveItem(Parsed);
break;
case PacketIds.RecvDropItem:
//.........這裏部分代碼省略.........