aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfusion32 <marcopuzziello@gmail.com>2025-09-19 23:49:21 -0300
committerfusion32 <marcopuzziello@gmail.com>2025-09-19 23:56:12 -0300
commit11bd6ba26dfdf70d54e685ed1fd1a5898a322c76 (patch)
treee8c1011833da2fd2e00a1fefb4b19a6dd932cc3b
parent465620a871e7da8d72d82a999eac8623570d13fd (diff)
downloadgame-11bd6ba26dfdf70d54e685ed1fd1a5898a322c76.tar.gz
game-11bd6ba26dfdf70d54e685ed1fd1a5898a322c76.zip
support 7.72 with non-default `-DTIBIA772=1` switch
-rw-r--r--src/communication.cc22
1 files changed, 21 insertions, 1 deletions
diff --git a/src/communication.cc b/src/communication.cc
index ab92092..b373900 100644
--- a/src/communication.cc
+++ b/src/communication.cc
@@ -23,7 +23,12 @@
#define MAX_COMMUNICATION_THREADS 1100
#define COMMUNICATION_THREAD_STACK_SIZE ((int)KB(64))
+#if TIBIA772
+static const int TERMINALVERSION[] = {772, 772, 772};
+#else
static const int TERMINALVERSION[] = {770, 770, 770};
+#endif
+
static int TCPSocket;
static ThreadHandle AcceptorThread;
static pid_t AcceptorThreadID;
@@ -918,10 +923,23 @@ bool HandleLogin(TConnection *Connection){
char PlayerName[30];
char PlayerPassword[30];
try{
+#if TIBIA772
+ // IMPORTANT(fusion): With 7.72, the terminal type and version are brought
+ // outside the asymmetric data. This is probably to maintain some level of
+ // backwards compatibility, given that 7.7 was the first encrypted protocol.
+ TerminalType = (int)InputBuffer.readWord();
+ TerminalVersion = (int)InputBuffer.readWord();
+#endif
+
+ // IMPORTANT(fusion): Without a checksum, there is no way of validating the
+ // asymmetric data. The best we can do is to verify that the first plaintext
+ // byte is ZERO, but that alone isn't enough.
+ // TODO(fusion): Using `SendLoginMessage` before initializing the symmetric
+ // key will result in gibberish being sent back to the client.
uint8 AsymmetricData[128];
InputBuffer.readBytes(AsymmetricData, 128);
RSAMutex.down();
- if(!PrivateKey.decrypt(AsymmetricData)){
+ if(!PrivateKey.decrypt(AsymmetricData) || AsymmetricData[0] != 0){
RSAMutex.up();
error("HandleLogin: Fehler beim Entschlüsseln.\n");
SendLoginMessage(Connection, LOGIN_MESSAGE_ERROR,
@@ -933,8 +951,10 @@ bool HandleLogin(TConnection *Connection){
TReadBuffer ReadBuffer(AsymmetricData, 128);
ReadBuffer.readByte(); // always zero
Connection->SymmetricKey.init(&ReadBuffer);
+#if !TIBIA772
TerminalType = (int)ReadBuffer.readWord();
TerminalVersion = (int)ReadBuffer.readWord();
+#endif
GamemasterClient = ReadBuffer.readByte() != 0;
AccountID = ReadBuffer.readQuad();
ReadBuffer.readString(PlayerName, sizeof(PlayerName));