MKWii Network Protocol/SELECT

From Custom Mario Kart
Jump to: navigation, search

This page is related to MKWii Network Protocol and describes the record type SELECT in GNU C notation.

typedef struct udp_select_t
{
 /*00*/  u64	time_sender;      // NULL or time of sender (milliseconds since 2000-01-01, based on real time clock)
 /*08*/  u64	time_receiver;    // NULL or assumed time of the receiver, based on the last received time

 /*10*/  u16	rank_pl1;         // rank of previous race == start position of next race (Player 1)
 /*12*/  u16	sum_pts_pl1;      // accumulated event points (Player 1)
 /*14*/  u8     driver_pl1;       // Driver of Player 1
 /*15*/  u8     vehicle_pl1;      // Vehicle of Player 1
 /*16*/  u8	user_track_pl1;   // 0x00-0x1f:course ID, 0x20-0x29:battle course ID, 0x43:none, 0xff:random
 /*17*/  u8	unknown_17;       // 0..3

 /*18*/  u16	rank_pl2;         // rank of previous race (Player 2. 0x00 if there is only one player)
 /*1a*/  u16	sum_pts_pl2;      // accumulated event points (Player 2. 0x00 if there is only one player)
 /*1c*/  u8     driver_pl2;       // Driver of Player 2 (0x30 when only one player)
 /*1d*/  u8     vehicle_pl2;      // Vehicle of Player 2 (0x24 when only one player)
 /*1e*/  u8	user_track_pl2;   // 0x00-0x1f:course ID, 0x20-0x29:battle course ID, 0x43:none, 0xff:random (one player: 0x43; two players: same as user_track_pl1)
 /*1f*/  u8 	unknown_1f;       // (nearly) always 0?

 /*20*/  u32 	select_id;        // a unique id, changed for every race/battle to a random value.
 /*24*/  u8	battle_type;      // Value indicating if COIN or BOSS-Battle (in SEL1) (0x00: UNKNOWN or COIN, 0x80: BOSS)
 /*25*/  u24	team;             // 2 bits for each client slot. Bit is set for red team.

 /*28*/  u8	client_slot[12];  // relation race_slot(index) : client slot (0xff=none)
 /*34*/  u8	sel_track;        // game: selected track: 0xff:none
 /*35*/  u8	sel_phase;        // selection phase: 0:prepare, 1:wait, 2:lottery
 /*36*/  u8	sel_client;       // client index: who has selected the track (0xff: none)
 /*37*/  u8	sel_engine;       // 0:none, 1:100cc, 2:150cc 3:mirror (WW and 1st race of GP)
 /*38*/
}
__attribute__ ((packed)) udp_select_t;


During phase 1 (SEL/PREPARE), the Wiis synchronize their clocks using "time_sender" and "time_receiver" so the race starts at the same time on all Wiis.