![]() |
R-Type
2
Doom but in better
|
This section describes the binary UDP protocol used for communication between the server and client in the R-Type game. This documentation aims to provide clarity on the structure of packets, message types, and their intended usage in both game logic and GUI components.
This is the current protocol that is used by the server and the client to communicate in order to provide a working game engine.
Each UDP message exchanged between the client and the server follows a specific format and scalability. A binary packet is structured as follows:
Field | Size (bits) | Description |
---|---|---|
Message Type | 8 | Identifies the type of message (i.e., MOVE, SHOOT). |
Payload | Variable | Contains data specific to the message type. Optional depending on the type. |
Types of messages sent by the client to the server:
| \[0x01\]\[username...\] | | :---- |
username
(8 characters max, padded with null bytes if shorter) is the name of the player.| 0x01 50 6c 61 79 65 72 31 00 | | :---- |
| \[0x02\]\[id...\]| | :---- |
id
(size_t) is the entity id on the ECS.| \[0x03\]\[id...\]\[x...\]\[y...\] | | :---- |
id
(size_t) is the entity id on the ECS.x
(float) is the X coordinatey
(float) is the Y coordinateExample: A player 1
moving to (16, 8)
:
| 0x03 0x00 ... 0x01 0x00 ... 0x10 0x00 ... 0x08 | | :-— |
Format:
| [0x04][id...] | | :-— |
id
(size_t) is the entity id on the ECS.Format:
| [0x05][id...][asset...][x...][y...] | | :-— |
id
(size_t): Unique entity ID.asset
(short): Asset ID.x
, y
(4 bytes each): Coordinates.Format:
| [0x06][id...] | | :-— |
id
(size_t) is the entity id on the ECS.Format:
| [0x07][id...] | | :-— |
id
(size_t) is the entity id on the ECS.Format:
| [0x08][status] | | :-— |
status
(1 byte)0x00
: On going.0x01
: Victory.0xFF
: Defeat.Format:
| [0xFF][0x00][size][error_code] | | :-— |
Client Errors If a client sends an invalid request (e.g., moving out of bounds), an error packet is returned:
| 0xFF 0x01 | | :-— |
0x01
: Invalid action.Server Errors: Malformed packets or server-side issues result in an error response:
| 0xFF 0x02 | | :-— |
0x02
: Malformed packet