Network Protocol/RACEHEADER_2

From Custom Mario Kart
Jump to navigation Jump to search

This article describes the record type RACEHEADER_2 of the Network Protocol. This record is not sent during live view, and its contents depend on the game mode.

Race Packet Sections
Name Amount Size Description
SLOT 0-1 0x08 Only used for redirected data via a proxy. The record identifies the original client by its slot number.
HEADER 1 0x10 A header for a race packet.
RACEHEADER_1 1 0x28 A record with basic race data.
RACEHEADER_2 0-1 0x28 A record with game-mode specific race data (not present in live view).
ROOM 0-1 0x04 A record containing a friend room message (not present outside friend room lobbies).
SELECT 0-1 0x38 A record containing data to set up a match (not present during races).
RACEDATA 1-2 0x40 A record containing race data for each player, such as positions or inputs.
USER 0-1 0xC0 A record containing user data such as Miis and friend codes.
ITEM 1-2 0x08 A record containing information about players' items.
EVENT 1 ≥ 0x18 A record transmitting item events.


VS Race Structure

Offset Size Description
0x00 13 bits Players who have finished the race (1 bit per player + 1).
0x01.5 13 bits Players who are participating in the race (1 bit per player + 1).
0x03.2 13 bits Players who have disconnected (1 bit per player + 1).
0x04.7 2 bits Local player count.
0x05.1 4 bits Client slot for Player 1.
0x05.5 22 bits Finishing time for Player 1 (6 bits for minutes, 6 for seconds and 10 for milliseconds).
0x08.3 13 bits Players who are ahead of Player 1 (1 bit per player + 1).
0x0A 4 bits Client slot for Player 2.
0x0A.4 22 bits Finishing time for Player 2 (6 bits for minutes, 6 for seconds and 10 for milliseconds).
0x0D.2 13 bits Players who are ahead of Player 2 (1 bit per player + 1).
0x0F 1 byte Padding.
0x10 2 bytes Unused. Local client slots.
0x12 1 byte Unused. Incomplete client slots bitfield.
0x13 1 byte Unused. Local player count.
0x14 4 bytes Time since the race leader finished (in frames).
0x18 4 bytes Minimum time before the race can time out (in frames). The value for each Nintendo track can be found at 0x808903A4 PAL.
0x1C 1 byte Marks the player as disconnected if set to 1.
0x1D 1 byte Padding.
0x1E 4 bytes Time (in frames) since each local player last moved faster than 30km/h. Caps at 300 (5 seconds).
0x22 4 bytes Time (in frames) since each countdown value maxed out. Caps at 3600 (1 minute), after which the player is disconnected if in a public room.
0x26 2 bytes Padding.

Balloon Battle Structure

Unlike the VS race structure, this packet has variable content that depends on the local (L) and total (N) player count.

Size Description
1 byte Player slot for each local player (4 bits each). Value is 0xC if a guest is not present.
14 bits Battle score for each local player (7 bits each) Value is 0 if a guest is not present.
N * 5 bits Unknown. A 2-bit value followed by a 3-bit value for each player.
4 bits Players who have disconnected (1 bit per player). The game keeps track of all players but cuts the bitfield off when sending it.
L * 10 bits Balloon colors for each local player (2 bits each):
  • 0: No balloon
  • 1: Red balloon
  • 2: Blue balloon
7 bits Battle event count (1 bit per event).
C * 27 bits C battle events. See below for the event structure.

Battle Event Structure

Offset Size Description
0x00 4 bits Event type:
  • 0: None (no event)
  • 1: Player stole a balloon from another
  • 2: Player fell off the course
  • 3: Player hit another with an item
  • 4: Player lost all their balloons
  • 5: Player hit an obstacle
  • 6: Unknown, but not unused
  • 7: Player disconnected
  • 8: Player's battle timer ran out
0x00.4 15 bits Unknown. Seems to be some sort of time value.
0x02.3 4 bits First player value, with different usage based on event type:
  • Events 1-7: Player who performed the action
  • Event 8: Value set to 0xC and ignored by the parsing code
0x02.7 4 bits Second player value, with different usage based on event type:
  • Events 1 and 3: Player that was hit/stolen from
  • Event 7: Guest of the player who disconnected (or 0xC)
  • Other event types: Value set to 0xC and ignored by the parsing code

Coin Runners Structure

The packet structure for this game mode is unknown.