Thanatos multiplayer protocol

The Thanatos Multiplayer Protocol (TMP) is a network protocol used by the Thanatos Engine, which runs Age of Prisoners, to establish connections between clients and servers in multiplayer mode. This article describes TMP 0.0.8 (the one used by Thanatos 0.0.8).

Login process
The default TCP/IP port for TMP is 1302. As soon as a connection between the server and the client is established, the server sends the 8-byte magic string  to the client, which allows the client to make sure it's a valid server. The client then responds with the 8-byte magic response, which tells the server that it's a valid client. Once this happens, the connection is said to be validated.

Once a connection is validated, the client has to log in. It does it by sending the login packet, which has the following format:

Each field directly follows the previous one. Example:. After the login packet has been sent, the server replies with a message. First, it sends 1 byte that specifies the size of the message string, and then the actual message. If the size is 0, then no message follows it, and the login was successful. If, however, there is a message, it means the login failed, and the message is a human-readable error message.

Once the user has logged in, all communication happens in terms of the message packet architecture, described below.

Message Packet Architecture (MPA)
The client and server send each other packets containing information for a specific module. The packet is prefix with a 48-bit (6-byte) header with the following format:

Each type of packet has a unique packet class assigned to it.

Chat
The most basic packet is the one with class 1,. Its body is plain text; it is just the message that the user is sending to the chat. When a user sends a message, the client shall not display it on its chat, since the server will send the message described below to all clients, including the sender.

The server may send a packet with class 2,, which tells the client to put something in the chat window. It is also plain text, however, it is prefixed with a header:

The header specifies what color the message should be displayed in.

Entity Management
There are 3 packet classes that manage entities: one for spawning, the other for updating, and the third for deleting.

Packet class 3,  is sent to a client if it needs to spawn an entity. The format of the packet is the following:

Packet class 4,  is sent to a client if an entity needs updating.

Packet class 5,  is sent to a client if an entity needs to be deleted.