I'll have to look at it to be sure but I think server to client isn't encoded, at least the version done in osRose it's sent that way directly in void CClientSocket::SendPacket( CPacket *P ):
- int retval = send( sock, (char*)P, P->Size, 0 );
You got the packet structure here:
-
- // Structures
- // Packet information
- struct CPacket
- {
- unsigned short Size; // Packet size
- unsigned short Command; // Packet command
- unsigned short Unused; // unused
- unsigned char Buffer[0x1000]; // Packet data //0x600
- };
-
The list of commands is found in the different servers, stuff like:
- bool CWorldServer::OnReceivePacket( CClientSocket* thisclient, CPacket *P )
Now on the exact structure of received data I know you got the size and stuff but I don't know that part by heart so I'll have to look at it.
You got all the received process in "bool CClientSocket::ReceiveData( )".
The header block of received data (actually the packet size) should be always > 6 but then it's kinda the same structure after decode since you got this after all data is received correctly:
- cryptPacket( (char*)Buffer, this->CryptTable );
- CPacket* pak = (CPacket*)Buffer;
Though indeed the first two Bytes aren't decoded in the CPacket if you look closely at the decode part, it only decodes from the "2" since the first two are actually the packet size
- // en/decrypt packet
- void cryptPacket(char *packet, char* crypttable )
- {
- unsigned short paksize=(*((unsigned short*)&packet[0])) - 2;
- for(int i=2; i<paksize; i++)
- {
- packet[i] = 0x61 ^ packet[i];
- }
- }
The only part where the servers are using the crypt function (apart from receiving data from client) is when they're talking to each other (worldserver to charserver and so on).