coastline 0.0.4
Loading...
Searching...
No Matches
netstream.h File Reference

The streams of the packets of network play: bytes and bits, the most significant first. More...

Include dependency graph for netstream.h:

Go to the source code of this file.

Classes

class  NetStream
 A stream of the bytes and bits of a packet, read and written from the most significant bit. More...
struct  NetPlayerProgress
 A player of network play and the progress that ranks it. More...

Macros

#define NET_STREAM_BUFFER_SIZE   0x200
 The size of the buffer of a NetStream.
#define NET_PLAYER_STREAM_COUNT   16
 The number of entries of g_aNetPlayerStreams.
#define NET_PACKET_MAX_SIZE   256
 The largest size of a packet of a NetStream, in bytes.

Functions

int CompareNetworkPlayerProgressDescending (const void *pA, const void *pB)
 Order two NetPlayerProgress entries for qsort() by their progress, the greatest first.
bool WriteTimeSyncPacket (NetStream *pStream, unsigned char bPlayer, unsigned nTime, unsigned nValue)
 Write a packet of the time of a player: the player with the tag 0xc0, the time in 24 bits, and a 16-bit value, when the packet fits.
bool WritePlayerRankingPacket (NetStream *pStream, unsigned char bPlayer)
 Write a packet of the positions of the players: the player with the tag 0x20 and the positions of g_adwNetPlayerRankPosition, two to a byte with the first in the low 4 bits, when the packet fits.
bool WritePlayerStatusPacket (NetStream *pStream, unsigned char bPlayer, int nState, int nStatusValue, unsigned char bOptionA, unsigned char bOptionB, unsigned char bOptionC, const char *szPlayerName, unsigned dwOwner)
 Write a player's state, options, and owner, followed by a name or countdown for states that include them.
bool WriteGameSettingsPacket (NetStream *pStream, unsigned char bPlayer)
 Write the maximum player count, track, weather, allowed cars, and tyre and suspension settings.
void DeserializeVehicleState (KeyframeState *pState, NetStream *pStream)
 Decode a full network vehicle keyframe from the bit stream into pState.
unsigned SendLocalVehicleStateUpdate (KeyframeState *state)
 Accumulate vehicle state over three frames and send full or delta snapshots on schedule.
unsigned SendKeyframePacket (KeyframeState *state)
 Send a complete vehicle keyframe as an unreliable network packet.
unsigned SendDeltaKeyframePacket (KeyframeState *state, KeyframeState *base)
 Send a vehicle keyframe compressed against base as an unreliable network packet.
void EncodeKeyframeBitstreamFull (NetStream *stream, KeyframeState *state)
 Encode orientation, position, motion, progress, lights, and effects as a full keyframe.
unsigned GetInterpolatedRemoteVehicleState (KeyframeState *state, int slotIndex)
 Interpolate or predict the vehicle state of a remote player from buffered snapshots.
void EncodeKeyframeBitstreamDelta (NetStream *stream, KeyframeState *state, KeyframeState *base)
 Encode a keyframe against base, shortening position and progress fields.
void DeserializeKeyframeDelta (KeyframeState *pState, const KeyframeState *pBase, NetStream *pStream)
 Reconstruct position and progress relative to pBase from a delta keyframe.

Variables

NetStream g_aNetPlayerStreams [NET_PLAYER_STREAM_COUNT]
 The streams of the players of network play.
NetPlayerProgress g_aNetPlayerProgressSort [NET_PLAYER_STREAM_COUNT]
 The players of network play, sorted by their progress.
int g_adwNetPlayerRankPosition [NET_PLAYER_STREAM_COUNT]
 The position of each network player in the race, from 0 to 15.
KeyframeState g_LastSentKeyframe
 The last complete local vehicle state sent to the other players.
float g_afKeyframeAccumMax [7]
 The largest values accumulated for the seven keyframe fields before the next send.
int g_dwVehicleStateSendCounter
 The number of local vehicle state updates since the network race started.
unsigned g_dwNetRaceStartCountdownTime
 The clock time at which the network race countdown ends, in milliseconds.

Detailed Description

The streams of the packets of network play: bytes and bits, the most significant first.

Macro Definition Documentation

◆ NET_STREAM_BUFFER_SIZE

#define NET_STREAM_BUFFER_SIZE   0x200

The size of the buffer of a NetStream.

◆ NET_PLAYER_STREAM_COUNT

#define NET_PLAYER_STREAM_COUNT   16

The number of entries of g_aNetPlayerStreams.

◆ NET_PACKET_MAX_SIZE

#define NET_PACKET_MAX_SIZE   256

The largest size of a packet of a NetStream, in bytes.

Function Documentation

◆ CompareNetworkPlayerProgressDescending()

int CompareNetworkPlayerProgressDescending ( const void * pA,
const void * pB )

Order two NetPlayerProgress entries for qsort() by their progress, the greatest first.

Parameters
pAThe first entry.
pBThe second entry.
Returns
1 when the first entry has less progress than the second, and 0 otherwise.
Ghidra address:
BRD3D: 0x10071b60
Ghidra address:
BRGlide: 0x1006aad0

◆ WriteTimeSyncPacket()

bool WriteTimeSyncPacket ( NetStream * pStream,
unsigned char bPlayer,
unsigned nTime,
unsigned nValue )

Write a packet of the time of a player: the player with the tag 0xc0, the time in 24 bits, and a 16-bit value, when the packet fits.

Parameters
pStreamThe stream.
bPlayerThe player, in the low 6 bits.
nTimeThe time, in its low 24 bits.
nValueThe 16-bit value after the time.
Returns
Whether the packet fit and was written.
Ghidra address:
BRD3D: 0x10072030
Ghidra address:
BRGlide: 0x1006afa0

◆ WritePlayerRankingPacket()

bool WritePlayerRankingPacket ( NetStream * pStream,
unsigned char bPlayer )

Write a packet of the positions of the players: the player with the tag 0x20 and the positions of g_adwNetPlayerRankPosition, two to a byte with the first in the low 4 bits, when the packet fits.

Parameters
pStreamThe stream.
bPlayerThe player, in the low 5 bits.
Returns
Whether the packet fit and was written.
Ghidra address:
BRD3D: 0x10072110
Ghidra address:
BRGlide: 0x1006b080

◆ WritePlayerStatusPacket()

bool WritePlayerStatusPacket ( NetStream * pStream,
unsigned char bPlayer,
int nState,
int nStatusValue,
unsigned char bOptionA,
unsigned char bOptionB,
unsigned char bOptionC,
const char * szPlayerName,
unsigned dwOwner )

Write a player's state, options, and owner, followed by a name or countdown for states that include them.

Returns
Whether the packet fit within the maximum network packet size.
Ghidra address:
BRD3D: 0x10071f40
Ghidra address:
BRGlide: 0x1006aeb0

◆ WriteGameSettingsPacket()

bool WriteGameSettingsPacket ( NetStream * pStream,
unsigned char bPlayer )

Write the maximum player count, track, weather, allowed cars, and tyre and suspension settings.

Returns
Whether the settings packet fit within the maximum network packet size.
Ghidra address:
BRD3D: 0x10072080
Ghidra address:
BRGlide: 0x1006aff0

◆ DeserializeVehicleState()

void DeserializeVehicleState ( KeyframeState * pState,
NetStream * pStream )

Decode a full network vehicle keyframe from the bit stream into pState.

Ghidra address:
BRD3D: 0x10006ec0
Ghidra address:
BRGlide: 0x10007230

◆ SendLocalVehicleStateUpdate()

unsigned SendLocalVehicleStateUpdate ( KeyframeState * state)

Accumulate vehicle state over three frames and send full or delta snapshots on schedule.

Returns
Whether the update was deferred or its network send succeeded.
Ghidra address:
BRD3D: 0x10005130
Ghidra address:
BRGlide: 0x100054a0

◆ SendKeyframePacket()

unsigned SendKeyframePacket ( KeyframeState * state)

Send a complete vehicle keyframe as an unreliable network packet.

Returns
Whether the send succeeded.
Ghidra address:
BRD3D: 0x10004c60
Ghidra address:
BRGlide: 0x10004fd0

◆ SendDeltaKeyframePacket()

unsigned SendDeltaKeyframePacket ( KeyframeState * state,
KeyframeState * base )

Send a vehicle keyframe compressed against base as an unreliable network packet.

Returns
Whether the send succeeded.
Ghidra address:
BRD3D: 0x10004e50
Ghidra address:
BRGlide: 0x100051c0

◆ EncodeKeyframeBitstreamFull()

void EncodeKeyframeBitstreamFull ( NetStream * stream,
KeyframeState * state )

Encode orientation, position, motion, progress, lights, and effects as a full keyframe.

Ghidra address:
BRD3D: 0x100061a0
Ghidra address:
BRGlide: 0x10006510

◆ GetInterpolatedRemoteVehicleState()

unsigned GetInterpolatedRemoteVehicleState ( KeyframeState * state,
int slotIndex )

Interpolate or predict the vehicle state of a remote player from buffered snapshots.

Returns
Zero when a remote slot has fewer than two snapshots; one otherwise.
Ghidra address:
BRD3D: 0x100054a0
Ghidra address:
BRGlide: 0x10005810

◆ EncodeKeyframeBitstreamDelta()

void EncodeKeyframeBitstreamDelta ( NetStream * stream,
KeyframeState * state,
KeyframeState * base )

Encode a keyframe against base, shortening position and progress fields.

Ghidra address:
BRD3D: 0x10006830
Ghidra address:
BRGlide: 0x10006ba0

◆ DeserializeKeyframeDelta()

void DeserializeKeyframeDelta ( KeyframeState * pState,
const KeyframeState * pBase,
NetStream * pStream )

Reconstruct position and progress relative to pBase from a delta keyframe.

Ghidra address:
BRD3D: 0x100073e0
Ghidra address:
BRGlide: 0x10007750

Variable Documentation

◆ g_aNetPlayerStreams

NetStream g_aNetPlayerStreams[NET_PLAYER_STREAM_COUNT]
extern

The streams of the players of network play.

Ghidra address:
BRD3D: 0x11826bd0
Ghidra address:
BRGlide: 0x11849f30

◆ g_aNetPlayerProgressSort

NetPlayerProgress g_aNetPlayerProgressSort[NET_PLAYER_STREAM_COUNT]
extern

The players of network play, sorted by their progress.

Ghidra address:
BRD3D: 0x11826b50
Ghidra address:
BRGlide: 0x11849eb0

◆ g_adwNetPlayerRankPosition

int g_adwNetPlayerRankPosition[NET_PLAYER_STREAM_COUNT]
extern

The position of each network player in the race, from 0 to 15.

Ghidra address:
BRD3D: 0x11826b08
Ghidra address:
BRGlide: 0x11849e68

◆ g_LastSentKeyframe

KeyframeState g_LastSentKeyframe
extern

The last complete local vehicle state sent to the other players.

Ghidra address:
BRD3D: 0x10220cf0
Ghidra address:
BRGlide: 0x1021c820

◆ g_afKeyframeAccumMax

float g_afKeyframeAccumMax[7]
extern

The largest values accumulated for the seven keyframe fields before the next send.

Ghidra address:
BRD3D: 0x10220e60
Ghidra address:
BRGlide: 0x1021c990

◆ g_dwVehicleStateSendCounter

int g_dwVehicleStateSendCounter
extern

The number of local vehicle state updates since the network race started.

Ghidra address:
BRD3D: 0x10094298
Ghidra address:
BRGlide: 0x1007b268

◆ g_dwNetRaceStartCountdownTime

unsigned g_dwNetRaceStartCountdownTime
extern

The clock time at which the network race countdown ends, in milliseconds.

Ghidra address:
BRD3D: 0x11828d14
Ghidra address:
BRGlide: 0x1184c074