Network Protocol/RACEHEADER_1

From Custom Mario Kart
< Network Protocol
Revision as of 09:41, 20 June 2020 by Seeky (talk | contribs) (Added a value Star found)
Jump to navigation Jump to search

This pages is related to MKWii Network Protocol and describes the record type RACEHEADER_1.

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.

    d->timer		= be16(src+ 0x002 );
    d->select_id        = be32(src+ 0x004 );
    d->team		= be16(src+ 0x00a );
    d->lag_frames       = be16(src+ 0x00c );
    d->vehicle[0]	=      src[ 0x00e ];
    d->driver[0]	=      src[ 0x00f ];
    d->vehicle[1]	=      src[ 0x010 ];
    d->driver[1]	=      src[ 0x011 ];
    d->countdown_time   = be16(src+ 0x012 );
    d->track		=      src[ 0x016 ];
    d->client_slot[0]	=      src[ 0x018 ];
    d->client_slot[1]	=      src[ 0x019 ];
    d->client_slot[2]	=      src[ 0x01a ];
    d->client_slot[3] 	=      src[ 0x01b ];
    d->client_slot[4]	=      src[ 0x01c ];
    d->client_slot[5]	=      src[ 0x01d ];
    d->client_slot[6]	=      src[ 0x01e ];
    d->client_slot[7]	=      src[ 0x01f ];
    d->client_slot[8]	=      src[ 0x020 ];
    d->client_slot[9]	=      src[ 0x021 ];
    d->client_slot[10]	=      src[ 0x022 ];
    d->client_slot[11]	=      src[ 0x023 ];
    d->engine		=      src[ 0x024 ];

    return 0x30; // last analyzed offset + 1

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.

 !------------------------------------------------------------------------------------------
 !                        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
   s16   countdown_time  -  12  0 16
   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
 !------------------------------------------------------------------------------------------


Template:MKWii Network Protocol