Doesnt crash when there's no data to put in the relative

This commit is contained in:
2025-04-14 22:01:12 +01:00
parent a915484c1b
commit 1ccbea7af5
5 changed files with 185 additions and 125 deletions
+24 -20
View File
@@ -2,21 +2,23 @@ package main
// DataPacket Lens
const (
SpeedLen = 5
GearLen = 3
RpmLen = 6
LapNumberLen = 5
CurrLapTimeLen = 10
LastLapTimeLen = 10
FuelTankLen = 15 // 101.6 / 123.4L
FuelEstLen = 15
SpeedLen = 5
GearLen = 3
RpmLen = 6
LapNumberLen = 5
DeltaToBestLapLen = 6
BestLapTimeLen = 10
CurrLapTimeLen = 10
LastLapTimeLen = 10
FuelTankLen = 15 // 101.6 / 123.4L
FuelEstLen = 15
)
// StandingsLineDataPacket Lens
const (
LapStringLen = 4
DriverNameLen = 24
TimeBehindStringLen = 16
TimeBehindStringLen = 8
)
type GameSource interface {
@@ -44,7 +46,7 @@ type SimulationData struct {
LapCount int32
LapDistPct float32
CurrLapTime [16]byte // Current lap time
LapDelta [16]byte // Delta to selected reference lap
LapDeltaFloat float32
BestLapTime [16]byte // Best lap in session
LastLapTime [16]byte // Last lap time
FuelUsageCurLap float32
@@ -63,14 +65,16 @@ type StandingsLineDataPacket struct {
}
type DataPacket struct {
StartMarker uint8 `binary:"little"`
Speed [SpeedLen]byte `binary:"little"`
Gear [GearLen]byte `binary:"little"`
RPM [RpmLen]byte `binary:"little"`
LapNumber [LapNumberLen]byte `binary:"little"`
CurrLapTime [CurrLapTimeLen]byte `binary:"little"` // Current lap time
LastLapTime [LastLapTimeLen]byte `binary:"little"` // Last lap time
FuelEst [FuelEstLen]byte `binary:"little"`
Standings [5]StandingsLineDataPacket `binary:"little"`
EndMarker uint8 `binary:"little"`
StartMarker uint8 `binary:"little"`
Speed [SpeedLen]byte `binary:"little"`
Gear [GearLen]byte `binary:"little"`
RPM [RpmLen]byte `binary:"little"`
LapNumber [LapNumberLen]byte `binary:"little"`
DeltaToBestLap [DeltaToBestLapLen]byte `binary:"little"`
BestLapTime [BestLapTimeLen]byte `binary:"little"`
CurrLapTime [CurrLapTimeLen]byte `binary:"little"`
LastLapTime [LastLapTimeLen]byte `binary:"little"`
FuelEst [FuelEstLen]byte `binary:"little"`
Standings [5]StandingsLineDataPacket `binary:"little"`
EndMarker uint8 `binary:"little"`
}