PHP Code:
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace Conquer_Online_Server.Network.GamePackets
{
public class GroundMovement : Writer, Interfaces.IPacket
{
public const uint Walk = 0,
Run = 1,
Slide = 9;
public GroundMovement(bool CreateInstance)
{
}
public byte[] CreateProtocolBuffer(params uint[] values)
{
List<byte> ptr = new List<byte>();
ptr.Add(8);
for (int x = 0; x < values.Length; x++)
{
uint value = values[x];
while (value > 0x7F)
{
ptr.Add((byte)((value & 0x7F) | 0x80));
value >>= 7;
}
ptr.Add((byte)(value & 0x7F));
ptr.Add((byte)(8 * (x + 2)));
if (x + 1 == values.Length)
break;
}
return ptr.ToArray();
}
public uint ReadFromProtocolUint32(uint position, BinaryReader reader)
{
byte key = reader.ReadByte();
if (key == position)
{
uint value = 0;
int shift = 0;
uint val = reader.ReadByte();
while (val > 0x7F)
{
value |= (val & 0x7F) << shift;
shift += 7;
val = reader.ReadByte();
}
value |= (val & 0x7F) << shift;
return value;
}
return 0;
}
public byte[] ToArray()
{
byte[] ptr = CreateProtocolBuffer((uint)Direction, UID, GroundMovementType, TimeStamp, MapID);
List<byte> pack = new List<byte>();
for (int i = 0; i < (ptr.Length - 1); i++)
{
pack.Add(ptr[i]);
}
ptr = pack.ToArray();
byte[] buffer = new byte[12 + ptr.Length];
Writer.WriteUInt16((ushort)(buffer.Length - 8), 0, buffer);
Writer.WriteUInt16(10005, 2, buffer);
System.Array.Copy(ptr, 0, buffer, 4, ptr.Length);
return buffer;
}
public void Deserialize(byte[] buffer)
{
var packet = new byte[buffer.Length - 4];
System.Array.Copy(buffer, 4, packet, 0, packet.Length);
using (var Reader = new BinaryReader(new MemoryStream(packet)))
{
uint direction = 0;
uint uid = 0;
uint type = 0;
uint tstamp = 0;
uint mapid = 0;
for (int i = 0; i < Reader.BaseStream.Length; i++)
{
Reader.BaseStream.Position = i;
if (packet[i] == 8)
{
direction = ReadFromProtocolUint32(8, Reader);
}
if (packet[i] == 16)
{
uid = ReadFromProtocolUint32(16, Reader);
}
if (packet[i] == 24)
{
type = ReadFromProtocolUint32(24, Reader);
}
if (packet[i] == 32)
{
tstamp = ReadFromProtocolUint32(32, Reader);
}
if (packet[i] == 40)
{
mapid = ReadFromProtocolUint32(40, Reader);
}
}
Direction = (Conquer_Online_Server.Game.Enums.ConquerAngle)direction;
UID = uid;
GroundMovementType = type;
TimeStamp = tstamp;
MapID = mapid;
}
}
public Game.Enums.ConquerAngle Direction;
public uint UID;
public uint TimeStamp;
public uint MapID;
public uint GroundMovementType;
public void Send(Client.GameClient client)
{
client.Send(ToArray());
}
}
}
change
Conquer_Online_Server
by name of your Project.