public override void LoadBytes(byte[] bytes) { ByteArrayManager BAM = new ByteArrayManager(bytes); base.LoadBytes(BAM.NextBytes(24)); //Load header int t = 0; List <CarTelemetryData> TelDatas = new List <CarTelemetryData>(); for (t = 1; t <= 22; t++) { TelDatas.Add(CarTelemetryData.Create(BAM.NextBytes(58))); } FieldTelemetryData = TelDatas.ToArray(); //Button status ButtonStatus = BitConverter.ToInt32(BAM.NextBytes(4), 0); //MFD Panel Index MfdPanelIndex = BAM.NextByte(); //Secndary player mfd panel index SecondaryPlayerMfdPanelIndex = BAM.NextByte(); //Suggested gear SuggestedGear = BAM.NextByte(); }
public static ParticipantData Create(byte[] bytes) { ParticipantData ReturnInstance = new ParticipantData(); ByteArrayManager BAM = new ByteArrayManager(bytes); //Get AI controlled byte nb = BAM.NextByte(); if (nb == 0) { ReturnInstance.IsAiControlled = false; } else if (nb == 1) { ReturnInstance.IsAiControlled = true; } //Get piloting driver ReturnInstance.PilotingDriver = CodemastersToolkit.GetDriverFromDriverId(BAM.NextByte(), Game.F1_2019); //Get Team ReturnInstance.ManufacturingTeam = CodemastersToolkit.GetTeamFromTeamId(BAM.NextByte(), Game.F1_2019); //Get race number ReturnInstance.CarRaceNumber = BAM.NextByte(); //Get nationallity ID ReturnInstance.NationalityId = BAM.NextByte(); //Get name string FullName = ""; int t = 1; for (t = 1; t <= 48; t++) { char ThisChar = Convert.ToChar(BAM.NextByte()); FullName = FullName + ThisChar.ToString(); } ReturnInstance.Name = FullName.Trim(); //Get telemetry private or not. nb = BAM.NextByte(); if (nb == 0) { ReturnInstance.TelemetryPrivate = false; } else if (nb == 1) { ReturnInstance.TelemetryPrivate = true; } return(ReturnInstance); }
public static MarshallZone Create(byte[] bytes) { MarshallZone ReturnInstance = new MarshallZone(); ByteArrayManager BAM = new ByteArrayManager(bytes); //Get zone start ReturnInstance.ZoneStart = BitConverter.ToSingle(BAM.NextBytes(4), 0); //Get zone flag byte nb = BAM.NextByte(); if (nb == 0) { ReturnInstance.ZoneFlag = FiaFlag.None; } else if (nb == 1) { ReturnInstance.ZoneFlag = FiaFlag.Green; } else if (nb == 2) { ReturnInstance.ZoneFlag = FiaFlag.Blue; } else if (nb == 3) { ReturnInstance.ZoneFlag = FiaFlag.Yellow; } else if (nb == 4) { ReturnInstance.ZoneFlag = FiaFlag.Red; } return(ReturnInstance); }
public override void LoadBytes(byte[] bytes) { ByteArrayManager BAM = new ByteArrayManager(bytes); //Load header base.LoadBytes(BAM.NextBytes(24)); this.NumPlayers = BAM.NextByte(); this.LobbyPlayers = new LobbyInfoData[22]; for (int i = 0; i < 22; i++) { var lobbyInfoData = new LobbyInfoData { AiControlled = BAM.NextByte() == 1, TeamId = CodemastersToolkit.GetTeamFromTeamId(BAM.NextByte()), Nationality = BAM.NextByte(), Name = "" }; for (var t = 1; t <= 48; t++) { var currentChar = Convert.ToChar(BAM.NextByte()); lobbyInfoData.Name += currentChar.ToString(); } var readyStatusByte = BAM.NextByte(); lobbyInfoData.ReadyStatus = readyStatusByte == 0 ? ReadyStatus.NotReady : readyStatusByte == 1 ? ReadyStatus.Ready : ReadyStatus.Spectating; this.LobbyPlayers[i] = lobbyInfoData; } }
public override void LoadBytes(byte[] bytes) { ByteArrayManager BAM = new ByteArrayManager(bytes); base.LoadBytes(BAM.NextBytes(23)); NumberOfActiveCars = BAM.NextByte(); List <ParticipantData> PDs = new List <ParticipantData>(); int t = 1; for (t = 1; t <= 20; t++) { PDs.Add(ParticipantData.Create(BAM.NextBytes(54))); } FieldParticipantData = PDs.ToArray(); }
public override void LoadBytes(byte[] bytes) { ByteArrayManager BAM = new ByteArrayManager(bytes); //Get header base.LoadBytes(BAM.NextBytes(24)); //Get number of cars NumberOfCars = BAM.NextByte(); //Get Final Classification Data List <FinalClassificationData> fcdata = new List <FinalClassificationData>(); // int t = 0; for (int t = 0; t < 22; t++) { fcdata.Add(FinalClassificationData.Create(BAM.NextBytes(37))); } FieldClassificationData = fcdata.ToArray(); }
public override void LoadBytes(byte[] bytes) { ByteArrayManager BAM = new ByteArrayManager(bytes); //Load header base.LoadBytes(BAM.NextBytes(24)); //Get weather byte nb = BAM.NextByte(); if (nb == 0) { CurrentWeatherCondition = WeatherCondition.Clear; } else if (nb == 1) { CurrentWeatherCondition = WeatherCondition.LightClouds; } else if (nb == 2) { CurrentWeatherCondition = WeatherCondition.Overcast; } else if (nb == 3) { CurrentWeatherCondition = WeatherCondition.LightRain; } else if (nb == 4) { CurrentWeatherCondition = WeatherCondition.HeavyRain; } else if (nb == 5) { CurrentWeatherCondition = WeatherCondition.Storm; } //Get track temperature TrackTemperatureCelsius = BAM.NextByte(); //Get air temperature AirTemperatureCelsius = BAM.NextByte(); //Get total laps TotalLapsInRace = BAM.NextByte(); //get track length TrackLengthMeters = BitConverter.ToUInt16(BAM.NextBytes(2), 0); //Get session type nb = BAM.NextByte(); if (nb == 0) { SessionTypeMode = SessionType.Unknown; } else if (nb == 1) { SessionTypeMode = SessionType.Practice1; } else if (nb == 2) { SessionTypeMode = SessionType.Practice2; } else if (nb == 3) { SessionTypeMode = SessionType.Practice3; } else if (nb == 4) { SessionTypeMode = SessionType.ShortPractice; } else if (nb == 5) { SessionTypeMode = SessionType.Qualifying1; } else if (nb == 6) { SessionTypeMode = SessionType.Qualifying2; } else if (nb == 7) { SessionTypeMode = SessionType.Qualifying3; } else if (nb == 8) { SessionTypeMode = SessionType.ShortPractice; } else if (nb == 9) { SessionTypeMode = SessionType.OneShotQualifying; } else if (nb == 10) { SessionTypeMode = SessionType.Race; } else if (nb == 11) { SessionTypeMode = SessionType.Race2; } else if (nb == 12) { SessionTypeMode = SessionType.TimeTrial; } //Get track SessionTrack = CodemastersToolkit.GetTrackFromTrackId(BAM.NextByte()); //Get formula nb = BAM.NextByte(); if (nb == 0) { Formula = FormulaType.Formula1Modern; } else if (nb == 1) { Formula = FormulaType.Formula1Classic; } else if (nb == 2) { Formula = FormulaType.Formula2; } else if (nb == 3) { Formula = FormulaType.Formula1Generic; } //Get session time left SessionTimeLeft = BitConverter.ToUInt16(BAM.NextBytes(2), 0); //Get session duration SessionDuration = BitConverter.ToUInt16(BAM.NextBytes(2), 0); //Get pit speed limit PitSpeedLimitKph = BAM.NextByte(); //get game paused nb = BAM.NextByte(); if (nb == 0) { GamePaused = false; } else if (nb == 1) { GamePaused = true; } //Get is spectating nb = BAM.NextByte(); if (nb == 0) { IsSpectating = false; } else if (nb == 1) { IsSpectating = true; } //Get spectating car index CarIndexBeingSpectated = BAM.NextByte(); //Get sli pro native support nb = BAM.NextByte(); if (nb == 0) { SliProNativeSupport = false; } else if (nb == 1) { SliProNativeSupport = true; } //Get number of marshall zones NumberOfMarshallZones = BAM.NextByte(); //Get marshall zones List <MarshallZone> MZs = new List <MarshallZone>(); int t = 1; for (t = 1; t <= 21; t++) { MZs.Add(MarshallZone.Create(BAM.NextBytes(5))); } //Get safety car status nb = BAM.NextByte(); if (nb == 0) { CurrentSafetyCarStatus = SafetyCarStatus.None; } else if (nb == 1) { CurrentSafetyCarStatus = SafetyCarStatus.Full; } else if (nb == 2) { CurrentSafetyCarStatus = SafetyCarStatus.Virtual; } //Get network game boolean nb = BAM.NextByte(); if (nb == 0) { IsNetworkGame = false; } else if (nb == 1) { IsNetworkGame = true; } //Get number of weather forecast samples NumberOfWeatherForecastSamples = BAM.NextByte(); //Get the next 20 weather forecast samples List <WeatherForecastSample> wfss = new List <WeatherForecastSample>(); t = 0; for (t = 0; t < 20; t++) { wfss.Add(WeatherForecastSample.Create(BAM.NextBytes(5))); } WeatherForecastSamples = wfss.ToArray(); }
public static WeatherForecastSample Create(byte[] bytes) { WeatherForecastSample ToReturn = new WeatherForecastSample(); ByteArrayManager BAM = new ByteArrayManager(bytes); //Get session type byte nb = BAM.NextByte(); if (nb == 0) { ToReturn.SessionTypeMode = SessionType.Unknown; } else if (nb == 1) { ToReturn.SessionTypeMode = SessionType.Practice1; } else if (nb == 2) { ToReturn.SessionTypeMode = SessionType.Practice2; } else if (nb == 3) { ToReturn.SessionTypeMode = SessionType.Practice3; } else if (nb == 4) { ToReturn.SessionTypeMode = SessionType.ShortPractice; } else if (nb == 5) { ToReturn.SessionTypeMode = SessionType.Qualifying1; } else if (nb == 6) { ToReturn.SessionTypeMode = SessionType.Qualifying2; } else if (nb == 7) { ToReturn.SessionTypeMode = SessionType.Qualifying3; } else if (nb == 8) { ToReturn.SessionTypeMode = SessionType.ShortPractice; } else if (nb == 9) { ToReturn.SessionTypeMode = SessionType.OneShotQualifying; } else if (nb == 10) { ToReturn.SessionTypeMode = SessionType.Race; } else if (nb == 11) { ToReturn.SessionTypeMode = SessionType.Race2; } else if (nb == 12) { ToReturn.SessionTypeMode = SessionType.TimeTrial; } //Get time offset ToReturn.TimeOffSet = BAM.NextByte(); //Get weather nb = BAM.NextByte(); if (nb == 0) { ToReturn.ForecastedWeatherCondition = WeatherCondition.Clear; } else if (nb == 1) { ToReturn.ForecastedWeatherCondition = WeatherCondition.LightClouds; } else if (nb == 2) { ToReturn.ForecastedWeatherCondition = WeatherCondition.Overcast; } else if (nb == 3) { ToReturn.ForecastedWeatherCondition = WeatherCondition.LightRain; } else if (nb == 4) { ToReturn.ForecastedWeatherCondition = WeatherCondition.HeavyRain; } else if (nb == 5) { ToReturn.ForecastedWeatherCondition = WeatherCondition.Storm; } //Get track temperature ToReturn.TrackTemperatureCelsius = BAM.NextByte(); //Get air temperature ToReturn.AirTemperatureCelsius = BAM.NextByte(); return(ToReturn); }
public static LapData Create(byte[] bytes) { LapData ReturnInstance = new LapData(); ByteArrayManager BAM = new ByteArrayManager(bytes); ReturnInstance.LastLapTime = BitConverter.ToSingle(BAM.NextBytes(4), 0); ReturnInstance.CurrentLapTime = BitConverter.ToSingle(BAM.NextBytes(4), 0); ReturnInstance.Sector1TimeMilliseconds = BitConverter.ToUInt16(BAM.NextBytes(2), 0); ReturnInstance.Sector2TimeMilliseconds = BitConverter.ToUInt16(BAM.NextBytes(2), 0); ReturnInstance.BestLapTimeSeconds = BitConverter.ToSingle(BAM.NextBytes(4), 0); ReturnInstance.BestLapNumber = BAM.NextByte(); ReturnInstance.BestLapSector1TimeMilliseconds = BitConverter.ToUInt16(BAM.NextBytes(2), 0); ReturnInstance.BestLapSector2TimeMilliseconds = BitConverter.ToUInt16(BAM.NextBytes(2), 0); ReturnInstance.BestLapSector3TimeMilliseconds = BitConverter.ToUInt16(BAM.NextBytes(2), 0); ReturnInstance.BestOverallSector1TimeMilliseconds = BitConverter.ToUInt16(BAM.NextBytes(2), 0); ReturnInstance.BestOverallSector1TimeLapNumber = BAM.NextByte(); ReturnInstance.BestOverallSector2TimeMilliseconds = BitConverter.ToUInt16(BAM.NextBytes(2), 0); ReturnInstance.BestOverallSector2TimeLapNumber = BAM.NextByte(); ReturnInstance.BestOverallSector3TimeMilliseconds = BitConverter.ToUInt16(BAM.NextBytes(2), 0); ReturnInstance.BestOverallSector3TimeLapNumber = BAM.NextByte(); ReturnInstance.LapDistance = BitConverter.ToSingle(BAM.NextBytes(4), 0); ReturnInstance.TotalDistance = BitConverter.ToSingle(BAM.NextBytes(4), 0); ReturnInstance.SafetyCarDelta = BitConverter.ToSingle(BAM.NextBytes(4), 0); ReturnInstance.CarPosition = BAM.NextByte(); ReturnInstance.CurrentLapNumber = BAM.NextByte(); //Get pit status byte nb = BAM.NextByte(); if (nb == 0) { ReturnInstance.CurrentPitStatus = PitStatus.OnTrack; } else if (nb == 1) { ReturnInstance.CurrentPitStatus = PitStatus.PitLane; } else if (nb == 2) { ReturnInstance.CurrentPitStatus = PitStatus.PitArea; } //Get sector ReturnInstance.Sector = System.Convert.ToByte(BAM.NextByte() + 1); //Get current lap invalid nb = BAM.NextByte(); if (nb == 0) { ReturnInstance.CurrentLapInvalid = false; } else if (nb == 1) { ReturnInstance.CurrentLapInvalid = true; } //Get penalties ReturnInstance.Penalties = BAM.NextByte(); //Get grid position ReturnInstance.StartingGridPosition = BAM.NextByte(); //Get driver status nb = BAM.NextByte(); if (nb == 0) { ReturnInstance.CurrentDriverStatus = DriverStatus.InGarage; } else if (nb == 1) { ReturnInstance.CurrentDriverStatus = DriverStatus.FlyingLap; } else if (nb == 2) { ReturnInstance.CurrentDriverStatus = DriverStatus.InLap; } else if (nb == 3) { ReturnInstance.CurrentDriverStatus = DriverStatus.OutLap; } else if (nb == 4) { ReturnInstance.CurrentDriverStatus = DriverStatus.OnTrack; } //Get result status nb = BAM.NextByte(); if (nb == 0) { ReturnInstance.FinalResultStatus = ResultStatus.Invalid; } else if (nb == 1) { ReturnInstance.FinalResultStatus = ResultStatus.Inactive; } else if (nb == 2) { ReturnInstance.FinalResultStatus = ResultStatus.Active; } else if (nb == 3) { ReturnInstance.FinalResultStatus = ResultStatus.Finished; } else if (nb == 4) { ReturnInstance.FinalResultStatus = ResultStatus.Disqualified; } else if (nb == 5) { ReturnInstance.FinalResultStatus = ResultStatus.NotClassified; } else if (nb == 6) { ReturnInstance.FinalResultStatus = ResultStatus.Retired; } return(ReturnInstance); }
/// <summary> /// Takes 56 bytes /// </summary> /// <param name="bytes"></param> /// <returns></returns> public static CarStatusData CreateFromBytes(byte[] bytes) { CarStatusData ToReturn = new CarStatusData(); ByteArrayManager bam = new ByteArrayManager(bytes); byte nb = 0; //Traction control nb = bam.NextByte(); if (nb == 0) { ToReturn.TractionControlStatus = TractionControlLevel.Off; } else if (nb == 1) { ToReturn.TractionControlStatus = TractionControlLevel.Low; } else if (nb == 2) { ToReturn.TractionControlStatus = TractionControlLevel.High; } else { ToReturn.TractionControlStatus = TractionControlLevel.Off; } //Anti-lock brakes if (bam.NextByte() == 1) { ToReturn.AntiLockBrakesOn = true; } else { ToReturn.AntiLockBrakesOn = false; } //Fuel mix nb = bam.NextByte(); if (nb == 0) { ToReturn.SelectedFuelMix = FuelMix.Lean; } else if (nb == 1) { ToReturn.SelectedFuelMix = FuelMix.Standard; } else if (nb == 2) { ToReturn.SelectedFuelMix = FuelMix.Rich; } else if (nb == 3) { ToReturn.SelectedFuelMix = FuelMix.Max; } //Front Brake bias percentage ToReturn.FrontBrakeBiasPercentage = bam.NextByte(); //Pit limiter if (bam.NextByte() == 1) { ToReturn.PitLimiterOn = true; } else { ToReturn.PitLimiterOn = false; } //Fuel in tank ToReturn.FuelLevel = BitConverter.ToSingle(bam.NextBytes(4), 0); //Fuel capacity ToReturn.FuelCapacity = BitConverter.ToSingle(bam.NextBytes(4), 0); //Fuel remaining laps ToReturn.FuelRemainingLaps = BitConverter.ToSingle(bam.NextBytes(4), 0); //Max RPM ToReturn.MaxRpm = BitConverter.ToUInt16(bam.NextBytes(2), 0); //Idle RPM ToReturn.IdleRpm = BitConverter.ToUInt16(bam.NextBytes(2), 0); //Max gears ToReturn.MaxGears = bam.NextByte(); //DRS allowed nb = bam.NextByte(); if (nb == 1) { ToReturn.DrsAllowed = true; } else { ToReturn.DrsAllowed = false; } //DRS activation distance ToReturn.DrsActivationDistance = BitConverter.ToUInt16(bam.NextBytes(2), 0); //Tyre Wear ToReturn.TyreWearPercentage = new WheelDataArray(); ToReturn.TyreWearPercentage.FrontLeft = Convert.ToSingle(bam.NextByte()); ToReturn.TyreWearPercentage.FrontRight = Convert.ToSingle(bam.NextByte()); ToReturn.TyreWearPercentage.RearLeft = Convert.ToSingle(bam.NextByte()); ToReturn.TyreWearPercentage.RearRight = Convert.ToSingle(bam.NextByte()); //Tyre Compound nb = bam.NextByte(); if (nb == 16) { ToReturn.EquippedTyreCompound = TyreCompound.C5; } else if (nb == 17) { ToReturn.EquippedTyreCompound = TyreCompound.C4; } else if (nb == 18) { ToReturn.EquippedTyreCompound = TyreCompound.C3; } else if (nb == 19) { ToReturn.EquippedTyreCompound = TyreCompound.C2; } else if (nb == 20) { ToReturn.EquippedTyreCompound = TyreCompound.C1; } else if (nb == 7) { ToReturn.EquippedTyreCompound = TyreCompound.Inter; } else if (nb == 8) { ToReturn.EquippedTyreCompound = TyreCompound.Wet; } //Tyre visual compound ToReturn.EquippedVisualTyreCompoundId = bam.NextByte(); //Tyre age in laps ToReturn.TyreAgeLaps = bam.NextByte(); //Tyre damage ToReturn.TyreDamagePercentage = new WheelDataArray(); ToReturn.TyreDamagePercentage.FrontLeft = Convert.ToSingle(bam.NextByte()); ToReturn.TyreDamagePercentage.FrontRight = Convert.ToSingle(bam.NextByte()); ToReturn.TyreDamagePercentage.RearLeft = Convert.ToSingle(bam.NextByte()); ToReturn.TyreDamagePercentage.RearRight = Convert.ToSingle(bam.NextByte()); //Front left wing damage ToReturn.FrontLeftWingDamagePercent = bam.NextByte(); //Front right wing damage ToReturn.FrontRightWingDamagePercent = bam.NextByte(); //Rear wing damage ToReturn.RearWingDamagePercent = bam.NextByte(); //DRS failure nb = bam.NextByte(); if (nb == 0) { ToReturn.DrsFailure = false; } else { ToReturn.DrsFailure = true; } //Engine damage ToReturn.EngineDamagePercent = bam.NextByte(); //Gear box damage ToReturn.GearBoxDamagePercent = bam.NextByte(); //FIA Vehicle Flag sbyte fiavf = Convert.ToSByte(bam.NextByte()); if (fiavf == -1) { ToReturn.VehicleFiaFlag = FiaFlag.Unknown; } else if (fiavf == 0) { ToReturn.VehicleFiaFlag = FiaFlag.None; } else if (fiavf == 1) { ToReturn.VehicleFiaFlag = FiaFlag.Green; } else if (fiavf == 2) { ToReturn.VehicleFiaFlag = FiaFlag.Blue; } else if (fiavf == 3) { ToReturn.VehicleFiaFlag = FiaFlag.Yellow; } else if (fiavf == 4) { ToReturn.VehicleFiaFlag = FiaFlag.Red; } //Ers Store energy ToReturn.ErsStoredEnergyJoules = BitConverter.ToSingle(bam.NextBytes(4), 0); //Ers deploy mode nb = bam.NextByte(); if (nb == 0) { ToReturn.SelectedErsDeployMode = ErsDeployMode.None; } else if (nb == 1) { ToReturn.SelectedErsDeployMode = ErsDeployMode.Medium; } else if (nb == 2) { ToReturn.SelectedErsDeployMode = ErsDeployMode.Overtake; } else if (nb == 3) { ToReturn.SelectedErsDeployMode = ErsDeployMode.HotLap; } //Ers Harvested this lap by MGUK ToReturn.ErsHarvestedThisLapByMGUK = BitConverter.ToSingle(bam.NextBytes(4), 0); //Ers harvested this lap by MGUH ToReturn.ErsHarvestedThisLapByMGUH = BitConverter.ToSingle(bam.NextBytes(4), 0); //Ers deployed this lap ToReturn.ErsDeployedThisLap = BitConverter.ToSingle(bam.NextBytes(4), 0); return(ToReturn); }
} //New to F1 2020. The index of the secondayr player's car (splitscreen). 255 if no second player. public virtual void LoadBytes(byte[] bytes) { ByteArrayManager BAM = new ByteArrayManager(bytes); List <byte> ToConvert = new List <byte>(); //Get packet format. ToConvert.Add(BAM.NextByte()); ToConvert.Add(BAM.NextByte()); ushort i = BitConverter.ToUInt16(ToConvert.ToArray(), 0); PacketFormat = i; ToConvert.Clear(); //Get major version GameMajorVersion = BAM.NextByte(); //Get minor version GameMinorVersion = BAM.NextByte(); //Get packet version PacketVersion = BAM.NextByte(); //Get packet type byte PackVer = BAM.NextByte(); if (PackVer == 0) { PacketType = PacketType.Motion; } else if (PackVer == 1) { PacketType = PacketType.Session; } else if (PackVer == 2) { PacketType = PacketType.Lap; } else if (PackVer == 3) { PacketType = PacketType.Event; } else if (PackVer == 4) { PacketType = PacketType.Participants; } else if (PackVer == 5) { PacketType = PacketType.CarSetup; } else if (PackVer == 6) { PacketType = PacketType.CarTelemetry; } else if (PackVer == 7) { PacketType = PacketType.CarStatus; } else if (PackVer == 8) { PacketType = PacketType.FinalClassification; } else if (PackVer == 9) { PacketType = PacketType.LobbyInfo; } //Get unique session ID ToConvert.Clear(); ToConvert.Add(BAM.NextByte()); ToConvert.Add(BAM.NextByte()); ToConvert.Add(BAM.NextByte()); ToConvert.Add(BAM.NextByte()); ToConvert.Add(BAM.NextByte()); ToConvert.Add(BAM.NextByte()); ToConvert.Add(BAM.NextByte()); ToConvert.Add(BAM.NextByte()); UniqueSessionId = BitConverter.ToUInt64(ToConvert.ToArray(), 0); ToConvert.Clear(); //Get session time SessionTime = BitConverter.ToSingle(BAM.NextBytes(4), 0); //Get frame identifier FrameIdentifier = BitConverter.ToUInt32(BAM.NextBytes(4), 0); //Get player car index PlayerCarIndex = BAM.NextByte(); //Get secondary player car index SecondaryPlayerCarIndex = BAM.NextByte(); }
public static CarTelemetryData Create(byte[] bytes) { CarTelemetryData ReturnInstance = new CarTelemetryData(); ByteArrayManager BAM = new ByteArrayManager(bytes); //Get speed ReturnInstance.SpeedKph = BitConverter.ToUInt16(BAM.NextBytes(2), 0); double MPH = ReturnInstance.SpeedKph * 0.621371; ReturnInstance.SpeedMph = (ushort)MPH; //Get throttle ReturnInstance.Throttle = BitConverter.ToSingle(BAM.NextBytes(4), 0); //Get steer ReturnInstance.Steer = BitConverter.ToSingle(BAM.NextBytes(4), 0); //Get brake ReturnInstance.Brake = BitConverter.ToSingle(BAM.NextBytes(4), 0); //Get clutch ReturnInstance.Clutch = BAM.NextByte(); //Get gear ReturnInstance.Gear = (sbyte)BAM.NextByte(); //Get engine RMP ReturnInstance.EngineRpm = BitConverter.ToUInt16(BAM.NextBytes(2), 0); //Drs on or not byte nb = BAM.NextByte(); if (nb == 0) { ReturnInstance.DrsActive = false; } else if (nb == 1) { ReturnInstance.DrsActive = true; } //Get engine rev lights percentage ReturnInstance.RevLightsPercentage = BAM.NextByte(); //get brake temperature ReturnInstance.BrakeTemperature = new WheelDataArray(); ReturnInstance.BrakeTemperature.RearLeft = (float)BitConverter.ToUInt16(BAM.NextBytes(2), 0); ReturnInstance.BrakeTemperature.RearRight = (float)BitConverter.ToUInt16(BAM.NextBytes(2), 0); ReturnInstance.BrakeTemperature.FrontLeft = (float)BitConverter.ToUInt16(BAM.NextBytes(2), 0); ReturnInstance.BrakeTemperature.FrontRight = (float)BitConverter.ToUInt16(BAM.NextBytes(2), 0); //get tyre surface temperature ReturnInstance.TyreSurfaceTemperature = new WheelDataArray(); ReturnInstance.TyreSurfaceTemperature.RearLeft = (float)BAM.NextByte(); ReturnInstance.TyreSurfaceTemperature.RearRight = (float)BAM.NextByte(); ReturnInstance.TyreSurfaceTemperature.FrontLeft = (float)BAM.NextByte(); ReturnInstance.TyreSurfaceTemperature.FrontRight = (float)BAM.NextByte(); //get tyre Inner Temperature ReturnInstance.TyreInnerTemperature = new WheelDataArray(); ReturnInstance.TyreInnerTemperature.RearLeft = (float)BAM.NextByte(); ReturnInstance.TyreInnerTemperature.RearRight = (float)BAM.NextByte(); ReturnInstance.TyreInnerTemperature.FrontLeft = (float)BAM.NextByte(); ReturnInstance.TyreInnerTemperature.FrontRight = (float)BAM.NextByte(); //Get engine temperature ReturnInstance.EngineTemperature = BitConverter.ToUInt16(BAM.NextBytes(2), 0); //Get tyre pressure ReturnInstance.TyrePressure = new WheelDataArray(); ReturnInstance.TyrePressure.RearLeft = BitConverter.ToSingle(BAM.NextBytes(4), 0); ReturnInstance.TyrePressure.RearRight = BitConverter.ToSingle(BAM.NextBytes(4), 0); ReturnInstance.TyrePressure.FrontLeft = BitConverter.ToSingle(BAM.NextBytes(4), 0); ReturnInstance.TyrePressure.FrontRight = BitConverter.ToSingle(BAM.NextBytes(4), 0); //Get surface type ReturnInstance.SurfaceType_RearLeft = CodemastersToolkit.GetSurfaceTypeFromSurfaceTypeId(BAM.NextByte()); ReturnInstance.SurfaceType_RearRight = CodemastersToolkit.GetSurfaceTypeFromSurfaceTypeId(BAM.NextByte()); ReturnInstance.SurfaceType_FrontLeft = CodemastersToolkit.GetSurfaceTypeFromSurfaceTypeId(BAM.NextByte()); ReturnInstance.SurfaceType_FrontRight = CodemastersToolkit.GetSurfaceTypeFromSurfaceTypeId(BAM.NextByte()); return(ReturnInstance); }
public static FinalClassificationData Create(byte[] bytes) { FinalClassificationData ToReturn = new FinalClassificationData(); ByteArrayManager BAM = new ByteArrayManager(bytes); //Finishing position ToReturn.FinishingPosition = BAM.NextByte(); //Number of laps ToReturn.NumberOfLaps = BAM.NextByte(); //Starting grid position ToReturn.StartingGridPosition = BAM.NextByte(); //Points scored ToReturn.PointsScored = BAM.NextByte(); //Number of pit stops ToReturn.NumberOfPitStops = BAM.NextByte(); //Result status byte nb = BAM.NextByte(); if (nb == 0) { ToReturn.FinalResultStatus = ResultStatus.Invalid; } else if (nb == 1) { ToReturn.FinalResultStatus = ResultStatus.Inactive; } else if (nb == 2) { ToReturn.FinalResultStatus = ResultStatus.Active; } else if (nb == 3) { ToReturn.FinalResultStatus = ResultStatus.Finished; } else if (nb == 4) { ToReturn.FinalResultStatus = ResultStatus.Disqualified; } else if (nb == 5) { ToReturn.FinalResultStatus = ResultStatus.NotClassified; } else if (nb == 6) { ToReturn.FinalResultStatus = ResultStatus.Retired; } //Best lap time in seconds ToReturn.BestLapTimeSeconds = BitConverter.ToSingle(BAM.NextBytes(4), 0); //Total race time in seconds ToReturn.TotalRaceTimeSeconds = BitConverter.ToDouble(BAM.NextBytes(8), 0); //Penalties time in seconds ToReturn.PenaltiesTimeSeconds = BAM.NextByte(); //Number of tyre stints ToReturn.NumberOfTyreStints = BAM.NextByte(); // F1 Modern - 16 = C5, 17 = C4, 18 = C3, 19 = C2, 20 = C1 // 7 = inter, 8 = wet // F1 Classic - 9 = dry, 10 = wet // F2 – 11 = super soft, 12 = soft, 13 = medium, 14 = hard // 15 = wet ToReturn.TyreStintsActual = new byte[8]; for (int i = 0; i < 8; i++) { ToReturn.TyreStintsActual[i] = BAM.NextByte(); } // F1 visual (can be different from actual compound) // 16 = soft, 17 = medium, 18 = hard, 7 = inter, 8 = wet // F1 Classic – same as above // F2 – same as above ToReturn.TyreStintsVisual = new byte[8]; for (int i = 0; i < 8; i++) { ToReturn.TyreStintsVisual[i] = BAM.NextByte(); } return(ToReturn); }
//Skipping tyre stints actual //Skipping tyre stints visual public static FinalClassificationData Create(byte[] bytes) { FinalClassificationData ToReturn = new FinalClassificationData(); ByteArrayManager BAM = new ByteArrayManager(bytes); //Finishing position ToReturn.FinishingPosition = BAM.NextByte(); //Number of laps ToReturn.NumberOfLaps = BAM.NextByte(); //Starting grid position ToReturn.StartingGridPosition = BAM.NextByte(); //Points scored ToReturn.PointsScored = BAM.NextByte(); //Number of pit stops ToReturn.NumberOfPitStops = BAM.NextByte(); //Result status byte nb = BAM.NextByte(); if (nb == 0) { ToReturn.FinalResultStatus = ResultStatus.Invalid; } else if (nb == 1) { ToReturn.FinalResultStatus = ResultStatus.Inactive; } else if (nb == 2) { ToReturn.FinalResultStatus = ResultStatus.Active; } else if (nb == 3) { ToReturn.FinalResultStatus = ResultStatus.Finished; } else if (nb == 4) { ToReturn.FinalResultStatus = ResultStatus.Disqualified; } else if (nb == 5) { ToReturn.FinalResultStatus = ResultStatus.NotClassified; } else if (nb == 6) { ToReturn.FinalResultStatus = ResultStatus.Retired; } //Best lap time in seconds ToReturn.BestLapTimeSeconds = BitConverter.ToSingle(BAM.NextBytes(4), 0); //Total race time in seconds ToReturn.TotalRaceTimeSeconds = BitConverter.ToDouble(BAM.NextBytes(8), 0); //Penalties time in seconds ToReturn.PenaltiesTimeSeconds = BAM.NextByte(); //Number of tyre stints ToReturn.NumberOfTyreStints = BAM.NextByte(); return(ToReturn); }