Network Message Formats

All data is sent in network, big endian, byte order.

Acknowledgment

Start Offset Field Length
0 Message type: MSG_TYPE_ACK 1
1 Client identification number 1
2 Number of messasges acknowledged.
The value must not exceed MSG_MAX_ACK.
1
3 First acknowledged message ID 2
5, 7, 9, ... Additional acknowledged message IDs 2
5 bytes minimum, 509 bytes maximum (253 messages acknowledged -- highly unlikely).

Connection

Request

Start Offset Field Length
0 Message type: MSG_TYPE_CONN_REQ 1
1 Broadcast receive capable flag
ClientData::bcast
1
2 Random value for client identification
clientRandId
4
6 bytes total.
Note:
This message does not have a message ID. It is not acknowledged in the normal manner. Instead, it is acknowledged by the acceptance message.

Denial

Start Offset Field Length
0 Message type: MSG_TYPE_CONN_DENY 1
1 Random value for client identification
clientRandId
ClientData::randId
4
5 bytes total.
Note:
This message is sent by the server and is not acknowledged.

Acceptance

Start Offset Field Length
0 Message type: MSG_TYPE_CONN_ACCEPT 1
1 Message ID 2
3 Assigned client ID
localPlayer
1
4 Random value for client identification
ClientData::randId
4
8 bytes total.
Note:
This message is sent by the server. The client must acknowledge it through the regular message acknowledgement system.

Disconnect

Start Offset Field Length
0 Message type: MSG_TYPE_CONN_DISCONN 1
1 Message ID 2
3 Client ID 1
4 bytes total.

Game State

Game Configuration

Start Offset Field Length
0 Message type: MSG_TYPE_OPTION 1
1 Message ID 2
3 Bit flags
GameOptions::flags
1
4 The maximum game duration
GameOptions::duration
4
8 Current red team score
GameOptions::teamScore[TEAM_RED]
2
10 Current red team score
GameOptions::teamScore[TEAM_BLUE]
2
12 Score needed to win
GameOptions::winScore
2
14 Battle field width
GameOptions::width
2
16 Battle field height
GameOptions::height
2
18 Total number of messages describing all the game's options
GameOptions::totalMsgs
2
20 bytes total. The index for this option message is always zero.

Obstacles

Start Offset Field Length
0 Message type: MSG_TYPE_OBSTACLE 1
1 Message ID 2
3 Total number of game option messages.
GameOptions::totalMsgs
2
5 The index of this game option message. 2
7 Total number of obstacles. 2
9 Index of the first obstacle in this message.
This value must be evenly divisible by MAX_OBSTACLES_PER_MSG (62).
2
11 + n * 8 X coordinate of upper left corner
Obstacle::loc
2
13 + n * 8 Y coordinate of upper left corner
Obstacle::loc
2
15 + n * 8 Width
Obstacle::loc
2
17 + n * 8 Height
Obstacle::loc
2
19 bytes minimum, 509 (?) bytes maximum. Multiple messages of this type may be required to describe all the obstacles.

n is the index of the obstacle in the message starting at zero and increasing to one less than the total number of obstacles in the messgae.

Spawn Areas

Start Offset Field Length
0 Message type: MSG_TYPE_SPAWN 1
1 Message ID 2
3 Total number of game option messages.
GameOptions::totalMsgs
2
5 The index of this game option message. 2
7 Total number of spawn areas for the red team (TEAM_RED) 1
8 Total number of spawn areas for the blue team (TEAM_BLUE) 1
9 Index of the next spawn area in this message. The index is specific to the owning team.
Note:
This field is part of the header for a set of spawn areas.
1
10 A field containing:
  • Owning team ID of the following set of spawn areas (upper two bits)
  • Number of spawn points in the set minus one (lower 6 bits)

Note:
This field is part of the header for a set of spawn areas.
1
11 X coordinate of the upper left corner 2
13 Y coordinate of the upper left corner 2
15 Width 2
17 Height 2
19 bytes minimum, 510 (?) bytes maximum. Multiple messages of this type may be required to describe all the spawn areas. The fields at offesets 11 through 18 are repeated the number of times specified in the field at offset 10. Following that, if the message is longer it will hold more fields of the same kind as at offsets 9 and 10, followed by more spawn areas described by the fields types in offsets 11 through 18.

Goal Areas

Goal areas, used in capture-the-flag games, are transmitted in the same format as Spawn Areas, except that the message type code is MSG_TYPE_GOAL.

Game Start

Start Offset Field Length
0 Message type: MSG_TYPE_GAME_START 1
1 Message ID 2
3 Common game time when the game will begin 4
7 bytes total. If a start message with a newer ID and later start time (each condition implies the other) is recieved, then the later start time is correct.

Game Over

Start Offset Field Length
0 Message type: MSG_TYPE_GAME_OVER 1
1 Message ID 2
3 Winning team ID, or -1 for a draw 1
4 Score of the red team 2
6 Score of the blue team 2
8 bytes total.

Score Update

Start Offset Field Length
0 Message type: MSG_TYPE_SCORE 1
1 Message ID 2
3 Number of player score updates 1
4 Score of the red team 2
6 Score of the blue team 2
8 + 4 * n ID of player scoring a kill 1
9 + 4 * n ID of player killed 1
10 + 4 * n New score for the player who got a kill 2
Additional player scores
At least 8 bytes with an additional 4 bytes per player score updated.

This message should be sent with a low priority by using a longer resend time.

Player State

Player Update

Start Offset Field Length
0 Message type: MSG_TYPE_PLAYER_UPDATE 1
1 Message ID 2
3 Update time
Player::lastUpdate for all players in the message
4
7 First player ID 1
8 Player flags
Valid values defined in PLAYER_FLAGS
  1. Player identity (PLAYER_FLAGS::PLAYER_UPDATE_IDENT)
  2. Tank position and rotation (PLAYER_FLAGS::PLAYER_UPDATE_TANK)
  3. Shell position and rotation (PLAYER_FLAGS::PLAYER_UPDATE_SHELL)
  4. Player dead time, flags, and score (PLAYER_FLAGS::PLAYER_UPDATE_DFS)
    This flag is only valid when sent from the server.
2
10 Update data. The ordering is the same as the flags. See the player data portions for more detail. Varies

Player Spawn Request

This message is only sent by clients when a player wants to spawn.

Start Offset Field Length
0 Message type: MSG_TYPE_PLAYER_SPAWN 1
1 Message ID 2
3 Player ID 1
4 bytes total.

Time Synchronization Datagrams

These datagrams are not handled by the messaging system.

Client to Server

Start Offset Field Length
0 Client's ID 1
1 Client's time 4
5 bytes total.

Server to Client

Start Offset Field Length
0 Client's ID 1
1 Client's time 5
5 Server's time 4
9 bytes total.
Generated on Mon May 28 04:41:40 2007 for Retro Tank Super Attack by  doxygen 1.5.2