Getting car data from api?

Discussion in 'Community Workshop' started by Munty, Jul 8, 2021.

  1. Munty

    Munty New Member

    Joined:
    Jul 18, 2020
    Ratings:
    +4 / 0 / -0
    Hi there. I need some help from someone with previous experience of reading the Memory Block.

    I have the small sample utilities written by sector which are great, I can pull out all the 'player' data, but I can't see any references to 'other' players. All I need is rotation and location.

    Can anyone help?

    Many thanks.
     
  2. OtterNas3

    OtterNas3 Well-Known Member

    Joined:
    Jan 9, 2018
    Ratings:
    +315 / 0 / -0
    The array with all Drivers in the Session, sorted by their Place, is here
    Code:
        namespace Data
        {
            ...
            ..
            .
            [StructLayout(LayoutKind.Sequential, Pack = 1)]
            internal struct Shared
            {
                ...
                ..
                .
                [MarshalAs(UnmanagedType.ByValArray, SizeConst = 128)]
                public DriverData[] DriverData;
            }
        }
    }
    For each Driver in DriverData, the available information would be:
    Code:
            [StructLayout(LayoutKind.Sequential, Pack = 1)]
            internal struct DriverData
            {
                public DriverInfo DriverInfo;
                // Note: See the R3E.Constant.FinishStatus enum
                public Int32 FinishStatus;
                public Int32 Place;
                // Based on performance index
                public Int32 PlaceClass;
                public Single LapDistance;
                public Vector3<Single> Position;
                public Int32 TrackSector;
                public Int32 CompletedLaps;
                public Int32 CurrentLapValid;
                public Single LapTimeCurrentSelf;
                public Sectors<Single> SectorTimeCurrentSelf;
                public Sectors<Single> SectorTimePreviousSelf;
                public Sectors<Single> SectorTimeBestSelf;
                public Single TimeDeltaFront;
                public Single TimeDeltaBehind;
                // Note: See the R3E.Constant.PitStopStatus enum
                public Int32 PitStopStatus;
                public Int32 InPitlane;
    
                public Int32 NumPitstops;
    
                public CutTrackPenalties Penalties;
    
                public Single CarSpeed;
                // Note: See the R3E.Constant.TireType enum
                public Int32 TireTypeFront;
                public Int32 TireTypeRear;
                // Note: See the R3E.Constant.TireSubtype enum
                public Int32 TireSubtypeFront;
                public Int32 TireSubtypeRear;
    
                public Single BasePenaltyWeight;
                public Single AidPenaltyWeight;
    
                // -1 unavailable, 0 = not engaged, 1 = engaged
                public Int32 DrsState;
                public Int32 PtpState;
    
                // -1 unavailable, DriveThrough = 0, StopAndGo = 1, Pitstop = 2, Time = 3, Slowdown = 4, Disqualify = 5,
                public Int32 PenaltyType;
    
                // Based on the PenaltyType you can assume the reason is:
    
                // DriveThroughPenaltyInvalid = 0,
                // DriveThroughPenaltyCutTrack = 1,
                // DriveThroughPenaltyPitSpeeding = 2,
                // DriveThroughPenaltyFalseStart = 3,
                // DriveThroughPenaltyIgnoredBlue = 4,
                // DriveThroughPenaltyDrivingTooSlow = 5,
                // DriveThroughPenaltyIllegallyPassedBeforeGreen = 6,
                // DriveThroughPenaltyIllegallyPassedBeforeFinish = 7,
                // DriveThroughPenaltyIllegallyPassedBeforePitEntrance = 8,
                // DriveThroughPenaltyIgnoredSlowDown = 9,
                // DriveThroughPenaltyMax = 10
    
                // StopAndGoPenaltyInvalid = 0,
                // StopAndGoPenaltyCutTrack1st = 1,
                // StopAndGoPenaltyCutTrackMult = 2,
                // StopAndGoPenaltyYellowFlagOvertake = 3,
                // StopAndGoPenaltyMax = 4
    
                // PitstopPenaltyInvalid = 0,
                // PitstopPenaltyIgnoredPitstopWindow = 1,
                // PitstopPenaltyMax = 2
    
                // ServableTimePenaltyInvalid = 0,
                // ServableTimePenaltyServedMandatoryPitstopLate = 1,
                // ServableTimePenaltyIgnoredMinimumPitstopDuration = 2,
                // ServableTimePenaltyMax = 3
    
                // SlowDownPenaltyInvalid = 0,
                // SlowDownPenaltyCutTrack1st = 1,
                // SlowDownPenaltyCutTrackMult = 2,
                // SlowDownPenaltyMax = 3
    
                // DisqualifyPenaltyInvalid = -1,
                // DisqualifyPenaltyFalseStart = 0,
                // DisqualifyPenaltyPitlaneSpeeding = 1,
                // DisqualifyPenaltyWrongWay = 2,
                // DisqualifyPenaltyEnteringPitsUnderRed = 3,
                // DisqualifyPenaltyExitingPitsUnderRed = 4,
                // DisqualifyPenaltyFailedDriverChange = 5,
                // DisqualifyPenaltyThreeDriveThroughsInLap = 6,
                // DisqualifyPenaltyLappedFieldMultipleTimes = 7,
                // DisqualifyPenaltyIgnoredDriveThroughPenalty = 8,
                // DisqualifyPenaltyIgnoredStopAndGoPenalty = 9,
                // DisqualifyPenaltyIgnoredPitStopPenalty = 10,
                // DisqualifyPenaltyIgnoredTimePenalty = 11,
                // DisqualifyPenaltyExcessiveCutting = 12,
                // DisqualifyPenaltyIgnoredBlueFlag = 13,
                // DisqualifyPenaltyMax = 14
                public Int32 PenaltyReason;
       
                // -1 unavailable, 0 = ignition off, 1 = ignition on but not running, 2 = ignition on and running
                public Int32 EngineState;
    
                // Reserved data
                public Int32 Unused1;
                public Single Unused2;
                public Single Unused3;
            }