Difference between revisions of "Network Protocol/RACEHEADER 1"

From Custom Mario Kart
Jump to navigation Jump to search
(Update documentation)
 
(7 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
{{DISPLAYTITLE:{{BASEPAGENAME}}/RACEHEADER_1}}
 
{{DISPLAYTITLE:{{BASEPAGENAME}}/RACEHEADER_1}}
This pages is related to [[MKWii Network Protocol]] and describes the record type '''RACEHEADER_1'''.
+
== Overview ==
 +
This article describes the record type '''RACEHEADER_1''' of the [[Network Protocol]].
  
Here is the record read function in GNU C notation. The function notation is used, because some values are bit packed. This code was created by a code generator.
+
{{Network Protocol RACE}}
  
<pre>
+
{| class="wikitable"
    d->timer = be16(src+ 0x002 );
+
! Offset
    d->select_id        = be32(src+ 0x004 );
+
! Size
    d->team = be16(src+ 0x00a );
+
! Description
    d->lag_frames      = be16(src+ 0x00c );
+
|-
    d->vehicle[0] =      src[ 0x00e ];
+
| 0x00 || 4 bytes || Frames since race start (starts counting when all players are synced).
    d->driver[0] =      src[ 0x00f ];
+
|-
    d->vehicle[1] =      src[ 0x010 ];
+
| 0x04 || 4 bytes || Shared random seed used for various things.
    d->driver[1] =      src[ 0x011 ];
+
|-
    d->track =      src[ 0x016 ];
+
| 0x08 || 1 bit || '''Battle Type''':
    d->client_slot[0] =      src[ 0x018 ];
+
* 0: Balloon Battle
    d->client_slot[1] =      src[ 0x019 ];
+
* 1: Coin Runners
    d->client_slot[2] =      src[ 0x01a ];
+
|-
    d->client_slot[3] =      src[ 0x01b ];
+
| 0x08.1 || 31 bits || '''Team Bitfield''':
    d->client_slot[4] =      src[ 0x01c ];
+
* 0: Blue Team
    d->client_slot[5] =      src[ 0x01d ];
+
* 1: Red Team
    d->client_slot[6] =      src[ 0x01e ];
+
|-
    d->client_slot[7] =      src[ 0x01f ];
+
| 0x0C || 2 bytes || Amount of frames the player has lagged.
    d->client_slot[8] =      src[ 0x020 ];
+
|-
    d->client_slot[9] =      src[ 0x021 ];
+
| 0x0E || 1 byte || [[List of Identifiers#Vehicles|Vehicle]] for Player 1.
    d->client_slot[10] =      src[ 0x022 ];
+
|-
    d->client_slot[11] =      src[ 0x023 ];
+
| 0x0F || 1 byte || [[List of Identifiers#Characters|Character]] for Player 1.
    d->engine =      src[ 0x024 ];
+
|-
 +
| 0x10 || 1 byte || [[List of Identifiers#Vehicles|Vehicle]] for Player 2.
 +
|-
 +
| 0x11 || 1 byte || [[List of Identifiers#Characters|Character]] for Player 2.
 +
|-
 +
| 0x12 || 2 bytes || Countdown time.
 +
|-
 +
| 0x14 || 2 bytes || Star rank of each player.
 +
|-
 +
| 0x16 || 1 byte || [[List of Identifiers#Courses|Course]] being played.
 +
|-
 +
| 0x17 || 1 byte || '''Player Type''':
 +
* 0: Regular player
 +
* 1: ??
 +
* 2: Spectator
 +
|-
 +
| 0x18 || 12 bytes || Client slot for each player.
 +
|-
 +
| 0x24 || 1 byte || '''Engine Class''':
 +
* 0: 50cc
 +
* 1: 100cc
 +
* 2: 150cc
 +
* 3: Mirror
 +
|-
 +
| 0x25 || 3 bytes || {{Unknown-left|'''Padding'''.}}
 +
|}
  
    return 0x30; // last analyzed offset + 1
+
{{Network Protocol}}
</pre>
+
[[Category:Network Protocol|R]]
 
 
And here the code of a self written code generator script. The script creates data structures and the read function above. The byte offset is hex, all others are decimal numbers.
 
<pre>
 
!------------------------------------------------------------------------------------------
 
!                        byte+bit
 
! type name N offset bits comment
 
!------------------------------------------------------------------------------------------
 
  u16  *timer -  02  0 16 racing time, 59.94 Hz
 
  u32  select_id      -  04  0 32    unique race id transmitted in SELECT
 
  u16  team -  0a  0 16 not null: team bit field, 0=blue, 1=red
 
  u16  lag_frames      -  0c  0 16    amount of frames the player has lagged
 
  u8    vehicle 2  -  -  - vehicle index of each user
 
  > vehicle[0] -  0e  0  8
 
  > vehicle[1] -  10  0  8
 
  u8    driver 2  -  -  - driver index of each user
 
  > driver[0] -  0f  0  8
 
  > driver[1] -  11  0  8
 
  u8 track -  16  0  8 index of current track
 
  u8 client_slot 12  18  0  8 relation race_slot(index) : client slot (0xff=none)
 
  u8 engine -  24  0  8 engine: 0:50cc, 1:100cc, 2:150cc, 3:mirror
 
!------------------------------------------------------------------------------------------
 
</pre>
 
 
 
<br/>
 
{{MKWii Network Protocol}}
 
[[category: Network Protocol|R]]
 

Latest revision as of 20:03, 28 January 2024

Overview

This article describes the record type RACEHEADER_1 of the Network Protocol.

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.


Offset Size Description
0x00 4 bytes Frames since race start (starts counting when all players are synced).
0x04 4 bytes Shared random seed used for various things.
0x08 1 bit Battle Type:
  • 0: Balloon Battle
  • 1: Coin Runners
0x08.1 31 bits Team Bitfield:
  • 0: Blue Team
  • 1: Red Team
0x0C 2 bytes Amount of frames the player has lagged.
0x0E 1 byte Vehicle for Player 1.
0x0F 1 byte Character for Player 1.
0x10 1 byte Vehicle for Player 2.
0x11 1 byte Character for Player 2.
0x12 2 bytes Countdown time.
0x14 2 bytes Star rank of each player.
0x16 1 byte Course being played.
0x17 1 byte Player Type:
  • 0: Regular player
  • 1: ??
  • 2: Spectator
0x18 12 bytes Client slot for each player.
0x24 1 byte Engine Class:
  • 0: 50cc
  • 1: 100cc
  • 2: 150cc
  • 3: Mirror
0x25 3 bytes Padding.