More cleanups

- Enabled Packet Obfuscation by default.
- Added a bit of documentation.
This commit is contained in:
aleos89 2015-03-14 11:45:42 -04:00
parent 1be5665580
commit 1b69b981fa
2 changed files with 9 additions and 9 deletions

View File

@ -93,10 +93,10 @@
#define MAX_CHAR_VIP 0
#endif
/// Uncomment to enable the official packet obfuscation support.
/// If enabled, make sure there is value for 'packet_keys' of used packet version or
/// redifned 'packet_keys_use' in db/[import/]packet_db.txt.
//#define PACKET_OBFUSCATION
/// Comment to disable the official packet obfuscation support.
/// When enabled, make sure there is value for 'packet_keys' of used packet version or
/// defined 'packet_keys_use' in db/[import/]packet_db.txt.
#define PACKET_OBFUSCATION
/**
* No settings past this point

View File

@ -17546,12 +17546,12 @@ static unsigned short clif_parse_cmd(int fd, struct map_session_data *sd) {
#ifndef PACKET_OBFUSCATION
return RFIFOW(fd, 0);
#else
unsigned short cmd = RFIFOW(fd,0);
unsigned short cmd = RFIFOW(fd,0); // Check if it is a player that tries to connect to the map server.
if (sd)
cmd = (cmd ^ ((sd->cryptKey >> 16) & 0x7FFF));
cmd = (cmd ^ ((sd->cryptKey >> 16) & 0x7FFF)); // Decrypt the current packet ID with the last key stored in the session.
else
cmd = (cmd ^ ((((clif_cryptKey[0] * clif_cryptKey[1]) + clif_cryptKey[2]) >> 16) & 0x7FFF));
return cmd;
cmd = (cmd ^ ((((clif_cryptKey[0] * clif_cryptKey[1]) + clif_cryptKey[2]) >> 16) & 0x7FFF)); // A player tries to connect - use the initial keys for the decryption of the packet ID.
return cmd; // Return the decrypted packet ID.
#endif
}