-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e0e823a
commit 3c72d1e
Showing
3 changed files
with
333 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
# Session Packet | ||
|
||
>The session packet includes details about the current session in progress. | ||
>>Frequency: 2 per second | ||
>>>Size: 632 bytes | ||
>>>>Version: 1 | ||
```cpp | ||
struct MarshalZone | ||
{ | ||
float m_zoneStart; // Fraction (0..1) of way through the lap the marshal zone starts | ||
int8 m_zoneFlag; // -1 = invalid/unknown, 0 = none, 1 = green, 2 = blue, 3 = yellow, 4 = red | ||
}; | ||
|
||
struct WeatherForecastSample{ | ||
uint8 m_sessionType; // 0 = unknown, 1 = P1, 2 = P2, 3 = P3, 4 = Short P, 5 = Q1 | ||
// 6 = Q2, 7 = Q3, 8 = Short Q, 9 = OSQ, 10 = R, 11 = R2 | ||
// 12 = R3, 13 = Time Trial | ||
uint8 m_timeOffset; // Time in minutes the forecast is for | ||
uint8 m_weather; // Weather - 0 = clear, 1 = light cloud, 2 = overcast | ||
// 3 = light rain, 4 = heavy rain, 5 = storm | ||
int8 m_trackTemperature; // Track temp. in degrees Celsius | ||
int8 m_trackTemperatureChange; // Track temp. change – 0 = up, 1 = down, 2 = no change | ||
int8 m_airTemperature; // Air temp. in degrees celsius | ||
int8 m_airTemperatureChange; // Air temp. change – 0 = up, 1 = down, 2 = no change | ||
uint8 m_rainPercentage; // Rain percentage (0-100) | ||
}; | ||
|
||
struct PacketSessionData | ||
{ | ||
PacketHeader m_header; // Header | ||
|
||
uint8 m_weather; // Weather - 0 = clear, 1 = light cloud, 2 = overcast | ||
// 3 = light rain, 4 = heavy rain, 5 = storm | ||
int8 m_trackTemperature; // Track temp. in degrees celsius | ||
int8 m_airTemperature; // Air temp. in degrees celsius | ||
uint8 m_totalLaps; // Total number of laps in this race | ||
uint16 m_trackLength; // Track length in metres | ||
uint8 m_sessionType; // 0 = unknown, 1 = P1, 2 = P2, 3 = P3, 4 = Short P | ||
// 5 = Q1, 6 = Q2, 7 = Q3, 8 = Short Q, 9 = OSQ | ||
// 10 = R, 11 = R2, 12 = R3, 13 = Time Trial | ||
int8 m_trackId; // -1 for unknown, see appendix | ||
uint8 m_formula; // Formula, 0 = F1 Modern, 1 = F1 Classic, 2 = F2, | ||
// 3 = F1 Generic, 4 = Beta, 5 = Supercars | ||
// 6 = Esports, 7 = F2 2021 | ||
uint16 m_sessionTimeLeft; // Time left in session in seconds | ||
uint16 m_sessionDuration; // Session duration in seconds | ||
uint8 m_pitSpeedLimit; // Pit speed limit in kilometres per hour | ||
uint8 m_gamePaused; // Whether the game is paused – network game only | ||
uint8 m_isSpectating; // Whether the player is spectating | ||
uint8 m_spectatorCarIndex; // Index of the car being spectated | ||
uint8 m_sliProNativeSupport; // SLI Pro support, 0 = inactive, 1 = active | ||
uint8 m_numMarshalZones; // Number of marshal zones to follow | ||
MarshalZone m_marshalZones[21]; // List of marshal zones – max 21 | ||
uint8 m_safetyCarStatus; // 0 = no safety car, 1 = full | ||
// 2 = virtual, 3 = formation lap | ||
uint8 m_networkGame; // 0 = offline, 1 = online | ||
uint8 m_numWeatherForecastSamples; // Number of weather samples to follow | ||
WeatherForecastSample m_weatherForecastSamples[56]; // Array of weather forecast samples | ||
uint8 m_forecastAccuracy; // 0 = Perfect, 1 = Approximate | ||
uint8 m_aiDifficulty; // AI Difficulty rating – 0-110 | ||
uint32 m_seasonLinkIdentifier; // Identifier for season - persists across saves | ||
uint32 m_weekendLinkIdentifier; // Identifier for weekend - persists across saves | ||
uint32 m_sessionLinkIdentifier; // Identifier for session - persists across saves | ||
uint8 m_pitStopWindowIdealLap; // Ideal lap to pit on for current strategy (player) | ||
uint8 m_pitStopWindowLatestLap; // Latest lap to pit on for current strategy (player) | ||
uint8 m_pitStopRejoinPosition; // Predicted position to rejoin at (player) | ||
uint8 m_steeringAssist; // 0 = off, 1 = on | ||
uint8 m_brakingAssist; // 0 = off, 1 = low, 2 = medium, 3 = high | ||
uint8 m_gearboxAssist; // 1 = manual, 2 = manual & suggested gear, 3 = auto | ||
uint8 m_pitAssist; // 0 = off, 1 = on | ||
uint8 m_pitReleaseAssist; // 0 = off, 1 = on | ||
uint8 m_ERSAssist; // 0 = off, 1 = on | ||
uint8 m_DRSAssist; // 0 = off, 1 = on | ||
uint8 m_dynamicRacingLine; // 0 = off, 1 = corners only, 2 = full | ||
uint8 m_dynamicRacingLineType; // 0 = 2D, 1 = 3D | ||
uint8 m_gameMode; // Game mode id - see appendix | ||
uint8 m_ruleSet; // Ruleset - see appendix | ||
uint32 m_timeOfDay; // Local time of day - minutes since midnight | ||
uint8 m_sessionLength; // 0 = None, 2 = Very Short, 3 = Short, 4 = Medium | ||
// 5 = Medium Long, 6 = Long, 7 = Full | ||
}; | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,189 @@ | ||
import {F1Parser} from '../../F1parser'; | ||
import {PacketHeaderParser} from '../../PacketHeader/PacketHeader.parser'; | ||
import {PacketSessionData} from '../types'; | ||
|
||
class MarshalZoneParser extends F1Parser { | ||
constructor() { | ||
super(); | ||
this.endianess('little').floatle('m_zoneStart').int8('m_zoneFlag'); | ||
} | ||
} | ||
|
||
/*struct WeatherForecastSample{ | ||
uint8 m_sessionType; // 0 = unknown, 1 = P1, 2 = P2, 3 = P3, 4 = Short P, 5 = Q1 | ||
uint8 m_timeOffset; // Time in minutes the forecast is for | ||
uint8 m_weather; // Weather - 0 = clear, 1 = light cloud, 2 = overcast | ||
int8 m_trackTemperature; // Track temp. in degrees Celsius | ||
int8 m_trackTemperatureChange; // Track temp. change – 0 = up, 1 = down, 2 = no change | ||
int8 m_airTemperature; // Air temp. in degrees celsius | ||
int8 m_airTemperatureChange; // Air temp. change – 0 = up, 1 = down, 2 = no change | ||
uint8 m_rainPercentage; // Rain percentage (0-100) | ||
};*/ | ||
class WeatherForecastSampleParser extends F1Parser { | ||
constructor() { | ||
super(); | ||
this.endianess('little') | ||
//uint8 | ||
.uint8('m_sessionType') | ||
//uint8 | ||
.uint8('m_timeOffset') | ||
//uint8 | ||
.uint8('m_weather') | ||
//int8 | ||
.int8('m_trackTemperature') | ||
//int8 | ||
.int8('m_trackTemperatureChange') | ||
//int8 | ||
.int8('m_airTemperature') | ||
//int8 | ||
.int8('m_airTemperatureChange') | ||
//uint8 | ||
.uint8('m_rainPercentage'); | ||
} | ||
} | ||
|
||
/** | ||
* struct PacketSessionData | ||
{ | ||
PacketHeader m_header; // Header | ||
uint8 m_weather; // Weather - 0 = clear, 1 = light cloud, 2 = overcast | ||
int8 m_trackTemperature; // Track temp. in degrees celsius | ||
int8 m_airTemperature; // Air temp. in degrees celsius | ||
uint8 m_totalLaps; // Total number of laps in this race | ||
uint16le m_trackLength; // Track length in metres | ||
uint8 m_sessionType; // 0 = unknown, 1 = P1, 2 = P2, 3 = P3, 4 = Short P | ||
int8 m_trackId; // -1 for unknown, see appendix | ||
uint8 m_formula; // Formula, 0 = F1 Modern, 1 = F1 Classic, 2 = F2, | ||
uint16le m_sessionTimeLeft; // Time left in session in seconds | ||
uint16le m_sessionDuration; // Session duration in seconds | ||
uint8 m_pitSpeedLimit; // Pit speed limit in kilometres per hour | ||
uint8 m_gamePaused; // Whether the game is paused – network game only | ||
uint8 m_isSpectating; // Whether the player is spectating | ||
uint8 m_spectatorCarIndex; // Index of the car being spectated | ||
uint8 m_sliProNativeSupport; // SLI Pro support, 0 = inactive, 1 = active | ||
uint8 m_numMarshalZones; // Number of marshal zones to follow | ||
MarshalZone m_marshalZones[21]; // List of marshal zones – max 21 | ||
uint8 m_safetyCarStatus; // 0 = no safety car, 1 = full | ||
uint8 m_networkGame; // 0 = offline, 1 = online | ||
uint8 m_numWeatherForecastSamples; // Number of weather samples to follow | ||
WeatherForecastSample m_weatherForecastSamples[56]; // Array of weather forecast samples | ||
uint8 m_forecastAccuracy; // 0 = Perfect, 1 = Approximate | ||
uint8 m_aiDifficulty; // AI Difficulty rating – 0-110 | ||
uint32le m_seasonLinkIdentifier; // Identifier for season - persists across saves | ||
uint32le m_weekendLinkIdentifier; // Identifier for weekend - persists across saves | ||
uint32le m_sessionLinkIdentifier; // Identifier for session - persists across saves | ||
uint8 m_pitStopWindowIdealLap; // Ideal lap to pit on for current strategy (player) | ||
uint8 m_pitStopWindowLatestLap; // Latest lap to pit on for current strategy (player) | ||
uint8 m_pitStopRejoinPosition; // Predicted position to rejoin at (player) | ||
uint8 m_steeringAssist; // 0 = off, 1 = on | ||
uint8 m_brakingAssist; // 0 = off, 1 = low, 2 = medium, 3 = high | ||
uint8 m_gearboxAssist; // 1 = manual, 2 = manual & suggested gear, 3 = auto | ||
uint8 m_pitAssist; // 0 = off, 1 = on | ||
uint8 m_pitReleaseAssist; // 0 = off, 1 = on | ||
uint8 m_ERSAssist; // 0 = off, 1 = on | ||
uint8 m_DRSAssist; // 0 = off, 1 = on | ||
uint8 m_dynamicRacingLine; // 0 = off, 1 = corners only, 2 = full | ||
uint8 m_dynamicRacingLineType; // 0 = 2D, 1 = 3D | ||
uint8 m_gameMode; // Game mode id - see appendix | ||
uint8 m_ruleSet; // Ruleset - see appendix | ||
uint32le m_timeOfDay; // Local time of day - minutes since midnight | ||
uint8 m_sessionLength; // 0 = None, 2 = Very Short, 3 = Short, 4 = Medium | ||
// 5 = Medium Long, 6 = Long, 7 = Full | ||
}; | ||
*/ | ||
|
||
export class PacketSessionDataParser extends F1Parser { | ||
data: PacketSessionData; | ||
constructor(buffer: Buffer) { | ||
super(); | ||
this.endianess('little') | ||
//PacketHeader | ||
.nest('m_header', {type: new PacketHeaderParser()}) | ||
//uint8 | ||
.uint8('m_weather') | ||
//int8 | ||
.int8('m_trackTemperature') | ||
//int8 | ||
.int8('m_airTemperature') | ||
//uint8 | ||
.uint8('m_totalLaps') | ||
//uint16le | ||
.uint16le('m_trackLength') | ||
//uint8 | ||
.uint8('m_sessionType') | ||
//int8 | ||
.int8('m_trackId') | ||
//uint8 | ||
.uint8('m_formula') | ||
//uint16le | ||
.uint16le('m_sessionTimeLeft') | ||
//uint16le | ||
.uint16le('m_sessionDuration') | ||
//uint8 | ||
.uint8('m_pitSpeedLimit') | ||
//uint8 | ||
.uint8('m_gamePaused') | ||
//uint8 | ||
.uint8('m_isSpectating') | ||
//uint8 | ||
.uint8('m_spectatorCarIndex') | ||
//uint8 | ||
.uint8('m_sliProNativeSupport') | ||
//uint8 | ||
.uint8('m_numMarshalZones') | ||
//MarshalZone | ||
.array('m_marshalZones', {type: new MarshalZoneParser(), length: 21}) | ||
//uint8 | ||
.uint8('m_safetyCarStatus') | ||
//uint8 | ||
.uint8('m_networkGame') | ||
//uint8 | ||
.uint8('m_numWeatherForecastSamples') | ||
//WeatherForecastSample | ||
.array('m_weatherForecastSamples', {type: new WeatherForecastSampleParser(), length: 56}) | ||
//uint8 | ||
.uint8('m_forecastAccuracy') | ||
//uint8 | ||
.uint8('m_aiDifficulty') | ||
//uint32le | ||
.uint32le('m_seasonLinkIdentifier') | ||
//uint32le | ||
.uint32le('m_weekendLinkIdentifier') | ||
//uint32le | ||
.uint32le('m_sessionLinkIdentifier') | ||
//uint8 | ||
.uint8('m_pitStopWindowIdealLap') | ||
//uint8 | ||
.uint8('m_pitStopWindowLatestLap') | ||
//uint8 | ||
.uint8('m_pitStopRejoinPosition') | ||
//uint8 | ||
.uint8('m_steeringAssist') | ||
//uint8 | ||
.uint8('m_brakingAssist') | ||
//uint8 | ||
.uint8('m_gearboxAssist') | ||
//uint8 | ||
.uint8('m_pitAssist') | ||
//uint8 | ||
.uint8('m_pitReleaseAssist') | ||
//uint8 | ||
.uint8('m_ERSAssist') | ||
//uint8 | ||
.uint8('m_DRSAssist') | ||
//uint8 | ||
.uint8('m_dynamicRacingLine') | ||
//uint8 | ||
.uint8('m_dynamicRacingLineType') | ||
//uint8 | ||
.uint8('m_gameMode') | ||
//uint8 | ||
.uint8('m_ruleSet') | ||
//uint32le | ||
.uint32le('m_timeOfDay') | ||
//uint8 | ||
.uint8('m_sessionLength'); | ||
|
||
this.data = this.fromBuffer(buffer); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
interface MarshalZone { | ||
m_zoneStart: number; | ||
m_zoneFlag: number; | ||
} | ||
|
||
interface WeatherForecastSample { | ||
m_sessionType: number; | ||
m_timeOffset: number; | ||
m_weather: number; | ||
m_trackTemperature: number; | ||
m_trackTemperatureChange: number; | ||
m_airTemperature: number; | ||
m_airTemperatureChange: number; | ||
m_rainPercentage: number; | ||
} | ||
|
||
export interface PacketSessionData { | ||
m_header: number; | ||
m_weather: number; | ||
m_trackTemperature: number; | ||
m_airTemperature: number; | ||
m_totalLaps: number; | ||
m_trackLength: number; | ||
m_sessionType: number; | ||
m_trackId: number; | ||
m_formula: number; | ||
m_sessionTimeLeft: number; | ||
m_sessionDuration: number; | ||
m_pitSpeedLimit: number; | ||
m_gamePaused: number; | ||
m_isSpectating: number; | ||
m_spectatorCarIndex: number; | ||
m_sliProNativeSupport: number; | ||
m_numMarshalZones: number; | ||
m_marshalZones: MarshalZone[]; | ||
m_safetyCarStatus: number; | ||
m_networkGame: number; | ||
m_numWeatherForecastSamples: number; | ||
m_weatherForecastSamples: WeatherForecastSample[]; | ||
m_forecastAccuracy: number; | ||
m_aiDifficulty: number; | ||
m_seasonLinkIdentifier: number; | ||
m_weekendLinkIdentifier: number; | ||
m_sessionLinkIdentifier: number; | ||
m_pitStopWindowIdealLap: number; | ||
m_pitStopWindowLatestLap: number; | ||
m_pitStopRejoinPosition: number; | ||
m_steeringAssist: number; | ||
m_brakingAssist: number; | ||
m_gearboxAssist: number; | ||
m_pitAssist: number; | ||
m_pitReleaseAssist: number; | ||
m_ERSAssist: number; | ||
m_DRSAssist: number; | ||
m_dynamicRacingLine: number; | ||
m_dynamicRacingLineType: number; | ||
m_gameMode: number; | ||
m_ruleSet: number; | ||
m_timeOfDay: number; | ||
m_sessionLength: number; | ||
} |