- Joined
- Apr 2, 2008
- Messages
- 271
- Reaction score
- 24
Hey, I'm currently trying to port a C++ source into C#, but it confuses me;
the C++ code:
the baseclient is declared but has no use?
The pak is a buffer wich stores all the written packet data, and after that, the buffer has to been Encrypted;
Current code:
the memcpy doesn't work with BlockCopy, how do I fix it?
packet.memoryStream = newpacket; doesn't work either
How do I get the bytes count from an object? Like if it's a short it would return 2?
Please help me
thx in advance
the C++ code:
Code:
void EncryptPacket( CTitanClient* baseclient, CTitanPacket* pak ){
if(pak->Size() > 0xFF){
pak->Set<byte>(0, 0, 0);
memcpy(pak->Buffer() + 3, pak->Buffer() + 1, pak->Size() - 1);
pak->Size(pak->Size() + 2);
pak->Set<word>(pak->Size() - 3, 1, 0);
}else{
pak->Set<byte>(pak->Size() - 1,0,0);
}
}
Code:
template <typename T> void Set( T val, word pos, word offset = PACKET_HEADER_SIZE )
{
*((T*)&_Buffer[pos + offset]) = val;
}
Current code:
the memcpy doesn't work with BlockCopy, how do I fix it?
packet.memoryStream = newpacket; doesn't work either
Code:
public void EncryptPacket(Packet packet, Player player)
{
if (packet.GetLenght() > 0xFF)
{
byte[] newpacket;
packet.WriteAtOffset((byte)0, 0, 0);
Buffer.BlockCopy(packet.GetWrittenBuffer() + 3, newpacket + 1, packet.GetLenght() - 1);
packet.memoryStream = newpacket;
packet.PacketSize += 2;
packet.WriteAtOffset((short)packet.PacketSize - 3, 1, 0);
}
else
{
packet.WriteAtOffset((byte)packet.PacketSize - 1, 0, 0);
}
}
public void WriteAtOffset(object value,int pos, int offset)
{
binaryWriter.Write(value, pos + offset, LENGHT);
}
How do I get the bytes count from an object? Like if it's a short it would return 2?
Please help me
thx in advance

Last edited: