-
Notifications
You must be signed in to change notification settings - Fork 32
Network Packets
Detailed information on members of each packet can be found in networking.h
Basic principles:
- main game data is marked as reliable
- important game state data needs to be reliable
- anything to do with pickups, joining the game, changing levels, stats etc.
- primary/secondary/position updates are on their own channel and set to sequenced | unreliable
- this creates a sub stream that will drop late pkts
+-------------------------------------------------------------------------+
| NAME | BYTES | GUARANTEED | UNICAST | CHANNEL |
+--------------------------------------------------------------+----------+
| BIKENUMMSG | 3 | X | | MAIN | -
| BGOUPDATEMSG | 12 | X | | MAIN | -
| NETSETTINGS | 20 | X | | MAIN | -
| DROPPICKUPMSG | 56 | X | | MAIN | -
| FUPDATEMSG | 68 | | | BIKES | -
| GROUPONLY_VERYSHORTFUPDATEMSG | 28 | | | BIKES | -
| HEREIAMMSG | 3 | X | | MAIN | -8
| INITMSG | 408 | X | X | MAIN | -72
| KILLPICKUPMSG | 8 | X | | MAIN | -
| LONGSTATUSMSG | 64 | X | | MAIN | -
| PRIMBULLPOSDIRMSG | 72 | | | MAIN | -
| REQTIMEMSG | 2 | X | | MAIN | -
| SECBULLPOSDIRMSG | 76 | X | | MAIN | -
| SHIPHITMSG | 56 | X | X | MAIN | -
| SHORTSHIPHITMSG | 36 | X | X | MAIN | -
| SHOCKWAVEMSG | 28 | | | MAIN | -
| SHIPDIEDMSG | 20 | X | | MAIN | -
| STATUSMSG | 24 | X | | MAIN | -
| SETTIMEMSG | 8 | X | | MAIN | -
| SHORTPICKUPMSG | 264 | X | X | MAIN | -
| SHORTREGENSLOTMSG | 244 | X | X | MAIN | -
| SHORTTRIGGERMSG | 244 | X | X | MAIN | -
| SHORTTRIGVARMSG | 244 | X | X | MAIN | -
| SHORTMINEMSG | 232 | X | X | MAIN | -
| TITANBITSMSG | 184 | X | | MAIN | -
| TEAMGOALSMSG | 10 | X | | MAIN | -
| TEXTMSG | 515 | | | MAIN | -
| UPDATEMSG | 72 | | | BIKES | -
| VERYSHORTUPDATEMSG | 40 | | | BIKES | -
| VERYSHORTFUPDATEMSG | 44 | | | BIKES | -
| VERYSHORTDROPPICKUPMSG | 36 | X | | MAIN | -
| YOUQUITMSG | 3 | X | | MAIN | -
+-------------------------------------------------------------------------+
+------------------------------------------------------+
| TEXT MSG NAME | GUARANTEED | UNICAST |
+------------------------------------------------------+
| TEXTMSGTYPE_SpeechTaunt | | X |
| TEXTMSGTYPE_ScoredWithFlag | X | |
+------------------------------------------------------+
Bullet packets also serve as position updates since ships can only ever shoot directly forward.
Note: Above these packets are marked un-reliable + sequenced since anything else would allow for very insane behavior with laggy or out of order packets (imagine seconds of bullets all appearing at same time or player jumping back and forth in time). Because of this there can be dropped bullets meaning they may never see them at all...
Structure of an update packet contains the following information:
typedef struct _VERYSHORTGLOBALSHIP
{
uint32 Flags; // Flags Enable/Stealth/Turbo/PrimFire/SecFire/PrimToggle/SecToggle
BYTE Status; // tells us constantly what this ship is doing...
BYTE GroupImIn; // Group Im In
SHORTVECTOR Pos; // x , y , z position
SHORTVECTOR Move_Off; // Last MoveMent...x , y , z
SHORTVECTOR Angle; // Last Rotation..
SHORTQUAT Quat; // Final Quat...
int16 Bank;
uint16 Move_Off_Scalar;
} VERYSHORTGLOBALSHIP, *LPVERYSHORTGLOBALSHIP;
uint32 BuildShipFlags( BYTE Player )
{
uint32 Flags;
Flags = Ships[Player].Object.Flags; // Flags
Flags &= ~( SHIP_IsHost + SHIP_Enable + SHIP_Invul +
SHIP_PowerLevelBit1+SHIP_PowerLevelBit2 +
SHIP_ModeBit1 + SHIP_ModeBit2 +
SHIP_Shield + SHIP_HullBit1+SHIP_HullBit2 +
SHIP_NumMultiplesBit1 + SHIP_NumMultiplesBit2 +
SHIP_NumMultiplesBit3 + SHIP_NumMultiplesBit4 );
if( IsHost ) Flags |= SHIP_IsHost;
if( Ships[ Player ].enable ) Flags |= SHIP_Enable;
if( Ships[Player].InvulTimer ) Flags |= SHIP_Invul;
Flags |= (Ships[Player].Object.PowerLevel&3) << SHIP_PowerLevel_Bit1;
Flags |= (Ships[Player].Object.Mode&3) << SHIP_Mode_Bit1;
if( Ships[Player].Object.Shield > 0.0F )
{
Flags |= SHIP_Shield;
}
if( Ships[Player].Object.Hull > 64.0F )
{
Flags |= SHIP_HullBit1+SHIP_HullBit2;
}else{
Flags |= ( (uint32) ( Ships[Player].Object.Hull * (1.0F/16.0F) ) ) << SHIP_Hull_Bit1;
}
Flags |= (Ships[ Player ].NumMultiples&15) << SHIP_NumMultiples_Bit1;
if( Ships[Player].headlights ) Flags |= SHIP_Light;
return Flags;
}
MSG_UPDATE
- SendANormalUpdate() (bike co-ords SHORTGLOBALSHIP) (short packets off)
MSG_FUPDATE
- DplayGameUpdate() (firing a weapon FSHORTGLOBALSHIP) (short packets off)
MSG_TITANBITS
- shooter of titan sends the details of the shrapnel to EVERYBODY (in either collision perspective)
MSG_KILLPICKUP
- sends to EVERYBODY when you picked up a pickup to remove it from level
MSG_SECBULLPOSDIR
- sends to EVERYBODY, telling them you have laid mines
MSG_SHOCKWAVE
- sends a shockwave to player's NEARBY when you die
MSG_SHIPDIED
- sends to EVERYBODY, telling them that someone killed me and with what weapon
- received by everybody and used to kill off the player and update score
MSG_STATUS
- sends your current status (e.g. STATUS_NORMAL) to EVERYBODY
- allows host to update packet rate dynamically
MSG_TEXTMSG
- sends/receives to EVERYBODY all text messages (including flag messages, player messages etc.)
- also used for biker sound taunts and version query (only sends to PLAYERS IN RANGE)
MSG_PINGREQUEST
- sends to EVERYBODY requesting guaranteed ping if shift+f7 is pressed
- sends to EVERYBODY requesting non-guaranteed ping if shift+f6 is pressed
MSG_PINGREPLY
- recepient of a MSG_PINGREQUEST sends ping reply to EVERYBODY
MSG_ACKMSG
- recepient of a MSG_GUARANTEEDMSG replies to the SENDER with an acknowledgement
MSG_SETTIME
- host sends responds to MSG_REQTIME by sending current time to EVERYBODY
MSG_REQTIME
- sends to EVERYBODY, requesting the time when joining a timed game
MSG_SERVERSCORED
- sends to EVERYBODY telling them i scored with the flag
MSG_BGOUPDATE
- sends a back ground object (e.g. door) update to EVERYBODY
MSG_TRACKERINFO
- host responds to MSG_HEREIAM with the address/port number of every player
- if host quits all addresses/port numbers (i.e. heartbeat) are sent to another player
MSG_INIT
- host sends game settings to SENDER OF MSG_HEREIAM
- receiving sets the game settings (e.g. lag tol and packet rate)
MSG_HEREIAM
- sends (to EVERYBODY) who player is if joining and if they are rejoining
- received by host and sends back with MSG_STATUS and MSG_INIT
MSG_SHORTPICKUP
- host sends this to EVERYBODY to initiate pickups
MSG_VERYSHORTDROPPICKUP
- sends who i am and what pickup i dropped to EVERYBODY (short packets on)
MSG_SHORTREGENSLOT
- host sends this to EVERYBODY to initiate regenslots
MSG_SHORTTRIGGER
- host sends this to EVERYBODY to initiate triggers
MSG_SHORTTRIGVAR
- host sends this to EVERYBODY to initiate trigvars
MSG_SHORTMINE
- host sends this to EVERYBODY to initiate mines
MSG_NAME
- sends player's current name to EVERYBODY
MSG_TEAMGOALS
- sends location of goals in team game to EVERYBODY as new goals are created
MSG_LONGSTATUS
- host sends MSG_STATUS and what level is being played to EVERYBODY
MSG_VERYSHORTFUPDATE
- DplayGameUpdate() (firing a weapon FVERYSHORTGLOBALSHIP) (big packets off, short packets on)
MSG_GROUPONLY_VERYSHORTFUPDATE
- DplayGameUpdate() (firing a weapon GROUPONLY_FVERYSHORTGLOBALSHIP) (big packets on, short packets on)
MSG_VERYSHORTUPDATE
- SendANormalUpdate() (bike co-ords VERYSHORTGLOBALSHIP) (short packets on)
MSG_SHIPHIT
- shooter sends to TARGET, claiming hit with weapon and position (only sent if TARGET decides collisions) (short packets off)
MSG_SHORTSHIPHIT
- shooter sends to TARGET, claiming hit with weapon and position (only sent if TARGET decides collisions) (short packets on)
MSG_BIKENUM
- sends your current bike number to EVERYBODY when you change bike
MSG_YOUQUIT
- host sends to EVERYBODY when kicking someone out of a game
- host sends to EVERYBODY when changing level to kick out player's in a weird status
MSG_PRIMBULLPOSDIR
- never gets sent to anybody as is
MSG_INTERPOLATE
- used for cleaning a demo recorded with short packets off
MSG_VERYSHORTINTERPOLATE
- used for cleaning a demo recorded with short packets on
MSG_BIGPACKET
- used in other messages to flag that the message is a big packet
MSG_GUARANTEEDMSG
- used in other messages to flag this is a guaranteed message and require and MSG_ACK