public void Silverstone_SecondObject_Has_12_Points()
        {
            var trackData = TrackFactsHelper.GetTrackSilverstone();

            using (var reader = new BinaryReader(MemoryStreamProvider.Open(trackData.Path)))
            {
                reader.BaseStream.Position = 4110;
                var objects = ObjectShapesReader.Read(reader, trackData.KnownOffsets.ObjectData);

                var obj = objects[1];
                obj.Points.Count.Should().Be(12);

                obj.Points[0].X.Should().Be(-960);
                obj.Points[0].Y.Should().Be(12032);
                obj.Points[0].Z.Should().Be(160);

                obj.Points[1].X.Should().Be(-960);
                obj.Points[1].Y.Should().Be(-10496);
                obj.Points[1].Z.Should().Be(160);

                obj.Points[2].X.Should().Be(960);
                obj.Points[2].Y.Should().Be(12032);
                obj.Points[2].Z.Should().Be(1014);

                obj.Points[11].X.Should().Be(960);
                obj.Points[11].Y.Should().Be(-10496);
                obj.Points[11].Z.Should().Be(160);
            }
        }
        public void Silverstone_FirstObject_Has_4_RawPoints()
        {
            var trackData = TrackFactsHelper.GetTrackSilverstone();

            using (var reader = new BinaryReader(MemoryStreamProvider.Open(trackData.Path)))
            {
                reader.BaseStream.Position = 4110;
                var objects = ObjectShapesReader.Read(reader, trackData.KnownOffsets.ObjectData);

                var obj = objects.First();
                obj.RawPoints.Count.Should().Be(4);

                // for X
                // [0] 132 -> Scale 0 negative -> -1536
                // [1]  4 -> Scale 0 positive -> 1536
                // [2] 32768 -> use XY from p[0]
                // [3] 32769 -> use XY from p[1]

                obj.RawPoints[0].XCoord.Should().Be(132);              // F1GP=34
                obj.RawPoints[0].ReferencePointValue.Should().Be(132); // F1GP = 34
                obj.RawPoints[0].ReferencePointFlag.Should().Be(0);
                obj.RawPoints[0].YCoord.Should().Be(0);
                obj.RawPoints[0].ZCoord.Should().Be(0);
                obj.RawPoints[0].Unknown.Should().Be(0);
                obj.RawPoints[1].XCoord.Should().Be(4);      // F1GP = 2
                obj.RawPoints[3].XCoord.Should().Be(-32767); // or 32769 if ushort?
            }
        }
        public void Silverstone_FirstObject_Has_4_Points()
        {
            var trackData = TrackFactsHelper.GetTrackSilverstone();

            using (var reader = new BinaryReader(MemoryStreamProvider.Open(trackData.Path)))
            {
                reader.BaseStream.Position = 4110;
                var objects = ObjectShapesReader.Read(reader, trackData.KnownOffsets.ObjectData);

                var obj = objects.First();
                obj.Points.Count.Should().Be(4);

                obj.Points[0].X.Should().Be(-1536);
                obj.Points[0].Y.Should().Be(0);
                obj.Points[0].Z.Should().Be(0);

                obj.Points[1].X.Should().Be(1536);
                obj.Points[1].Y.Should().Be(0);
                obj.Points[1].Z.Should().Be(0);

                obj.Points[2].X.Should().Be(-1536);
                obj.Points[2].Y.Should().Be(0);
                obj.Points[2].Z.Should().Be(768);

                obj.Points[3].X.Should().Be(1536);
                obj.Points[3].Y.Should().Be(0);
                obj.Points[3].Z.Should().Be(768);
            }
        }
Beispiel #4
0
        public void Read_MontrealTrack_HasExpectedBehaviorData()
        {
            var trackData = TrackFactsHelper.GetTrackMontreal();

            using (var reader = new BinaryReader(MemoryStreamProvider.Open(trackData.Path)))
            {
                var settings = TrackSettingsReader.Read(reader, trackData.KnownComputerCarBehaviorStart);

                settings.LapCount.Should().Be(69);
            }
        }
        public void Silverstone_FirstShape_Has_5_Vectors()
        {
            var trackData = TrackFactsHelper.GetTrackSilverstone();

            using (var reader = new BinaryReader(MemoryStreamProvider.Open(trackData.Path)))
            {
                var objects = ObjectShapesReader.Read(reader, trackData.KnownOffsets.ObjectData);

                var obj = objects.First();
                obj.Vectors.Count.Should().Be(5);
            }
        }
Beispiel #6
0
        public void SilverstoneHeader()
        {
            var trackData = TrackFactsHelper.GetTrackSilverstone();

            using (var reader = new BinaryReader(MemoryStreamProvider.Open(trackData.Path)))
            {
                var header = TrackSectionHeaderReader.Read(reader, trackData.KnownOffsets.TrackData);

                header.PitsSide.Should().Be(TrackSide.Right);

                header.CommandLength0xC5.Should().Be(8);
            }
        }
        public void Monaco_ObjectShapes()
        {
            var trackData = TrackFactsHelper.GetTrackMonaco();

            using (var reader = new BinaryReader(MemoryStreamProvider.Open(trackData.Path)))
            {
                var objects = ObjectShapesReader.Read(reader, trackData.KnownOffsets.ObjectData);

                objects.Count.Should().Be(59);
                objects.First().AllData.Length.Should().Be(1796);
                objects.Last().AllData.Length.Should().Be(740);
            }
        }
        public void Monaco_DataAndHeader_AreSetCorrectly()
        {
            var trackData = TrackFactsHelper.GetTrackMonaco();

            using (var reader = new BinaryReader(MemoryStreamProvider.Open(trackData.Path)))
            {
                var objects = ObjectShapesReader.Read(reader, trackData.KnownOffsets.ObjectData);

                objects.First().HeaderIndex.Should().Be(0);
                objects.First().DataIndex.Should().Be(37);
                objects.Last().HeaderIndex.Should().Be(58);
                objects.Last().DataIndex.Should().Be(58);
            }
        }
        public void Monaco_FirstShape_Has_28_ScaleValues()
        {
            var trackData = TrackFactsHelper.GetTrackMonaco();

            using (var reader = new BinaryReader(MemoryStreamProvider.Open(trackData.Path)))
            {
                var objects = ObjectShapesReader.Read(reader, trackData.KnownOffsets.ObjectData);

                var obj = objects.First();
                obj.ScaleValues.Count.Should().Be(28);
                obj.ScaleValues[0].Should().Be(2860);
                obj.ScaleValues[27].Should().Be(2199);
            }
        }
        public void Silverstone_SecondShape_Has_3_ScaleValues()
        {
            var trackData = TrackFactsHelper.GetTrackSilverstone();

            using (var reader = new BinaryReader(MemoryStreamProvider.Open(trackData.Path)))
            {
                var objects = ObjectShapesReader.Read(reader, trackData.KnownOffsets.ObjectData);

                var obj = objects[1];
                obj.ScaleValues.Count.Should().Be(3);
                obj.ScaleValues[0].Should().Be(960);
                obj.ScaleValues[1].Should().Be(12032);
                obj.ScaleValues[2].Should().Be(10496);
            }
        }
Beispiel #11
0
        public void Read_MontrealTrack_HasExpectedData()
        {
            var trackData = TrackFactsHelper.GetTrackMontreal();

            using (var reader = new BinaryReader(MemoryStreamProvider.Open(trackData.Path)))
            {
                var result = ComputerCarDataReader.Read(reader, trackData.KnownOffsets.ComputerCarSetup);
                var data   = result.ComputerCarData;

                data.GripFactor.Should().Be(16384);
                data.Acceleration.Should().Be(16384);
                data.AirResistance.Should().Be(16384);
                data.FuelLoad.Should().Be(5203);
            }
        }
Beispiel #12
0
        public void MontrealOffsetsReader()
        {
            var trackData = TrackFactsHelper.GetTrackMontreal();

            using (var reader = new BinaryReader(MemoryStreamProvider.Open(trackData.Path)))
            {
                var offsets = OffsetReader.Read(reader);

                offsets.UnknownLong1.Should().Be(trackData.KnownOffsets.UnknownLong1);
                offsets.UnknownLong2.Should().Be(trackData.KnownOffsets.UnknownLong2);
                offsets.ChecksumPosition.Should().Be(trackData.KnownOffsets.ChecksumPosition);
                offsets.ObjectData.Should().Be(trackData.KnownOffsets.ObjectData);
                offsets.TrackData.Should().Be(trackData.KnownOffsets.TrackData);
                offsets.PitLaneData.Should().Be(trackData.KnownOffsets.PitLaneData);
            }
        }
Beispiel #13
0
        public ObjectSettingsReaderFacts()
        {
            var trackDataMontreal = TrackFactsHelper.GetTrackMontreal();

            using (var reader = new BinaryReader(MemoryStreamProvider.Open(trackDataMontreal.Path)))
            {
                _montrealObjectSettings = TrackObjectSettingsReader.Read(reader,
                                                                         trackDataMontreal.KnownOffsets.ObjectData, trackDataMontreal.KnownOffsets.TrackData);
            }

            var trackDataSilverstone = TrackFactsHelper.GetTrackSilverstone();

            using (var reader = new BinaryReader(MemoryStreamProvider.Open(trackDataSilverstone.Path)))
            {
                _silverstoneObjectSettings = TrackObjectSettingsReader.Read(reader,
                                                                            trackDataSilverstone.KnownOffsets.ObjectData, trackDataSilverstone.KnownOffsets.TrackData);
            }
        }
        public void Silverstone_FirstShape_Has_Expected_Offsets()
        {
            var trackData = TrackFactsHelper.GetTrackSilverstone();

            using (var reader = new BinaryReader(MemoryStreamProvider.Open(trackData.Path)))
            {
                var objects = ObjectShapesReader.Read(reader, trackData.KnownOffsets.ObjectData);

                var obj = objects.First();
                obj.Offset1.Should().Be(15638);
                obj.Offset2.Should().Be(15642);
                obj.Offset3.Should().Be(15646);
                obj.Offset4.Should().Be(15682);
                obj.Offset5.Should().Be(15714);
                obj.Offset6.Should().Be(15674);
                obj.Offset7.Should().Be(15734);
            }
        }
Beispiel #15
0
        public void MontrealBestLine()
        {
            var trackData = TrackFactsHelper.GetTrackMontreal();

            using (var reader = new BinaryReader(MemoryStreamProvider.Open(trackData.Path)))
            {
                var bestLines = ComputerCarLineReader.Read(reader, trackData.KnownBestLineSectionDataStart);

                bestLines.Header.LineStartX.Should().Be(4);
                bestLines.Header.LineStartXHigh.Should().Be(208);
                bestLines.Header.LineStartY.Should().Be(0);
                //bestLines.Header.LineStartYHigh.Should().Be(0);
                bestLines.Header.Unknown1.Should().Be(65354);
                bestLines.Header.Unknown2.Should().Be(0);
                bestLines.Header.Unknown3.Should().Be(0);
                bestLines.Header.Unknown4.Should().Be(0);

                var firstSegment = bestLines.Segments[0];
                firstSegment.Length.Should().Be(26);
                firstSegment.Command.Should().Be(0x50);
                firstSegment.SignScale.Should().Be(1);
                firstSegment.Radius.Should().Be(65092);

                var segment2 = bestLines.Segments[1];
                segment2.Length.Should().Be(37);
                segment2.Radius.Should().Be(0);

                var segment3 = bestLines.Segments[2];
                segment3.Correction.Should().Be(185);

                var segment6 = bestLines.Segments[5];
                segment6.Length.Should().Be(17);
                segment6.Command.Should().Be(0x70);
                segment6.Radius.Should().Be(8280);
                segment6.Sign0x70.Should().Be(0);
                segment6.Radius0x70.Should().Be(9650);

                var lastSegment = bestLines.Segments.Last();
                lastSegment.Length.Should().Be(48);
                lastSegment.Command.Should().Be(0x50);
                lastSegment.Radius.Should().Be(48032);
            }
        }
        public void Monaco_LastShape_Has_14_Points()
        {
            var trackData = TrackFactsHelper.GetTrackMonaco();

            using (var reader = new BinaryReader(MemoryStreamProvider.Open(trackData.Path)))
            {
                reader.BaseStream.Position = 4110;
                var objects = ObjectShapesReader.Read(reader, trackData.KnownOffsets.ObjectData);

                var obj = objects.Last();
                obj.Points.Count.Should().Be(14);

                obj.Points[0].X.Should().Be(5120);
                obj.Points[0].Y.Should().Be(10752);
                obj.Points[0].Z.Should().Be(65024);

                obj.Points[13].X.Should().Be(-3584);
                obj.Points[13].Y.Should().Be(10752);
                obj.Points[13].Z.Should().Be(4608);
            }
        }
Beispiel #17
0
        public void Read_MontrealTrack_HasExpectedSetup()
        {
            var trackData = TrackFactsHelper.GetTrackMontreal();

            using (var reader = new BinaryReader(MemoryStreamProvider.Open(trackData.Path)))
            {
                var result = ComputerCarDataReader.Read(reader, trackData.KnownOffsets.ComputerCarSetup);
                var setup  = result.Setup;

                setup.FrontWing.Should().Be(11);
                setup.RearWing.Should().Be(10);
                setup.GearRatio1.Should().Be(28);
                setup.GearRatio2.Should().Be(35);
                setup.GearRatio3.Should().Be(42);
                setup.GearRatio4.Should().Be(49);
                setup.GearRatio5.Should().Be(55);
                setup.GearRatio6.Should().Be(61);
                setup.TyreCompound.Should().Be(SetupTyreCompound.C);
                setup.BrakeBalance.Should().Be(0);
            }
        }
        public TrackSectionReaderFacts()
        {
            var trackDataMontreal = TrackFactsHelper.GetTrackMontreal();

            using (var reader = new BinaryReader(MemoryStreamProvider.Open(trackDataMontreal.Path)))
            {
                _montrealTrackSections = TrackSectionReader.Read(reader, trackDataMontreal.KnownTrackSectionDataStart,
                                                                 new TrackSectionCommandOptions {
                    Command0xC5Length = 7
                });
            }

            var trackDataSilverstone = TrackFactsHelper.GetTrackSilverstone();

            using (var reader = new BinaryReader(MemoryStreamProvider.Open(trackDataSilverstone.Path)))
            {
                _silverstoneTrackSections = TrackSectionReader.Read(reader, trackDataSilverstone.KnownTrackSectionDataStart,
                                                                    new TrackSectionCommandOptions {
                    Command0xC5Length = 8
                });
            }
        }
Beispiel #19
0
        public void MontrealHeader()
        {
            var trackData = TrackFactsHelper.GetTrackMontreal();

            using (var reader = new BinaryReader(MemoryStreamProvider.Open(trackData.Path)))
            {
                var header = TrackSectionHeaderReader.Read(reader, trackData.KnownOffsets.TrackData);

                header.FirstSectionAngle.Should().Be(65354);
                header.FirstSectionHeight.Should().Be(0);
                header.TrackCenterX.Should().Be(13000);
                header.TrackCenterZ.Should().Be(1328);
                header.TrackCenterY.Should().Be(-4299);
                header.StartWidth.Should().Be(1203);

                header.PoleSide.Should().Be(TrackSide.Left);
                header.PitsSide.Should().Be(TrackSide.Left);

                header.CommandLength0xC5.Should().Be(7);

                header.LeftVergeStartWidth.Should().Be(8);
                header.RightVergeStartWidth.Should().Be(20);
            }
        }